Commit f7d12fea authored by Loic Poulain's avatar Loic Poulain Committed by Mauro Carvalho Chehab

media: venus: venc: Apply inloop deblocking filter

Deblocking filter allows to reduce blocking artifacts and improve
visual quality. This is configurable via the V4L2 API but eventually
not applied to the encoder.

Note that alpha and beta deblocking values are 32-bit signed (-6;+6).
Signed-off-by: default avatarLoic Poulain <loic.poulain@linaro.org>
Reviewed-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent a7837e11
...@@ -144,8 +144,8 @@ struct venc_controls { ...@@ -144,8 +144,8 @@ struct venc_controls {
u32 h264_min_qp; u32 h264_min_qp;
u32 h264_max_qp; u32 h264_max_qp;
u32 h264_loop_filter_mode; u32 h264_loop_filter_mode;
u32 h264_loop_filter_alpha; s32 h264_loop_filter_alpha;
u32 h264_loop_filter_beta; s32 h264_loop_filter_beta;
u32 vp8_min_qp; u32 vp8_min_qp;
u32 vp8_max_qp; u32 vp8_max_qp;
......
...@@ -585,8 +585,8 @@ struct hfi_enable { ...@@ -585,8 +585,8 @@ struct hfi_enable {
struct hfi_h264_db_control { struct hfi_h264_db_control {
u32 mode; u32 mode;
u32 slice_alpha_offset; s32 slice_alpha_offset;
u32 slice_beta_offset; s32 slice_beta_offset;
}; };
#define HFI_H264_ENTROPY_CAVLC 0x1 #define HFI_H264_ENTROPY_CAVLC 0x1
......
...@@ -234,6 +234,16 @@ static int venc_v4l2_to_hfi(int id, int value) ...@@ -234,6 +234,16 @@ static int venc_v4l2_to_hfi(int id, int value)
case 3: case 3:
return HFI_VPX_PROFILE_VERSION_3; return HFI_VPX_PROFILE_VERSION_3;
} }
case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE:
switch (value) {
case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED:
default:
return HFI_H264_DB_MODE_ALL_BOUNDARY;
case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED:
return HFI_H264_DB_MODE_DISABLE;
case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY:
return HFI_H264_DB_MODE_SKIP_SLICE_BOUNDARY;
}
} }
return 0; return 0;
...@@ -642,6 +652,7 @@ static int venc_set_properties(struct venus_inst *inst) ...@@ -642,6 +652,7 @@ static int venc_set_properties(struct venus_inst *inst)
if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) {
struct hfi_h264_vui_timing_info info; struct hfi_h264_vui_timing_info info;
struct hfi_h264_entropy_control entropy; struct hfi_h264_entropy_control entropy;
struct hfi_h264_db_control deblock;
ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO; ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO;
info.enable = 1; info.enable = 1;
...@@ -661,6 +672,17 @@ static int venc_set_properties(struct venus_inst *inst) ...@@ -661,6 +672,17 @@ static int venc_set_properties(struct venus_inst *inst)
ret = hfi_session_set_property(inst, ptype, &entropy); ret = hfi_session_set_property(inst, ptype, &entropy);
if (ret) if (ret)
return ret; return ret;
ptype = HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL;
deblock.mode = venc_v4l2_to_hfi(
V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE,
ctr->h264_loop_filter_mode);
deblock.slice_alpha_offset = ctr->h264_loop_filter_alpha;
deblock.slice_beta_offset = ctr->h264_loop_filter_beta;
ret = hfi_session_set_property(inst, ptype, &deblock);
if (ret)
return ret;
} }
/* IDR periodicity, n: /* IDR periodicity, n:
......
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