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