[FFmpeg-cvslog] avcodec/nvenc: write out user data unregistered SEI

Brad Hards git at videolan.org
Fri Jun 4 19:44:12 EEST 2021


ffmpeg | branch: master | Brad Hards <bradh at frogmouth.net> | Fri Jun  4 16:06:38 2021 +0200| [cee9f9628fb983ad9e1c84fb17570f297bc542d2] | committer: Timo Rothenpieler

avcodec/nvenc: write out user data unregistered SEI

Signed-off-by: Brad Hards <bradh at frogmouth.net>
Signed-off-by: Timo Rothenpieler <timo at rothenpieler.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cee9f9628fb983ad9e1c84fb17570f297bc542d2
---

 libavcodec/nvenc.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 5ae68b7101..e254c2983a 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -2282,6 +2282,34 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
             }
         }
 
+        for (int j = 0; j < frame->nb_side_data; j++) {
+            AVFrameSideData *side_data = frame->side_data[j];
+            void *tmp;
+
+            if (side_data->type != AV_FRAME_DATA_SEI_UNREGISTERED)
+                continue;
+
+            tmp = av_fast_realloc(ctx->sei_data,
+                                  &ctx->sei_data_size,
+                                  (sei_count + 1) * sizeof(*ctx->sei_data));
+            if (!tmp) {
+                res = AVERROR(ENOMEM);
+                goto sei_failed;
+            } else {
+                ctx->sei_data = tmp;
+                ctx->sei_data[sei_count].payloadSize = side_data->size;
+                ctx->sei_data[sei_count].payloadType = SEI_TYPE_USER_DATA_UNREGISTERED;
+                ctx->sei_data[sei_count].payload = av_memdup(side_data->data, side_data->size);
+
+                if (!ctx->sei_data[sei_count].payload) {
+                    res = AVERROR(ENOMEM);
+                    goto sei_failed;
+                }
+
+                sei_count++;
+            }
+        }
+
         nvenc_codec_specific_pic_params(avctx, &pic_params, ctx->sei_data, sei_count);
     } else {
         pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS;



More information about the ffmpeg-cvslog mailing list