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

Alex Converse alex.converse
Sun Feb 15 01:01:35 CET 2009


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

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.
*"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.

Alex Converse
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ogg-monotonic-gp.diff
Type: text/x-diff
Size: 464 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090214/97ffdff0/attachment.diff>

More information about the ffmpeg-devel mailing list