diff options
-rw-r--r-- | Documentation/media/uapi/v4l/ext-ctrls-codec.rst | 57 | ||||
-rw-r--r-- | Documentation/media/uapi/v4l/pixfmt-compressed.rst | 6 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ctrls.c | 9 | ||||
-rw-r--r-- | include/media/h264-ctrls.h | 10 |
4 files changed, 79 insertions, 3 deletions
diff --git a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst index c5f39dd50043..1da17a2c94d7 100644 --- a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst +++ b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst | |||
@@ -1748,6 +1748,14 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - | |||
1748 | - ``size`` | 1748 | - ``size`` |
1749 | - | 1749 | - |
1750 | * - __u32 | 1750 | * - __u32 |
1751 | - ``start_byte_offset`` | ||
1752 | Offset (in bytes) from the beginning of the OUTPUT buffer to the start | ||
1753 | of the slice. If the slice starts with a start code, then this is the | ||
1754 | offset to such start code. When operating in slice-based decoding mode | ||
1755 | (see :c:type:`v4l2_mpeg_video_h264_decode_mode`), this field should | ||
1756 | be set to 0. When operating in frame-based decoding mode, this field | ||
1757 | should be 0 for the first slice. | ||
1758 | * - __u32 | ||
1751 | - ``header_bit_size`` | 1759 | - ``header_bit_size`` |
1752 | - | 1760 | - |
1753 | * - __u16 | 1761 | * - __u16 |
@@ -1930,7 +1938,10 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - | |||
1930 | - | 1938 | - |
1931 | * - __u16 | 1939 | * - __u16 |
1932 | - ``num_slices`` | 1940 | - ``num_slices`` |
1933 | - Number of slices needed to decode the current frame | 1941 | - Number of slices needed to decode the current frame/field. When |
1942 | operating in slice-based decoding mode (see | ||
1943 | :c:type:`v4l2_mpeg_video_h264_decode_mode`), this field | ||
1944 | should always be set to one. | ||
1934 | * - __u16 | 1945 | * - __u16 |
1935 | - ``nal_ref_idc`` | 1946 | - ``nal_ref_idc`` |
1936 | - NAL reference ID value coming from the NAL Unit header | 1947 | - NAL reference ID value coming from the NAL Unit header |
@@ -2021,6 +2032,50 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - | |||
2021 | - 0x00000004 | 2032 | - 0x00000004 |
2022 | - The DPB entry is a long term reference frame | 2033 | - The DPB entry is a long term reference frame |
2023 | 2034 | ||
2035 | ``V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE (enum)`` | ||
2036 | Specifies the decoding mode to use. Currently exposes slice-based and | ||
2037 | frame-based decoding but new modes might be added later on. | ||
2038 | This control is used as a modifier for V4L2_PIX_FMT_H264_SLICE | ||
2039 | pixel format. Applications that support V4L2_PIX_FMT_H264_SLICE | ||
2040 | are required to set this control in order to specify the decoding mode | ||
2041 | that is expected for the buffer. | ||
2042 | Drivers may expose a single or multiple decoding modes, depending | ||
2043 | on what they can support. | ||
2044 | |||
2045 | .. note:: | ||
2046 | |||
2047 | This menu control is not yet part of the public kernel API and | ||
2048 | it is expected to change. | ||
2049 | |||
2050 | .. c:type:: v4l2_mpeg_video_h264_decode_mode | ||
2051 | |||
2052 | .. cssclass:: longtable | ||
2053 | |||
2054 | .. flat-table:: | ||
2055 | :header-rows: 0 | ||
2056 | :stub-columns: 0 | ||
2057 | :widths: 1 1 2 | ||
2058 | |||
2059 | * - ``V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED`` | ||
2060 | - 0 | ||
2061 | - Decoding is done at the slice granularity. | ||
2062 | In this mode, ``num_slices`` field in struct | ||
2063 | :c:type:`v4l2_ctrl_h264_decode_params` should be set to 1, | ||
2064 | and ``start_byte_offset`` in struct | ||
2065 | :c:type:`v4l2_ctrl_h264_slice_params` should be set to 0. | ||
2066 | The OUTPUT buffer must contain a single slice. | ||
2067 | * - ``V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED`` | ||
2068 | - 1 | ||
2069 | - Decoding is done at the frame granularity. | ||
2070 | In this mode, ``num_slices`` field in struct | ||
2071 | :c:type:`v4l2_ctrl_h264_decode_params` should be set to the number | ||
2072 | of slices in the frame, and ``start_byte_offset`` in struct | ||
2073 | :c:type:`v4l2_ctrl_h264_slice_params` should be set accordingly | ||
2074 | for each slice. For the first slice, ``start_byte_offset`` should | ||
2075 | be zero. | ||
2076 | The OUTPUT buffer must contain all slices needed to decode the | ||
2077 | frame. The OUTPUT buffer must also contain both fields. | ||
2078 | |||
2024 | .. _v4l2-mpeg-mpeg2: | 2079 | .. _v4l2-mpeg-mpeg2: |
2025 | 2080 | ||
2026 | ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (struct)`` | 2081 | ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (struct)`` |
diff --git a/Documentation/media/uapi/v4l/pixfmt-compressed.rst b/Documentation/media/uapi/v4l/pixfmt-compressed.rst index 9b65473a2288..d666eb51741a 100644 --- a/Documentation/media/uapi/v4l/pixfmt-compressed.rst +++ b/Documentation/media/uapi/v4l/pixfmt-compressed.rst | |||
@@ -60,8 +60,10 @@ Compressed Formats | |||
60 | extracted from the H264 bitstream. This format is adapted for | 60 | extracted from the H264 bitstream. This format is adapted for |
61 | stateless video decoders that implement an H264 pipeline | 61 | stateless video decoders that implement an H264 pipeline |
62 | (using the :ref:`mem2mem` and :ref:`media-request-api`). | 62 | (using the :ref:`mem2mem` and :ref:`media-request-api`). |
63 | Metadata associated with the frame to decode are required to | 63 | This pixelformat has a modifier that must be set at least once |
64 | be passed through the ``V4L2_CID_MPEG_VIDEO_H264_SPS``, | 64 | through the ``V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE`` control. |
65 | In addition, metadata associated with the frame to decode are | ||
66 | required to be passed through the ``V4L2_CID_MPEG_VIDEO_H264_SPS``, | ||
65 | ``V4L2_CID_MPEG_VIDEO_H264_PPS``, | 67 | ``V4L2_CID_MPEG_VIDEO_H264_PPS``, |
66 | ``V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX``, | 68 | ``V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX``, |
67 | ``V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS`` and | 69 | ``V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS`` and |
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index cd1ae016706f..2c67f9fc4d5b 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c | |||
@@ -402,6 +402,11 @@ const char * const *v4l2_ctrl_get_menu(u32 id) | |||
402 | "Explicit", | 402 | "Explicit", |
403 | NULL, | 403 | NULL, |
404 | }; | 404 | }; |
405 | static const char * const h264_decode_mode[] = { | ||
406 | "Slice-Based", | ||
407 | "Frame-Based", | ||
408 | NULL, | ||
409 | }; | ||
405 | static const char * const mpeg_mpeg2_level[] = { | 410 | static const char * const mpeg_mpeg2_level[] = { |
406 | "Low", | 411 | "Low", |
407 | "Main", | 412 | "Main", |
@@ -633,6 +638,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id) | |||
633 | return h264_fp_arrangement_type; | 638 | return h264_fp_arrangement_type; |
634 | case V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE: | 639 | case V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE: |
635 | return h264_fmo_map_type; | 640 | return h264_fmo_map_type; |
641 | case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE: | ||
642 | return h264_decode_mode; | ||
636 | case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL: | 643 | case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL: |
637 | return mpeg_mpeg2_level; | 644 | return mpeg_mpeg2_level; |
638 | case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE: | 645 | case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE: |
@@ -852,6 +859,7 @@ const char *v4l2_ctrl_get_name(u32 id) | |||
852 | case V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX: return "H264 Scaling Matrix"; | 859 | case V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX: return "H264 Scaling Matrix"; |
853 | case V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS: return "H264 Slice Parameters"; | 860 | case V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS: return "H264 Slice Parameters"; |
854 | case V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS: return "H264 Decode Parameters"; | 861 | case V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS: return "H264 Decode Parameters"; |
862 | case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE: return "H264 Decode Mode"; | ||
855 | case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL: return "MPEG2 Level"; | 863 | case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL: return "MPEG2 Level"; |
856 | case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE: return "MPEG2 Profile"; | 864 | case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE: return "MPEG2 Profile"; |
857 | case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: return "MPEG4 I-Frame QP Value"; | 865 | case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: return "MPEG4 I-Frame QP Value"; |
@@ -1220,6 +1228,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, | |||
1220 | case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC: | 1228 | case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC: |
1221 | case V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE: | 1229 | case V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE: |
1222 | case V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE: | 1230 | case V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE: |
1231 | case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE: | ||
1223 | case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL: | 1232 | case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL: |
1224 | case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE: | 1233 | case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE: |
1225 | case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: | 1234 | case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: |
diff --git a/include/media/h264-ctrls.h b/include/media/h264-ctrls.h index 6160a69c0143..928c48c57282 100644 --- a/include/media/h264-ctrls.h +++ b/include/media/h264-ctrls.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #define V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX (V4L2_CID_MPEG_BASE+1002) | 26 | #define V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX (V4L2_CID_MPEG_BASE+1002) |
27 | #define V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS (V4L2_CID_MPEG_BASE+1003) | 27 | #define V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS (V4L2_CID_MPEG_BASE+1003) |
28 | #define V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS (V4L2_CID_MPEG_BASE+1004) | 28 | #define V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS (V4L2_CID_MPEG_BASE+1004) |
29 | #define V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE (V4L2_CID_MPEG_BASE+1005) | ||
29 | 30 | ||
30 | /* enum v4l2_ctrl_type type values */ | 31 | /* enum v4l2_ctrl_type type values */ |
31 | #define V4L2_CTRL_TYPE_H264_SPS 0x0110 | 32 | #define V4L2_CTRL_TYPE_H264_SPS 0x0110 |
@@ -34,6 +35,11 @@ | |||
34 | #define V4L2_CTRL_TYPE_H264_SLICE_PARAMS 0x0113 | 35 | #define V4L2_CTRL_TYPE_H264_SLICE_PARAMS 0x0113 |
35 | #define V4L2_CTRL_TYPE_H264_DECODE_PARAMS 0x0114 | 36 | #define V4L2_CTRL_TYPE_H264_DECODE_PARAMS 0x0114 |
36 | 37 | ||
38 | enum v4l2_mpeg_video_h264_decode_mode { | ||
39 | V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED, | ||
40 | V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED, | ||
41 | }; | ||
42 | |||
37 | #define V4L2_H264_SPS_CONSTRAINT_SET0_FLAG 0x01 | 43 | #define V4L2_H264_SPS_CONSTRAINT_SET0_FLAG 0x01 |
38 | #define V4L2_H264_SPS_CONSTRAINT_SET1_FLAG 0x02 | 44 | #define V4L2_H264_SPS_CONSTRAINT_SET1_FLAG 0x02 |
39 | #define V4L2_H264_SPS_CONSTRAINT_SET2_FLAG 0x04 | 45 | #define V4L2_H264_SPS_CONSTRAINT_SET2_FLAG 0x04 |
@@ -125,6 +131,10 @@ struct v4l2_h264_pred_weight_table { | |||
125 | struct v4l2_ctrl_h264_slice_params { | 131 | struct v4l2_ctrl_h264_slice_params { |
126 | /* Size in bytes, including header */ | 132 | /* Size in bytes, including header */ |
127 | __u32 size; | 133 | __u32 size; |
134 | |||
135 | /* Offset in bytes to the start of slice in the OUTPUT buffer. */ | ||
136 | __u32 start_byte_offset; | ||
137 | |||
128 | /* Offset in bits to slice_data() from the beginning of this slice. */ | 138 | /* Offset in bits to slice_data() from the beginning of this slice. */ |
129 | __u32 header_bit_size; | 139 | __u32 header_bit_size; |
130 | 140 | ||