diff --git a/src/amd/vpelib/src/core/color.c b/src/amd/vpelib/src/core/color.c index 1384a6cb3ce..9bd5e3543cf 100644 --- a/src/amd/vpelib/src/core/color.c +++ b/src/amd/vpelib/src/core/color.c @@ -881,6 +881,9 @@ void vpe_color_get_color_space_and_tf( case VPE_TF_BT709: *tf = TRANSFER_FUNC_BT709; break; + case VPE_TF_HLG: + *tf = TRANSFER_FUNC_HLG; + break; default: break; } @@ -974,7 +977,7 @@ void vpe_convert_full_range_color_enum(enum color_space *cs) bool vpe_is_HDR(enum color_transfer_func tf) { - return (tf == TRANSFER_FUNC_PQ2084 || tf == TRANSFER_FUNC_LINEAR_0_125); + return (tf == TRANSFER_FUNC_PQ2084 || tf == TRANSFER_FUNC_LINEAR_0_125 || tf == TRANSFER_FUNC_HLG); } /* diff --git a/src/amd/vpelib/src/core/common.c b/src/amd/vpelib/src/core/common.c index 1b0fc812612..20654d71ef4 100644 --- a/src/amd/vpelib/src/core/common.c +++ b/src/amd/vpelib/src/core/common.c @@ -295,7 +295,7 @@ bool vpe_has_per_pixel_alpha(enum vpe_surface_pixel_format format) // another function is needed here. static bool is_HDR(enum vpe_transfer_function tf) { - return (tf == VPE_TF_PQ || tf == VPE_TF_G10); + return (tf == VPE_TF_PQ || tf == VPE_TF_G10 || tf == VPE_TF_HLG); } enum vpe_status vpe_check_output_support(struct vpe *vpe, const struct vpe_build_param *param) @@ -565,27 +565,24 @@ enum vpe_status vpe_check_tone_map_support( struct vpe *vpe, const struct vpe_stream *stream, const struct vpe_build_param *param) { enum vpe_status status = VPE_STATUS_OK; + bool input_is_hdr = is_HDR(stream->surface_info.cs.tf); + bool is_3D_lut_enabled = stream->tm_params.enable_3dlut; + bool is_hlg = stream->tm_params.shaper_tf == VPE_TF_HLG; + bool is_in_lum_greater_than_out_lum = stream->hdr_metadata.max_mastering > param->hdr_metadata.max_mastering; - // If tone map enabled but bad luminance reject. - if (stream->tm_params.enable_3dlut && - stream->hdr_metadata.max_mastering <= param->hdr_metadata.max_mastering) { - status = VPE_STATUS_BAD_TONE_MAP_PARAMS; - goto exit; + // Check if Tone Mapping parameters are valid + if (is_3D_lut_enabled) { + if ((stream->tm_params.lut_data == NULL) || + (!input_is_hdr) || + (!is_hlg && !is_in_lum_greater_than_out_lum)) { + status = VPE_STATUS_BAD_TONE_MAP_PARAMS; + } + } else { + if (is_hlg || + (input_is_hdr && is_in_lum_greater_than_out_lum)) { + status = VPE_STATUS_BAD_TONE_MAP_PARAMS; + } } - // If tone map enabled but input is not HDR, reject. - if (stream->tm_params.enable_3dlut && !is_HDR(stream->surface_info.cs.tf)) { - status = VPE_STATUS_BAD_TONE_MAP_PARAMS; - goto exit; - } - - // If tone map case but enable tm flag is not set or 3dlut pointer is null reject. - if (stream->hdr_metadata.max_mastering > param->hdr_metadata.max_mastering && - is_HDR(stream->surface_info.cs.tf) && - (!stream->tm_params.enable_3dlut || stream->tm_params.lut_data == NULL)) { - status = VPE_STATUS_BAD_HDR_METADATA; - } - -exit: return status; } diff --git a/src/amd/vpelib/src/core/inc/color.h b/src/amd/vpelib/src/core/inc/color.h index 4e6db7cb894..8ba007c664a 100644 --- a/src/amd/vpelib/src/core/inc/color.h +++ b/src/amd/vpelib/src/core/inc/color.h @@ -70,7 +70,8 @@ enum color_depth { TRANSFER_FUNC_PQ2084, TRANSFER_FUNC_LINEAR_0_1, TRANSFER_FUNC_LINEAR_0_125, - TRANSFER_FUNC_NORMALIZED_PQ + TRANSFER_FUNC_NORMALIZED_PQ, + TRANSFER_FUNC_HLG }; enum dither_option {