diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-07-12 10:30:58 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2022-08-23 16:47:48 +0200 |
commit | 2e14032bc97eb2e575da59378d09b8f9009c0425 (patch) | |
tree | 48a085ab645a9f4bce158370c1a0946b1bf30ea7 | |
parent | 71890ac3774bc041bed3ddb254defc66b4d9e4f8 (diff) |
lavc/encode: generalize a check for setting dts=pts
-rw-r--r-- | libavcodec/encode.c | 10 |
1 files 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; } |