Mercurial > libavformat.hg
changeset 1542:98ef8d631737 libavformat
readjust dts if negative
author | bcoudurier |
---|---|
date | Tue, 28 Nov 2006 15:34:18 +0000 |
parents | 463d731628b3 |
children | 394a8590d5a0 |
files | gxfenc.c |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gxfenc.c Mon Nov 27 12:55:24 2006 +0000 +++ b/gxfenc.c Tue Nov 28 15:34:18 2006 +0000 @@ -45,6 +45,7 @@ int b_per_gop; int first_gop_closed; int64_t current_dts; + int dts_delay; } GXFStreamContext; typedef struct GXFContext { @@ -785,8 +786,9 @@ int i; for (i = 0; i < s->nb_streams; i++) { - if (s->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) { - GXFStreamContext *sc = &gxf->streams[i]; + AVStream *st = s->streams[i]; + GXFStreamContext *sc = &gxf->streams[i]; + if (st->codec->codec_type == CODEC_TYPE_AUDIO) { if (pkt && pkt->stream_index == i) { av_fifo_write(&sc->audio_buffer, pkt->data, pkt->size); pkt = NULL; @@ -797,6 +799,14 @@ break; /* add pkt right now into list */ } } + } else if (pkt) { + /* adjust dts if negative */ + if (pkt->dts < 0 && !sc->dts_delay) { + /* XXX: rescale if codec time base is different from stream time base */ + sc->dts_delay = av_rescale_q(pkt->dts, st->codec->time_base, st->time_base); + pkt->dts = sc->dts_delay; /* set to 0 */ + } + pkt->dts -= sc->dts_delay; } } return av_interleave_packet_per_dts(s, out, pkt, flush);