[FFmpeg-devel] [PATCH] Fix Ogg data_offset computation.

Reimar Döffinger Reimar.Doeffinger
Mon Nov 22 19:36:40 CET 2010


On Thu, Nov 18, 2010 at 03:04:45PM -0800, Aaron Colwell wrote:
> > If (in your example) only the first audio packet is demuxed and then
> > a seek is done, the video packet will never be demuxer and thus
> > data_offset will stay wrong.
> >
> 
> You are right. I've attached a new patch that makes sure that
> data_offset is set properly before ogg_get_headers() returns. This
> should prevent the scenario you described.
> 
> A proper fix means you have to set data_offset already when the
> 
> > first packet is read/parsed.
> > Concerning "valid Ogg file or not" I can only think, valid it may be,
> > it just would be nice to find something one could call a "sane Ogg file".
> >
> 
> I agree that it would be nice to have a stronger definition of "sane", but
> unfortunately stuff like this appears to be par for the course in ogg.

> diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
> index 5e52bb3..1b85eeb 100644
> --- a/libavformat/oggdec.c
> +++ b/libavformat/oggdec.c
> @@ -373,9 +373,14 @@ ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize, int64_t *fpo
>          if (!os->header){
>              os->segp = segp;
>              os->psize = psize;
> -            if (!ogg->headers)
> -                s->data_offset = os->sync_pos;
> -            ogg->headers = 1;
> +            if (!ogg->headers) {
> +                if (!s->data_offset || s->data_offset > os->sync_pos)
> +                    s->data_offset = os->sync_pos;
> +                ogg->headers = 1;
> +                for (i = 0; ogg->headers && i < ogg->nstreams; i++)
> +                    if (ogg->streams[i].header > 0)
> +                        ogg->headers = 0;
> +            }

Sorry, but I am not able to understand you patch.
To me it looks like it still updates data_offset multiple times, what
ensures that the application/seek framework never sees one of
those wrong values?



More information about the ffmpeg-devel mailing list