On Friday, 6 August 2021 7:16:33 PM AEST Brad Hards wrote: > MISB ST 0604 and ST 2101 require user data unregistered SEI messages > (precision timestamps and sensor identifiers) to be included. That > currently isn't supported for libx264. This patch adds support > for user data unregistered SEI messages in accordance with ISO/IEC > 14496-10:2020(E) section D.1.7 (syntax) and D.2.7 (semantics). > > This code is based on a similar change for libx265 (commit > 1f58503013720700a5adfd72c708e6275aefc165). > --- > libavcodec/libx264.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c > index 9afaf19547..e9bbe8d494 100644 > --- a/libavcodec/libx264.c > +++ b/libavcodec/libx264.c > @@ -32,6 +32,7 @@ > #include "internal.h" > #include "packet_internal.h" > #include "atsc_a53.h" > +#include "sei.h" > > #if defined(_MSC_VER) > #define X264_API_IMPORTS 1 > @@ -114,6 +115,9 @@ typedef struct X264Context { > * encounter a frame with ROI side data. > */ > int roi_warned; > + > + void *sei_data; > + int sei_data_size; > } X264Context; > > static void X264_log(void *p, int level, const char *fmt, va_list args) > @@ -317,6 +321,9 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, > const AVFrame *frame, > x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt); > > if (frame) { > + x264_sei_t *sei = &x4->pic.extra_sei; > + sei->num_payloads = 0; > + > for (i = 0; i < x4->pic.img.i_plane; i++) { > x4->pic.img.plane[i] = frame->data[i]; > x4->pic.img.i_stride[i] = frame->linesize[i]; > @@ -439,6 +446,27 @@ static int X264_frame(AVCodecContext *ctx, AVPacket > *pkt, const AVFrame *frame, > } > } > } > + > + for (int j = 0; j < frame->nb_side_data; j++) { > + AVFrameSideData *side_data = frame->side_data[j]; > + void *tmp; > + x264_sei_payload_t *sei_payload; > + if (side_data->type != AV_FRAME_DATA_SEI_UNREGISTERED) > + continue; > + tmp = av_fast_realloc(x4->sei_data, &x4->sei_data_size, > (sei->num_payloads + 1) * sizeof(*sei_payload)); > + if (!tmp) { > + av_freep(&x4->pic.extra_sei.payloads); > + av_freep(&x4->pic.prop.quant_offsets); > + return AVERROR(ENOMEM); > + } > + x4->sei_data = tmp; > + sei->payloads = x4->sei_data; > + sei_payload = &sei->payloads[sei->num_payloads]; > + sei_payload->payload = side_data->data; > + sei_payload->payload_size = side_data->size; > + sei_payload->payload_type = SEI_TYPE_USER_DATA_UNREGISTERED; > + sei->num_payloads++; > + } > } > > do { > @@ -505,6 +533,8 @@ static av_cold int X264_close(AVCodecContext *avctx) > x264_param_cleanup(&x4->params); > #endif > > + av_freep(&x4->sei_data); > + > if (x4->enc) { > x264_encoder_close(x4->enc); > x4->enc = NULL; > Ping on this patch.
Brad _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".