[FFmpeg-devel] [PATCH 3/5] libavcodec: write out user data unregistered SEI for x265
Brad Hards
bradh at frogmouth.net
Fri Apr 30 14:34:30 EEST 2021
Signed-off-by: Brad Hards <bradh at frogmouth.net>
---
libavcodec/libx265.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index a1bd205201..3dceb3d165 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -484,6 +484,8 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int nnal;
int ret;
int i;
+ AVFrameSideData *sd;
+ int num_unregistered_sei;
ctx->api->picture_init(ctx->params, &x265pic);
@@ -515,6 +517,17 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
memcpy(x265pic.userData, &pic->reordered_opaque, sizeof(pic->reordered_opaque));
}
+ num_unregistered_sei = av_frame_num_side_data(pic, AV_FRAME_DATA_SEI_UNREGISTERED);
+ x265pic.userSEI.payloads = av_realloc_array(x265pic.userSEI.payloads, x265pic.userSEI.numPayloads + num_unregistered_sei, sizeof(x265_sei_payload));
+ for (i = 0; i < num_unregistered_sei; i++) {
+ sd = av_frame_get_side_data_n(pic, AV_FRAME_DATA_SEI_UNREGISTERED, i);
+ if (sd) {
+ x265pic.userSEI.payloads[x265pic.userSEI.numPayloads + i].payload = sd->data;
+ x265pic.userSEI.payloads[x265pic.userSEI.numPayloads + i].payloadSize = sd->size;
+ x265pic.userSEI.payloads[x265pic.userSEI.numPayloads + i].payloadType = USER_DATA_UNREGISTERED;
+ }
+ }
+ x265pic.userSEI.numPayloads += num_unregistered_sei;
}
ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal,
--
2.27.0
More information about the ffmpeg-devel
mailing list