[FFmpeg-devel] [PATCH] Fix potential infinite discard loop.

Don Moir donmoir at comcast.net
Sat Feb 4 20:27:32 CET 2012


> On Sat, Feb 04, 2012 at 03:29:58PM +0100, Reimar Döffinger wrote:
> > Fixes trac issue #438.
> > Seeking in that sample would cause ogg_read_timestamp to fail
> > because ogg_packet would go into a state where all packets
> > of stream 1 would be discarded until the end of the stream.
> > 
> > Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
> 
>> if it works and considering you know the ogg demxuer better than me
>> Id say patch is very likely correct

>Nobody really knows it very well unfortunately.
>For now I just go with the strategy of adding lots of comments,
>hopefully that at least means we can avoid breaking it in the same
>way multiple times.
>I pushed it but only afterwards realized a big mess-up:
>the issue it fixes is #941, so I added a comment to #438 to
>clear that up.

The reason I had to create the index entries prior to seeking is to prevent it from ever getting to read_timestamp as I knew it failed there and I needed something to work now for it. But with ticket #438, there may be more to it. Since I know I have created the index_entries (albeit not as efficiently as possible), I also make sure I seek to an exact time in the index entries and my frames look good. Sometimes I get a very slight distortion but nothing as bad as in ticket 438. Not sure if this is relevant though.

I just looked at oggdec.c for git 785d8a3 and I see nothing was done about these:

2) make sure os->keyframe_seek is set back to 0 always and don't depend on any return value. Currently this only set back to 0 only if the return value from 
ff_seek_frame_binary is < 0. This is not correct. This fixed all the remaining weirdness.

3) call ogg_reset after the seek - this is not perfect and there is something more with this but without this - the first packet read will contain stale information as mentioned above. You will still get AV_NOPTS_VALUE on the first read which is not right either. I think calling ogg_reset and setting the lastpts and lastdts in the ogg_stream may do it.

Both these items are important. It's not clear to me about how to fix item 3) . I do know there is stale information on the first read after a seek in lastpts and last dts. Item 2) also goes a long way to fixing the remaining issues with ogg seeking.

Since it appears items 2 and 3 were not addressed, I don't understand why ticket #941 was closed.


More information about the ffmpeg-devel mailing list