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