Codecs with internal parallelism need to set the pkt_pts/pkt_dts
by themselves.
---
 libavcodec/avcodec.h | 5 +++++
 libavcodec/utils.c   | 6 ++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 0ec02d7..9e74cbd 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -750,6 +750,11 @@ typedef struct RcOverride{
  */
 #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
 
+/**
+ * Codec sets by its own the frame pkt_pts and pkt_dts.
+ */
+#define CODEC_CAP_PKT_TS 0x20000
+
 //The following defines may change, don't expect compatibility if you use them.
 #define MB_TYPE_INTRA4x4   0x0001
 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 13419c7..86354cd 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1389,7 +1389,8 @@ int attribute_align_arg 
avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
         else {
             ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
                                        avpkt);
-            picture->pkt_dts = avpkt->dts;
+            if (!(avctx->codec->capabilities & CODEC_CAP_PKT_TS))
+                picture->pkt_dts = avpkt->dts;
             /* get_buffer is supposed to set frame parameters */
             if (!(avctx->codec->capabilities & CODEC_CAP_DR1)) {
                 picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
@@ -1452,7 +1453,8 @@ int attribute_align_arg 
avcodec_decode_audio4(AVCodecContext *avctx,
         ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
         if (ret >= 0 && *got_frame_ptr) {
             avctx->frame_number++;
-            frame->pkt_dts = avpkt->dts;
+            if (!(avctx->codec->capabilities & CODEC_CAP_PKT_TS))
+                frame->pkt_dts = avpkt->dts;
             if (frame->format == AV_SAMPLE_FMT_NONE)
                 frame->format = avctx->sample_fmt;
 
-- 
1.8.3.2

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to