Skip to content

Commit afe2a5d

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 0dd040b commit afe2a5d

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
@@ -4206,6 +4206,47 @@ enum v4l2_mpeg_video_hevc_size_of_length_field -
42064206
- ``padding[6]``
42074207
- Applications and drivers must set this to zero.
42084208

4209+
``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (struct)``
4210+
Specifies the scaling matrix (as extracted from the bitstream) for
4211+
the associated HEVC slice data. The bitstream parameters are
4212+
defined according to :ref:`hevc`, section 7.4.5 "Scaling list
4213+
data semantics". For further documentation, refer to the above
4214+
specification, unless there is an explicit comment stating
4215+
otherwise.
4216+
4217+
.. note::
4218+
4219+
This compound control is not yet part of the public kernel API and
4220+
it is expected to change.
4221+
4222+
.. c:type:: v4l2_ctrl_hevc_scaling_matrix
4223+
4224+
.. cssclass:: longtable
4225+
4226+
.. flat-table:: struct v4l2_ctrl_hevc_scaling_matrix
4227+
:header-rows: 0
4228+
:stub-columns: 0
4229+
:widths: 1 1 2
4230+
4231+
* - __u8
4232+
- ``scaling_list_4x4[6][16]``
4233+
-
4234+
* - __u8
4235+
- ``scaling_list_8x8[6][64]``
4236+
-
4237+
* - __u8
4238+
- ``scaling_list_16x16[6][64]``
4239+
-
4240+
* - __u8
4241+
- ``scaling_list_32x32[2][64]``
4242+
-
4243+
* - __u8
4244+
- ``scaling_list_dc_coef_16x16[6]``
4245+
-
4246+
* - __u8
4247+
- ``scaling_list_dc_coef_32x32[2]``
4248+
-
4249+
42094250
``V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (enum)``
42104251
Specifies the decoding mode to use. Currently exposes slice-based and
42114252
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
@@ -207,6 +207,7 @@ Compressed Formats
207207
* ``V4L2_CID_MPEG_VIDEO_HEVC_SPS``
208208
* ``V4L2_CID_MPEG_VIDEO_HEVC_PPS``
209209
* ``V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS``
210+
* ``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX``
210211
See the :ref:`associated Codec Control IDs <v4l2-mpeg-hevc>`.
211212
Buffers associated with this pixel format must contain the appropriate
212213
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
@@ -990,6 +990,7 @@ const char *v4l2_ctrl_get_name(u32 id)
990990
case V4L2_CID_MPEG_VIDEO_HEVC_SPS: return "HEVC Sequence Parameter Set";
991991
case V4L2_CID_MPEG_VIDEO_HEVC_PPS: return "HEVC Picture Parameter Set";
992992
case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS: return "HEVC Slice Parameters";
993+
case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX: return "HEVC Scaling Matrix";
993994
case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE: return "HEVC Decode Mode";
994995
case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE: return "HEVC Start Code";
995996

@@ -1425,6 +1426,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
14251426
case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
14261427
*type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS;
14271428
break;
1429+
case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX:
1430+
*type = V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX;
1431+
break;
14281432
case V4L2_CID_UNIT_CELL_SIZE:
14291433
*type = V4L2_CTRL_TYPE_AREA;
14301434
*flags |= V4L2_CTRL_FLAG_READ_ONLY;
@@ -1877,6 +1881,9 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
18771881
zero_padding(*p_hevc_slice_params);
18781882
break;
18791883

1884+
case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
1885+
break;
1886+
18801887
case V4L2_CTRL_TYPE_AREA:
18811888
area = p;
18821889
if (!area->width || !area->height)
@@ -2566,6 +2573,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
25662573
case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
25672574
elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
25682575
break;
2576+
case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
2577+
elem_size = sizeof(struct v4l2_ctrl_hevc_scaling_matrix);
2578+
break;
25692579
case V4L2_CTRL_TYPE_AREA:
25702580
elem_size = sizeof(struct v4l2_area);
25712581
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)