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>
This commit is contained in:
committed by
James Zern
parent
c1ff2c24b5
commit
e1797cdd51
@@ -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
@@ -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);
|
||||
|
||||
@@ -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, \
|
||||
|
||||
Reference in New Issue
Block a user