aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorDavid Conrad <lessen42@gmail.com>2010-03-11 07:17:56 +0000
committerDavid Conrad <lessen42@gmail.com>2010-03-11 07:17:56 +0000
commit873d117e4be3268b26397b05ed1fa74396d2ae84 (patch)
tree93b309352f3b0c8a12cb3a23892a68e14efb0d5b /libavformat
parent6abaa27211dab639d07414dc243620af697047cd (diff)
downloadffmpeg-873d117e4be3268b26397b05ed1fa74396d2ae84.tar.gz
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. Originally committed as revision 22462 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/oggdec.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index f627c1efb3..ca88140cc6 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -581,15 +581,14 @@ ogg_read_timestamp (AVFormatContext * s, int stream_index, int64_t * pos_arg,
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);
- break;
+ 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;