PR #23044 opened by vigneshvg URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23044 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23044.patch
If incoming packets contain Smpte2094App5 metadata, retain them so that they are passed through to the output. Signed-off-by: Vignesh Venkat <[email protected]> >From 82ddc76bfd3b540915a21c485667a0ebb1d41eb2 Mon Sep 17 00:00:00 2001 From: Vignesh Venkat <[email protected]> Date: Thu, 7 May 2026 13:06:32 -0700 Subject: [PATCH] avcodec/libvpxenc: Copy Smpte2094App5 metadata If incoming packets contain Smpte2094App5 metadata, retain them so that they are passed through to the output. Signed-off-by: Vignesh Venkat <[email protected]> --- libavcodec/libvpxenc.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index b21ba175ab..963fa6c619 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -74,6 +74,7 @@ typedef struct FrameData { AVBufferRef *frame_opaque_ref; AVBufferRef *hdr10_plus; + AVBufferRef *hdr_smpte2094_app5; } FrameData; typedef struct VPxEncoderContext { @@ -341,6 +342,7 @@ static void frame_data_uninit(FrameData *fd) { av_buffer_unref(&fd->frame_opaque_ref); av_buffer_unref(&fd->hdr10_plus); + av_buffer_unref(&fd->hdr_smpte2094_app5); } static av_cold void fifo_free(AVFifo **fifo) @@ -366,12 +368,13 @@ static int frame_data_submit(AVCodecContext *avctx, AVFifo *fifo, FrameData fd = { .pts = frame->pts }; int ret; + const AVFrameSideData *sd; if (IS_VP9(avctx) && // Keep HDR10+ if it has bit depth higher than 8 and // it has PQ trc (SMPTE2084). enccfg->g_bit_depth > 8 && avctx->color_trc == AVCOL_TRC_SMPTE2084) { - const AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS); + sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS); if (sd) { fd.hdr10_plus = av_buffer_ref(sd->buf); @@ -380,6 +383,14 @@ static int frame_data_submit(AVCodecContext *avctx, AVFifo *fifo, } } + // Keep SMPTE2094_APP5 metadata. + sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_SMPTE_2094_APP5); + if (sd) { + fd.hdr_smpte2094_app5 = av_buffer_ref(sd->buf); + if (!fd.hdr_smpte2094_app5) + return AVERROR(ENOMEM); + } + fd.duration = frame->duration; fd.frame_opaque = frame->opaque; if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE && frame->opaque_ref) { @@ -454,6 +465,16 @@ static int frame_data_apply(AVCodecContext *avctx, AVFifo *fifo, AVPacket *pkt) memcpy(data, fd.hdr10_plus->data, fd.hdr10_plus->size); } + if (fd.hdr_smpte2094_app5) { + data = av_packet_new_side_data(pkt, AV_PKT_DATA_DYNAMIC_HDR_SMPTE_2094_APP5, fd.hdr_smpte2094_app5->size); + if (!data) { + ret = AVERROR(ENOMEM); + goto skip; + } + + memcpy(data, fd.hdr_smpte2094_app5->data, fd.hdr_smpte2094_app5->size); + } + skip: av_fifo_drain2(fifo, 1); frame_data_uninit(&fd); -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
