[FFmpeg-devel] [PATCH] lavf/oggdec: check for begin-of-stream flag in case of chained streams.

Clément Bœsch ubitux at gmail.com
Fri Sep 21 23:20:32 CEST 2012

On Fri, Sep 21, 2012 at 10:39:02PM +0200, Clément Bœsch wrote:
> Fix Ticket #1617, revealing a regression I introduced in 8f3eebd.
> ---
> Difference from the latest attempt: as requested by Michael, I needed to make
> sure no stream is added in between Ogg context save/restore operations (because
> it would likely lead to a mismatch between ogg->nstreams and
> AVFormatContext->nb_streams after the restore op). Before this patch, checking
> for ogg->headers was preventing this: ogg->headers is always set before any ogg
> save/restore (though, it was also preventing from creating the stream when
> necessary).
> But I still don't get how the ogg_new_stream() is never called between
> ogg_save/restore calls (the ogg->state I added in ogg_new_stream is never
> triggered with my tests), while it obviously calls the same read pages and
> packets function as usual...

OK I think I kind of get it now:

ogg_read_header() first makes sure all the streams are found in a classic
multiplexed stream, and set the ogg->headers flag as a consequence. Then
when entering the ogg save/restore plays, all the streams are likely
already declared, so they are found when calling ogg_find_stream() in the
read page function.

In the case of the flac+theora.ogg (from the ticket #1617), only 1/2
stream is detected before ogg->headers flag is set. And indeed, when we
are later between ogg save & restore, the other stream identified by
another serial prevents ogg_find_stream() from selecting the stream (since
it doesn't exist yet). But the good thing is that data are found before
the declaration of the second stream (a page related to the stream
detected at the beginning without BOS is detected), so it's making it call
the replace stream code for a while.

Strangely, after the ogg restore, the other stream is found and added and
everything seems to go kind of well.

This is still very obscure to me, and I hope everything is fine now.
Anyone willing to give some more insight is welcome.

Anyway, the current patch fixes the regression, and is still able to play
classic multiplexed files, as well are chained audio streams, and the
likely broken sample from the ticket.

Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120921/579b4166/attachment.asc>

More information about the ffmpeg-devel mailing list