2 * uvc_h264.h - Definitions of the UVC H.264 Payload specification Version 1.0
4 * Copyright (c) 2011 USB Implementers Forum, Inc.
6 * Modification into glib-like header by :
7 * Copyright (C) 2012 Cisco Systems, Inc.
8 * Author: Youness Alaoui <youness.alaoui@collabora.co.uk>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 /* Header File for the little-endian platform */
34 #include <glib-object.h>
38 #define UVC_H264_BMHINTS_RESOLUTION (0x0001)
39 #define UVC_H264_BMHINTS_PROFILE (0x0002)
40 #define UVC_H264_BMHINTS_RATECONTROL (0x0004)
41 #define UVC_H264_BMHINTS_USAGE (0x0008)
42 #define UVC_H264_BMHINTS_SLICEMODE (0x0010)
43 #define UVC_H264_BMHINTS_SLICEUNITS (0x0020)
44 #define UVC_H264_BMHINTS_MVCVIEW (0x0040)
45 #define UVC_H264_BMHINTS_TEMPORAL (0x0080)
46 #define UVC_H264_BMHINTS_SNR (0x0100)
47 #define UVC_H264_BMHINTS_SPATIAL (0x0200)
48 #define UVC_H264_BMHINTS_SPATIAL_RATIO (0x0400)
49 #define UVC_H264_BMHINTS_FRAME_INTERVAL (0x0800)
50 #define UVC_H264_BMHINTS_LEAKY_BKT_SIZE (0x1000)
51 #define UVC_H264_BMHINTS_BITRATE (0x2000)
52 #define UVC_H264_BMHINTS_ENTROPY (0x4000)
53 #define UVC_H264_BMHINTS_IFRAMEPERIOD (0x8000)
56 #define UVC_H264_QP_STEPS_I_FRAME_TYPE (0x01)
57 #define UVC_H264_QP_STEPS_P_FRAME_TYPE (0x02)
58 #define UVC_H264_QP_STEPS_B_FRAME_TYPE (0x04)
59 #define UVC_H264_QP_STEPS_ALL_FRAME_TYPES (UVC_H264_QP_STEPS_I_FRAME_TYPE | \
60 UVC_H264_QP_STEPS_P_FRAME_TYPE | UVC_H264_QP_STEPS_B_FRAME_TYPE)
62 /* wSliceMode defines */
66 UVC_H264_SLICEMODE_IGNORED = 0x0000,
67 UVC_H264_SLICEMODE_BITSPERSLICE = 0x0001,
68 UVC_H264_SLICEMODE_MBSPERSLICE = 0x0002,
69 UVC_H264_SLICEMODE_SLICEPERFRAME = 0x0003
72 #define UVC_H264_SLICEMODE_TYPE (uvc_h264_slicemode_get_type())
74 GType uvc_h264_slicemode_get_type (void);
76 /* bUsageType defines */
79 UVC_H264_USAGETYPE_REALTIME = 0x01,
80 UVC_H264_USAGETYPE_BROADCAST = 0x02,
81 UVC_H264_USAGETYPE_STORAGE = 0x03,
82 UVC_H264_USAGETYPE_UCCONFIG_0 = 0x04,
83 UVC_H264_USAGETYPE_UCCONFIG_1 = 0x05,
84 UVC_H264_USAGETYPE_UCCONFIG_2Q = 0x06,
85 UVC_H264_USAGETYPE_UCCONFIG_2S = 0x07,
86 UVC_H264_USAGETYPE_UCCONFIG_3 = 0x08,
89 #define UVC_H264_USAGETYPE_TYPE (uvc_h264_usagetype_get_type())
91 GType uvc_h264_usagetype_get_type (void);
93 /* bRateControlMode defines */
96 UVC_H264_RATECONTROL_CBR = 0x01,
97 UVC_H264_RATECONTROL_VBR = 0x02,
98 UVC_H264_RATECONTROL_CONST_QP = 0x03,
101 #define UVC_H264_RATECONTROL_FIXED_FRM_FLG (0x10)
103 #define UVC_H264_RATECONTROL_TYPE (uvc_h264_ratecontrol_get_type())
105 GType uvc_h264_ratecontrol_get_type (void);
107 /* bStreamFormat defines */
110 UVC_H264_STREAMFORMAT_ANNEXB = 0x00,
111 UVC_H264_STREAMFORMAT_NAL = 0x01,
112 } UvcH264StreamFormat;
114 #define UVC_H264_STREAMFORMAT_TYPE (uvc_h264_streamformat_get_type())
116 GType uvc_h264_streamformat_get_type (void);
118 /* bEntropyCABAC defines */
121 UVC_H264_ENTROPY_CAVLC = 0x00,
122 UVC_H264_ENTROPY_CABAC = 0x01,
125 #define UVC_H264_ENTROPY_TYPE (uvc_h264_entropy_get_type())
127 GType uvc_h264_entropy_get_type (void);
129 /* bProfile defines */
130 #define UVC_H264_PROFILE_CONSTRAINED_BASELINE 0x4240
131 #define UVC_H264_PROFILE_BASELINE 0x4200
132 #define UVC_H264_PROFILE_MAIN 0x4D00
133 #define UVC_H264_PROFILE_HIGH 0x6400
135 /* bTimingstamp defines */
137 #define UVC_H264_TIMESTAMP_SEI_DISABLE (0x00)
138 #define UVC_H264_TIMESTAMP_SEI_ENABLE (0x01)
140 /* bPreviewFlipped defines */
142 #define UVC_H264_PREFLIPPED_DISABLE (0x00)
143 #define UVC_H264_PREFLIPPED_HORIZONTAL (0x01)
145 /* wPicType defines */
146 #define UVC_H264_PICTYPE_I_FRAME (0x00)
147 #define UVC_H264_PICTYPE_IDR (0x01)
148 #define UVC_H264_PICTYPE_IDR_WITH_PPS_SPS (0x02)
154 |------------+------------+------------+----------------+------------|
155 | Reserved | StreamID | QualityID | DependencyID | TemporalID |
156 | (3 bits) | (3 bits) | (3 bits) | (4 bits) | (3 bits) |
157 |------------+------------+------------+----------------+------------|
158 |15 13|12 10|9 7|6 3|2 0|
159 |------------+------------+------------+----------------+------------|
162 #define xLayerID(stream_id, quality_id, dependency_id, temporal_id) \
163 ((((stream_id) & 7) << 10) | \
164 (((quality_id) & 7) << 7) | \
165 (((dependency_id) & 15) << 3) | \
168 /* id extraction from wLayerID */
170 #define xStream_id(layer_id) (((layer_id) >> 10) & 7)
171 #define xQuality_id(layer_id) (((layer_id) >> 7) & 7)
172 #define xDependency_id(layer_id) (((layer_id) >> 3) & 15)
173 #define xTemporal_id(layer_id) ((layer_id)&7)
175 /* UVC H.264 control selectors */
177 typedef enum _uvcx_control_selector_t
179 UVCX_VIDEO_CONFIG_PROBE = 0x01,
180 UVCX_VIDEO_CONFIG_COMMIT = 0x02,
181 UVCX_RATE_CONTROL_MODE = 0x03,
182 UVCX_TEMPORAL_SCALE_MODE = 0x04,
183 UVCX_SPATIAL_SCALE_MODE = 0x05,
184 UVCX_SNR_SCALE_MODE = 0x06,
185 UVCX_LTR_BUFFER_SIZE_CONTROL = 0x07,
186 UVCX_LTR_PICTURE_CONTROL = 0x08,
187 UVCX_PICTURE_TYPE_CONTROL = 0x09,
189 UVCX_ENCODER_RESET = 0x0B,
190 UVCX_FRAMERATE_CONFIG = 0x0C,
191 UVCX_VIDEO_ADVANCE_CONFIG = 0x0D,
192 UVCX_BITRATE_LAYERS = 0x0E,
193 UVCX_QP_STEPS_LAYERS = 0x0F,
194 } uvcx_control_selector_t;
197 typedef struct _uvcx_video_config_probe_commit_t
199 guint32 dwFrameInterval;
202 guint16 wConfigurationIndex;
208 guint16 wIFramePeriod;
209 guint16 wEstimatedVideoDelay;
210 guint16 wEstimatedMaxConfigDelay;
212 guint8 bRateControlMode;
213 guint8 bTemporalScaleMode;
214 guint8 bSpatialScaleMode;
215 guint8 bSNRScaleMode;
216 guint8 bStreamMuxOption;
217 guint8 bStreamFormat;
218 guint8 bEntropyCABAC;
220 guint8 bNumOfReorderFrames;
221 guint8 bPreviewFlipped;
226 guint8 bSpatialLayerRatio;
227 guint16 wLeakyBucketSize;
228 } __attribute__((packed)) uvcx_video_config_probe_commit_t;
231 typedef struct _uvcx_rate_control_mode_t
234 guint8 bRateControlMode;
235 } __attribute__((packed)) uvcx_rate_control_mode_t;
238 typedef struct _uvcx_temporal_scale_mode_t
241 guint8 bTemporalScaleMode;
242 } __attribute__((packed)) uvcx_temporal_scale_mode_t;
245 typedef struct _uvcx_spatial_scale_mode_t
248 guint8 bSpatialScaleMode;
249 } __attribute__((packed)) uvcx_spatial_scale_mode_t;
252 typedef struct _uvcx_snr_scale_mode_t
255 guint8 bSNRScaleMode;
256 guint8 bMGSSublayerMode;
257 } __attribute__((packed)) uvcx_snr_scale_mode_t;
260 typedef struct _uvcx_ltr_buffer_size_control_t
263 guint8 bLTRBufferSize;
264 guint8 bLTREncoderControl;
265 } __attribute__((packed)) uvcx_ltr_buffer_size_control_t;
267 typedef struct _uvcx_ltr_picture_control
270 guint8 bPutAtPositionInLTRBuffer;
271 guint8 bEncodeUsingLTR;
272 } __attribute__((packed)) uvcx_ltr_picture_control;
275 typedef struct _uvcx_picture_type_control_t
279 } __attribute__((packed)) uvcx_picture_type_control_t;
282 typedef struct _uvcx_version_t
285 } __attribute__((packed)) uvcx_version_t;
288 typedef struct _uvcx_encoder_reset
291 } __attribute__((packed)) uvcx_encoder_reset;
294 typedef struct _uvcx_framerate_config_t
297 guint32 dwFrameInterval;
298 } __attribute__((packed)) uvcx_framerate_config_t;
301 typedef struct _uvcx_video_advance_config_t
307 } __attribute__((packed)) uvcx_video_advance_config_t;
310 typedef struct _uvcx_bitrate_layers_t
313 guint32 dwPeakBitrate;
314 guint32 dwAverageBitrate;
315 } __attribute__((packed)) uvcx_bitrate_layers_t;
318 typedef struct _uvcx_qp_steps_layers_t
324 } __attribute__((packed)) uvcx_qp_steps_layers_t;
328 // GUID of the UVC H.264 extension unit: {A29E7641-DE04-47E3-8B2B-F4341AFF003B}
329 DEFINE_GUID(GUID_UVCX_H264_XU, 0xA29E7641, 0xDE04, 0x47E3, 0x8B, 0x2B, 0xF4, 0x34, 0x1A, 0xFF, 0x00, 0x3B);
331 #define GUID_UVCX_H264_XU \
332 {0x41, 0x76, 0x9e, 0xa2, 0x04, 0xde, 0xe3, 0x47, 0x8b, 0x2b, 0xF4, 0x34, 0x1A, 0xFF, 0x00, 0x3B}
335 #endif /*_UVC_H264_H_*/