PR #21154 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21154 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21154.patch
>From e86bd0784a28d0baf7f3fb097dcd3f9e2ea8b350 Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Mon, 8 Dec 2025 22:35:33 -0300 Subject: [PATCH 1/3] avcodec/cbs_sei: store a pointer to the start of Registered and Unregistered SEI messages Required for the following commit, where a parsing function expects the buffer to include the country code bytes. Signed-off-by: James Almer <[email protected]> --- libavcodec/cbs_sei.c | 4 ++-- libavcodec/cbs_sei.h | 6 ++++-- libavcodec/cbs_sei_syntax_template.c | 15 ++++++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/libavcodec/cbs_sei.c b/libavcodec/cbs_sei.c index acc3578aa9..d57901f15d 100644 --- a/libavcodec/cbs_sei.c +++ b/libavcodec/cbs_sei.c @@ -28,13 +28,13 @@ static void cbs_free_user_data_registered(AVRefStructOpaque unused, void *obj) { SEIRawUserDataRegistered *udr = obj; - av_refstruct_unref(&udr->data); + av_refstruct_unref(&udr->data_ref); } static void cbs_free_user_data_unregistered(AVRefStructOpaque unused, void *obj) { SEIRawUserDataUnregistered *udu = obj; - av_refstruct_unref(&udu->data); + av_refstruct_unref(&udu->data_ref); } int ff_cbs_sei_alloc_message_payload(SEIRawMessage *message, diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h index 81867b79a7..decc4e19e1 100644 --- a/libavcodec/cbs_sei.h +++ b/libavcodec/cbs_sei.h @@ -33,13 +33,15 @@ typedef struct SEIRawFillerPayload { typedef struct SEIRawUserDataRegistered { uint8_t itu_t_t35_country_code; uint8_t itu_t_t35_country_code_extension_byte; - uint8_t *data; ///< RefStruct reference + uint8_t *data; + uint8_t *data_ref; ///< RefStruct reference size_t data_length; } SEIRawUserDataRegistered; typedef struct SEIRawUserDataUnregistered { uint8_t uuid_iso_iec_11578[16]; - uint8_t *data; ///< RefStruct reference + uint8_t *data; + uint8_t *data_ref; ///< RefStruct reference size_t data_length; } SEIRawUserDataUnregistered; diff --git a/libavcodec/cbs_sei_syntax_template.c b/libavcodec/cbs_sei_syntax_template.c index e6863a0fd7..f70eb24d80 100644 --- a/libavcodec/cbs_sei_syntax_template.c +++ b/libavcodec/cbs_sei_syntax_template.c @@ -57,9 +57,16 @@ SEI_FUNC(user_data_registered, (CodedBitstreamContext *ctx, RWContext *rw, return AVERROR_INVALIDDATA; } current->data_length = state->payload_size - i; -#endif + allocate(current->data_ref, state->payload_size); + current->data = current->data_ref; + + *current->data++ = current->itu_t_t35_country_code; + if (current->itu_t_t35_country_code == 0xff) + *current->data++ = current->itu_t_t35_country_code_extension_byte; +#else allocate(current->data, current->data_length); +#endif for (j = 0; j < current->data_length; j++) xu(8, itu_t_t35_payload_byte[], current->data[j], 0x00, 0xff, 1, i + j); @@ -86,7 +93,13 @@ SEI_FUNC(user_data_unregistered, (CodedBitstreamContext *ctx, RWContext *rw, for (i = 0; i < 16; i++) us(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i); +#ifdef READ + allocate(current->data_ref, state->payload_size); + memcpy(current->data_ref, current->uuid_iso_iec_11578, sizeof(current->uuid_iso_iec_11578)); + current->data = current->data_ref + 16; +#else allocate(current->data, current->data_length); +#endif for (i = 0; i < current->data_length; i++) xu(8, user_data_payload_byte[i], current->data[i], 0x00, 0xff, 1, i); -- 2.49.1 >From 3456c8439a89699123ea2b1a5c4f92e00c688614 Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Mon, 8 Dec 2025 22:36:18 -0300 Subject: [PATCH 2/3] avcodec/vvc/sei: parse Registered and Unregistered SEI messages Signed-off-by: James Almer <[email protected]> --- libavcodec/vvc/sei.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/libavcodec/vvc/sei.c b/libavcodec/vvc/sei.c index cd202edb2a..241943f3c1 100644 --- a/libavcodec/vvc/sei.c +++ b/libavcodec/vvc/sei.c @@ -22,6 +22,7 @@ #include "sei.h" #include "dec.h" +#include "libavcodec/bytestream.h" #include "libavutil/refstruct.h" static int decode_film_grain_characteristics(H2645SEIFilmGrainCharacteristics *h, const SEIRawFilmGrainCharacteristics *s, const VVCFrameContext *fc) @@ -176,6 +177,27 @@ static int decode_mastering_display_colour_volume(H2645SEIMasteringDisplay *h, c return 0; } +static int decode_user_data_registered_itu_t_t35(H2645SEI *sei, const SEIRawUserDataRegistered *s, + const VVCFrameContext *fc) +{ + GetByteContext gbc; + int offset = (s->itu_t_t35_country_code == 0xff) + 1; + + bytestream2_init(&gbc, s->data_ref, s->data_length + offset); + return ff_h2645_sei_message_decode(sei, SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35, + AV_CODEC_ID_VVC, NULL, &gbc, fc->log_ctx); +} + +static int decode_user_data_uregistered(H2645SEI *sei, const SEIRawUserDataUnregistered *s, + const VVCFrameContext *fc) +{ + GetByteContext gbc; + + bytestream2_init(&gbc, s->data_ref, s->data_length + 16); + return ff_h2645_sei_message_decode(sei, SEI_TYPE_USER_DATA_UNREGISTERED, + AV_CODEC_ID_VVC, NULL, &gbc, fc->log_ctx); +} + int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc) { H2645SEI *c = &s->common; @@ -221,6 +243,14 @@ int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameCon ret = decode_mastering_display_colour_volume(&s->common.mastering_display, payload); break; + case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: + ret = decode_user_data_registered_itu_t_t35(&s->common, payload, fc); + break; + + case SEI_TYPE_USER_DATA_UNREGISTERED: + ret = decode_user_data_uregistered(&s->common, payload, fc); + break; + default: av_log(fc->log_ctx, AV_LOG_DEBUG, "Skipped %s SEI %d\n", sei->nal_unit_header.nal_unit_type == VVC_PREFIX_SEI_NUT ? -- 2.49.1 >From 7ac1a20f5319c19190dac6bf0115c9bb36d82261 Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Tue, 9 Dec 2025 14:36:22 -0300 Subject: [PATCH 3/3] avcodec/vvc/refs: export in-band LCEVC side data in frames Signed-off-by: James Almer <[email protected]> --- libavcodec/vvc/dec.c | 5 +++-- libavcodec/vvc/refs.c | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c index 028f34b491..194e2fc7ef 100644 --- a/libavcodec/vvc/dec.c +++ b/libavcodec/vvc/dec.c @@ -807,11 +807,11 @@ static int frame_start(VVCContext *s, VVCFrameContext *fc, SliceContext *sc) if (!s->temporal_id && !ph->r->ph_non_ref_pic_flag && !(IS_RASL(s) || IS_RADL(s))) s->poc_tid0 = ph->poc; + decode_prefix_sei(fc, s); + if ((ret = ff_vvc_set_new_ref(s, fc, &fc->frame)) < 0) goto fail; - decode_prefix_sei(fc, s); - ret = set_side_data(s, fc); if (ret < 0) goto fail; @@ -1225,6 +1225,7 @@ static av_cold void vvc_decode_flush(AVCodecContext *avctx) if (s->fcs) { VVCFrameContext *last = get_frame_context(s, s->fcs, s->nb_frames - 1); + ff_vvc_sei_reset(&last->sei); ff_vvc_flush_dpb(last); } diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c index f134a100b4..c1f027aed5 100644 --- a/libavcodec/vvc/refs.c +++ b/libavcodec/vvc/refs.c @@ -133,6 +133,15 @@ static VVCFrame *alloc_frame(VVCContext *s, VVCFrameContext *fc) frame->sps = av_refstruct_ref_c(fc->ps.sps); frame->pps = av_refstruct_ref_c(fc->ps.pps); + // Add LCEVC SEI metadata here, as it's needed in get_buffer() + if (fc->sei.common.lcevc.info) { + HEVCSEILCEVC *lcevc = &fc->sei.common.lcevc; + ret = ff_frame_new_side_data_from_buf(s->avctx, frame->frame, + AV_FRAME_DATA_LCEVC, &lcevc->info); + if (ret < 0) + goto fail; + } + ret = ff_thread_get_buffer(s->avctx, frame->frame, AV_GET_BUFFER_FLAG_REF); if (ret < 0) return NULL; -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
