mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-06-04 22:50:24 +00:00
avcodec/aomenc: Handle Smpte2094App5 metadata
If packets contain Smpte2094App5 metadata, pass it to the libaom encoder. Signed-off-by: Vignesh Venkat <vigneshv@google.com>
This commit is contained in:
parent
2d826f18fb
commit
f69aa0cc64
2 changed files with 50 additions and 1 deletions
|
|
@ -372,6 +372,51 @@ static int add_hdr_plus(AVCodecContext *avctx, struct aom_image *img, const AVFr
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int add_hdr_smpte2094_app5(AVCodecContext *avctx, struct aom_image *img,
|
||||
const AVFrame *frame)
|
||||
{
|
||||
AVFrameSideData *side_data =
|
||||
av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_SMPTE_2094_APP5);
|
||||
if (!side_data)
|
||||
return 0;
|
||||
|
||||
size_t payload_size;
|
||||
AVDynamicHDRSmpte2094App5 *hdr = (AVDynamicHDRSmpte2094App5 *)side_data->buf->data;
|
||||
int res = av_dynamic_hdr_smpte2094_app5_to_t35(hdr, NULL, &payload_size);
|
||||
if (res < 0) {
|
||||
log_encoder_error(avctx, "Error finding the size of HDR SMPTE-2094-50");
|
||||
return res;
|
||||
}
|
||||
|
||||
uint8_t *hdr_buf;
|
||||
// Extra bytes for the country code, provider code, provider oriented code.
|
||||
const size_t hdr_buf_size = payload_size + 5;
|
||||
hdr_buf = av_malloc(hdr_buf_size);
|
||||
if (!hdr_buf)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
uint8_t *payload = hdr_buf;
|
||||
bytestream_put_byte(&payload, ITU_T_T35_COUNTRY_CODE_US);
|
||||
bytestream_put_be16(&payload, ITU_T_T35_PROVIDER_CODE_SMPTE);
|
||||
bytestream_put_be16(&payload, 0x0001); // provider_oriented_code
|
||||
|
||||
res = av_dynamic_hdr_smpte2094_app5_to_t35(hdr, &payload, &payload_size);
|
||||
if (res < 0) {
|
||||
av_free(hdr_buf);
|
||||
log_encoder_error(avctx, "Error encoding HDR SMPTE-2094-50 from side data");
|
||||
return res;
|
||||
}
|
||||
|
||||
res = aom_img_add_metadata(img, OBU_METADATA_TYPE_ITUT_T35,
|
||||
hdr_buf, hdr_buf_size, AOM_MIF_ANY_FRAME);
|
||||
av_free(hdr_buf);
|
||||
if (res < 0) {
|
||||
log_encoder_error(avctx, "Error adding HDR SMPTE-2094-50 to aom_img");
|
||||
return res;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS) && \
|
||||
defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
|
||||
defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
|
||||
|
|
@ -1324,6 +1369,10 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt,
|
|||
res = add_hdr_plus(avctx, rawimg, frame);
|
||||
if (res < 0)
|
||||
return res;
|
||||
|
||||
res = add_hdr_smpte2094_app5(avctx, rawimg, frame);
|
||||
if (res < 0)
|
||||
return res;
|
||||
}
|
||||
|
||||
res = aom_codec_encode(&ctx->encoder, rawimg, timestamp, duration, flags);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include "version_major.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MINOR 31
|
||||
#define LIBAVCODEC_VERSION_MINOR 32
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue