mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-20 07:54:32 +08:00
feat[mpp_dec]: support hdr10plus dynamic metadata parse
The HDR10PLUS data parser reference link: https://www.atsc.org/wp-content/uploads/2018/02/S34-301r2-A341-Amendment-2094-40.pdf Change-Id: If7f8284d21aebdec5a71c4dbf6196a53ab2cebb8 Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
This commit is contained in:
@@ -2447,6 +2447,39 @@ __BITREAD_ERR:
|
||||
return MPP_ERR_STREAM;
|
||||
}
|
||||
|
||||
static void mpp_av1_fill_dynamic_meta(AV1Context *ctx, const RK_U8 *data, RK_U32 size, RK_U32 hdr_fmt)
|
||||
{
|
||||
MppFrameHdrDynamicMeta *hdr_dynamic_meta = ctx->hdr_dynamic_meta;
|
||||
|
||||
if (hdr_dynamic_meta && (hdr_dynamic_meta->size < size)) {
|
||||
mpp_free(hdr_dynamic_meta);
|
||||
hdr_dynamic_meta = NULL;
|
||||
}
|
||||
|
||||
if (!hdr_dynamic_meta) {
|
||||
hdr_dynamic_meta = mpp_calloc_size(MppFrameHdrDynamicMeta,
|
||||
sizeof(MppFrameHdrDynamicMeta) + size);
|
||||
if (!hdr_dynamic_meta) {
|
||||
mpp_err_f("malloc hdr dynamic data failed!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (size && data) {
|
||||
switch (hdr_fmt) {
|
||||
case HDR10PLUS: {
|
||||
memcpy((RK_U8*)hdr_dynamic_meta->data, (RK_U8*)data, size);
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
hdr_dynamic_meta->size = size;
|
||||
hdr_dynamic_meta->hdr_fmt = hdr_fmt;
|
||||
|
||||
ctx->hdr_dynamic_meta = hdr_dynamic_meta;
|
||||
ctx->hdr_dynamic = 1;
|
||||
ctx->is_hdr = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static RK_S32 mpp_av1_metadata_itut_t35(AV1Context *ctx, BitReadCtx_t *gb,
|
||||
AV1RawMetadataITUTT35 *current)
|
||||
{
|
||||
@@ -2462,18 +2495,37 @@ static RK_S32 mpp_av1_metadata_itut_t35(AV1Context *ctx, BitReadCtx_t *gb,
|
||||
__func__, current->itu_t_t35_country_code, current->payload_size);
|
||||
|
||||
fb(16, itu_t_t35_terminal_provider_code);
|
||||
READ_BITS_LONG(gb, 32, ¤t->itu_t_t35_terminal_provider_oriented_code);
|
||||
|
||||
av1d_dbg(AV1D_DBG_STRMIN, "itu_t_t35_country_code 0x%x\n",
|
||||
current->itu_t_t35_country_code);
|
||||
av1d_dbg(AV1D_DBG_STRMIN, "itu_t_t35_terminal_provider_code 0x%x\n",
|
||||
current->itu_t_t35_terminal_provider_code);
|
||||
av1d_dbg(AV1D_DBG_STRMIN, "itu_t_t35_terminal_provider_oriented_code 0x%x\n",
|
||||
current->itu_t_t35_terminal_provider_oriented_code);
|
||||
|
||||
if (current->itu_t_t35_terminal_provider_code == 0x3B &&
|
||||
current->itu_t_t35_terminal_provider_oriented_code == 0x800)
|
||||
mpp_av1_get_dolby_rpu(ctx, gb);
|
||||
switch (current->itu_t_t35_terminal_provider_code) {
|
||||
case 0x3B: {/* dolby provider_code is 0x3b*/
|
||||
READ_BITS_LONG(gb, 32, ¤t->itu_t_t35_terminal_provider_oriented_code);
|
||||
av1d_dbg(AV1D_DBG_STRMIN, "itu_t_t35_terminal_provider_oriented_code 0x%x\n",
|
||||
current->itu_t_t35_terminal_provider_oriented_code);
|
||||
if (current->itu_t_t35_terminal_provider_oriented_code == 0x800)
|
||||
mpp_av1_get_dolby_rpu(ctx, gb);
|
||||
} break;
|
||||
case 0x3C: {/* smpte2094_40 provider_code is 0x3c*/
|
||||
const RK_U16 smpte2094_40_provider_oriented_code = 0x0001;
|
||||
const RK_U8 smpte2094_40_application_identifier = 0x04;
|
||||
RK_U8 application_identifier;
|
||||
|
||||
fb(16, itu_t_t35_terminal_provider_oriented_code);
|
||||
av1d_dbg(AV1D_DBG_STRMIN, "itu_t_t35_terminal_provider_oriented_code 0x%x\n",
|
||||
current->itu_t_t35_terminal_provider_oriented_code);
|
||||
READ_BITS(gb, 8, &application_identifier);
|
||||
/* hdr10plus priverder_oriented_code is 0x0001, application_identifier is 0x04 */
|
||||
if (current->itu_t_t35_terminal_provider_oriented_code == smpte2094_40_provider_oriented_code &&
|
||||
application_identifier == smpte2094_40_application_identifier)
|
||||
mpp_av1_fill_dynamic_meta(ctx, gb->data_, mpp_get_bits_left(gb) >> 3, HDR10PLUS);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
__BITREAD_ERR:
|
||||
|
@@ -1720,13 +1720,20 @@ void mpp_hevc_fill_dynamic_meta(HEVCContext *s, const RK_U8 *data, RK_U32 size,
|
||||
}
|
||||
}
|
||||
if (size && data) {
|
||||
if (hdr_fmt == DOLBY) {
|
||||
switch (hdr_fmt) {
|
||||
case DOLBY: {
|
||||
RK_U8 start_code[4] = {0, 0, 0, 1};
|
||||
|
||||
memcpy((RK_U8*)hdr_dynamic_meta->data, start_code, 4);
|
||||
memcpy((RK_U8*)hdr_dynamic_meta->data + 4, (RK_U8*)data, size - 4);
|
||||
} else
|
||||
} break;
|
||||
case HDRVIVID:
|
||||
case HDR10PLUS: {
|
||||
memcpy((RK_U8*)hdr_dynamic_meta->data, (RK_U8*)data, size);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
hdr_dynamic_meta->size = size;
|
||||
hdr_dynamic_meta->hdr_fmt = hdr_fmt;
|
||||
}
|
||||
|
@@ -336,10 +336,17 @@ static RK_S32 vivid_display_info(HEVCContext *s, BitReadCtx_t *gb, RK_U32 size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static RK_S32 hdr10plus_dynamic_data(HEVCContext *s, BitReadCtx_t *gb, RK_U32 size)
|
||||
{
|
||||
if (gb)
|
||||
mpp_hevc_fill_dynamic_meta(s, gb->data_, size, HDR10PLUS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static RK_S32 user_data_registered_itu_t_t35(HEVCContext *s, BitReadCtx_t *gb, int size)
|
||||
{
|
||||
RK_S32 country_code, provider_code;
|
||||
RK_U16 terminal_provide_oriented_code;
|
||||
RK_U16 provider_oriented_code;
|
||||
|
||||
if (size < 3)
|
||||
return 0;
|
||||
@@ -359,11 +366,27 @@ static RK_S32 user_data_registered_itu_t_t35(HEVCContext *s, BitReadCtx_t *gb, i
|
||||
}
|
||||
|
||||
READ_BITS(gb, 16, &provider_code);
|
||||
READ_BITS(gb, 16, &terminal_provide_oriented_code);
|
||||
READ_BITS(gb, 16, &provider_oriented_code);
|
||||
h265d_dbg(H265D_DBG_SEI, "country_code=%d provider_code=%d terminal_provider_code %d\n",
|
||||
country_code, provider_code, terminal_provide_oriented_code);
|
||||
if (provider_code == 4)
|
||||
country_code, provider_code, provider_oriented_code);
|
||||
switch (provider_code) {
|
||||
case 0x4: {/* cuva provider_code is 0x4 */
|
||||
vivid_display_info(s, gb, mpp_get_bits_left(gb) >> 3);
|
||||
} break;
|
||||
case 0x3c: {/* smpte2094_40 provider_code is 0x3c*/
|
||||
const RK_U16 smpte2094_40_provider_oriented_code = 0x0001;
|
||||
const RK_U8 smpte2094_40_application_identifier = 0x04;
|
||||
RK_U8 application_identifier;
|
||||
|
||||
READ_BITS(gb, 8, &application_identifier);
|
||||
/* hdr10plus priverder_oriented_code is 0x0001, application_identifier is 0x04 */
|
||||
if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
|
||||
application_identifier == smpte2094_40_application_identifier)
|
||||
hdr10plus_dynamic_data(s, gb, mpp_get_bits_left(gb) >> 3);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
Reference in New Issue
Block a user