readjust dts if negative

Originally committed as revision 7179 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Baptiste Coudurier 2006-11-28 15:34:18 +00:00
parent 7504e4fa1d
commit 6a287fd7ce
2 changed files with 14 additions and 4 deletions

View File

@ -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);

View File

@ -28,9 +28,9 @@ bac6c5f50f3ca5db6e2ef6eaccf1d4f1 *./data/b-libav.asf
26c41db318d9aacfd6b9e734c0ea4d94 *./data/b-libav.dv
3600000 ./data/b-libav.dv
./data/b-libav.dv CRC=0xa6b8b635
304ee17506e4526ba04285f6cd14630f *./data/b-libav.gxf
ff65eeeb156c8b42ad9fdb7c8dbdb6b7 *./data/b-libav.gxf
816068 ./data/b-libav.gxf
./data/b-libav.gxf CRC=0xb2d644fa
./data/b-libav.gxf CRC=0xb19044fa
9a9da315747599f7718cc9a9a09c21ff *./data/b-libav.pbm
317075 ./data/b-libav.pbm
./data/b-libav.pbm CRC=0xb92906cb