OSDN Git Service

avcodec: do not override pts or duration from the audio encoder
authorJustin Ruggles <justin.ruggles@gmail.com>
Fri, 10 Feb 2012 22:16:18 +0000 (17:16 -0500)
committerJustin Ruggles <justin.ruggles@gmail.com>
Tue, 21 Feb 2012 20:18:51 +0000 (15:18 -0500)
This allows encoders to set pts and/or duration even if they do not use
CODEC_CAP_DELAY.

libavcodec/utils.c

index 2ab3b8e..c88f379 100644 (file)
@@ -885,9 +885,11 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
         ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
         if (!ret && *got_packet_ptr) {
             if (!(avctx->codec->capabilities & CODEC_CAP_DELAY)) {
-                avpkt->pts = frame->pts;
-                avpkt->duration = ff_samples_to_time_base(avctx,
-                                                          frame->nb_samples);
+                if (avpkt->pts == AV_NOPTS_VALUE)
+                    avpkt->pts = frame->pts;
+                if (!avpkt->duration)
+                    avpkt->duration = ff_samples_to_time_base(avctx,
+                                                              frame->nb_samples);
             }
             avpkt->dts = avpkt->pts;
         } else {