diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2006-11-28 15:34:18 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2006-11-28 15:34:18 +0000 |
commit | 6a287fd7ce5ea69f4eeadda6a049d669eb8efb46 (patch) | |
tree | e8e11634987d6888aa9b5b3a31bebb11a89b64d3 /libavformat/gxfenc.c | |
parent | 7504e4fa1dc5aca29c205ce629591fd1d457a264 (diff) | |
download | ffmpeg-6a287fd7ce5ea69f4eeadda6a049d669eb8efb46.tar.gz |
readjust dts if negative
Originally committed as revision 7179 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/gxfenc.c')
-rw-r--r-- | libavformat/gxfenc.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 033e6c633e..fef5ec1044 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -45,6 +45,7 @@ typedef struct GXFStreamContext { int b_per_gop; int first_gop_closed; int64_t current_dts; + int dts_delay; } GXFStreamContext; typedef struct GXFContext { @@ -785,8 +786,9 @@ static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pk 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 @@ static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pk 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); |