Commit f792e4f6 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] omap3isp: resizer: Use 4-tap mode equations when the ratio is <= 512

As the number of phases/taps, used to select the correct equations to
compute the ratio, depends on the ratio, start with the 7-tap mode
equations to compute an approximation of the ratio, and switch to the
4-tap mode equations if the approximation is lower than or equal to 512.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 8eca7a00
...@@ -724,9 +724,20 @@ static void resizer_print_status(struct isp_res_device *res) ...@@ -724,9 +724,20 @@ static void resizer_print_status(struct isp_res_device *res)
* vrsz = ((ih - 7) * 256 - 32 - 64 * spv) / (oh - 1) * vrsz = ((ih - 7) * 256 - 32 - 64 * spv) / (oh - 1)
* *
* The ratios are integer values, and must be rounded down to ensure that the * The ratios are integer values, and must be rounded down to ensure that the
* cropped input size is not bigger than the uncropped input size. As the ratio * cropped input size is not bigger than the uncropped input size.
* in 7-tap mode is always smaller than the ratio in 4-tap mode, we can use the *
* 7-tap mode equations to compute a ratio approximation. * As the number of phases/taps, used to select the correct equations to compute
* the ratio, depends on the ratio, we start with the 4-tap mode equations to
* compute an approximation of the ratio, and switch to the 7-tap mode equations
* if the approximation is higher than the ratio threshold.
*
* As the 7-tap mode equations will return a ratio smaller than or equal to the
* 4-tap mode equations, the resulting ratio could become lower than or equal to
* the ratio threshold. This 'equations loop' isn't an issue as long as the
* correct equations are used to compute the final input size. Starting with the
* 4-tap mode equations ensure that, in case of values resulting in a 'ratio
* loop', the smallest of the ratio values will be used, never exceeding the
* requested input size.
* *
* We first clamp the output size according to the hardware capabilitie to avoid * We first clamp the output size according to the hardware capabilitie to avoid
* auto-cropping the input more than required to satisfy the TRM equations. The * auto-cropping the input more than required to satisfy the TRM equations. The
...@@ -788,6 +799,9 @@ static void resizer_calc_ratios(struct isp_res_device *res, ...@@ -788,6 +799,9 @@ static void resizer_calc_ratios(struct isp_res_device *res,
max_height = min_t(unsigned int, max_height, MAX_OUT_HEIGHT); max_height = min_t(unsigned int, max_height, MAX_OUT_HEIGHT);
output->height = clamp(output->height, min_height, max_height); output->height = clamp(output->height, min_height, max_height);
ratio->vert = ((input->height - 4) * 256 - 16 - 32 * spv)
/ (output->height - 1);
if (ratio->vert > MID_RESIZE_VALUE)
ratio->vert = ((input->height - 7) * 256 - 32 - 64 * spv) ratio->vert = ((input->height - 7) * 256 - 32 - 64 * spv)
/ (output->height - 1); / (output->height - 1);
ratio->vert = clamp_t(unsigned int, ratio->vert, ratio->vert = clamp_t(unsigned int, ratio->vert,
...@@ -856,6 +870,9 @@ static void resizer_calc_ratios(struct isp_res_device *res, ...@@ -856,6 +870,9 @@ static void resizer_calc_ratios(struct isp_res_device *res,
max_width & ~(width_alignment - 1)); max_width & ~(width_alignment - 1));
output->width = ALIGN(output->width, width_alignment); output->width = ALIGN(output->width, width_alignment);
ratio->horz = ((input->width - 7) * 256 - 16 - 32 * sph)
/ (output->width - 1);
if (ratio->horz > MID_RESIZE_VALUE)
ratio->horz = ((input->width - 7) * 256 - 32 - 64 * sph) ratio->horz = ((input->width - 7) * 256 - 32 - 64 * sph)
/ (output->width - 1); / (output->width - 1);
ratio->horz = clamp_t(unsigned int, ratio->horz, ratio->horz = clamp_t(unsigned int, ratio->horz,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment