[theora-dev] ogg/theora decoder skipping frames

salsaman salsaman at gmail.com
Wed Nov 5 19:04:09 PST 2008

Hi all,
I have been working on an ogg/theora demuxer/decoder plugin for LiVES (
http://lives.sourceforge.net). The decoder has a very simple interface, in
fact there are only two major functions: - a function to get details (frame
size, fps, palette, etc) from a URL; - a function to get a given frame from
a specified URL and copy the resulting frame into memory buffers.

The code can be seen here:


The function which is causing problems is get_frame(). Here the first pass
will seek to the keyframe before the target frame, then decode until we
reach the target frame, at which point the frame is output. The output is
done by way of ogg_data_process() which in turn calls ogg_theora_read().

So far so good. However, on the second and subsequent frames, assuming we
are playing forwards sequentially, a shortcut is taken - at line 960:

if (tframe>last_frame&&((tframe-last_frame<=max_frame_diff||kframe==last_kframe)))

here, tframe is our target frame, (static) last_frame is the last frame
output, and max_frame_diff is the keyframe skip / 2
If we are playing sequentially, then this shortcut will be taken - it sets
cont(inue) to TRUE and drops back into ogg_data_process(), and processing
should continue exactly where we left off last time. However what I see is
this - I am using 3 test clips. On one of the clips, playbck works
perfectly; however, on the other two clips, it looks like frames are being
skipped - the clip plays back too fast, with distortion, and we reach EOF
too soon.

Maybe somebody can take a quick look at the code and tell me where I am
going wrong ?

Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/theora-dev/attachments/20081106/e77f2eea/attachment.htm 

More information about the theora-dev mailing list