Compare commits

...

2 Commits

Author SHA1 Message Date
Vignesh Venkat 2c1af16872 avformat/matroskaenc: Use correct buffer for smpte2094_app5
In the call to mkv_write_blockadditional, use the correct
buffer for smpte2094_app5.

Commit 38df985fba updated the
buffer usage to prevent incorrect buffer reuse, but left this line
unchanged inadvertently.

Signed-off-by: Vignesh Venkat <vigneshv@google.com>
2026-05-11 14:44:25 -07:00
Vignesh Venkat e1797cdd51 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 <vigneshv@google.com>
2026-05-11 20:17:11 +00:00
4 changed files with 25 additions and 3 deletions
+1
View File
@@ -9,6 +9,7 @@ version <next>:
- HE-AAC 960 decoding (DAB+)
- transpose_cuda filter
- Add AMF Frame Rate Converter (vf_frc_amf) filter
- SMPTE 2094-50 metadata support and passthrough
version 8.1:
+22 -1
View File
@@ -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);
+1 -1
View File
@@ -29,7 +29,7 @@
#include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 30
#define LIBAVCODEC_VERSION_MINOR 31
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
+1 -1
View File
@@ -2960,7 +2960,7 @@ static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv,
if (ret < 0)
return ret;
mkv_write_blockadditional(&writer, t35_buf, payload_size + 5,
mkv_write_blockadditional(&writer, smpte_2094_app5_buf, payload_size + 5,
MATROSKA_BLOCK_ADD_ID_ITU_T_T35);
track->max_blockaddid = FFMAX(track->max_blockaddid,
MATROSKA_BLOCK_ADD_ID_ITU_T_T35);