diff options
Diffstat (limited to 'libavformat/oggdec.c')
-rw-r--r-- | libavformat/oggdec.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 33b453c584..26a6af20cb 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -119,6 +119,7 @@ ogg_reset (struct ogg * ogg) os->psize = 0; os->granule = -1; os->lastpts = AV_NOPTS_VALUE; + os->lastdts = AV_NOPTS_VALUE; os->nsegs = 0; os->segp = 0; } @@ -428,16 +429,18 @@ ogg_get_headers (AVFormatContext * s) } static uint64_t -ogg_gptopts (AVFormatContext * s, int i, uint64_t gp) +ogg_gptopts (AVFormatContext * s, int i, uint64_t gp, int64_t *dts) { struct ogg *ogg = s->priv_data; struct ogg_stream *os = ogg->streams + i; uint64_t pts = AV_NOPTS_VALUE; if(os->codec->gptopts){ - pts = os->codec->gptopts(s, i, gp); + pts = os->codec->gptopts(s, i, gp, dts); } else { pts = gp; + if (dts) + *dts = pts; } return pts; @@ -474,7 +477,7 @@ ogg_get_length (AVFormatContext * s) if (idx != -1){ s->streams[idx]->duration = - ogg_gptopts (s, idx, ogg->streams[idx].granule); + ogg_gptopts (s, idx, ogg->streams[idx].granule, NULL); } ogg->size = size; @@ -534,12 +537,16 @@ ogg_read_packet (AVFormatContext * s, AVPacket * pkt) pkt->pts = os->lastpts; os->lastpts = AV_NOPTS_VALUE; } + if (os->lastdts != AV_NOPTS_VALUE) { + pkt->dts = os->lastdts; + os->lastdts = AV_NOPTS_VALUE; + } if (os->page_end) { if (os->granule != -1LL) { if (os->codec && os->codec->granule_is_start) - pkt->pts = ogg_gptopts(s, idx, os->granule); + pkt->pts = ogg_gptopts(s, idx, os->granule, &pkt->dts); else - os->lastpts = ogg_gptopts(s, idx, os->granule); + os->lastpts = ogg_gptopts(s, idx, os->granule, &os->lastdts); os->granule = -1LL; } else av_log(s, AV_LOG_WARNING, "Packet is missing granule\n"); @@ -579,7 +586,7 @@ ogg_read_timestamp (AVFormatContext * s, int stream_index, int64_t * pos_arg, 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); + 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); |