Without counters this will all have to be done in software. Use a comparison to determine if the state has changed from low to high and vice versa. Count the number of samples that occur between these changes in state. The numbers of high samples and the number of low samples are enough. Keeping track of the count and clearing it between buffer reads will be the only tricky part.