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