On 11/27/2022 2:03 PM, Anton Khirnov wrote:
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 7e2d54ae9b..e4270b6c34 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -220,6 +220,18 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket
*avpkt,
avpkt->duration = ff_samples_to_time_base(avctx,
frame->nb_samples);
}
+
+ avctx->reordered_opaque = frame->reordered_opaque;
+ if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
+ avpkt->opaque = frame->opaque;
+ if (frame->opaque_ref) {
+ avpkt->opaque_ref = av_buffer_ref(frame->opaque_ref);
+ if (!avpkt->opaque_ref) {
+ ret = AVERROR(ENOMEM);
+ goto unref;
+ }
+ }
You could simplify this to simply
ret = av_buffer_replace(&avpkt->opaque_ref, frame->opaque_ref);
if (ret < 0)
return ret;
Here and elsewhere you did the same thing. No need to check for
frame->opaque_ref since av_buffer_replace() can handle NULL src, in
which case for this scenario (where avpkt->opaque_ref is always NULL) it
will be a no-op.
+ }
}
// dts equals pts unless there is reordering
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".