浏览代码

[media] omap3isp: resizer: Center the crop rectangle

When the crop rectangle needs to be modified to match hardware
requirements, center the resulting rectangle on the requested rectangle
instead of removing pixels from the right and bottom sides only.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Laurent Pinchart 14 年之前
父节点
当前提交
8eca7a004e
共有 1 个文件被更改,包括 12 次插入4 次删除
  1. 12 4
      drivers/media/video/omap3isp/ispresizer.c

+ 12 - 4
drivers/media/video/omap3isp/ispresizer.c

@@ -775,6 +775,8 @@ static void resizer_calc_ratios(struct isp_res_device *res,
 	unsigned int max_width;
 	unsigned int max_width;
 	unsigned int max_height;
 	unsigned int max_height;
 	unsigned int width_alignment;
 	unsigned int width_alignment;
+	unsigned int width;
+	unsigned int height;
 
 
 	/*
 	/*
 	 * Clamp the output height based on the hardware capabilities and
 	 * Clamp the output height based on the hardware capabilities and
@@ -794,11 +796,11 @@ static void resizer_calc_ratios(struct isp_res_device *res,
 	if (ratio->vert <= MID_RESIZE_VALUE) {
 	if (ratio->vert <= MID_RESIZE_VALUE) {
 		upscaled_height = (output->height - 1) * ratio->vert
 		upscaled_height = (output->height - 1) * ratio->vert
 				+ 32 * spv + 16;
 				+ 32 * spv + 16;
-		input->height = (upscaled_height >> 8) + 4;
+		height = (upscaled_height >> 8) + 4;
 	} else {
 	} else {
 		upscaled_height = (output->height - 1) * ratio->vert
 		upscaled_height = (output->height - 1) * ratio->vert
 				+ 64 * spv + 32;
 				+ 64 * spv + 32;
-		input->height = (upscaled_height >> 8) + 7;
+		height = (upscaled_height >> 8) + 7;
 	}
 	}
 
 
 	/*
 	/*
@@ -862,12 +864,18 @@ static void resizer_calc_ratios(struct isp_res_device *res,
 	if (ratio->horz <= MID_RESIZE_VALUE) {
 	if (ratio->horz <= MID_RESIZE_VALUE) {
 		upscaled_width = (output->width - 1) * ratio->horz
 		upscaled_width = (output->width - 1) * ratio->horz
 			       + 32 * sph + 16;
 			       + 32 * sph + 16;
-		input->width = (upscaled_width >> 8) + 7;
+		width = (upscaled_width >> 8) + 7;
 	} else {
 	} else {
 		upscaled_width = (output->width - 1) * ratio->horz
 		upscaled_width = (output->width - 1) * ratio->horz
 			       + 64 * sph + 32;
 			       + 64 * sph + 32;
-		input->width = (upscaled_width >> 8) + 7;
+		width = (upscaled_width >> 8) + 7;
 	}
 	}
+
+	/* Center the new crop rectangle. */
+	input->left += (input->width - width) / 2;
+	input->top += (input->height - height) / 2;
+	input->width = width;
+	input->height = height;
 }
 }
 
 
 /*
 /*