Skip to content

Commit 8cef03d

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 a92ae59 commit 8cef03d

4 files changed

Lines changed: 65 additions & 2 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
@@ -3574,6 +3574,47 @@ enum v4l2_mpeg_video_hevc_size_of_length_field -
35743574
- ``padding[6]``
35753575
- Applications and drivers must set this to zero.
35763576

3577+
``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (struct)``
3578+
Specifies the scaling matrix (as extracted from the bitstream) for
3579+
the associated HEVC slice data. The bitstream parameters are
3580+
defined according to :ref:`hevc`, section 7.4.5 "Scaling list
3581+
data semantics". For further documentation, refer to the above
3582+
specification, unless there is an explicit comment stating
3583+
otherwise.
3584+
3585+
.. note::
3586+
3587+
This compound control is not yet part of the public kernel API and
3588+
it is expected to change.
3589+
3590+
.. c:type:: v4l2_ctrl_hevc_scaling_matrix
3591+
3592+
.. cssclass:: longtable
3593+
3594+
.. flat-table:: struct v4l2_ctrl_hevc_scaling_matrix
3595+
:header-rows: 0
3596+
:stub-columns: 0
3597+
:widths: 1 1 2
3598+
3599+
* - __u8
3600+
- ``scaling_list_4x4[6][16]``
3601+
-
3602+
* - __u8
3603+
- ``scaling_list_8x8[6][64]``
3604+
-
3605+
* - __u8
3606+
- ``scaling_list_16x16[6][64]``
3607+
-
3608+
* - __u8
3609+
- ``scaling_list_32x32[2][64]``
3610+
-
3611+
* - __u8
3612+
- ``scaling_list_dc_coef_16x16[6]``
3613+
-
3614+
* - __u8
3615+
- ``scaling_list_dc_coef_32x32[2]``
3616+
-
3617+
35773618
``V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (enum)``
35783619
Specifies the decoding mode to use. Currently exposes slice-based and
35793620
frame-based decoding but new modes might be added later on.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ Compressed Formats
193193
Metadata associated with the frame to decode is required to be passed
194194
through the following controls:
195195
``V4L2_CID_MPEG_VIDEO_HEVC_SPS``,
196-
``V4L2_CID_MPEG_VIDEO_HEVC_PPS``, and
197-
``V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS``.
196+
``V4L2_CID_MPEG_VIDEO_HEVC_PPS``,
197+
``V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS``, and
198+
``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX``.
198199
See the :ref:`associated Codec Control IDs <v4l2-mpeg-hevc>`.
199200
Buffers associated with this pixel format must contain the appropriate
200201
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
@@ -1029,6 +1029,7 @@ const char *v4l2_ctrl_get_name(u32 id)
10291029
case V4L2_CID_MPEG_VIDEO_HEVC_SPS: return "HEVC Sequence Parameter Set";
10301030
case V4L2_CID_MPEG_VIDEO_HEVC_PPS: return "HEVC Picture Parameter Set";
10311031
case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS: return "HEVC Slice Parameters";
1032+
case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX: return "HEVC Scaling Matrix";
10321033
case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE: return "HEVC Decode Mode";
10331034
case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE: return "HEVC Start Code";
10341035

@@ -1483,6 +1484,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
14831484
case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
14841485
*type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS;
14851486
break;
1487+
case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX:
1488+
*type = V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX;
1489+
break;
14861490
case V4L2_CID_UNIT_CELL_SIZE:
14871491
*type = V4L2_CTRL_TYPE_AREA;
14881492
*flags |= V4L2_CTRL_FLAG_READ_ONLY;
@@ -2131,6 +2135,9 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
21312135
zero_padding(*p_hevc_slice_params);
21322136
break;
21332137

2138+
case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
2139+
break;
2140+
21342141
case V4L2_CTRL_TYPE_AREA:
21352142
area = p;
21362143
if (!area->width || !area->height)
@@ -2841,6 +2848,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
28412848
case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
28422849
elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
28432850
break;
2851+
case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
2852+
elem_size = sizeof(struct v4l2_ctrl_hevc_scaling_matrix);
2853+
break;
28442854
case V4L2_CTRL_TYPE_AREA:
28452855
elem_size = sizeof(struct v4l2_area);
28462856
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_CODEC_BASE + 1008)
2020
#define V4L2_CID_MPEG_VIDEO_HEVC_PPS (V4L2_CID_CODEC_BASE + 1009)
2121
#define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS (V4L2_CID_CODEC_BASE + 1010)
22+
#define V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (V4L2_CID_CODEC_BASE + 1011)
2223
#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (V4L2_CID_CODEC_BASE + 1015)
2324
#define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE (V4L2_CID_CODEC_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,
@@ -210,4 +212,13 @@ struct v4l2_ctrl_hevc_slice_params {
210212
__u64 flags;
211213
};
212214

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

0 commit comments

Comments
 (0)