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

Don Moir donmoir at comcast.net
Sun Feb 5 10:47:13 CET 2012

> Test cases that fail when ogg_stream->keyframe is not set back to 0 after 
> a seek in ogg_read_seek.
> I have several files that fail but I don't want to hit you them all at one 
> time. Sometimes they get errors with ffplay and sometimes not. Some 
> downloaded from archive.org and some not. archive.org is providing most of 
> their video files in theora/ogg format.
> I tested the following file in VLC, SMplayer, ffplay, and my own app. We 
> can't really count on VLC because I have no idea what it's using but I 
> used it as a comparison.
> Reimar, if you could cross-check me on this file before I file a bug 
> report that would be good. Keep in mind it's not just this one file and 
> the various files may produce errors or not. But this one file shows well 
> what I am talking about and just disregard the 7 bits left in packet error 
> that ffplay reports for it for now, because the problem exist even when 
> errors are not displayed.
> file 1 ) 
> http://sms.pangolin.com/temp/bad_seek_os-keyframe_Wiki_feel_stupid.ogv
> Neither VLC, SMPlayer, or ffplay can seek into this file correctly.
> o -with SMPlayer you never will be able to seek back to the start of the 
> file and it will jump all around when you click the seek bar. Audio may go 
> out of sync as well.
> o - with ffplay just hit left arrow and you will never get back to the 
> start. Hit left arrow again and the guy that looks like he is from India 
> will still be talking when the guy with the blond hair is showing and 
> talking. So also audio completely out of sync with ffplay.
> o - VLC can seek back to beginning etc, but displays incomplete frames. So 
> do SMPlayer and ffplay but not quite as bad.
> o - with my own app and if I don't set os->keyframe back to zero, I 
> successfully seek to the correct audio position but the next valid frame 
> may not display for some time. I also could not get back to the first 
> video frame but audio is fine. If I do set os->keyframe back to zero, then 
> I have no problem with this file at all. That is, no incomplete frames, no 
> problem seeking to the exact position including first frame, and audio is 
> perfectly in sync.
> I also have not seen a case where setting os->keyframe back to zero causes 
> any problem (tested about 40-50 ogg files). It might be that it just needs 
> to be put back into the state it was in prior to calling 
> ff_seek_frame_binary. don't know.

I tested the the 2 patches made by Reimar for:

o - fix keyframe seeking when granule_is_start is 0

o - Fix potential finite discard loop.

With these 2 patches in there is no need for me to manually create the 
index_entries :), but I still have to set os->keyframe back to zero after a 
seek in order to correct the other problem files as in the above. Doing this 
and testing many files, I still have not found a failure because of it but I 
will test some more files later with the patches in. 

More information about the ffmpeg-devel mailing list