# HG changeset patch # User conrad # Date 1268291876 0 # Node ID eb9c746c3584cb27c1572ad5dc75d71ded5ad1d9 # Parent c587ece53810a4a9f5b128d6e3dcc163584b45d4 oggdec: Determine pts and filepos on a packet basis in read_timestamp This takes into account whether the granule defines the start or end times of packets, and sets the correct file offset of the associated page. diff -r c587ece53810 -r eb9c746c3584 oggdec.c --- a/oggdec.c Thu Mar 11 07:17:53 2010 +0000 +++ b/oggdec.c Thu Mar 11 07:17:56 2010 +0000 @@ -581,15 +581,14 @@ int64_t pts = AV_NOPTS_VALUE; 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 && - 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); + ogg_reset(ogg); + + while (url_ftell(bc) < pos_limit && !ogg_packet(s, &i, NULL, NULL, pos_arg)) { + if (i == stream_index) { + pts = ogg_calc_pts(s, i, NULL); + } + if (pts != AV_NOPTS_VALUE) break; - } } ogg_reset(ogg); return pts;