Sebastian Smyczyński <[email protected]> added the comment:
Adding new version of patch (unacceptable whitespaces removed).
The granule change is needed since with condition ogg->streams[i].granule != 0
the first page of OGG was totally ignored.
Due to RFC 3533 — "The Ogg Encapsulation Format Version 0" only -1 is the
special value of granule.
____________________________________________________
FFmpeg issue tracker <[email protected]>
<https://roundup.ffmpeg.org/roundup/ffmpeg/issue592>
____________________________________________________
Index: libavformat/oggdec.c
===================================================================
--- libavformat/oggdec.c (revision 21850)
+++ libavformat/oggdec.c (working copy)
@@ -296,6 +296,10 @@
os->granule = gp;
os->flags = flags;
+ // remember the current page size (used in ogg_read_timestamp)
+ // header + number of segments + summarized size of segments
+ os->pagesize = 27 + os->nsegs + size;
+
if (str)
*str = idx;
@@ -587,12 +591,11 @@
int i;
url_fseek(bc, *pos_arg, SEEK_SET);
while (url_ftell(bc) < pos_limit && !ogg_read_page (s, &i)) {
- if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
+ if (ogg->streams[i].granule != -1 &&
ogg->streams[i].codec && i == stream_index) {
pts = ogg_gptopts(s, i, ogg->streams[i].granule, NULL);
- // FIXME: this is the position of the packet after the one with above
- // pts.
- *pos_arg = url_ftell(bc);
+ // store the position of the page with above pts.
+ *pos_arg = url_ftell(bc) - ogg->streams[i].pagesize;
break;
}
}
Index: libavformat/oggdec.h
===================================================================
--- libavformat/oggdec.h (revision 21850)
+++ libavformat/oggdec.h (working copy)
@@ -71,6 +71,7 @@
int header;
int nsegs, segp;
uint8_t segments[255];
+ uint32_t pagesize;
int incomplete; ///< whether we're expecting a continuation in the next page
int page_end; ///< current packet is the last one completed in the page
void *private;