amd/vpelib: Color Keyer Implementation

[New] - New color keyer function. Take input from VPE_STREAM and FORMAT, program - Added color keyer call in Front end - Hard code Alpha Keyer Range to be entire range - Added vpe_is_yuv() to determine if input format is any YUV format. Combines existing functions - Set Per-pixel Alpha in vpelib when stream.enable_luma_key=1

[Updated]
- Updated the macros to include the luma_key field
- Updated vpe10 and resource calls to have mathching function calls
- removed unused data structure for keying mode since hard code keyer mode to 0x3 in real world
- Updated Luma Key enum to properly represent reg spec

[Removed]
- Removed unused alpha keyer struct. Opted to take in directly from stream_ctx

Reviewed-by: Brendan Steve Leder <brendanSteve.leder@amd.com>
Acked-by: Chih-Wei Chien <Chih-Wei.Chien@amd.com>
Signed-off-by: Evan <evan.damphousse@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31605>
This commit is contained in:
Evan 2024-07-09 15:34:20 -04:00 committed by Marge Bot
parent 2272db2ac6
commit 7a293a812a
5 changed files with 34 additions and 30 deletions

View File

@ -870,7 +870,7 @@ void vpe10_dpp_cnv_program_pre_dgam(struct dpp *dpp, enum color_transfer_func tr
void vpe10_dpp_program_cnv_bias_scale(struct dpp *dpp, struct bias_and_scale *bias_and_scale);
void vpe10_dpp_cnv_program_alpha_keyer(struct dpp *dpp, struct cnv_color_keyer_params *color_keyer);
void vpe10_dpp_cnv_program_alpha_keyer(struct dpp *dpp, enum vpe_surface_pixel_format format, bool enable_luma_key, float lower_luma_bound, float upper_luma_bound);
void vpe10_dpp_program_input_transfer_func(struct dpp *dpp, struct transfer_func *input_tf);

View File

@ -346,26 +346,37 @@ void vpe10_dpp_cnv_program_pre_dgam(struct dpp *dpp, enum color_transfer_func tr
VPCNVC_PRE_DEGAM, 0, PRE_DEGAM_MODE, pre_degam_en, PRE_DEGAM_SELECT, degamma_lut_selection);
}
void vpe10_dpp_cnv_program_alpha_keyer(struct dpp *dpp, struct cnv_color_keyer_params *color_keyer)
void vpe10_dpp_cnv_program_alpha_keyer(
struct dpp *dpp,
enum vpe_surface_pixel_format format,
bool enable_luma_key,
float lower_luma_bound,
float upper_luma_bound)
{
uint32_t lower_luma_bound_int = (uint32_t)lower_luma_bound * 65535;
uint32_t upper_luma_bound_int = (uint32_t)upper_luma_bound * 65535;
PROGRAM_ENTRY();
REG_SET_2(VPCNVC_COLOR_KEYER_CONTROL, 0, COLOR_KEYER_EN, color_keyer->color_keyer_en,
COLOR_KEYER_MODE, color_keyer->color_keyer_mode);
REG_SET_2(VPCNVC_COLOR_KEYER_CONTROL, 0,
COLOR_KEYER_EN, enable_luma_key,
COLOR_KEYER_MODE, CNV_COLOR_KEYER_MODE_RANGE_00);
REG_SET_2(VPCNVC_COLOR_KEYER_ALPHA, 0, COLOR_KEYER_ALPHA_LOW,
color_keyer->color_keyer_alpha_low, COLOR_KEYER_ALPHA_HIGH,
color_keyer->color_keyer_alpha_high);
REG_SET_2(VPCNVC_COLOR_KEYER_ALPHA, 0,
COLOR_KEYER_ALPHA_LOW, lower_luma_bound_int,
COLOR_KEYER_ALPHA_HIGH, upper_luma_bound_int);
REG_SET_2(VPCNVC_COLOR_KEYER_RED, 0, COLOR_KEYER_RED_LOW, color_keyer->color_keyer_red_low,
COLOR_KEYER_RED_HIGH, color_keyer->color_keyer_red_high);
REG_SET_2(VPCNVC_COLOR_KEYER_RED, 0,
COLOR_KEYER_RED_LOW, lower_luma_bound_int,
COLOR_KEYER_RED_HIGH, upper_luma_bound_int);
REG_SET_2(VPCNVC_COLOR_KEYER_GREEN, 0, COLOR_KEYER_GREEN_LOW,
color_keyer->color_keyer_green_low, COLOR_KEYER_GREEN_HIGH,
color_keyer->color_keyer_green_high);
REG_SET_2(VPCNVC_COLOR_KEYER_GREEN, 0,
COLOR_KEYER_GREEN_LOW, lower_luma_bound_int,
COLOR_KEYER_GREEN_HIGH, upper_luma_bound_int);
REG_SET_2(VPCNVC_COLOR_KEYER_BLUE, 0, COLOR_KEYER_BLUE_LOW, color_keyer->color_keyer_blue_low,
COLOR_KEYER_BLUE_HIGH, color_keyer->color_keyer_blue_high);
REG_SET_2(VPCNVC_COLOR_KEYER_BLUE, 0,
COLOR_KEYER_BLUE_LOW, lower_luma_bound_int,
COLOR_KEYER_BLUE_HIGH, upper_luma_bound_int);
}
uint32_t vpe10_get_line_buffer_size()

View File

@ -75,6 +75,8 @@ bool vpe_is_yuv444_8(enum vpe_surface_pixel_format format);
bool vpe_is_yuv444_10(enum vpe_surface_pixel_format format);
bool vpe_is_yuv444(enum vpe_surface_pixel_format format);
bool vpe_is_yuv(enum vpe_surface_pixel_format format);
enum color_depth vpe_get_color_depth(enum vpe_surface_pixel_format format);
bool vpe_has_per_pixel_alpha(enum vpe_surface_pixel_format format);

View File

@ -47,21 +47,8 @@ struct cnv_alpha_2bit_lut {
enum CNV_COLOR_KEYER_MODE {
CNV_COLOR_KEYER_MODE_FORCE_00 = 0,
CNV_COLOR_KEYER_MODE_FORCE_FF = 1,
CNV_COLOR_KEYER_MODE_RANGE_00 = 2,
CNV_COLOR_KEYER_MODE_RANGE_FF = 3
};
struct cnv_color_keyer_params {
int color_keyer_en;
int color_keyer_mode;
int color_keyer_alpha_low;
int color_keyer_alpha_high;
int color_keyer_red_low;
int color_keyer_red_high;
int color_keyer_green_low;
int color_keyer_green_high;
int color_keyer_blue_low;
int color_keyer_blue_high;
CNV_COLOR_KEYER_MODE_RANGE_FF = 2,
CNV_COLOR_KEYER_MODE_RANGE_00 = 3
};
enum input_csc_select {
@ -85,7 +72,7 @@ struct dpp_funcs {
void (*program_cnv_bias_scale)(struct dpp *dpp, struct bias_and_scale *bias_and_scale);
void (*program_alpha_keyer)(struct dpp *dpp, struct cnv_color_keyer_params *color_keyer);
void (*program_alpha_keyer)(struct dpp *dpp, enum vpe_surface_pixel_format format, bool enable_luma_key, float lower_luma_bound, float upper_luma_bound);
void (*program_input_transfer_func)(struct dpp *dpp, struct transfer_func *input_tf);

View File

@ -346,10 +346,14 @@ static enum vpe_status populate_input_streams(struct vpe_priv *vpe_priv, const s
stream_ctx = &stream_ctx_base[i];
stream_ctx->stream_type = VPE_STREAM_TYPE_INPUT;
stream_ctx->stream_idx = (int32_t)i;
stream_ctx->per_pixel_alpha =
vpe_has_per_pixel_alpha(param->streams[i].surface_info.format);
if (vpe_priv->init.debug.bypass_per_pixel_alpha) {
stream_ctx->per_pixel_alpha = false;
} else if (param->streams[i].enable_luma_key) {
stream_ctx->per_pixel_alpha = true;
}
if (param->streams[i].horizontal_mirror && !input_h_mirror && output_h_mirror)
stream_ctx->flip_horizonal_output = true;