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