diff --git a/libavcodec/internal.h b/libavcodec/internal.h index fc906322f8..500511dada 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -46,7 +46,13 @@ * all. */ #define FF_CODEC_CAP_INIT_CLEANUP (1 << 1) - +/** + * Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set + * AVFrame.pkt_dts manually. If the flag is set, utils.c won't overwrite + * this field. If it's unset, utils.c tries to guess the pkt_dts field + * from the input AVPacket. + */ +#define FF_CODEC_CAP_SETS_PKT_DTS (1 << 2) #ifdef DEBUG # define ff_dlog(ctx, ...) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__) diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c index f4bf9214fe..a23a97fcfa 100644 --- a/libavcodec/mmaldec.c +++ b/libavcodec/mmaldec.c @@ -792,6 +792,7 @@ AVCodec ff_h264_mmal_decoder = { .flush = ffmmal_flush, .priv_class = &ffmmaldec_class, .capabilities = AV_CODEC_CAP_DELAY, + .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}, diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1d718b288c..a94e4a6058 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1482,7 +1482,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->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS)) + picture->pkt_dts = avpkt->dts; /* get_buffer is supposed to set frame parameters */ if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) { picture->sample_aspect_ratio = avctx->sample_aspect_ratio;