[FFmpeg-devel] [PATCH] Enforce ogg granule position monotonicity

David Conrad lessen42
Sun Feb 15 01:34:34 CET 2009

On Feb 14, 2009, at 7:01 PM, Alex Converse wrote:

> Hi,
> I'm new to Ogg but had problems with certain streams seeming to loop
> forever. These streams were corrupted and had negative granule
> positions. See inf-loop.ogv. This patch adds a gp sanity check to
> ogg_read_page.
> Here is what I know for sure:
> *"The Granule Position is a signed 64 bit field appearing in the
> header of every Ogg page." [1] (The fact that gp variables in ffmpeg
> are almost always uint64_t bothers me.)


> *"Granule Position must always increase forward or remain equal from
> page to page, be unset, or be zero for a header page. The absolute
> time to which any correct sequence of granule position maps must
> similarly always increase forward or remain equal." Ibid.

Given that the header pages are at the start of a stream (with a  
granule of 0), how can later pages have a negative granule, given that  
they cannot decrease? The special '-1' case is just the simplest way  
to say all 64 bits are 1 (as opposed to saying 0xFFFFFFFFFFFFFFFF).

> *"A special value of '-1' (in two's complement) indicates that no
> packets finish on this page." [2]
> *Libtheora rejects negative granule positions [3]
> What I am uncertain of is what the implications of "unset" are.
> [1] http://www.xiph.org/ogg/doc/ogg-multiplex.html
> [2] http://www.xiph.org/ogg/doc/framing.html
> [3] http://libtheora.sourcearchive.com/documentation/1.0~beta3/ 
> group__basefuncs_g95b10e76fc4c05d0240ea2dfd9fd62bd 
> .html#g95b10e76fc4c05d0240ea2dfd9fd62bd
> Your thoughts would be greatly appreciated, but I know no one here
> likes Ogg and don't want to get a lot of whining about how
> "broken"/"strange"/"ass backwards" it is.
> Regards,
> Alex Converse
> <ogg-monotonic-gp.diff>_______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel

More information about the ffmpeg-devel mailing list