1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef C2CONFIG_H_
18 #define C2CONFIG_H_
19
20 #include <C2.h>
21 #include <C2Component.h>
22 #include <C2Enum.h>
23 #include <C2ParamDef.h>
24
25 /// \defgroup config Component configuration
26 /// @{
27
28 /**
29 * Enumerated boolean.
30 */
31 C2ENUM(c2_bool_t, uint32_t,
32 C2_FALSE, ///< true
33 C2_TRUE, ///< false
34 )
35
36 typedef C2SimpleValueStruct<c2_bool_t> C2BoolValue;
37
38 typedef C2SimpleValueStruct<C2EasyEnum<c2_bool_t>> C2EasyBoolValue;
39
40 /**
41 * Enumerated set tri-state.
42 *
43 * Used for optional configurations to distinguish between values set by the client,
44 * default values set by the component, or unset values.
45 */
46 C2ENUM(c2_set_t, uint32_t,
47 C2_UNSET, // parameter is unset and has no value
48 C2_SET, // parameter is/has been set by the client
49 C2_DEFAULT, // parameter has not been set by the client, but is set by the component
50 )
51
52 /** Enumerations used by configuration parameters */
53 struct C2Config {
54 enum aac_packaging_t : uint32_t; ///< AAC packaging (RAW vs ADTS)
55 enum aac_sbr_mode_t : uint32_t; ///< AAC SBR mode
56 enum api_feature_t : uint64_t; ///< API features
57 enum api_level_t : uint32_t; ///< API level
58 enum bitrate_mode_t : uint32_t; ///< bitrate control mode
59 enum drc_compression_mode_t : int32_t; ///< DRC compression mode
60 enum drc_effect_type_t : int32_t; ///< DRC effect type
61 enum drc_album_mode_t : int32_t; ///< DRC album mode
62 enum hdr_dynamic_metadata_type_t : uint32_t; ///< HDR dynamic metadata type
63 enum hdr_format_t : uint32_t; ///< HDR format
64 enum intra_refresh_mode_t : uint32_t; ///< intra refresh modes
65 enum level_t : uint32_t; ///< coding level
66 enum ordinal_key_t : uint32_t; ///< work ordering keys
67 enum pcm_encoding_t : uint32_t; ///< PCM encoding
68 enum picture_type_t : uint32_t; ///< picture types
69 enum platform_feature_t : uint64_t; ///< platform features
70 enum platform_level_t : uint32_t; ///< platform level
71 enum prepend_header_mode_t : uint32_t; ///< prepend header operational modes
72 enum profile_t : uint32_t; ///< coding profile
73 enum resource_kind_t : uint32_t; ///< resource kinds
74 enum scaling_method_t : uint32_t; ///< scaling methods
75 enum scan_order_t : uint32_t; ///< scan orders
76 enum secure_mode_t : uint32_t; ///< secure/protected modes
77 enum supplemental_info_t : uint32_t; ///< supplemental information types
78 enum tiling_mode_t : uint32_t; ///< tiling modes
79 };
80
81 struct C2PlatformConfig {
82 enum encoding_quality_level_t : uint32_t; ///< encoding quality level
83 enum tunnel_peek_mode_t: uint32_t; ///< tunnel peek mode
84 };
85
86 namespace {
87
88 enum C2ParamIndexKind : C2Param::type_index_t {
89 C2_PARAM_INDEX_INVALID = 0x0, ///< do not use
90 C2_PARAM_INDEX_STRUCT_START = 0x1, ///< struct only indices
91 C2_PARAM_INDEX_PARAM_START = 0x800, ///< regular parameters
92 C2_PARAM_INDEX_CODER_PARAM_START = 0x1000, ///< en/transcoder parameters
93 C2_PARAM_INDEX_PICTURE_PARAM_START = 0x1800, ///< image/video parameters
94 C2_PARAM_INDEX_VIDEO_PARAM_START = 0x2000, ///< video parameters
95 C2_PARAM_INDEX_IMAGE_PARAM_START = 0x2800, ///< image parameters
96 C2_PARAM_INDEX_AUDIO_PARAM_START = 0x3000, ///< image parameters
97 C2_PARAM_INDEX_PLATFORM_START = 0x4000, ///< platform-defined parameters
98
99 /* =================================== structure indices =================================== */
100
101 kParamIndexColorXy = C2_PARAM_INDEX_STRUCT_START,
102 kParamIndexMasteringDisplayColorVolume,
103 kParamIndexChromaOffset,
104 kParamIndexGopLayer,
105 kParamIndexSystemResource,
106
107 /* =================================== parameter indices =================================== */
108
109 kParamIndexApiLevel = C2_PARAM_INDEX_PARAM_START,
110 kParamIndexApiFeatures,
111
112 /* ------------------------------------ all components ------------------------------------ */
113
114 /* generic component characteristics */
115 kParamIndexName,
116 kParamIndexAliases,
117 kParamIndexKind,
118 kParamIndexDomain,
119 kParamIndexAttributes,
120 kParamIndexTimeStretch,
121
122 /* coding characteristics */
123 kParamIndexProfileLevel,
124 kParamIndexInitData,
125 kParamIndexSupplementalData,
126 kParamIndexSubscribedSupplementalData,
127
128 /* pipeline characteristics */
129 kParamIndexMediaType,
130 __kParamIndexRESERVED_0,
131 kParamIndexDelay,
132 kParamIndexMaxReferenceAge,
133 kParamIndexMaxReferenceCount,
134 kParamIndexReorderBufferDepth,
135 kParamIndexReorderKey,
136 kParamIndexStreamCount,
137 kParamIndexSubscribedParamIndices,
138 kParamIndexSuggestedBufferCount,
139 kParamIndexBatchSize,
140 kParamIndexCurrentWork,
141 kParamIndexLastWorkQueued,
142
143 /* memory allocation */
144 kParamIndexAllocators,
145 kParamIndexBlockPools,
146 kParamIndexBufferType,
147 kParamIndexUsage,
148 kParamIndexOutOfMemory,
149 kParamIndexMaxBufferSize,
150
151 /* misc. state */
152 kParamIndexTripped,
153 kParamIndexConfigCounter,
154
155 /* resources */
156 kParamIndexResourcesNeeded,
157 kParamIndexResourcesReserved,
158 kParamIndexOperatingRate,
159 kParamIndexRealTimePriority,
160
161 /* protected content */
162 kParamIndexSecureMode,
163 kParamIndexEncryptedBuffer, // info-buffer, used with SM_READ_PROTECTED_WITH_ENCRYPTED
164
165 /* multiple access unit support */
166 kParamIndexLargeFrame,
167 kParamIndexAccessUnitInfos, // struct
168
169 /* Region of Interest Encoding parameters */
170 kParamIndexQpOffsetMapBuffer, // info-buffer, used to signal qp-offset map for a frame
171
172 /* resource capacity and resources excluded */
173 kParamIndexResourcesCapacity,
174 kParamIndexResourcesExcluded,
175
176 // deprecated
177 kParamIndexDelayRequest = kParamIndexDelay | C2Param::CoreIndex::IS_REQUEST_FLAG,
178
179 /* ------------------------------------ (trans/en)coders ------------------------------------ */
180
181 kParamIndexBitrate = C2_PARAM_INDEX_CODER_PARAM_START,
182 kParamIndexBitrateMode,
183 kParamIndexQuality,
184 kParamIndexComplexity,
185 kParamIndexPrependHeaderMode,
186
187 /* --------------------------------- image/video components --------------------------------- */
188
189 kParamIndexPictureSize = C2_PARAM_INDEX_PICTURE_PARAM_START,
190 kParamIndexCropRect,
191 kParamIndexPixelFormat,
192 kParamIndexRotation,
193 kParamIndexPixelAspectRatio,
194 kParamIndexScaledPictureSize,
195 kParamIndexScaledCropRect,
196 kParamIndexScalingMethod,
197 kParamIndexColorInfo,
198 kParamIndexColorAspects,
199 kParamIndexHdrStaticMetadata,
200 kParamIndexDefaultColorAspects,
201
202 kParamIndexBlockSize,
203 kParamIndexBlockCount,
204 kParamIndexBlockRate,
205
206 kParamIndexPictureTypeMask,
207 kParamIndexPictureType,
208 // deprecated
209 kParamIndexHdr10PlusMetadata,
210 kParamIndexPictureQuantization,
211 kParamIndexHdrDynamicMetadata,
212 kParamIndexHdrFormat,
213 kParamIndexQpOffsetRect,
214 kParamIndexQpOffsetRects,
215
216 /* ------------------------------------ video components ------------------------------------ */
217
218 kParamIndexFrameRate = C2_PARAM_INDEX_VIDEO_PARAM_START,
219 kParamIndexMaxBitrate,
220 kParamIndexMaxFrameRate,
221 kParamIndexMaxPictureSize,
222 kParamIndexGop,
223 kParamIndexSyncFrameInterval,
224 kParamIndexRequestSyncFrame,
225 kParamIndexTemporalLayering,
226 kParamIndexLayerIndex,
227 kParamIndexLayerCount,
228 kParamIndexIntraRefresh,
229
230 /* ------------------------------------ image components ------------------------------------ */
231
232 kParamIndexTileLayout = C2_PARAM_INDEX_IMAGE_PARAM_START,
233 kParamIndexTileHandling,
234
235 /* ------------------------------------ audio components ------------------------------------ */
236
237 kParamIndexSampleRate = C2_PARAM_INDEX_AUDIO_PARAM_START,
238 kParamIndexChannelCount,
239 kParamIndexPcmEncoding,
240 kParamIndexAacPackaging,
241 kParamIndexMaxChannelCount,
242 kParamIndexAacSbrMode, // aac encode, enum
243 kParamIndexDrcEncodedTargetLevel, // drc, float (dBFS)
244 kParamIndexDrcTargetReferenceLevel, // drc, float (dBFS)
245 kParamIndexDrcCompression, // drc, enum
246 kParamIndexDrcBoostFactor, // drc, float (0-1)
247 kParamIndexDrcAttenuationFactor, // drc, float (0-1)
248 kParamIndexDrcEffectType, // drc, enum
249 kParamIndexDrcOutputLoudness, // drc, float (dBFS)
250 kParamIndexDrcAlbumMode, // drc, enum
251 kParamIndexAudioFrameSize, // int
252
253 /* ============================== platform-defined parameters ============================== */
254
255 kParamIndexPlatformLevel = C2_PARAM_INDEX_PLATFORM_START, // all, u32
256 kParamIndexPlatformFeatures, // all, u64 mask
257 kParamIndexStoreIonUsage, // store, struct
258 kParamIndexAspectsToDataSpace, // store, struct
259 kParamIndexFlexiblePixelFormatDescriptor, // store, struct
260 kParamIndexFlexiblePixelFormatDescriptors, // store, struct[]
261 kParamIndexDataSpaceToAspects, // store, struct
262 kParamIndexDataSpace, // u32
263 kParamIndexSurfaceScaling, // u32
264
265 // input surface
266 kParamIndexInputSurfaceEos, // input-surface, eos
267 kParamIndexTimedControl, // struct
268 kParamIndexStartAt, // input-surface, struct
269 kParamIndexSuspendAt, // input-surface, struct
270 kParamIndexResumeAt, // input-surface, struct
271 kParamIndexStopAt, // input-surface, struct
272 kParamIndexTimeOffset, // input-surface, int64_t
273 kParamIndexMinFrameRate, // input-surface, float
274 kParamIndexTimestampGapAdjustment, // input-surface, struct
275
276 kParamIndexSurfaceAllocator, // u32
277
278 // low latency mode
279 kParamIndexLowLatencyMode, // bool
280
281 // tunneled codec
282 kParamIndexTunneledMode, // struct
283 kParamIndexTunnelHandle, // int32[]
284 kParamIndexTunnelSystemTime, // int64
285 kParamIndexTunnelHoldRender, // bool
286 kParamIndexTunnelStartRender, // bool
287
288 // dmabuf allocator
289 kParamIndexStoreDmaBufUsage, // store, struct
290
291 // encoding quality requirements
292 kParamIndexEncodingQualityLevel, // encoders, enum
293
294 // encoding statistics, average block qp of a frame
295 kParamIndexAverageBlockQuantization, // int32
296
297 // channel mask for decoded audio
298 kParamIndexAndroidChannelMask, // uint32
299
300 // allow tunnel peek behavior to be unspecified for app compatibility
301 kParamIndexTunnelPeekMode, // tunnel mode, enum
302
303 // input surface
304 kParamIndexCaptureFrameRate, // input-surface, float
305 kParamIndexStopTimeOffset, // input-surface, int64_t
306 };
307
308 }
309
310 /**
311 * Codec 2.0 parameter types follow the following naming convention:
312 *
313 * C2<group><domain><index><type>
314 *
315 * E.g. C2StreamPictureSizeInfo: group="" domain="Stream" index="PictureSize" type="Info".
316 * Group is somewhat arbitrary, but denotes kind of objects the parameter is defined.
317 * At this point we use Component and Store to distinguish basic component/store parameters.
318 *
319 * Parameter keys are named C2_PARAMKEY_[<group>_]<domain>_<index> as type is not expected
320 * to distinguish parameters. E.g. a component could change the type of the parameter and it
321 * is not expected users would need to change the key.
322 */
323
324 /* ----------------------------------------- API level ----------------------------------------- */
325
326 enum C2Config::api_level_t : uint32_t {
327 API_L0_1 = 0, ///< support for API level 0.1
328 };
329
330 // read-only
331 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Config::api_level_t>, kParamIndexApiLevel>
332 C2ApiLevelSetting;
333 constexpr char C2_PARAMKEY_API_LEVEL[] = "api.level";
334
335 C2ENUM(C2Config::api_feature_t, uint64_t,
336 API_REFLECTION = (1U << 0), ///< ability to list supported parameters
337 API_VALUES = (1U << 1), ///< ability to list supported values for each parameter
338 API_CURRENT_VALUES = (1U << 2), ///< ability to list currently supported values for each parameter
339 API_DEPENDENCY = (1U << 3), ///< have a defined parameter dependency
340
341 API_SAME_INPUT_BUFFER = (1U << 16), ///< supporting multiple input buffers
342 ///< backed by the same allocation
343
344 API_STREAMS = (1ULL << 32), ///< supporting variable number of streams
345
346 API_TUNNELING = (1ULL << 48) ///< tunneling API
347 )
348
349 // read-only
350 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Config::api_feature_t>, kParamIndexApiFeatures>
351 C2ApiFeaturesSetting;
352 constexpr char C2_PARAMKEY_API_FEATURES[] = "api.features";
353
354 /* ----------------------------- generic component characteristics ----------------------------- */
355
356 /**
357 * The name of the component.
358 *
359 * This must contain only alphanumeric characters or dot '.', hyphen '-', plus '+', or
360 * underline '_'. The name of each component must be unique.
361 *
362 * For Android: Component names must start with 'c2.' followed by the company name or abbreviation
363 * and another dot, e.g. 'c2.android.'. Use of lowercase is preferred but not required.
364 */
365 // read-only
366 typedef C2GlobalParam<C2Setting, C2StringValue, kParamIndexName> C2ComponentNameSetting;
367 constexpr char C2_PARAMKEY_COMPONENT_NAME[] = "component.name";
368
369 /**
370 * Alternate names (aliases) of the component.
371 *
372 * This is a comma ',' separated list of alternate component names. Unlike component names that
373 * must be unique, multiple components can have the same alias.
374 */
375 // read-only
376 typedef C2GlobalParam<C2Setting, C2StringValue, kParamIndexAliases> C2ComponentAliasesSetting;
377 constexpr char C2_PARAMKEY_COMPONENT_ALIASES[] = "component.aliases";
378
379 /**
380 * Component kind.
381 */
382 // read-only
383 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Component::kind_t>, kParamIndexKind>
384 C2ComponentKindSetting;
385 constexpr char C2_PARAMKEY_COMPONENT_KIND[] = "component.kind";
386
387 /**
388 * Component domain.
389 */
390 // read-only
391 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Component::domain_t>, kParamIndexDomain>
392 C2ComponentDomainSetting;
393 constexpr char C2_PARAMKEY_COMPONENT_DOMAIN[] = "component.domain";
394
395 /**
396 * Component attributes.
397 *
398 * These are a set of flags provided by the component characterizing its processing algorithm.
399 */
400 C2ENUM(C2Component::attrib_t, uint64_t,
401 ATTRIB_IS_TEMPORAL = 1u << 0, ///< component input ordering matters for processing
402 )
403
404 // read-only
405 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Component::attrib_t>, kParamIndexAttributes>
406 C2ComponentAttributesSetting;
407 constexpr char C2_PARAMKEY_COMPONENT_ATTRIBUTES[] = "component.attributes";
408
409 /**
410 * Time stretching.
411 *
412 * This is the ratio between the rate of the input timestamp, and the rate of the output timestamp.
413 * E.g. if this is 4.0, for every 1 seconds of input timestamp difference, the output shall differ
414 * by 4 seconds.
415 */
416 typedef C2GlobalParam<C2Tuning, C2FloatValue, kParamIndexTimeStretch> C2ComponentTimeStretchTuning;
417 constexpr char C2_PARAMKEY_TIME_STRETCH[] = "algo.time-stretch";
418
419 /* ----------------------------------- coding characteristics ----------------------------------- */
420
421 /**
422 * Profile and level.
423 *
424 * Profile determines the tools used by the component.
425 * Level determines the level of resources used by the component.
426 */
427
428 namespace {
429
430 // Codec bases are ordered by their date of introduction to the code base.
431 enum : uint32_t {
432 _C2_PL_MP2V_BASE = 0x1000,
433 _C2_PL_AAC_BASE = 0x2000,
434 _C2_PL_H263_BASE = 0x3000,
435 _C2_PL_MP4V_BASE = 0x4000,
436 _C2_PL_AVC_BASE = 0x5000,
437 _C2_PL_HEVC_BASE = 0x6000,
438 _C2_PL_VP9_BASE = 0x7000,
439 _C2_PL_DV_BASE = 0x8000,
440 _C2_PL_AV1_BASE = 0x9000,
441 _C2_PL_VP8_BASE = 0xA000,
442 _C2_PL_MPEGH_BASE = 0xB000, // MPEG-H 3D Audio
443 _C2_PL_APV_BASE = 0xC000, // APV
444
445 C2_PROFILE_LEVEL_VENDOR_START = 0x70000000,
446 };
447
448 }
449
450 // Profiles and levels for each codec are ordered based on how they are ordered in the
451 // corresponding standard documents at introduction, and chronologically afterwards.
452 enum C2Config::profile_t : uint32_t {
453 PROFILE_UNUSED = 0, ///< profile is not used by this media type
454
455 // AAC (MPEG-2 Part 7 and MPEG-4 Part 3) profiles
456 PROFILE_AAC_LC = _C2_PL_AAC_BASE, ///< AAC Low-Complexity
457 PROFILE_AAC_MAIN, ///< AAC Main
458 PROFILE_AAC_SSR, ///< AAC Scalable Sampling Rate
459 PROFILE_AAC_LTP, ///< AAC Long Term Prediction
460 PROFILE_AAC_HE, ///< AAC High-Efficiency
461 PROFILE_AAC_SCALABLE, ///< AAC Scalable
462 PROFILE_AAC_ER_LC, ///< AAC Error Resilient Low-Complexity
463 PROFILE_AAC_ER_SCALABLE, ///< AAC Error Resilient Scalable
464 PROFILE_AAC_LD, ///< AAC Low Delay
465 PROFILE_AAC_HE_PS, ///< AAC High-Efficiency Parametric Stereo
466 PROFILE_AAC_ELD, ///< AAC Enhanced Low Delay
467 PROFILE_AAC_XHE, ///< AAC Extended High-Efficiency
468
469 // MPEG-2 Video profiles
470 PROFILE_MP2V_SIMPLE = _C2_PL_MP2V_BASE, ///< MPEG-2 Video (H.262) Simple
471 PROFILE_MP2V_MAIN, ///< MPEG-2 Video (H.262) Main
472 PROFILE_MP2V_SNR_SCALABLE, ///< MPEG-2 Video (H.262) SNR Scalable
473 PROFILE_MP2V_SPATIALLY_SCALABLE, ///< MPEG-2 Video (H.262) Spatially Scalable
474 PROFILE_MP2V_HIGH, ///< MPEG-2 Video (H.262) High
475 PROFILE_MP2V_422, ///< MPEG-2 Video (H.262) 4:2:2
476 PROFILE_MP2V_MULTIVIEW, ///< MPEG-2 Video (H.262) Multi-view
477
478 // H.263 profiles
479 PROFILE_H263_BASELINE = _C2_PL_H263_BASE, ///< H.263 Baseline (Profile 0)
480 PROFILE_H263_H320, ///< H.263 H.320 Coding Efficiency Version 2 Backward-Compatibility (Profile 1)
481 PROFILE_H263_V1BC, ///< H.263 Version 1 Backward-Compatibility (Profile 2)
482 PROFILE_H263_ISWV2, ///< H.263 Version 2 Interactive and Streaming Wireless (Profile 3)
483 PROFILE_H263_ISWV3, ///< H.263 Version 3 Interactive and Streaming Wireless (Profile 4)
484 PROFILE_H263_HIGH_COMPRESSION, ///< H.263 Conversational High Compression (Profile 5)
485 PROFILE_H263_INTERNET, ///< H.263 Conversational Internet (Profile 6)
486 PROFILE_H263_INTERLACE, ///< H.263 Conversational Interlace (Profile 7)
487 PROFILE_H263_HIGH_LATENCY, ///< H.263 High Latency (Profile 8)
488
489 // MPEG-4 Part 2 (Video) Natural Visual Profiles
490 PROFILE_MP4V_SIMPLE, ///< MPEG-4 Video Simple
491 PROFILE_MP4V_SIMPLE_SCALABLE, ///< MPEG-4 Video Simple Scalable
492 PROFILE_MP4V_CORE, ///< MPEG-4 Video Core
493 PROFILE_MP4V_MAIN, ///< MPEG-4 Video Main
494 PROFILE_MP4V_NBIT, ///< MPEG-4 Video N-Bit
495 PROFILE_MP4V_ARTS, ///< MPEG-4 Video Advanced Realtime Simple
496 PROFILE_MP4V_CORE_SCALABLE, ///< MPEG-4 Video Core Scalable
497 PROFILE_MP4V_ACE, ///< MPEG-4 Video Advanced Coding Efficiency
498 PROFILE_MP4V_ADVANCED_CORE, ///< MPEG-4 Video Advanced Core
499 PROFILE_MP4V_SIMPLE_STUDIO, ///< MPEG-4 Video Simple Studio
500 PROFILE_MP4V_CORE_STUDIO, ///< MPEG-4 Video Core Studio
501 PROFILE_MP4V_ADVANCED_SIMPLE, ///< MPEG-4 Video Advanced Simple
502 PROFILE_MP4V_FGS, ///< MPEG-4 Video Fine Granularity Scalable
503
504 // AVC / MPEG-4 Part 10 (H.264) profiles
505 PROFILE_AVC_BASELINE = _C2_PL_AVC_BASE, ///< AVC (H.264) Baseline
506 PROFILE_AVC_CONSTRAINED_BASELINE, ///< AVC (H.264) Constrained Baseline
507 PROFILE_AVC_MAIN, ///< AVC (H.264) Main
508 PROFILE_AVC_EXTENDED, ///< AVC (H.264) Extended
509 PROFILE_AVC_HIGH, ///< AVC (H.264) High
510 PROFILE_AVC_PROGRESSIVE_HIGH, ///< AVC (H.264) Progressive High
511 PROFILE_AVC_CONSTRAINED_HIGH, ///< AVC (H.264) Constrained High
512 PROFILE_AVC_HIGH_10, ///< AVC (H.264) High 10
513 PROFILE_AVC_PROGRESSIVE_HIGH_10, ///< AVC (H.264) Progressive High 10
514 PROFILE_AVC_HIGH_422, ///< AVC (H.264) High 4:2:2
515 PROFILE_AVC_HIGH_444_PREDICTIVE, ///< AVC (H.264) High 4:4:4 Predictive
516 PROFILE_AVC_HIGH_10_INTRA, ///< AVC (H.264) High 10 Intra
517 PROFILE_AVC_HIGH_422_INTRA, ///< AVC (H.264) High 4:2:2 Intra
518 PROFILE_AVC_HIGH_444_INTRA, ///< AVC (H.264) High 4:4:4 Intra
519 PROFILE_AVC_CAVLC_444_INTRA, ///< AVC (H.264) CAVLC 4:4:4 Intra
520 PROFILE_AVC_SCALABLE_BASELINE = _C2_PL_AVC_BASE + 0x100, ///< AVC (H.264) Scalable Baseline
521 PROFILE_AVC_SCALABLE_CONSTRAINED_BASELINE, ///< AVC (H.264) Scalable Constrained Baseline
522 PROFILE_AVC_SCALABLE_HIGH, ///< AVC (H.264) Scalable High
523 PROFILE_AVC_SCALABLE_CONSTRAINED_HIGH, ///< AVC (H.264) Scalable Constrained High
524 PROFILE_AVC_SCALABLE_HIGH_INTRA, ///< AVC (H.264) Scalable High Intra
525 PROFILE_AVC_MULTIVIEW_HIGH = _C2_PL_AVC_BASE + 0x200, ///< AVC (H.264) Multiview High
526 PROFILE_AVC_STEREO_HIGH, ///< AVC (H.264) Stereo High
527 PROFILE_AVC_MFC_HIGH, ///< AVC (H.264) MFC High
528 PROFILE_AVC_MULTIVIEW_DEPTH_HIGH = _C2_PL_AVC_BASE + 0x300, ///< AVC (H.264) Multiview Depth High
529 PROFILE_AVC_MFC_DEPTH_HIGH, ///< AVC (H.264) MFC Depth High
530 PROFILE_AVC_ENHANCED_MULTIVIEW_DEPTH_HIGH = _C2_PL_AVC_BASE + 0x400, ///< AVC (H.264) Enhanced Multiview Depth High
531
532 // HEVC profiles
533 PROFILE_HEVC_MAIN = _C2_PL_HEVC_BASE, ///< HEVC (H.265) Main
534 PROFILE_HEVC_MAIN_10, ///< HEVC (H.265) Main 10
535 PROFILE_HEVC_MAIN_STILL, ///< HEVC (H.265) Main Still Picture
536 PROFILE_HEVC_MONO = _C2_PL_HEVC_BASE + 0x100, ///< HEVC (H.265) Monochrome
537 PROFILE_HEVC_MONO_12, ///< HEVC (H.265) Monochrome 12
538 PROFILE_HEVC_MONO_16, ///< HEVC (H.265) Monochrome 16
539 PROFILE_HEVC_MAIN_12, ///< HEVC (H.265) Main 12
540 PROFILE_HEVC_MAIN_422_10, ///< HEVC (H.265) Main 4:2:2 10
541 PROFILE_HEVC_MAIN_422_12, ///< HEVC (H.265) Main 4:2:2 12
542 PROFILE_HEVC_MAIN_444, ///< HEVC (H.265) Main 4:4:4
543 PROFILE_HEVC_MAIN_444_10, ///< HEVC (H.265) Main 4:4:4 10
544 PROFILE_HEVC_MAIN_444_12, ///< HEVC (H.265) Main 4:4:4 12
545 PROFILE_HEVC_MAIN_INTRA, ///< HEVC (H.265) Main Intra
546 PROFILE_HEVC_MAIN_10_INTRA, ///< HEVC (H.265) Main 10 Intra
547 PROFILE_HEVC_MAIN_12_INTRA, ///< HEVC (H.265) Main 12 Intra
548 PROFILE_HEVC_MAIN_422_10_INTRA, ///< HEVC (H.265) Main 4:2:2 10 Intra
549 PROFILE_HEVC_MAIN_422_12_INTRA, ///< HEVC (H.265) Main 4:2:2 12 Intra
550 PROFILE_HEVC_MAIN_444_INTRA, ///< HEVC (H.265) Main 4:4:4 Intra
551 PROFILE_HEVC_MAIN_444_10_INTRA, ///< HEVC (H.265) Main 4:4:4 10 Intra
552 PROFILE_HEVC_MAIN_444_12_INTRA, ///< HEVC (H.265) Main 4:4:4 12 Intra
553 PROFILE_HEVC_MAIN_444_16_INTRA, ///< HEVC (H.265) Main 4:4:4 16 Intra
554 PROFILE_HEVC_MAIN_444_STILL, ///< HEVC (H.265) Main 4:4:4 Still Picture
555 PROFILE_HEVC_MAIN_444_16_STILL, ///< HEVC (H.265) Main 4:4:4 16 Still Picture
556 PROFILE_HEVC_HIGH_444 = _C2_PL_HEVC_BASE + 0x200, ///< HEVC (H.265) High Throughput 4:4:4
557 PROFILE_HEVC_HIGH_444_10, ///< HEVC (H.265) High Throughput 4:4:4 10
558 PROFILE_HEVC_HIGH_444_14, ///< HEVC (H.265) High Throughput 4:4:4 14
559 PROFILE_HEVC_HIGH_444_16_INTRA, ///< HEVC (H.265) High Throughput 4:4:4 16 Intra
560 PROFILE_HEVC_SX_MAIN = _C2_PL_HEVC_BASE + 0x300, ///< HEVC (H.265) Screen-Extended Main
561 PROFILE_HEVC_SX_MAIN_10, ///< HEVC (H.265) Screen-Extended Main 10
562 PROFILE_HEVC_SX_MAIN_444, ///< HEVC (H.265) Screen-Extended Main 4:4:4
563 PROFILE_HEVC_SX_MAIN_444_10, ///< HEVC (H.265) Screen-Extended Main 4:4:4 10
564 PROFILE_HEVC_SX_HIGH_444, ///< HEVC (H.265) Screen-Extended High Throughput 4:4:4
565 PROFILE_HEVC_SX_HIGH_444_10, ///< HEVC (H.265) Screen-Extended High Throughput 4:4:4 10
566 PROFILE_HEVC_SX_HIGH_444_14, ///< HEVC (H.265) Screen-Extended High Throughput 4:4:4 14
567 PROFILE_HEVC_MULTIVIEW_MAIN = _C2_PL_HEVC_BASE + 0x400, ///< HEVC (H.265) Multiview Main
568 PROFILE_HEVC_SCALABLE_MAIN = _C2_PL_HEVC_BASE + 0x500, ///< HEVC (H.265) Scalable Main
569 PROFILE_HEVC_SCALABLE_MAIN_10, ///< HEVC (H.265) Scalable Main 10
570 PROFILE_HEVC_SCALABLE_MONO = _C2_PL_HEVC_BASE + 0x600, ///< HEVC (H.265) Scalable Monochrome
571 PROFILE_HEVC_SCALABLE_MONO_12, ///< HEVC (H.265) Scalable Monochrome 12
572 PROFILE_HEVC_SCALABLE_MONO_16, ///< HEVC (H.265) Scalable Monochrome 16
573 PROFILE_HEVC_SCALABLE_MAIN_444, ///< HEVC (H.265) Scalable Main 4:4:4
574 PROFILE_HEVC_3D_MAIN = _C2_PL_HEVC_BASE + 0x700, ///< HEVC (H.265) 3D Main
575
576 // VP9 profiles
577 PROFILE_VP9_0 = _C2_PL_VP9_BASE, ///< VP9 Profile 0 (4:2:0)
578 PROFILE_VP9_1, ///< VP9 Profile 1 (4:2:2 or 4:4:4)
579 PROFILE_VP9_2, ///< VP9 Profile 2 (4:2:0, 10 or 12 bit)
580 PROFILE_VP9_3, ///< VP9 Profile 3 (4:2:2 or 4:4:4, 10 or 12 bit)
581
582 // Dolby Vision profiles
583 PROFILE_DV_AV_PER = _C2_PL_DV_BASE + 0, ///< Dolby Vision dvav.per profile (deprecated)
584 PROFILE_DV_AV_PEN, ///< Dolby Vision dvav.pen profile (deprecated)
585 PROFILE_DV_HE_DER, ///< Dolby Vision dvhe.der profile (deprecated)
586 PROFILE_DV_HE_DEN, ///< Dolby Vision dvhe.den profile (deprecated)
587 PROFILE_DV_HE_04 = _C2_PL_DV_BASE + 4, ///< Dolby Vision dvhe.04 profile
588 PROFILE_DV_HE_05 = _C2_PL_DV_BASE + 5, ///< Dolby Vision dvhe.05 profile
589 PROFILE_DV_HE_DTH, ///< Dolby Vision dvhe.dth profile (deprecated)
590 PROFILE_DV_HE_07 = _C2_PL_DV_BASE + 7, ///< Dolby Vision dvhe.07 profile
591 PROFILE_DV_HE_08 = _C2_PL_DV_BASE + 8, ///< Dolby Vision dvhe.08 profile
592 PROFILE_DV_AV_09 = _C2_PL_DV_BASE + 9, ///< Dolby Vision dvav.09 profile
593 PROFILE_DV_AV1_10 = _C2_PL_DV_BASE + 10, ///< Dolby Vision dav1.10 profile
594
595 // AV1 profiles
596 PROFILE_AV1_0 = _C2_PL_AV1_BASE, ///< AV1 Profile 0 (4:2:0, 8 to 10 bit)
597 PROFILE_AV1_1, ///< AV1 Profile 1 (8 to 10 bit)
598 PROFILE_AV1_2, ///< AV1 Profile 2 (8 to 12 bit)
599
600 // VP8 profiles
601 PROFILE_VP8_0 = _C2_PL_VP8_BASE, ///< VP8 Profile 0
602 PROFILE_VP8_1, ///< VP8 Profile 1
603 PROFILE_VP8_2, ///< VP8 Profile 2
604 PROFILE_VP8_3, ///< VP8 Profile 3
605
606 // MPEG-H 3D Audio profiles
607 PROFILE_MPEGH_MAIN = _C2_PL_MPEGH_BASE, ///< MPEG-H Main
608 PROFILE_MPEGH_HIGH, ///< MPEG-H High
609 PROFILE_MPEGH_LC, ///< MPEG-H Low-complexity
610 PROFILE_MPEGH_BASELINE, ///< MPEG-H Baseline
611
612 // Advanced Professional VideoCodec (APV)
613 PROFILE_APV_422_10 = _C2_PL_APV_BASE, ///< APV 422-10 Profile
614 PROFILE_APV_422_12, ///< APV 422-12 Profile
615 PROFILE_APV_444_10, ///< APV 444-10 Profile
616 PROFILE_APV_444_12, ///< APV 444-12 Profile
617 PROFILE_APV_4444_10, ///< APV 4444-10 Profile
618 PROFILE_APV_4444_12, ///< APV 4444-12 Profile
619 PROFILE_APV_400_10, ///< APV 400-10 Profile
620 };
621
622 enum C2Config::level_t : uint32_t {
623 LEVEL_UNUSED = 0, ///< level is not used by this media type
624
625 // MPEG-2 Video levels
626 LEVEL_MP2V_LOW = _C2_PL_MP2V_BASE, ///< MPEG-2 Video (H.262) Low Level
627 LEVEL_MP2V_MAIN, ///< MPEG-2 Video (H.262) Main Level
628 LEVEL_MP2V_HIGH_1440, ///< MPEG-2 Video (H.262) High 1440 Level
629 LEVEL_MP2V_HIGH, ///< MPEG-2 Video (H.262) High Level
630 LEVEL_MP2V_HIGHP, ///< MPEG-2 Video (H.262) HighP Level
631
632 // H.263 levels
633 LEVEL_H263_10 = _C2_PL_H263_BASE, ///< H.263 Level 10
634 LEVEL_H263_20, ///< H.263 Level 20
635 LEVEL_H263_30, ///< H.263 Level 30
636 LEVEL_H263_40, ///< H.263 Level 40
637 LEVEL_H263_45, ///< H.263 Level 45
638 LEVEL_H263_50, ///< H.263 Level 50
639 LEVEL_H263_60, ///< H.263 Level 60
640 LEVEL_H263_70, ///< H.263 Level 70
641
642 // MPEG-4 Part 2 (Video) levels
643 LEVEL_MP4V_0 = _C2_PL_MP4V_BASE, ///< MPEG-4 Video Level 0
644 LEVEL_MP4V_0B, ///< MPEG-4 Video Level 0b
645 LEVEL_MP4V_1, ///< MPEG-4 Video Level 1
646 LEVEL_MP4V_2, ///< MPEG-4 Video Level 2
647 LEVEL_MP4V_3, ///< MPEG-4 Video Level 3
648 LEVEL_MP4V_3B, ///< MPEG-4 Video Level 3b
649 LEVEL_MP4V_4, ///< MPEG-4 Video Level 4
650 LEVEL_MP4V_4A, ///< MPEG-4 Video Level 4a
651 LEVEL_MP4V_5, ///< MPEG-4 Video Level 5
652 LEVEL_MP4V_6, ///< MPEG-4 Video Level 6
653
654 // AVC / MPEG-4 Part 10 (H.264) levels
655 LEVEL_AVC_1 = _C2_PL_AVC_BASE, ///< AVC (H.264) Level 1
656 LEVEL_AVC_1B, ///< AVC (H.264) Level 1b
657 LEVEL_AVC_1_1, ///< AVC (H.264) Level 1.1
658 LEVEL_AVC_1_2, ///< AVC (H.264) Level 1.2
659 LEVEL_AVC_1_3, ///< AVC (H.264) Level 1.3
660 LEVEL_AVC_2, ///< AVC (H.264) Level 2
661 LEVEL_AVC_2_1, ///< AVC (H.264) Level 2.1
662 LEVEL_AVC_2_2, ///< AVC (H.264) Level 2.2
663 LEVEL_AVC_3, ///< AVC (H.264) Level 3
664 LEVEL_AVC_3_1, ///< AVC (H.264) Level 3.1
665 LEVEL_AVC_3_2, ///< AVC (H.264) Level 3.2
666 LEVEL_AVC_4, ///< AVC (H.264) Level 4
667 LEVEL_AVC_4_1, ///< AVC (H.264) Level 4.1
668 LEVEL_AVC_4_2, ///< AVC (H.264) Level 4.2
669 LEVEL_AVC_5, ///< AVC (H.264) Level 5
670 LEVEL_AVC_5_1, ///< AVC (H.264) Level 5.1
671 LEVEL_AVC_5_2, ///< AVC (H.264) Level 5.2
672 LEVEL_AVC_6, ///< AVC (H.264) Level 6
673 LEVEL_AVC_6_1, ///< AVC (H.264) Level 6.1
674 LEVEL_AVC_6_2, ///< AVC (H.264) Level 6.2
675
676 // HEVC (H.265) tiers and levels
677 LEVEL_HEVC_MAIN_1 = _C2_PL_HEVC_BASE, ///< HEVC (H.265) Main Tier Level 1
678 LEVEL_HEVC_MAIN_2, ///< HEVC (H.265) Main Tier Level 2
679 LEVEL_HEVC_MAIN_2_1, ///< HEVC (H.265) Main Tier Level 2.1
680 LEVEL_HEVC_MAIN_3, ///< HEVC (H.265) Main Tier Level 3
681 LEVEL_HEVC_MAIN_3_1, ///< HEVC (H.265) Main Tier Level 3.1
682 LEVEL_HEVC_MAIN_4, ///< HEVC (H.265) Main Tier Level 4
683 LEVEL_HEVC_MAIN_4_1, ///< HEVC (H.265) Main Tier Level 4.1
684 LEVEL_HEVC_MAIN_5, ///< HEVC (H.265) Main Tier Level 5
685 LEVEL_HEVC_MAIN_5_1, ///< HEVC (H.265) Main Tier Level 5.1
686 LEVEL_HEVC_MAIN_5_2, ///< HEVC (H.265) Main Tier Level 5.2
687 LEVEL_HEVC_MAIN_6, ///< HEVC (H.265) Main Tier Level 6
688 LEVEL_HEVC_MAIN_6_1, ///< HEVC (H.265) Main Tier Level 6.1
689 LEVEL_HEVC_MAIN_6_2, ///< HEVC (H.265) Main Tier Level 6.2
690
691 LEVEL_HEVC_HIGH_4 = _C2_PL_HEVC_BASE + 0x100, ///< HEVC (H.265) High Tier Level 4
692 LEVEL_HEVC_HIGH_4_1, ///< HEVC (H.265) High Tier Level 4.1
693 LEVEL_HEVC_HIGH_5, ///< HEVC (H.265) High Tier Level 5
694 LEVEL_HEVC_HIGH_5_1, ///< HEVC (H.265) High Tier Level 5.1
695 LEVEL_HEVC_HIGH_5_2, ///< HEVC (H.265) High Tier Level 5.2
696 LEVEL_HEVC_HIGH_6, ///< HEVC (H.265) High Tier Level 6
697 LEVEL_HEVC_HIGH_6_1, ///< HEVC (H.265) High Tier Level 6.1
698 LEVEL_HEVC_HIGH_6_2, ///< HEVC (H.265) High Tier Level 6.2
699
700 // VP9 levels
701 LEVEL_VP9_1 = _C2_PL_VP9_BASE, ///< VP9 Level 1
702 LEVEL_VP9_1_1, ///< VP9 Level 1.1
703 LEVEL_VP9_2, ///< VP9 Level 2
704 LEVEL_VP9_2_1, ///< VP9 Level 2.1
705 LEVEL_VP9_3, ///< VP9 Level 3
706 LEVEL_VP9_3_1, ///< VP9 Level 3.1
707 LEVEL_VP9_4, ///< VP9 Level 4
708 LEVEL_VP9_4_1, ///< VP9 Level 4.1
709 LEVEL_VP9_5, ///< VP9 Level 5
710 LEVEL_VP9_5_1, ///< VP9 Level 5.1
711 LEVEL_VP9_5_2, ///< VP9 Level 5.2
712 LEVEL_VP9_6, ///< VP9 Level 6
713 LEVEL_VP9_6_1, ///< VP9 Level 6.1
714 LEVEL_VP9_6_2, ///< VP9 Level 6.2
715
716 // Dolby Vision levels
717 LEVEL_DV_MAIN_HD_24 = _C2_PL_DV_BASE, ///< Dolby Vision main tier hd24
718 LEVEL_DV_MAIN_HD_30, ///< Dolby Vision main tier hd30
719 LEVEL_DV_MAIN_FHD_24, ///< Dolby Vision main tier fhd24
720 LEVEL_DV_MAIN_FHD_30, ///< Dolby Vision main tier fhd30
721 LEVEL_DV_MAIN_FHD_60, ///< Dolby Vision main tier fhd60
722 LEVEL_DV_MAIN_UHD_24, ///< Dolby Vision main tier uhd24
723 LEVEL_DV_MAIN_UHD_30, ///< Dolby Vision main tier uhd30
724 LEVEL_DV_MAIN_UHD_48, ///< Dolby Vision main tier uhd48
725 LEVEL_DV_MAIN_UHD_60, ///< Dolby Vision main tier uhd60
726 LEVEL_DV_MAIN_UHD_120, ///< Dolby Vision main tier uhd120
727 LEVEL_DV_MAIN_8K_30, ///< Dolby Vision main tier 8k30
728 LEVEL_DV_MAIN_8K_60, ///< Dolby Vision main tier 8k60
729
730 LEVEL_DV_HIGH_HD_24 = _C2_PL_DV_BASE + 0x100, ///< Dolby Vision high tier hd24
731 LEVEL_DV_HIGH_HD_30, ///< Dolby Vision high tier hd30
732 LEVEL_DV_HIGH_FHD_24, ///< Dolby Vision high tier fhd24
733 LEVEL_DV_HIGH_FHD_30, ///< Dolby Vision high tier fhd30
734 LEVEL_DV_HIGH_FHD_60, ///< Dolby Vision high tier fhd60
735 LEVEL_DV_HIGH_UHD_24, ///< Dolby Vision high tier uhd24
736 LEVEL_DV_HIGH_UHD_30, ///< Dolby Vision high tier uhd30
737 LEVEL_DV_HIGH_UHD_48, ///< Dolby Vision high tier uhd48
738 LEVEL_DV_HIGH_UHD_60, ///< Dolby Vision high tier uhd60
739 LEVEL_DV_HIGH_UHD_120, ///< Dolby Vision high tier uhd120
740 LEVEL_DV_HIGH_8K_30, ///< Dolby Vision high tier 8k30
741 LEVEL_DV_HIGH_8K_60, ///< Dolby Vision high tier 8k60
742
743 // AV1 levels
744 LEVEL_AV1_2 = _C2_PL_AV1_BASE , ///< AV1 Level 2
745 LEVEL_AV1_2_1, ///< AV1 Level 2.1
746 LEVEL_AV1_2_2, ///< AV1 Level 2.2
747 LEVEL_AV1_2_3, ///< AV1 Level 2.3
748 LEVEL_AV1_3, ///< AV1 Level 3
749 LEVEL_AV1_3_1, ///< AV1 Level 3.1
750 LEVEL_AV1_3_2, ///< AV1 Level 3.2
751 LEVEL_AV1_3_3, ///< AV1 Level 3.3
752 LEVEL_AV1_4, ///< AV1 Level 4
753 LEVEL_AV1_4_1, ///< AV1 Level 4.1
754 LEVEL_AV1_4_2, ///< AV1 Level 4.2
755 LEVEL_AV1_4_3, ///< AV1 Level 4.3
756 LEVEL_AV1_5, ///< AV1 Level 5
757 LEVEL_AV1_5_1, ///< AV1 Level 5.1
758 LEVEL_AV1_5_2, ///< AV1 Level 5.2
759 LEVEL_AV1_5_3, ///< AV1 Level 5.3
760 LEVEL_AV1_6, ///< AV1 Level 6
761 LEVEL_AV1_6_1, ///< AV1 Level 6.1
762 LEVEL_AV1_6_2, ///< AV1 Level 6.2
763 LEVEL_AV1_6_3, ///< AV1 Level 6.3
764 LEVEL_AV1_7, ///< AV1 Level 7
765 LEVEL_AV1_7_1, ///< AV1 Level 7.1
766 LEVEL_AV1_7_2, ///< AV1 Level 7.2
767 LEVEL_AV1_7_3, ///< AV1 Level 7.3
768
769 // MPEG-H 3D Audio levels
770 LEVEL_MPEGH_1 = _C2_PL_MPEGH_BASE, ///< MPEG-H L1
771 LEVEL_MPEGH_2, ///< MPEG-H L2
772 LEVEL_MPEGH_3, ///< MPEG-H L3
773 LEVEL_MPEGH_4, ///< MPEG-H L4
774 LEVEL_MPEGH_5, ///< MPEG-H L5
775
776 // Advanced Professional VideoCodec(APV) levels/bands
777 LEVEL_APV_1_BAND_0 = _C2_PL_APV_BASE, ///< APV L 1, BAND 0
778 LEVEL_APV_1_1_BAND_0, ///< APV L 1.1, BAND 0
779 LEVEL_APV_2_BAND_0, ///< APV L 2, BAND 0
780 LEVEL_APV_2_1_BAND_0, ///< APV L 2.1, BAND 0
781 LEVEL_APV_3_BAND_0, ///< APV L 3, BAND 0
782 LEVEL_APV_3_1_BAND_0, ///< APV L 3.1, BAND 0
783 LEVEL_APV_4_BAND_0, ///< APV L 4, BAND 0
784 LEVEL_APV_4_1_BAND_0, ///< APV L 4.1, BAND 0
785 LEVEL_APV_5_BAND_0, ///< APV L 5, BAND 0
786 LEVEL_APV_5_1_BAND_0, ///< APV L 5.1, BAND 0
787 LEVEL_APV_6_BAND_0, ///< APV L 6, BAND 0
788 LEVEL_APV_6_1_BAND_0, ///< APV L 6.1, BAND 0
789 LEVEL_APV_7_BAND_0, ///< APV L 7, BAND 0
790 LEVEL_APV_7_1_BAND_0, ///< APV L 7.1, BAND 0
791
792 LEVEL_APV_1_BAND_1 = _C2_PL_APV_BASE + 0x100, ///< APV L 1, BAND 1
793 LEVEL_APV_1_1_BAND_1, ///< APV L 1.1, BAND 1
794 LEVEL_APV_2_BAND_1, ///< APV L 2, BAND 1
795 LEVEL_APV_2_1_BAND_1, ///< APV L 2.1, BAND 1
796 LEVEL_APV_3_BAND_1, ///< APV L 3, BAND 1
797 LEVEL_APV_3_1_BAND_1, ///< APV L 3.1, BAND 1
798 LEVEL_APV_4_BAND_1, ///< APV L 4, BAND 1
799 LEVEL_APV_4_1_BAND_1, ///< APV L 4.1, BAND 1
800 LEVEL_APV_5_BAND_1, ///< APV L 5, BAND 1
801 LEVEL_APV_5_1_BAND_1, ///< APV L 5.1, BAND 1
802 LEVEL_APV_6_BAND_1, ///< APV L 6, BAND 1
803 LEVEL_APV_6_1_BAND_1, ///< APV L 6.1, BAND 1
804 LEVEL_APV_7_BAND_1, ///< APV L 7, BAND 1
805 LEVEL_APV_7_1_BAND_1, ///< APV L 7.1, BAND 1
806
807 LEVEL_APV_1_BAND_2 = _C2_PL_APV_BASE + 0x200, ///< APV L 1, BAND 2
808 LEVEL_APV_1_1_BAND_2, ///< APV L 1.1, BAND 2
809 LEVEL_APV_2_BAND_2, ///< APV L 2, BAND 2
810 LEVEL_APV_2_1_BAND_2, ///< APV L 2.1, BAND 2
811 LEVEL_APV_3_BAND_2, ///< APV L 3, BAND 2
812 LEVEL_APV_3_1_BAND_2, ///< APV L 3.1, BAND 2
813 LEVEL_APV_4_BAND_2, ///< APV L 4, BAND 2
814 LEVEL_APV_4_1_BAND_2, ///< APV L 4.1, BAND 2
815 LEVEL_APV_5_BAND_2, ///< APV L 5, BAND 2
816 LEVEL_APV_5_1_BAND_2, ///< APV L 5.1, BAND 2
817 LEVEL_APV_6_BAND_2, ///< APV L 6, BAND 2
818 LEVEL_APV_6_1_BAND_2, ///< APV L 6.1, BAND 2
819 LEVEL_APV_7_BAND_2, ///< APV L 7, BAND 2
820 LEVEL_APV_7_1_BAND_2, ///< APV L 7.1, BAND 2
821
822 LEVEL_APV_1_BAND_3 = _C2_PL_APV_BASE + 0x300, ///< APV L 1, BAND 3
823 LEVEL_APV_1_1_BAND_3, ///< APV L 1.1, BAND 3
824 LEVEL_APV_2_BAND_3, ///< APV L 2, BAND 3
825 LEVEL_APV_2_1_BAND_3, ///< APV L 2.1, BAND 3
826 LEVEL_APV_3_BAND_3, ///< APV L 3, BAND 3
827 LEVEL_APV_3_1_BAND_3, ///< APV L 3.1, BAND 3
828 LEVEL_APV_4_BAND_3, ///< APV L 4, BAND 3
829 LEVEL_APV_4_1_BAND_3, ///< APV L 4.1, BAND 3
830 LEVEL_APV_5_BAND_3, ///< APV L 5, BAND 3
831 LEVEL_APV_5_1_BAND_3, ///< APV L 5.1, BAND 3
832 LEVEL_APV_6_BAND_3, ///< APV L 6, BAND 3
833 LEVEL_APV_6_1_BAND_3, ///< APV L 6.1, BAND 3
834 LEVEL_APV_7_BAND_3, ///< APV L 7, BAND 3
835 LEVEL_APV_7_1_BAND_3, ///< APV L 7.1, BAND 3
836
837 };
838
839 struct C2ProfileLevelStruct {
840 C2Config::profile_t profile; ///< coding profile
841 C2Config::level_t level; ///< coding level
842
843 C2ProfileLevelStruct(
844 C2Config::profile_t profile_ = C2Config::PROFILE_UNUSED,
845 C2Config::level_t level_ = C2Config::LEVEL_UNUSED)
profileC2ProfileLevelStruct846 : profile(profile_), level(level_) { }
847
848 DEFINE_AND_DESCRIBE_C2STRUCT(ProfileLevel)
849 C2FIELD(profile, "profile")
850 C2FIELD(level, "level")
851 };
852
853 // TODO: may need to make this explicit (have .set member)
854 typedef C2StreamParam<C2Info, C2ProfileLevelStruct, kParamIndexProfileLevel>
855 C2StreamProfileLevelInfo;
856 constexpr char C2_PARAMKEY_PROFILE_LEVEL[] = "coded.pl";
857
858 /**
859 * Codec-specific initialization data.
860 *
861 * This is initialization data for the codec.
862 *
863 * For AVC/HEVC, these are the concatenated SPS/PPS/VPS NALs.
864 *
865 * TODO: define for other codecs.
866 */
867 typedef C2StreamParam<C2Info, C2BlobValue, kParamIndexInitData> C2StreamInitDataInfo;
868 constexpr char C2_PARAMKEY_INIT_DATA[] = "coded.init-data";
869
870 /**
871 * Supplemental Data.
872 *
873 * This is coding-specific supplemental informational data, e.g. SEI for AVC/HEVC.
874 * This structure is not a configuration so it does not have a parameter key.
875 * This structure shall be returned in the configuration update, and can be repeated as needed
876 * in the same update.
877 */
878 C2ENUM(C2Config::supplemental_info_t, uint32_t,
879 INFO_NONE = 0,
880
881 INFO_PREFIX_SEI_UNIT = 0x10000, ///< prefix SEI payload types add this flag
882 INFO_SUFFIX_SEI_UNIT = 0x20000, ///< suffix SEI payload types add this flag
883
884 INFO_SEI_USER_DATA = INFO_PREFIX_SEI_UNIT | 4, ///< closed-captioning data (ITU-T T35)
885 INFO_SEI_MDCV = INFO_PREFIX_SEI_UNIT | 137, ///< mastering display color volume
886 INFO_SET_USER_DATA_SFX = INFO_SUFFIX_SEI_UNIT | 4, ///< closed-captioning data (ITU-T T35)
887
888 INFO_VENDOR_START = 0x70000000
889 )
890
891 struct C2SupplementalDataStruct {
C2SupplementalDataStructC2SupplementalDataStruct892 C2SupplementalDataStruct()
893 : type_(INFO_NONE) { }
894
C2SupplementalDataStructC2SupplementalDataStruct895 C2SupplementalDataStruct(
896 size_t flexCount, C2Config::supplemental_info_t type, std::vector<uint8_t> data_)
897 : type_(type) {
898 memcpy(data, &data_[0], c2_min(data_.size(), flexCount));
899 }
900
901 C2Config::supplemental_info_t type_;
902 uint8_t data[];
903
904 DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(SupplementalData, data)
905 C2FIELD(type_, "type")
906 C2FIELD(data, "data")
907 };
908 typedef C2StreamParam<C2Info, C2SupplementalDataStruct, kParamIndexSupplementalData>
909 C2StreamSupplementalDataInfo;
910
911 /**
912 * Supplemental Data Subscription
913 */
914 typedef C2StreamParam<C2Tuning, C2SimpleArrayStruct<C2Config::supplemental_info_t>,
915 kParamIndexSubscribedSupplementalData>
916 C2StreamSubscribedSupplementalDataTuning;
917 constexpr char C2_PARAMKEY_SUBSCRIBED_SUPPLEMENTAL_DATA[] = "output.subscribed-supplemental";
918
919 /* ---------------------------------- pipeline characteristics ---------------------------------- */
920
921 /**
922 * Media-type.
923 *
924 * This is defined for both port and stream, but stream media type may be a subtype of the
925 * port media type.
926 */
927 typedef C2PortParam<C2Setting, C2StringValue, kParamIndexMediaType> C2PortMediaTypeSetting;
928 constexpr char C2_PARAMKEY_INPUT_MEDIA_TYPE[] = "input.media-type";
929 constexpr char C2_PARAMKEY_OUTPUT_MEDIA_TYPE[] = "output.media-type";
930
931 typedef C2StreamParam<C2Setting, C2StringValue, kParamIndexMediaType> C2StreamMediaTypeSetting;
932
933 /**
934 * Pipeline delays.
935 *
936 * Input delay is the number of additional input frames requested by the component to process
937 * an input frame.
938 *
939 * Output delay is the number of additional output frames that need to be generated before an
940 * output can be released by the component.
941 *
942 * Pipeline delay is the number of additional frames that are processed at one time by the
943 * component.
944 *
945 * As these may vary from frame to frame, the number is the maximum required value. E.g. if
946 * input delay is 0, the component is expected to consume each frame queued even if no further
947 * frames are queued. Similarly, if input delay is 1, as long as there are always exactly 2
948 * outstanding input frames queued to the component, it shall produce output.
949 */
950
951 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexDelay | C2Param::CoreIndex::IS_REQUEST_FLAG>
952 C2PortRequestedDelayTuning;
953 constexpr char C2_PARAMKEY_INPUT_DELAY_REQUEST[] = "input.delay"; // deprecated
954 constexpr char C2_PARAMKEY_OUTPUT_DELAY_REQUEST[] = "output.delay"; // deprecated
955
956 typedef C2GlobalParam<C2Tuning, C2Uint32Value,
957 kParamIndexDelay | C2Param::CoreIndex::IS_REQUEST_FLAG>
958 C2RequestedPipelineDelayTuning;
959 constexpr char C2_PARAMKEY_PIPELINE_DELAY_REQUEST[] = "algo.delay"; // deprecated
960
961 // read-only
962 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexDelay> C2PortDelayTuning;
963 typedef C2PortDelayTuning C2PortActualDelayTuning; // deprecated
964 constexpr char C2_PARAMKEY_INPUT_DELAY[] = "input.delay";
965 constexpr char C2_PARAMKEY_OUTPUT_DELAY[] = "output.delay";
966
967 // read-only
968 typedef C2GlobalParam<C2Tuning, C2Uint32Value, kParamIndexDelay> C2PipelineDelayTuning;
969 typedef C2PipelineDelayTuning C2ActualPipelineDelayTuning; // deprecated
970 constexpr char C2_PARAMKEY_PIPELINE_DELAY[] = "algo.delay";
971
972 /**
973 * Enable/disable low latency mode.
974 * If true, low latency is preferred over low power. Disable power optimizations that
975 * may result in increased latency. For decoders, this means that the decoder does not
976 * hold input and output data more than required by the codec standards.
977 */
978 typedef C2GlobalParam<C2Tuning, C2EasyBoolValue, kParamIndexLowLatencyMode>
979 C2GlobalLowLatencyModeTuning;
980 constexpr char C2_PARAMKEY_LOW_LATENCY_MODE[] = "algo.low-latency";
981
982 /**
983 * Reference characteristics.
984 *
985 * The component may hold onto input and output buffers even after completing the corresponding
986 * work item.
987 *
988 * Max reference age is the longest number of additional frame processing that a component may
989 * hold onto a buffer for. Max reference count is the number of buffers that a component may
990 * hold onto at the same time at the worst case. These numbers assume single frame per buffers.
991 *
992 * Use max-uint32 if there is no limit for the max age or count.
993 */
994 typedef C2StreamParam<C2Tuning, C2Uint32Value, kParamIndexMaxReferenceAge>
995 C2StreamMaxReferenceAgeTuning;
996 constexpr char C2_PARAMKEY_INPUT_MAX_REFERENCE_AGE[] = "input.reference.max-age";
997 constexpr char C2_PARAMKEY_OUTPUT_MAX_REFERENCE_AGE[] = "output.reference.max-age";
998
999 typedef C2StreamParam<C2Tuning, C2Uint32Value, kParamIndexMaxReferenceCount>
1000 C2StreamMaxReferenceCountTuning;
1001 constexpr char C2_PARAMKEY_INPUT_MAX_REFERENCE_COUNT[] = "input.reference.max-count";
1002 constexpr char C2_PARAMKEY_OUTPUT_MAX_REFERENCE_COUNT[] = "output.reference.max-count";
1003
1004 /**
1005 * Output reordering.
1006 *
1007 * The size of the window to use for output buffer reordering. 0 is interpreted as 1.
1008 */
1009 // output only
1010 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexReorderBufferDepth>
1011 C2PortReorderBufferDepthTuning;
1012 constexpr char C2_PARAMKEY_OUTPUT_REORDER_DEPTH[] = "output.reorder.depth";
1013
1014 C2ENUM(C2Config::ordinal_key_t, uint32_t,
1015 ORDINAL,
1016 TIMESTAMP,
1017 CUSTOM)
1018
1019 // read-only, output only
1020 typedef C2PortParam<C2Setting, C2SimpleValueStruct<C2Config::ordinal_key_t>, kParamIndexReorderKey>
1021 C2PortReorderKeySetting;
1022 constexpr char C2_PARAMKEY_OUTPUT_REORDER_KEY[] = "output.reorder.key";
1023
1024 /**
1025 * Stream count.
1026 */
1027 // private
1028 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexStreamCount> C2PortStreamCountTuning;
1029 constexpr char C2_PARAMKEY_INPUT_STREAM_COUNT[] = "input.stream-count";
1030 constexpr char C2_PARAMKEY_OUTPUT_STREAM_COUNT[] = "output.stream-count";
1031
1032 /**
1033 * Config update subscription.
1034 */
1035 // private
1036 typedef C2GlobalParam<C2Tuning, C2Uint32Array, kParamIndexSubscribedParamIndices>
1037 C2SubscribedParamIndicesTuning;
1038 constexpr char C2_PARAMKEY_SUBSCRIBED_PARAM_INDICES[] = "output.subscribed-indices";
1039
1040 /**
1041 * Suggested buffer (C2Frame) count. This is a suggestion by the component for the number of
1042 * input and output frames allocated for the component's use in the buffer pools.
1043 *
1044 * Component shall set the acceptable range of buffers allocated for it. E.g. client shall
1045 * allocate at least the minimum required value.
1046 */
1047 // read-only
1048 typedef C2PortParam<C2Tuning, C2Uint64Array, kParamIndexSuggestedBufferCount>
1049 C2PortSuggestedBufferCountTuning;
1050 constexpr char C2_PARAMKEY_INPUT_SUGGESTED_BUFFER_COUNT[] = "input.buffers.pool-size";
1051 constexpr char C2_PARAMKEY_OUTPUT_SUGGESTED_BUFFER_COUNT[] = "output.buffers.pool-size";
1052
1053 /**
1054 * Input/output batching.
1055 *
1056 * For input, component requests that client batches work in batches of specified size. For output,
1057 * client requests that the component batches work completion in given batch size.
1058 * Value 0 means don't care.
1059 */
1060 typedef C2PortParam<C2Tuning, C2Uint64Array, kParamIndexBatchSize> C2PortBatchSizeTuning;
1061 constexpr char C2_PARAMKEY_INPUT_BATCH_SIZE[] = "input.buffers.batch-size";
1062 constexpr char C2_PARAMKEY_OUTPUT_BATCH_SIZE[] = "output.buffers.batch-size";
1063
1064 /**
1065 * Current & last work ordinals.
1066 *
1067 * input port: last work queued to component.
1068 * output port: last work completed by component.
1069 * global: current work.
1070 */
1071 typedef C2PortParam<C2Tuning, C2WorkOrdinalStruct, kParamIndexLastWorkQueued> C2LastWorkQueuedTuning;
1072 typedef C2GlobalParam<C2Tuning, C2WorkOrdinalStruct, kParamIndexCurrentWork> C2CurrentWorkTuning;
1073
1074
1075 /* ------------------------------------- memory allocation ------------------------------------- */
1076
1077 /**
1078 * Allocators to use.
1079 *
1080 * These are requested by the component.
1081 *
1082 * If none specified, client will use the default allocator ID based on the component domain and
1083 * kind.
1084 */
1085 typedef C2PortParam<C2Tuning, C2SimpleArrayStruct<C2Allocator::id_t>, kParamIndexAllocators>
1086 C2PortAllocatorsTuning;
1087 constexpr char C2_PARAMKEY_INPUT_ALLOCATORS[] = "input.buffers.allocator-ids";
1088 constexpr char C2_PARAMKEY_OUTPUT_ALLOCATORS[] = "output.buffers.allocator-ids";
1089
1090 typedef C2GlobalParam<C2Tuning, C2SimpleArrayStruct<C2Allocator::id_t>, kParamIndexAllocators>
1091 C2PrivateAllocatorsTuning;
1092 constexpr char C2_PARAMKEY_PRIVATE_ALLOCATORS[] = "algo.buffers.allocator-ids";
1093
1094 /**
1095 * Allocator to use for outputting to surface.
1096 *
1097 * Components can optionally request allocator type for outputting to surface.
1098 *
1099 * If none specified, client will use the default BufferQueue-backed allocator ID for outputting to
1100 * surface.
1101 */
1102 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexSurfaceAllocator>
1103 C2PortSurfaceAllocatorTuning;
1104 constexpr char C2_PARAMKEY_OUTPUT_SURFACE_ALLOCATOR[] = "output.buffers.surface-allocator-id";
1105
1106 /**
1107 * Block pools to use.
1108 *
1109 * These are allocated by the client for the component using the allocator IDs specified by the
1110 * component. This is not used for the input port.
1111 */
1112 typedef C2PortParam<C2Tuning, C2SimpleArrayStruct<C2BlockPool::local_id_t>, kParamIndexBlockPools>
1113 C2PortBlockPoolsTuning;
1114 constexpr char C2_PARAMKEY_OUTPUT_BLOCK_POOLS[] = "output.buffers.pool-ids";
1115
1116 typedef C2GlobalParam<C2Tuning, C2SimpleArrayStruct<C2BlockPool::local_id_t>, kParamIndexBlockPools>
1117 C2PrivateBlockPoolsTuning;
1118 constexpr char C2_PARAMKEY_PRIVATE_BLOCK_POOLS[] = "algo.buffers.pool-ids";
1119
1120 /**
1121 * The max number of private allocations at any one time by the component.
1122 * (This is an array with a corresponding value for each private allocator)
1123 */
1124 typedef C2GlobalParam<C2Tuning, C2Uint32Array, kParamIndexMaxReferenceCount>
1125 C2MaxPrivateBufferCountTuning;
1126 constexpr char C2_PARAMKEY_MAX_PRIVATE_BUFFER_COUNT[] = "algo.buffers.max-count";
1127
1128 /**
1129 * Buffer type
1130 *
1131 * This is provided by the component for the client to allocate the proper buffer type for the
1132 * input port, and can be provided by the client to control the buffer type for the output.
1133 */
1134 // private
1135 typedef C2StreamParam<C2Setting, C2SimpleValueStruct<C2EasyEnum<C2BufferData::type_t>>,
1136 kParamIndexBufferType>
1137 C2StreamBufferTypeSetting;
1138 constexpr char C2_PARAMKEY_INPUT_STREAM_BUFFER_TYPE[] = "input.buffers.type";
1139 constexpr char C2_PARAMKEY_OUTPUT_STREAM_BUFFER_TYPE[] = "output.buffers.type";
1140
1141 /**
1142 * Memory usage.
1143 *
1144 * Suggested by component for input and negotiated between client and component for output.
1145 */
1146 typedef C2StreamParam<C2Tuning, C2Uint64Value, kParamIndexUsage> C2StreamUsageTuning;
1147 constexpr char C2_PARAMKEY_INPUT_STREAM_USAGE[] = "input.buffers.usage";
1148 constexpr char C2_PARAMKEY_OUTPUT_STREAM_USAGE[] = "output.buffers.usage";
1149
1150 /**
1151 * Picture (video or image frame) size.
1152 */
1153 struct C2PictureSizeStruct {
C2PictureSizeStructC2PictureSizeStruct1154 inline C2PictureSizeStruct()
1155 : width(0), height(0) { }
1156
C2PictureSizeStructC2PictureSizeStruct1157 inline C2PictureSizeStruct(uint32_t width_, uint32_t height_)
1158 : width(width_), height(height_) { }
1159
1160 uint32_t width; ///< video width
1161 uint32_t height; ///< video height
1162
1163 DEFINE_AND_DESCRIBE_C2STRUCT(PictureSize)
1164 C2FIELD(width, "width")
1165 C2FIELD(height, "height")
1166 };
1167
1168 /**
1169 * Out of memory signaling
1170 *
1171 * This is a configuration for the client to mark that it cannot allocate necessary private and/
1172 * or output buffers to continue operation, and to signal the failing configuration.
1173 */
1174 struct C2OutOfMemoryStruct {
1175 C2BlockPool::local_id_t pool; ///< pool ID that failed the allocation
1176 uint64_t usage; ///< memory usage used
1177 C2PictureSizeStruct planar; ///< buffer dimensions to be allocated if 2D
1178 uint32_t format; ///< pixel format to be used if 2D
1179 uint32_t capacity; ///< buffer capacity to be allocated if 1D
1180 c2_bool_t outOfMemory; ///< true if component is out of memory
1181
1182 DEFINE_AND_DESCRIBE_C2STRUCT(OutOfMemory)
1183 C2FIELD(pool, "pool")
1184 C2FIELD(usage, "usage")
1185 C2FIELD(planar, "planar")
1186 C2FIELD(format, "format")
1187 C2FIELD(capacity, "capacity")
1188 C2FIELD(outOfMemory, "out-of-memory")
1189 };
1190
1191 typedef C2GlobalParam<C2Tuning, C2OutOfMemoryStruct, kParamIndexOutOfMemory> C2OutOfMemoryTuning;
1192 constexpr char C2_PARAMKEY_OUT_OF_MEMORY[] = "algo.oom";
1193
1194 /**
1195 * Max buffer size
1196 *
1197 * This is a hint provided by the component for the maximum buffer size expected on a stream for the
1198 * current configuration on its input and output streams. This is communicated to clients so they
1199 * can preallocate input buffers, or configure downstream components that require a maximum size on
1200 * their buffers.
1201 *
1202 * Read-only. Required to be provided by components on all compressed streams.
1203 */
1204 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexMaxBufferSize> C2StreamMaxBufferSizeInfo;
1205 constexpr char C2_PARAMKEY_INPUT_MAX_BUFFER_SIZE[] = "input.buffers.max-size";
1206 constexpr char C2_PARAMKEY_OUTPUT_MAX_BUFFER_SIZE[] = "output.buffers.max-size";
1207
1208 /**
1209 * Large frame struct
1210 *
1211 * This structure describes the size limits for large frames (frames with multiple
1212 * access units.)
1213 */
1214 struct C2LargeFrameStruct {
1215 uint32_t maxSize; ///< maximum size of the buffer in bytes
1216 uint32_t thresholdSize; ///< size threshold for the buffer in bytes. The buffer is considered
1217 ///< full as soon as its size reaches or surpasses this limit.
C2LargeFrameStructC2LargeFrameStruct1218 C2LargeFrameStruct()
1219 : maxSize(0),
1220 thresholdSize(0) {}
1221
C2LargeFrameStructC2LargeFrameStruct1222 C2LargeFrameStruct(uint32_t maxSize_, uint32_t thresholdSize_)
1223 : maxSize(maxSize_), thresholdSize(thresholdSize_) {}
1224
1225 DEFINE_AND_DESCRIBE_C2STRUCT(LargeFrame)
1226 C2FIELD(maxSize, "max-size")
1227 C2FIELD(thresholdSize, "threshold-size")
1228 };
1229
1230 /**
1231 * This tuning controls the size limits for large output frames for the component.
1232 * The default value for this tuning is platform specific.
1233 */
1234 typedef C2StreamParam<C2Tuning, C2LargeFrameStruct, kParamIndexLargeFrame>
1235 C2LargeFrame;
1236 constexpr char C2_PARAMKEY_OUTPUT_LARGE_FRAME[] = "output.large-frame";
1237
1238 /* ---------------------------------------- misc. state ---------------------------------------- */
1239
1240 /**
1241 * Tripped state,
1242 *
1243 * This state exists to be able to provide reasoning for a tripped state during normal
1244 * interface operations, as well as to allow client to trip the component on demand.
1245 */
1246 typedef C2GlobalParam<C2Tuning, C2BoolValue, kParamIndexTripped>
1247 C2TrippedTuning;
1248 constexpr char C2_PARAMKEY_TRIPPED[] = "algo.tripped";
1249
1250 /**
1251 * Configuration counters.
1252 *
1253 * Configurations are tracked using three counters. The input counter is incremented exactly
1254 * once with each work accepted by the component. The output counter is incremented exactly
1255 * once with each work completed by the component (in the order of work completion). The
1256 * global counter is incremented exactly once during to each config() call. These counters
1257 * shall be read-only.
1258 *
1259 * TODO: these should be counters.
1260 */
1261 typedef C2PortParam<C2Tuning, C2Uint64Value, kParamIndexConfigCounter> C2PortConfigCounterTuning;
1262 typedef C2GlobalParam<C2Tuning, C2Uint64Value, kParamIndexConfigCounter> C2ConfigCounterTuning;
1263 constexpr char C2_PARAMKEY_INPUT_COUNTER[] = "input.buffers.counter";
1264 constexpr char C2_PARAMKEY_OUTPUT_COUNTER[] = "output.buffers.counter";
1265 constexpr char C2_PARAMKEY_CONFIG_COUNTER[] = "algo.config.counter";
1266
1267 /* ----------------------------------------- resources ----------------------------------------- */
1268
1269 /**
1270 * Resource kind.
1271 */
1272 C2ENUM(C2Config::resource_kind_t, uint32_t,
1273 CONST,
1274 PER_FRAME,
1275 PER_INPUT_BLOCK,
1276 PER_OUTPUT_BLOCK
1277 )
1278
1279 /**
1280 * Definition of a system resource use.
1281 *
1282 * [PROPOSED]
1283 *
1284 * System resources are defined by the default component store.
1285 * They represent any physical or abstract entities of limited availability
1286 * that is required for a component instance to execute and process work.
1287 *
1288 * Each defined resource has an id.
1289 * The use of a resource is specified by the amount and the kind (e.g. whether the amount
1290 * of resources is required for each frame processed, or whether they are required
1291 * regardless of the processing rate (const amount)).
1292 *
1293 * Note: implementations can shadow this structure with their own custom resource
1294 * structure where a uint32_t based enum is used for id.
1295 * This can be used to provide a name for each resource, via parameter descriptors.
1296 */
1297
1298 struct C2SystemResourceStruct {
C2SystemResourceStructC2SystemResourceStruct1299 C2SystemResourceStruct(uint32_t id_,
1300 C2Config::resource_kind_t kind_,
1301 uint64_t amount_)
1302 : id(id_), kind(kind_), amount(amount_) { }
1303 uint32_t id;
1304 C2Config::resource_kind_t kind;
1305 uint64_t amount;
1306
1307 DEFINE_AND_DESCRIBE_C2STRUCT(SystemResource)
1308 C2FIELD(id, "id")
1309 C2FIELD(kind, "kind")
1310 C2FIELD(amount, "amount")
1311 };
1312
1313 /**
1314 * Total system resource capacity.
1315 *
1316 * [PROPOSED]
1317 *
1318 * This setting is implemented by the default component store.
1319 * The total resource capacity is specified as the maximum amount for each resource ID
1320 * that is supported by the device hardware or firmware.
1321 * As such, the kind must be CONST for each element.
1322 */
1323 typedef C2GlobalParam<C2Tuning,
1324 C2SimpleArrayStruct<C2SystemResourceStruct>,
1325 kParamIndexResourcesCapacity> C2ResourcesCapacityTuning;
1326 constexpr char C2_PARAMKEY_RESOURCES_CAPACITY[] = "resources.capacity";
1327
1328 /**
1329 * Excluded system resources.
1330 *
1331 * [PROPOSED]
1332 *
1333 * This setting is implemented by the default component store.
1334 * Some system resources may be used by components and not tracked by the Codec 2.0 API.
1335 * This is communicated by this tuning.
1336 * Excluded resources are the total resources that are used by non-Codec 2.0 components.
1337 * It is specified as the excluded amount for each resource ID that is used by
1338 * a non-Codec 2.0 component. As such, the kind must be CONST for each element.
1339 *
1340 * The platform can calculate the available resources as total capacity minus
1341 * excluded resource minus sum of needed resources for each component.
1342 */
1343 typedef C2GlobalParam<C2Tuning,
1344 C2SimpleArrayStruct<C2SystemResourceStruct>,
1345 kParamIndexResourcesExcluded> C2ResourcesExcludedTuning;
1346 constexpr char C2_PARAMKEY_RESOURCES_EXCLUDED[] = "resources.excluded";
1347
1348 /**
1349 * System resources needed for the current configuration.
1350 *
1351 * [PROPOSED]
1352 *
1353 * Resources are tracked as a list of individual resource use specifications.
1354 * The resource kind can be CONST, PER_FRAME, PER_INPUT_BLODCK or PER_OUTPUT_BLOCK.
1355 */
1356 typedef C2GlobalParam<C2Tuning,
1357 C2SimpleArrayStruct<C2SystemResourceStruct>,
1358 kParamIndexResourcesNeeded> C2ResourcesNeededTuning;
1359 constexpr char C2_PARAMKEY_RESOURCES_NEEDED[] = "resources.needed";
1360
1361 /**
1362 * System resources reserved for this component
1363 *
1364 * [FUTURE]
1365 *
1366 * This allows the platform to set aside system resources for the component.
1367 * Since this is a static resource reservation, kind must be CONST for each element.
1368 * This resource reservation only considers CONST and PER_FRAME use.
1369 *
1370 * By default, no resources are reserved for a component.
1371 * If resource reservation is successful, the component shall be able to use those
1372 * resources exclusively. If however, the component is not using all of the
1373 * reserved resources, those may be shared with other components.
1374 */
1375 typedef C2GlobalParam<C2Tuning,
1376 C2SimpleArrayStruct<C2SystemResourceStruct>,
1377 kParamIndexResourcesReserved> C2ResourcesReservedTuning;
1378 constexpr char C2_PARAMKEY_RESOURCES_RESERVED[] = "resources.reserved";
1379
1380 /**
1381 * Operating rate.
1382 *
1383 * Operating rate is the expected rate of work through the component. Negative values is
1384 * invalid.
1385 *
1386 * TODO: this could distinguish set value
1387 */
1388 typedef C2GlobalParam<C2Tuning, C2FloatValue, kParamIndexOperatingRate> C2OperatingRateTuning;
1389 constexpr char C2_PARAMKEY_OPERATING_RATE[] = "algo.rate";
1390
1391 /**
1392 * Realtime / operating point.
1393 *
1394 * Priority value defines the operating point for the component. Operating points are defined by
1395 * the vendor. Priority value of 0 means that the client requires operation at the given operating
1396 * rate. Priority values -1 and below define operating points in decreasing performance. In this
1397 * case client expects best effort without exceeding the specific operating point. This allows
1398 * client to run components deeper in the background by using larger priority values. In these
1399 * cases operating rate is a hint for the maximum rate that the client anticipates.
1400 *
1401 * Operating rate and priority are used in tandem. E.g. if there are components that run at a
1402 * higher operating point (priority) it will make more resources available for components at
1403 * a lower operating point, so operating rate can be used to gate those components.
1404 *
1405 * Positive priority values are not defined at the moment and shall be treated equivalent to 0.
1406 */
1407 typedef C2GlobalParam<C2Tuning, C2Int32Value, kParamIndexRealTimePriority>
1408 C2RealTimePriorityTuning;
1409 constexpr char C2_PARAMKEY_PRIORITY[] = "algo.priority";
1410
1411 /* ------------------------------------- protected content ------------------------------------- */
1412
1413 /**
1414 * Secure mode.
1415 */
1416 C2ENUM(C2Config::secure_mode_t, uint32_t,
1417 SM_UNPROTECTED, ///< no content protection
1418 SM_READ_PROTECTED, ///< input and output buffers shall be protected from reading
1419 /// both read protected and readable encrypted buffers are used
1420 SM_READ_PROTECTED_WITH_ENCRYPTED,
1421 )
1422
1423 typedef C2GlobalParam<C2Tuning, C2SimpleValueStruct<C2Config::secure_mode_t>, kParamIndexSecureMode>
1424 C2SecureModeTuning;
1425 constexpr char C2_PARAMKEY_SECURE_MODE[] = "algo.secure-mode";
1426
1427 /* ===================================== ENCODER COMPONENTS ===================================== */
1428
1429 /**
1430 * Bitrate
1431 */
1432 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexBitrate> C2StreamBitrateInfo;
1433 constexpr char C2_PARAMKEY_BITRATE[] = "coded.bitrate";
1434
1435 /**
1436 * Bitrate mode.
1437 *
1438 * TODO: refine this with bitrate ranges and suggested window
1439 */
1440 C2ENUM(C2Config::bitrate_mode_t, uint32_t,
1441 BITRATE_CONST_SKIP_ALLOWED = 0, ///< constant bitrate, frame skipping allowed
1442 BITRATE_CONST = 1, ///< constant bitrate, keep all frames
1443 BITRATE_VARIABLE_SKIP_ALLOWED = 2, ///< bitrate can vary, frame skipping allowed
1444 BITRATE_VARIABLE = 3, ///< bitrate can vary, keep all frames
1445 BITRATE_IGNORE = 7, ///< bitrate can be exceeded at will to achieve
1446 ///< quality or other settings
1447
1448 // bitrate modes are composed of the following flags
1449 BITRATE_FLAG_KEEP_ALL_FRAMES = 1,
1450 BITRATE_FLAG_CAN_VARY = 2,
1451 BITRATE_FLAG_CAN_EXCEED = 4,
1452 )
1453
1454 typedef C2StreamParam<C2Tuning, C2SimpleValueStruct<C2Config::bitrate_mode_t>,
1455 kParamIndexBitrateMode>
1456 C2StreamBitrateModeTuning;
1457 constexpr char C2_PARAMKEY_BITRATE_MODE[] = "algo.bitrate-mode";
1458
1459 /**
1460 * Quality.
1461 *
1462 * This is defined by each component, the higher the better the output quality at the expense of
1463 * less compression efficiency. This setting is defined for the output streams in case the
1464 * component can support varying quality on each stream, or as an output port tuning in case the
1465 * quality is global to all streams.
1466 */
1467 typedef C2StreamParam<C2Tuning, C2Uint32Value, kParamIndexQuality> C2StreamQualityTuning;
1468 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexQuality> C2QualityTuning;
1469 constexpr char C2_PARAMKEY_QUALITY[] = "algo.quality";
1470
1471 /**
1472 * Complexity.
1473 *
1474 * This is defined by each component, this higher the value, the more resources the component
1475 * will use to produce better quality at the same compression efficiency or better compression
1476 * efficiency at the same quality. This setting is defined for the output streams in case the
1477 * component can support varying complexity on each stream, or as an output port tuning in case the
1478 * quality is global to all streams
1479 */
1480 typedef C2StreamParam<C2Tuning, C2Uint32Value, kParamIndexComplexity> C2StreamComplexityTuning;
1481 typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexComplexity> C2ComplexityTuning;
1482 constexpr char C2_PARAMKEY_COMPLEXITY[] = "algo.complexity";
1483
1484 /**
1485 * Header (init-data) handling around sync frames.
1486 */
1487 C2ENUM(C2Config::prepend_header_mode_t, uint32_t,
1488 /**
1489 * don't prepend header. Signal header only through C2StreamInitDataInfo.
1490 */
1491 PREPEND_HEADER_TO_NONE,
1492
1493 /**
1494 * prepend header before the first output frame and thereafter before the next sync frame
1495 * if it changes.
1496 */
1497 PREPEND_HEADER_ON_CHANGE,
1498
1499 /**
1500 * prepend header before every sync frame.
1501 */
1502 PREPEND_HEADER_TO_ALL_SYNC,
1503 )
1504
1505 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Config::prepend_header_mode_t>,
1506 kParamIndexPrependHeaderMode>
1507 C2PrependHeaderModeSetting;
1508 constexpr char C2_PARAMKEY_PREPEND_HEADER_MODE[] = "output.buffers.prepend-header";
1509
1510 /* =================================== IMAGE/VIDEO COMPONENTS =================================== */
1511
1512 /*
1513 * Order of transformation is:
1514 *
1515 * crop => (scaling => scaled-crop) => sample-aspect-ratio => flip => rotation
1516 */
1517
1518 /**
1519 * Picture (image- and video frame) size.
1520 *
1521 * This is used for the output of the video decoder, and the input of the video encoder.
1522 */
1523 typedef C2StreamParam<C2Info, C2PictureSizeStruct, kParamIndexPictureSize> C2StreamPictureSizeInfo;
1524 constexpr char C2_PARAMKEY_PICTURE_SIZE[] = "raw.size";
1525
1526 /**
1527 * Crop rectangle.
1528 */
1529 struct C2RectStruct : C2Rect {
1530 C2RectStruct() = default;
C2RectStructC2RectStruct1531 C2RectStruct(const C2Rect &rect) : C2Rect(rect) { }
1532
1533 bool operator==(const C2RectStruct &) = delete;
1534 bool operator!=(const C2RectStruct &) = delete;
1535
1536 DEFINE_AND_DESCRIBE_BASE_C2STRUCT(Rect)
1537 C2FIELD(width, "width")
1538 C2FIELD(height, "height")
1539 C2FIELD(left, "left")
1540 C2FIELD(top, "top")
1541 };
1542
1543 typedef C2StreamParam<C2Info, C2RectStruct, kParamIndexCropRect> C2StreamCropRectInfo;
1544 constexpr char C2_PARAMKEY_CROP_RECT[] = "raw.crop";
1545 constexpr char C2_PARAMKEY_CODED_CROP_RECT[] = "coded.crop";
1546
1547 /**
1548 * Pixel format.
1549 */
1550 // TODO: define some
1551
1552 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexPixelFormat> C2StreamPixelFormatInfo;
1553 constexpr char C2_PARAMKEY_PIXEL_FORMAT[] = "raw.pixel-format";
1554
1555 /**
1556 * Extended rotation information also incorporating a flip.
1557 *
1558 * Rotation is counter clock-wise.
1559 */
1560 struct C2RotationStruct {
1561 C2RotationStruct(int32_t rotation = 0)
1562 : flip(0), value(rotation) { }
1563
1564 int32_t flip; ///< horizontal flip (left-right flip applied prior to rotation)
1565 int32_t value; ///< rotation in degrees counter clockwise
1566
1567 DEFINE_AND_DESCRIBE_BASE_C2STRUCT(Rotation)
1568 C2FIELD(flip, "flip")
1569 C2FIELD(value, "value")
1570 };
1571
1572 typedef C2StreamParam<C2Info, C2RotationStruct, kParamIndexRotation> C2StreamRotationInfo;
1573 constexpr char C2_PARAMKEY_ROTATION[] = "raw.rotation";
1574 constexpr char C2_PARAMKEY_VUI_ROTATION[] = "coded.vui.rotation";
1575
1576 /**
1577 * Region of Interest of an image/video frame communicated as an array of C2QpOffsetRectStruct
1578 *
1579 * Fields width, height, left and top of C2QpOffsetRectStruct form a bounding box contouring RoI.
1580 * Field qpOffset of C2QpOffsetRectStruct indicates the qp bias to be used for quantizing the
1581 * coding units of the bounding box.
1582 *
1583 * If Roi rect is not valid that is bounding box width is < 0 or bounding box height is < 0,
1584 * components may ignore the configuration silently. If Roi rect extends outside frame
1585 * boundaries, then rect shall be clamped to the frame boundaries.
1586 *
1587 * The scope of this key is throughout the encoding session until it is reconfigured with a
1588 * different value.
1589 *
1590 * The number of elements in C2StreamQpOffset array is not limited by C2 specification.
1591 * However components may mandate a limit. Implementations may drop the rectangles that are beyond
1592 * the supported limits. Hence it is preferable to place the rects in descending order of
1593 * importance. Transitively, if the bounding boxes overlap, then the most preferred
1594 * rectangle's qp offset (earlier rectangle qp offset) will be used to quantize the block.
1595 */
1596 struct C2QpOffsetRectStruct : C2Rect {
1597 C2QpOffsetRectStruct() = default;
C2QpOffsetRectStructC2QpOffsetRectStruct1598 C2QpOffsetRectStruct(const C2Rect &rect, int32_t offset) : C2Rect(rect), qpOffset(offset) {}
1599
1600 bool operator==(const C2QpOffsetRectStruct &) = delete;
1601 bool operator!=(const C2QpOffsetRectStruct &) = delete;
1602
1603 int32_t qpOffset;
1604
1605 DEFINE_AND_DESCRIBE_C2STRUCT(QpOffsetRect)
1606 C2FIELD(width, "width")
1607 C2FIELD(height, "height")
1608 C2FIELD(left, "left")
1609 C2FIELD(top, "top")
1610 C2FIELD(qpOffset, "qp-offset")
1611 };
1612
1613 typedef C2StreamParam<C2Info, C2SimpleArrayStruct<C2QpOffsetRectStruct>, kParamIndexQpOffsetRects>
1614 C2StreamQpOffsetRects;
1615 constexpr char C2_PARAMKEY_QP_OFFSET_RECTS[] = "coding.qp-offset-rects";
1616
1617 /**
1618 * Pixel (sample) aspect ratio.
1619 */
1620 typedef C2StreamParam<C2Info, C2PictureSizeStruct, kParamIndexPixelAspectRatio>
1621 C2StreamPixelAspectRatioInfo;
1622 constexpr char C2_PARAMKEY_PIXEL_ASPECT_RATIO[] = "raw.sar";
1623 constexpr char C2_PARAMKEY_VUI_PIXEL_ASPECT_RATIO[] = "coded.vui.sar";
1624
1625 /**
1626 * In-line scaling.
1627 *
1628 * Components can optionally support scaling of raw image/video frames. Or scaling only a
1629 * portion of raw image/video frames (scaled-crop).
1630 */
1631
1632 C2ENUM(C2Config::scaling_method_t, uint32_t,
1633 SCALING_ARBITRARY, ///< arbitrary, unspecified
1634 )
1635
1636 typedef C2StreamParam<C2Tuning, C2SimpleValueStruct<C2Config::scaling_method_t>,
1637 kParamIndexScalingMethod>
1638 C2StreamScalingMethodTuning;
1639 constexpr char C2_PARAMKEY_SCALING_MODE[] = "raw.scaling-method";
1640
1641 typedef C2StreamParam<C2Tuning, C2PictureSizeStruct, kParamIndexScaledPictureSize>
1642 C2StreamScaledPictureSizeTuning;
1643 constexpr char C2_PARAMKEY_SCALED_PICTURE_SIZE[] = "raw.scaled-size";
1644
1645 typedef C2StreamParam<C2Tuning, C2RectStruct, kParamIndexScaledCropRect>
1646 C2StreamScaledCropRectTuning;
1647 constexpr char C2_PARAMKEY_SCALED_CROP_RECT[] = "raw.scaled-crop";
1648
1649 /* ------------------------------------- color information ------------------------------------- */
1650
1651 /**
1652 * Color Info
1653 *
1654 * Chroma location can vary for top and bottom fields, so use an array, that can have 0 to 2
1655 * values. Empty array is used for non YUV formats.
1656 */
1657
1658 struct C2Color {
1659 enum matrix_t : uint32_t; ///< matrix coefficient (YUV <=> RGB)
1660 enum plane_layout_t : uint32_t; ///< plane layout for flexible formats
1661 enum primaries_t : uint32_t; ///< color primaries and white point
1662 enum range_t : uint32_t; ///< range of color component values
1663 enum subsampling_t : uint32_t; ///< chroma subsampling
1664 enum transfer_t : uint32_t; ///< transfer function
1665 };
1666
1667 /// Chroma subsampling
1668 C2ENUM(C2Color::subsampling_t, uint32_t,
1669 MONOCHROME, ///< there are no Cr nor Cb planes
1670 MONOCHROME_ALPHA, ///< there are no Cr nor Cb planes, but there is an alpha plane
1671 RGB, ///< RGB
1672 RGBA, ///< RGBA
1673 YUV_420, ///< Cr and Cb planes are subsampled by 2 both horizontally and vertically
1674 YUV_422, ///< Cr and Cb planes are subsampled horizontally
1675 YUV_444, ///< Cr and Cb planes are not subsampled
1676 YUVA_444, ///< Cr and Cb planes are not subsampled, there is an alpha plane
1677 )
1678
1679 struct C2ChromaOffsetStruct {
1680 // chroma offsets defined by ITU
ITU_YUV_444C2ChromaOffsetStruct1681 constexpr static C2ChromaOffsetStruct ITU_YUV_444() { return { 0.0f, 0.0f }; }
ITU_YUV_422C2ChromaOffsetStruct1682 constexpr static C2ChromaOffsetStruct ITU_YUV_422() { return { 0.0f, 0.0f }; }
ITU_YUV_420_0C2ChromaOffsetStruct1683 constexpr static C2ChromaOffsetStruct ITU_YUV_420_0() { return { 0.0f, 0.5f }; }
ITU_YUV_420_1C2ChromaOffsetStruct1684 constexpr static C2ChromaOffsetStruct ITU_YUV_420_1() { return { 0.5f, 0.5f }; }
ITU_YUV_420_2C2ChromaOffsetStruct1685 constexpr static C2ChromaOffsetStruct ITU_YUV_420_2() { return { 0.0f, 0.0f }; }
ITU_YUV_420_3C2ChromaOffsetStruct1686 constexpr static C2ChromaOffsetStruct ITU_YUV_420_3() { return { 0.5f, 0.0f }; }
ITU_YUV_420_4C2ChromaOffsetStruct1687 constexpr static C2ChromaOffsetStruct ITU_YUV_420_4() { return { 0.0f, 1.0f }; }
ITU_YUV_420_5C2ChromaOffsetStruct1688 constexpr static C2ChromaOffsetStruct ITU_YUV_420_5() { return { 0.5f, 1.0f }; }
1689
1690 float x; ///< x offset in pixels (towards right)
1691 float y; ///< y offset in pixels (towards down)
1692
1693 DEFINE_AND_DESCRIBE_C2STRUCT(ChromaOffset)
1694 C2FIELD(x, "x")
1695 C2FIELD(y, "y")
1696 };
1697
1698 struct C2ColorInfoStruct {
C2ColorInfoStructC2ColorInfoStruct1699 C2ColorInfoStruct()
1700 : bitDepth(8), subsampling(C2Color::YUV_420) { }
1701
1702 uint32_t bitDepth;
1703 C2Color::subsampling_t subsampling;
1704 C2ChromaOffsetStruct locations[]; // max 2 elements
1705
C2ColorInfoStructC2ColorInfoStruct1706 C2ColorInfoStruct(
1707 size_t /* flexCount */, uint32_t bitDepth_, C2Color::subsampling_t subsampling_)
1708 : bitDepth(bitDepth_), subsampling(subsampling_) { }
1709
C2ColorInfoStructC2ColorInfoStruct1710 C2ColorInfoStruct(
1711 size_t flexCount, uint32_t bitDepth_, C2Color::subsampling_t subsampling_,
1712 std::initializer_list<C2ChromaOffsetStruct> locations_)
1713 : bitDepth(bitDepth_), subsampling(subsampling_) {
1714 size_t ix = 0;
1715 for (const C2ChromaOffsetStruct &location : locations_) {
1716 if (ix == flexCount) {
1717 break;
1718 }
1719 locations[ix] = location;
1720 ++ix;
1721 }
1722 }
1723
1724 DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(ColorInfo, locations)
1725 C2FIELD(bitDepth, "bit-depth")
1726 C2FIELD(subsampling, "subsampling")
1727 C2FIELD(locations, "locations")
1728 };
1729
1730 typedef C2StreamParam<C2Info, C2ColorInfoStruct, kParamIndexColorInfo> C2StreamColorInfo;
1731 constexpr char C2_PARAMKEY_COLOR_INFO[] = "raw.color-format";
1732 constexpr char C2_PARAMKEY_CODED_COLOR_INFO[] = "coded.color-format";
1733
1734 /**
1735 * Color Aspects
1736 */
1737
1738 /* The meaning of the following enumerators is as described in ITU-T H.273. */
1739
1740 /// Range
1741 C2ENUM(C2Color::range_t, uint32_t,
1742 RANGE_UNSPECIFIED, ///< range is unspecified
1743 RANGE_FULL, ///< full range
1744 RANGE_LIMITED, ///< limited range
1745
1746 RANGE_VENDOR_START = 0x80, ///< vendor-specific range values start here
1747 RANGE_OTHER = 0XFF ///< max value, reserved for undefined values
1748 )
1749
1750 /// Color primaries
1751 C2ENUM(C2Color::primaries_t, uint32_t,
1752 PRIMARIES_UNSPECIFIED, ///< primaries are unspecified
1753 PRIMARIES_BT709, ///< Rec.ITU-R BT.709-6 or equivalent
1754 PRIMARIES_BT470_M, ///< Rec.ITU-R BT.470-6 System M or equivalent
1755 PRIMARIES_BT601_625, ///< Rec.ITU-R BT.601-6 625 or equivalent
1756 PRIMARIES_BT601_525, ///< Rec.ITU-R BT.601-6 525 or equivalent
1757 PRIMARIES_GENERIC_FILM, ///< Generic Film
1758 PRIMARIES_BT2020, ///< Rec.ITU-R BT.2020 or equivalent
1759 PRIMARIES_RP431, ///< SMPTE RP 431-2 or equivalent
1760 PRIMARIES_EG432, ///< SMPTE EG 432-1 or equivalent
1761 PRIMARIES_EBU3213, ///< EBU Tech.3213-E or equivalent
1762 ///
1763 PRIMARIES_VENDOR_START = 0x80, ///< vendor-specific primaries values start here
1764 PRIMARIES_OTHER = 0xff ///< max value, reserved for undefined values
1765 )
1766
1767 /// Transfer function
1768 C2ENUM(C2Color::transfer_t, uint32_t,
1769 TRANSFER_UNSPECIFIED, ///< transfer is unspecified
1770 TRANSFER_LINEAR, ///< Linear transfer characteristics
1771 TRANSFER_SRGB, ///< sRGB or equivalent
1772 TRANSFER_170M, ///< SMPTE 170M or equivalent (e.g. BT.601/709/2020)
1773 TRANSFER_GAMMA22, ///< Assumed display gamma 2.2
1774 TRANSFER_GAMMA28, ///< Assumed display gamma 2.8
1775 TRANSFER_ST2084, ///< SMPTE ST 2084 for 10/12/14/16 bit systems
1776 TRANSFER_HLG, ///< ARIB STD-B67 hybrid-log-gamma
1777
1778 TRANSFER_240M = 0x40, ///< SMPTE 240M or equivalent
1779 TRANSFER_XVYCC, ///< IEC 61966-2-4 or equivalent
1780 TRANSFER_BT1361, ///< Rec.ITU-R BT.1361 extended gamut
1781 TRANSFER_ST428, ///< SMPTE ST 428-1 or equivalent
1782 ///
1783 TRANSFER_VENDOR_START = 0x80, ///< vendor-specific transfer values start here
1784 TRANSFER_OTHER = 0xff ///< max value, reserved for undefined values
1785 )
1786
1787 /// Matrix coefficient
1788 C2ENUM(C2Color::matrix_t, uint32_t,
1789 MATRIX_UNSPECIFIED, ///< matrix coefficients are unspecified
1790 MATRIX_BT709, ///< Rec.ITU-R BT.709-5 or equivalent
1791 MATRIX_FCC47_73_682, ///< FCC Title 47 CFR 73.682 or equivalent (KR=0.30, KB=0.11)
1792 MATRIX_BT601, ///< Rec.ITU-R BT.470, BT.601-6 625 or equivalent
1793 MATRIX_240M, ///< SMPTE 240M or equivalent
1794 MATRIX_BT2020, ///< Rec.ITU-R BT.2020 non-constant luminance
1795 MATRIX_BT2020_CONSTANT, ///< Rec.ITU-R BT.2020 constant luminance
1796 MATRIX_VENDOR_START = 0x80, ///< vendor-specific matrix coefficient values start here
1797 MATRIX_OTHER = 0xff, ///< max value, reserved for undefined values
1798 )
1799
1800 struct C2ColorAspectsStruct {
1801 C2Color::range_t range;
1802 C2Color::primaries_t primaries;
1803 C2Color::transfer_t transfer;
1804 C2Color::matrix_t matrix;
1805
C2ColorAspectsStructC2ColorAspectsStruct1806 C2ColorAspectsStruct()
1807 : range(C2Color::RANGE_UNSPECIFIED),
1808 primaries(C2Color::PRIMARIES_UNSPECIFIED),
1809 transfer(C2Color::TRANSFER_UNSPECIFIED),
1810 matrix(C2Color::MATRIX_UNSPECIFIED) { }
1811
C2ColorAspectsStructC2ColorAspectsStruct1812 C2ColorAspectsStruct(C2Color::range_t range_, C2Color::primaries_t primaries_,
1813 C2Color::transfer_t transfer_, C2Color::matrix_t matrix_)
1814 : range(range_), primaries(primaries_), transfer(transfer_), matrix(matrix_) {}
1815
1816 DEFINE_AND_DESCRIBE_C2STRUCT(ColorAspects)
1817 C2FIELD(range, "range")
1818 C2FIELD(primaries, "primaries")
1819 C2FIELD(transfer, "transfer")
1820 C2FIELD(matrix, "matrix")
1821 };
1822
1823 typedef C2StreamParam<C2Info, C2ColorAspectsStruct, kParamIndexColorAspects>
1824 C2StreamColorAspectsInfo;
1825 constexpr char C2_PARAMKEY_COLOR_ASPECTS[] = "raw.color";
1826 constexpr char C2_PARAMKEY_VUI_COLOR_ASPECTS[] = "coded.vui.color";
1827
1828 /**
1829 * Default color aspects to use. These come from the container or client and shall be handled
1830 * according to the coding standard.
1831 */
1832 typedef C2StreamParam<C2Tuning, C2ColorAspectsStruct, kParamIndexDefaultColorAspects>
1833 C2StreamColorAspectsTuning;
1834 constexpr char C2_PARAMKEY_DEFAULT_COLOR_ASPECTS[] = "default.color";
1835
1836 /**
1837 * HDR Static Metadata Info.
1838 */
1839 struct C2ColorXyStruct {
1840 float x; ///< x color coordinate in xyY space [0-1]
1841 float y; ///< y color coordinate in xyY space [0-1]
1842
1843 DEFINE_AND_DESCRIBE_C2STRUCT(ColorXy)
1844 C2FIELD(x, "x")
1845 C2FIELD(y, "y")
1846 };
1847
1848 struct C2MasteringDisplayColorVolumeStruct {
1849 C2ColorXyStruct red; ///< coordinates of red display primary
1850 C2ColorXyStruct green; ///< coordinates of green display primary
1851 C2ColorXyStruct blue; ///< coordinates of blue display primary
1852 C2ColorXyStruct white; ///< coordinates of white point
1853
1854 float maxLuminance; ///< max display mastering luminance in cd/m^2
1855 float minLuminance; ///< min display mastering luminance in cd/m^2
1856
1857 DEFINE_AND_DESCRIBE_C2STRUCT(MasteringDisplayColorVolume)
1858 C2FIELD(red, "red")
1859 C2FIELD(green, "green")
1860 C2FIELD(blue, "blue")
1861 C2FIELD(white, "white")
1862
1863 C2FIELD(maxLuminance, "max-luminance")
1864 C2FIELD(minLuminance, "min-luminance")
1865 };
1866
1867 struct C2HdrStaticMetadataStruct {
1868 C2MasteringDisplayColorVolumeStruct mastering;
1869
1870 // content descriptors
1871 float maxCll; ///< max content light level (pixel luminance) in cd/m^2
1872 float maxFall; ///< max frame average light level (frame luminance) in cd/m^2
1873
1874 DEFINE_AND_DESCRIBE_BASE_C2STRUCT(HdrStaticMetadata)
1875 C2FIELD(mastering, "mastering")
1876 C2FIELD(maxCll, "max-cll")
1877 C2FIELD(maxFall, "max-fall")
1878 };
1879 typedef C2StreamParam<C2Info, C2HdrStaticMetadataStruct, kParamIndexHdrStaticMetadata>
1880 C2StreamHdrStaticMetadataInfo;
1881 typedef C2StreamParam<C2Info, C2HdrStaticMetadataStruct, kParamIndexHdrStaticMetadata>
1882 C2StreamHdrStaticInfo; // deprecated
1883 constexpr char C2_PARAMKEY_HDR_STATIC_INFO[] = "raw.hdr-static-info";
1884
1885 /**
1886 * HDR10+ Metadata Info.
1887 *
1888 * Deprecated. Use C2StreamHdrDynamicMetadataInfo with
1889 * HDR_DYNAMIC_METADATA_TYPE_SMPTE_2094_40
1890 */
1891 typedef C2StreamParam<C2Info, C2BlobValue, kParamIndexHdr10PlusMetadata>
1892 C2StreamHdr10PlusInfo; // deprecated
1893 constexpr char C2_PARAMKEY_INPUT_HDR10_PLUS_INFO[] = "input.hdr10-plus-info"; // deprecated
1894 constexpr char C2_PARAMKEY_OUTPUT_HDR10_PLUS_INFO[] = "output.hdr10-plus-info"; // deprecated
1895
1896 /**
1897 * HDR dynamic metadata types
1898 */
1899 C2ENUM(C2Config::hdr_dynamic_metadata_type_t, uint32_t,
1900 HDR_DYNAMIC_METADATA_TYPE_SMPTE_2094_10, ///< SMPTE ST 2094-10
1901 HDR_DYNAMIC_METADATA_TYPE_SMPTE_2094_40, ///< SMPTE ST 2094-40
1902 )
1903
1904 struct C2HdrDynamicMetadataStruct {
C2HdrDynamicMetadataStructC2HdrDynamicMetadataStruct1905 inline C2HdrDynamicMetadataStruct() { memset(this, 0, sizeof(*this)); }
1906
C2HdrDynamicMetadataStructC2HdrDynamicMetadataStruct1907 inline C2HdrDynamicMetadataStruct(
1908 size_t flexCount, C2Config::hdr_dynamic_metadata_type_t type)
1909 : type_(type) {
1910 memset(data, 0, flexCount);
1911 }
1912
1913 C2Config::hdr_dynamic_metadata_type_t type_;
1914 uint8_t data[];
1915
1916 DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(HdrDynamicMetadata, data)
1917 C2FIELD(type_, "type")
1918 C2FIELD(data, "data")
1919 };
1920
1921 /**
1922 * Dynamic HDR Metadata Info.
1923 */
1924 typedef C2StreamParam<C2Info, C2HdrDynamicMetadataStruct, kParamIndexHdrDynamicMetadata>
1925 C2StreamHdrDynamicMetadataInfo;
1926 constexpr char C2_PARAMKEY_INPUT_HDR_DYNAMIC_INFO[] = "input.hdr-dynamic-info";
1927 constexpr char C2_PARAMKEY_OUTPUT_HDR_DYNAMIC_INFO[] = "output.hdr-dynamic-info";
1928
1929 /**
1930 * HDR Format
1931 */
1932 C2ENUM(C2Config::hdr_format_t, uint32_t,
1933 UNKNOWN, ///< HDR format not known (default)
1934 SDR, ///< not HDR (SDR)
1935 HLG, ///< HLG
1936 HDR10, ///< HDR10
1937 HDR10_PLUS, ///< HDR10+
1938 );
1939
1940 /**
1941 * HDR Format Info
1942 *
1943 * This information may be present during configuration to allow encoders to
1944 * prepare encoding certain HDR formats. When this information is not present
1945 * before start, encoders should determine the HDR format based on the available
1946 * HDR metadata on the first input frame.
1947 *
1948 * While this information is optional, it is not a hint. When present, encoders
1949 * that do not support dynamic reconfiguration do not need to switch to the HDR
1950 * format based on the metadata on the first input frame.
1951 */
1952 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2EasyEnum<C2Config::hdr_format_t>>,
1953 kParamIndexHdrFormat>
1954 C2StreamHdrFormatInfo;
1955 constexpr char C2_PARAMKEY_HDR_FORMAT[] = "coded.hdr-format";
1956
1957 /* ------------------------------------ block-based coding ----------------------------------- */
1958
1959 /**
1960 * Block-size, block count and block rate. Used to determine or communicate profile-level
1961 * requirements.
1962 */
1963 typedef C2StreamParam<C2Info, C2PictureSizeStruct, kParamIndexBlockSize> C2StreamBlockSizeInfo;
1964 constexpr char C2_PARAMKEY_BLOCK_SIZE[] = "coded.block-size";
1965
1966 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexBlockCount> C2StreamBlockCountInfo;
1967 constexpr char C2_PARAMKEY_BLOCK_COUNT[] = "coded.block-count";
1968
1969 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexBlockRate> C2StreamBlockRateInfo;
1970 constexpr char C2_PARAMKEY_BLOCK_RATE[] = "coded.block-rate";
1971
1972 /* ====================================== VIDEO COMPONENTS ====================================== */
1973
1974 /**
1975 * Frame rate (coded and port for raw data)
1976 *
1977 * Coded frame rates are what is represented in the compressed bitstream and should correspond to
1978 * the timestamp.
1979 *
1980 * Frame rates on raw ports should still correspond to the timestamps.
1981 *
1982 * For slow motion or timelapse recording, the timestamp shall be adjusted prior to feeding an
1983 * encoder, and the time stretch parameter should be used to signal the relationship between
1984 * timestamp and real-world time.
1985 */
1986 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexFrameRate> C2StreamFrameRateInfo;
1987 constexpr char C2_PARAMKEY_FRAME_RATE[] = "coded.frame-rate";
1988
1989 typedef C2PortParam<C2Info, C2FloatValue, kParamIndexFrameRate> C2PortFrameRateInfo;
1990 constexpr char C2_PARAMKEY_INPUT_FRAME_RATE[] = "input.frame-rate";
1991 constexpr char C2_PARAMKEY_OUTPUT_FRAME_RATE[] = "output.frame-rate";
1992
1993 /**
1994 * Time stretch. Ratio between real-world time and timestamp. E.g. time stretch of 4.0 means that
1995 * timestamp grows 1/4 the speed of real-world time (e.g. 4x slo-mo input). This can be used to
1996 * optimize encoding.
1997 */
1998 typedef C2PortParam<C2Info, C2FloatValue, kParamIndexTimeStretch> C2PortTimeStretchInfo;
1999 constexpr char C2_PARAMKEY_INPUT_TIME_STRETCH[] = "input.time-stretch";
2000 constexpr char C2_PARAMKEY_OUTPUT_TIME_STRETCH[] = "output.time-stretch";
2001
2002 /**
2003 * Max video frame size.
2004 */
2005 typedef C2StreamParam<C2Tuning, C2PictureSizeStruct, kParamIndexMaxPictureSize>
2006 C2StreamMaxPictureSizeTuning;
2007 typedef C2StreamMaxPictureSizeTuning C2MaxVideoSizeHintPortSetting;
2008 constexpr char C2_PARAMKEY_MAX_PICTURE_SIZE[] = "raw.max-size";
2009
2010 /**
2011 * Picture type mask.
2012 */
2013 C2ENUM(C2Config::picture_type_t, uint32_t,
2014 SYNC_FRAME = (1 << 0), ///< sync frame, e.g. IDR
2015 I_FRAME = (1 << 1), ///< intra frame that is completely encoded
2016 P_FRAME = (1 << 2), ///< inter predicted frame from previous frames
2017 B_FRAME = (1 << 3), ///< bidirectional predicted (out-of-order) frame
2018 )
2019
2020 /**
2021 * Allowed picture types.
2022 */
2023 typedef C2StreamParam<C2Tuning, C2SimpleValueStruct<C2EasyEnum<C2Config::picture_type_t>>,
2024 kParamIndexPictureTypeMask>
2025 C2StreamPictureTypeMaskTuning;
2026 constexpr char C2_PARAMKEY_PICTURE_TYPE_MASK[] = "coding.picture-type-mask";
2027
2028 /**
2029 * Resulting picture type
2030 */
2031 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2EasyEnum<C2Config::picture_type_t>>,
2032 kParamIndexPictureType>
2033 C2StreamPictureTypeInfo;
2034 typedef C2StreamPictureTypeInfo C2StreamPictureTypeMaskInfo;
2035 constexpr char C2_PARAMKEY_PICTURE_TYPE[] = "coded.picture-type";
2036
2037 /**
2038 * GOP specification.
2039 *
2040 * GOP is specified in layers between sync frames, by specifying the number of specific type of
2041 * frames between the previous type (starting with sync frames for the first layer):
2042 *
2043 * E.g.
2044 * - 4 I frames between each sync frame
2045 * - 2 P frames between each I frame
2046 * - 1 B frame between each P frame
2047 *
2048 * [ { I, 4 }, { P, 2 }, { B, 1 } ] ==> (Sync)BPBPB IBPBPB IBPBPB IBPBPB IBPBPB (Sync)BPBPB
2049 *
2050 * For infinite GOP, I layer can be omitted (as the first frame is always a sync frame.):
2051 *
2052 * [ { P, MAX_UINT } ] ==> (Sync)PPPPPPPPPPPPPPPPPP...
2053 *
2054 * Sync frames can also be requested on demand, and as a time-based interval. For time-based
2055 * interval, if there hasn't been a sync frame in at least the given time, the next I frame shall
2056 * be encoded as a sync frame. For sync request, the next I frame shall be encoded as a sync frame.
2057 *
2058 * Temporal layering will determine GOP structure other than the I frame count between sync
2059 * frames.
2060 */
2061 struct C2GopLayerStruct {
C2GopLayerStructC2GopLayerStruct2062 C2GopLayerStruct() : type_((C2Config::picture_type_t)0), count(0) {}
C2GopLayerStructC2GopLayerStruct2063 C2GopLayerStruct(C2Config::picture_type_t type, uint32_t count_)
2064 : type_(type), count(count_) { }
2065
2066 C2Config::picture_type_t type_;
2067 uint32_t count;
2068
2069 DEFINE_AND_DESCRIBE_C2STRUCT(GopLayer)
2070 C2FIELD(type_, "type")
2071 C2FIELD(count, "count")
2072 };
2073
2074 typedef C2StreamParam<C2Tuning, C2SimpleArrayStruct<C2GopLayerStruct>, kParamIndexGop>
2075 C2StreamGopTuning;
2076 constexpr char C2_PARAMKEY_GOP[] = "coding.gop";
2077
2078 /**
2079 * Quantization
2080 * min/max for each picture type
2081 *
2082 */
2083 struct C2PictureQuantizationStruct {
C2PictureQuantizationStructC2PictureQuantizationStruct2084 C2PictureQuantizationStruct() : type_((C2Config::picture_type_t)0),
2085 min(INT32_MIN), max(INT32_MAX) {}
C2PictureQuantizationStructC2PictureQuantizationStruct2086 C2PictureQuantizationStruct(C2Config::picture_type_t type, int32_t min_, int32_t max_)
2087 : type_(type), min(min_), max(max_) { }
2088
2089 C2Config::picture_type_t type_;
2090 int32_t min; // INT32_MIN == 'no lower bound specified'
2091 int32_t max; // INT32_MAX == 'no upper bound specified'
2092
2093 DEFINE_AND_DESCRIBE_C2STRUCT(PictureQuantization)
2094 C2FIELD(type_, "type")
2095 C2FIELD(min, "min")
2096 C2FIELD(max, "max")
2097 };
2098
2099 typedef C2StreamParam<C2Tuning, C2SimpleArrayStruct<C2PictureQuantizationStruct>,
2100 kParamIndexPictureQuantization> C2StreamPictureQuantizationTuning;
2101 constexpr char C2_PARAMKEY_PICTURE_QUANTIZATION[] = "coding.qp";
2102
2103 /**
2104 * Sync frame can be requested on demand by the client.
2105 *
2106 * If true, the next I frame shall be encoded as a sync frame. This config can be passed
2107 * synchronously with the work, or directly to the component - leading to different result.
2108 * If it is passed with work, it shall take effect when that work item is being processed (so
2109 * the first I frame at or after that work item shall be a sync frame).
2110 */
2111 typedef C2StreamParam<C2Tuning, C2EasyBoolValue, kParamIndexRequestSyncFrame>
2112 C2StreamRequestSyncFrameTuning;
2113 constexpr char C2_PARAMKEY_REQUEST_SYNC_FRAME[] = "coding.request-sync-frame";
2114
2115 /**
2116 * Sync frame interval in time domain (timestamp).
2117 *
2118 * If there hasn't been a sync frame in at least this value, the next intra frame shall be encoded
2119 * as a sync frame. The value of MAX_I64 or a negative value means no sync frames after the first
2120 * frame. A value of 0 means all sync frames.
2121 */
2122 typedef C2StreamParam<C2Tuning, C2Int64Value, kParamIndexSyncFrameInterval>
2123 C2StreamSyncFrameIntervalTuning;
2124 constexpr char C2_PARAMKEY_SYNC_FRAME_INTERVAL[] = "coding.sync-frame-interval";
2125
2126 /**
2127 * Temporal layering
2128 *
2129 * Layer index is a value between 0 and layer count - 1. Layers with higher index have higher
2130 * frequency:
2131 * 0
2132 * 1 1
2133 * 2 2 2 2
2134 */
2135 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexLayerIndex> C2StreamLayerIndexInfo;
2136 constexpr char C2_PARAMKEY_LAYER_INDEX[] = "coded.layer-index";
2137
2138 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexLayerCount> C2StreamLayerCountInfo;
2139 constexpr char C2_PARAMKEY_LAYER_COUNT[] = "coded.layer-count";
2140
2141 struct C2TemporalLayeringStruct {
C2TemporalLayeringStructC2TemporalLayeringStruct2142 C2TemporalLayeringStruct()
2143 : layerCount(0), bLayerCount(0) { }
2144
C2TemporalLayeringStructC2TemporalLayeringStruct2145 C2TemporalLayeringStruct(size_t /* flexCount */, uint32_t layerCount_, uint32_t bLayerCount_)
2146 : layerCount(layerCount_), bLayerCount(c2_min(layerCount_, bLayerCount_)) { }
2147
C2TemporalLayeringStructC2TemporalLayeringStruct2148 C2TemporalLayeringStruct(size_t flexCount, uint32_t layerCount_, uint32_t bLayerCount_,
2149 std::initializer_list<float> ratios)
2150 : layerCount(layerCount_), bLayerCount(c2_min(layerCount_, bLayerCount_)) {
2151 size_t ix = 0;
2152 for (float ratio : ratios) {
2153 if (ix == flexCount) {
2154 break;
2155 }
2156 bitrateRatios[ix++] = ratio;
2157 }
2158 }
2159
2160 uint32_t layerCount; ///< total number of layers (0 means no temporal layering)
2161 uint32_t bLayerCount; ///< total number of bidirectional layers (<= num layers)
2162 /**
2163 * Bitrate budgets for each layer and the layers below, given as a ratio of the total
2164 * stream bitrate. This can be omitted or partially specififed by the client while configuring,
2165 * in which case the component shall fill in appropriate values for the missing layers.
2166 * This must be provided by the component when queried for at least layer count - 1 (as the
2167 * last layer's budget is always 1.0).
2168 */
2169 float bitrateRatios[]; ///< 1.0-based
2170
2171 DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(TemporalLayering, bitrateRatios)
2172 C2FIELD(layerCount, "layer-count")
2173 C2FIELD(bLayerCount, "b-layer-count")
2174 C2FIELD(bitrateRatios, "bitrate-ratios")
2175 };
2176
2177 typedef C2StreamParam<C2Tuning, C2TemporalLayeringStruct, kParamIndexTemporalLayering>
2178 C2StreamTemporalLayeringTuning;
2179 constexpr char C2_PARAMKEY_TEMPORAL_LAYERING[] = "coding.temporal-layering";
2180
2181 /**
2182 * Intra-refresh.
2183 */
2184
2185 C2ENUM(C2Config::intra_refresh_mode_t, uint32_t,
2186 INTRA_REFRESH_DISABLED, ///< no intra refresh
2187 INTRA_REFRESH_ARBITRARY, ///< arbitrary, unspecified
2188 )
2189
2190 struct C2IntraRefreshStruct {
C2IntraRefreshStructC2IntraRefreshStruct2191 C2IntraRefreshStruct()
2192 : mode(C2Config::INTRA_REFRESH_DISABLED), period(0.) { }
2193
C2IntraRefreshStructC2IntraRefreshStruct2194 C2IntraRefreshStruct(C2Config::intra_refresh_mode_t mode_, float period_)
2195 : mode(mode_), period(period_) { }
2196
2197 C2Config::intra_refresh_mode_t mode; ///< refresh mode
2198 float period; ///< intra refresh period in frames (must be >= 1), 0 means disabled
2199
2200 DEFINE_AND_DESCRIBE_C2STRUCT(IntraRefresh)
2201 C2FIELD(mode, "mode")
2202 C2FIELD(period, "period")
2203 };
2204
2205 typedef C2StreamParam<C2Tuning, C2IntraRefreshStruct, kParamIndexIntraRefresh>
2206 C2StreamIntraRefreshTuning;
2207 constexpr char C2_PARAMKEY_INTRA_REFRESH[] = "coding.intra-refresh";
2208
2209 /* ====================================== IMAGE COMPONENTS ====================================== */
2210
2211 /**
2212 * Tile layout.
2213 *
2214 * This described how the image is decomposed into tiles.
2215 */
2216 C2ENUM(C2Config::scan_order_t, uint32_t,
2217 SCAN_LEFT_TO_RIGHT_THEN_DOWN
2218 )
2219
2220 struct C2TileLayoutStruct {
2221 C2PictureSizeStruct tile; ///< tile size
2222 uint32_t columnCount; ///< number of tiles horizontally
2223 uint32_t rowCount; ///< number of tiles vertically
2224 C2Config::scan_order_t order; ///< tile order
2225
2226 DEFINE_AND_DESCRIBE_C2STRUCT(TileLayout)
2227 C2FIELD(tile, "tile")
2228 C2FIELD(columnCount, "columns")
2229 C2FIELD(rowCount, "rows")
2230 C2FIELD(order, "order")
2231 };
2232
2233 typedef C2StreamParam<C2Info, C2TileLayoutStruct, kParamIndexTileLayout> C2StreamTileLayoutInfo;
2234 constexpr char C2_PARAMKEY_TILE_LAYOUT[] = "coded.tile-layout";
2235
2236 /**
2237 * Tile handling.
2238 *
2239 * Whether to concatenate tiles or output them each.
2240 */
2241 C2ENUM(C2Config::tiling_mode_t, uint32_t,
2242 TILING_SEPARATE, ///< output each tile in a separate onWorkDone
2243 TILING_CONCATENATE ///< output one work completion per frame (concatenate tiles)
2244 )
2245
2246 typedef C2StreamParam<C2Tuning, C2TileLayoutStruct, kParamIndexTileHandling>
2247 C2StreamTileHandlingTuning;
2248 constexpr char C2_PARAMKEY_TILE_HANDLING[] = "coding.tile-handling";
2249
2250 /* ====================================== AUDIO COMPONENTS ====================================== */
2251
2252 /**
2253 * Sample rate
2254 */
2255 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexSampleRate> C2StreamSampleRateInfo;
2256 constexpr char C2_PARAMKEY_SAMPLE_RATE[] = "raw.sample-rate";
2257 constexpr char C2_PARAMKEY_CODED_SAMPLE_RATE[] = "coded.sample-rate";
2258
2259 /**
2260 * Channel count.
2261 */
2262 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexChannelCount> C2StreamChannelCountInfo;
2263 constexpr char C2_PARAMKEY_CHANNEL_COUNT[] = "raw.channel-count";
2264 constexpr char C2_PARAMKEY_CODED_CHANNEL_COUNT[] = "coded.channel-count";
2265
2266 /**
2267 * Max channel count. Used to limit the number of coded or decoded channels.
2268 */
2269 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexMaxChannelCount> C2StreamMaxChannelCountInfo;
2270 constexpr char C2_PARAMKEY_MAX_CHANNEL_COUNT[] = "raw.max-channel-count";
2271 constexpr char C2_PARAMKEY_MAX_CODED_CHANNEL_COUNT[] = "coded.max-channel-count";
2272
2273 /**
2274 * Audio channel mask. Used by decoder to express audio channel mask of decoded content,
2275 * or by encoder for the channel mask of the encoded content once decoded.
2276 * Channel representation is specified according to the Java android.media.AudioFormat
2277 * CHANNEL_OUT_* constants.
2278 */
2279 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexAndroidChannelMask> C2StreamChannelMaskInfo;
2280 const char C2_PARAMKEY_CHANNEL_MASK[] = "raw.channel-mask";
2281
2282 /**
2283 * Audio sample format (PCM encoding)
2284 */
2285 C2ENUM(C2Config::pcm_encoding_t, uint32_t,
2286 PCM_16,
2287 PCM_8,
2288 PCM_FLOAT,
2289 PCM_24,
2290 PCM_32
2291 )
2292
2293 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2Config::pcm_encoding_t>, kParamIndexPcmEncoding>
2294 C2StreamPcmEncodingInfo;
2295 constexpr char C2_PARAMKEY_PCM_ENCODING[] = "raw.pcm-encoding";
2296 constexpr char C2_PARAMKEY_CODED_PCM_ENCODING[] = "coded.pcm-encoding";
2297
2298 /**
2299 * AAC SBR Mode. Used during encoding.
2300 */
2301 C2ENUM(C2Config::aac_sbr_mode_t, uint32_t,
2302 AAC_SBR_OFF,
2303 AAC_SBR_SINGLE_RATE,
2304 AAC_SBR_DUAL_RATE,
2305 AAC_SBR_AUTO ///< let the codec decide
2306 )
2307
2308 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2Config::aac_sbr_mode_t>, kParamIndexAacSbrMode>
2309 C2StreamAacSbrModeTuning;
2310 constexpr char C2_PARAMKEY_AAC_SBR_MODE[] = "coding.aac-sbr-mode";
2311
2312 /**
2313 * DRC Compression. Used during decoding.
2314 */
2315 C2ENUM(C2Config::drc_compression_mode_t, int32_t,
2316 DRC_COMPRESSION_ODM_DEFAULT, ///< odm's default
2317 DRC_COMPRESSION_NONE,
2318 DRC_COMPRESSION_LIGHT,
2319 DRC_COMPRESSION_HEAVY ///<
2320 )
2321
2322 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2Config::drc_compression_mode_t>,
2323 kParamIndexDrcCompression>
2324 C2StreamDrcCompressionModeTuning;
2325 constexpr char C2_PARAMKEY_DRC_COMPRESSION_MODE[] = "coding.drc.compression-mode";
2326
2327 /**
2328 * DRC target reference level in dBFS. Used during decoding.
2329 */
2330 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexDrcTargetReferenceLevel>
2331 C2StreamDrcTargetReferenceLevelTuning;
2332 constexpr char C2_PARAMKEY_DRC_TARGET_REFERENCE_LEVEL[] = "coding.drc.reference-level";
2333
2334 /**
2335 * DRC target reference level in dBFS. Used during decoding.
2336 */
2337 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexDrcEncodedTargetLevel>
2338 C2StreamDrcEncodedTargetLevelTuning;
2339 constexpr char C2_PARAMKEY_DRC_ENCODED_TARGET_LEVEL[] = "coding.drc.encoded-level";
2340
2341 /**
2342 * DRC target reference level in dBFS. Used during decoding.
2343 */
2344 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexDrcBoostFactor>
2345 C2StreamDrcBoostFactorTuning;
2346 constexpr char C2_PARAMKEY_DRC_BOOST_FACTOR[] = "coding.drc.boost-factor";
2347
2348 /**
2349 * DRC target reference level in dBFS. Used during decoding.
2350 */
2351 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexDrcAttenuationFactor>
2352 C2StreamDrcAttenuationFactorTuning;
2353 constexpr char C2_PARAMKEY_DRC_ATTENUATION_FACTOR[] = "coding.drc.attenuation-factor";
2354
2355 /**
2356 * DRC Effect Type (see ISO 23003-4) Uniform Dynamic Range Control. Used during decoding.
2357 */
2358 C2ENUM(C2Config::drc_effect_type_t, int32_t,
2359 DRC_EFFECT_ODM_DEFAULT = -2, ///< odm's default
2360 DRC_EFFECT_OFF = -1, ///< no DRC
2361 DRC_EFFECT_NONE = 0, ///< no DRC except to prevent clipping
2362 DRC_EFFECT_LATE_NIGHT,
2363 DRC_EFFECT_NOISY_ENVIRONMENT,
2364 DRC_EFFECT_LIMITED_PLAYBACK_RANGE,
2365 DRC_EFFECT_LOW_PLAYBACK_LEVEL,
2366 DRC_EFFECT_DIALOG_ENHANCEMENT,
2367 DRC_EFFECT_GENERAL_COMPRESSION
2368 )
2369
2370 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2Config::drc_effect_type_t>,
2371 kParamIndexDrcEffectType>
2372 C2StreamDrcEffectTypeTuning;
2373 constexpr char C2_PARAMKEY_DRC_EFFECT_TYPE[] = "coding.drc.effect-type";
2374
2375 /**
2376 * DRC album mode. Used during decoding.
2377 */
2378 C2ENUM(C2Config::drc_album_mode_t, int32_t,
2379 DRC_ALBUM_MODE_OFF = 0,
2380 DRC_ALBUM_MODE_ON = 1
2381 )
2382 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2Config::drc_album_mode_t>, kParamIndexDrcAlbumMode>
2383 C2StreamDrcAlbumModeTuning;
2384 constexpr char C2_PARAMKEY_DRC_ALBUM_MODE[] = "coding.drc.album-mode";
2385
2386 /**
2387 * DRC output loudness in dBFS. Retrieved during decoding
2388 */
2389 typedef C2StreamParam<C2Info, C2FloatValue, kParamIndexDrcOutputLoudness>
2390 C2StreamDrcOutputLoudnessTuning;
2391 constexpr char C2_PARAMKEY_DRC_OUTPUT_LOUDNESS[] = "output.drc.output-loudness";
2392
2393 /**
2394 * Audio frame size in samples.
2395 *
2396 * Audio encoders can expose this parameter to signal the desired audio frame
2397 * size that corresponds to a single coded access unit.
2398 * Default value is 0, meaning that the encoder accepts input buffers of any size.
2399 */
2400 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexAudioFrameSize>
2401 C2StreamAudioFrameSizeInfo;
2402 constexpr char C2_PARAMKEY_AUDIO_FRAME_SIZE[] = "raw.audio-frame-size";
2403
2404 /**
2405 * Information for an access unit in a large frame (containing multiple access units)
2406 */
2407 struct C2AccessUnitInfosStruct {
2408
C2AccessUnitInfosStructC2AccessUnitInfosStruct2409 inline C2AccessUnitInfosStruct() {
2410 memset(this, 0, sizeof(*this));
2411 }
2412
C2AccessUnitInfosStructC2AccessUnitInfosStruct2413 inline C2AccessUnitInfosStruct(
2414 uint32_t flags_,
2415 uint32_t size_,
2416 int64_t timestamp_)
2417 : flags(flags_),
2418 size(size_),
2419 timestamp(timestamp_) { }
2420
2421 uint32_t flags; ///<flags for the access-unit
2422 uint32_t size; ///<size of access-unit
2423 int64_t timestamp; ///<timestamp in us for the access-unit
2424
2425 DEFINE_AND_DESCRIBE_C2STRUCT(AccessUnitInfos)
2426 C2FIELD(flags, "flags")
2427 C2FIELD(size, "size")
2428 C2FIELD(timestamp, "timestamp")
2429 };
2430
2431 /**
2432 * Multiple access unit support (e.g large audio frames)
2433 *
2434 * If supported by a component, multiple access units may be contained
2435 * in a single work item. For now this is only defined for linear buffers.
2436 * The metadata indicates the access-unit boundaries in a single buffer.
2437 * The boundary of each access-units are marked by its size, immediately
2438 * followed by the next access-unit.
2439 */
2440 typedef C2StreamParam<C2Info, C2SimpleArrayStruct<C2AccessUnitInfosStruct>,
2441 kParamIndexAccessUnitInfos>
2442 C2AccessUnitInfos;
2443
2444 constexpr char C2_PARAMKEY_INPUT_ACCESS_UNIT_INFOS[] = "input.access-unit-infos";
2445 constexpr char C2_PARAMKEY_OUTPUT_ACCESS_UNIT_INFOS[] = "output.access-unit-infos";
2446
2447 /* --------------------------------------- AAC components --------------------------------------- */
2448
2449 /**
2450 * AAC stream format
2451 */
2452 C2ENUM(C2Config::aac_packaging_t, uint32_t,
2453 AAC_PACKAGING_RAW,
2454 AAC_PACKAGING_ADTS
2455 )
2456
2457 typedef C2StreamParam<C2Info, C2SimpleValueStruct<C2EasyEnum<C2Config::aac_packaging_t>>,
2458 kParamIndexAacPackaging> C2StreamAacPackagingInfo;
2459 typedef C2StreamAacPackagingInfo C2StreamAacFormatInfo;
2460 constexpr char C2_PARAMKEY_AAC_PACKAGING[] = "coded.aac-packaging";
2461
2462 /* ================================ PLATFORM-DEFINED PARAMETERS ================================ */
2463
2464 /**
2465 * Platform level and features.
2466 */
2467 enum C2Config::platform_level_t : uint32_t {
2468 PLATFORM_P, ///< support for Android 9.0 feature set
2469 };
2470
2471 // read-only
2472 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Config::platform_level_t>,
2473 kParamIndexPlatformLevel>
2474 C2PlatformLevelSetting;
2475 constexpr char C2_PARAMKEY_PLATFORM_LEVEL[] = "api.platform-level";
2476
2477 enum C2Config::platform_feature_t : uint64_t {
2478 // no platform-specific features have been defined
2479 };
2480
2481 // read-only
2482 typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Config::platform_feature_t>,
2483 kParamIndexPlatformFeatures>
2484 C2PlatformFeaturesSetting;
2485 constexpr char C2_PARAMKEY_PLATFORM_FEATURES[] = "api.platform-features";
2486
2487 /**
2488 * This structure describes the preferred ion allocation parameters for a given memory usage.
2489 */
2490 struct C2StoreIonUsageStruct {
C2StoreIonUsageStructC2StoreIonUsageStruct2491 inline C2StoreIonUsageStruct() {
2492 memset(this, 0, sizeof(*this));
2493 }
2494
C2StoreIonUsageStructC2StoreIonUsageStruct2495 inline C2StoreIonUsageStruct(uint64_t usage_, uint32_t capacity_)
2496 : usage(usage_), capacity(capacity_), heapMask(0), allocFlags(0), minAlignment(0) { }
2497
2498 uint64_t usage; ///< C2MemoryUsage
2499 uint32_t capacity; ///< capacity
2500 int32_t heapMask; ///< ion heapMask
2501 int32_t allocFlags; ///< ion allocation flags
2502 uint32_t minAlignment; ///< minimum alignment
2503
2504 DEFINE_AND_DESCRIBE_C2STRUCT(StoreIonUsage)
2505 C2FIELD(usage, "usage")
2506 C2FIELD(capacity, "capacity")
2507 C2FIELD(heapMask, "heap-mask")
2508 C2FIELD(allocFlags, "alloc-flags")
2509 C2FIELD(minAlignment, "min-alignment")
2510 };
2511
2512 // store, private
2513 typedef C2GlobalParam<C2Info, C2StoreIonUsageStruct, kParamIndexStoreIonUsage>
2514 C2StoreIonUsageInfo;
2515
2516 /**
2517 * This structure describes the preferred DMA-Buf allocation parameters for a given memory usage.
2518 */
2519 struct C2StoreDmaBufUsageStruct {
C2StoreDmaBufUsageStructC2StoreDmaBufUsageStruct2520 inline C2StoreDmaBufUsageStruct() { memset(this, 0, sizeof(*this)); }
2521
C2StoreDmaBufUsageStructC2StoreDmaBufUsageStruct2522 inline C2StoreDmaBufUsageStruct(size_t flexCount, uint64_t usage_, uint32_t capacity_)
2523 : usage(usage_), capacity(capacity_), allocFlags(0) {
2524 memset(heapName, 0, flexCount);
2525 }
2526
2527 uint64_t usage; ///< C2MemoryUsage
2528 uint32_t capacity; ///< capacity
2529 int32_t allocFlags; ///< ion allocation flags
2530 char heapName[]; ///< dmabuf heap name
2531
2532 DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(StoreDmaBufUsage, heapName)
2533 C2FIELD(usage, "usage")
2534 C2FIELD(capacity, "capacity")
2535 C2FIELD(allocFlags, "alloc-flags")
2536 C2FIELD(heapName, "heap-name")
2537 };
2538
2539 // store, private
2540 typedef C2GlobalParam<C2Info, C2StoreDmaBufUsageStruct, kParamIndexStoreDmaBufUsage>
2541 C2StoreDmaBufUsageInfo;
2542
2543 /**
2544 * Flexible pixel format descriptors
2545 */
2546 struct C2FlexiblePixelFormatDescriptorStruct {
2547 uint32_t pixelFormat;
2548 uint32_t bitDepth;
2549 C2Color::subsampling_t subsampling;
2550 C2Color::plane_layout_t layout;
2551
2552 DEFINE_AND_DESCRIBE_C2STRUCT(FlexiblePixelFormatDescriptor)
2553 C2FIELD(pixelFormat, "pixel-format")
2554 C2FIELD(bitDepth, "bit-depth")
2555 C2FIELD(subsampling, "subsampling")
2556 C2FIELD(layout, "layout")
2557 };
2558
2559 /**
2560 * Plane layout of flexible pixel formats.
2561 *
2562 * bpp: bytes per color component, e.g. 1 for 8-bit formats, and 2 for 10-16-bit formats.
2563 */
2564 C2ENUM(C2Color::plane_layout_t, uint32_t,
2565 /** Unknown layout */
2566 UNKNOWN_LAYOUT,
2567
2568 /** Planar layout with rows of each plane packed (colInc = bpp) */
2569 PLANAR_PACKED,
2570
2571 /** Semiplanar layout with rows of each plane packed (colInc_Y/A = bpp (planar),
2572 * colInc_Cb/Cr = 2*bpp (interleaved). Used only for YUV(A) formats. */
2573 SEMIPLANAR_PACKED,
2574
2575 /** Interleaved packed. colInc = N*bpp (N are the number of color components) */
2576 INTERLEAVED_PACKED,
2577
2578 /** Interleaved aligned. colInc = smallest power of 2 >= N*bpp (N are the number of color
2579 * components) */
2580 INTERLEAVED_ALIGNED
2581 )
2582
2583 typedef C2GlobalParam<C2Info, C2SimpleArrayStruct<C2FlexiblePixelFormatDescriptorStruct>,
2584 kParamIndexFlexiblePixelFormatDescriptors>
2585 C2StoreFlexiblePixelFormatDescriptorsInfo;
2586
2587 /**
2588 * This structure describes the android dataspace for a raw video/image frame.
2589 */
2590 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexDataSpace> C2StreamDataSpaceInfo;
2591 constexpr char C2_PARAMKEY_DATA_SPACE[] = "raw.data-space";
2592
2593 /**
2594 * This structure describes the android surface scaling mode for a raw video/image frame.
2595 */
2596 typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexSurfaceScaling> C2StreamSurfaceScalingInfo;
2597 constexpr char C2_PARAMKEY_SURFACE_SCALING_MODE[] = "raw.surface-scaling";
2598
2599 /* ======================================= INPUT SURFACE ======================================= */
2600
2601 /**
2602 * Input surface EOS
2603 */
2604 typedef C2GlobalParam<C2Tuning, C2EasyBoolValue, kParamIndexInputSurfaceEos>
2605 C2InputSurfaceEosTuning;
2606 constexpr char C2_PARAMKEY_INPUT_SURFACE_EOS[] = "input-surface.eos";
2607
2608 /**
2609 * Start/suspend/resume/stop controls and timestamps for input surface.
2610 *
2611 * TODO: make these counters
2612 */
2613
2614 struct C2TimedControlStruct {
2615 c2_bool_t enabled; ///< control is enabled
2616 int64_t timestamp; ///< if enabled, time the control should take effect
2617
C2TimedControlStructC2TimedControlStruct2618 C2TimedControlStruct()
2619 : enabled(C2_FALSE), timestamp(0) { }
2620
C2TimedControlStructC2TimedControlStruct2621 /* implicit */ C2TimedControlStruct(uint64_t timestamp_)
2622 : enabled(C2_TRUE), timestamp(timestamp_) { }
2623
2624 DEFINE_AND_DESCRIBE_C2STRUCT(TimedControl)
2625 C2FIELD(enabled, "enabled")
2626 C2FIELD(timestamp, "timestamp")
2627 };
2628
2629 typedef C2PortParam<C2Tuning, C2TimedControlStruct, kParamIndexStartAt>
2630 C2PortStartTimestampTuning;
2631 constexpr char C2_PARAMKEY_INPUT_SURFACE_START_AT[] = "input-surface.start";
2632 typedef C2PortParam<C2Tuning, C2TimedControlStruct, kParamIndexSuspendAt>
2633 C2PortSuspendTimestampTuning;
2634 constexpr char C2_PARAMKEY_INPUT_SURFACE_SUSPEND_AT[] = "input-surface.suspend";
2635 typedef C2PortParam<C2Tuning, C2TimedControlStruct, kParamIndexResumeAt>
2636 C2PortResumeTimestampTuning;
2637 constexpr char C2_PARAMKEY_INPUT_SURFACE_RESUME_AT[] = "input-surface.resume";
2638 typedef C2PortParam<C2Tuning, C2TimedControlStruct, kParamIndexStopAt>
2639 C2PortStopTimestampTuning;
2640 constexpr char C2_PARAMKEY_INPUT_SURFACE_STOP_AT[] = "input-surface.stop";
2641
2642 /**
2643 * Time offset for input surface. Input timestamp to codec is surface buffer timestamp plus this
2644 * time offset.
2645 */
2646 typedef C2GlobalParam<C2Tuning, C2Int64Value, kParamIndexTimeOffset> C2ComponentTimeOffsetTuning;
2647 constexpr char C2_PARAMKEY_INPUT_SURFACE_TIME_OFFSET[] = "input-surface.time-offset";
2648
2649 /**
2650 * Minimum fps for input surface.
2651 *
2652 * Repeat frame to meet this.
2653 */
2654 typedef C2PortParam<C2Tuning, C2FloatValue, kParamIndexMinFrameRate> C2PortMinFrameRateTuning;
2655 constexpr char C2_PARAMKEY_INPUT_SURFACE_MIN_FRAME_RATE[] = "input-surface.min-frame-rate";
2656
2657 /**
2658 * Maximum fps for input surface.
2659 *
2660 * Drop frame to meet this.
2661 */
2662 typedef C2PortParam<C2Tuning, C2FloatValue, kParamIndexMaxFrameRate> C2PortMaxFrameRateTuning;
2663 constexpr char C2_PARAMKEY_INPUT_SURFACE_MAX_FRAME_RATE[] = "input-surface.max-frame-rate";
2664
2665 /**
2666 * Timestamp adjustment (override) for input surface buffers. These control the input timestamp
2667 * fed to the codec, but do not impact the output timestamp.
2668 */
2669 struct C2TimestampGapAdjustmentStruct {
2670 /// control modes
2671 enum mode_t : uint32_t;
2672
2673 inline C2TimestampGapAdjustmentStruct();
2674
C2TimestampGapAdjustmentStructC2TimestampGapAdjustmentStruct2675 inline C2TimestampGapAdjustmentStruct(mode_t mode_, uint64_t value_)
2676 : mode(mode_), value(value_) { }
2677
2678 mode_t mode; ///< control mode
2679 uint64_t value; ///< control value for gap between two timestamp
2680
2681 DEFINE_AND_DESCRIBE_C2STRUCT(TimestampGapAdjustment)
2682 C2FIELD(mode, "mode")
2683 C2FIELD(value, "value")
2684 };
2685
2686 C2ENUM(C2TimestampGapAdjustmentStruct::mode_t, uint32_t,
2687 NONE,
2688 MIN_GAP,
2689 FIXED_GAP,
2690 );
2691
C2TimestampGapAdjustmentStruct()2692 inline C2TimestampGapAdjustmentStruct::C2TimestampGapAdjustmentStruct()
2693 : mode(C2TimestampGapAdjustmentStruct::NONE), value(0) { }
2694
2695 typedef C2PortParam<C2Tuning, C2TimestampGapAdjustmentStruct, kParamIndexTimestampGapAdjustment>
2696 C2PortTimestampGapTuning;
2697 constexpr char C2_PARAMKEY_INPUT_SURFACE_TIMESTAMP_ADJUSTMENT[] = "input-surface.timestamp-adjustment";
2698
2699 /**
2700 * Capture frame rate for input surface. During timelapse or slowmo encoding,
2701 * this represents the frame rate of input surface.
2702 */
2703 typedef C2PortParam<C2Tuning, C2FloatValue, kParamIndexCaptureFrameRate>
2704 C2PortCaptureFrameRateTuning;
2705 constexpr char C2_PARAMKEY_INPUT_SURFACE_CAPTURE_FRAME_RATE[] = "input-surface.capture-frame-rate";
2706
2707 /**
2708 * Stop time offset for input surface. Stop time offset is the elapsed time
2709 * offset to the last frame time from the stop time. This could be returned from
2710 * IInputSurface when it is queried.
2711 */
2712 typedef C2PortParam<C2Tuning, C2Int64Value, kParamIndexStopTimeOffset> C2PortStopTimeOffset;
2713 constexpr char C2_PARAMKEY_INPUT_SURFACE_STOP_TIME_OFFSET[] = "input-surface.stop-time-offset";
2714
2715 /* ===================================== TUNNELED CODEC ==================================== */
2716
2717 /**
2718 * Tunneled codec control.
2719 */
2720 struct C2TunneledModeStruct {
2721 /// mode
2722 enum mode_t : uint32_t;
2723 /// sync type
2724 enum sync_type_t : uint32_t;
2725
2726 inline C2TunneledModeStruct() = default;
2727
C2TunneledModeStructC2TunneledModeStruct2728 inline C2TunneledModeStruct(
2729 size_t flexCount, mode_t mode_, sync_type_t type, std::vector<int32_t> id)
2730 : mode(mode_), syncType(type) {
2731 memcpy(&syncId, &id[0], c2_min(id.size(), flexCount) * FLEX_SIZE);
2732 }
2733
C2TunneledModeStructC2TunneledModeStruct2734 inline C2TunneledModeStruct(size_t flexCount, mode_t mode_, sync_type_t type, int32_t id)
2735 : mode(mode_), syncType(type) {
2736 if (flexCount >= 1) {
2737 syncId[0] = id;
2738 }
2739 }
2740
2741 mode_t mode; ///< tunneled mode
2742 sync_type_t syncType; ///< type of sync used for tunneled mode
2743 int32_t syncId[]; ///< sync id
2744
2745 DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(TunneledMode, syncId)
2746 C2FIELD(mode, "mode")
2747 C2FIELD(syncType, "sync-type")
2748 C2FIELD(syncId, "sync-id")
2749
2750 };
2751
2752 C2ENUM(C2TunneledModeStruct::mode_t, uint32_t,
2753 NONE,
2754 SIDEBAND,
2755 );
2756
2757
2758 C2ENUM(C2TunneledModeStruct::sync_type_t, uint32_t,
2759 REALTIME,
2760 AUDIO_HW_SYNC,
2761 HW_AV_SYNC,
2762 );
2763
2764 /**
2765 * Configure tunneled mode
2766 */
2767 typedef C2PortParam<C2Tuning, C2TunneledModeStruct, kParamIndexTunneledMode>
2768 C2PortTunneledModeTuning;
2769 constexpr char C2_PARAMKEY_TUNNELED_RENDER[] = "output.tunneled-render";
2770
2771 /**
2772 * Tunneled mode handle. The meaning of this is depends on the
2773 * tunneled mode. If the tunneled mode is SIDEBAND, this is the
2774 * sideband handle.
2775 */
2776 typedef C2PortParam<C2Tuning, C2Int32Array, kParamIndexTunnelHandle> C2PortTunnelHandleTuning;
2777 constexpr char C2_PARAMKEY_OUTPUT_TUNNEL_HANDLE[] = "output.tunnel-handle";
2778
2779 /**
2780 * The system time using CLOCK_MONOTONIC in nanoseconds at the tunnel endpoint.
2781 * For decoders this is the render time for the output frame and
2782 * this corresponds to the media timestamp of the output frame.
2783 */
2784 typedef C2PortParam<C2Info, C2SimpleValueStruct<int64_t>, kParamIndexTunnelSystemTime>
2785 C2PortTunnelSystemTime;
2786 constexpr char C2_PARAMKEY_OUTPUT_RENDER_TIME[] = "output.render-time";
2787
2788
2789 /**
2790 * Tunneled mode video peek signaling flag.
2791 *
2792 * When a video frame is pushed to the decoder with this parameter set to true,
2793 * the decoder must decode the frame, signal partial completion, and hold on the
2794 * frame until C2StreamTunnelStartRender is set to true (which resets this
2795 * flag). Flush will also result in the frames being returned back to the
2796 * client (but not rendered).
2797 */
2798 typedef C2StreamParam<C2Info, C2EasyBoolValue, kParamIndexTunnelHoldRender>
2799 C2StreamTunnelHoldRender;
2800 constexpr char C2_PARAMKEY_TUNNEL_HOLD_RENDER[] = "output.tunnel-hold-render";
2801
2802 /**
2803 * Tunneled mode video peek signaling flag.
2804 *
2805 * Upon receiving this flag, the decoder shall set C2StreamTunnelHoldRender to
2806 * false, which shall cause any frames held for rendering to be immediately
2807 * displayed, regardless of their timestamps.
2808 */
2809 typedef C2StreamParam<C2Info, C2EasyBoolValue, kParamIndexTunnelStartRender>
2810 C2StreamTunnelStartRender;
2811 constexpr char C2_PARAMKEY_TUNNEL_START_RENDER[] = "output.tunnel-start-render";
2812
2813 /** Tunnel Peek Mode. */
2814 C2ENUM(C2PlatformConfig::tunnel_peek_mode_t, uint32_t,
2815 UNSPECIFIED_PEEK = 0,
2816 SPECIFIED_PEEK = 1
2817 );
2818
2819 /**
2820 * Tunnel Peek Mode Tuning parameter.
2821 *
2822 * If set to UNSPECIFIED_PEEK_MODE, the decoder is free to ignore the
2823 * C2StreamTunnelHoldRender and C2StreamTunnelStartRender flags and associated
2824 * features. Additionally, it becomes up to the decoder to display any frame
2825 * before receiving synchronization information.
2826 *
2827 * Note: This parameter allows a decoder to ignore the video peek machinery and
2828 * to revert to its preferred behavior.
2829 */
2830 typedef C2StreamParam<C2Tuning,
2831 C2SimpleValueStruct<C2EasyEnum<C2PlatformConfig::tunnel_peek_mode_t>>,
2832 kParamIndexTunnelPeekMode> C2StreamTunnelPeekModeTuning;
2833 constexpr char C2_PARAMKEY_TUNNEL_PEEK_MODE[] =
2834 "output.tunnel-peek-mode";
2835
2836 /**
2837 * Encoding quality level signaling.
2838 *
2839 * Signal the 'minimum encoding quality' introduced in Android 12/S. It indicates
2840 * whether the underlying codec is expected to take extra steps to ensure quality meets the
2841 * appropriate minimum. A value of NONE indicates that the codec is not to apply
2842 * any minimum quality bar requirements. Other values indicate that the codec is to apply
2843 * a minimum quality bar, with the exact quality bar being decided by the parameter value.
2844 */
2845 typedef C2GlobalParam<C2Setting,
2846 C2SimpleValueStruct<C2EasyEnum<C2PlatformConfig::encoding_quality_level_t>>,
2847 kParamIndexEncodingQualityLevel> C2EncodingQualityLevel;
2848 constexpr char C2_PARAMKEY_ENCODING_QUALITY_LEVEL[] = "algo.encoding-quality-level";
2849
2850 C2ENUM(C2PlatformConfig::encoding_quality_level_t, uint32_t,
2851 NONE = 0,
2852 S_HANDHELD = 1 // corresponds to VMAF=70
2853 );
2854
2855 /**
2856 * Video Encoding Statistics Export
2857 */
2858
2859 /**
2860 * Average block QP exported from video encoder.
2861 */
2862 typedef C2StreamParam<C2Info, C2SimpleValueStruct<int32_t>, kParamIndexAverageBlockQuantization>
2863 C2AndroidStreamAverageBlockQuantizationInfo;
2864 constexpr char C2_PARAMKEY_AVERAGE_QP[] = "coded.average-qp";
2865
2866 /// @}
2867
2868 #endif // C2CONFIG_H_
2869