1 /* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CODEC_OMX_EXT_H 17 #define CODEC_OMX_EXT_H 18 #include <OMX_IVCommon.h> 19 #include <OMX_Video.h> 20 #include <stdbool.h> 21 #ifdef __cplusplus 22 #if __cplusplus 23 extern "C" { 24 #endif 25 #endif /* __cplusplus */ 26 27 #define PROCESS_NAME_LEN 50 28 29 /** 30 * @brief Enumerates the extended AVC profile. 31 */ 32 enum CodecAVCProfileExt { 33 OMX_VIDEO_AVC_LEVEL52 = 0x10000, /**< Level 5.2 */ 34 OMX_VIDEO_AVC_LEVEL6 = 0x20000, /**< Level 6 */ 35 OMX_VIDEO_AVC_LEVEL61 = 0x40000, /**< Level 6.1 */ 36 OMX_VIDEO_AVC_LEVEL62 = 0x80000, /**< Level 6.2 */ 37 }; 38 39 /** 40 * @brief Enumerates the extended codec codingtyps. 41 */ 42 enum CodecVideoExType { 43 CODEC_OMX_VIDEO_CodingVP9 = 10, /** VP9 Index in Codec HDI */ 44 CODEC_OMX_VIDEO_CodingHEVC = 11, /** HEVC Index in Codec HDI */ 45 CODEC_OMX_VIDEO_CodingVVC = 0x7F000007, /** VVC Index in Codec HDI */ 46 }; 47 48 /** 49 * @brief Enumerates the extended HEVC profile. 50 */ 51 enum CodecHevcProfile { 52 CODEC_HEVC_PROFILE_INVALID = 0x0, 53 CODEC_HEVC_PROFILE_MAIN = 0x1, 54 CODEC_HEVC_PROFILE_MAIN10 = 0x2, 55 CODEC_HEVC_PROFILE_MAIN_STILL = 0x3, 56 // main_10 profile with HDR SEI support. 57 CODEC_HEVC_PROFILE_MAIN10_HDR10 = 0x1000, 58 CODEC_HEVC_PROFILE_MAIN10_HDR10_PLUS = 0x2000, 59 CODEC_HEVC_PROFILE_MAX = 0x7FFFFFFF 60 }; 61 62 /** 63 * @brief Enumerates the extended HEVC level. 64 */ 65 enum CodecHevcLevel { 66 CODEC_HEVC_LEVEL_INVALID = 0x0, 67 CODEC_HEVC_MAIN_TIER_LEVEL1 = 0x1, 68 CODEC_HEVC_HIGH_TIER_LEVEL1 = 0x2, 69 CODEC_HEVC_MAIN_TIER_LEVEL2 = 0x4, 70 CODEC_HEVC_HIGH_TIER_LEVEL2 = 0x8, 71 CODEC_HEVC_MAIN_TIER_LEVEL21 = 0x10, 72 CODEC_HEVC_HIGH_TIER_LEVEL21 = 0x20, 73 CODEC_HEVC_MAIN_TIER_LEVEL3 = 0x40, 74 CODEC_HEVC_HIGH_TIER_LEVEL3 = 0x80, 75 CODEC_HEVC_MAIN_TIER_LEVEL31 = 0x100, 76 CODEC_HEVC_HIGH_TIER_LEVEL31 = 0x200, 77 CODEC_HEVC_MAIN_TIER_LEVEL4 = 0x400, 78 CODEC_HEVC_HIGH_TIER_LEVEL4 = 0x800, 79 CODEC_HEVC_MAIN_TIER_LEVEL41 = 0x1000, 80 CODEC_HEVC_HIGH_TIER_LEVEL41 = 0x2000, 81 CODEC_HEVC_MAIN_TIER_LEVEL5 = 0x4000, 82 CODEC_HEVC_HIGH_TIER_LEVEL5 = 0x8000, 83 CODEC_HEVC_MAIN_TIER_LEVEL51 = 0x10000, 84 CODEC_HEVC_HIGH_TIER_LEVEL51 = 0x20000, 85 CODEC_HEVC_MAIN_TIER_LEVEL52 = 0x40000, 86 CODEC_HEVC_HIGH_TIER_LEVEL52 = 0x80000, 87 CODEC_HEVC_MAIN_TIER_LEVEL6 = 0x100000, 88 CODEC_HEVC_HIGH_TIER_LEVEL6 = 0x200000, 89 CODEC_HEVC_MAIN_TIER_LEVEL61 = 0x400000, 90 CODEC_HEVC_HIGH_TIER_LEVEL61 = 0x800000, 91 CODEC_HEVC_MAIN_TIER_LEVEL62 = 0x1000000, 92 CODEC_HEVC_HIGH_TIER_LEVEL62 = 0x2000000, 93 CODEC_HEVC_HIGH_TIER_MAX = 0x7FFFFFFF 94 }; 95 96 /** 97 * @brief Enumerates the extended VVC profile. 98 */ 99 enum CodecVvcProfile { 100 CODEC_VVC_PROFILE_INVALID = 0x0, 101 CODEC_VVC_PROFILE_MAIN10 = 0x1, 102 CODEC_VVC_PROFILE_MAIN10_STILL = 0x2, 103 CODEC_VVC_PROFILE_MAIN10_444 = 0x3, 104 CODEC_VVC_PROFILE_MAIN10_444_STILL = 0x4, 105 CODEC_VVC_PROFILE_MULTI_MAIN10 = 0x5, 106 CODEC_VVC_PROFILE_MULTI_MAIN10_444 = 0x6, 107 // Operation range extensions profiles 108 CODEC_VVC_PROFILE_MAIN12 = 0x7, 109 CODEC_VVC_PROFILE_MAIN12_INTRA = 0x8, 110 CODEC_VVC_PROFILE_MAIN12_STILL = 0x9, 111 CODEC_VVC_PROFILE_MAIN12_444 = 0xA, 112 CODEC_VVC_PROFILE_MAIN12_444_INTRA = 0xB, 113 CODEC_VVC_PROFILE_MAIN12_444_STILL = 0xC, 114 CODEC_VVC_PROFILE_MAIN16_444 = 0xD, 115 CODEC_VVC_PROFILE_MAIN16_444_INTRA = 0xE, 116 CODEC_VVC_PROFILE_MAIN16_444_STILL = 0xF, 117 CODEC_VVC_PROFILE_MAX = 0x7FFFFFFF 118 }; 119 120 /** 121 * @brief Enumerates the extended VVC level. 122 */ 123 enum CodecVvcLevel { 124 CODEC_VVC_LEVEL_INVALID = 0x0, 125 CODEC_VVC_MAIN_TIER_LEVEL1 = 0x1, 126 CODEC_VVC_HIGH_TIER_LEVEL1 = 0x2, 127 CODEC_VVC_MAIN_TIER_LEVEL2 = 0x4, 128 CODEC_VVC_HIGH_TIER_LEVEL2 = 0x8, 129 CODEC_VVC_MAIN_TIER_LEVEL21 = 0x10, 130 CODEC_VVC_HIGH_TIER_LEVEL21 = 0x20, 131 CODEC_VVC_MAIN_TIER_LEVEL3 = 0x40, 132 CODEC_VVC_HIGH_TIER_LEVEL3 = 0x80, 133 CODEC_VVC_MAIN_TIER_LEVEL31 = 0x100, 134 CODEC_VVC_HIGH_TIER_LEVEL31 = 0x200, 135 CODEC_VVC_MAIN_TIER_LEVEL4 = 0x400, 136 CODEC_VVC_HIGH_TIER_LEVEL4 = 0x800, 137 CODEC_VVC_MAIN_TIER_LEVEL41 = 0x1000, 138 CODEC_VVC_HIGH_TIER_LEVEL41 = 0x2000, 139 CODEC_VVC_MAIN_TIER_LEVEL5 = 0x4000, 140 CODEC_VVC_HIGH_TIER_LEVEL5 = 0x8000, 141 CODEC_VVC_MAIN_TIER_LEVEL51 = 0x10000, 142 CODEC_VVC_HIGH_TIER_LEVEL51 = 0x20000, 143 CODEC_VVC_MAIN_TIER_LEVEL52 = 0x40000, 144 CODEC_VVC_HIGH_TIER_LEVEL52 = 0x80000, 145 CODEC_VVC_MAIN_TIER_LEVEL6 = 0x100000, 146 CODEC_VVC_HIGH_TIER_LEVEL6 = 0x200000, 147 CODEC_VVC_MAIN_TIER_LEVEL61 = 0x400000, 148 CODEC_VVC_HIGH_TIER_LEVEL61 = 0x800000, 149 CODEC_VVC_MAIN_TIER_LEVEL62 = 0x1000000, 150 CODEC_VVC_HIGH_TIER_LEVEL62 = 0x2000000, 151 CODEC_VVC_MAIN_TIER_LEVEL63 = 0x4000000, 152 CODEC_VVC_HIGH_TIER_LEVEL63 = 0x8000000, 153 CODEC_VVC_MAIN_TIER_LEVEL155 = 0x10000000, 154 CODEC_VVC_HIGH_TIER_LEVEL155 = 0x20000000, 155 CODEC_VVC_HIGH_TIER_MAX = 0x7FFFFFFF 156 }; 157 158 /** 159 * @brief Enumerates the extended codec color format. 160 */ 161 enum CodecColorFormatExt { 162 CODEC_COLOR_FORMAT_RGBA8888 = OMX_COLOR_FormatVendorStartUnused + 100, 163 }; 164 165 /** 166 * @brief Enumerates the buffer types. 167 */ 168 enum CodecBufferType { 169 /** Invalid buffer type. */ 170 CODEC_BUFFER_TYPE_INVALID = 0, 171 /** Virtual address type. */ 172 CODEC_BUFFER_TYPE_VIRTUAL_ADDR = 0x1, 173 /** Shared memory. */ 174 CODEC_BUFFER_TYPE_AVSHARE_MEM_FD = 0x2, 175 /** Handle. */ 176 CODEC_BUFFER_TYPE_HANDLE = 0x4, 177 /** Dynamic handle. */ 178 CODEC_BUFFER_TYPE_DYNAMIC_HANDLE = 0x8, 179 /** DMA memory. */ 180 CODEC_BUFFER_TYPE_DMA_MEM_FD = 0x10, 181 }; 182 183 /** 184 * @brief Defines the <b>SupportBuffer</b>. 185 */ 186 struct SupportBufferType { 187 uint32_t size; /** Size of the structure */ 188 union OMX_VERSIONTYPE version; /** Component version */ 189 uint32_t portIndex; /** Port index */ 190 uint32_t bufferTypes; /** Supported buffer types */ 191 }; 192 193 /** 194 * @brief Define the <b>UseBuffer</b>. 195 */ 196 struct UseBufferType { 197 uint32_t size; /** Size of the structure */ 198 union OMX_VERSIONTYPE version; /** Component version */ 199 uint32_t portIndex; /** Port index */ 200 uint32_t bufferType; /** Buffer type */ 201 }; 202 203 /** 204 * @brief Defines the <b>BufferHandleUsage</b>. 205 */ 206 struct GetBufferHandleUsageParams { 207 uint32_t size; /** Size of the structure */ 208 union OMX_VERSIONTYPE version; /** Component version */ 209 uint32_t portIndex; /** Port index */ 210 uint64_t usage; /** Usage */ 211 }; 212 213 /** 214 * @brief Defines the <b>CodecVideoPortFormatParam</b>. 215 */ 216 struct CodecVideoPortFormatParam { 217 uint32_t size; /** Size of the structure */ 218 union OMX_VERSIONTYPE version; /** Component version */ 219 uint32_t portIndex; /** Port index */ 220 uint32_t codecColorIndex; /** Color format index */ 221 uint32_t codecColorFormat; /** Color format defined in Display */ 222 uint32_t codecCompressFormat; /** See */ 223 uint32_t framerate; /** Q16 format */ 224 }; 225 226 /** 227 * @brief Defines the <b>ControlRateConstantQuality</b>. 228 */ 229 struct ControlRateConstantQuality { 230 uint32_t size; /** Size of the structure */ 231 union OMX_VERSIONTYPE version; /** Component version */ 232 uint32_t portIndex; /** Port index */ 233 uint32_t qualityValue; /** Control rate constant quality */ 234 }; 235 236 /** 237 * @brief Defines the <b>StableControlRate</b>. 238 */ 239 struct StableControlRate { 240 uint32_t size; /** Size of the structure */ 241 union OMX_VERSIONTYPE version; /** Component version */ 242 uint32_t portIndex; /** Port index */ 243 uint32_t sqrFactor; /** sqr Factor */ 244 uint32_t sMaxBitrate; /** Control max bitrate */ 245 uint32_t sTargetBitrate; /** Control bitrate */ 246 }; 247 248 /** 249 * @brief Defines the <b>PassthroughParam</b>. 250 */ 251 struct PassthroughParam { 252 int32_t key; /**< Parameter type index */ 253 void *val; /**< Pointer to the parameter value */ 254 int size; /**< Parameter value size */ 255 }; 256 257 /** 258 * @brief Defines the <b>WorkingFrequencyParam</b>. 259 */ 260 struct WorkingFrequencyParam { 261 uint32_t size; /** Size of the structure */ 262 union OMX_VERSIONTYPE version; /** Component version */ 263 uint32_t level; /** Working Frequency level */ 264 }; 265 266 /** 267 * @brief Defines the <b>ProcessNameParam</b>. 268 */ 269 struct ProcessNameParam { 270 uint32_t size; /** Size of the structure */ 271 union OMX_VERSIONTYPE version; /** Component version */ 272 char processName[PROCESS_NAME_LEN]; /** Process name array */ 273 }; 274 275 /** 276 * @brief Defines the <b>AudioCodecParam</b>. 277 */ 278 struct AudioCodecParam { 279 uint32_t size; /** Size of the structure */ 280 union OMX_VERSIONTYPE version; /** Component version */ 281 uint32_t sampleRate; /** Sample Rate */ 282 uint32_t sampleFormat; /** Sample Format */ 283 uint32_t channels; /** Channels */ 284 uint32_t bitRate; /** Bit Rate */ 285 uint32_t reserved; /** reserved word */ 286 }; 287 288 /** 289 * @brief Enumerates the extended codec indexes. 290 */ 291 enum OmxIndexCodecExType { 292 /** Extended BufferType index */ 293 OMX_IndexExtBufferTypeStartUnused = OMX_IndexKhronosExtensions + 0x00a00000, 294 /** SupportBuffer */ 295 OMX_IndexParamSupportBufferType, 296 /** UseBuffer */ 297 OMX_IndexParamUseBufferType, 298 /** GetBufferHandleUsage */ 299 OMX_IndexParamGetBufferHandleUsage, 300 /** CodecVideoPortFormatParam */ 301 OMX_IndexCodecVideoPortFormat, 302 /** ControlRateConstantQuality */ 303 OMX_IndexParamControlRateConstantQuality, 304 /** PassthroughParam */ 305 OMX_IndexParamPassthrough, 306 /** OMX_IndexParamVideoHevc */ 307 OMX_IndexParamVideoHevc, 308 /** range/primary/transfer/matrix */ 309 OMX_IndexColorAspects, 310 /** WorkingFrequencyParam */ 311 OMX_IndexParamWorkingFrequency, 312 /** ProcessNameParam */ 313 OMX_IndexParamProcessName, 314 /** AudioCodecParam */ 315 OMX_IndexParamAudioCodec, 316 /** CodecParamOverlayBuffer */ 317 OMX_IndexParamOverlayBuffer, 318 /** CodecLTRParam/CodecLTRPerFrameParam */ 319 OMX_IndexParamLTR, 320 /** CodecQPRangeParam */ 321 OMX_IndexParamQPRange, 322 /** OMX_CONFIG_BOOLEANTYPE */ 323 OMX_IndexParamLowLatency, 324 /** WirelessLowDelay */ 325 OMX_IndexParamWirelessLowDelay, 326 /** OMX_S32 */ 327 OMX_IndexParamEncOutQp, 328 /** double */ 329 OMX_IndexParamEncOutMse, 330 /** CodecEncOutLTRParam */ 331 OMX_IndexParamEncOutLTR, 332 /** OMX_CONFIG_BOOLEANTYPE */ 333 OMX_IndexParamEncParamsFeedback, 334 /** OMX_S32 */ 335 OMX_IndexParamEncOutFrameLayer, 336 /** OMX_S32 */ 337 OMX_IndexParamQPStsart, 338 /** OMX_BOOL */ 339 OMX_IndexParamSkipFrame, 340 /** CodecTemperalLayerParam */ 341 OMX_IndexParamTemperalLayer, 342 /** OMX_S32 */ 343 OMX_IndexParamEncOutRealBitrate, 344 /** CodecEncOutMadParam */ 345 OMX_IndexParamEncOutMad, 346 /** OMX_S32 */ 347 OMX_IndexParamEncOutIRatio, 348 /** OMX_S32 */ 349 OMX_IndexParamEncOutFrameQp, 350 /** OMX_CONFIG_BOOLEANTYPE */ 351 OMX_IndexParamSupportPackInput, 352 /** OMX_CONFIG_BOOLEANTYPE */ 353 OMX_IndexParamIsMvUpload, 354 /** OMX_CONFIG_BOOLEANTYPE */ 355 OMX_IndexParamEnablePackInput, 356 /** OMX_CONFIG_BOOLEANTYPE */ 357 OMX_IndexParamSwitchGround, 358 /** ControlRateSQR */ 359 OMX_IndexParamControlRateSQR, 360 }; 361 362 /** 363 * @brief Enumerates the Other Control Rate Type. 364 */ 365 typedef enum OmxVideoControlRateVendorExtType { 366 /** constant bit rate mode with Rlambda */ 367 OMX_Video_ControlRateConstantWithRlambda = OMX_Video_ControlRateVendorStartUnused + 0x1, 368 /** constant bit rate mode with CQ */ 369 OMX_Video_ControlRateConstantWithCQ, 370 /** stable bit rate mode with SQR */ 371 OMX_Video_ControlRateConstantWithSQR, 372 } OmxVideoControlRateVendorExtType; 373 374 /** 375 * @brief Enumerates the Other extended codec indexes. 376 */ 377 enum OmxIndexCodecOtherExtType { 378 /** Extended Config AutoFramerate Conversion */ 379 OMX_IndexCodecExtConfigAutoFramerateConversion = OMX_IndexOtherStartUnused + 0x1, 380 /** Extended Config Priority */ 381 OMX_IndexCodecExtConfigPriority, 382 /** Extended Config OperatingRate index */ 383 OMX_IndexCodecExtConfigOperatingRate, 384 }; 385 386 enum OmxIndexCodecVendorExtType { 387 /** Extended Channel Attributes index */ 388 OMX_IndexCodecExtChannelAttributes = OMX_IndexVendorStartUnused + 0x1, 389 /** CodecEnableNativeBufferParams */ 390 OMX_IndexCodecExtEnableNativeBuffer, 391 }; 392 393 /** 394 * @brief Structure for controlling HEVC video encoding 395 */ 396 struct CodecVideoParamHevc { 397 uint32_t size; /** Size of the structure */ 398 union OMX_VERSIONTYPE version; /** Component version */ 399 uint32_t portIndex; /** Port index */ 400 enum CodecHevcProfile profile; /** Hevc profile. For details, see {@link CodecHevcProfile}. */ 401 enum CodecHevcLevel level; /** Hevc level. For details, see {@link CodecHevcLevel}. */ 402 uint32_t keyFrameInterval; /** Distance between consecutive I-frames (including one of the I frams). 403 0 means interval is unspecified and can be freely chosen by the codec. 404 1 means a stream of only I frams. other means the real value. */ 405 }; 406 407 /** 408 * @brief Defines the <b>CodecEnableNativeBufferParams</b>. 409 */ 410 struct CodecEnableNativeBufferParams { 411 uint32_t size; /** Size of the structure */ 412 union OMX_VERSIONTYPE version; /** Component version */ 413 uint32_t portIndex; /** Port index */ 414 bool enable; /** Enable NativeBuffer */ 415 }; 416 417 struct ColorAspects { 418 bool range; 419 uint8_t primaries; 420 uint8_t transfer; 421 uint8_t matrixCoeffs; 422 }; 423 424 /** 425 * @brief Structure for controlling color space 426 */ 427 struct CodecVideoColorspace { 428 uint32_t size; /** Size of the structure */ 429 union OMX_VERSIONTYPE version; /** Component version */ 430 uint32_t portIndex; /** Port index */ 431 uint32_t requestingDataSpace; 432 uint32_t dataSpaceChanged; 433 uint32_t pixeFormat; 434 uint32_t dataSpace; 435 struct ColorAspects aspects; 436 }; 437 438 /** 439 * @brief Structure for pAppPrivate data of OMX_BUFFERHEADERTYPE 440 */ 441 struct OMXBufferAppPrivateData { 442 int32_t fd; /** dma fd or secure dma fd allocated by vender */ 443 uint32_t sizeOfParam; 444 void *param; 445 }; 446 447 struct CodecLTRParam { 448 uint32_t size; /** Size of the structure */ 449 union OMX_VERSIONTYPE version; /** Component version */ 450 uint32_t ltrFrameListLen; 451 }; 452 453 struct CodecLTRPerFrameParam { 454 bool markAsLTR; 455 bool useLTR; 456 uint32_t useLTRPoc; 457 }; 458 459 struct CodecEncOutLTRParam { 460 bool isLTR; 461 uint32_t poc; 462 }; 463 464 struct CodecQPRangeParam { 465 uint32_t size; /** Size of the structure */ 466 union OMX_VERSIONTYPE version; /** Component version */ 467 uint32_t minQp; 468 uint32_t maxQp; 469 }; 470 471 struct CodecTemperalLayerParam { 472 uint32_t size; /** Size of the structure */ 473 union OMX_VERSIONTYPE version; /** Component version */ 474 uint32_t layerCnt; 475 }; 476 477 struct CodecParamOverlayBuffer { 478 uint32_t size; /** Size of the structure */ 479 union OMX_VERSIONTYPE version; /** Component version */ 480 bool enable; 481 uint32_t dstX; 482 uint32_t dstY; 483 uint32_t dstW; 484 uint32_t dstH; 485 void* bufferHandle; 486 }; 487 488 struct CodecEncOutMadParam { 489 int32_t frameMadi; 490 int32_t frameMadp; 491 int32_t sumMadi; 492 }; 493 494 #ifdef __cplusplus 495 #if __cplusplus 496 } 497 #endif 498 #endif /* __cplusplus */ 499 500 #endif // CODEC_OMX_EXT_H