summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel@collabora.com>2019-08-16 12:01:25 -0400
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-08-19 12:23:12 -0400
commit8cae93e090113e46bd29a99c1727d8f13ea12fdf (patch)
tree14bd89209cf54424272a7b1100f6765985ed7dca
parent5604be66a56867a784e162299a48c214921ffa1b (diff)
media: uapi: h264: Add the concept of start code
Stateless decoders have different expectations about the start code that is prepended on H264 slices. Add a menu control to express the supported start code types (including no start code). Drivers are allowed to support only one start code type, but they can support both too. Note that this is independent of the H264 decoding mode, which specifies the granularity of the decoding operations. Either in frame-based or slice-based mode, this new control will allow to define the start code expected on H264 slices. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Tested-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
-rw-r--r--Documentation/media/uapi/v4l/ext-ctrls-codec.rst33
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-compressed.rst5
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c9
-rw-r--r--include/media/h264-ctrls.h6
4 files changed, 51 insertions, 2 deletions
diff --git a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst
index 1da17a2c94d7..810ae9bb6f7c 100644
--- a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst
+++ b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst
@@ -2076,6 +2076,39 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type -
2076 The OUTPUT buffer must contain all slices needed to decode the 2076 The OUTPUT buffer must contain all slices needed to decode the
2077 frame. The OUTPUT buffer must also contain both fields. 2077 frame. The OUTPUT buffer must also contain both fields.
2078 2078
2079``V4L2_CID_MPEG_VIDEO_H264_START_CODE (enum)``
2080 Specifies the H264 slice start code expected for each slice.
2081 This control is used as a modifier for V4L2_PIX_FMT_H264_SLICE
2082 pixel format. Applications that support V4L2_PIX_FMT_H264_SLICE
2083 are required to set this control in order to specify the start code
2084 that is expected for the buffer.
2085 Drivers may expose a single or multiple start codes, depending
2086 on what they can support.
2087
2088 .. note::
2089
2090 This menu control is not yet part of the public kernel API and
2091 it is expected to change.
2092
2093.. c:type:: v4l2_mpeg_video_h264_start_code
2094
2095.. cssclass:: longtable
2096
2097.. flat-table::
2098 :header-rows: 0
2099 :stub-columns: 0
2100 :widths: 1 1 2
2101
2102 * - ``V4L2_MPEG_VIDEO_H264_START_CODE_NONE``
2103 - 0
2104 - Selecting this value specifies that H264 slices are passed
2105 to the driver without any start code.
2106 * - ``V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B``
2107 - 1
2108 - Selecting this value specifies that H264 slices are expected
2109 to be prefixed by Annex B start codes. According to :ref:`h264`
2110 valid start codes can be 3-bytes 0x000001 or 4-bytes 0x00000001.
2111
2079.. _v4l2-mpeg-mpeg2: 2112.. _v4l2-mpeg-mpeg2:
2080 2113
2081``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (struct)`` 2114``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 d666eb51741a..493b6020107d 100644
--- a/Documentation/media/uapi/v4l/pixfmt-compressed.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-compressed.rst
@@ -60,8 +60,9 @@ 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 This pixelformat has a modifier that must be set at least once 63 This pixelformat has two modifiers that must be set at least once
64 through the ``V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE`` control. 64 through the ``V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE``
65 and ``V4L2_CID_MPEG_VIDEO_H264_START_CODE`` controls.
65 In addition, metadata associated with the frame to decode are 66 In addition, metadata associated with the frame to decode are
66 required to be passed through the ``V4L2_CID_MPEG_VIDEO_H264_SPS``, 67 required to be passed through the ``V4L2_CID_MPEG_VIDEO_H264_SPS``,
67 ``V4L2_CID_MPEG_VIDEO_H264_PPS``, 68 ``V4L2_CID_MPEG_VIDEO_H264_PPS``,
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 2c67f9fc4d5b..1d8f38824631 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -407,6 +407,11 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
407 "Frame-Based", 407 "Frame-Based",
408 NULL, 408 NULL,
409 }; 409 };
410 static const char * const h264_start_code[] = {
411 "No Start Code",
412 "Annex B Start Code",
413 NULL,
414 };
410 static const char * const mpeg_mpeg2_level[] = { 415 static const char * const mpeg_mpeg2_level[] = {
411 "Low", 416 "Low",
412 "Main", 417 "Main",
@@ -640,6 +645,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
640 return h264_fmo_map_type; 645 return h264_fmo_map_type;
641 case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE: 646 case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE:
642 return h264_decode_mode; 647 return h264_decode_mode;
648 case V4L2_CID_MPEG_VIDEO_H264_START_CODE:
649 return h264_start_code;
643 case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL: 650 case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL:
644 return mpeg_mpeg2_level; 651 return mpeg_mpeg2_level;
645 case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE: 652 case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE:
@@ -860,6 +867,7 @@ const char *v4l2_ctrl_get_name(u32 id)
860 case V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS: return "H264 Slice Parameters"; 867 case V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS: return "H264 Slice Parameters";
861 case V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS: return "H264 Decode Parameters"; 868 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"; 869 case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE: return "H264 Decode Mode";
870 case V4L2_CID_MPEG_VIDEO_H264_START_CODE: return "H264 Start Code";
863 case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL: return "MPEG2 Level"; 871 case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL: return "MPEG2 Level";
864 case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE: return "MPEG2 Profile"; 872 case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE: return "MPEG2 Profile";
865 case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: return "MPEG4 I-Frame QP Value"; 873 case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: return "MPEG4 I-Frame QP Value";
@@ -1229,6 +1237,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
1229 case V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE: 1237 case V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE:
1230 case V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE: 1238 case V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE:
1231 case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE: 1239 case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE:
1240 case V4L2_CID_MPEG_VIDEO_H264_START_CODE:
1232 case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL: 1241 case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL:
1233 case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE: 1242 case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE:
1234 case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: 1243 case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
diff --git a/include/media/h264-ctrls.h b/include/media/h264-ctrls.h
index 928c48c57282..ba2876a64cf6 100644
--- a/include/media/h264-ctrls.h
+++ b/include/media/h264-ctrls.h
@@ -27,6 +27,7 @@
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#define V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE (V4L2_CID_MPEG_BASE+1005)
30#define V4L2_CID_MPEG_VIDEO_H264_START_CODE (V4L2_CID_MPEG_BASE+1006)
30 31
31/* enum v4l2_ctrl_type type values */ 32/* enum v4l2_ctrl_type type values */
32#define V4L2_CTRL_TYPE_H264_SPS 0x0110 33#define V4L2_CTRL_TYPE_H264_SPS 0x0110
@@ -40,6 +41,11 @@ enum v4l2_mpeg_video_h264_decode_mode {
40 V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED, 41 V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED,
41}; 42};
42 43
44enum v4l2_mpeg_video_h264_start_code {
45 V4L2_MPEG_VIDEO_H264_START_CODE_NONE,
46 V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B,
47};
48
43#define V4L2_H264_SPS_CONSTRAINT_SET0_FLAG 0x01 49#define V4L2_H264_SPS_CONSTRAINT_SET0_FLAG 0x01
44#define V4L2_H264_SPS_CONSTRAINT_SET1_FLAG 0x02 50#define V4L2_H264_SPS_CONSTRAINT_SET1_FLAG 0x02
45#define V4L2_H264_SPS_CONSTRAINT_SET2_FLAG 0x04 51#define V4L2_H264_SPS_CONSTRAINT_SET2_FLAG 0x04