Skip to content

Commit b08280e

Browse files
jernejskpopcornmix
authored andcommitted
media: uapi: hevc: Add scaling matrix control
Taken from https://patchwork.linuxtv.org/patch/60728/ Changes (mainly documentation) have been requested. HEVC has a scaling matrix concept. Add support for it. Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
1 parent 539c6f3 commit b08280e

4 files changed

Lines changed: 63 additions & 0 deletions

File tree

‎Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4316,6 +4316,47 @@ enum v4l2_mpeg_video_hevc_size_of_length_field -
43164316
- ``padding[6]``
43174317
- Applications and drivers must set this to zero.
43184318

4319+
``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (struct)``
4320+
Specifies the scaling matrix (as extracted from the bitstream) for
4321+
the associated HEVC slice data. The bitstream parameters are
4322+
defined according to :ref:`hevc`, section 7.4.5 "Scaling list
4323+
data semantics". For further documentation, refer to the above
4324+
specification, unless there is an explicit comment stating
4325+
otherwise.
4326+
4327+
.. note::
4328+
4329+
This compound control is not yet part of the public kernel API and
4330+
it is expected to change.
4331+
4332+
.. c:type:: v4l2_ctrl_hevc_scaling_matrix
4333+
4334+
.. cssclass:: longtable
4335+
4336+
.. flat-table:: struct v4l2_ctrl_hevc_scaling_matrix
4337+
:header-rows: 0
4338+
:stub-columns: 0
4339+
:widths: 1 1 2
4340+
4341+
* - __u8
4342+
- ``scaling_list_4x4[6][16]``
4343+
-
4344+
* - __u8
4345+
- ``scaling_list_8x8[6][64]``
4346+
-
4347+
* - __u8
4348+
- ``scaling_list_16x16[6][64]``
4349+
-
4350+
* - __u8
4351+
- ``scaling_list_32x32[2][64]``
4352+
-
4353+
* - __u8
4354+
- ``scaling_list_dc_coef_16x16[6]``
4355+
-
4356+
* - __u8
4357+
- ``scaling_list_dc_coef_32x32[2]``
4358+
-
4359+
43194360
``V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (enum)``
43204361
Specifies the decoding mode to use. Currently exposes slice-based and
43214362
frame-based decoding but new modes might be added later on.

‎Documentation/userspace-api/media/v4l/pixfmt-compressed.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ Compressed Formats
200200
* ``V4L2_CID_MPEG_VIDEO_HEVC_SPS``
201201
* ``V4L2_CID_MPEG_VIDEO_HEVC_PPS``
202202
* ``V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS``
203+
* ``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX``
203204
See the :ref:`associated Codec Control IDs <v4l2-mpeg-hevc>`.
204205
Buffers associated with this pixel format must contain the appropriate
205206
number of macroblocks to decode a full corresponding frame.

‎drivers/media/v4l2-core/v4l2-ctrls.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,7 @@ const char *v4l2_ctrl_get_name(u32 id)
10221022
case V4L2_CID_MPEG_VIDEO_HEVC_SPS: return "HEVC Sequence Parameter Set";
10231023
case V4L2_CID_MPEG_VIDEO_HEVC_PPS: return "HEVC Picture Parameter Set";
10241024
case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS: return "HEVC Slice Parameters";
1025+
case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX: return "HEVC Scaling Matrix";
10251026
case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE: return "HEVC Decode Mode";
10261027
case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE: return "HEVC Start Code";
10271028

@@ -1462,6 +1463,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
14621463
case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
14631464
*type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS;
14641465
break;
1466+
case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX:
1467+
*type = V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX;
1468+
break;
14651469
case V4L2_CID_UNIT_CELL_SIZE:
14661470
*type = V4L2_CTRL_TYPE_AREA;
14671471
*flags |= V4L2_CTRL_FLAG_READ_ONLY;
@@ -1935,6 +1939,9 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
19351939
zero_padding(*p_hevc_slice_params);
19361940
break;
19371941

1942+
case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
1943+
break;
1944+
19381945
case V4L2_CTRL_TYPE_AREA:
19391946
area = p;
19401947
if (!area->width || !area->height)
@@ -2627,6 +2634,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
26272634
case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
26282635
elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
26292636
break;
2637+
case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
2638+
elem_size = sizeof(struct v4l2_ctrl_hevc_scaling_matrix);
2639+
break;
26302640
case V4L2_CTRL_TYPE_AREA:
26312641
elem_size = sizeof(struct v4l2_area);
26322642
break;

‎include/media/hevc-ctrls.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
#define V4L2_CID_MPEG_VIDEO_HEVC_SPS (V4L2_CID_MPEG_BASE + 1008)
2020
#define V4L2_CID_MPEG_VIDEO_HEVC_PPS (V4L2_CID_MPEG_BASE + 1009)
2121
#define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS (V4L2_CID_MPEG_BASE + 1010)
22+
#define V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (V4L2_CID_MPEG_BASE + 1011)
2223
#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (V4L2_CID_MPEG_BASE + 1015)
2324
#define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE (V4L2_CID_MPEG_BASE + 1016)
2425

2526
/* enum v4l2_ctrl_type type values */
2627
#define V4L2_CTRL_TYPE_HEVC_SPS 0x0120
2728
#define V4L2_CTRL_TYPE_HEVC_PPS 0x0121
2829
#define V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS 0x0122
30+
#define V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX 0x0123
2931

3032
enum v4l2_mpeg_video_hevc_decode_mode {
3133
V4L2_MPEG_VIDEO_HEVC_DECODE_MODE_SLICE_BASED,
@@ -209,4 +211,13 @@ struct v4l2_ctrl_hevc_slice_params {
209211
__u64 flags;
210212
};
211213

214+
struct v4l2_ctrl_hevc_scaling_matrix {
215+
__u8 scaling_list_4x4[6][16];
216+
__u8 scaling_list_8x8[6][64];
217+
__u8 scaling_list_16x16[6][64];
218+
__u8 scaling_list_32x32[2][64];
219+
__u8 scaling_list_dc_coef_16x16[6];
220+
__u8 scaling_list_dc_coef_32x32[2];
221+
};
222+
212223
#endif

0 commit comments

Comments
 (0)