aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/encode.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-11-27 13:37:10 +0100
committerAnton Khirnov <anton@khirnov.net>2023-01-29 09:22:57 +0100
commit8d73f3ce56fc90d840c83e8ab3463474d2d38046 (patch)
tree2c39943e0e05d06f198a9f80845e49eb88c0eeb7 /libavcodec/encode.c
parent5c0348f3d61ce850fa33fe79b5d2bc49f7b52683 (diff)
downloadffmpeg-8d73f3ce56fc90d840c83e8ab3463474d2d38046.tar.gz
lavc: support AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE in all no-delay encoders
Including fake-delay encoders marked with FF_CODEC_CAP_EOF_FLUSH.
Diffstat (limited to 'libavcodec/encode.c')
-rw-r--r--libavcodec/encode.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index d6c73dc044..555bd3ff96 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -190,6 +190,21 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
return 0;
}
+int ff_encode_reordered_opaque(AVCodecContext *avctx,
+ AVPacket *pkt, const AVFrame *frame)
+{
+ avctx->reordered_opaque = frame->reordered_opaque;
+
+ if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
+ int ret = av_buffer_replace(&pkt->opaque_ref, frame->opaque_ref);
+ if (ret < 0)
+ return ret;
+ pkt->opaque = frame->opaque;
+ }
+
+ return 0;
+}
+
int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt,
AVFrame *frame, int *got_packet)
{
@@ -221,6 +236,10 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt,
avpkt->duration = ff_samples_to_time_base(avctx,
frame->nb_samples);
}
+
+ ret = ff_encode_reordered_opaque(avctx, avpkt, frame);
+ if (ret < 0)
+ goto unref;
}
// dts equals pts unless there is reordering