From 7d326ab0829787605446450c49f70c8e08d196dd Mon Sep 17 00:00:00 2001 From: "Chen, Phoebe" Date: Mon, 2 Dec 2024 10:51:06 -0500 Subject: [PATCH] amd/vpelib: Refactor YUV format check Using general vpe_is_yuv* helper function for the condition check Reviewed-by: Evan Damphousse Reviewed-by: Roy Chan Reviewed-by: Navid Assadian Acked-by: Chih-Wei Chien Signed-off-by: Phoebe Chen Part-of: --- src/amd/vpelib/src/core/color.c | 4 ++-- src/amd/vpelib/src/core/common.c | 12 ++++++++++++ src/amd/vpelib/src/core/inc/common.h | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/amd/vpelib/src/core/color.c b/src/amd/vpelib/src/core/color.c index 73ab5351bea..d5f0b47f7b2 100644 --- a/src/amd/vpelib/src/core/color.c +++ b/src/amd/vpelib/src/core/color.c @@ -399,7 +399,7 @@ static bool build_scale_and_bias(struct bias_and_scale *bias_and_scale, scale = vpe_fixpt_from_fraction(1024, 940 - 64); bias = vpe_fixpt_from_fraction(-64, 1024); } // else report error? here just go with default (1.0, 0.0) - } else if (vpe_is_yuv420_8(format) || vpe_is_yuv444_8(format)) { + } else if (vpe_is_yuv8(format)) { if (vcs->range == VPE_COLOR_RANGE_FULL) { scale = vpe_fixpt_from_fraction(256, 255); } else if (vcs->range == VPE_COLOR_RANGE_STUDIO) { @@ -409,7 +409,7 @@ static bool build_scale_and_bias(struct bias_and_scale *bias_and_scale, bias_c = vpe_fixpt_from_fraction(-16, 256); // See notes in function comment is_chroma_different = true; } // else report error? not sure if default is right - } else if (vpe_is_yuv420_10(format) || vpe_is_yuv444_10(format)) { + } else if (vpe_is_yuv10(format)) { if (vcs->range == VPE_COLOR_RANGE_FULL) { scale = vpe_fixpt_from_fraction(1024, 1023); } else if (vcs->range == VPE_COLOR_RANGE_STUDIO) { diff --git a/src/amd/vpelib/src/core/common.c b/src/amd/vpelib/src/core/common.c index 763d7893713..f31b009a4e1 100644 --- a/src/amd/vpelib/src/core/common.c +++ b/src/amd/vpelib/src/core/common.c @@ -196,6 +196,18 @@ bool vpe_is_yuv444(enum vpe_surface_pixel_format format) vpe_is_yuv444_10(format)); } +bool vpe_is_yuv8(enum vpe_surface_pixel_format format) +{ + return (vpe_is_yuv420_8(format) || + vpe_is_yuv444_8(format)); +} + +bool vpe_is_yuv10(enum vpe_surface_pixel_format format) +{ + return (vpe_is_yuv420_10(format) || + vpe_is_yuv444_10(format)); +} + bool vpe_is_yuv(enum vpe_surface_pixel_format format) { return (vpe_is_yuv420(format) || diff --git a/src/amd/vpelib/src/core/inc/common.h b/src/amd/vpelib/src/core/inc/common.h index 5bfecf54b18..5e8f9a2cf80 100644 --- a/src/amd/vpelib/src/core/inc/common.h +++ b/src/amd/vpelib/src/core/inc/common.h @@ -64,6 +64,9 @@ bool vpe_is_rgb8(enum vpe_surface_pixel_format format); bool vpe_is_rgb10(enum vpe_surface_pixel_format format); bool vpe_is_fp16(enum vpe_surface_pixel_format format); +bool vpe_is_yuv8(enum vpe_surface_pixel_format format); +bool vpe_is_yuv10(enum vpe_surface_pixel_format format); + // yuv 4:2:0 check bool vpe_is_yuv420_8(enum vpe_surface_pixel_format format); bool vpe_is_yuv420_10(enum vpe_surface_pixel_format format);