diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2007-10-10 10:33:07 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2007-10-10 10:33:07 +0000 |
commit | a1f29b959baa93b9f7c7162f7f1b629efbf3000a (patch) | |
tree | d6a44b9c32e9a5d98651b09ac4c5f1653223309a /libavformat/ogg2.c | |
parent | 03d3cab876cc0dfc4b9d2352653bb3dca64f30f9 (diff) | |
download | ffmpeg-a1f29b959baa93b9f7c7162f7f1b629efbf3000a.tar.gz |
Add a read_timestamp function to ogg demuxer
Originally committed as revision 10701 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/ogg2.c')
-rw-r--r-- | libavformat/ogg2.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/libavformat/ogg2.c b/libavformat/ogg2.c index 2b4b1603b6..4d73bd4458 100644 --- a/libavformat/ogg2.c +++ b/libavformat/ogg2.c @@ -659,21 +659,28 @@ ogg_read_seek (AVFormatContext * s, int stream_index, int64_t target_ts, } -#if 0 static int64_t ogg_read_timestamp (AVFormatContext * s, int stream_index, int64_t * pos_arg, int64_t pos_limit) { ogg_t *ogg = s->priv_data; ByteIOContext *bc = &s->pb; - int64_t pos, pts; - - if (*pos_arg < 0) - return AV_NOPTS_VALUE; - - pos = *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); + // FIXME: this is the position of the packet after the one with above + // pts. + *pos_arg = url_ftell(bc); + break; + } + } + ogg_reset(ogg); + return pts; } -#endif static int ogg_probe(AVProbeData *p) { @@ -694,6 +701,6 @@ AVInputFormat ogg_demuxer = { ogg_read_packet, ogg_read_close, ogg_read_seek, -// ogg_read_timestamp, + ogg_read_timestamp, .extensions = "ogg", }; |