Skip to content

Commit f7a3d3d

Browse files
Stanimir Varbanovmchehab
authored andcommitted
media: venus: venc: Add support for intra-refresh period
Add support for intra-refresh period v4l2 control and drop cyclic intra-refresh macroblock control in the same time. Signed-off-by: Stanimir Varbanov <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 9d5adee commit f7a3d3d

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

drivers/media/platform/qcom/venus/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ struct venc_controls {
256256

257257
u32 header_mode;
258258
bool aud_enable;
259+
u32 intra_refresh_period;
259260

260261
struct {
261262
u32 h264;

drivers/media/platform/qcom/venus/venc.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ static int venc_set_properties(struct venus_inst *inst)
549549
struct hfi_quantization_range quant_range;
550550
struct hfi_enable en;
551551
struct hfi_ltr_mode ltr_mode;
552+
struct hfi_intra_refresh intra_refresh = {};
552553
u32 ptype, rate_control, bitrate;
553554
u32 profile, level;
554555
int ret;
@@ -804,6 +805,31 @@ static int venc_set_properties(struct venus_inst *inst)
804805
en.enable = 1;
805806

806807
ret = hfi_session_set_property(inst, ptype, &en);
808+
}
809+
810+
if ((inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 ||
811+
inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) &&
812+
(rate_control == HFI_RATE_CONTROL_CBR_VFR ||
813+
rate_control == HFI_RATE_CONTROL_CBR_CFR)) {
814+
intra_refresh.mode = HFI_INTRA_REFRESH_NONE;
815+
intra_refresh.cir_mbs = 0;
816+
817+
if (ctr->intra_refresh_period) {
818+
u32 mbs;
819+
820+
mbs = ALIGN(inst->width, 16) * ALIGN(inst->height, 16);
821+
mbs /= 16 * 16;
822+
if (mbs % ctr->intra_refresh_period)
823+
mbs++;
824+
mbs /= ctr->intra_refresh_period;
825+
826+
intra_refresh.mode = HFI_INTRA_REFRESH_RANDOM;
827+
intra_refresh.cir_mbs = mbs;
828+
}
829+
830+
ptype = HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH;
831+
832+
ret = hfi_session_set_property(inst, ptype, &intra_refresh);
807833
if (ret)
808834
return ret;
809835
}

drivers/media/platform/qcom/venus/venc_ctrls.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#define SLICE_BYTE_SIZE_MAX 1024
1818
#define SLICE_BYTE_SIZE_MIN 1024
1919
#define SLICE_MB_SIZE_MAX 300
20-
#define INTRA_REFRESH_MBS_MAX 300
2120
#define AT_SLICE_BOUNDARY \
2221
V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY
2322
#define MAX_LTR_FRAME_COUNT 4
@@ -227,8 +226,6 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
227226
}
228227
mutex_unlock(&inst->lock);
229228
break;
230-
case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB:
231-
break;
232229
case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
233230
ret = venc_calc_bpframes(ctrl->val, ctr->num_b_frames, &bframes,
234231
&ctr->num_p_frames);
@@ -319,6 +316,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
319316
case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
320317
ctr->mastering = *ctrl->p_new.p_hdr10_mastering;
321318
break;
319+
case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD:
320+
ctr->intra_refresh_period = ctrl->val;
321+
break;
322322
default:
323323
return -EINVAL;
324324
}
@@ -502,10 +502,6 @@ int venc_ctrl_init(struct venus_inst *inst)
502502
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
503503
V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA, -6, 6, 1, 0);
504504

505-
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
506-
V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB,
507-
0, INTRA_REFRESH_MBS_MAX, 1, 0);
508-
509505
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
510506
V4L2_CID_MPEG_VIDEO_GOP_SIZE, 0, (1 << 16) - 1, 1, 30);
511507

@@ -564,6 +560,10 @@ int venc_ctrl_init(struct venus_inst *inst)
564560
V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY,
565561
v4l2_ctrl_ptr_create(NULL));
566562

563+
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
564+
V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD, 0,
565+
((4096 * 2304) >> 8), 1, 0);
566+
567567
ret = inst->ctrl_handler.error;
568568
if (ret)
569569
goto err;

0 commit comments

Comments
 (0)