avcodec/h2645_sei: refactor decode_registered_user_data()

Switch statements are cleaner and will be useful for an upcoming change.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2026-03-12 20:32:34 -03:00
parent 482395f830
commit 64edbb37f1

View File

@@ -161,7 +161,10 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb,
/* itu_t_t35_payload_byte follows */
provider_code = bytestream2_get_be16u(gb);
if (country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == ITU_T_T35_PROVIDER_CODE_ATSC) {
switch (country_code) {
case ITU_T_T35_COUNTRY_CODE_US:
switch (provider_code) {
case ITU_T_T35_PROVIDER_CODE_ATSC: {
uint32_t user_identifier;
if (bytestream2_get_bytes_left(gb) < 4)
@@ -179,53 +182,15 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb,
user_identifier);
break;
}
} else if (country_code == ITU_T_T35_COUNTRY_CODE_UK && provider_code == ITU_T_T35_PROVIDER_CODE_VNOVA) {
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
bytestream2_skipu(gb, 1); // user_data_type_code
return decode_registered_user_data_lcevc(&h->lcevc, gb);
}
break;
}
#if CONFIG_HEVC_SEI
else if (country_code == ITU_T_T35_COUNTRY_CODE_CN && provider_code == ITU_T_T35_PROVIDER_CODE_HDR_VIVID) {
const uint16_t cuva_provider_oriented_code = 0x0005;
uint16_t provider_oriented_code;
if (!IS_HEVC(codec_id))
goto unsupported_provider_code;
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
provider_oriented_code = bytestream2_get_be16u(gb);
if (provider_oriented_code == cuva_provider_oriented_code) {
return decode_registered_user_data_dynamic_hdr_vivid(&h->dynamic_hdr_vivid, gb);
}
} else if(country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == ITU_T_T35_PROVIDER_CODE_SAMSUNG) {
// A/341 Amendment - 2094-40
const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
const uint8_t smpte2094_40_application_identifier = 0x04;
uint16_t provider_oriented_code;
uint8_t application_identifier;
if (!IS_HEVC(codec_id))
goto unsupported_provider_code;
if (bytestream2_get_bytes_left(gb) < 3)
return AVERROR_INVALIDDATA;
provider_oriented_code = bytestream2_get_be16u(gb);
application_identifier = bytestream2_get_byteu(gb);
if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
application_identifier == smpte2094_40_application_identifier) {
return decode_registered_user_data_dynamic_hdr_plus(&h->dynamic_hdr_plus, gb);
}
} else if (country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == ITU_T_T35_PROVIDER_CODE_AOM) {
case ITU_T_T35_PROVIDER_CODE_AOM: {
const uint16_t aom_grain_provider_oriented_code = 0x0001;
uint16_t provider_oriented_code;
if (!IS_HEVC(codec_id))
goto unsupported_provider_code;
break;
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
@@ -236,14 +201,77 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb,
gb->buffer,
bytestream2_get_bytes_left(gb));
}
break;
}
case ITU_T_T35_PROVIDER_CODE_SAMSUNG: {
// A/341 Amendment - 2094-40
const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
const uint8_t smpte2094_40_application_identifier = 0x04;
uint16_t provider_oriented_code;
uint8_t application_identifier;
if (!IS_HEVC(codec_id))
break;
if (bytestream2_get_bytes_left(gb) < 3)
return AVERROR_INVALIDDATA;
provider_oriented_code = bytestream2_get_be16u(gb);
application_identifier = bytestream2_get_byteu(gb);
if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
application_identifier == smpte2094_40_application_identifier) {
return decode_registered_user_data_dynamic_hdr_plus(&h->dynamic_hdr_plus, gb);
}
break;
}
#endif
default:
break;
}
break;
case ITU_T_T35_COUNTRY_CODE_UK:
switch (provider_code) {
case ITU_T_T35_PROVIDER_CODE_VNOVA:
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
bytestream2_skipu(gb, 1); // user_data_type_code
return decode_registered_user_data_lcevc(&h->lcevc, gb);
default:
break;
}
break;
#if CONFIG_HEVC_SEI
case ITU_T_T35_COUNTRY_CODE_CN: {
const uint16_t cuva_provider_oriented_code = 0x0005;
uint16_t provider_oriented_code;
switch (provider_code) {
case ITU_T_T35_PROVIDER_CODE_HDR_VIVID:
if (!IS_HEVC(codec_id))
break;
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
provider_oriented_code = bytestream2_get_be16u(gb);
if (provider_oriented_code == cuva_provider_oriented_code) {
return decode_registered_user_data_dynamic_hdr_vivid(&h->dynamic_hdr_vivid, gb);
}
break;
default:
break;
}
break;
}
#endif
else {
unsupported_provider_code:
default:
break;
}
av_log(logctx, AV_LOG_VERBOSE,
"Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d, provider_code = %d)\n",
country_code, provider_code);
}
return 0;
}