media: uapi: mpeg2: Cleanup flags
PATCH 1/3 media: uapi: mpeg2: Cleanup flags
Our current MPEG-2 uAPI uses 1-byte fields for MPEG-2 boolean syntax elements. Clean these by adding a 'flags' field and flag macro for each boolean syntax element.
Move quantization "load" flags to struct v4l2_mpeg2_picture, so the applications can skip passing the quantization matrices (by not setting the MPEG2_QUANTIZATION control in decode request).
A follow-up change will refactor this uAPI so we don't need to add padding fields just yet.
--- .../media/v4l/ext-ctrls-codec.rst | 108 +++++++++++------- drivers/media/v4l2-core/v4l2-ctrls.c | 14 +-- .../media/hantro/hantro_g1_mpeg2_dec.c | 76 ++++++------ .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 76 ++++++------ .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 42 +++---- include/media/mpeg2-ctrls.h | 47 +++++--- 6 files changed, 196 insertions(+), 167 deletions(-)
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +68 -40
@@ -2275,13 +2275,28 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - - ``profile_and_level_indication`` - The current profile and level indication as extracted from the bitstream. - * - __u8 - - ``progressive_sequence`` - - Indication that all the frames for the sequence are progressive instead - of interlaced. * - __u8 - ``chroma_format`` - The chrominance sub-sampling format (1: 4:2:0, 2: 4:2:2, 3: 4:4:4). + * - __u32 + - ``flags`` + - See :ref:`MPEG-2 Sequence Flags <mpeg2_sequence_flags>`. + +.. _mpeg2_sequence_flags: + +``MPEG-2 Sequence Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE`` + - 0x00000001 + - Indication that all the frames for the sequence are progressive instead + of interlaced. .. c:type:: v4l2_mpeg2_picture
@@ -2310,30 +2325,60 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - - ``picture_structure`` - Picture structure (1: interlaced top field, 2: interlaced bottom field, 3: progressive frame). - * - __u8 - - ``top_field_first`` - - If set to 1 and interlaced stream, top field is output first. - * - __u8 - - ``frame_pred_frame_dct`` - - If set to 1, only frame-DCT and frame prediction are used. - * - __u8 - - ``concealment_motion_vectors`` - - If set to 1, motion vectors are coded for intra macroblocks. - * - __u8 - - ``q_scale_type`` + * - __u32 + - ``flags`` + - See :ref:`MPEG-2 Picture Flags <mpeg2_picture_flags>`. + + +.. _mpeg2_picture_flags: + +``MPEG-2 Picture Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_MPEG2_PIC_FLAG_TOP_FIELD_FIRST`` + - 0x00000001 + - If set and it's an interlaced stream, top field is output first. + * - ``V4L2_MPEG2_PIC_FLAG_FRAME_PRED_DCT`` + - 0x00000002 + - If set only frame-DCT and frame prediction are used. + * - ``V4L2_MPEG2_PIC_FLAG_CONCEALMENT_MV`` + - 0x00000004 + - If set motion vectors are coded for intra macroblocks. + * - ``V4L2_MPEG2_PIC_FLAG_Q_SCALE_TYPE`` + - 0x00000008 - This flag affects the inverse quantization process. - * - __u8 - - ``intra_vlc_format`` + * - ``V4L2_MPEG2_PIC_FLAG_INTRA_VLC`` + - 0x00000010 - This flag affects the decoding of transform coefficient data. - * - __u8 - - ``alternate_scan`` + * - ``V4L2_MPEG2_PIC_FLAG_ALT_SCAN`` + - 0x00000020 - This flag affects the decoding of transform coefficient data. - * - __u8 - - ``repeat_first_field`` + * - ``V4L2_MPEG2_PIC_FLAG_REPEAT_FIRST`` + - 0x00000040 - This flag affects the decoding process of progressive frames. - * - __u16 - - ``progressive_frame`` + * - ``V4L2_MPEG2_PIC_FLAG_PROGRESSIVE`` + - 0x00000080 - Indicates whether the current frame is progressive. + * - ``V4L2_MPEG2_PIC_FLAG_LOAD_INTRA`` + * - 0x00000100 + - Indicate whether to load the user-specified intra quantiser matrix. + * - ``V4L2_MPEG2_PIC_FLAG_LOAD_NON_INTRA`` + * - 0x00000200 + - Indicate whether to load the user-specified non-intra quantiser matrix. + * - ``V4L2_MPEG2_PIC_FLAG_LOAD_CHROMA_INTRA`` + * - 0x00000400 + - Indicate whether to load the user-specified chroma intra quantiser + matrix, only relevant for 4:2:2 and 4:4:4 YUV formats. + * - ``V4L2_MPEG2_PIC_FLAG_LOAD_CHROMA_NON_INTRA`` + * - 0x0000800 + - Indicate whether to load the user-specified chroma non-intra quantiser + matrix, only relevant for 4:2:2 and 4:4:4 YUV formats. ``V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (struct)`` Specifies quantization matrices (as extracted from the bitstream) for the
@@ -2359,23 +2404,6 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - :stub-columns: 0 :widths: 1 1 2 - * - __u8 - - ``load_intra_quantiser_matrix`` - - One bit to indicate whether to load the ``intra_quantiser_matrix`` data. - * - __u8 - - ``load_non_intra_quantiser_matrix`` - - One bit to indicate whether to load the ``non_intra_quantiser_matrix`` - data. - * - __u8 - - ``load_chroma_intra_quantiser_matrix`` - - One bit to indicate whether to load the - ``chroma_intra_quantiser_matrix`` data, only relevant for non-4:2:0 YUV - formats. - * - __u8 - - ``load_chroma_non_intra_quantiser_matrix`` - - One bit to indicate whether to load the - ``chroma_non_intra_quantiser_matrix`` data, only relevant for non-4:2:0 - YUV formats. * - __u8 - ``intra_quantiser_matrix[64]`` - The quantization matrix coefficients for intra-coded frames, in zigzag
drivers/media/v4l2-core/v4l2-ctrls.c +7 -7
@@ -1641,7 +1641,7 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx,/* interlaced top field */ p_mpeg2_slice_params->picture.picture_structure =1 ; p_mpeg2_slice_params->picture.picture_coding_type = -V4L2_MPEG2_PICTURE_CODING_TYPE_I ; +V4L2_MPEG2_PIC_CODING_TYPE_I ;break ; } }
@@ -1803,18 +1803,18 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, }switch (p_mpeg2_slice_params->picture.picture_structure) { -case 1 :/* interlaced top field */ -case 2 :/* interlaced bottom field */ -case 3 :/* progressive */ +case V4L2_MPEG2_PIC_TOP_FIELD : +case V4L2_MPEG2_PIC_BOTTOM_FIELD : +case V4L2_MPEG2_PIC_FRAME :break ;default :return -EINVAL ; }switch (p_mpeg2_slice_params->picture.picture_coding_type) { -case V4L2_MPEG2_PICTURE_CODING_TYPE_I : -case V4L2_MPEG2_PICTURE_CODING_TYPE_P : -case V4L2_MPEG2_PICTURE_CODING_TYPE_B : +case V4L2_MPEG2_PIC_CODING_TYPE_I : +case V4L2_MPEG2_PIC_CODING_TYPE_P : +case V4L2_MPEG2_PIC_CODING_TYPE_B :break ;default :return -EINVAL ;
drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c +36 -40
151 lines not on this page · raw message
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c +36 -40
147 lines not on this page · raw message
drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +21 -21
78 lines not on this page · raw message
include/media/mpeg2-ctrls.h +28 -19
75 lines not on this page · raw message
Signature · 1 line
2.27.0
kernel test robot
build botI love your patch! Perhaps something to improve:
Hi Ezequiel,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on linus/master v5.9-rc7 next-20200930] [cannot apply to sunxi/sunxi/for-next linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Ezequiel-Garcia/MPEG-2-stateless-API-cleanup/20200930-075132 base: git://linuxtv.org/media_tree.git master config: arm64-randconfig-r005-20200930 (attached as .config) compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project bcd05599d0e53977a963799d6ee4f6e0bc21331b)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/66b41927094ce2dca6a1b64570eb067fa5a24f74
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Ezequiel-Garcia/MPEG-2-stateless-API-cleanup/20200930-075132 git checkout 66b41927094ce2dca6a1b64570eb067fa5a24f74
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c:208:33: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses]
VDPU_REG_PIC_INTERLACE_E(!seq->flags & V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE) |
^ ~
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c:52:39: note: expanded from macro 'VDPU_REG_PIC_INTERLACE_E'
#define VDPU_REG_PIC_INTERLACE_E(v) ((v) ? BIT(17) : 0)
^ drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c:208:33: note: add parentheses after the '!' to evaluate the bitwise operator first drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c:208:33: note: add parentheses around left hand side expression to silence this warning 1 warning generated.
vim +208 drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c
155
156 void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx)
157 {
158 struct hantro_dev *vpu = ctx->dev;
159 struct vb2_v4l2_buffer *src_buf, *dst_buf;
160 const struct v4l2_ctrl_mpeg2_slice_params *slice_params;
161 const struct v4l2_mpeg2_sequence *seq;
162 const struct v4l2_mpeg2_picture *pic;
163 u32 reg;
164
165 src_buf = hantro_get_src_buf(ctx);
166 dst_buf = hantro_get_dst_buf(ctx);
167
168 hantro_start_prepare_run(ctx);
169
170 slice_params = hantro_get_ctrl(ctx,
171 V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS);
172 seq = &slice_params->sequence;
173 pic = &slice_params->picture;
174
175 reg = VDPU_REG_DEC_ADV_PRE_DIS(0) |
176 VDPU_REG_DEC_SCMD_DIS(0) | 177 VDPU_REG_FILTERING_DIS(1) | 178 VDPU_REG_DEC_LATENCY(0); 179 vdpu_write_relaxed(vpu, reg, VDPU_SWREG(50)); 180 181 reg = VDPU_REG_INIT_QP(1) | 182 VDPU_REG_STREAM_LEN(slice_params->bit_size >> 3); 183 vdpu_write_relaxed(vpu, reg, VDPU_SWREG(51)); 184 185 reg = VDPU_REG_APF_THRESHOLD(8) | 186 VDPU_REG_STARTMB_X(0) | 187 VDPU_REG_STARTMB_Y(0); 188 vdpu_write_relaxed(vpu, reg, VDPU_SWREG(52)); 189 190 reg = VDPU_REG_DEC_MODE(5); 191 vdpu_write_relaxed(vpu, reg, VDPU_SWREG(53)); 192 193 reg = VDPU_REG_DEC_STRENDIAN_E(1) | 194 VDPU_REG_DEC_STRSWAP32_E(1) | 195 VDPU_REG_DEC_OUTSWAP32_E(1) | 196 VDPU_REG_DEC_INSWAP32_E(1) | 197 VDPU_REG_DEC_OUT_ENDIAN(1) | 198 VDPU_REG_DEC_IN_ENDIAN(1); 199 vdpu_write_relaxed(vpu, reg, VDPU_SWREG(54)); 200 201 reg = VDPU_REG_DEC_DATA_DISC_E(0) | 202 VDPU_REG_DEC_MAX_BURST(16) | 203 VDPU_REG_DEC_AXI_WR_ID(0) | 204 VDPU_REG_DEC_AXI_RD_ID(0); 205 vdpu_write_relaxed(vpu, reg, VDPU_SWREG(56)); 206 207 reg = VDPU_REG_RLC_MODE_E(0) | > 208 VDPU_REG_PIC_INTERLACE_E(!seq->flags & V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE) |
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org