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