[FFmpeg-devel] [PATCH 4/5] libavcodec: write out user data unregistered SEI for nvenc
Brad Hards
bradh at frogmouth.net
Fri Apr 30 14:34:31 EEST 2021
Signed-off-by: Brad Hards <bradh at frogmouth.net>
---
libavcodec/nvenc.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 0dcd93a99c..1a895a64f4 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -2173,6 +2173,8 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
NV_ENC_SEI_PAYLOAD sei_data[8];
int sei_count = 0;
int i;
+ AVFrameSideData *sd;
+ int num_unregistered_sei;
NvencContext *ctx = avctx->priv_data;
NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;
@@ -2261,6 +2263,20 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
}
}
+ num_unregistered_sei = av_frame_num_side_data(frame, AV_FRAME_DATA_SEI_UNREGISTERED);
+ for (int i = 0; i < num_unregistered_sei; i++) {
+ sd = av_frame_get_side_data_n(frame, AV_FRAME_DATA_SEI_UNREGISTERED, i);
+ if (sd) {
+ sei_data[sei_count].payloadSize = sd->size;
+ sei_data[sei_count].payloadType = SEI_TYPE_USER_DATA_UNREGISTERED;
+ sei_data[sei_count].payload = av_memdup(sd->data, sd->size);
+ sei_count ++;
+ if (sei_count >= 8) {
+ break;
+ }
+ }
+ }
+
nvenc_codec_specific_pic_params(avctx, &pic_params, sei_data, sei_count);
} else {
pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS;
--
2.27.0
More information about the ffmpeg-devel
mailing list