瀏覽代碼

video: driver: fix incorrect crop resolution

Store unaligned resolution in driver inst formats
to avoid crop resolution getting updated to aligned
resolution whenever client did g_fmt and s_fmt again
after setting raw input resolution.

Change-Id: Ic2b6cf6e7d418d2bf0c35270199b914648e933d4
Signed-off-by: Akshata Sahukar <[email protected]>
Akshata Sahukar 3 年之前
父節點
當前提交
93742170e9
共有 3 個文件被更改,包括 18 次插入19 次删除
  1. 2 5
      driver/vidc/src/msm_venc.c
  2. 16 4
      driver/vidc/src/msm_vidc_buffer.c
  3. 0 10
      driver/vidc/src/msm_vidc_driver.c

+ 2 - 5
driver/vidc/src/msm_venc.c

@@ -1227,11 +1227,8 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
 	height = f->fmt.pix_mp.height;
 
 	if (is_image_session(inst)) {
-		width = ALIGN(f->fmt.pix_mp.width, HEIC_GRID_DIMENSION);
-		height = ALIGN(f->fmt.pix_mp.height, HEIC_GRID_DIMENSION);
-		inst->crop.width = ALIGN(inst->crop.width, HEIC_GRID_DIMENSION);
-		inst->crop.height = ALIGN(inst->crop.height, HEIC_GRID_DIMENSION);
-		bytesperline = width * (is_10bit_colorformat(pix_fmt) ? 2 : 1);
+		bytesperline = ALIGN(f->fmt.pix_mp.width, HEIC_GRID_DIMENSION) *
+			(is_10bit_colorformat(pix_fmt) ? 2 : 1);
 	} else if (is_rgba_colorformat(pix_fmt)) {
 		bytesperline = VIDEO_RGB_STRIDE_BYTES(f->fmt.pix_mp.pixelformat,
 				f->fmt.pix_mp.width);

+ 16 - 4
driver/vidc/src/msm_vidc_buffer.c

@@ -294,11 +294,17 @@ u32 msm_vidc_encoder_input_size(struct msm_vidc_inst *inst)
 {
 	u32 size;
 	struct v4l2_format *f;
+	u32 width, height;
 
 	f = &inst->fmts[INPUT_PORT];
+	width = f->fmt.pix_mp.width;
+	height = f->fmt.pix_mp.height;
+	if (is_image_session(inst)) {
+		width = ALIGN(width, HEIC_GRID_DIMENSION);
+		height = ALIGN(height, HEIC_GRID_DIMENSION);
+	}
 	size = VIDEO_RAW_BUFFER_SIZE(f->fmt.pix_mp.pixelformat,
-			f->fmt.pix_mp.width,
-			f->fmt.pix_mp.height, true);
+			width, height, true);
 	return size;
 }
 
@@ -415,6 +421,7 @@ u32 msm_vidc_encoder_input_meta_size(struct msm_vidc_inst *inst)
 	u32 size = 0;
 	u32 lcu_size = 0;
 	struct v4l2_format *f;
+	u32 width, height;
 
 	if (!inst || !inst->capabilities) {
 		d_vpr_e("%s: invalid params\n", __func__);
@@ -434,8 +441,13 @@ u32 msm_vidc_encoder_input_meta_size(struct msm_vidc_inst *inst)
 			lcu_size = 32;
 
 		f = &inst->fmts[INPUT_PORT];
-		size += ROI_METADATA_SIZE(f->fmt.pix_mp.width,
-			f->fmt.pix_mp.height, lcu_size);
+		width = f->fmt.pix_mp.width;
+		height = f->fmt.pix_mp.height;
+		if (is_image_session(inst)) {
+			width = ALIGN(width, HEIC_GRID_DIMENSION);
+			height = ALIGN(height, HEIC_GRID_DIMENSION);
+		}
+		size += ROI_METADATA_SIZE(width, height, lcu_size);
 		size = ALIGN(size, SZ_4K);
 	}
 	return size;

+ 0 - 10
driver/vidc/src/msm_vidc_driver.c

@@ -6194,16 +6194,6 @@ static bool msm_vidc_allow_image_encode_session(struct msm_vidc_inst *inst)
 		goto exit;
 	}
 
-	/* is input grid aligned */
-	fmt = &inst->fmts[INPUT_PORT];
-	allow = IS_ALIGNED(fmt->fmt.pix_mp.width, HEIC_GRID_DIMENSION);
-	allow &= IS_ALIGNED(fmt->fmt.pix_mp.height, HEIC_GRID_DIMENSION);
-	if (!allow) {
-		i_vpr_e(inst, "%s: input is not grid aligned: %u x %u\n", __func__,
-			fmt->fmt.pix_mp.width, fmt->fmt.pix_mp.height);
-		goto exit;
-	}
-
 	/* is output grid dimension */
 	fmt = &inst->fmts[OUTPUT_PORT];
 	allow = fmt->fmt.pix_mp.width == HEIC_GRID_DIMENSION;