media: venus: venc: Apply inloop deblocking filter
authorLoic Poulain <loic.poulain@linaro.org>
Fri, 24 Nov 2017 09:34:02 +0000 (04:34 -0500)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 8 Dec 2017 16:20:41 +0000 (11:20 -0500)
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: Loic Poulain <loic.poulain@linaro.org>
Reviewed-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/qcom/venus/core.h
drivers/media/platform/qcom/venus/hfi_helper.h
drivers/media/platform/qcom/venus/venc.c

index a0fe80df0cbd541ee3befb11059dc90343ce21f4..0360d295f4c839363f87ed9d51734b6c052ce255 100644 (file)
@@ -144,8 +144,8 @@ struct venc_controls {
        u32 h264_min_qp;
        u32 h264_max_qp;
        u32 h264_loop_filter_mode;
-       u32 h264_loop_filter_alpha;
-       u32 h264_loop_filter_beta;
+       s32 h264_loop_filter_alpha;
+       s32 h264_loop_filter_beta;
 
        u32 vp8_min_qp;
        u32 vp8_max_qp;
index 8d282dba9e5721ab3389dddc61cab35d67573a91..55d8eb21403a72be6b2db6b7cffaa3d61f5b8259 100644 (file)
@@ -585,8 +585,8 @@ struct hfi_enable {
 
 struct hfi_h264_db_control {
        u32 mode;
-       u32 slice_alpha_offset;
-       u32 slice_beta_offset;
+       s32 slice_alpha_offset;
+       s32 slice_beta_offset;
 };
 
 #define HFI_H264_ENTROPY_CAVLC                 0x1
index 0c2331f53b7981d3d07b93a4c829e43bba1cb161..e3a10a852cade9cb8eca6b1768a73ce4cab8d0b0 100644 (file)
@@ -234,6 +234,16 @@ static int venc_v4l2_to_hfi(int id, int value)
                case 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;
@@ -642,6 +652,7 @@ static int venc_set_properties(struct venus_inst *inst)
        if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) {
                struct hfi_h264_vui_timing_info info;
                struct hfi_h264_entropy_control entropy;
+               struct hfi_h264_db_control deblock;
 
                ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO;
                info.enable = 1;
@@ -661,6 +672,17 @@ static int venc_set_properties(struct venus_inst *inst)
                ret = hfi_session_set_property(inst, ptype, &entropy);
                if (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: