From 2e14032bc97eb2e575da59378d09b8f9009c0425 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Jul 2022 10:30:58 +0200 Subject: lavc/encode: generalize a check for setting dts=pts --- libavcodec/encode.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index a765bfa2c8..d0c3903258 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -213,7 +213,7 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) ret = codec->cb.encode(avctx, avpkt, frame, &got_packet); if (avctx->codec->type == AVMEDIA_TYPE_VIDEO && !ret && got_packet && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) - avpkt->pts = avpkt->dts = frame->pts; + avpkt->pts = frame->pts; } av_assert0(ret <= 0); @@ -236,9 +236,13 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) frame->nb_samples); } } - if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { + + // dts equals pts unless there is reordering + // there can be no reordering if there is no encoder delay + if (!(avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER) || + !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) avpkt->dts = avpkt->pts; - } + avpkt->flags |= avci->intra_only_flag; } -- cgit v1.2.3