]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
media: coda: fix H.264 deblocking filter controls
authorPhilipp Zabel <p.zabel@pengutronix.de>
Wed, 28 Nov 2018 13:01:22 +0000 (08:01 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 7 Dec 2018 13:19:01 +0000 (08:19 -0500)
Add support for the third loop filter mode
V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY,
and fix V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA and
V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA controls.

The filter offset controls are signed values in the -6 to 6 range and
are stored into the slice header fields slice_alpha_c0_offset_div2 and
slice_beta_offset_div2. The actual filter offsets FilterOffsetA/B are
double their value, in range of -12 to 12.

Rename variables to more closely match the nomenclature in the H.264
specification.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/platform/coda/coda-bit.c
drivers/media/platform/coda/coda-common.c
drivers/media/platform/coda/coda.h
drivers/media/platform/coda/coda_regs.h

index f2c0aa261c9babb2a7e05b8f9fa1e8a3b9e15764..8e0194993a52e826d82f325b22adc99a2f3313cb 100644 (file)
@@ -1002,16 +1002,15 @@ static int coda_start_encoding(struct coda_ctx *ctx)
                else
                        coda_write(dev, CODA_STD_H264,
                                   CODA_CMD_ENC_SEQ_COD_STD);
-               if (ctx->params.h264_deblk_enabled) {
-                       value = ((ctx->params.h264_deblk_alpha &
-                                 CODA_264PARAM_DEBLKFILTEROFFSETALPHA_MASK) <<
-                                CODA_264PARAM_DEBLKFILTEROFFSETALPHA_OFFSET) |
-                               ((ctx->params.h264_deblk_beta &
-                                 CODA_264PARAM_DEBLKFILTEROFFSETBETA_MASK) <<
-                                CODA_264PARAM_DEBLKFILTEROFFSETBETA_OFFSET);
-               } else {
-                       value = 1 << CODA_264PARAM_DISABLEDEBLK_OFFSET;
-               }
+               value = ((ctx->params.h264_disable_deblocking_filter_idc &
+                         CODA_264PARAM_DISABLEDEBLK_MASK) <<
+                        CODA_264PARAM_DISABLEDEBLK_OFFSET) |
+                       ((ctx->params.h264_slice_alpha_c0_offset_div2 &
+                         CODA_264PARAM_DEBLKFILTEROFFSETALPHA_MASK) <<
+                        CODA_264PARAM_DEBLKFILTEROFFSETALPHA_OFFSET) |
+                       ((ctx->params.h264_slice_beta_offset_div2 &
+                         CODA_264PARAM_DEBLKFILTEROFFSETBETA_MASK) <<
+                        CODA_264PARAM_DEBLKFILTEROFFSETBETA_OFFSET);
                coda_write(dev, value, CODA_CMD_ENC_SEQ_264_PARA);
                break;
        case V4L2_PIX_FMT_JPEG:
index a62c47843d2f9ea210366792bd59349569b54883..7518f01c48f762ad2d9b4f7cbadd3c2ac4b11cbd 100644 (file)
@@ -1831,14 +1831,13 @@ static int coda_s_ctrl(struct v4l2_ctrl *ctrl)
                ctx->params.h264_max_qp = ctrl->val;
                break;
        case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA:
-               ctx->params.h264_deblk_alpha = ctrl->val;
+               ctx->params.h264_slice_alpha_c0_offset_div2 = ctrl->val;
                break;
        case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA:
-               ctx->params.h264_deblk_beta = ctrl->val;
+               ctx->params.h264_slice_beta_offset_div2 = ctrl->val;
                break;
        case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE:
-               ctx->params.h264_deblk_enabled = (ctrl->val ==
-                               V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED);
+               ctx->params.h264_disable_deblocking_filter_idc = ctrl->val;
                break;
        case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
                /* TODO: switch between baseline and constrained baseline */
@@ -1919,13 +1918,13 @@ static void coda_encode_ctrls(struct coda_ctx *ctx)
        v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
                V4L2_CID_MPEG_VIDEO_H264_MAX_QP, 0, 51, 1, 51);
        v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
-               V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA, 0, 15, 1, 0);
+               V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA, -6, 6, 1, 0);
        v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
-               V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA, 0, 15, 1, 0);
+               V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA, -6, 6, 1, 0);
        v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops,
                V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE,
-               V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED, 0x0,
-               V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED);
+               V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY,
+               0x0, V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED);
        v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops,
                V4L2_CID_MPEG_VIDEO_H264_PROFILE,
                V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, 0x0,
index 22f6efaf9510c711081ced0953732f11c20ab98a..31cea72f5b2ac7b61b21206ccc3a5e06ba114254 100644 (file)
@@ -115,9 +115,9 @@ struct coda_params {
        u8                      h264_inter_qp;
        u8                      h264_min_qp;
        u8                      h264_max_qp;
-       u8                      h264_deblk_enabled;
-       u8                      h264_deblk_alpha;
-       u8                      h264_deblk_beta;
+       u8                      h264_disable_deblocking_filter_idc;
+       s8                      h264_slice_alpha_c0_offset_div2;
+       s8                      h264_slice_beta_offset_div2;
        u8                      h264_profile_idc;
        u8                      h264_level_idc;
        u8                      mpeg4_intra_qp;
index 5e7b00a97671ef396426d0e2b8cf9c93c00afdb6..e675e38f3475e79737f3ac22e2e12911cede7003 100644 (file)
 #define                CODA_264PARAM_DEBLKFILTEROFFSETALPHA_OFFSET     8
 #define                CODA_264PARAM_DEBLKFILTEROFFSETALPHA_MASK       0x0f
 #define                CODA_264PARAM_DISABLEDEBLK_OFFSET               6
-#define                CODA_264PARAM_DISABLEDEBLK_MASK         0x01
+#define                CODA_264PARAM_DISABLEDEBLK_MASK         0x03
 #define                CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_OFFSET   5
 #define                CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_MASK     0x01
 #define                CODA_264PARAM_CHROMAQPOFFSET_OFFSET             0