1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef C2CONFIG_H_
18 #define C2CONFIG_H_
19
20 #include <C2.h>
21 #include <C2Component.h>
22 #include <C2Enum.h>
23 #include <C2ParamDef.h>
24
25 /// \defgroup config Component configuration
26 /// @{
27
28 /**
29 * Enumerated boolean.
30 */
31 C2ENUM(c2_bool_t, uint32_t,
32 C2_FALSE, ///< true
33 C2_TRUE, ///< false
34 )
35
36 typedef C2SimpleValueStruct<c2_bool_t> C2BoolValue;
37
38 typedef C2SimpleValueStruct<C2EasyEnum<c2_bool_t>> C2EasyBoolValue;
39
40 /**
41 * Enumerated set tri-state.
42 *
43 * Used for optional configurations to distinguish between values set by the client,
44 * default values set by the component, or unset values.
45 */
46 C2ENUM(c2_set_t, uint32_t,
47 C2_UNSET, // parameter is unset and has no value
48 C2_SET, // parameter is/has been set by the client
49 C2_DEFAULT, // parameter has not been set by the client, but is set by the component
50 )
51
52 /** Enumerations used by configuration parameters */
53 struct C2Config {
54 enum aac_packaging_t : uint32_t; ///< AAC packaging (RAW vs ADTS)
55 enum aac_sbr_mode_t : uint32_t; ///< AAC SBR mode
56 enum api_feature_t : uint64_t; ///< API features
57 enum api_level_t : uint32_t; ///< API level
58 enum bitrate_mode_t : uint32_t; ///< bitrate control mode
59 enum drc_compression_mode_t : int32_t; ///< DRC compression mode
60 enum drc_effect_type_t : int32_t; ///< DRC effect type
61 enum drc_album_mode_t : int32_t; ///< DRC album mode
62 enum intra_refresh_mode_t : uint32_t; ///< intra refresh modes
63 enum level_t : uint32_t; ///< coding level
64 enum ordinal_key_t : uint32_t; ///< work ordering keys
65 enum pcm_encoding_t : uint32_t; ///< PCM encoding
66 enum picture_type_t : uint32_t; ///< picture types
67 enum platform_feature_t : uint64_t; ///< platform features
68 enum platform_level_t : uint32_t; ///< platform level
69 enum prepend_header_mode_t : uint32_t; ///< prepend header operational modes
70 enum profile_t : uint32_t; ///< coding profile
71 enum scaling_method_t : uint32_t; ///< scaling methods
72 enum scan_order_t : uint32_t; ///< scan orders
73 enum secure_mode_t : uint32_t; ///< secure/protected modes
74 enum supplemental_info_t : uint32_t; ///< supplemental information types
75 enum tiling_mode_t : uint32_t; ///< tiling modes
76 };
77
78 namespace {
79
80 enum C2ParamIndexKind : C2Param::type_index_t {
81 C2_PARAM_INDEX_INVALID = 0x0, ///< do not use
82 C2_PARAM_INDEX_STRUCT_START = 0x1, ///< struct only indices
83 C2_PARAM_INDEX_PARAM_START = 0x800, ///< regular parameters
84 C2_PARAM_INDEX_CODER_PARAM_START = 0x1000, ///< en/transcoder parameters
85 C2_PARAM_INDEX_PICTURE_PARAM_START = 0x1800, ///< image/video parameters
86 C2_PARAM_INDEX_VIDEO_PARAM_START = 0x2000, ///< video parameters
87 C2_PARAM_INDEX_IMAGE_PARAM_START = 0x2800, ///< image parameters
88 C2_PARAM_INDEX_AUDIO_PARAM_START = 0x3000, ///< image parameters
89 C2_PARAM_INDEX_PLATFORM_START = 0x4000, ///< platform-defined parameters
90
91 /* =================================== structure indices =================================== */
92
93 kParamIndexColorXy = C2_PARAM_INDEX_STRUCT_START,
94 kParamIndexMasteringDisplayColorVolume,
95 kParamIndexChromaOffset,
96 kParamIndexGopLayer,
97
98 /* =================================== parameter indices =================================== */
99
100 kParamIndexApiLevel = C2_PARAM_INDEX_PARAM_START,
101 kParamIndexApiFeatures,
102
103 /* ------------------------------------ all components ------------------------------------ */
104
105 /* generic component characteristics */
106 kParamIndexName,
107 kParamIndexAliases,
108 kParamIndexKind,
109 kParamIndexDomain,
110 kParamIndexAttributes,
111 kParamIndexTimeStretch,
112
113 /* coding characteristics */
114 kParamIndexProfileLevel,
115 kParamIndexInitData,
116 kParamIndexSupplementalData,
117 kParamIndexSubscribedSupplementalData,
118
119 /* pipeline characteristics */
120 kParamIndexMediaType,
121 __kParamIndexRESERVED_0,
122 kParamIndexDelay,
123 kParamIndexMaxReferenceAge,
124 kParamIndexMaxReferenceCount,
125 kParamIndexReorderBufferDepth,
126 kParamIndexReorderKey,
127 kParamIndexStreamCount,
128 kParamIndexSubscribedParamIndices,
129 kParamIndexSuggestedBufferCount,
130 kParamIndexBatchSize,
131 kParamIndexCurrentWork,
132 kParamIndexLastWorkQueued,
133
134 /* memory allocation */
135 kParamIndexAllocators,
136 kParamIndexBlockPools,
137 kParamIndexBufferType,
138 kParamIndexUsage,
139 kParamIndexOutOfMemory,
140 kParamIndexMaxBufferSize,
141
142 /* misc. state */
143 kParamIndexTripped,
144 kParamIndexConfigCounter,
145
146 /* resources */
147 kParamIndexResourcesNeeded,
148 kParamIndexResourcesReserved,
149 kParamIndexOperatingRate,
150 kParamIndexRealTimePriority,
151
152 /* protected content */
153 kParamIndexSecureMode,
154
155 // deprecated
156 kParamIndexDelayRequest = kParamIndexDelay | C2Param::CoreIndex::IS_REQUEST_FLAG,
157
158 /* ------------------------------------ (trans/en)coders ------------------------------------ */
159
160 kParamIndexBitrate = C2_PARAM_INDEX_CODER_PARAM_START,
161 kParamIndexBitrateMode,
162 kParamIndexQuality,
163 kParamIndexComplexity,
164 kParamIndexPrependHeaderMode,
165
166 /* --------------------------------- image/video components --------------------------------- */
167
168 kParamIndexPictureSize = C2_PARAM_INDEX_PICTURE_PARAM_START,
169 kParamIndexCropRect,
170 kParamIndexPixelFormat,
171 kParamIndexRotation,
172 kParamIndexPixelAspectRatio,
173 kParamIndexScaledPictureSize,
174 kParamIndexScaledCropRect,
175 kParamIndexScalingMethod,
176 kParamIndexColorInfo,
177 kParamIndexColorAspects,
178 kParamIndexHdrStaticMetadata,
179 kParamIndexDefaultColorAspects,
180
181 kParamIndexBlockSize,
182 kParamIndexBlockCount,
183 kParamIndexBlockRate,
184
185 kParamIndexPictureTypeMask,
186 kParamIndexPictureType,
187 kParamIndexHdr10PlusMetadata,
188
189 /* ------------------------------------ video components ------------------------------------ */
190
191 kParamIndexFrameRate = C2_PARAM_INDEX_VIDEO_PARAM_START,
192 kParamIndexMaxBitrate,
193 kParamIndexMaxFrameRate,
194 kParamIndexMaxPictureSize,
195 kParamIndexGop,
196 kParamIndexSyncFrameInterval,
197 kParamIndexRequestSyncFrame,
198 kParamIndexTemporalLayering,
199 kParamIndexLayerIndex,
200 kParamIndexLayerCount,
201 kParamIndexIntraRefresh,
202
203 /* ------------------------------------ image components ------------------------------------ */
204
205 kParamIndexTileLayout = C2_PARAM_INDEX_IMAGE_PARAM_START,
206 kParamIndexTileHandling,
207
208 /* ------------------------------------ audio components ------------------------------------ */
209
210 kParamIndexSampleRate = C2_PARAM_INDEX_AUDIO_PARAM_START,
211 kParamIndexChannelCount,
212 kParamIndexPcmEncoding,
213 kParamIndexAacPackaging,
214 kParamIndexMaxChannelCount,
215 kParamIndexAacSbrMode, // aac encode, enum
216 kParamIndexDrcEncodedTargetLevel, // drc, float (dBFS)
217 kParamIndexDrcTargetReferenceLevel, // drc, float (dBFS)
218 kParamIndexDrcCompression, // drc, enum
219 kParamIndexDrcBoostFactor, // drc, float (0-1)
220 kParamIndexDrcAttenuationFactor, // drc, float (0-1)
221 kParamIndexDrcEffectType, // drc, enum
222 kParamIndexDrcOutputLoudness, // drc, float (dBFS)
223 kParamIndexDrcAlbumMode, // drc, enum
224
225 /* ============================== platform-defined parameters ============================== */
226
227 kParamIndexPlatformLevel = C2_PARAM_INDEX_PLATFORM_START, // all, u32
228 kParamIndexPlatformFeatures, // all, u64 mask
229 kParamIndexStoreIonUsage, // store, struct
230 kParamIndexAspectsToDataSpace, // store, struct
231 kParamIndexFlexiblePixelFormatDescriptor, // store, struct
232 kParamIndexFlexiblePixelFormatDescriptors, // store, struct[]
233 kParamIndexDataSpaceToAspects, // store, struct
234 kParamIndexDataSpace, // u32
235 kParamIndexSurfaceScaling, // u32
236
237 // input surface
238 kParamIndexInputSurfaceEos, // input-surface, eos
239 kParamIndexTimedControl, // struct
240 kParamIndexStartAt, // input-surface, struct
241 kParamIndexSuspendAt, // input-surface, struct
242 kParamIndexResumeAt, // input-surface, struct
243 kParamIndexStopAt, // input-surface, struct
244 kParamIndexTimeOffset, // input-surface, struct
245 kParamIndexMinFrameRate, // input-surface, float
246 kParamIndexTimestampGapAdjustment, // input-surface, struct
247
248 kParamIndexSurfaceAllocator, // u32
249
250 // low latency mode
251 kParamIndexLowLatencyMode, // bool
252 };
253
254 }
255
256 /**
257 * Codec 2.0 parameter types follow the following naming convention:
258 *
259 * C2<group><domain><index><type>
260 *
261 * E.g. C2StreamPictureSizeInfo: group="" domain="Stream" index="PictureSize" type="Info".
262 * Group is somewhat arbitrary, but denotes kind of objects the parameter is defined.
263 * At this point we use Component and Store to distinguish basic component/store parameters.
264 *
265 * Parameter keys are named C2_PARAMKEY_[<group>_]<domain>_<index> as type is not expected
266 * to distinguish parameters. E.g. a component could change the type of the parameter and it
267 * is not expected users would need to change the key.
268 */
269
270 /* ----------------------------------------- API level ----------------------------------------- */
271
272 enum C2Config::api_level_t : uint32_t {
273 API_L0_1 = 0, ///< support for API level 0.1
274 };
275
276 // read-only
277 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Config::api_level_t>, kParamIndexApiLevel>
278 C2ApiLevelSetting;
279 constexpr char C2_PARAMKEY_API_LEVEL[] = "api.level";
280
281 C2ENUM(C2Config::api_feature_t, uint64_t,
282 API_REFLECTION = (1U << 0), ///< ability to list supported parameters
283 API_VALUES = (1U << 1), ///< ability to list supported values for each parameter
284 API_CURRENT_VALUES = (1U << 2), ///< ability to list currently supported values for each parameter
285 API_DEPENDENCY = (1U << 3), ///< have a defined parameter dependency
286
287 API_SAME_INPUT_BUFFER = (1U << 16), ///< supporting multiple input buffers
288 ///< backed by the same allocation
289
290 API_STREAMS = (1ULL << 32), ///< supporting variable number of streams
291
292 API_TUNNELING = (1ULL << 48) ///< tunneling API
293 )
294
295 // read-only
296 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Config::api_feature_t>, kParamIndexApiFeatures>
297 C2ApiFeaturesSetting;
298 constexpr char C2_PARAMKEY_API_FEATURES[] = "api.features";
299
300 /* ----------------------------- generic component characteristics ----------------------------- */
301
302 /**
303 * The name of the component.
304 *
305 * This must contain only alphanumeric characters or dot '.', hyphen '-', plus '+', or
306 * underline '_'. The name of each component must be unique.
307 *
308 * For Android: Component names must start with 'c2.' followed by the company name or abbreviation
309 * and another dot, e.g. 'c2.android.'. Use of lowercase is preferred but not required.
310 */
311 // read-only
312 typedef C2GlobalParam<C2Setting, C2StringValue, kParamIndexName> C2ComponentNameSetting;
313 constexpr char C2_PARAMKEY_COMPONENT_NAME[] = "component.name";
314
315 /**
316 * Alternate names (aliases) of the component.
317 *
318 * This is a comma ',' separated list of alternate component names. Unlike component names that
319 * must be unique, multiple components can have the same alias.
320 */
321 // read-only
322 typedef C2GlobalParam<C2Setting, C2StringValue, kParamIndexAliases> C2ComponentAliasesSetting;
323 constexpr char C2_PARAMKEY_COMPONENT_ALIASES[] = "component.aliases";
324
325 /**
326 * Component kind.
327 */
328 // read-only
329 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Component::kind_t>, kParamIndexKind>
330 C2ComponentKindSetting;
331 constexpr char C2_PARAMKEY_COMPONENT_KIND[] = "component.kind";
332
333 /**
334 * Component domain.
335 */
336 // read-only
337 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Component::domain_t>, kParamIndexDomain>
338 C2ComponentDomainSetting;
339 constexpr char C2_PARAMKEY_COMPONENT_DOMAIN[] = "component.domain";
340
341 /**
342 * Component attributes.
343 *
344 * These are a set of flags provided by the component characterizing its processing algorithm.
345 */
346 C2ENUM(C2Component::attrib_t, uint64_t,
347 ATTRIB_IS_TEMPORAL = 1u << 0, ///< component input ordering matters for processing
348 )
349
350 // read-only
351 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Component::attrib_t>, kParamIndexAttributes>
352 C2ComponentAttributesSetting;
353 constexpr char C2_PARAMKEY_COMPONENT_ATTRIBUTES[] = "component.attributes";
354
355 /**
356 * Time stretching.
357 *
358 * This is the ratio between the rate of the input timestamp, and the rate of the output timestamp.
359 * E.g. if this is 4.0, for every 1 seconds of input timestamp difference, the output shall differ
360 * by 4 seconds.
361 */
362 typedef C2GlobalParam<C2Tuning, C2FloatValue, kParamIndexTimeStretch> C2ComponentTimeStretchTuning;
363 constexpr char C2_PARAMKEY_TIME_STRETCH[] = "algo.time-stretch";
364
365 /* ----------------------------------- coding characteristics ----------------------------------- */
366
367 /**
368 * Profile and level.
369 *
370 * Profile determines the tools used by the component.
371 * Level determines the level of resources used by the component.
372 */
373
374 namespace {
375
376 enum : uint32_t {
377 _C2_PL_MP2V_BASE = 0x1000,
378 _C2_PL_AAC_BASE = 0x2000,
379 _C2_PL_H263_BASE = 0x3000,
380 _C2_PL_MP4V_BASE = 0x4000,
381 _C2_PL_AVC_BASE = 0x5000,
382 _C2_PL_HEVC_BASE = 0x6000,
383 _C2_PL_VP9_BASE = 0x7000,
384 _C2_PL_DV_BASE = 0x8000,
385 _C2_PL_AV1_BASE = 0x9000,
386
387 C2_PROFILE_LEVEL_VENDOR_START = 0x70000000,
388 };
389
390 }
391
392 enum C2Config::profile_t : uint32_t {
393 PROFILE_UNUSED = 0, ///< profile is not used by this media type
394
395 // AAC (MPEG-2 Part 7 and MPEG-4 Part 3) profiles
396 PROFILE_AAC_LC = _C2_PL_AAC_BASE, ///< AAC Low-Complexity
397 PROFILE_AAC_MAIN, ///< AAC Main
398 PROFILE_AAC_SSR, ///< AAC Scalable Sampling Rate
399 PROFILE_AAC_LTP, ///< AAC Long Term Prediction
400 PROFILE_AAC_HE, ///< AAC High-Efficiency
401 PROFILE_AAC_SCALABLE, ///< AAC Scalable
402 PROFILE_AAC_ER_LC, ///< AAC Error Resilient Low-Complexity
403 PROFILE_AAC_ER_SCALABLE, ///< AAC Error Resilient Scalable
404 PROFILE_AAC_LD, ///< AAC Low Delay
405 PROFILE_AAC_HE_PS, ///< AAC High-Efficiency Parametric Stereo
406 PROFILE_AAC_ELD, ///< AAC Enhanced Low Delay
407 PROFILE_AAC_XHE, ///< AAC Extended High-Efficiency
408
409 // MPEG-2 Video profiles
410 PROFILE_MP2V_SIMPLE = _C2_PL_MP2V_BASE, ///< MPEG-2 Video (H.262) Simple
411 PROFILE_MP2V_MAIN, ///< MPEG-2 Video (H.262) Main
412 PROFILE_MP2V_SNR_SCALABLE, ///< MPEG-2 Video (H.262) SNR Scalable
413 PROFILE_MP2V_SPATIALLY_SCALABLE, ///< MPEG-2 Video (H.262) Spatially Scalable
414 PROFILE_MP2V_HIGH, ///< MPEG-2 Video (H.262) High
415 PROFILE_MP2V_422, ///< MPEG-2 Video (H.262) 4:2:2
416 PROFILE_MP2V_MULTIVIEW, ///< MPEG-2 Video (H.262) Multi-view
417
418 // H.263 profiles
419 PROFILE_H263_BASELINE = _C2_PL_H263_BASE, ///< H.263 Baseline (Profile 0)
420 PROFILE_H263_H320, ///< H.263 H.320 Coding Efficiency Version 2 Backward-Compatibility (Profile 1)
421 PROFILE_H263_V1BC, ///< H.263 Version 1 Backward-Compatibility (Profile 2)
422 PROFILE_H263_ISWV2, ///< H.263 Version 2 Interactive and Streaming Wireless (Profile 3)
423 PROFILE_H263_ISWV3, ///< H.263 Version 3 Interactive and Streaming Wireless (Profile 4)
424 PROFILE_H263_HIGH_COMPRESSION, ///< H.263 Conversational High Compression (Profile 5)
425 PROFILE_H263_INTERNET, ///< H.263 Conversational Internet (Profile 6)
426 PROFILE_H263_INTERLACE, ///< H.263 Conversational Interlace (Profile 7)
427 PROFILE_H263_HIGH_LATENCY, ///< H.263 High Latency (Profile 8)
428
429 // MPEG-4 Part 2 (Video) Natural Visual Profiles
430 PROFILE_MP4V_SIMPLE, ///< MPEG-4 Video Simple
431 PROFILE_MP4V_SIMPLE_SCALABLE, ///< MPEG-4 Video Simple Scalable
432 PROFILE_MP4V_CORE, ///< MPEG-4 Video Core
433 PROFILE_MP4V_MAIN, ///< MPEG-4 Video Main
434 PROFILE_MP4V_NBIT, ///< MPEG-4 Video N-Bit
435 PROFILE_MP4V_ARTS, ///< MPEG-4 Video Advanced Realtime Simple
436 PROFILE_MP4V_CORE_SCALABLE, ///< MPEG-4 Video Core Scalable
437 PROFILE_MP4V_ACE, ///< MPEG-4 Video Advanced Coding Efficiency
438 PROFILE_MP4V_ADVANCED_CORE, ///< MPEG-4 Video Advanced Core
439 PROFILE_MP4V_SIMPLE_STUDIO, ///< MPEG-4 Video Simple Studio
440 PROFILE_MP4V_CORE_STUDIO, ///< MPEG-4 Video Core Studio
441 PROFILE_MP4V_ADVANCED_SIMPLE, ///< MPEG-4 Video Advanced Simple
442 PROFILE_MP4V_FGS, ///< MPEG-4 Video Fine Granularity Scalable
443
444 // AVC / MPEG-4 Part 10 (H.264) profiles
445 PROFILE_AVC_BASELINE = _C2_PL_AVC_BASE, ///< AVC (H.264) Baseline
446 PROFILE_AVC_CONSTRAINED_BASELINE, ///< AVC (H.264) Constrained Baseline
447 PROFILE_AVC_MAIN, ///< AVC (H.264) Main
448 PROFILE_AVC_EXTENDED, ///< AVC (H.264) Extended
449 PROFILE_AVC_HIGH, ///< AVC (H.264) High
450 PROFILE_AVC_PROGRESSIVE_HIGH, ///< AVC (H.264) Progressive High
451 PROFILE_AVC_CONSTRAINED_HIGH, ///< AVC (H.264) Constrained High
452 PROFILE_AVC_HIGH_10, ///< AVC (H.264) High 10
453 PROFILE_AVC_PROGRESSIVE_HIGH_10, ///< AVC (H.264) Progressive High 10
454 PROFILE_AVC_HIGH_422, ///< AVC (H.264) High 4:2:2
455 PROFILE_AVC_HIGH_444_PREDICTIVE, ///< AVC (H.264) High 4:4:4 Predictive
456 PROFILE_AVC_HIGH_10_INTRA, ///< AVC (H.264) High 10 Intra
457 PROFILE_AVC_HIGH_422_INTRA, ///< AVC (H.264) High 4:2:2 Intra
458 PROFILE_AVC_HIGH_444_INTRA, ///< AVC (H.264) High 4:4:4 Intra
459 PROFILE_AVC_CAVLC_444_INTRA, ///< AVC (H.264) CAVLC 4:4:4 Intra
460 PROFILE_AVC_SCALABLE_BASELINE = _C2_PL_AVC_BASE + 0x100, ///< AVC (H.264) Scalable Baseline
461 PROFILE_AVC_SCALABLE_CONSTRAINED_BASELINE, ///< AVC (H.264) Scalable Constrained Baseline
462 PROFILE_AVC_SCALABLE_HIGH, ///< AVC (H.264) Scalable High
463 PROFILE_AVC_SCALABLE_CONSTRAINED_HIGH, ///< AVC (H.264) Scalable Constrained High
464 PROFILE_AVC_SCALABLE_HIGH_INTRA, ///< AVC (H.264) Scalable High Intra
465 PROFILE_AVC_MULTIVIEW_HIGH = _C2_PL_AVC_BASE + 0x200, ///< AVC (H.264) Multiview High
466 PROFILE_AVC_STEREO_HIGH, ///< AVC (H.264) Stereo High
467 PROFILE_AVC_MFC_HIGH, ///< AVC (H.264) MFC High
468 PROFILE_AVC_MULTIVIEW_DEPTH_HIGH = _C2_PL_AVC_BASE + 0x300, ///< AVC (H.264) Multiview Depth High
469 PROFILE_AVC_MFC_DEPTH_HIGH, ///< AVC (H.264) MFC Depth High
470 PROFILE_AVC_ENHANCED_MULTIVIEW_DEPTH_HIGH = _C2_PL_AVC_BASE + 0x400, ///< AVC (H.264) Enhanced Multiview Depth High
471
472 // HEVC profiles
473 PROFILE_HEVC_MAIN = _C2_PL_HEVC_BASE, ///< HEVC (H.265) Main
474 PROFILE_HEVC_MAIN_10, ///< HEVC (H.265) Main 10
475 PROFILE_HEVC_MAIN_STILL, ///< HEVC (H.265) Main Still Picture
476 PROFILE_HEVC_MONO = _C2_PL_HEVC_BASE + 0x100, ///< HEVC (H.265) Monochrome
477 PROFILE_HEVC_MONO_12, ///< HEVC (H.265) Monochrome 12
478 PROFILE_HEVC_MONO_16, ///< HEVC (H.265) Monochrome 16
479 PROFILE_HEVC_MAIN_12, ///< HEVC (H.265) Main 12
480 PROFILE_HEVC_MAIN_422_10, ///< HEVC (H.265) Main 4:2:2 10
481 PROFILE_HEVC_MAIN_422_12, ///< HEVC (H.265) Main 4:2:2 12
482 PROFILE_HEVC_MAIN_444, ///< HEVC (H.265) Main 4:4:4
483 PROFILE_HEVC_MAIN_444_10, ///< HEVC (H.265) Main 4:4:4 10
484 PROFILE_HEVC_MAIN_444_12, ///< HEVC (H.265) Main 4:4:4 12
485 PROFILE_HEVC_MAIN_INTRA, ///< HEVC (H.265) Main Intra
486 PROFILE_HEVC_MAIN_10_INTRA, ///< HEVC (H.265) Main 10 Intra
487 PROFILE_HEVC_MAIN_12_INTRA, ///< HEVC (H.265) Main 12 Intra
488 PROFILE_HEVC_MAIN_422_10_INTRA, ///< HEVC (H.265) Main 4:2:2 10 Intra
489 PROFILE_HEVC_MAIN_422_12_INTRA, ///< HEVC (H.265) Main 4:2:2 12 Intra
490 PROFILE_HEVC_MAIN_444_INTRA, ///< HEVC (H.265) Main 4:4:4 Intra
491 PROFILE_HEVC_MAIN_444_10_INTRA, ///< HEVC (H.265) Main 4:4:4 10 Intra
492 PROFILE_HEVC_MAIN_444_12_INTRA, ///< HEVC (H.265) Main 4:4:4 12 Intra
493 PROFILE_HEVC_MAIN_444_16_INTRA, ///< HEVC (H.265) Main 4:4:4 16 Intra
494 PROFILE_HEVC_MAIN_444_STILL, ///< HEVC (H.265) Main 4:4:4 Still Picture
495 PROFILE_HEVC_MAIN_444_16_STILL, ///< HEVC (H.265) Main 4:4:4 16 Still Picture
496 PROFILE_HEVC_HIGH_444 = _C2_PL_HEVC_BASE + 0x200, ///< HEVC (H.265) High Throughput 4:4:4
497 PROFILE_HEVC_HIGH_444_10, ///< HEVC (H.265) High Throughput 4:4:4 10
498 PROFILE_HEVC_HIGH_444_14, ///< HEVC (H.265) High Throughput 4:4:4 14
499 PROFILE_HEVC_HIGH_444_16_INTRA, ///< HEVC (H.265) High Throughput 4:4:4 16 Intra
500 PROFILE_HEVC_SX_MAIN = _C2_PL_HEVC_BASE + 0x300, ///< HEVC (H.265) Screen-Extended Main
501 PROFILE_HEVC_SX_MAIN_10, ///< HEVC (H.265) Screen-Extended Main 10
502 PROFILE_HEVC_SX_MAIN_444, ///< HEVC (H.265) Screen-Extended Main 4:4:4
503 PROFILE_HEVC_SX_MAIN_444_10, ///< HEVC (H.265) Screen-Extended Main 4:4:4 10
504 PROFILE_HEVC_SX_HIGH_444, ///< HEVC (H.265) Screen-Extended High Throughput 4:4:4
505 PROFILE_HEVC_SX_HIGH_444_10, ///< HEVC (H.265) Screen-Extended High Throughput 4:4:4 10
506 PROFILE_HEVC_SX_HIGH_444_14, ///< HEVC (H.265) Screen-Extended High Throughput 4:4:4 14
507 PROFILE_HEVC_MULTIVIEW_MAIN = _C2_PL_HEVC_BASE + 0x400, ///< HEVC (H.265) Multiview Main
508 PROFILE_HEVC_SCALABLE_MAIN = _C2_PL_HEVC_BASE + 0x500, ///< HEVC (H.265) Scalable Main
509 PROFILE_HEVC_SCALABLE_MAIN_10, ///< HEVC (H.265) Scalable Main 10
510 PROFILE_HEVC_SCALABLE_MONO = _C2_PL_HEVC_BASE + 0x600, ///< HEVC (H.265) Scalable Monochrome
511 PROFILE_HEVC_SCALABLE_MONO_12, ///< HEVC (H.265) Scalable Monochrome 12
512 PROFILE_HEVC_SCALABLE_MONO_16, ///< HEVC (H.265) Scalable Monochrome 16
513 PROFILE_HEVC_SCALABLE_MAIN_444, ///< HEVC (H.265) Scalable Main 4:4:4
514 PROFILE_HEVC_3D_MAIN = _C2_PL_HEVC_BASE + 0x700, ///< HEVC (H.265) 3D Main
515
516 // VP9 profiles
517 PROFILE_VP9_0 = _C2_PL_VP9_BASE, ///< VP9 Profile 0 (4:2:0)
518 PROFILE_VP9_1, ///< VP9 Profile 1 (4:2:2 or 4:4:4)
519 PROFILE_VP9_2, ///< VP9 Profile 2 (4:2:0, 10 or 12 bit)
520 PROFILE_VP9_3, ///< VP9 Profile 3 (4:2:2 or 4:4:4, 10 or 12 bit)
521
522 // Dolby Vision profiles
523 PROFILE_DV_AV_PER = _C2_PL_DV_BASE + 0, ///< Dolby Vision dvav.per profile (deprecated)
524 PROFILE_DV_AV_PEN, ///< Dolby Vision dvav.pen profile (deprecated)
525 PROFILE_DV_HE_DER, ///< Dolby Vision dvhe.der profile (deprecated)
526 PROFILE_DV_HE_DEN, ///< Dolby Vision dvhe.den profile (deprecated)
527 PROFILE_DV_HE_04 = _C2_PL_DV_BASE + 4, ///< Dolby Vision dvhe.04 profile
528 PROFILE_DV_HE_05 = _C2_PL_DV_BASE + 5, ///< Dolby Vision dvhe.05 profile
529 PROFILE_DV_HE_DTH, ///< Dolby Vision dvhe.dth profile (deprecated)
530 PROFILE_DV_HE_07 = _C2_PL_DV_BASE + 7, ///< Dolby Vision dvhe.07 profile
531 PROFILE_DV_HE_08 = _C2_PL_DV_BASE + 8, ///< Dolby Vision dvhe.08 profile
532 PROFILE_DV_AV_09 = _C2_PL_DV_BASE + 9, ///< Dolby Vision dvav.09 profile
533 PROFILE_DV_AV1_10 = _C2_PL_DV_BASE + 10, ///< Dolby Vision dav1.10 profile
534
535 // AV1 profiles
536 PROFILE_AV1_0 = _C2_PL_AV1_BASE, ///< AV1 Profile 0 (4:2:0, 8 to 10 bit)
537 PROFILE_AV1_1, ///< AV1 Profile 1 (8 to 10 bit)
538 PROFILE_AV1_2, ///< AV1 Profile 2 (8 to 12 bit)
539 };
540
541 enum C2Config::level_t : uint32_t {
542 LEVEL_UNUSED = 0, ///< level is not used by this media type
543
544 // MPEG-2 Video levels
545 LEVEL_MP2V_LOW = _C2_PL_MP2V_BASE, ///< MPEG-2 Video (H.262) Low Level
546 LEVEL_MP2V_MAIN, ///< MPEG-2 Video (H.262) Main Level
547 LEVEL_MP2V_HIGH_1440, ///< MPEG-2 Video (H.262) High 1440 Level
548 LEVEL_MP2V_HIGH, ///< MPEG-2 Video (H.262) High Level
549 LEVEL_MP2V_HIGHP, ///< MPEG-2 Video (H.262) HighP Level
550
551 // H.263 levels
552 LEVEL_H263_10 = _C2_PL_H263_BASE, ///< H.263 Level 10
553 LEVEL_H263_20, ///< H.263 Level 20
554 LEVEL_H263_30, ///< H.263 Level 30
555 LEVEL_H263_40, ///< H.263 Level 40
556 LEVEL_H263_45, ///< H.263 Level 45
557 LEVEL_H263_50, ///< H.263 Level 50
558 LEVEL_H263_60, ///< H.263 Level 60
559 LEVEL_H263_70, ///< H.263 Level 70
560
561 // MPEG-4 Part 2 (Video) levels
562 LEVEL_MP4V_0 = _C2_PL_MP4V_BASE, ///< MPEG-4 Video Level 0
563 LEVEL_MP4V_0B, ///< MPEG-4 Video Level 0b
564 LEVEL_MP4V_1, ///< MPEG-4 Video Level 1
565 LEVEL_MP4V_2, ///< MPEG-4 Video Level 2
566 LEVEL_MP4V_3, ///< MPEG-4 Video Level 3
567 LEVEL_MP4V_3B, ///< MPEG-4 Video Level 3b
568 LEVEL_MP4V_4, ///< MPEG-4 Video Level 4
569 LEVEL_MP4V_4A, ///< MPEG-4 Video Level 4a
570 LEVEL_MP4V_5, ///< MPEG-4 Video Level 5
571 LEVEL_MP4V_6, ///< MPEG-4 Video Level 6
572
573 // AVC / MPEG-4 Part 10 (H.264) levels
574 LEVEL_AVC_1 = _C2_PL_AVC_BASE, ///< AVC (H.264) Level 1
575 LEVEL_AVC_1B, ///< AVC (H.264) Level 1b
576 LEVEL_AVC_1_1, ///< AVC (H.264) Level 1.1
577 LEVEL_AVC_1_2, ///< AVC (H.264) Level 1.2
578 LEVEL_AVC_1_3, ///< AVC (H.264) Level 1.3
579 LEVEL_AVC_2, ///< AVC (H.264) Level 2
580 LEVEL_AVC_2_1, ///< AVC (H.264) Level 2.1
581 LEVEL_AVC_2_2, ///< AVC (H.264) Level 2.2
582 LEVEL_AVC_3, ///< AVC (H.264) Level 3
583 LEVEL_AVC_3_1, ///< AVC (H.264) Level 3.1
584 LEVEL_AVC_3_2, ///< AVC (H.264) Level 3.2
585 LEVEL_AVC_4, ///< AVC (H.264) Level 4
586 LEVEL_AVC_4_1, ///< AVC (H.264) Level 4.1
587 LEVEL_AVC_4_2, ///< AVC (H.264) Level 4.2
588 LEVEL_AVC_5, ///< AVC (H.264) Level 5
589 LEVEL_AVC_5_1, ///< AVC (H.264) Level 5.1
590 LEVEL_AVC_5_2, ///< AVC (H.264) Level 5.2
591 LEVEL_AVC_6, ///< AVC (H.264) Level 6
592 LEVEL_AVC_6_1, ///< AVC (H.264) Level 6.1
593 LEVEL_AVC_6_2, ///< AVC (H.264) Level 6.2
594
595 // HEVC (H.265) tiers and levels
596 LEVEL_HEVC_MAIN_1 = _C2_PL_HEVC_BASE, ///< HEVC (H.265) Main Tier Level 1
597 LEVEL_HEVC_MAIN_2, ///< HEVC (H.265) Main Tier Level 2
598 LEVEL_HEVC_MAIN_2_1, ///< HEVC (H.265) Main Tier Level 2.1
599 LEVEL_HEVC_MAIN_3, ///< HEVC (H.265) Main Tier Level 3
600 LEVEL_HEVC_MAIN_3_1, ///< HEVC (H.265) Main Tier Level 3.1
601 LEVEL_HEVC_MAIN_4, ///< HEVC (H.265) Main Tier Level 4
602 LEVEL_HEVC_MAIN_4_1, ///< HEVC (H.265) Main Tier Level 4.1
603 LEVEL_HEVC_MAIN_5, ///< HEVC (H.265) Main Tier Level 5
604 LEVEL_HEVC_MAIN_5_1, ///< HEVC (H.265) Main Tier Level 5.1
605 LEVEL_HEVC_MAIN_5_2, ///< HEVC (H.265) Main Tier Level 5.2
606 LEVEL_HEVC_MAIN_6, ///< HEVC (H.265) Main Tier Level 6
607 LEVEL_HEVC_MAIN_6_1, ///< HEVC (H.265) Main Tier Level 6.1
608 LEVEL_HEVC_MAIN_6_2, ///< HEVC (H.265) Main Tier Level 6.2
609
610 LEVEL_HEVC_HIGH_4 = _C2_PL_HEVC_BASE + 0x100, ///< HEVC (H.265) High Tier Level 4
611 LEVEL_HEVC_HIGH_4_1, ///< HEVC (H.265) High Tier Level 4.1
612 LEVEL_HEVC_HIGH_5, ///< HEVC (H.265) High Tier Level 5
613 LEVEL_HEVC_HIGH_5_1, ///< HEVC (H.265) High Tier Level 5.1
614 LEVEL_HEVC_HIGH_5_2, ///< HEVC (H.265) High Tier Level 5.2
615 LEVEL_HEVC_HIGH_6, ///< HEVC (H.265) High Tier Level 6
616 LEVEL_HEVC_HIGH_6_1, ///< HEVC (H.265) High Tier Level 6.1
617 LEVEL_HEVC_HIGH_6_2, ///< HEVC (H.265) High Tier Level 6.2
618
619 // VP9 levels
620 LEVEL_VP9_1 = _C2_PL_VP9_BASE, ///< VP9 Level 1
621 LEVEL_VP9_1_1, ///< VP9 Level 1.1
622 LEVEL_VP9_2, ///< VP9 Level 2
623 LEVEL_VP9_2_1, ///< VP9 Level 2.1
624 LEVEL_VP9_3, ///< VP9 Level 3
625 LEVEL_VP9_3_1, ///< VP9 Level 3.1
626 LEVEL_VP9_4, ///< VP9 Level 4
627 LEVEL_VP9_4_1, ///< VP9 Level 4.1
628 LEVEL_VP9_5, ///< VP9 Level 5
629 LEVEL_VP9_5_1, ///< VP9 Level 5.1
630 LEVEL_VP9_5_2, ///< VP9 Level 5.2
631 LEVEL_VP9_6, ///< VP9 Level 6
632 LEVEL_VP9_6_1, ///< VP9 Level 6.1
633 LEVEL_VP9_6_2, ///< VP9 Level 6.2
634
635 // Dolby Vision levels
636 LEVEL_DV_MAIN_HD_24 = _C2_PL_DV_BASE, ///< Dolby Vision main tier hd24
637 LEVEL_DV_MAIN_HD_30, ///< Dolby Vision main tier hd30
638 LEVEL_DV_MAIN_FHD_24, ///< Dolby Vision main tier fhd24
639 LEVEL_DV_MAIN_FHD_30, ///< Dolby Vision main tier fhd30
640 LEVEL_DV_MAIN_FHD_60, ///< Dolby Vision main tier fhd60
641 LEVEL_DV_MAIN_UHD_24, ///< Dolby Vision main tier uhd24
642 LEVEL_DV_MAIN_UHD_30, ///< Dolby Vision main tier uhd30
643 LEVEL_DV_MAIN_UHD_48, ///< Dolby Vision main tier uhd48
644 LEVEL_DV_MAIN_UHD_60, ///< Dolby Vision main tier uhd60
645
646 LEVEL_DV_HIGH_HD_24 = _C2_PL_DV_BASE + 0x100, ///< Dolby Vision high tier hd24
647 LEVEL_DV_HIGH_HD_30, ///< Dolby Vision high tier hd30
648 LEVEL_DV_HIGH_FHD_24, ///< Dolby Vision high tier fhd24
649 LEVEL_DV_HIGH_FHD_30, ///< Dolby Vision high tier fhd30
650 LEVEL_DV_HIGH_FHD_60, ///< Dolby Vision high tier fhd60
651 LEVEL_DV_HIGH_UHD_24, ///< Dolby Vision high tier uhd24
652 LEVEL_DV_HIGH_UHD_30, ///< Dolby Vision high tier uhd30
653 LEVEL_DV_HIGH_UHD_48, ///< Dolby Vision high tier uhd48
654 LEVEL_DV_HIGH_UHD_60, ///< Dolby Vision high tier uhd60
655
656 // AV1 levels
657 LEVEL_AV1_2 = _C2_PL_AV1_BASE , ///< AV1 Level 2
658 LEVEL_AV1_2_1, ///< AV1 Level 2.1
659 LEVEL_AV1_2_2, ///< AV1 Level 2.2
660 LEVEL_AV1_2_3, ///< AV1 Level 2.3
661 LEVEL_AV1_3, ///< AV1 Level 3
662 LEVEL_AV1_3_1, ///< AV1 Level 3.1
663 LEVEL_AV1_3_2, ///< AV1 Level 3.2
664 LEVEL_AV1_3_3, ///< AV1 Level 3.3
665 LEVEL_AV1_4, ///< AV1 Level 4
666 LEVEL_AV1_4_1, ///< AV1 Level 4.1
667 LEVEL_AV1_4_2, ///< AV1 Level 4.2
668 LEVEL_AV1_4_3, ///< AV1 Level 4.3
669 LEVEL_AV1_5, ///< AV1 Level 5
670 LEVEL_AV1_5_1, ///< AV1 Level 5.1
671 LEVEL_AV1_5_2, ///< AV1 Level 5.2
672 LEVEL_AV1_5_3, ///< AV1 Level 5.3
673 LEVEL_AV1_6, ///< AV1 Level 6
674 LEVEL_AV1_6_1, ///< AV1 Level 6.1
675 LEVEL_AV1_6_2, ///< AV1 Level 6.2
676 LEVEL_AV1_6_3, ///< AV1 Level 6.3
677 LEVEL_AV1_7, ///< AV1 Level 7
678 LEVEL_AV1_7_1, ///< AV1 Level 7.1
679 LEVEL_AV1_7_2, ///< AV1 Level 7.2
680 LEVEL_AV1_7_3, ///< AV1 Level 7.3
681 };
682
683 struct C2ProfileLevelStruct {
684 C2Config::profile_t profile; ///< coding profile
685 C2Config::level_t level; ///< coding level
686
687 C2ProfileLevelStruct(
688 C2Config::profile_t profile_ = C2Config::PROFILE_UNUSED,
689 C2Config::level_t level_ = C2Config::LEVEL_UNUSED)
profileC2ProfileLevelStruct690 : profile(profile_), level(level_) { }
691
692 DEFINE_AND_DESCRIBE_C2STRUCT(ProfileLevel)
693 C2FIELD(profile, "profile")
694 C2FIELD(level, "level")
695 };
696
697 // TODO: may need to make this explicit (have .set member)
698 typedef C2StreamParam<C2Info, C2ProfileLevelStruct, kParamIndexProfileLevel>
699 C2StreamProfileLevelInfo;
700 constexpr char C2_PARAMKEY_PROFILE_LEVEL[] = "coded.pl";
701
702 /**
703 * Codec-specific initialization data.
704 *
705 * This is initialization data for the codec.
706 *
707 * For AVC/HEVC, these are the concatenated SPS/PPS/VPS NALs.
708 *
709 * TODO: define for other codecs.
710 */
711 typedef C2StreamParam<C2Info, C2BlobValue, kParamIndexInitData> C2StreamInitDataInfo;
712 constexpr char C2_PARAMKEY_INIT_DATA[] = "coded.init-data";
713
714 /**
715 * Supplemental Data.
716 *
717 * This is coding-specific supplemental informational data, e.g. SEI for AVC/HEVC.
718 * This structure is not a configuration so it does not have a parameter key.
719 * This structure shall be returned in the configuration update, and can be repeated as needed
720 * in the same update.
721 */
722 C2ENUM(C2Config::supplemental_info_t, uint32_t,
723 INFO_NONE = 0,
724
725 INFO_PREFIX_SEI_UNIT = 0x10000, ///< prefix SEI payload types add this flag
726 INFO_SUFFIX_SEI_UNIT = 0x20000, ///< suffix SEI payload types add this flag
727
728 INFO_SEI_USER_DATA = INFO_PREFIX_SEI_UNIT | 4, ///< closed-captioning data (ITU-T T35)
729 INFO_SEI_MDCV = INFO_PREFIX_SEI_UNIT | 137, ///< mastering display color volume
730 INFO_SET_USER_DATA_SFX = INFO_SUFFIX_SEI_UNIT | 4, ///< closed-captioning data (ITU-T T35)
731
732 INFO_VENDOR_START = 0x70000000
733 )
734
735 struct C2SupplementalDataStruct {
C2SupplementalDataStructC2SupplementalDataStruct736 C2SupplementalDataStruct()
737 : type_(INFO_NONE) { }
738
C2SupplementalDataStructC2SupplementalDataStruct739 C2SupplementalDataStruct(
740 size_t flexCount, C2Config::supplemental_info_t type, std::vector<uint8_t> data_)
741 : type_(type) {
742 memcpy(data, &data_[0], c2_min(data_.size(), flexCount));
743 }
744
745 C2Config::supplemental_info_t type_;
746 uint8_t data[];
747
748 DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(SupplementalData, data)
749 C2FIELD(type_, "type")
750 C2FIELD(data, "data")
751 };
752 typedef C2StreamParam<C2Info, C2SupplementalDataStruct, kParamIndexSupplementalData>
753 C2StreamSupplementalDataInfo;
754
755 /**
756 * Supplemental Data Subscription
757 */
758 typedef C2StreamParam<C2Tuning, C2SimpleArrayStruct<C2Config::supplemental_info_t>,
759 kParamIndexSubscribedSupplementalData>
760 C2StreamSubscribedSupplementalDataTuning;
761 constexpr char C2_PARAMKEY_SUBSCRIBED_SUPPLEMENTAL_DATA[] = "output.subscribed-supplemental";
762
763 /* ---------------------------------- pipeline characteristics ---------------------------------- */
764
765 /**
766 * Media-type.
767 *
768 * This is defined for both port and stream, but stream media type may be a subtype of the
769 * port media type.
770 */
771 typedef C2PortParam<C2Setting, C2StringValue, kParamIndexMediaType> C2PortMediaTypeSetting;
772 constexpr char C2_PARAMKEY_INPUT_MEDIA_TYPE[] = "input.media-type";
773 constexpr char C2_PARAMKEY_OUTPUT_MEDIA_TYPE[] = "output.media-type";
774
775 typedef C2StreamParam<C2Setting, C2StringValue, kParamIndexMediaType> C2StreamMediaTypeSetting;
776
777 /**
778 * Pipeline delays.
779 *
780 * Input delay is the number of additional input frames requested by the component to process
781 * an input frame.
782 *
783 * Output delay is the number of additional output frames that need to be generated before an
784 * output can be released by the component.
785 *
786 * Pipeline delay is the number of additional frames that are processed at one time by the
787 * component.
788 *
789 * As these may vary from frame to frame, the number is the maximum required value. E.g. if
790 * input delay is 0, the component is expected to consume each frame queued even if no further
791 * frames are queued. Similarly, if input delay is 1, as long as there are always exactly 2
792 * outstanding input frames queued to the component, it shall produce output.
793 */
794
795 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexDelay | C2Param::CoreIndex::IS_REQUEST_FLAG>
796 C2PortRequestedDelayTuning;
797 constexpr char C2_PARAMKEY_INPUT_DELAY_REQUEST[] = "input.delay"; // deprecated
798 constexpr char C2_PARAMKEY_OUTPUT_DELAY_REQUEST[] = "output.delay"; // deprecated
799
800 typedef C2GlobalParam<C2Tuning, C2Uint32Value,
801 kParamIndexDelay | C2Param::CoreIndex::IS_REQUEST_FLAG>
802 C2RequestedPipelineDelayTuning;
803 constexpr char C2_PARAMKEY_PIPELINE_DELAY_REQUEST[] = "algo.delay"; // deprecated
804
805 // read-only
806 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexDelay> C2PortDelayTuning;
807 typedef C2PortDelayTuning C2PortActualDelayTuning; // deprecated
808 constexpr char C2_PARAMKEY_INPUT_DELAY[] = "input.delay";
809 constexpr char C2_PARAMKEY_OUTPUT_DELAY[] = "output.delay";
810
811 // read-only
812 typedef C2GlobalParam<C2Tuning, C2Uint32Value, kParamIndexDelay> C2PipelineDelayTuning;
813 typedef C2PipelineDelayTuning C2ActualPipelineDelayTuning; // deprecated
814 constexpr char C2_PARAMKEY_PIPELINE_DELAY[] = "algo.delay";
815
816 /**
817 * Enable/disable low latency mode.
818 * If true, low latency is preferred over low power. Disable power optimizations that
819 * may result in increased latency. For decoders, this means that the decoder does not
820 * hold input and output data more than required by the codec standards.
821 */
822 typedef C2GlobalParam<C2Tuning, C2EasyBoolValue, kParamIndexLowLatencyMode>
823 C2GlobalLowLatencyModeTuning;
824 constexpr char C2_PARAMKEY_LOW_LATENCY_MODE[] = "algo.low-latency";
825
826 /**
827 * Reference characteristics.
828 *
829 * The component may hold onto input and output buffers even after completing the corresponding
830 * work item.
831 *
832 * Max reference age is the longest number of additional frame processing that a component may
833 * hold onto a buffer for. Max reference count is the number of buffers that a component may
834 * hold onto at the same time at the worst case. These numbers assume single frame per buffers.
835 *
836 * Use max-uint32 if there is no limit for the max age or count.
837 */
838 typedef C2StreamParam<C2Tuning, C2Uint32Value, kParamIndexMaxReferenceAge>
839 C2StreamMaxReferenceAgeTuning;
840 constexpr char C2_PARAMKEY_INPUT_MAX_REFERENCE_AGE[] = "input.reference.max-age";
841 constexpr char C2_PARAMKEY_OUTPUT_MAX_REFERENCE_AGE[] = "output.reference.max-age";
842
843 typedef C2StreamParam<C2Tuning, C2Uint32Value, kParamIndexMaxReferenceCount>
844 C2StreamMaxReferenceCountTuning;
845 constexpr char C2_PARAMKEY_INPUT_MAX_REFERENCE_COUNT[] = "input.reference.max-count";
846 constexpr char C2_PARAMKEY_OUTPUT_MAX_REFERENCE_COUNT[] = "output.reference.max-count";
847
848 /**
849 * Output reordering.
850 *
851 * The size of the window to use for output buffer reordering. 0 is interpreted as 1.
852 */
853 // output only
854 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexReorderBufferDepth>
855 C2PortReorderBufferDepthTuning;
856 constexpr char C2_PARAMKEY_OUTPUT_REORDER_DEPTH[] = "output.reorder.depth";
857
858 C2ENUM(C2Config::ordinal_key_t, uint32_t,
859 ORDINAL,
860 TIMESTAMP,
861 CUSTOM)
862
863 // read-only, output only
864 typedef C2PortParam<C2Setting, C2SimpleValueStruct<C2Config::ordinal_key_t>, kParamIndexReorderKey>
865 C2PortReorderKeySetting;
866 constexpr char C2_PARAMKEY_OUTPUT_REORDER_KEY[] = "output.reorder.key";
867
868 /**
869 * Stream count.
870 */
871 // private
872 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexStreamCount> C2PortStreamCountTuning;
873 constexpr char C2_PARAMKEY_INPUT_STREAM_COUNT[] = "input.stream-count";
874 constexpr char C2_PARAMKEY_OUTPUT_STREAM_COUNT[] = "output.stream-count";
875
876 /**
877 * Config update subscription.
878 */
879 // private
880 typedef C2GlobalParam<C2Tuning, C2Uint32Array, kParamIndexSubscribedParamIndices>
881 C2SubscribedParamIndicesTuning;
882 constexpr char C2_PARAMKEY_SUBSCRIBED_PARAM_INDICES[] = "output.subscribed-indices";
883
884 /**
885 * Suggested buffer (C2Frame) count. This is a suggestion by the component for the number of
886 * input and output frames allocated for the component's use in the buffer pools.
887 *
888 * Component shall set the acceptable range of buffers allocated for it. E.g. client shall
889 * allocate at least the minimum required value.
890 */
891 // read-only
892 typedef C2PortParam<C2Tuning, C2Uint64Array, kParamIndexSuggestedBufferCount>
893 C2PortSuggestedBufferCountTuning;
894 constexpr char C2_PARAMKEY_INPUT_SUGGESTED_BUFFER_COUNT[] = "input.buffers.pool-size";
895 constexpr char C2_PARAMKEY_OUTPUT_SUGGESTED_BUFFER_COUNT[] = "output.buffers.pool-size";
896
897 /**
898 * Input/output batching.
899 *
900 * For input, component requests that client batches work in batches of specified size. For output,
901 * client requests that the component batches work completion in given batch size.
902 * Value 0 means don't care.
903 */
904 typedef C2PortParam<C2Tuning, C2Uint64Array, kParamIndexBatchSize> C2PortBatchSizeTuning;
905 constexpr char C2_PARAMKEY_INPUT_BATCH_SIZE[] = "input.buffers.batch-size";
906 constexpr char C2_PARAMKEY_OUTPUT_BATCH_SIZE[] = "output.buffers.batch-size";
907
908 /**
909 * Current & last work ordinals.
910 *
911 * input port: last work queued to component.
912 * output port: last work completed by component.
913 * global: current work.
914 */
915 typedef C2PortParam<C2Tuning, C2WorkOrdinalStruct, kParamIndexLastWorkQueued> C2LastWorkQueuedTuning;
916 typedef C2GlobalParam<C2Tuning, C2WorkOrdinalStruct, kParamIndexCurrentWork> C2CurrentWorkTuning;
917
918
919 /* ------------------------------------- memory allocation ------------------------------------- */
920
921 /**
922 * Allocators to use.
923 *
924 * These are requested by the component.
925 *
926 * If none specified, client will use the default allocator ID based on the component domain and
927 * kind.
928 */
929 typedef C2PortParam<C2Tuning, C2SimpleArrayStruct<C2Allocator::id_t>, kParamIndexAllocators>
930 C2PortAllocatorsTuning;
931 constexpr char C2_PARAMKEY_INPUT_ALLOCATORS[] = "input.buffers.allocator-ids";
932 constexpr char C2_PARAMKEY_OUTPUT_ALLOCATORS[] = "output.buffers.allocator-ids";
933
934 typedef C2GlobalParam<C2Tuning, C2SimpleArrayStruct<C2Allocator::id_t>, kParamIndexAllocators>
935 C2PrivateAllocatorsTuning;
936 constexpr char C2_PARAMKEY_PRIVATE_ALLOCATORS[] = "algo.buffers.allocator-ids";
937
938 /**
939 * Allocator to use for outputting to surface.
940 *
941 * Components can optionally request allocator type for outputting to surface.
942 *
943 * If none specified, client will use the default BufferQueue-backed allocator ID for outputting to
944 * surface.
945 */
946 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexSurfaceAllocator>
947 C2PortSurfaceAllocatorTuning;
948 constexpr char C2_PARAMKEY_OUTPUT_SURFACE_ALLOCATOR[] = "output.buffers.surface-allocator-id";
949
950 /**
951 * Block pools to use.
952 *
953 * These are allocated by the client for the component using the allocator IDs specified by the
954 * component. This is not used for the input port.
955 */
956 typedef C2PortParam<C2Tuning, C2SimpleArrayStruct<C2BlockPool::local_id_t>, kParamIndexBlockPools>
957 C2PortBlockPoolsTuning;
958 constexpr char C2_PARAMKEY_OUTPUT_BLOCK_POOLS[] = "output.buffers.pool-ids";
959
960 typedef C2GlobalParam<C2Tuning, C2SimpleArrayStruct<C2BlockPool::local_id_t>, kParamIndexBlockPools>
961 C2PrivateBlockPoolsTuning;
962 constexpr char C2_PARAMKEY_PRIVATE_BLOCK_POOLS[] = "algo.buffers.pool-ids";
963
964 /**
965 * The max number of private allocations at any one time by the component.
966 * (This is an array with a corresponding value for each private allocator)
967 */
968 typedef C2GlobalParam<C2Tuning, C2Uint32Array, kParamIndexMaxReferenceCount>
969 C2MaxPrivateBufferCountTuning;
970 constexpr char C2_PARAMKEY_MAX_PRIVATE_BUFFER_COUNT[] = "algo.buffers.max-count";
971
972 /**
973 * Buffer type
974 *
975 * This is provided by the component for the client to allocate the proper buffer type for the
976 * input port, and can be provided by the client to control the buffer type for the output.
977 */
978 // private
979 typedef C2StreamParam<C2Setting, C2SimpleValueStruct<C2EasyEnum<C2BufferData::type_t>>,
980 kParamIndexBufferType>
981 C2StreamBufferTypeSetting;
982 constexpr char C2_PARAMKEY_INPUT_STREAM_BUFFER_TYPE[] = "input.buffers.type";
983 constexpr char C2_PARAMKEY_OUTPUT_STREAM_BUFFER_TYPE[] = "output.buffers.type";
984
985 /**
986 * Memory usage.
987 *
988 * Suggested by component for input and negotiated between client and component for output.
989 */
990 typedef C2StreamParam<C2Tuning, C2Uint64Value, kParamIndexUsage> C2StreamUsageTuning;
991 constexpr char C2_PARAMKEY_INPUT_STREAM_USAGE[] = "input.buffers.usage";
992 constexpr char C2_PARAMKEY_OUTPUT_STREAM_USAGE[] = "output.buffers.usage";
993
994 /**
995 * Picture (video or image frame) size.
996 */
997 struct C2PictureSizeStruct {
C2PictureSizeStructC2PictureSizeStruct998 inline C2PictureSizeStruct()
999 : width(0), height(0) { }
1000
C2PictureSizeStructC2PictureSizeStruct1001 inline C2PictureSizeStruct(uint32_t width_, uint32_t height_)
1002 : width(width_), height(height_) { }
1003
1004 uint32_t width; ///< video width
1005 uint32_t height; ///< video height
1006
1007 DEFINE_AND_DESCRIBE_C2STRUCT(PictureSize)
1008 C2FIELD(width, "width")
1009 C2FIELD(height, "height")
1010 };
1011
1012 /**
1013 * Out of memory signaling
1014 *
1015 * This is a configuration for the client to mark that it cannot allocate necessary private and/
1016 * or output buffers to continue operation, and to signal the failing configuration.
1017 */
1018 struct C2OutOfMemoryStruct {
1019 C2BlockPool::local_id_t pool; ///< pool ID that failed the allocation
1020 uint64_t usage; ///< memory usage used
1021 C2PictureSizeStruct planar; ///< buffer dimensions to be allocated if 2D
1022 uint32_t format; ///< pixel format to be used if 2D
1023 uint32_t capacity; ///< buffer capacity to be allocated if 1D
1024 c2_bool_t outOfMemory; ///< true if component is out of memory
1025
1026 DEFINE_AND_DESCRIBE_C2STRUCT(OutOfMemory)
1027 C2FIELD(pool, "pool")
1028 C2FIELD(usage, "usage")
1029 C2FIELD(planar, "planar")
1030 C2FIELD(format, "format")
1031 C2FIELD(capacity, "capacity")
1032 C2FIELD(outOfMemory, "out-of-memory")
1033 };
1034
1035 typedef C2GlobalParam<C2Tuning, C2OutOfMemoryStruct, kParamIndexOutOfMemory> C2OutOfMemoryTuning;
1036 constexpr char C2_PARAMKEY_OUT_OF_MEMORY[] = "algo.oom";
1037
1038 /**
1039 * Max buffer size
1040 *
1041 * This is a hint provided by the component for the maximum buffer size expected on a stream for the
1042 * current configuration on its input and output streams. This is communicated to clients so they
1043 * can preallocate input buffers, or configure downstream components that require a maximum size on
1044 * their buffers.
1045 *
1046 * Read-only. Required to be provided by components on all compressed streams.
1047 */
1048 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexMaxBufferSize> C2StreamMaxBufferSizeInfo;
1049 constexpr char C2_PARAMKEY_INPUT_MAX_BUFFER_SIZE[] = "input.buffers.max-size";
1050 constexpr char C2_PARAMKEY_OUTPUT_MAX_BUFFER_SIZE[] = "output.buffers.max-size";
1051
1052 /* ---------------------------------------- misc. state ---------------------------------------- */
1053
1054 /**
1055 * Tripped state,
1056 *
1057 * This state exists to be able to provide reasoning for a tripped state during normal
1058 * interface operations, as well as to allow client to trip the component on demand.
1059 */
1060 typedef C2GlobalParam<C2Tuning, C2BoolValue, kParamIndexTripped>
1061 C2TrippedTuning;
1062 constexpr char C2_PARAMKEY_TRIPPED[] = "algo.tripped";
1063
1064 /**
1065 * Configuration counters.
1066 *
1067 * Configurations are tracked using three counters. The input counter is incremented exactly
1068 * once with each work accepted by the component. The output counter is incremented exactly
1069 * once with each work completed by the component (in the order of work completion). The
1070 * global counter is incremented exactly once during to each config() call. These counters
1071 * shall be read-only.
1072 *
1073 * TODO: these should be counters.
1074 */
1075 typedef C2PortParam<C2Tuning, C2Uint64Value, kParamIndexConfigCounter> C2PortConfigCounterTuning;
1076 typedef C2GlobalParam<C2Tuning, C2Uint64Value, kParamIndexConfigCounter> C2ConfigCounterTuning;
1077 constexpr char C2_PARAMKEY_INPUT_COUNTER[] = "input.buffers.counter";
1078 constexpr char C2_PARAMKEY_OUTPUT_COUNTER[] = "output.buffers.counter";
1079 constexpr char C2_PARAMKEY_CONFIG_COUNTER[] = "algo.config.counter";
1080
1081 /* ----------------------------------------- resources ----------------------------------------- */
1082
1083 /**
1084 * Resources needed and resources reserved for current configuration.
1085 *
1086 * Resources are tracked as a vector of positive numbers. Available resources are defined by
1087 * the vendor.
1088 *
1089 * By default, no resources are reserved for a component. If resource reservation is successful,
1090 * the component shall be able to use those resources exclusively. If however, the component is
1091 * not using all of the reserved resources, those may be shared with other components.
1092 *
1093 * TODO: define some of the resources.
1094 */
1095 typedef C2GlobalParam<C2Tuning, C2Uint64Array, kParamIndexResourcesNeeded> C2ResourcesNeededTuning;
1096 typedef C2GlobalParam<C2Tuning, C2Uint64Array, kParamIndexResourcesReserved>
1097 C2ResourcesReservedTuning;
1098 constexpr char C2_PARAMKEY_RESOURCES_NEEDED[] = "resources.needed";
1099 constexpr char C2_PARAMKEY_RESOURCES_RESERVED[] = "resources.reserved";
1100
1101 /**
1102 * Operating rate.
1103 *
1104 * Operating rate is the expected rate of work through the component. Negative values is
1105 * invalid.
1106 *
1107 * TODO: this could distinguish set value
1108 */
1109 typedef C2GlobalParam<C2Tuning, C2FloatValue, kParamIndexOperatingRate> C2OperatingRateTuning;
1110 constexpr char C2_PARAMKEY_OPERATING_RATE[] = "algo.rate";
1111
1112 /**
1113 * Realtime / operating point.
1114 *
1115 * Priority value defines the operating point for the component. Operating points are defined by
1116 * the vendor. Priority value of 0 means that the client requires operation at the given operating
1117 * rate. Priority values -1 and below define operating points in decreasing performance. In this
1118 * case client expects best effort without exceeding the specific operating point. This allows
1119 * client to run components deeper in the background by using larger priority values. In these
1120 * cases operating rate is a hint for the maximum rate that the client anticipates.
1121 *
1122 * Operating rate and priority are used in tandem. E.g. if there are components that run at a
1123 * higher operating point (priority) it will make more resources available for components at
1124 * a lower operating point, so operating rate can be used to gate those components.
1125 *
1126 * Positive priority values are not defined at the moment and shall be treated equivalent to 0.
1127 */
1128 typedef C2GlobalParam<C2Tuning, C2Int32Value, kParamIndexRealTimePriority>
1129 C2RealTimePriorityTuning;
1130 constexpr char C2_PARAMKEY_PRIORITY[] = "algo.priority";
1131
1132 /* ------------------------------------- protected content ------------------------------------- */
1133
1134 /**
1135 * Secure mode.
1136 */
1137 C2ENUM(C2Config::secure_mode_t, uint32_t,
1138 SM_UNPROTECTED, ///< no content protection
1139 SM_READ_PROTECTED, ///< input and output buffers shall be protected from reading
1140 )
1141
1142 typedef C2GlobalParam<C2Tuning, C2SimpleValueStruct<C2Config::secure_mode_t>, kParamIndexSecureMode>
1143 C2SecureModeTuning;
1144 constexpr char C2_PARAMKEY_SECURE_MODE[] = "algo.secure-mode";
1145
1146 /* ===================================== ENCODER COMPONENTS ===================================== */
1147
1148 /**
1149 * Bitrate
1150 */
1151 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexBitrate> C2StreamBitrateInfo;
1152 constexpr char C2_PARAMKEY_BITRATE[] = "coded.bitrate";
1153
1154 /**
1155 * Bitrate mode.
1156 *
1157 * TODO: refine this with bitrate ranges and suggested window
1158 */
1159 C2ENUM(C2Config::bitrate_mode_t, uint32_t,
1160 BITRATE_CONST_SKIP_ALLOWED = 0, ///< constant bitrate, frame skipping allowed
1161 BITRATE_CONST = 1, ///< constant bitrate, keep all frames
1162 BITRATE_VARIABLE_SKIP_ALLOWED = 2, ///< bitrate can vary, frame skipping allowed
1163 BITRATE_VARIABLE = 3, ///< bitrate can vary, keep all frames
1164 BITRATE_IGNORE = 7, ///< bitrate can be exceeded at will to achieve
1165 ///< quality or other settings
1166
1167 // bitrate modes are composed of the following flags
1168 BITRATE_FLAG_KEEP_ALL_FRAMES = 1,
1169 BITRATE_FLAG_CAN_VARY = 2,
1170 BITRATE_FLAG_CAN_EXCEED = 4,
1171 )
1172
1173 typedef C2StreamParam<C2Tuning, C2SimpleValueStruct<C2Config::bitrate_mode_t>,
1174 kParamIndexBitrateMode>
1175 C2StreamBitrateModeTuning;
1176 constexpr char C2_PARAMKEY_BITRATE_MODE[] = "algo.bitrate-mode";
1177
1178 /**
1179 * Quality.
1180 *
1181 * This is defined by each component, the higher the better the output quality at the expense of
1182 * less compression efficiency. This setting is defined for the output streams in case the
1183 * component can support varying quality on each stream, or as an output port tuning in case the
1184 * quality is global to all streams.
1185 */
1186 typedef C2StreamParam<C2Tuning, C2Uint32Value, kParamIndexQuality> C2StreamQualityTuning;
1187 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexQuality> C2QualityTuning;
1188 constexpr char C2_PARAMKEY_QUALITY[] = "algo.quality";
1189
1190 /**
1191 * Complexity.
1192 *
1193 * This is defined by each component, this higher the value, the more resources the component
1194 * will use to produce better quality at the same compression efficiency or better compression
1195 * efficiency at the same quality. This setting is defined for the output streams in case the
1196 * component can support varying complexity on each stream, or as an output port tuning in case the
1197 * quality is global to all streams
1198 */
1199 typedef C2StreamParam<C2Tuning, C2Uint32Value, kParamIndexComplexity> C2StreamComplexityTuning;
1200 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexComplexity> C2ComplexityTuning;
1201 constexpr char C2_PARAMKEY_COMPLEXITY[] = "algo.complexity";
1202
1203 /**
1204 * Header (init-data) handling around sync frames.
1205 */
1206 C2ENUM(C2Config::prepend_header_mode_t, uint32_t,
1207 /**
1208 * don't prepend header. Signal header only through C2StreamInitDataInfo.
1209 */
1210 PREPEND_HEADER_TO_NONE,
1211
1212 /**
1213 * prepend header before the first output frame and thereafter before the next sync frame
1214 * if it changes.
1215 */
1216 PREPEND_HEADER_ON_CHANGE,
1217
1218 /**
1219 * prepend header before every sync frame.
1220 */
1221 PREPEND_HEADER_TO_ALL_SYNC,
1222 )
1223
1224 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Config::prepend_header_mode_t>,
1225 kParamIndexPrependHeaderMode>
1226 C2PrependHeaderModeSetting;
1227 constexpr char C2_PARAMKEY_PREPEND_HEADER_MODE[] = "output.buffers.prepend-header";
1228
1229 /* =================================== IMAGE/VIDEO COMPONENTS =================================== */
1230
1231 /*
1232 * Order of transformation is:
1233 *
1234 * crop => (scaling => scaled-crop) => sample-aspect-ratio => flip => rotation
1235 */
1236
1237 /**
1238 * Picture (image- and video frame) size.
1239 *
1240 * This is used for the output of the video decoder, and the input of the video encoder.
1241 */
1242 typedef C2StreamParam<C2Info, C2PictureSizeStruct, kParamIndexPictureSize> C2StreamPictureSizeInfo;
1243 constexpr char C2_PARAMKEY_PICTURE_SIZE[] = "raw.size";
1244
1245 /**
1246 * Crop rectangle.
1247 */
1248 struct C2RectStruct : C2Rect {
1249 C2RectStruct() = default;
C2RectStructC2RectStruct1250 C2RectStruct(const C2Rect &rect) : C2Rect(rect) { }
1251
1252 bool operator==(const C2RectStruct &) = delete;
1253 bool operator!=(const C2RectStruct &) = delete;
1254
1255 DEFINE_AND_DESCRIBE_BASE_C2STRUCT(Rect)
1256 C2FIELD(width, "width")
1257 C2FIELD(height, "height")
1258 C2FIELD(left, "left")
1259 C2FIELD(top, "top")
1260 };
1261
1262 typedef C2StreamParam<C2Info, C2RectStruct, kParamIndexCropRect> C2StreamCropRectInfo;
1263 constexpr char C2_PARAMKEY_CROP_RECT[] = "raw.crop";
1264 constexpr char C2_PARAMKEY_CODED_CROP_RECT[] = "coded.crop";
1265
1266 /**
1267 * Pixel format.
1268 */
1269 // TODO: define some
1270
1271 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexPixelFormat> C2StreamPixelFormatInfo;
1272 constexpr char C2_PARAMKEY_PIXEL_FORMAT[] = "raw.pixel-format";
1273
1274 /**
1275 * Extended rotation information also incorporating a flip.
1276 *
1277 * Rotation is counter clock-wise.
1278 */
1279 struct C2RotationStruct {
1280 C2RotationStruct(int32_t rotation = 0)
1281 : flip(0), value(rotation) { }
1282
1283 int32_t flip; ///< horizontal flip (left-right flip applied prior to rotation)
1284 int32_t value; ///< rotation in degrees counter clockwise
1285
1286 DEFINE_AND_DESCRIBE_BASE_C2STRUCT(Rotation)
1287 C2FIELD(flip, "flip")
1288 C2FIELD(value, "value")
1289 };
1290
1291 typedef C2StreamParam<C2Info, C2RotationStruct, kParamIndexRotation> C2StreamRotationInfo;
1292 constexpr char C2_PARAMKEY_ROTATION[] = "raw.rotation";
1293 constexpr char C2_PARAMKEY_VUI_ROTATION[] = "coded.vui.rotation";
1294
1295 /**
1296 * Pixel (sample) aspect ratio.
1297 */
1298 typedef C2StreamParam<C2Info, C2PictureSizeStruct, kParamIndexPixelAspectRatio>
1299 C2StreamPixelAspectRatioInfo;
1300 constexpr char C2_PARAMKEY_PIXEL_ASPECT_RATIO[] = "raw.sar";
1301 constexpr char C2_PARAMKEY_VUI_PIXEL_ASPECT_RATIO[] = "coded.vui.sar";
1302
1303 /**
1304 * In-line scaling.
1305 *
1306 * Components can optionally support scaling of raw image/video frames. Or scaling only a
1307 * portion of raw image/video frames (scaled-crop).
1308 */
1309
1310 C2ENUM(C2Config::scaling_method_t, uint32_t,
1311 SCALING_ARBITRARY, ///< arbitrary, unspecified
1312 )
1313
1314 typedef C2StreamParam<C2Tuning, C2SimpleValueStruct<C2Config::scaling_method_t>,
1315 kParamIndexScalingMethod>
1316 C2StreamScalingMethodTuning;
1317 constexpr char C2_PARAMKEY_SCALING_MODE[] = "raw.scaling-method";
1318
1319 typedef C2StreamParam<C2Tuning, C2PictureSizeStruct, kParamIndexScaledPictureSize>
1320 C2StreamScaledPictureSizeTuning;
1321 constexpr char C2_PARAMKEY_SCALED_PICTURE_SIZE[] = "raw.scaled-size";
1322
1323 typedef C2StreamParam<C2Tuning, C2RectStruct, kParamIndexScaledCropRect>
1324 C2StreamScaledCropRectTuning;
1325 constexpr char C2_PARAMKEY_SCALED_CROP_RECT[] = "raw.scaled-crop";
1326
1327 /* ------------------------------------- color information ------------------------------------- */
1328
1329 /**
1330 * Color Info
1331 *
1332 * Chroma location can vary for top and bottom fields, so use an array, that can have 0 to 2
1333 * values. Empty array is used for non YUV formats.
1334 */
1335
1336 struct C2Color {
1337 enum matrix_t : uint32_t; ///< matrix coefficient (YUV <=> RGB)
1338 enum plane_layout_t : uint32_t; ///< plane layout for flexible formats
1339 enum primaries_t : uint32_t; ///< color primaries and white point
1340 enum range_t : uint32_t; ///< range of color component values
1341 enum subsampling_t : uint32_t; ///< chroma subsampling
1342 enum transfer_t : uint32_t; ///< transfer function
1343 };
1344
1345 /// Chroma subsampling
1346 C2ENUM(C2Color::subsampling_t, uint32_t,
1347 MONOCHROME, ///< there are no Cr nor Cb planes
1348 MONOCHROME_ALPHA, ///< there are no Cr nor Cb planes, but there is an alpha plane
1349 RGB, ///< RGB
1350 RGBA, ///< RGBA
1351 YUV_420, ///< Cr and Cb planes are subsampled by 2 both horizontally and vertically
1352 YUV_422, ///< Cr and Cb planes are subsampled horizontally
1353 YUV_444, ///< Cr and Cb planes are not subsampled
1354 YUVA_444, ///< Cr and Cb planes are not subsampled, there is an alpha plane
1355 )
1356
1357 struct C2ChromaOffsetStruct {
1358 // chroma offsets defined by ITU
ITU_YUV_444C2ChromaOffsetStruct1359 constexpr static C2ChromaOffsetStruct ITU_YUV_444() { return { 0.0f, 0.0f }; }
ITU_YUV_422C2ChromaOffsetStruct1360 constexpr static C2ChromaOffsetStruct ITU_YUV_422() { return { 0.0f, 0.0f }; }
ITU_YUV_420_0C2ChromaOffsetStruct1361 constexpr static C2ChromaOffsetStruct ITU_YUV_420_0() { return { 0.0f, 0.5f }; }
ITU_YUV_420_1C2ChromaOffsetStruct1362 constexpr static C2ChromaOffsetStruct ITU_YUV_420_1() { return { 0.5f, 0.5f }; }
ITU_YUV_420_2C2ChromaOffsetStruct1363 constexpr static C2ChromaOffsetStruct ITU_YUV_420_2() { return { 0.0f, 0.0f }; }
ITU_YUV_420_3C2ChromaOffsetStruct1364 constexpr static C2ChromaOffsetStruct ITU_YUV_420_3() { return { 0.5f, 0.0f }; }
ITU_YUV_420_4C2ChromaOffsetStruct1365 constexpr static C2ChromaOffsetStruct ITU_YUV_420_4() { return { 0.0f, 1.0f }; }
ITU_YUV_420_5C2ChromaOffsetStruct1366 constexpr static C2ChromaOffsetStruct ITU_YUV_420_5() { return { 0.5f, 1.0f }; }
1367
1368 float x; ///< x offset in pixels (towards right)
1369 float y; ///< y offset in pixels (towards down)
1370
1371 DEFINE_AND_DESCRIBE_C2STRUCT(ChromaOffset)
1372 C2FIELD(x, "x")
1373 C2FIELD(y, "y")
1374 };
1375
1376 struct C2ColorInfoStruct {
C2ColorInfoStructC2ColorInfoStruct1377 C2ColorInfoStruct()
1378 : bitDepth(8), subsampling(C2Color::YUV_420) { }
1379
1380 uint32_t bitDepth;
1381 C2Color::subsampling_t subsampling;
1382 C2ChromaOffsetStruct locations[]; // max 2 elements
1383
C2ColorInfoStructC2ColorInfoStruct1384 C2ColorInfoStruct(
1385 size_t /* flexCount */, uint32_t bitDepth_, C2Color::subsampling_t subsampling_)
1386 : bitDepth(bitDepth_), subsampling(subsampling_) { }
1387
C2ColorInfoStructC2ColorInfoStruct1388 C2ColorInfoStruct(
1389 size_t flexCount, uint32_t bitDepth_, C2Color::subsampling_t subsampling_,
1390 std::initializer_list<C2ChromaOffsetStruct> locations_)
1391 : bitDepth(bitDepth_), subsampling(subsampling_) {
1392 size_t ix = 0;
1393 for (const C2ChromaOffsetStruct &location : locations_) {
1394 if (ix == flexCount) {
1395 break;
1396 }
1397 locations[ix] = location;
1398 ++ix;
1399 }
1400 }
1401
1402 DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(ColorInfo, locations)
1403 C2FIELD(bitDepth, "bit-depth")
1404 C2FIELD(subsampling, "subsampling")
1405 C2FIELD(locations, "locations")
1406 };
1407
1408 typedef C2StreamParam<C2Info, C2ColorInfoStruct, kParamIndexColorInfo> C2StreamColorInfo;
1409 constexpr char C2_PARAMKEY_COLOR_INFO[] = "raw.color-format";
1410 constexpr char C2_PARAMKEY_CODED_COLOR_INFO[] = "coded.color-format";
1411
1412 /**
1413 * Color Aspects
1414 */
1415
1416 /* The meaning of the following enumerators is as described in ITU-T H.273. */
1417
1418 /// Range
1419 C2ENUM(C2Color::range_t, uint32_t,
1420 RANGE_UNSPECIFIED, ///< range is unspecified
1421 RANGE_FULL, ///< full range
1422 RANGE_LIMITED, ///< limited range
1423
1424 RANGE_VENDOR_START = 0x80, ///< vendor-specific range values start here
1425 RANGE_OTHER = 0XFF ///< max value, reserved for undefined values
1426 )
1427
1428 /// Color primaries
1429 C2ENUM(C2Color::primaries_t, uint32_t,
1430 PRIMARIES_UNSPECIFIED, ///< primaries are unspecified
1431 PRIMARIES_BT709, ///< Rec.ITU-R BT.709-6 or equivalent
1432 PRIMARIES_BT470_M, ///< Rec.ITU-R BT.470-6 System M or equivalent
1433 PRIMARIES_BT601_625, ///< Rec.ITU-R BT.601-6 625 or equivalent
1434 PRIMARIES_BT601_525, ///< Rec.ITU-R BT.601-6 525 or equivalent
1435 PRIMARIES_GENERIC_FILM, ///< Generic Film
1436 PRIMARIES_BT2020, ///< Rec.ITU-R BT.2020 or equivalent
1437 PRIMARIES_RP431, ///< SMPTE RP 431-2 or equivalent
1438 PRIMARIES_EG432, ///< SMPTE EG 432-1 or equivalent
1439 PRIMARIES_EBU3213, ///< EBU Tech.3213-E or equivalent
1440 ///
1441 PRIMARIES_VENDOR_START = 0x80, ///< vendor-specific primaries values start here
1442 PRIMARIES_OTHER = 0xff ///< max value, reserved for undefined values
1443 )
1444
1445 /// Transfer function
1446 C2ENUM(C2Color::transfer_t, uint32_t,
1447 TRANSFER_UNSPECIFIED, ///< transfer is unspecified
1448 TRANSFER_LINEAR, ///< Linear transfer characteristics
1449 TRANSFER_SRGB, ///< sRGB or equivalent
1450 TRANSFER_170M, ///< SMPTE 170M or equivalent (e.g. BT.601/709/2020)
1451 TRANSFER_GAMMA22, ///< Assumed display gamma 2.2
1452 TRANSFER_GAMMA28, ///< Assumed display gamma 2.8
1453 TRANSFER_ST2084, ///< SMPTE ST 2084 for 10/12/14/16 bit systems
1454 TRANSFER_HLG, ///< ARIB STD-B67 hybrid-log-gamma
1455
1456 TRANSFER_240M = 0x40, ///< SMPTE 240M or equivalent
1457 TRANSFER_XVYCC, ///< IEC 61966-2-4 or equivalent
1458 TRANSFER_BT1361, ///< Rec.ITU-R BT.1361 extended gamut
1459 TRANSFER_ST428, ///< SMPTE ST 428-1 or equivalent
1460 ///
1461 TRANSFER_VENDOR_START = 0x80, ///< vendor-specific transfer values start here
1462 TRANSFER_OTHER = 0xff ///< max value, reserved for undefined values
1463 )
1464
1465 /// Matrix coefficient
1466 C2ENUM(C2Color::matrix_t, uint32_t,
1467 MATRIX_UNSPECIFIED, ///< matrix coefficients are unspecified
1468 MATRIX_BT709, ///< Rec.ITU-R BT.709-5 or equivalent
1469 MATRIX_FCC47_73_682, ///< FCC Title 47 CFR 73.682 or equivalent (KR=0.30, KB=0.11)
1470 MATRIX_BT601, ///< Rec.ITU-R BT.470, BT.601-6 625 or equivalent
1471 MATRIX_240M, ///< SMPTE 240M or equivalent
1472 MATRIX_BT2020, ///< Rec.ITU-R BT.2020 non-constant luminance
1473 MATRIX_BT2020_CONSTANT, ///< Rec.ITU-R BT.2020 constant luminance
1474 MATRIX_VENDOR_START = 0x80, ///< vendor-specific matrix coefficient values start here
1475 MATRIX_OTHER = 0xff, ///< max value, reserved for undefined values
1476 )
1477
1478 struct C2ColorAspectsStruct {
1479 C2Color::range_t range;
1480 C2Color::primaries_t primaries;
1481 C2Color::transfer_t transfer;
1482 C2Color::matrix_t matrix;
1483
C2ColorAspectsStructC2ColorAspectsStruct1484 C2ColorAspectsStruct()
1485 : range(C2Color::RANGE_UNSPECIFIED),
1486 primaries(C2Color::PRIMARIES_UNSPECIFIED),
1487 transfer(C2Color::TRANSFER_UNSPECIFIED),
1488 matrix(C2Color::MATRIX_UNSPECIFIED) { }
1489
C2ColorAspectsStructC2ColorAspectsStruct1490 C2ColorAspectsStruct(C2Color::range_t range_, C2Color::primaries_t primaries_,
1491 C2Color::transfer_t transfer_, C2Color::matrix_t matrix_)
1492 : range(range_), primaries(primaries_), transfer(transfer_), matrix(matrix_) {}
1493
1494 DEFINE_AND_DESCRIBE_C2STRUCT(ColorAspects)
1495 C2FIELD(range, "range")
1496 C2FIELD(primaries, "primaries")
1497 C2FIELD(transfer, "transfer")
1498 C2FIELD(matrix, "matrix")
1499 };
1500
1501 typedef C2StreamParam<C2Info, C2ColorAspectsStruct, kParamIndexColorAspects>
1502 C2StreamColorAspectsInfo;
1503 constexpr char C2_PARAMKEY_COLOR_ASPECTS[] = "raw.color";
1504 constexpr char C2_PARAMKEY_VUI_COLOR_ASPECTS[] = "coded.vui.color";
1505
1506 /**
1507 * Default color aspects to use. These come from the container or client and shall be handled
1508 * according to the coding standard.
1509 */
1510 typedef C2StreamParam<C2Tuning, C2ColorAspectsStruct, kParamIndexDefaultColorAspects>
1511 C2StreamColorAspectsTuning;
1512 constexpr char C2_PARAMKEY_DEFAULT_COLOR_ASPECTS[] = "default.color";
1513
1514 /**
1515 * HDR Static Metadata Info.
1516 */
1517 struct C2ColorXyStruct {
1518 float x; ///< x color coordinate in xyY space [0-1]
1519 float y; ///< y color coordinate in xyY space [0-1]
1520
1521 DEFINE_AND_DESCRIBE_C2STRUCT(ColorXy)
1522 C2FIELD(x, "x")
1523 C2FIELD(y, "y")
1524 };
1525
1526 struct C2MasteringDisplayColorVolumeStruct {
1527 C2ColorXyStruct red; ///< coordinates of red display primary
1528 C2ColorXyStruct green; ///< coordinates of green display primary
1529 C2ColorXyStruct blue; ///< coordinates of blue display primary
1530 C2ColorXyStruct white; ///< coordinates of white point
1531
1532 float maxLuminance; ///< max display mastering luminance in cd/m^2
1533 float minLuminance; ///< min display mastering luminance in cd/m^2
1534
1535 DEFINE_AND_DESCRIBE_C2STRUCT(MasteringDisplayColorVolume)
1536 C2FIELD(red, "red")
1537 C2FIELD(green, "green")
1538 C2FIELD(blue, "blue")
1539 C2FIELD(white, "white")
1540
1541 C2FIELD(maxLuminance, "max-luminance")
1542 C2FIELD(minLuminance, "min-luminance")
1543 };
1544
1545 struct C2HdrStaticMetadataStruct {
1546 C2MasteringDisplayColorVolumeStruct mastering;
1547
1548 // content descriptors
1549 float maxCll; ///< max content light level (pixel luminance) in cd/m^2
1550 float maxFall; ///< max frame average light level (frame luminance) in cd/m^2
1551
1552 DEFINE_AND_DESCRIBE_BASE_C2STRUCT(HdrStaticMetadata)
1553 C2FIELD(mastering, "mastering")
1554 C2FIELD(maxCll, "max-cll")
1555 C2FIELD(maxFall, "max-fall")
1556 };
1557 typedef C2StreamParam<C2Info, C2HdrStaticMetadataStruct, kParamIndexHdrStaticMetadata>
1558 C2StreamHdrStaticInfo;
1559 constexpr char C2_PARAMKEY_HDR_STATIC_INFO[] = "raw.hdr-static-info";
1560
1561 /**
1562 * HDR10+ Metadata Info.
1563 */
1564 typedef C2StreamParam<C2Info, C2BlobValue, kParamIndexHdr10PlusMetadata>
1565 C2StreamHdr10PlusInfo;
1566 constexpr char C2_PARAMKEY_INPUT_HDR10_PLUS_INFO[] = "input.hdr10-plus-info";
1567 constexpr char C2_PARAMKEY_OUTPUT_HDR10_PLUS_INFO[] = "output.hdr10-plus-info";
1568
1569 /* ------------------------------------ block-based coding ----------------------------------- */
1570
1571 /**
1572 * Block-size, block count and block rate. Used to determine or communicate profile-level
1573 * requirements.
1574 */
1575 typedef C2StreamParam<C2Info, C2PictureSizeStruct, kParamIndexBlockSize> C2StreamBlockSizeInfo;
1576 constexpr char C2_PARAMKEY_BLOCK_SIZE[] = "coded.block-size";
1577
1578 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexBlockCount> C2StreamBlockCountInfo;
1579 constexpr char C2_PARAMKEY_BLOCK_COUNT[] = "coded.block-count";
1580
1581 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexBlockRate> C2StreamBlockRateInfo;
1582 constexpr char C2_PARAMKEY_BLOCK_RATE[] = "coded.block-rate";
1583
1584 /* ====================================== VIDEO COMPONENTS ====================================== */
1585
1586 /**
1587 * Frame rate (coded and port for raw data)
1588 *
1589 * Coded frame rates are what is represented in the compressed bitstream and should correspond to
1590 * the timestamp.
1591 *
1592 * Frame rates on raw ports should still correspond to the timestamps.
1593 *
1594 * For slow motion or timelapse recording, the timestamp shall be adjusted prior to feeding an
1595 * encoder, and the time stretch parameter should be used to signal the relationship between
1596 * timestamp and real-world time.
1597 */
1598 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexFrameRate> C2StreamFrameRateInfo;
1599 constexpr char C2_PARAMKEY_FRAME_RATE[] = "coded.frame-rate";
1600
1601 typedef C2PortParam<C2Info, C2FloatValue, kParamIndexFrameRate> C2PortFrameRateInfo;
1602 constexpr char C2_PARAMKEY_INPUT_FRAME_RATE[] = "input.frame-rate";
1603 constexpr char C2_PARAMKEY_OUTPUT_FRAME_RATE[] = "output.frame-rate";
1604
1605 /**
1606 * Time stretch. Ratio between real-world time and timestamp. E.g. time stretch of 4.0 means that
1607 * timestamp grows 1/4 the speed of real-world time (e.g. 4x slo-mo input). This can be used to
1608 * optimize encoding.
1609 */
1610 typedef C2PortParam<C2Info, C2FloatValue, kParamIndexTimeStretch> C2PortTimeStretchInfo;
1611 constexpr char C2_PARAMKEY_INPUT_TIME_STRETCH[] = "input.time-stretch";
1612 constexpr char C2_PARAMKEY_OUTPUT_TIME_STRETCH[] = "output.time-stretch";
1613
1614 /**
1615 * Max video frame size.
1616 */
1617 typedef C2StreamParam<C2Tuning, C2PictureSizeStruct, kParamIndexMaxPictureSize>
1618 C2StreamMaxPictureSizeTuning;
1619 typedef C2StreamMaxPictureSizeTuning C2MaxVideoSizeHintPortSetting;
1620 constexpr char C2_PARAMKEY_MAX_PICTURE_SIZE[] = "raw.max-size";
1621
1622 /**
1623 * Picture type mask.
1624 */
1625 C2ENUM(C2Config::picture_type_t, uint32_t,
1626 SYNC_FRAME = (1 << 0), ///< sync frame, e.g. IDR
1627 I_FRAME = (1 << 1), ///< intra frame that is completely encoded
1628 P_FRAME = (1 << 2), ///< inter predicted frame from previous frames
1629 B_FRAME = (1 << 3), ///< backward predicted (out-of-order) frame
1630 )
1631
1632 /**
1633 * Allowed picture types.
1634 */
1635 typedef C2StreamParam<C2Tuning, C2SimpleValueStruct<C2EasyEnum<C2Config::picture_type_t>>,
1636 kParamIndexPictureTypeMask>
1637 C2StreamPictureTypeMaskTuning;
1638 constexpr char C2_PARAMKEY_PICTURE_TYPE_MASK[] = "coding.picture-type-mask";
1639
1640 /**
1641 * Resulting picture type
1642 */
1643 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2EasyEnum<C2Config::picture_type_t>>,
1644 kParamIndexPictureType>
1645 C2StreamPictureTypeInfo;
1646 typedef C2StreamPictureTypeInfo C2StreamPictureTypeMaskInfo;
1647 constexpr char C2_PARAMKEY_PICTURE_TYPE[] = "coded.picture-type";
1648
1649 /**
1650 * GOP specification.
1651 *
1652 * GOP is specified in layers between sync frames, by specifying the number of specific type of
1653 * frames between the previous type (starting with sync frames for the first layer):
1654 *
1655 * E.g.
1656 * - 4 I frames between each sync frame
1657 * - 2 P frames between each I frame
1658 * - 1 B frame between each P frame
1659 *
1660 * [ { I, 4 }, { P, 2 }, { B, 1 } ] ==> (Sync)BPBPB IBPBPB IBPBPB IBPBPB IBPBPB (Sync)BPBPB
1661 *
1662 * For infinite GOP, I layer can be omitted (as the first frame is always a sync frame.):
1663 *
1664 * [ { P, MAX_UINT } ] ==> (Sync)PPPPPPPPPPPPPPPPPP...
1665 *
1666 * Sync frames can also be requested on demand, and as a time-based interval. For time-based
1667 * interval, if there hasn't been a sync frame in at least the given time, the next I frame shall
1668 * be encoded as a sync frame. For sync request, the next I frame shall be encoded as a sync frame.
1669 *
1670 * Temporal layering will determine GOP structure other than the I frame count between sync
1671 * frames.
1672 */
1673 struct C2GopLayerStruct {
C2GopLayerStructC2GopLayerStruct1674 C2GopLayerStruct() : type_((C2Config::picture_type_t)0), count(0) {}
C2GopLayerStructC2GopLayerStruct1675 C2GopLayerStruct(C2Config::picture_type_t type, uint32_t count_)
1676 : type_(type), count(count_) { }
1677
1678 C2Config::picture_type_t type_;
1679 uint32_t count;
1680
1681 DEFINE_AND_DESCRIBE_C2STRUCT(GopLayer)
1682 C2FIELD(type_, "type")
1683 C2FIELD(count, "count")
1684 };
1685
1686 typedef C2StreamParam<C2Tuning, C2SimpleArrayStruct<C2GopLayerStruct>, kParamIndexGop>
1687 C2StreamGopTuning;
1688 constexpr char C2_PARAMKEY_GOP[] = "coding.gop";
1689
1690 /**
1691 * Sync frame can be requested on demand by the client.
1692 *
1693 * If true, the next I frame shall be encoded as a sync frame. This config can be passed
1694 * synchronously with the work, or directly to the component - leading to different result.
1695 * If it is passed with work, it shall take effect when that work item is being processed (so
1696 * the first I frame at or after that work item shall be a sync frame).
1697 */
1698 typedef C2StreamParam<C2Tuning, C2EasyBoolValue, kParamIndexRequestSyncFrame>
1699 C2StreamRequestSyncFrameTuning;
1700 constexpr char C2_PARAMKEY_REQUEST_SYNC_FRAME[] = "coding.request-sync-frame";
1701
1702 /**
1703 * Sync frame interval in time domain (timestamp).
1704 *
1705 * If there hasn't been a sync frame in at least this value, the next intra frame shall be encoded
1706 * as a sync frame. The value of MAX_I64 or a negative value means no sync frames after the first
1707 * frame. A value of 0 means all sync frames.
1708 */
1709 typedef C2StreamParam<C2Tuning, C2Int64Value, kParamIndexSyncFrameInterval>
1710 C2StreamSyncFrameIntervalTuning;
1711 constexpr char C2_PARAMKEY_SYNC_FRAME_INTERVAL[] = "coding.sync-frame-interval";
1712
1713 /**
1714 * Temporal layering
1715 *
1716 * Layer index is a value between 0 and layer count - 1. Layers with higher index have higher
1717 * frequency:
1718 * 0
1719 * 1 1
1720 * 2 2 2 2
1721 */
1722 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexLayerIndex> C2StreamLayerIndexInfo;
1723 constexpr char C2_PARAMKEY_LAYER_INDEX[] = "coded.layer-index";
1724
1725 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexLayerCount> C2StreamLayerCountInfo;
1726 constexpr char C2_PARAMKEY_LAYER_COUNT[] = "coded.layer-count";
1727
1728 struct C2TemporalLayeringStruct {
C2TemporalLayeringStructC2TemporalLayeringStruct1729 C2TemporalLayeringStruct()
1730 : layerCount(0), bLayerCount(0) { }
1731
C2TemporalLayeringStructC2TemporalLayeringStruct1732 C2TemporalLayeringStruct(size_t /* flexCount */, uint32_t layerCount_, uint32_t bLayerCount_)
1733 : layerCount(layerCount_), bLayerCount(c2_min(layerCount_, bLayerCount_)) { }
1734
C2TemporalLayeringStructC2TemporalLayeringStruct1735 C2TemporalLayeringStruct(size_t flexCount, uint32_t layerCount_, uint32_t bLayerCount_,
1736 std::initializer_list<float> ratios)
1737 : layerCount(layerCount_), bLayerCount(c2_min(layerCount_, bLayerCount_)) {
1738 size_t ix = 0;
1739 for (float ratio : ratios) {
1740 if (ix == flexCount) {
1741 break;
1742 }
1743 bitrateRatios[ix++] = ratio;
1744 }
1745 }
1746
1747 uint32_t layerCount; ///< total number of layers (0 means no temporal layering)
1748 uint32_t bLayerCount; ///< total number of bidirectional layers (<= num layers)
1749 /**
1750 * Bitrate budgets for each layer and the layers below, given as a ratio of the total
1751 * stream bitrate. This can be omitted or partially specififed by the client while configuring,
1752 * in which case the component shall fill in appropriate values for the missing layers.
1753 * This must be provided by the component when queried for at least layer count - 1 (as the
1754 * last layer's budget is always 1.0).
1755 */
1756 float bitrateRatios[]; ///< 1.0-based
1757
1758 DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(TemporalLayering, bitrateRatios)
1759 C2FIELD(layerCount, "layer-count")
1760 C2FIELD(bLayerCount, "b-layer-count")
1761 C2FIELD(bitrateRatios, "bitrate-ratios")
1762 };
1763
1764 typedef C2StreamParam<C2Tuning, C2TemporalLayeringStruct, kParamIndexTemporalLayering>
1765 C2StreamTemporalLayeringTuning;
1766 constexpr char C2_PARAMKEY_TEMPORAL_LAYERING[] = "coding.temporal-layering";
1767
1768 /**
1769 * Intra-refresh.
1770 */
1771
1772 C2ENUM(C2Config::intra_refresh_mode_t, uint32_t,
1773 INTRA_REFRESH_DISABLED, ///< no intra refresh
1774 INTRA_REFRESH_ARBITRARY, ///< arbitrary, unspecified
1775 )
1776
1777 struct C2IntraRefreshStruct {
C2IntraRefreshStructC2IntraRefreshStruct1778 C2IntraRefreshStruct()
1779 : mode(C2Config::INTRA_REFRESH_DISABLED), period(0.) { }
1780
C2IntraRefreshStructC2IntraRefreshStruct1781 C2IntraRefreshStruct(C2Config::intra_refresh_mode_t mode_, float period_)
1782 : mode(mode_), period(period_) { }
1783
1784 C2Config::intra_refresh_mode_t mode; ///< refresh mode
1785 float period; ///< intra refresh period in frames (must be >= 1), 0 means disabled
1786
1787 DEFINE_AND_DESCRIBE_C2STRUCT(IntraRefresh)
1788 C2FIELD(mode, "mode")
1789 C2FIELD(period, "period")
1790 };
1791
1792 typedef C2StreamParam<C2Tuning, C2IntraRefreshStruct, kParamIndexIntraRefresh>
1793 C2StreamIntraRefreshTuning;
1794 constexpr char C2_PARAMKEY_INTRA_REFRESH[] = "coding.intra-refresh";
1795
1796 /* ====================================== IMAGE COMPONENTS ====================================== */
1797
1798 /**
1799 * Tile layout.
1800 *
1801 * This described how the image is decomposed into tiles.
1802 */
1803 C2ENUM(C2Config::scan_order_t, uint32_t,
1804 SCAN_LEFT_TO_RIGHT_THEN_DOWN
1805 )
1806
1807 struct C2TileLayoutStruct {
1808 C2PictureSizeStruct tile; ///< tile size
1809 uint32_t columnCount; ///< number of tiles horizontally
1810 uint32_t rowCount; ///< number of tiles vertically
1811 C2Config::scan_order_t order; ///< tile order
1812
1813 DEFINE_AND_DESCRIBE_C2STRUCT(TileLayout)
1814 C2FIELD(tile, "tile")
1815 C2FIELD(columnCount, "columns")
1816 C2FIELD(rowCount, "rows")
1817 C2FIELD(order, "order")
1818 };
1819
1820 typedef C2StreamParam<C2Info, C2TileLayoutStruct, kParamIndexTileLayout> C2StreamTileLayoutInfo;
1821 constexpr char C2_PARAMKEY_TILE_LAYOUT[] = "coded.tile-layout";
1822
1823 /**
1824 * Tile handling.
1825 *
1826 * Whether to concatenate tiles or output them each.
1827 */
1828 C2ENUM(C2Config::tiling_mode_t, uint32_t,
1829 TILING_SEPARATE, ///< output each tile in a separate onWorkDone
1830 TILING_CONCATENATE ///< output one work completion per frame (concatenate tiles)
1831 )
1832
1833 typedef C2StreamParam<C2Tuning, C2TileLayoutStruct, kParamIndexTileHandling>
1834 C2StreamTileHandlingTuning;
1835 constexpr char C2_PARAMKEY_TILE_HANDLING[] = "coding.tile-handling";
1836
1837 /* ====================================== AUDIO COMPONENTS ====================================== */
1838
1839 /**
1840 * Sample rate
1841 */
1842 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexSampleRate> C2StreamSampleRateInfo;
1843 constexpr char C2_PARAMKEY_SAMPLE_RATE[] = "raw.sample-rate";
1844 constexpr char C2_PARAMKEY_CODED_SAMPLE_RATE[] = "coded.sample-rate";
1845
1846 /**
1847 * Channel count.
1848 */
1849 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexChannelCount> C2StreamChannelCountInfo;
1850 constexpr char C2_PARAMKEY_CHANNEL_COUNT[] = "raw.channel-count";
1851 constexpr char C2_PARAMKEY_CODED_CHANNEL_COUNT[] = "coded.channel-count";
1852
1853 /**
1854 * Max channel count. Used to limit the number of coded or decoded channels.
1855 */
1856 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexMaxChannelCount> C2StreamMaxChannelCountInfo;
1857 constexpr char C2_PARAMKEY_MAX_CHANNEL_COUNT[] = "raw.max-channel-count";
1858 constexpr char C2_PARAMKEY_MAX_CODED_CHANNEL_COUNT[] = "coded.max-channel-count";
1859
1860 /**
1861 * Audio sample format (PCM encoding)
1862 */
1863 C2ENUM(C2Config::pcm_encoding_t, uint32_t,
1864 PCM_16,
1865 PCM_8,
1866 PCM_FLOAT
1867 )
1868
1869 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2Config::pcm_encoding_t>, kParamIndexPcmEncoding>
1870 C2StreamPcmEncodingInfo;
1871 constexpr char C2_PARAMKEY_PCM_ENCODING[] = "raw.pcm-encoding";
1872 constexpr char C2_PARAMKEY_CODED_PCM_ENCODING[] = "coded.pcm-encoding";
1873
1874 /**
1875 * AAC SBR Mode. Used during encoding.
1876 */
1877 C2ENUM(C2Config::aac_sbr_mode_t, uint32_t,
1878 AAC_SBR_OFF,
1879 AAC_SBR_SINGLE_RATE,
1880 AAC_SBR_DUAL_RATE,
1881 AAC_SBR_AUTO ///< let the codec decide
1882 )
1883
1884 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2Config::aac_sbr_mode_t>, kParamIndexAacSbrMode>
1885 C2StreamAacSbrModeTuning;
1886 constexpr char C2_PARAMKEY_AAC_SBR_MODE[] = "coding.aac-sbr-mode";
1887
1888 /**
1889 * DRC Compression. Used during decoding.
1890 */
1891 C2ENUM(C2Config::drc_compression_mode_t, int32_t,
1892 DRC_COMPRESSION_ODM_DEFAULT, ///< odm's default
1893 DRC_COMPRESSION_NONE,
1894 DRC_COMPRESSION_LIGHT,
1895 DRC_COMPRESSION_HEAVY ///<
1896 )
1897
1898 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2Config::drc_compression_mode_t>,
1899 kParamIndexDrcCompression>
1900 C2StreamDrcCompressionModeTuning;
1901 constexpr char C2_PARAMKEY_DRC_COMPRESSION_MODE[] = "coding.drc.compression-mode";
1902
1903 /**
1904 * DRC target reference level in dBFS. Used during decoding.
1905 */
1906 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexDrcTargetReferenceLevel>
1907 C2StreamDrcTargetReferenceLevelTuning;
1908 constexpr char C2_PARAMKEY_DRC_TARGET_REFERENCE_LEVEL[] = "coding.drc.reference-level";
1909
1910 /**
1911 * DRC target reference level in dBFS. Used during decoding.
1912 */
1913 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexDrcEncodedTargetLevel>
1914 C2StreamDrcEncodedTargetLevelTuning;
1915 constexpr char C2_PARAMKEY_DRC_ENCODED_TARGET_LEVEL[] = "coding.drc.encoded-level";
1916
1917 /**
1918 * DRC target reference level in dBFS. Used during decoding.
1919 */
1920 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexDrcBoostFactor>
1921 C2StreamDrcBoostFactorTuning;
1922 constexpr char C2_PARAMKEY_DRC_BOOST_FACTOR[] = "coding.drc.boost-factor";
1923
1924 /**
1925 * DRC target reference level in dBFS. Used during decoding.
1926 */
1927 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexDrcAttenuationFactor>
1928 C2StreamDrcAttenuationFactorTuning;
1929 constexpr char C2_PARAMKEY_DRC_ATTENUATION_FACTOR[] = "coding.drc.attenuation-factor";
1930
1931 /**
1932 * DRC Effect Type (see ISO 23003-4) Uniform Dynamic Range Control. Used during decoding.
1933 */
1934 C2ENUM(C2Config::drc_effect_type_t, int32_t,
1935 DRC_EFFECT_ODM_DEFAULT = -2, ///< odm's default
1936 DRC_EFFECT_OFF = -1, ///< no DRC
1937 DRC_EFFECT_NONE = 0, ///< no DRC except to prevent clipping
1938 DRC_EFFECT_LATE_NIGHT,
1939 DRC_EFFECT_NOISY_ENVIRONMENT,
1940 DRC_EFFECT_LIMITED_PLAYBACK_RANGE,
1941 DRC_EFFECT_LOW_PLAYBACK_LEVEL,
1942 DRC_EFFECT_DIALOG_ENHANCEMENT,
1943 DRC_EFFECT_GENERAL_COMPRESSION
1944 )
1945
1946 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2Config::drc_effect_type_t>,
1947 kParamIndexDrcEffectType>
1948 C2StreamDrcEffectTypeTuning;
1949 constexpr char C2_PARAMKEY_DRC_EFFECT_TYPE[] = "coding.drc.effect-type";
1950
1951 /**
1952 * DRC album mode. Used during decoding.
1953 */
1954 C2ENUM(C2Config::drc_album_mode_t, int32_t,
1955 DRC_ALBUM_MODE_OFF = 0,
1956 DRC_ALBUM_MODE_ON = 1
1957 )
1958 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2Config::drc_album_mode_t>, kParamIndexDrcAlbumMode>
1959 C2StreamDrcAlbumModeTuning;
1960 constexpr char C2_PARAMKEY_DRC_ALBUM_MODE[] = "coding.drc.album-mode";
1961
1962 /**
1963 * DRC output loudness in dBFS. Retrieved during decoding
1964 */
1965 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexDrcOutputLoudness>
1966 C2StreamDrcOutputLoudnessTuning;
1967 constexpr char C2_PARAMKEY_DRC_OUTPUT_LOUDNESS[] = "output.drc.output-loudness";
1968
1969 /* --------------------------------------- AAC components --------------------------------------- */
1970
1971 /**
1972 * AAC stream format
1973 */
1974 C2ENUM(C2Config::aac_packaging_t, uint32_t,
1975 AAC_PACKAGING_RAW,
1976 AAC_PACKAGING_ADTS
1977 )
1978
1979 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2EasyEnum<C2Config::aac_packaging_t>>,
1980 kParamIndexAacPackaging> C2StreamAacPackagingInfo;
1981 typedef C2StreamAacPackagingInfo C2StreamAacFormatInfo;
1982 constexpr char C2_PARAMKEY_AAC_PACKAGING[] = "coded.aac-packaging";
1983
1984 /* ================================ PLATFORM-DEFINED PARAMETERS ================================ */
1985
1986 /**
1987 * Platform level and features.
1988 */
1989 enum C2Config::platform_level_t : uint32_t {
1990 PLATFORM_P, ///< support for Android 9.0 feature set
1991 };
1992
1993 // read-only
1994 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Config::platform_level_t>,
1995 kParamIndexPlatformLevel>
1996 C2PlatformLevelSetting;
1997 constexpr char C2_PARAMKEY_PLATFORM_LEVEL[] = "api.platform-level";
1998
1999 enum C2Config::platform_feature_t : uint64_t {
2000 // no platform-specific features have been defined
2001 };
2002
2003 // read-only
2004 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Config::platform_feature_t>,
2005 kParamIndexPlatformFeatures>
2006 C2PlatformFeaturesSetting;
2007 constexpr char C2_PARAMKEY_PLATFORM_FEATURES[] = "api.platform-features";
2008
2009 /**
2010 * This structure describes the preferred ion allocation parameters for a given memory usage.
2011 */
2012 struct C2StoreIonUsageStruct {
C2StoreIonUsageStructC2StoreIonUsageStruct2013 inline C2StoreIonUsageStruct() {
2014 memset(this, 0, sizeof(*this));
2015 }
2016
C2StoreIonUsageStructC2StoreIonUsageStruct2017 inline C2StoreIonUsageStruct(uint64_t usage_, uint32_t capacity_)
2018 : usage(usage_), capacity(capacity_), heapMask(0), allocFlags(0), minAlignment(0) { }
2019
2020 uint64_t usage; ///< C2MemoryUsage
2021 uint32_t capacity; ///< capacity
2022 int32_t heapMask; ///< ion heapMask
2023 int32_t allocFlags; ///< ion allocation flags
2024 uint32_t minAlignment; ///< minimum alignment
2025
2026 DEFINE_AND_DESCRIBE_C2STRUCT(StoreIonUsage)
2027 C2FIELD(usage, "usage")
2028 C2FIELD(capacity, "capacity")
2029 C2FIELD(heapMask, "heap-mask")
2030 C2FIELD(allocFlags, "alloc-flags")
2031 C2FIELD(minAlignment, "min-alignment")
2032 };
2033
2034 // store, private
2035 typedef C2GlobalParam<C2Info, C2StoreIonUsageStruct, kParamIndexStoreIonUsage>
2036 C2StoreIonUsageInfo;
2037
2038 /**
2039 * Flexible pixel format descriptors
2040 */
2041 struct C2FlexiblePixelFormatDescriptorStruct {
2042 uint32_t pixelFormat;
2043 uint32_t bitDepth;
2044 C2Color::subsampling_t subsampling;
2045 C2Color::plane_layout_t layout;
2046
2047 DEFINE_AND_DESCRIBE_C2STRUCT(FlexiblePixelFormatDescriptor)
2048 C2FIELD(pixelFormat, "pixel-format")
2049 C2FIELD(bitDepth, "bit-depth")
2050 C2FIELD(subsampling, "subsampling")
2051 C2FIELD(layout, "layout")
2052 };
2053
2054 /**
2055 * Plane layout of flexible pixel formats.
2056 *
2057 * bpp: bytes per color component, e.g. 1 for 8-bit formats, and 2 for 10-16-bit formats.
2058 */
2059 C2ENUM(C2Color::plane_layout_t, uint32_t,
2060 /** Unknown layout */
2061 UNKNOWN_LAYOUT,
2062
2063 /** Planar layout with rows of each plane packed (colInc = bpp) */
2064 PLANAR_PACKED,
2065
2066 /** Semiplanar layout with rows of each plane packed (colInc_Y/A = bpp (planar),
2067 * colInc_Cb/Cr = 2*bpp (interleaved). Used only for YUV(A) formats. */
2068 SEMIPLANAR_PACKED,
2069
2070 /** Interleaved packed. colInc = N*bpp (N are the number of color components) */
2071 INTERLEAVED_PACKED,
2072
2073 /** Interleaved aligned. colInc = smallest power of 2 >= N*bpp (N are the number of color
2074 * components) */
2075 INTERLEAVED_ALIGNED
2076 )
2077
2078 typedef C2GlobalParam<C2Info, C2SimpleArrayStruct<C2FlexiblePixelFormatDescriptorStruct>,
2079 kParamIndexFlexiblePixelFormatDescriptors>
2080 C2StoreFlexiblePixelFormatDescriptorsInfo;
2081
2082 /**
2083 * This structure describes the android dataspace for a raw video/image frame.
2084 */
2085 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexDataSpace> C2StreamDataSpaceInfo;
2086 constexpr char C2_PARAMKEY_DATA_SPACE[] = "raw.data-space";
2087
2088 /**
2089 * This structure describes the android surface scaling mode for a raw video/image frame.
2090 */
2091 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexSurfaceScaling> C2StreamSurfaceScalingInfo;
2092 constexpr char C2_PARAMKEY_SURFACE_SCALING_MODE[] = "raw.surface-scaling";
2093
2094 /* ======================================= INPUT SURFACE ======================================= */
2095
2096 /**
2097 * Input surface EOS
2098 */
2099 typedef C2GlobalParam<C2Tuning, C2EasyBoolValue, kParamIndexInputSurfaceEos>
2100 C2InputSurfaceEosTuning;
2101 constexpr char C2_PARAMKEY_INPUT_SURFACE_EOS[] = "input-surface.eos";
2102
2103 /**
2104 * Start/suspend/resume/stop controls and timestamps for input surface.
2105 *
2106 * TODO: make these counters
2107 */
2108
2109 struct C2TimedControlStruct {
2110 c2_bool_t enabled; ///< control is enabled
2111 int64_t timestamp; ///< if enabled, time the control should take effect
2112
C2TimedControlStructC2TimedControlStruct2113 C2TimedControlStruct()
2114 : enabled(C2_FALSE), timestamp(0) { }
2115
C2TimedControlStructC2TimedControlStruct2116 /* implicit */ C2TimedControlStruct(uint64_t timestamp_)
2117 : enabled(C2_TRUE), timestamp(timestamp_) { }
2118
2119 DEFINE_AND_DESCRIBE_C2STRUCT(TimedControl)
2120 C2FIELD(enabled, "enabled")
2121 C2FIELD(timestamp, "timestamp")
2122 };
2123
2124 typedef C2PortParam<C2Tuning, C2TimedControlStruct, kParamIndexStartAt>
2125 C2PortStartTimestampTuning;
2126 constexpr char C2_PARAMKEY_INPUT_SURFACE_START_AT[] = "input-surface.start";
2127 typedef C2PortParam<C2Tuning, C2TimedControlStruct, kParamIndexSuspendAt>
2128 C2PortSuspendTimestampTuning;
2129 constexpr char C2_PARAMKEY_INPUT_SURFACE_SUSPEND_AT[] = "input-surface.suspend";
2130 typedef C2PortParam<C2Tuning, C2TimedControlStruct, kParamIndexResumeAt>
2131 C2PortResumeTimestampTuning;
2132 constexpr char C2_PARAMKEY_INPUT_SURFACE_RESUME_AT[] = "input-surface.resume";
2133 typedef C2PortParam<C2Tuning, C2TimedControlStruct, kParamIndexStopAt>
2134 C2PortStopTimestampTuning;
2135 constexpr char C2_PARAMKEY_INPUT_SURFACE_STOP_AT[] = "input-surface.stop";
2136
2137 /**
2138 * Time offset for input surface. Input timestamp to codec is surface buffer timestamp plus this
2139 * time offset.
2140 */
2141 typedef C2GlobalParam<C2Tuning, C2Int64Value, kParamIndexTimeOffset> C2ComponentTimeOffsetTuning;
2142 constexpr char C2_PARAMKEY_INPUT_SURFACE_TIME_OFFSET[] = "input-surface.time-offset";
2143
2144 /**
2145 * Minimum fps for input surface.
2146 *
2147 * Repeat frame to meet this.
2148 */
2149 typedef C2PortParam<C2Tuning, C2FloatValue, kParamIndexMinFrameRate> C2PortMinFrameRateTuning;
2150 constexpr char C2_PARAMKEY_INPUT_SURFACE_MIN_FRAME_RATE[] = "input-surface.min-frame-rate";
2151
2152 /**
2153 * Timestamp adjustment (override) for input surface buffers. These control the input timestamp
2154 * fed to the codec, but do not impact the output timestamp.
2155 */
2156 struct C2TimestampGapAdjustmentStruct {
2157 /// control modes
2158 enum mode_t : uint32_t;
2159
2160 inline C2TimestampGapAdjustmentStruct();
2161
C2TimestampGapAdjustmentStructC2TimestampGapAdjustmentStruct2162 inline C2TimestampGapAdjustmentStruct(mode_t mode_, uint64_t value_)
2163 : mode(mode_), value(value_) { }
2164
2165 mode_t mode; ///< control mode
2166 uint64_t value; ///< control value for gap between two timestamp
2167
2168 DEFINE_AND_DESCRIBE_C2STRUCT(TimestampGapAdjustment)
2169 C2FIELD(mode, "mode")
2170 C2FIELD(value, "value")
2171 };
2172
2173 C2ENUM(C2TimestampGapAdjustmentStruct::mode_t, uint32_t,
2174 NONE,
2175 MIN_GAP,
2176 FIXED_GAP,
2177 );
2178
C2TimestampGapAdjustmentStruct()2179 inline C2TimestampGapAdjustmentStruct::C2TimestampGapAdjustmentStruct()
2180 : mode(C2TimestampGapAdjustmentStruct::NONE), value(0) { }
2181
2182 typedef C2PortParam<C2Tuning, C2TimestampGapAdjustmentStruct> C2PortTimestampGapTuning;
2183 constexpr char C2_PARAMKEY_INPUT_SURFACE_TIMESTAMP_ADJUSTMENT[] = "input-surface.timestamp-adjustment";
2184
2185 /// @}
2186
2187 #endif // C2CONFIG_H_
2188