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

Commit ac598c37 authored by Praneeth Paladugu's avatar Praneeth Paladugu
Browse files

msm: vidc: Limit the session QP for HEVC encoder



For some use cases HEVC RC algorithm is deriving QP as
low as 1. This increases the encoded bit rate to very
high value. Hence limit the minimum QP value to 2.

CRs-Fixed: 817156
Change-Id: I3f5cc0e51203272657673563ca94dcbbb778fe01
Signed-off-by: default avatarPraneeth Paladugu <ppaladug@codeaurora.org>
parent 2e5123a1
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -3239,6 +3239,8 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)

	if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
		struct hal_frame_size frame_sz = {0};
		struct hal_quantization_range qp_range;
		void *pdata = NULL;

		rc = msm_comm_try_state(inst, MSM_VIDC_OPEN_DONE);
		if (rc) {
@@ -3257,6 +3259,33 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
					"Failed to set OUTPUT framesize\n");
			goto exit;
		}

		if (inst->fmts[CAPTURE_PORT]->fourcc == V4L2_PIX_FMT_HEVC) {

			/*
			* Currently Venus HW has a limitation on minimum
			* value of QP for HEVC encoder. Hence restricting
			* the QP in the range of 2 - 51. This workaround
			* will be removed once FW able to handle the full
			* QP range.
			*/

			qp_range.layer_id = 0;
			qp_range.max_qp = 51;
			qp_range.min_qp = 2;

			pdata = &qp_range;

			rc = call_hfi_op(hdev, session_set_property,
					(void *)inst->session,
					HAL_PARAM_VENC_SESSION_QP_RANGE, pdata);
			if (rc) {
				dprintk(VIDC_ERR,
						"Failed to set QP range\n");
				goto exit;
			}
		}

	} else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
		struct hal_buffer_requirements *bufreq = NULL;
		int extra_idx = 0;