Mercurial > libavformat.hg
changeset 2592:c2f4fba2c234 libavformat
Add a read_timestamp function to ogg demuxer
author | reimar |
---|---|
date | Wed, 10 Oct 2007 10:33:07 +0000 |
parents | fb98ebeedd81 |
children | 16aa09b0f20f |
files | ogg2.c |
diffstat | 1 files changed, 16 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/ogg2.c Tue Oct 09 01:12:27 2007 +0000 +++ b/ogg2.c Wed Oct 10 10:33:07 2007 +0000 @@ -659,21 +659,28 @@ } -#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 @@ ogg_read_packet, ogg_read_close, ogg_read_seek, -// ogg_read_timestamp, + ogg_read_timestamp, .extensions = "ogg", };