[theora-dev] further debugging of my ogg/theora decoder

Ralph Giles giles at xiph.org
Mon Nov 17 19:27:28 PST 2008

On Sun, Nov 16, 2008 at 5:54 PM, salsaman <salsaman at gmail.com> wrote:

> I am finding something very strange in my test ogg files.
> For example: I have a shift of 64, and I get a granulepos of 5130.
> 5130 == 80*64 + 10
> which suggests that frame 80 is a keyframe.

That's right.

> However, if I start decoding from the beginning, the 81st frame is a
> keyframe.

Really? Someone has an off-by-one somewhere.

> This suggests that the first frame should be 0. But if I try to search for
> frame 0, it fails.

Correct. The granulepos is derived from the count of decodeable
frames. So the granulepos is:

first frame 1:0 (keyframe)
second frame 1:1
third frame 1:2
80th frame 80:0 (keyframe)
81st frame 80:1
90th frame 80:10

> Any suggestions ?

Are you counting frames from 0 instead of 1 somewhere? I try to think
of 'frame index' which starts from zero and 'frame count' which starts
from 1, similar to the normal index and bounds in C 'for' loops. The
granulepos records the count, not the index.


More information about the theora-dev mailing list