Commit f7a3d3dc authored by Stanimir Varbanov's avatar Stanimir Varbanov Committed by Mauro Carvalho Chehab

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: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 9d5adeec
...@@ -256,6 +256,7 @@ struct venc_controls { ...@@ -256,6 +256,7 @@ struct venc_controls {
u32 header_mode; u32 header_mode;
bool aud_enable; bool aud_enable;
u32 intra_refresh_period;
struct { struct {
u32 h264; u32 h264;
......
...@@ -549,6 +549,7 @@ static int venc_set_properties(struct venus_inst *inst) ...@@ -549,6 +549,7 @@ static int venc_set_properties(struct venus_inst *inst)
struct hfi_quantization_range quant_range; struct hfi_quantization_range quant_range;
struct hfi_enable en; struct hfi_enable en;
struct hfi_ltr_mode ltr_mode; struct hfi_ltr_mode ltr_mode;
struct hfi_intra_refresh intra_refresh = {};
u32 ptype, rate_control, bitrate; u32 ptype, rate_control, bitrate;
u32 profile, level; u32 profile, level;
int ret; int ret;
...@@ -804,6 +805,31 @@ static int venc_set_properties(struct venus_inst *inst) ...@@ -804,6 +805,31 @@ static int venc_set_properties(struct venus_inst *inst)
en.enable = 1; en.enable = 1;
ret = hfi_session_set_property(inst, ptype, &en); ret = hfi_session_set_property(inst, ptype, &en);
}
if ((inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 ||
inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) &&
(rate_control == HFI_RATE_CONTROL_CBR_VFR ||
rate_control == HFI_RATE_CONTROL_CBR_CFR)) {
intra_refresh.mode = HFI_INTRA_REFRESH_NONE;
intra_refresh.cir_mbs = 0;
if (ctr->intra_refresh_period) {
u32 mbs;
mbs = ALIGN(inst->width, 16) * ALIGN(inst->height, 16);
mbs /= 16 * 16;
if (mbs % ctr->intra_refresh_period)
mbs++;
mbs /= ctr->intra_refresh_period;
intra_refresh.mode = HFI_INTRA_REFRESH_RANDOM;
intra_refresh.cir_mbs = mbs;
}
ptype = HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH;
ret = hfi_session_set_property(inst, ptype, &intra_refresh);
if (ret) if (ret)
return ret; return ret;
} }
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#define SLICE_BYTE_SIZE_MAX 1024 #define SLICE_BYTE_SIZE_MAX 1024
#define SLICE_BYTE_SIZE_MIN 1024 #define SLICE_BYTE_SIZE_MIN 1024
#define SLICE_MB_SIZE_MAX 300 #define SLICE_MB_SIZE_MAX 300
#define INTRA_REFRESH_MBS_MAX 300
#define AT_SLICE_BOUNDARY \ #define AT_SLICE_BOUNDARY \
V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY
#define MAX_LTR_FRAME_COUNT 4 #define MAX_LTR_FRAME_COUNT 4
...@@ -227,8 +226,6 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -227,8 +226,6 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
} }
mutex_unlock(&inst->lock); mutex_unlock(&inst->lock);
break; break;
case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB:
break;
case V4L2_CID_MPEG_VIDEO_GOP_SIZE: case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
ret = venc_calc_bpframes(ctrl->val, ctr->num_b_frames, &bframes, ret = venc_calc_bpframes(ctrl->val, ctr->num_b_frames, &bframes,
&ctr->num_p_frames); &ctr->num_p_frames);
...@@ -319,6 +316,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -319,6 +316,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY: case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
ctr->mastering = *ctrl->p_new.p_hdr10_mastering; ctr->mastering = *ctrl->p_new.p_hdr10_mastering;
break; break;
case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD:
ctr->intra_refresh_period = ctrl->val;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -502,10 +502,6 @@ int venc_ctrl_init(struct venus_inst *inst) ...@@ -502,10 +502,6 @@ int venc_ctrl_init(struct venus_inst *inst)
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA, -6, 6, 1, 0); V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA, -6, 6, 1, 0);
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB,
0, INTRA_REFRESH_MBS_MAX, 1, 0);
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_MPEG_VIDEO_GOP_SIZE, 0, (1 << 16) - 1, 1, 30); V4L2_CID_MPEG_VIDEO_GOP_SIZE, 0, (1 << 16) - 1, 1, 30);
...@@ -564,6 +560,10 @@ int venc_ctrl_init(struct venus_inst *inst) ...@@ -564,6 +560,10 @@ int venc_ctrl_init(struct venus_inst *inst)
V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY, V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY,
v4l2_ctrl_ptr_create(NULL)); v4l2_ctrl_ptr_create(NULL));
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD, 0,
((4096 * 2304) >> 8), 1, 0);
ret = inst->ctrl_handler.error; ret = inst->ctrl_handler.error;
if (ret) if (ret)
goto err; goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment