Skip to content

Commit b587990

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 ce53df3 commit b587990

4 files changed

Lines changed: 63 additions & 0 deletions

File tree

‎Documentation/media/uapi/v4l/ext-ctrls-codec.rst‎

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

4183+
``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (struct)``
4184+
Specifies the scaling matrix (as extracted from the bitstream) for
4185+
the associated HEVC slice data. The bitstream parameters are
4186+
defined according to :ref:`hevc`, section 7.4.5 "Scaling list
4187+
data semantics". For further documentation, refer to the above
4188+
specification, unless there is an explicit comment stating
4189+
otherwise.
4190+
4191+
.. note::
4192+
4193+
This compound control is not yet part of the public kernel API and
4194+
it is expected to change.
4195+
4196+
.. c:type:: v4l2_ctrl_hevc_scaling_matrix
4197+
4198+
.. cssclass:: longtable
4199+
4200+
.. flat-table:: struct v4l2_ctrl_hevc_scaling_matrix
4201+
:header-rows: 0
4202+
:stub-columns: 0
4203+
:widths: 1 1 2
4204+
4205+
* - __u8
4206+
- ``scaling_list_4x4[6][16]``
4207+
-
4208+
* - __u8
4209+
- ``scaling_list_8x8[6][64]``
4210+
-
4211+
* - __u8
4212+
- ``scaling_list_16x16[6][64]``
4213+
-
4214+
* - __u8
4215+
- ``scaling_list_32x32[2][64]``
4216+
-
4217+
* - __u8
4218+
- ``scaling_list_dc_coef_16x16[6]``
4219+
-
4220+
* - __u8
4221+
- ``scaling_list_dc_coef_32x32[2]``
4222+
-
4223+
41834224
``V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (enum)``
41844225
Specifies the decoding mode to use. Currently exposes slice-based and
41854226
frame-based decoding but new modes might be added later on.

‎Documentation/media/uapi/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
@@ -976,6 +976,7 @@ const char *v4l2_ctrl_get_name(u32 id)
976976
case V4L2_CID_MPEG_VIDEO_HEVC_SPS: return "HEVC Sequence Parameter Set";
977977
case V4L2_CID_MPEG_VIDEO_HEVC_PPS: return "HEVC Picture Parameter Set";
978978
case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS: return "HEVC Slice Parameters";
979+
case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX: return "HEVC Scaling Matrix";
979980
case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE: return "HEVC Decode Mode";
980981
case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE: return "HEVC Start Code";
981982

@@ -1408,6 +1409,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
14081409
case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
14091410
*type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS;
14101411
break;
1412+
case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX:
1413+
*type = V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX;
1414+
break;
14111415
case V4L2_CID_UNIT_CELL_SIZE:
14121416
*type = V4L2_CTRL_TYPE_AREA;
14131417
*flags |= V4L2_CTRL_FLAG_READ_ONLY;
@@ -1858,6 +1862,9 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
18581862
zero_padding(*p_hevc_slice_params);
18591863
break;
18601864

1865+
case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
1866+
break;
1867+
18611868
case V4L2_CTRL_TYPE_AREA:
18621869
area = p;
18631870
if (!area->width || !area->height)
@@ -2547,6 +2554,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
25472554
case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
25482555
elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
25492556
break;
2557+
case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
2558+
elem_size = sizeof(struct v4l2_ctrl_hevc_scaling_matrix);
2559+
break;
25502560
case V4L2_CTRL_TYPE_AREA:
25512561
elem_size = sizeof(struct v4l2_area);
25522562
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)