[FFmpeg-devel] [PATCH 2/5] libavcodec: write out user data unregistered SEI for x264
Brad Hards
bradh at frogmouth.net
Fri Apr 30 14:34:29 EEST 2021
Signed-off-by: Brad Hards <bradh at frogmouth.net>
---
libavcodec/libx264.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 22c91d8df7..6d4cee55c0 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -31,6 +31,7 @@
#include "internal.h"
#include "packet_internal.h"
#include "atsc_a53.h"
+#include "sei.h"
#if defined(_MSC_VER)
#define X264_API_IMPORTS 1
@@ -303,6 +304,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
int64_t wallclock = 0;
X264Opaque *out_opaque;
AVFrameSideData *sd;
+ int num_unregistered_sei;
x264_picture_init( &x4->pic );
x4->pic.img.i_csp = x4->params.i_csp;
@@ -438,6 +440,19 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
}
}
}
+ num_unregistered_sei = av_frame_num_side_data(frame, AV_FRAME_DATA_SEI_UNREGISTERED);
+ x4->pic.extra_sei.payloads = av_realloc_array(x4->pic.extra_sei.payloads,
+ x4->pic.extra_sei.num_payloads + num_unregistered_sei,
+ sizeof(x264_sei_payload_t));
+ 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) {
+ x4->pic.extra_sei.payloads[x4->pic.extra_sei.num_payloads + i].payload = sd->data;
+ x4->pic.extra_sei.payloads[x4->pic.extra_sei.num_payloads + i].payload_size = sd->size;
+ x4->pic.extra_sei.payloads[x4->pic.extra_sei.num_payloads + i].payload_type = SEI_TYPE_USER_DATA_UNREGISTERED;
+ }
+ }
+ x4->pic.extra_sei.num_payloads += num_unregistered_sei;
}
do {
--
2.27.0
More information about the ffmpeg-devel
mailing list