#include "dc_spl.h"
#include "dc_spl_scl_easf_filters.h"
#include "dc_spl_isharp_filters.h"
#include "spl_debug.h"
#define IDENTITY_RATIO(ratio) (SPL_NAMESPACE(spl_fixpt_u3d19(ratio)) == (1 << 19))
#define MIN_VIEWPORT_SIZE 12
static bool spl_is_yuv420(enum spl_pixel_format format)
{
if ((format >= SPL_PIXEL_FORMAT_420BPP8) &&
(format <= SPL_PIXEL_FORMAT_420BPP10))
return true;
return false;
}
static bool spl_is_rgb8(enum spl_pixel_format format)
{
if (format == SPL_PIXEL_FORMAT_ARGB8888)
return true;
return false;
}
static bool spl_is_video_format(enum spl_pixel_format format)
{
if (format >= SPL_PIXEL_FORMAT_VIDEO_BEGIN
&& format <= SPL_PIXEL_FORMAT_VIDEO_END)
return true;
else
return false;
}
static bool spl_is_subsampled_format(enum spl_pixel_format format)
{
if (format >= SPL_PIXEL_FORMAT_SUBSAMPLED_BEGIN
&& format <= SPL_PIXEL_FORMAT_SUBSAMPLED_END)
return true;
else
return false;
}
static struct spl_rect intersect_rec(const struct spl_rect *r0, const struct spl_rect *r1)
{
struct spl_rect rec;
int r0_x_end = r0->x + r0->width;
int r1_x_end = r1->x + r1->width;
int r0_y_end = r0->y + r0->height;
int r1_y_end = r1->y + r1->height;
rec.x = r0->x > r1->x ? r0->x : r1->x;
rec.width = r0_x_end > r1_x_end ? r1_x_end - rec.x : r0_x_end - rec.x;
rec.y = r0->y > r1->y ? r0->y : r1->y;
rec.height = r0_y_end > r1_y_end ? r1_y_end - rec.y : r0_y_end - rec.y;
if (rec.width < 0 || rec.height < 0)
memset(&rec, 0, sizeof(rec));
return rec;
}
static struct spl_rect shift_rec(const struct spl_rect *rec_in, int x, int y)
{
struct spl_rect rec_out = *rec_in;
rec_out.x += x;
rec_out.y += y;
return rec_out;
}
static void spl_opp_adjust_rect(struct spl_rect *rec, const struct spl_opp_adjust *adjust)
{
if ((rec->x + adjust->x) >= 0)
rec->x += adjust->x;
if ((rec->y + adjust->y) >= 0)
rec->y += adjust->y;
if ((rec->width + adjust->width) >= 1)
rec->width += adjust->width;
if ((rec->height + adjust->height) >= 1)
rec->height += adjust->height;
}
static struct spl_rect calculate_plane_rec_in_timing_active(
struct spl_in *spl_in,
const struct spl_rect *rec_in)
{
const struct spl_rect *stream_src = &spl_in->basic_out.src_rect;
const struct spl_rect *stream_dst = &spl_in->basic_out.dst_rect;
struct spl_rect rec_out = {0};
struct spl_fixed31_32 temp;
temp = SPL_NAMESPACE(spl_fixpt_from_fraction(
rec_in->x * (long long)stream_dst->width,
stream_src->width));
rec_out.x = stream_dst->x + spl_fixpt_round(temp);
temp = SPL_NAMESPACE(spl_fixpt_from_fraction(
(rec_in->x + rec_in->width) * (long long)stream_dst->width,
stream_src->width));
rec_out.width = stream_dst->x + spl_fixpt_round(temp) - rec_out.x;
temp = SPL_NAMESPACE(spl_fixpt_from_fraction(
rec_in->y * (long long)stream_dst->height,
stream_src->height));
rec_out.y = stream_dst->y + spl_fixpt_round(temp);
temp = SPL_NAMESPACE(spl_fixpt_from_fraction(
(rec_in->y + rec_in->height) * (long long)stream_dst->height,
stream_src->height));
rec_out.height = stream_dst->y + spl_fixpt_round(temp) - rec_out.y;
return rec_out;
}
static struct spl_rect calculate_mpc_slice_in_timing_active(
struct spl_in *spl_in,
struct spl_rect *plane_clip_rec)
{
bool use_recout_width_aligned =
spl_in->basic_in.num_h_slices_recout_width_align.use_recout_width_aligned;
int mpc_slice_count =
spl_in->basic_in.num_h_slices_recout_width_align.num_slices_recout_width.mpc_num_h_slices;
int recout_width_align =
spl_in->basic_in.num_h_slices_recout_width_align.num_slices_recout_width.mpc_recout_width_align;
int mpc_slice_idx = spl_in->basic_in.mpc_h_slice_index;
int epimo = mpc_slice_count - plane_clip_rec->width % mpc_slice_count - 1;
struct spl_rect mpc_rec;
if (spl_in->basic_in.custom_width != 0) {
mpc_rec.width = spl_in->basic_in.custom_width;
mpc_rec.x = spl_in->basic_in.custom_x;
mpc_rec.height = plane_clip_rec->height;
mpc_rec.y = plane_clip_rec->y;
} else if (use_recout_width_aligned) {
mpc_rec.width = recout_width_align;
if ((mpc_rec.width * (mpc_slice_idx + 1)) > plane_clip_rec->width) {
mpc_rec.width = plane_clip_rec->width % recout_width_align;
mpc_rec.x = plane_clip_rec->x + recout_width_align * mpc_slice_idx;
} else
mpc_rec.x = plane_clip_rec->x + mpc_rec.width * mpc_slice_idx;
mpc_rec.height = plane_clip_rec->height;
mpc_rec.y = plane_clip_rec->y;
} else {
mpc_rec.width = plane_clip_rec->width / mpc_slice_count;
mpc_rec.x = plane_clip_rec->x + mpc_rec.width * mpc_slice_idx;
mpc_rec.height = plane_clip_rec->height;
mpc_rec.y = plane_clip_rec->y;
}
SPL_ASSERT(mpc_slice_count == 1 ||
spl_in->basic_out.view_format != SPL_VIEW_3D_SIDE_BY_SIDE ||
mpc_rec.width % 2 == 0);
if ((use_recout_width_aligned == false) &&
mpc_slice_idx > epimo && spl_in->basic_in.custom_width == 0) {
mpc_rec.x += mpc_slice_idx - epimo - 1;
mpc_rec.width += 1;
}
if (spl_in->basic_out.view_format == SPL_VIEW_3D_TOP_AND_BOTTOM) {
SPL_ASSERT(mpc_rec.height % 2 == 0);
mpc_rec.height /= 2;
}
return mpc_rec;
}
static struct spl_rect calculate_odm_slice_in_timing_active(struct spl_in *spl_in)
{
int odm_slice_count = spl_in->basic_out.odm_combine_factor;
int odm_slice_idx = spl_in->odm_slice_index;
bool is_last_odm_slice = (odm_slice_idx + 1) == odm_slice_count;
int h_active = spl_in->basic_out.output_size.width;
int v_active = spl_in->basic_out.output_size.height;
int odm_slice_width;
struct spl_rect odm_rec;
if (spl_in->basic_out.odm_combine_factor > 0) {
odm_slice_width = h_active / odm_slice_count;
if (spl_in->basic_out.use_two_pixels_per_container && (odm_slice_width % 2))
odm_slice_width++;
odm_rec.x = odm_slice_width * odm_slice_idx;
odm_rec.width = is_last_odm_slice ?
h_active - odm_slice_width * (odm_slice_count - 1) :
odm_slice_width;
odm_rec.y = 0;
odm_rec.height = v_active;
return odm_rec;
}
return spl_in->basic_out.odm_slice_rect;
}
static void spl_calculate_recout(struct spl_in *spl_in, struct spl_scratch *spl_scratch, struct spl_out *spl_out)
{
struct spl_rect plane_clip;
struct spl_rect mpc_slice_of_plane_clip;
struct spl_rect odm_slice;
struct spl_rect overlapping_area;
plane_clip = calculate_plane_rec_in_timing_active(spl_in,
&spl_in->basic_in.clip_rect);
plane_clip = intersect_rec(&plane_clip,
&spl_in->basic_out.dst_rect);
mpc_slice_of_plane_clip = calculate_mpc_slice_in_timing_active(
spl_in, &plane_clip);
odm_slice = calculate_odm_slice_in_timing_active(spl_in);
overlapping_area = intersect_rec(&mpc_slice_of_plane_clip, &odm_slice);
if (overlapping_area.height > 0 &&
overlapping_area.width > 0) {
spl_scratch->scl_data.recout = shift_rec(
&overlapping_area,
-odm_slice.x, -odm_slice.y);
spl_scratch->scl_data.recout.height -=
spl_in->debug.visual_confirm_base_offset;
spl_scratch->scl_data.recout.height -=
spl_in->debug.visual_confirm_dpp_offset;
} else
memset(&spl_scratch->scl_data.recout, 0,
sizeof(struct spl_rect));
}
static void spl_calculate_scaling_ratios(struct spl_in *spl_in,
struct spl_scratch *spl_scratch,
struct spl_out *spl_out)
{
const int in_w = spl_in->basic_out.src_rect.width;
const int in_h = spl_in->basic_out.src_rect.height;
const int out_w = spl_in->basic_out.dst_rect.width;
const int out_h = spl_in->basic_out.dst_rect.height;
struct spl_rect surf_src = spl_in->basic_in.src_rect;
if (spl_in->basic_in.rotation == SPL_ROTATION_ANGLE_90 ||
spl_in->basic_in.rotation == SPL_ROTATION_ANGLE_270)
spl_swap(surf_src.height, surf_src.width);
spl_scratch->scl_data.ratios.horz = SPL_NAMESPACE(spl_fixpt_from_fraction(
surf_src.width,
spl_in->basic_in.dst_rect.width));
spl_scratch->scl_data.ratios.vert = SPL_NAMESPACE(spl_fixpt_from_fraction(
surf_src.height,
spl_in->basic_in.dst_rect.height));
if (spl_in->basic_out.view_format == SPL_VIEW_3D_SIDE_BY_SIDE)
spl_scratch->scl_data.ratios.horz.value *= 2;
else if (spl_in->basic_out.view_format == SPL_VIEW_3D_TOP_AND_BOTTOM)
spl_scratch->scl_data.ratios.vert.value *= 2;
spl_scratch->scl_data.ratios.vert.value = spl_div64_s64(
spl_scratch->scl_data.ratios.vert.value * in_h, out_h);
spl_scratch->scl_data.ratios.horz.value = spl_div64_s64(
spl_scratch->scl_data.ratios.horz.value * in_w, out_w);
spl_scratch->scl_data.ratios.horz_c = spl_scratch->scl_data.ratios.horz;
spl_scratch->scl_data.ratios.vert_c = spl_scratch->scl_data.ratios.vert;
if (spl_is_yuv420(spl_in->basic_in.format)) {
spl_scratch->scl_data.ratios.horz_c.value /= 2;
spl_scratch->scl_data.ratios.vert_c.value /= 2;
}
spl_scratch->scl_data.ratios.horz = spl_fixpt_truncate(
spl_scratch->scl_data.ratios.horz, 19);
spl_scratch->scl_data.ratios.vert = spl_fixpt_truncate(
spl_scratch->scl_data.ratios.vert, 19);
spl_scratch->scl_data.ratios.horz_c = spl_fixpt_truncate(
spl_scratch->scl_data.ratios.horz_c, 19);
spl_scratch->scl_data.ratios.vert_c = spl_fixpt_truncate(
spl_scratch->scl_data.ratios.vert_c, 19);
spl_scratch->scl_data.recip_ratios.horz = SPL_NAMESPACE(spl_fixpt_recip(
spl_scratch->scl_data.ratios.horz));
spl_scratch->scl_data.recip_ratios.vert = SPL_NAMESPACE(spl_fixpt_recip(
spl_scratch->scl_data.ratios.vert));
spl_scratch->scl_data.recip_ratios.horz_c = SPL_NAMESPACE(spl_fixpt_recip(
spl_scratch->scl_data.ratios.horz_c));
spl_scratch->scl_data.recip_ratios.vert_c = SPL_NAMESPACE(spl_fixpt_recip(
spl_scratch->scl_data.ratios.vert_c));
}
static void spl_calculate_viewport_size(struct spl_in *spl_in, struct spl_scratch *spl_scratch)
{
spl_scratch->scl_data.viewport.width = spl_fixpt_ceil(spl_fixpt_mul_int(spl_scratch->scl_data.ratios.horz,
spl_scratch->scl_data.recout.width));
spl_scratch->scl_data.viewport.height = spl_fixpt_ceil(spl_fixpt_mul_int(spl_scratch->scl_data.ratios.vert,
spl_scratch->scl_data.recout.height));
spl_scratch->scl_data.viewport_c.width = spl_fixpt_ceil(spl_fixpt_mul_int(spl_scratch->scl_data.ratios.horz_c,
spl_scratch->scl_data.recout.width));
spl_scratch->scl_data.viewport_c.height = spl_fixpt_ceil(spl_fixpt_mul_int(spl_scratch->scl_data.ratios.vert_c,
spl_scratch->scl_data.recout.height));
if (spl_in->basic_in.rotation == SPL_ROTATION_ANGLE_90 ||
spl_in->basic_in.rotation == SPL_ROTATION_ANGLE_270) {
spl_swap(spl_scratch->scl_data.viewport.width, spl_scratch->scl_data.viewport.height);
spl_swap(spl_scratch->scl_data.viewport_c.width, spl_scratch->scl_data.viewport_c.height);
}
}
static void spl_get_vp_scan_direction(enum spl_rotation_angle rotation,
bool horizontal_mirror,
bool *orthogonal_rotation,
bool *flip_vert_scan_dir,
bool *flip_horz_scan_dir)
{
*orthogonal_rotation = false;
*flip_vert_scan_dir = false;
*flip_horz_scan_dir = false;
if (rotation == SPL_ROTATION_ANGLE_180) {
*flip_vert_scan_dir = true;
*flip_horz_scan_dir = true;
} else if (rotation == SPL_ROTATION_ANGLE_90) {
*orthogonal_rotation = true;
*flip_horz_scan_dir = true;
} else if (rotation == SPL_ROTATION_ANGLE_270) {
*orthogonal_rotation = true;
*flip_vert_scan_dir = true;
}
if (horizontal_mirror)
*flip_horz_scan_dir = !*flip_horz_scan_dir;
}
static void spl_calculate_init_and_vp(bool flip_scan_dir,
int recout_offset_within_recout_full,
int recout_size,
int src_size,
int taps,
struct spl_fixed31_32 ratio,
struct spl_fixed31_32 init_adj,
struct spl_fixed31_32 *init,
int *vp_offset,
int *vp_size)
{
struct spl_fixed31_32 temp;
int int_part;
temp = spl_fixpt_mul_int(ratio, recout_offset_within_recout_full);
*vp_offset = spl_fixpt_floor(temp);
temp.value &= 0xffffffff;
*init = spl_fixpt_add(spl_fixpt_div_int(spl_fixpt_add_int(ratio, taps + 1), 2), temp);
*init = spl_fixpt_add(*init, init_adj);
*init = spl_fixpt_truncate(*init, 19);
int_part = spl_fixpt_floor(*init);
if (int_part < taps) {
int_part = taps - int_part;
if (int_part > *vp_offset)
int_part = *vp_offset;
*vp_offset -= int_part;
*init = spl_fixpt_add_int(*init, int_part);
}
temp = spl_fixpt_add(*init, spl_fixpt_mul_int(ratio, recout_size - 1));
*vp_size = spl_fixpt_floor(temp);
if (*vp_size + *vp_offset > src_size)
*vp_size = src_size - *vp_offset;
if (flip_scan_dir)
*vp_offset = src_size - *vp_offset - *vp_size;
}
static void spl_calculate_inits_and_viewports(struct spl_in *spl_in,
struct spl_scratch *spl_scratch)
{
struct spl_rect src = spl_in->basic_in.src_rect;
struct spl_rect recout_dst_in_active_timing;
struct spl_rect recout_clip_in_active_timing;
struct spl_rect recout_clip_in_recout_dst;
struct spl_rect overlap_in_active_timing;
struct spl_rect odm_slice = calculate_odm_slice_in_timing_active(spl_in);
int vpc_div = spl_is_subsampled_format(spl_in->basic_in.format) ? 2 : 1;
bool orthogonal_rotation, flip_vert_scan_dir, flip_horz_scan_dir;
struct spl_fixed31_32 init_adj_h = spl_fixpt_zero;
struct spl_fixed31_32 init_adj_v = spl_fixpt_zero;
recout_clip_in_active_timing = shift_rec(
&spl_scratch->scl_data.recout, odm_slice.x, odm_slice.y);
recout_dst_in_active_timing = calculate_plane_rec_in_timing_active(
spl_in, &spl_in->basic_in.dst_rect);
overlap_in_active_timing = intersect_rec(&recout_clip_in_active_timing,
&recout_dst_in_active_timing);
if (overlap_in_active_timing.width > 0 &&
overlap_in_active_timing.height > 0)
recout_clip_in_recout_dst = shift_rec(&overlap_in_active_timing,
-recout_dst_in_active_timing.x,
-recout_dst_in_active_timing.y);
else
memset(&recout_clip_in_recout_dst, 0, sizeof(struct spl_rect));
spl_get_vp_scan_direction(
spl_in->basic_in.rotation,
spl_in->basic_in.horizontal_mirror,
&orthogonal_rotation,
&flip_vert_scan_dir,
&flip_horz_scan_dir);
if (spl_is_subsampled_format(spl_in->basic_in.format)) {
int h_sign = flip_horz_scan_dir ? -1 : 1;
int v_sign = flip_vert_scan_dir ? -1 : 1;
switch (spl_in->basic_in.cositing) {
case CHROMA_COSITING_TOPLEFT:
init_adj_h = SPL_NAMESPACE(spl_fixpt_from_fraction(h_sign, 4));
init_adj_v = SPL_NAMESPACE(spl_fixpt_from_fraction(v_sign, 4));
break;
case CHROMA_COSITING_LEFT:
init_adj_h = SPL_NAMESPACE(spl_fixpt_from_fraction(h_sign, 4));
init_adj_v = spl_fixpt_zero;
break;
case CHROMA_COSITING_NONE:
default:
init_adj_h = spl_fixpt_zero;
init_adj_v = spl_fixpt_zero;
break;
}
}
if (orthogonal_rotation) {
spl_swap(src.width, src.height);
spl_swap(flip_vert_scan_dir, flip_horz_scan_dir);
spl_swap(init_adj_h, init_adj_v);
}
spl_calculate_init_and_vp(
flip_horz_scan_dir,
recout_clip_in_recout_dst.x,
spl_scratch->scl_data.recout.width,
src.width,
spl_scratch->scl_data.taps.h_taps,
spl_scratch->scl_data.ratios.horz,
spl_fixpt_zero,
&spl_scratch->scl_data.inits.h,
&spl_scratch->scl_data.viewport.x,
&spl_scratch->scl_data.viewport.width);
spl_calculate_init_and_vp(
flip_horz_scan_dir,
recout_clip_in_recout_dst.x,
spl_scratch->scl_data.recout.width,
src.width / vpc_div,
spl_scratch->scl_data.taps.h_taps_c,
spl_scratch->scl_data.ratios.horz_c,
init_adj_h,
&spl_scratch->scl_data.inits.h_c,
&spl_scratch->scl_data.viewport_c.x,
&spl_scratch->scl_data.viewport_c.width);
spl_calculate_init_and_vp(
flip_vert_scan_dir,
recout_clip_in_recout_dst.y,
spl_scratch->scl_data.recout.height,
src.height,
spl_scratch->scl_data.taps.v_taps,
spl_scratch->scl_data.ratios.vert,
spl_fixpt_zero,
&spl_scratch->scl_data.inits.v,
&spl_scratch->scl_data.viewport.y,
&spl_scratch->scl_data.viewport.height);
spl_calculate_init_and_vp(
flip_vert_scan_dir,
recout_clip_in_recout_dst.y,
spl_scratch->scl_data.recout.height,
src.height / vpc_div,
spl_scratch->scl_data.taps.v_taps_c,
spl_scratch->scl_data.ratios.vert_c,
init_adj_v,
&spl_scratch->scl_data.inits.v_c,
&spl_scratch->scl_data.viewport_c.y,
&spl_scratch->scl_data.viewport_c.height);
if (orthogonal_rotation) {
spl_swap(spl_scratch->scl_data.viewport.x, spl_scratch->scl_data.viewport.y);
spl_swap(spl_scratch->scl_data.viewport.width, spl_scratch->scl_data.viewport.height);
spl_swap(spl_scratch->scl_data.viewport_c.x, spl_scratch->scl_data.viewport_c.y);
spl_swap(spl_scratch->scl_data.viewport_c.width, spl_scratch->scl_data.viewport_c.height);
}
spl_scratch->scl_data.viewport.x += src.x;
spl_scratch->scl_data.viewport.y += src.y;
SPL_ASSERT(src.x % vpc_div == 0 && src.y % vpc_div == 0);
spl_scratch->scl_data.viewport_c.x += src.x / vpc_div;
spl_scratch->scl_data.viewport_c.y += src.y / vpc_div;
}
static void spl_handle_3d_recout(struct spl_in *spl_in, struct spl_rect *recout)
{
if (spl_in->basic_in.mpc_h_slice_index) {
SPL_ASSERT(spl_in->basic_in.rotation == SPL_ROTATION_ANGLE_0 ||
(spl_in->basic_out.view_format != SPL_VIEW_3D_TOP_AND_BOTTOM &&
spl_in->basic_out.view_format != SPL_VIEW_3D_SIDE_BY_SIDE));
if (spl_in->basic_out.view_format == SPL_VIEW_3D_TOP_AND_BOTTOM)
recout->y += recout->height;
else if (spl_in->basic_out.view_format == SPL_VIEW_3D_SIDE_BY_SIDE)
recout->x += recout->width;
}
}
static void spl_clamp_viewport(struct spl_rect *viewport, int min_viewport_size)
{
if (min_viewport_size == 0)
min_viewport_size = MIN_VIEWPORT_SIZE;
if (viewport->height < min_viewport_size)
viewport->height = min_viewport_size;
if (viewport->width < min_viewport_size)
viewport->width = min_viewport_size;
}
static enum scl_mode spl_get_dscl_mode(const struct spl_in *spl_in,
const struct spl_scaler_data *data,
bool enable_isharp, bool enable_easf)
{
const long long one = spl_fixpt_one.value;
enum spl_pixel_format pixel_format = spl_in->basic_in.format;
if (data->ratios.horz.value == one
&& data->ratios.vert.value == one
&& data->ratios.horz_c.value == one
&& data->ratios.vert_c.value == one
&& !spl_in->basic_out.always_scale
&& !enable_isharp)
return SCL_MODE_SCALING_444_BYPASS;
if (!spl_is_subsampled_format(pixel_format)) {
if (spl_is_video_format(pixel_format))
return SCL_MODE_SCALING_444_YCBCR_ENABLE;
else
return SCL_MODE_SCALING_444_RGB_ENABLE;
}
if (!enable_isharp) {
if (data->ratios.horz.value == one && data->ratios.vert.value == one && !spl_in->basic_out.always_scale)
return SCL_MODE_SCALING_420_LUMA_BYPASS;
}
return SCL_MODE_SCALING_420_YCBCR_ENABLE;
}
static void spl_choose_lls_policy(enum spl_pixel_format format,
enum linear_light_scaling *lls_pref)
{
if (spl_is_subsampled_format(format))
*lls_pref = LLS_PREF_NO;
else
*lls_pref = LLS_PREF_YES;
}
static bool enable_easf(struct spl_in *spl_in, struct spl_scratch *spl_scratch)
{
int vratio = 0;
int hratio = 0;
bool skip_easf = false;
if (spl_in->disable_easf)
skip_easf = true;
vratio = spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert);
hratio = spl_fixpt_ceil(spl_scratch->scl_data.ratios.horz);
if ((vratio > 2) || (hratio > 2))
skip_easf = true;
if (spl_in->lls_pref == LLS_PREF_DONT_CARE)
spl_choose_lls_policy(spl_in->basic_in.format,
&spl_in->lls_pref);
if (spl_in->lls_pref != LLS_PREF_YES && !spl_in->prefer_easf)
skip_easf = true;
return skip_easf;
}
static bool spl_is_video_fullscreen(struct spl_in *spl_in)
{
if (spl_is_video_format(spl_in->basic_in.format) && spl_in->is_fullscreen)
return true;
return false;
}
static bool spl_get_isharp_en(struct spl_in *spl_in,
struct spl_scratch *spl_scratch)
{
bool enable_isharp = false;
int vratio = 0;
int hratio = 0;
struct spl_taps taps = spl_scratch->scl_data.taps;
bool fullscreen = spl_is_video_fullscreen(spl_in);
if (spl_in->adaptive_sharpness.enable == false)
return enable_isharp;
vratio = spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert);
hratio = spl_fixpt_ceil(spl_scratch->scl_data.ratios.horz);
if (vratio > 1 || hratio > 1)
return enable_isharp;
if (!spl_is_video_format(spl_in->basic_in.format) &&
(spl_in->sharpen_policy == SHARPEN_YUV))
return enable_isharp;
else if ((spl_is_video_format(spl_in->basic_in.format) && !fullscreen) &&
(spl_in->sharpen_policy == SHARPEN_RGB_FULLSCREEN_YUV))
return enable_isharp;
else if (!spl_in->is_fullscreen &&
spl_in->sharpen_policy == SHARPEN_FULLSCREEN_ALL)
return enable_isharp;
if ((taps.h_taps == 4 || taps.h_taps == 6) &&
(taps.v_taps == 3 || taps.v_taps == 4 || taps.v_taps == 6))
enable_isharp = true;
return enable_isharp;
}
static void spl_get_taps_non_adaptive_scaler(
struct spl_scratch *spl_scratch,
const struct spl_taps *in_taps,
bool is_subsampled)
{
bool check_max_downscale = false;
if (in_taps->h_taps == 0) {
if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.horz) > 1)
spl_scratch->scl_data.taps.h_taps = spl_min(2 * spl_fixpt_ceil(
spl_scratch->scl_data.ratios.horz), 8);
else
spl_scratch->scl_data.taps.h_taps = 4;
} else
spl_scratch->scl_data.taps.h_taps = in_taps->h_taps;
if (in_taps->v_taps == 0) {
if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert) > 1)
spl_scratch->scl_data.taps.v_taps = spl_min(2 * spl_fixpt_ceil(
spl_scratch->scl_data.ratios.vert), 8);
else
spl_scratch->scl_data.taps.v_taps = 4;
} else
spl_scratch->scl_data.taps.v_taps = in_taps->v_taps;
if (in_taps->v_taps_c == 0) {
if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c) > 1)
spl_scratch->scl_data.taps.v_taps_c = spl_min(2 * spl_fixpt_ceil(
spl_scratch->scl_data.ratios.vert_c), 8);
else
spl_scratch->scl_data.taps.v_taps_c = 4;
} else
spl_scratch->scl_data.taps.v_taps_c = in_taps->v_taps_c;
if (in_taps->h_taps_c == 0) {
if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.horz_c) > 1)
spl_scratch->scl_data.taps.h_taps_c = spl_min(2 * spl_fixpt_ceil(
spl_scratch->scl_data.ratios.horz_c), 8);
else
spl_scratch->scl_data.taps.h_taps_c = 4;
} else if ((in_taps->h_taps_c % 2) != 0 && in_taps->h_taps_c != 1)
spl_scratch->scl_data.taps.h_taps_c = in_taps->h_taps_c - 1;
else
spl_scratch->scl_data.taps.h_taps_c = in_taps->h_taps_c;
check_max_downscale = spl_fixpt_le(spl_scratch->scl_data.ratios.horz,
SPL_NAMESPACE(spl_fixpt_from_fraction(6, 1)));
SPL_ASSERT(check_max_downscale);
check_max_downscale = spl_fixpt_le(spl_scratch->scl_data.ratios.vert,
SPL_NAMESPACE(spl_fixpt_from_fraction(6, 1)));
SPL_ASSERT(check_max_downscale);
check_max_downscale = spl_fixpt_le(spl_scratch->scl_data.ratios.horz_c,
SPL_NAMESPACE(spl_fixpt_from_fraction(6, 1)));
SPL_ASSERT(check_max_downscale);
check_max_downscale = spl_fixpt_le(spl_scratch->scl_data.ratios.vert_c,
SPL_NAMESPACE(spl_fixpt_from_fraction(6, 1)));
SPL_ASSERT(check_max_downscale);
if (IDENTITY_RATIO(spl_scratch->scl_data.ratios.horz))
spl_scratch->scl_data.taps.h_taps = 1;
if (IDENTITY_RATIO(spl_scratch->scl_data.ratios.vert))
spl_scratch->scl_data.taps.v_taps = 1;
if (IDENTITY_RATIO(spl_scratch->scl_data.ratios.horz_c) && !is_subsampled)
spl_scratch->scl_data.taps.h_taps_c = 1;
if (IDENTITY_RATIO(spl_scratch->scl_data.ratios.vert_c) && !is_subsampled)
spl_scratch->scl_data.taps.v_taps_c = 1;
}
static bool spl_get_optimal_number_of_taps(
int max_downscale_src_width, struct spl_in *spl_in, struct spl_scratch *spl_scratch,
const struct spl_taps *in_taps, bool *enable_easf_v, bool *enable_easf_h,
bool *enable_isharp)
{
int num_part_y, num_part_c;
unsigned int max_taps_y, max_taps_c;
unsigned int min_taps_y, min_taps_c;
enum lb_memory_config lb_config;
bool skip_easf = false;
bool is_subsampled = spl_is_subsampled_format(spl_in->basic_in.format);
if (spl_scratch->scl_data.viewport.width > spl_scratch->scl_data.h_active &&
max_downscale_src_width != 0 &&
spl_scratch->scl_data.viewport.width > max_downscale_src_width) {
spl_get_taps_non_adaptive_scaler(spl_scratch, in_taps, is_subsampled);
*enable_easf_v = false;
*enable_easf_h = false;
*enable_isharp = false;
return false;
}
if (spl_in->scaling_quality.integer_scaling) {
spl_get_taps_non_adaptive_scaler(spl_scratch, in_taps, is_subsampled);
*enable_easf_v = false;
*enable_easf_h = false;
*enable_isharp = false;
return true;
}
skip_easf = enable_easf(spl_in, spl_scratch);
if (skip_easf) {
spl_get_taps_non_adaptive_scaler(spl_scratch, in_taps, is_subsampled);
}
else {
if (spl_is_video_format(spl_in->basic_in.format)) {
spl_scratch->scl_data.taps.h_taps = 6;
spl_scratch->scl_data.taps.v_taps = 6;
spl_scratch->scl_data.taps.h_taps_c = 4;
spl_scratch->scl_data.taps.v_taps_c = 4;
} else {
spl_scratch->scl_data.taps.h_taps = 6;
spl_scratch->scl_data.taps.v_taps = 6;
spl_scratch->scl_data.taps.h_taps_c = 6;
spl_scratch->scl_data.taps.v_taps_c = 6;
}
if (spl_in->override_easf) {
spl_scratch->scl_data.taps.h_taps = (in_taps->h_taps != 0) ? in_taps->h_taps : spl_scratch->scl_data.taps.h_taps;
spl_scratch->scl_data.taps.v_taps = (in_taps->v_taps != 0) ? in_taps->v_taps : spl_scratch->scl_data.taps.v_taps;
spl_scratch->scl_data.taps.h_taps_c = (in_taps->h_taps_c != 0) ? in_taps->h_taps_c : spl_scratch->scl_data.taps.h_taps_c;
spl_scratch->scl_data.taps.v_taps_c = (in_taps->v_taps_c != 0) ? in_taps->v_taps_c : spl_scratch->scl_data.taps.v_taps_c;
if ((spl_scratch->scl_data.taps.h_taps > 6) || (spl_scratch->scl_data.taps.v_taps > 6))
skip_easf = true;
if ((spl_scratch->scl_data.taps.h_taps > 1) && (spl_scratch->scl_data.taps.h_taps % 2))
spl_scratch->scl_data.taps.h_taps--;
if ((spl_scratch->scl_data.taps.h_taps_c > 1) && (spl_scratch->scl_data.taps.h_taps_c % 2))
spl_scratch->scl_data.taps.h_taps_c--;
}
}
min_taps_y = spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert);
min_taps_c = spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c);
if (spl_is_yuv420(spl_in->basic_in.format))
lb_config = LB_MEMORY_CONFIG_3;
else
lb_config = LB_MEMORY_CONFIG_0;
spl_in->callbacks.spl_calc_lb_num_partitions(spl_in->basic_out.alpha_en, &spl_scratch->scl_data,
lb_config, &num_part_y, &num_part_c);
if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert) > 2)
if ((spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert) - 2) > num_part_y)
max_taps_y = 0;
else
max_taps_y = num_part_y - (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert) - 2);
else
max_taps_y = num_part_y;
if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c) > 2)
if ((spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c) - 2) > num_part_c)
max_taps_c = 0;
else
max_taps_c = num_part_c - (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c) - 2);
else
max_taps_c = num_part_c;
if (max_taps_y < min_taps_y)
return false;
else if (max_taps_c < min_taps_c)
return false;
if (spl_scratch->scl_data.taps.v_taps > max_taps_y)
spl_scratch->scl_data.taps.v_taps = max_taps_y;
if (spl_scratch->scl_data.taps.v_taps_c > max_taps_c)
spl_scratch->scl_data.taps.v_taps_c = max_taps_c;
if (!skip_easf) {
if (spl_scratch->scl_data.taps.v_taps == 5)
spl_scratch->scl_data.taps.v_taps = 4;
if (spl_scratch->scl_data.taps.v_taps_c == 5)
spl_scratch->scl_data.taps.v_taps_c = 4;
if (spl_scratch->scl_data.taps.h_taps == 5)
spl_scratch->scl_data.taps.h_taps = 4;
if (spl_scratch->scl_data.taps.h_taps_c == 5)
spl_scratch->scl_data.taps.h_taps_c = 4;
if (spl_is_video_format(spl_in->basic_in.format)) {
if (spl_scratch->scl_data.taps.h_taps <= 4) {
*enable_easf_v = false;
*enable_easf_h = false;
} else if (spl_scratch->scl_data.taps.v_taps <= 3) {
*enable_easf_v = false;
*enable_easf_h = true;
} else {
*enable_easf_v = true;
*enable_easf_h = true;
}
SPL_ASSERT((spl_scratch->scl_data.taps.v_taps > 1) &&
(spl_scratch->scl_data.taps.v_taps_c > 1));
} else {
if (spl_scratch->scl_data.taps.h_taps <= 3) {
*enable_easf_v = false;
*enable_easf_h = false;
} else if (spl_scratch->scl_data.taps.v_taps < 3) {
*enable_easf_v = false;
*enable_easf_h = true;
} else {
*enable_easf_v = true;
*enable_easf_h = true;
}
SPL_ASSERT(spl_scratch->scl_data.taps.v_taps > 1);
}
} else {
*enable_easf_v = false;
*enable_easf_h = false;
}
*enable_isharp = spl_get_isharp_en(spl_in, spl_scratch);
if (!*enable_isharp && !spl_in->basic_out.always_scale) {
if ((IDENTITY_RATIO(spl_scratch->scl_data.ratios.horz)) &&
(IDENTITY_RATIO(spl_scratch->scl_data.ratios.vert))) {
spl_scratch->scl_data.taps.h_taps = 1;
spl_scratch->scl_data.taps.v_taps = 1;
if (IDENTITY_RATIO(spl_scratch->scl_data.ratios.horz_c) && !is_subsampled)
spl_scratch->scl_data.taps.h_taps_c = 1;
if (IDENTITY_RATIO(spl_scratch->scl_data.ratios.vert_c) && !is_subsampled)
spl_scratch->scl_data.taps.v_taps_c = 1;
*enable_easf_v = false;
*enable_easf_h = false;
} else {
if ((!*enable_easf_h) &&
(IDENTITY_RATIO(spl_scratch->scl_data.ratios.horz)))
spl_scratch->scl_data.taps.h_taps = 1;
if ((!*enable_easf_v) &&
(IDENTITY_RATIO(spl_scratch->scl_data.ratios.vert)))
spl_scratch->scl_data.taps.v_taps = 1;
if ((!*enable_easf_h) && !is_subsampled &&
(IDENTITY_RATIO(spl_scratch->scl_data.ratios.horz_c)))
spl_scratch->scl_data.taps.h_taps_c = 1;
if ((!*enable_easf_v) && !is_subsampled &&
(IDENTITY_RATIO(spl_scratch->scl_data.ratios.vert_c)))
spl_scratch->scl_data.taps.v_taps_c = 1;
}
}
return true;
}
static void spl_set_black_color_data(enum spl_pixel_format format,
struct scl_black_color *scl_black_color)
{
bool ycbcr = spl_is_video_format(format);
if (ycbcr) {
scl_black_color->offset_rgb_y = BLACK_OFFSET_RGB_Y;
scl_black_color->offset_rgb_cbcr = BLACK_OFFSET_CBCR;
} else {
scl_black_color->offset_rgb_y = 0x0;
scl_black_color->offset_rgb_cbcr = 0x0;
}
}
static void spl_set_manual_ratio_init_data(struct dscl_prog_data *dscl_prog_data,
const struct spl_scaler_data *scl_data)
{
struct spl_fixed31_32 bot;
dscl_prog_data->ratios.h_scale_ratio = SPL_NAMESPACE(spl_fixpt_u3d19(
scl_data->ratios.horz)) << 5;
dscl_prog_data->ratios.v_scale_ratio = SPL_NAMESPACE(spl_fixpt_u3d19(
scl_data->ratios.vert)) << 5;
dscl_prog_data->ratios.h_scale_ratio_c = SPL_NAMESPACE(spl_fixpt_u3d19(
scl_data->ratios.horz_c)) << 5;
dscl_prog_data->ratios.v_scale_ratio_c = SPL_NAMESPACE(spl_fixpt_u3d19(
scl_data->ratios.vert_c)) << 5;
dscl_prog_data->init.h_filter_init_frac =
SPL_NAMESPACE(spl_fixpt_u0d19(scl_data->inits.h)) << 5;
dscl_prog_data->init.h_filter_init_int =
spl_fixpt_floor(scl_data->inits.h);
dscl_prog_data->init.h_filter_init_frac_c =
SPL_NAMESPACE(spl_fixpt_u0d19(scl_data->inits.h_c)) << 5;
dscl_prog_data->init.h_filter_init_int_c =
spl_fixpt_floor(scl_data->inits.h_c);
dscl_prog_data->init.v_filter_init_frac =
SPL_NAMESPACE(spl_fixpt_u0d19(scl_data->inits.v)) << 5;
dscl_prog_data->init.v_filter_init_int =
spl_fixpt_floor(scl_data->inits.v);
dscl_prog_data->init.v_filter_init_frac_c =
SPL_NAMESPACE(spl_fixpt_u0d19(scl_data->inits.v_c)) << 5;
dscl_prog_data->init.v_filter_init_int_c =
spl_fixpt_floor(scl_data->inits.v_c);
bot = spl_fixpt_add(scl_data->inits.v, scl_data->ratios.vert);
dscl_prog_data->init.v_filter_init_bot_frac = SPL_NAMESPACE(spl_fixpt_u0d19(bot)) << 5;
dscl_prog_data->init.v_filter_init_bot_int = spl_fixpt_floor(bot);
bot = spl_fixpt_add(scl_data->inits.v_c, scl_data->ratios.vert_c);
dscl_prog_data->init.v_filter_init_bot_frac_c = SPL_NAMESPACE(spl_fixpt_u0d19(bot)) << 5;
dscl_prog_data->init.v_filter_init_bot_int_c = spl_fixpt_floor(bot);
}
static void spl_set_taps_data(struct dscl_prog_data *dscl_prog_data,
const struct spl_scaler_data *scl_data)
{
dscl_prog_data->taps.v_taps = scl_data->taps.v_taps - 1;
dscl_prog_data->taps.h_taps = scl_data->taps.h_taps - 1;
dscl_prog_data->taps.v_taps_c = scl_data->taps.v_taps_c - 1;
dscl_prog_data->taps.h_taps_c = scl_data->taps.h_taps_c - 1;
}
static void spl_set_dscl_prog_data(struct spl_in *spl_in, struct spl_scratch *spl_scratch,
struct spl_out *spl_out, bool enable_easf_v, bool enable_easf_h, bool enable_isharp)
{
struct dscl_prog_data *dscl_prog_data = spl_out->dscl_prog_data;
const struct spl_scaler_data *data = &spl_scratch->scl_data;
struct scl_black_color *scl_black_color = &dscl_prog_data->scl_black_color;
bool enable_easf = enable_easf_v || enable_easf_h;
dscl_prog_data->recout = spl_scratch->scl_data.recout;
dscl_prog_data->mpc_size.width = spl_scratch->scl_data.h_active;
dscl_prog_data->mpc_size.height = spl_scratch->scl_data.v_active;
dscl_prog_data->dscl_mode = spl_get_dscl_mode(spl_in, data, enable_isharp,
enable_easf);
spl_set_black_color_data(spl_in->basic_in.format, scl_black_color);
spl_set_manual_ratio_init_data(dscl_prog_data, data);
spl_set_taps_data(dscl_prog_data, data);
dscl_prog_data->viewport = spl_scratch->scl_data.viewport;
dscl_prog_data->viewport_c = spl_scratch->scl_data.viewport_c;
SPL_NAMESPACE(spl_set_filters_data(dscl_prog_data, data, enable_easf_v, enable_easf_h));
}
static void spl_calculate_c0_c3_hdr(struct dscl_prog_data *dscl_prog_data, uint32_t sdr_white_level_nits)
{
struct spl_fixed31_32 hdr_mult, c0_mult, c1_mult, c2_mult;
struct spl_fixed31_32 c0_calc, c1_calc, c2_calc;
struct spl_custom_float_format fmt;
uint32_t hdr_multx100_int;
if ((sdr_white_level_nits >= 80) && (sdr_white_level_nits <= 480))
hdr_multx100_int = sdr_white_level_nits * 100 / 80;
else
hdr_multx100_int = 100;
hdr_mult = SPL_NAMESPACE(spl_fixpt_from_fraction((long long)hdr_multx100_int, 100LL));
c0_mult = SPL_NAMESPACE(spl_fixpt_from_fraction(2126LL, 10000LL));
c1_mult = SPL_NAMESPACE(spl_fixpt_from_fraction(7152LL, 10000LL));
c2_mult = SPL_NAMESPACE(spl_fixpt_from_fraction(722LL, 10000LL));
c0_calc = SPL_NAMESPACE(spl_fixpt_mul(hdr_mult, SPL_NAMESPACE(spl_fixpt_mul(c0_mult,
SPL_NAMESPACE(spl_fixpt_from_fraction(16384LL, 125LL))))));
c1_calc = SPL_NAMESPACE(spl_fixpt_mul(hdr_mult, SPL_NAMESPACE(spl_fixpt_mul(c1_mult,
SPL_NAMESPACE(spl_fixpt_from_fraction(16384LL, 125LL))))));
c2_calc = SPL_NAMESPACE(spl_fixpt_mul(hdr_mult, SPL_NAMESPACE(spl_fixpt_mul(c2_mult,
SPL_NAMESPACE(spl_fixpt_from_fraction(16384LL, 125LL))))));
fmt.exponenta_bits = 5;
fmt.mantissa_bits = 10;
fmt.sign = true;
SPL_NAMESPACE(spl_convert_to_custom_float_format(c0_calc, &fmt,
&dscl_prog_data->easf_matrix_c0));
SPL_NAMESPACE(spl_convert_to_custom_float_format(c1_calc, &fmt,
&dscl_prog_data->easf_matrix_c1));
SPL_NAMESPACE(spl_convert_to_custom_float_format(c2_calc, &fmt,
&dscl_prog_data->easf_matrix_c2));
dscl_prog_data->easf_matrix_c3 = 0x0;
}
static void spl_set_easf_data(struct spl_scratch *spl_scratch, struct spl_out *spl_out, bool enable_easf_v,
bool enable_easf_h, enum linear_light_scaling lls_pref,
enum spl_pixel_format format, enum system_setup setup,
uint32_t sdr_white_level_nits)
{
struct dscl_prog_data *dscl_prog_data = spl_out->dscl_prog_data;
if (enable_easf_v) {
dscl_prog_data->easf_v_en = true;
dscl_prog_data->easf_v_ring = 0;
dscl_prog_data->easf_v_sharp_factor = 1;
dscl_prog_data->easf_v_bf1_en = 1;
dscl_prog_data->easf_v_bf2_mode = 0xF;
dscl_prog_data->easf_v_bf3_mode = SPL_NAMESPACE(spl_get_v_bf3_mode(
spl_scratch->scl_data.recip_ratios.vert));
dscl_prog_data->easf_v_ringest_3tap_dntilt_uptilt =
SPL_NAMESPACE(spl_get_3tap_dntilt_uptilt_offset(spl_scratch->scl_data.taps.v_taps,
spl_scratch->scl_data.recip_ratios.vert));
dscl_prog_data->easf_v_ringest_3tap_uptilt_max =
SPL_NAMESPACE(spl_get_3tap_uptilt_maxval(spl_scratch->scl_data.taps.v_taps,
spl_scratch->scl_data.recip_ratios.vert));
dscl_prog_data->easf_v_ringest_3tap_dntilt_slope =
SPL_NAMESPACE(spl_get_3tap_dntilt_slope(spl_scratch->scl_data.taps.v_taps,
spl_scratch->scl_data.recip_ratios.vert));
dscl_prog_data->easf_v_ringest_3tap_uptilt1_slope =
SPL_NAMESPACE(spl_get_3tap_uptilt1_slope(spl_scratch->scl_data.taps.v_taps,
spl_scratch->scl_data.recip_ratios.vert));
dscl_prog_data->easf_v_ringest_3tap_uptilt2_slope =
SPL_NAMESPACE(spl_get_3tap_uptilt2_slope(spl_scratch->scl_data.taps.v_taps,
spl_scratch->scl_data.recip_ratios.vert));
dscl_prog_data->easf_v_ringest_3tap_uptilt2_offset =
SPL_NAMESPACE(spl_get_3tap_uptilt2_offset(spl_scratch->scl_data.taps.v_taps,
spl_scratch->scl_data.recip_ratios.vert));
dscl_prog_data->easf_v_ringest_eventap_reduceg1 =
SPL_NAMESPACE(spl_get_reducer_gain4(spl_scratch->scl_data.taps.v_taps,
spl_scratch->scl_data.recip_ratios.vert));
dscl_prog_data->easf_v_ringest_eventap_reduceg2 =
SPL_NAMESPACE(spl_get_reducer_gain6(spl_scratch->scl_data.taps.v_taps,
spl_scratch->scl_data.recip_ratios.vert));
dscl_prog_data->easf_v_ringest_eventap_gain1 =
SPL_NAMESPACE(spl_get_gainRing4(spl_scratch->scl_data.taps.v_taps,
spl_scratch->scl_data.recip_ratios.vert));
dscl_prog_data->easf_v_ringest_eventap_gain2 =
SPL_NAMESPACE(spl_get_gainRing6(spl_scratch->scl_data.taps.v_taps,
spl_scratch->scl_data.recip_ratios.vert));
dscl_prog_data->easf_v_bf_maxa = 63;
dscl_prog_data->easf_v_bf_maxb = 63;
dscl_prog_data->easf_v_bf_mina = 0;
dscl_prog_data->easf_v_bf_minb = 0;
if (lls_pref == LLS_PREF_YES) {
dscl_prog_data->easf_v_bf2_flat1_gain = 4;
dscl_prog_data->easf_v_bf2_flat2_gain = 8;
dscl_prog_data->easf_v_bf2_roc_gain = 4;
dscl_prog_data->easf_v_bf1_pwl_in_seg0 = 0x600;
dscl_prog_data->easf_v_bf1_pwl_base_seg0 = 0;
dscl_prog_data->easf_v_bf1_pwl_slope_seg0 = 3;
dscl_prog_data->easf_v_bf1_pwl_in_seg1 = 0x7EC;
dscl_prog_data->easf_v_bf1_pwl_base_seg1 = 12;
dscl_prog_data->easf_v_bf1_pwl_slope_seg1 = 326;
dscl_prog_data->easf_v_bf1_pwl_in_seg2 = 0;
dscl_prog_data->easf_v_bf1_pwl_base_seg2 = 63;
dscl_prog_data->easf_v_bf1_pwl_slope_seg2 = 0;
dscl_prog_data->easf_v_bf1_pwl_in_seg3 = 16;
dscl_prog_data->easf_v_bf1_pwl_base_seg3 = 63;
dscl_prog_data->easf_v_bf1_pwl_slope_seg3 = 0x7C8;
dscl_prog_data->easf_v_bf1_pwl_in_seg4 = 32;
dscl_prog_data->easf_v_bf1_pwl_base_seg4 = 56;
dscl_prog_data->easf_v_bf1_pwl_slope_seg4 = 0x7D0;
dscl_prog_data->easf_v_bf1_pwl_in_seg5 = 48;
dscl_prog_data->easf_v_bf1_pwl_base_seg5 = 50;
dscl_prog_data->easf_v_bf1_pwl_slope_seg5 = 0x710;
dscl_prog_data->easf_v_bf1_pwl_in_seg6 = 64;
dscl_prog_data->easf_v_bf1_pwl_base_seg6 = 20;
dscl_prog_data->easf_v_bf1_pwl_slope_seg6 = 0x760;
dscl_prog_data->easf_v_bf1_pwl_in_seg7 = 80;
dscl_prog_data->easf_v_bf1_pwl_base_seg7 = 0;
dscl_prog_data->easf_v_bf3_pwl_in_set0 = 0x000;
dscl_prog_data->easf_v_bf3_pwl_base_set0 = 63;
dscl_prog_data->easf_v_bf3_pwl_slope_set0 = 0x12C5;
dscl_prog_data->easf_v_bf3_pwl_in_set1 =
0x0B37;
dscl_prog_data->easf_v_bf3_pwl_base_set1 = 62;
dscl_prog_data->easf_v_bf3_pwl_slope_set1 =
0x13B8;
dscl_prog_data->easf_v_bf3_pwl_in_set2 =
0x0BB7;
dscl_prog_data->easf_v_bf3_pwl_base_set2 = 20;
dscl_prog_data->easf_v_bf3_pwl_slope_set2 =
0x1356;
dscl_prog_data->easf_v_bf3_pwl_in_set3 =
0x0BF7;
dscl_prog_data->easf_v_bf3_pwl_base_set3 = 0;
dscl_prog_data->easf_v_bf3_pwl_slope_set3 =
0x136B;
dscl_prog_data->easf_v_bf3_pwl_in_set4 =
0x0C37;
dscl_prog_data->easf_v_bf3_pwl_base_set4 = 0x4E;
dscl_prog_data->easf_v_bf3_pwl_slope_set4 =
0x1200;
dscl_prog_data->easf_v_bf3_pwl_in_set5 =
0x0CF7;
dscl_prog_data->easf_v_bf3_pwl_base_set5 = 0x41;
} else {
dscl_prog_data->easf_v_bf2_flat1_gain = 13;
dscl_prog_data->easf_v_bf2_flat2_gain = 15;
dscl_prog_data->easf_v_bf2_roc_gain = 14;
dscl_prog_data->easf_v_bf1_pwl_in_seg0 = 0x440;
dscl_prog_data->easf_v_bf1_pwl_base_seg0 = 0;
dscl_prog_data->easf_v_bf1_pwl_slope_seg0 = 2;
dscl_prog_data->easf_v_bf1_pwl_in_seg1 = 0x7C4;
dscl_prog_data->easf_v_bf1_pwl_base_seg1 = 12;
dscl_prog_data->easf_v_bf1_pwl_slope_seg1 = 109;
dscl_prog_data->easf_v_bf1_pwl_in_seg2 = 0;
dscl_prog_data->easf_v_bf1_pwl_base_seg2 = 63;
dscl_prog_data->easf_v_bf1_pwl_slope_seg2 = 0;
dscl_prog_data->easf_v_bf1_pwl_in_seg3 = 48;
dscl_prog_data->easf_v_bf1_pwl_base_seg3 = 63;
dscl_prog_data->easf_v_bf1_pwl_slope_seg3 = 0x7ED;
dscl_prog_data->easf_v_bf1_pwl_in_seg4 = 96;
dscl_prog_data->easf_v_bf1_pwl_base_seg4 = 56;
dscl_prog_data->easf_v_bf1_pwl_slope_seg4 = 0x7F0;
dscl_prog_data->easf_v_bf1_pwl_in_seg5 = 144;
dscl_prog_data->easf_v_bf1_pwl_base_seg5 = 50;
dscl_prog_data->easf_v_bf1_pwl_slope_seg5 = 0x7B0;
dscl_prog_data->easf_v_bf1_pwl_in_seg6 = 192;
dscl_prog_data->easf_v_bf1_pwl_base_seg6 = 20;
dscl_prog_data->easf_v_bf1_pwl_slope_seg6 = 0x7CB;
dscl_prog_data->easf_v_bf1_pwl_in_seg7 = 240;
dscl_prog_data->easf_v_bf1_pwl_base_seg7 = 0;
dscl_prog_data->easf_v_bf3_pwl_in_set0 = 0x000;
dscl_prog_data->easf_v_bf3_pwl_base_set0 = 63;
dscl_prog_data->easf_v_bf3_pwl_slope_set0 = 0x0000;
dscl_prog_data->easf_v_bf3_pwl_in_set1 =
0x06C0;
dscl_prog_data->easf_v_bf3_pwl_base_set1 = 63;
dscl_prog_data->easf_v_bf3_pwl_slope_set1 = 0x1896;
dscl_prog_data->easf_v_bf3_pwl_in_set2 =
0x0700;
dscl_prog_data->easf_v_bf3_pwl_base_set2 = 20;
dscl_prog_data->easf_v_bf3_pwl_slope_set2 = 0x1810;
dscl_prog_data->easf_v_bf3_pwl_in_set3 =
0x0740;
dscl_prog_data->easf_v_bf3_pwl_base_set3 = 0;
dscl_prog_data->easf_v_bf3_pwl_slope_set3 =
0x1878;
dscl_prog_data->easf_v_bf3_pwl_in_set4 =
0x0761;
dscl_prog_data->easf_v_bf3_pwl_base_set4 = 0x44;
dscl_prog_data->easf_v_bf3_pwl_slope_set4 = 0x1760;
dscl_prog_data->easf_v_bf3_pwl_in_set5 =
0x0780;
dscl_prog_data->easf_v_bf3_pwl_base_set5 = 0x41;
}
} else
dscl_prog_data->easf_v_en = false;
if (enable_easf_h) {
dscl_prog_data->easf_h_en = true;
dscl_prog_data->easf_h_ring = 0;
dscl_prog_data->easf_h_sharp_factor = 1;
dscl_prog_data->easf_h_bf1_en =
1;
dscl_prog_data->easf_h_bf2_mode =
0xF;
dscl_prog_data->easf_h_bf3_mode = SPL_NAMESPACE(spl_get_h_bf3_mode(
spl_scratch->scl_data.recip_ratios.horz));
dscl_prog_data->easf_h_ringest_eventap_reduceg1 =
SPL_NAMESPACE(spl_get_reducer_gain4(spl_scratch->scl_data.taps.h_taps,
spl_scratch->scl_data.recip_ratios.horz));
dscl_prog_data->easf_h_ringest_eventap_reduceg2 =
SPL_NAMESPACE(spl_get_reducer_gain6(spl_scratch->scl_data.taps.h_taps,
spl_scratch->scl_data.recip_ratios.horz));
dscl_prog_data->easf_h_ringest_eventap_gain1 =
SPL_NAMESPACE(spl_get_gainRing4(spl_scratch->scl_data.taps.h_taps,
spl_scratch->scl_data.recip_ratios.horz));
dscl_prog_data->easf_h_ringest_eventap_gain2 =
SPL_NAMESPACE(spl_get_gainRing6(spl_scratch->scl_data.taps.h_taps,
spl_scratch->scl_data.recip_ratios.horz));
dscl_prog_data->easf_h_bf_maxa = 63;
dscl_prog_data->easf_h_bf_maxb = 63;
dscl_prog_data->easf_h_bf_mina = 0;
dscl_prog_data->easf_h_bf_minb = 0;
if (lls_pref == LLS_PREF_YES) {
dscl_prog_data->easf_h_bf2_flat1_gain = 4;
dscl_prog_data->easf_h_bf2_flat2_gain = 8;
dscl_prog_data->easf_h_bf2_roc_gain = 4;
dscl_prog_data->easf_h_bf1_pwl_in_seg0 = 0x600;
dscl_prog_data->easf_h_bf1_pwl_base_seg0 = 0;
dscl_prog_data->easf_h_bf1_pwl_slope_seg0 = 3;
dscl_prog_data->easf_h_bf1_pwl_in_seg1 = 0x7EC;
dscl_prog_data->easf_h_bf1_pwl_base_seg1 = 12;
dscl_prog_data->easf_h_bf1_pwl_slope_seg1 = 326;
dscl_prog_data->easf_h_bf1_pwl_in_seg2 = 0;
dscl_prog_data->easf_h_bf1_pwl_base_seg2 = 63;
dscl_prog_data->easf_h_bf1_pwl_slope_seg2 = 0;
dscl_prog_data->easf_h_bf1_pwl_in_seg3 = 16;
dscl_prog_data->easf_h_bf1_pwl_base_seg3 = 63;
dscl_prog_data->easf_h_bf1_pwl_slope_seg3 = 0x7C8;
dscl_prog_data->easf_h_bf1_pwl_in_seg4 = 32;
dscl_prog_data->easf_h_bf1_pwl_base_seg4 = 56;
dscl_prog_data->easf_h_bf1_pwl_slope_seg4 = 0x7D0;
dscl_prog_data->easf_h_bf1_pwl_in_seg5 = 48;
dscl_prog_data->easf_h_bf1_pwl_base_seg5 = 50;
dscl_prog_data->easf_h_bf1_pwl_slope_seg5 = 0x710;
dscl_prog_data->easf_h_bf1_pwl_in_seg6 = 64;
dscl_prog_data->easf_h_bf1_pwl_base_seg6 = 20;
dscl_prog_data->easf_h_bf1_pwl_slope_seg6 = 0x760;
dscl_prog_data->easf_h_bf1_pwl_in_seg7 = 80;
dscl_prog_data->easf_h_bf1_pwl_base_seg7 = 0;
dscl_prog_data->easf_h_bf3_pwl_in_set0 = 0x000;
dscl_prog_data->easf_h_bf3_pwl_base_set0 = 63;
dscl_prog_data->easf_h_bf3_pwl_slope_set0 = 0x12C5;
dscl_prog_data->easf_h_bf3_pwl_in_set1 =
0x0B37;
dscl_prog_data->easf_h_bf3_pwl_base_set1 = 62;
dscl_prog_data->easf_h_bf3_pwl_slope_set1 = 0x13B8;
dscl_prog_data->easf_h_bf3_pwl_in_set2 =
0x0BB7;
dscl_prog_data->easf_h_bf3_pwl_base_set2 = 20;
dscl_prog_data->easf_h_bf3_pwl_slope_set2 = 0x1356;
dscl_prog_data->easf_h_bf3_pwl_in_set3 =
0x0BF7;
dscl_prog_data->easf_h_bf3_pwl_base_set3 = 0;
dscl_prog_data->easf_h_bf3_pwl_slope_set3 = 0x136B;
dscl_prog_data->easf_h_bf3_pwl_in_set4 =
0x0C37;
dscl_prog_data->easf_h_bf3_pwl_base_set4 = 0x4E;
dscl_prog_data->easf_h_bf3_pwl_slope_set4 = 0x1200;
dscl_prog_data->easf_h_bf3_pwl_in_set5 =
0x0CF7;
dscl_prog_data->easf_h_bf3_pwl_base_set5 = 0x41;
} else {
dscl_prog_data->easf_h_bf2_flat1_gain = 13;
dscl_prog_data->easf_h_bf2_flat2_gain = 15;
dscl_prog_data->easf_h_bf2_roc_gain = 14;
dscl_prog_data->easf_h_bf1_pwl_in_seg0 = 0x440;
dscl_prog_data->easf_h_bf1_pwl_base_seg0 = 0;
dscl_prog_data->easf_h_bf1_pwl_slope_seg0 = 2;
dscl_prog_data->easf_h_bf1_pwl_in_seg1 = 0x7C4;
dscl_prog_data->easf_h_bf1_pwl_base_seg1 = 12;
dscl_prog_data->easf_h_bf1_pwl_slope_seg1 = 109;
dscl_prog_data->easf_h_bf1_pwl_in_seg2 = 0;
dscl_prog_data->easf_h_bf1_pwl_base_seg2 = 63;
dscl_prog_data->easf_h_bf1_pwl_slope_seg2 = 0;
dscl_prog_data->easf_h_bf1_pwl_in_seg3 = 48;
dscl_prog_data->easf_h_bf1_pwl_base_seg3 = 63;
dscl_prog_data->easf_h_bf1_pwl_slope_seg3 = 0x7ED;
dscl_prog_data->easf_h_bf1_pwl_in_seg4 = 96;
dscl_prog_data->easf_h_bf1_pwl_base_seg4 = 56;
dscl_prog_data->easf_h_bf1_pwl_slope_seg4 = 0x7F0;
dscl_prog_data->easf_h_bf1_pwl_in_seg5 = 144;
dscl_prog_data->easf_h_bf1_pwl_base_seg5 = 50;
dscl_prog_data->easf_h_bf1_pwl_slope_seg5 = 0x7B0;
dscl_prog_data->easf_h_bf1_pwl_in_seg6 = 192;
dscl_prog_data->easf_h_bf1_pwl_base_seg6 = 20;
dscl_prog_data->easf_h_bf1_pwl_slope_seg6 = 0x7CB;
dscl_prog_data->easf_h_bf1_pwl_in_seg7 = 240;
dscl_prog_data->easf_h_bf1_pwl_base_seg7 = 0;
dscl_prog_data->easf_h_bf3_pwl_in_set0 = 0x000;
dscl_prog_data->easf_h_bf3_pwl_base_set0 = 63;
dscl_prog_data->easf_h_bf3_pwl_slope_set0 = 0x0000;
dscl_prog_data->easf_h_bf3_pwl_in_set1 =
0x06C0;
dscl_prog_data->easf_h_bf3_pwl_base_set1 = 63;
dscl_prog_data->easf_h_bf3_pwl_slope_set1 = 0x1896;
dscl_prog_data->easf_h_bf3_pwl_in_set2 =
0x0700;
dscl_prog_data->easf_h_bf3_pwl_base_set2 = 20;
dscl_prog_data->easf_h_bf3_pwl_slope_set2 = 0x1810;
dscl_prog_data->easf_h_bf3_pwl_in_set3 =
0x0740;
dscl_prog_data->easf_h_bf3_pwl_base_set3 = 0;
dscl_prog_data->easf_h_bf3_pwl_slope_set3 = 0x1878;
dscl_prog_data->easf_h_bf3_pwl_in_set4 =
0x0761;
dscl_prog_data->easf_h_bf3_pwl_base_set4 = 0x44;
dscl_prog_data->easf_h_bf3_pwl_slope_set4 = 0x1760;
dscl_prog_data->easf_h_bf3_pwl_in_set5 =
0x0780;
dscl_prog_data->easf_h_bf3_pwl_base_set5 = 0x41;
}
} else
dscl_prog_data->easf_h_en = false;
if (lls_pref == LLS_PREF_YES) {
dscl_prog_data->easf_ltonl_en = 1;
if ((setup == HDR_L) && (spl_is_rgb8(format))) {
spl_calculate_c0_c3_hdr(dscl_prog_data, sdr_white_level_nits);
} else {
dscl_prog_data->easf_matrix_c0 =
0x4EF7;
dscl_prog_data->easf_matrix_c1 =
0x55DC;
dscl_prog_data->easf_matrix_c2 =
0x48BB;
dscl_prog_data->easf_matrix_c3 =
0x0;
}
} else {
dscl_prog_data->easf_ltonl_en = 0;
dscl_prog_data->easf_matrix_c0 =
0x3434;
dscl_prog_data->easf_matrix_c1 =
0x396D;
dscl_prog_data->easf_matrix_c2 =
0x2B97;
dscl_prog_data->easf_matrix_c3 =
0x0;
}
if (spl_is_subsampled_format(format)) {
dscl_prog_data->easf_matrix_mode = 1;
dscl_prog_data->easf_v_bf3_mode = 0;
dscl_prog_data->easf_h_bf3_mode = 0;
} else
dscl_prog_data->easf_matrix_mode = 0;
}
static void spl_set_isharp_noise_det_mode(struct dscl_prog_data *dscl_prog_data,
const struct spl_scaler_data *data)
{
if (data->taps.v_taps == 6)
dscl_prog_data->isharp_noise_det.mode = 3;
else if (data->taps.v_taps == 4)
dscl_prog_data->isharp_noise_det.mode = 1;
else if (data->taps.v_taps == 3)
dscl_prog_data->isharp_noise_det.mode = 0;
};
static void spl_set_isharp_data(struct dscl_prog_data *dscl_prog_data,
struct adaptive_sharpness adp_sharpness, bool enable_isharp,
enum linear_light_scaling lls_pref, enum spl_pixel_format format,
const struct spl_scaler_data *data, struct spl_fixed31_32 ratio,
enum system_setup setup, enum scale_to_sharpness_policy scale_to_sharpness_policy)
{
if (!enable_isharp) {
dscl_prog_data->isharp_en = 0;
return;
}
SPL_NAMESPACE(spl_build_isharp_1dlut_from_reference_curve(ratio, setup, adp_sharpness,
scale_to_sharpness_policy));
memcpy(dscl_prog_data->isharp_delta, SPL_NAMESPACE(spl_get_pregen_filter_isharp_1D_lut(setup)),
sizeof(uint32_t) * ISHARP_LUT_TABLE_SIZE);
dscl_prog_data->sharpness_level = adp_sharpness.sharpness_level;
dscl_prog_data->isharp_en = 1;
if (data->taps.h_taps == 6) {
dscl_prog_data->isharp_noise_det.enable = 1;
spl_set_isharp_noise_det_mode(dscl_prog_data, data);
} else
dscl_prog_data->isharp_noise_det.enable = 0;
dscl_prog_data->isharp_noise_det.uthreshold = 24;
dscl_prog_data->isharp_noise_det.dthreshold = 4;
dscl_prog_data->isharp_noise_det.pwl_start_in = 3;
dscl_prog_data->isharp_noise_det.pwl_end_in = 13;
dscl_prog_data->isharp_noise_det.pwl_slope = 1623;
if (lls_pref == LLS_PREF_NO)
dscl_prog_data->isharp_fmt.mode = 1;
else
dscl_prog_data->isharp_fmt.mode = 0;
dscl_prog_data->isharp_fmt.norm = 0x3C00;
dscl_prog_data->isharp_lba.mode = 0;
if (setup == SDR_L) {
dscl_prog_data->isharp_lba.in_seg[0] = 0;
dscl_prog_data->isharp_lba.base_seg[0] = 0;
dscl_prog_data->isharp_lba.slope_seg[0] = 62;
dscl_prog_data->isharp_lba.in_seg[1] = 130;
dscl_prog_data->isharp_lba.base_seg[1] = 63;
dscl_prog_data->isharp_lba.slope_seg[1] = 0;
dscl_prog_data->isharp_lba.in_seg[2] = 450;
dscl_prog_data->isharp_lba.base_seg[2] = 63;
dscl_prog_data->isharp_lba.slope_seg[2] = 0x18D;
dscl_prog_data->isharp_lba.in_seg[3] = 520;
dscl_prog_data->isharp_lba.base_seg[3] = 0;
dscl_prog_data->isharp_lba.slope_seg[3] = 0;
dscl_prog_data->isharp_lba.in_seg[4] = 520;
dscl_prog_data->isharp_lba.base_seg[4] = 0;
dscl_prog_data->isharp_lba.slope_seg[4] = 0;
dscl_prog_data->isharp_lba.in_seg[5] = 520;
dscl_prog_data->isharp_lba.base_seg[5] = 0;
} else if (setup == HDR_L) {
dscl_prog_data->isharp_lba.in_seg[0] = 0;
dscl_prog_data->isharp_lba.base_seg[0] = 0;
dscl_prog_data->isharp_lba.slope_seg[0] = 32;
dscl_prog_data->isharp_lba.in_seg[1] = 254;
dscl_prog_data->isharp_lba.base_seg[1] = 63;
dscl_prog_data->isharp_lba.slope_seg[1] = 0;
dscl_prog_data->isharp_lba.in_seg[2] = 559;
dscl_prog_data->isharp_lba.base_seg[2] = 63;
dscl_prog_data->isharp_lba.slope_seg[2] = 0x10C;
dscl_prog_data->isharp_lba.in_seg[3] = 592;
dscl_prog_data->isharp_lba.base_seg[3] = 0;
dscl_prog_data->isharp_lba.slope_seg[3] = 0;
dscl_prog_data->isharp_lba.in_seg[4] = 1023;
dscl_prog_data->isharp_lba.base_seg[4] = 0;
dscl_prog_data->isharp_lba.slope_seg[4] = 0;
dscl_prog_data->isharp_lba.in_seg[5] = 1023;
dscl_prog_data->isharp_lba.base_seg[5] = 0;
} else {
dscl_prog_data->isharp_lba.in_seg[0] = 0;
dscl_prog_data->isharp_lba.base_seg[0] = 0;
dscl_prog_data->isharp_lba.slope_seg[0] = 40;
dscl_prog_data->isharp_lba.in_seg[1] = 204;
dscl_prog_data->isharp_lba.base_seg[1] = 63;
dscl_prog_data->isharp_lba.slope_seg[1] = 0;
dscl_prog_data->isharp_lba.in_seg[2] = 818;
dscl_prog_data->isharp_lba.base_seg[2] = 63;
dscl_prog_data->isharp_lba.slope_seg[2] = 0x1D9;
dscl_prog_data->isharp_lba.in_seg[3] = 1023;
dscl_prog_data->isharp_lba.base_seg[3] = 0;
dscl_prog_data->isharp_lba.slope_seg[3] = 0;
dscl_prog_data->isharp_lba.in_seg[4] = 1023;
dscl_prog_data->isharp_lba.base_seg[4] = 0;
dscl_prog_data->isharp_lba.slope_seg[4] = 0;
dscl_prog_data->isharp_lba.in_seg[5] = 1023;
dscl_prog_data->isharp_lba.base_seg[5] = 0;
}
if (lls_pref == LLS_PREF_YES) {
dscl_prog_data->isharp_nldelta_sclip.enable_p = 0;
dscl_prog_data->isharp_nldelta_sclip.pivot_p = 0;
dscl_prog_data->isharp_nldelta_sclip.slope_p = 0;
dscl_prog_data->isharp_nldelta_sclip.enable_n = 1;
dscl_prog_data->isharp_nldelta_sclip.pivot_n = 71;
dscl_prog_data->isharp_nldelta_sclip.slope_n = 16;
} else {
dscl_prog_data->isharp_nldelta_sclip.enable_p = 1;
dscl_prog_data->isharp_nldelta_sclip.pivot_p = 70;
dscl_prog_data->isharp_nldelta_sclip.slope_p = 24;
dscl_prog_data->isharp_nldelta_sclip.enable_n = 1;
dscl_prog_data->isharp_nldelta_sclip.pivot_n = 70;
dscl_prog_data->isharp_nldelta_sclip.slope_n = 24;
}
SPL_NAMESPACE(spl_set_blur_scale_data(dscl_prog_data, data));
}
static bool spl_calculate_number_of_taps(struct spl_in *spl_in, struct spl_scratch *spl_scratch, struct spl_out *spl_out,
bool *enable_easf_v, bool *enable_easf_h, bool *enable_isharp)
{
bool res = false;
memset(spl_scratch, 0, sizeof(struct spl_scratch));
spl_scratch->scl_data.h_active = spl_in->h_active;
spl_scratch->scl_data.v_active = spl_in->v_active;
spl_calculate_recout(spl_in, spl_scratch, spl_out);
spl_calculate_scaling_ratios(spl_in, spl_scratch, spl_out);
spl_opp_adjust_rect(&spl_scratch->scl_data.recout, &spl_in->basic_in.opp_recout_adjust);
spl_calculate_viewport_size(spl_in, spl_scratch);
res = spl_get_optimal_number_of_taps(
spl_in->basic_out.max_downscale_src_width, spl_in,
spl_scratch, &spl_in->scaling_quality, enable_easf_v,
enable_easf_h, enable_isharp);
return res;
}
bool SPL_NAMESPACE(spl_calculate_scaler_params(struct spl_in *spl_in, struct spl_out *spl_out))
{
bool res = false;
bool enable_easf_v = false;
bool enable_easf_h = false;
int vratio = 0;
int hratio = 0;
struct spl_scratch spl_scratch;
struct spl_fixed31_32 isharp_scale_ratio;
enum system_setup setup;
bool enable_isharp = false;
const struct spl_scaler_data *data = &spl_scratch.scl_data;
res = spl_calculate_number_of_taps(spl_in, &spl_scratch, spl_out,
&enable_easf_v, &enable_easf_h, &enable_isharp);
if (res)
spl_calculate_inits_and_viewports(spl_in, &spl_scratch);
spl_handle_3d_recout(spl_in, &spl_scratch.scl_data.recout);
spl_clamp_viewport(&spl_scratch.scl_data.viewport, spl_in->min_viewport_size);
spl_set_dscl_prog_data(spl_in, &spl_scratch, spl_out, enable_easf_v, enable_easf_h, enable_isharp);
if (!res)
return res;
if (spl_in->lls_pref == LLS_PREF_YES) {
if (spl_in->is_hdr_on)
setup = HDR_L;
else
setup = SDR_L;
} else {
if (spl_in->is_hdr_on)
setup = HDR_NL;
else
setup = SDR_NL;
}
spl_set_easf_data(&spl_scratch, spl_out, enable_easf_v, enable_easf_h, spl_in->lls_pref,
spl_in->basic_in.format, setup, spl_in->sdr_white_level_nits);
vratio = spl_fixpt_ceil(spl_scratch.scl_data.ratios.vert);
hratio = spl_fixpt_ceil(spl_scratch.scl_data.ratios.horz);
if (vratio <= hratio)
isharp_scale_ratio = spl_scratch.scl_data.recip_ratios.vert;
else
isharp_scale_ratio = spl_scratch.scl_data.recip_ratios.horz;
spl_set_isharp_data(spl_out->dscl_prog_data, spl_in->adaptive_sharpness, enable_isharp,
spl_in->lls_pref, spl_in->basic_in.format, data, isharp_scale_ratio, setup,
spl_in->debug.scale_to_sharpness_policy);
return res;
}
bool SPL_NAMESPACE(spl_get_number_of_taps(struct spl_in *spl_in, struct spl_out *spl_out))
{
bool res = false;
bool enable_easf_v = false;
bool enable_easf_h = false;
bool enable_isharp = false;
struct spl_scratch spl_scratch;
struct dscl_prog_data *dscl_prog_data = spl_out->dscl_prog_data;
const struct spl_scaler_data *data = &spl_scratch.scl_data;
res = spl_calculate_number_of_taps(spl_in, &spl_scratch, spl_out,
&enable_easf_v, &enable_easf_h, &enable_isharp);
spl_set_taps_data(dscl_prog_data, data);
return res;
}