Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d3a015f authored by Dikshita Agarwal's avatar Dikshita Agarwal Committed by Amit Shekhar
Browse files

msm-vidc: calculate buffer size based on 512x512 for heic



For HEIC encoding, client sets output resolution = input resolution.
However, driver produces tile based output. Hence, output buffer size
and firmware output buffer size should be based on tile size.

Change-Id: Ib1fe1c1caaf09f01b928f8b6e54e8e473c50f411
Signed-off-by: default avatarAmit Shekhar <ashekhar@codeaurora.org>
parent 01a16bd3
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ static struct msm_vidc_ctrl msm_venc_ctrls[] = {
		.name = "Image grid size",
		.type = V4L2_CTRL_TYPE_INTEGER,
		.minimum = 0,
		.maximum = 512,
		.maximum = HEIC_GRID_DIMENSION,
		.default_value = 0,
		.step = 1,
		.qmenu = NULL,
@@ -1929,6 +1929,11 @@ int msm_venc_set_frame_size(struct msm_vidc_inst *inst)
	frame_sz.buffer_type = HFI_BUFFER_OUTPUT;
	frame_sz.width = f->fmt.pix_mp.width;
	frame_sz.height = f->fmt.pix_mp.height;
	/* firmware needs grid size in output where as
	 * client sends out full resolution in output port */
	if (is_grid_session(inst)) {
		frame_sz.width = frame_sz.height = HEIC_GRID_DIMENSION;
	}
	s_vpr_h(inst->sid, "%s: output %d %d\n", __func__,
			frame_sz.width, frame_sz.height);
	rc = call_hfi_op(hdev, session_set_property, inst->session,
+4 −0
Original line number Diff line number Diff line
@@ -980,6 +980,10 @@ u32 msm_vidc_calculate_enc_output_frame_size(struct msm_vidc_inst *inst)
	 * For resolution > 4k : YUVsize / 4
	 * Initially frame_size = YUVsize * 2;
	 */

	if (is_grid_session(inst)) {
		f->fmt.pix_mp.width = f->fmt.pix_mp.height = HEIC_GRID_DIMENSION;
	}
	width = ALIGN(f->fmt.pix_mp.width, BUFFER_ALIGNMENT_SIZE(32));
	height = ALIGN(f->fmt.pix_mp.height, BUFFER_ALIGNMENT_SIZE(32));
	mbs_per_frame = NUM_MBS_PER_FRAME(width, height);
+4 −11
Original line number Diff line number Diff line
@@ -5594,16 +5594,11 @@ int msm_vidc_check_scaling_supported(struct msm_vidc_inst *inst)
	u32 x_min, x_max, y_min, y_max;
	u32 input_height, input_width, output_height, output_width;
	struct v4l2_format *f;
	struct v4l2_ctrl *ctrl = NULL;

	/* Grid get_ctrl allowed for encode session only */
	if (is_image_session(inst)) {
		ctrl = get_ctrl(inst, V4L2_CID_MPEG_VIDC_IMG_GRID_SIZE);
		if (ctrl->val > 0) {
	if (is_grid_session(inst)) {
		s_vpr_h(inst->sid, "Skip scaling check for HEIC\n");
		return 0;
	}
	}

	f = &inst->fmts[INPUT_PORT].v4l2_fmt;
	input_height = f->fmt.pix_mp.height;
@@ -5687,7 +5682,6 @@ int msm_vidc_check_session_supported(struct msm_vidc_inst *inst)
	u32 width_min, width_max, height_min, height_max;
	u32 mbpf_max;
	struct v4l2_format *f;
	struct v4l2_ctrl *ctrl = NULL;
	u32 sid;

	if (!inst || !inst->core || !inst->core->device) {
@@ -5750,8 +5744,7 @@ int msm_vidc_check_session_supported(struct msm_vidc_inst *inst)
			return -ENOTSUPP;
		}

		ctrl = get_ctrl(inst, V4L2_CID_MPEG_VIDC_IMG_GRID_SIZE);
		if (ctrl->val > 0) {
		if (is_grid_session(inst)) {
			if (inst->fmts[INPUT_PORT].v4l2_fmt.fmt.pix_mp.pixelformat !=
				V4L2_PIX_FMT_NV12 &&
				inst->fmts[INPUT_PORT].v4l2_fmt.fmt.pix_mp.pixelformat !=
+10 −0
Original line number Diff line number Diff line
@@ -110,6 +110,16 @@ static inline bool is_image_session(struct msm_vidc_inst *inst)
		inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_CQ;
}

static inline bool is_grid_session(struct msm_vidc_inst *inst)
{
	struct v4l2_ctrl *ctrl = NULL;
	if (inst->session_type == MSM_VIDC_ENCODER &&
		get_v4l2_codec(inst) == V4L2_PIX_FMT_HEVC) {
		ctrl = get_ctrl(inst, V4L2_CID_MPEG_VIDC_IMG_GRID_SIZE);
		return (ctrl->val > 0);
	}
	return 0;
}
static inline bool is_realtime_session(struct msm_vidc_inst *inst)
{
	struct v4l2_ctrl *ctrl;