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 = 12, /** 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>PassthroughParam</b>. 238 */ 239 struct PassthroughParam { 240 int32_t key; /**< Parameter type index */ 241 void *val; /**< Pointer to the parameter value */ 242 int size; /**< Parameter value size */ 243 }; 244 245 /** 246 * @brief Defines the <b>WorkingFrequencyParam</b>. 247 */ 248 struct WorkingFrequencyParam { 249 uint32_t size; /** Size of the structure */ 250 union OMX_VERSIONTYPE version; /** Component version */ 251 uint32_t level; /** Working Frequency level */ 252 }; 253 254 /** 255 * @brief Defines the <b>ProcessNameParam</b>. 256 */ 257 struct ProcessNameParam { 258 uint32_t size; /** Size of the structure */ 259 union OMX_VERSIONTYPE version; /** Component version */ 260 char processName[PROCESS_NAME_LEN]; /** Process name array */ 261 }; 262 263 /** 264 * @brief Defines the <b>AudioCodecParam</b>. 265 */ 266 struct AudioCodecParam { 267 uint32_t size; /** Size of the structure */ 268 union OMX_VERSIONTYPE version; /** Component version */ 269 uint32_t sampleRate; /** Sample Rate */ 270 uint32_t sampleFormat; /** Sample Format */ 271 uint32_t channels; /** Channels */ 272 uint32_t bitRate; /** Bit Rate */ 273 uint32_t reserved; /** reserved word */ 274 }; 275 276 /** 277 * @brief Enumerates the extended codec indexes. 278 */ 279 enum OmxIndexCodecExType { 280 /** Extended BufferType index */ 281 OMX_IndexExtBufferTypeStartUnused = OMX_IndexKhronosExtensions + 0x00a00000, 282 /** SupportBuffer */ 283 OMX_IndexParamSupportBufferType, 284 /** UseBuffer */ 285 OMX_IndexParamUseBufferType, 286 /** GetBufferHandleUsage */ 287 OMX_IndexParamGetBufferHandleUsage, 288 /** CodecVideoPortFormatParam */ 289 OMX_IndexCodecVideoPortFormat, 290 /** ControlRateConstantQuality */ 291 OMX_IndexParamControlRateConstantQuality, 292 /** PassthroughParam */ 293 OMX_IndexParamPassthrough, 294 /** OMX_IndexParamVideoHevc */ 295 OMX_IndexParamVideoHevc, 296 /** range/primary/transfer/matrix */ 297 OMX_IndexColorAspects, 298 /** WorkingFrequencyParam */ 299 OMX_IndexParamWorkingFrequency, 300 /** ProcessNameParam */ 301 OMX_IndexParamProcessName, 302 /** AudioCodecParam */ 303 OMX_IndexParamAudioCodec, 304 /** CodecParamOverlayBuffer */ 305 OMX_IndexParamOverlayBuffer, 306 /** CodecLTRParam/CodecLTRPerFrameParam */ 307 OMX_IndexParamLTR, 308 /** CodecQPRangeParam */ 309 OMX_IndexParamQPRange, 310 /** OMX_CONFIG_BOOLEANTYPE */ 311 OMX_IndexParamLowLatency, 312 /** WirelessLowDelay */ 313 OMX_IndexParamWirelessLowDelay, 314 /** OMX_S32 */ 315 OMX_IndexParamEncOutQp, 316 /** double */ 317 OMX_IndexParamEncOutMse, 318 /** CodecEncOutLTRParam */ 319 OMX_IndexParamEncOutLTR, 320 /** OMX_CONFIG_BOOLEANTYPE */ 321 OMX_IndexParamEncParamsFeedback, 322 /** OMX_S32 */ 323 OMX_IndexParamEncOutFrameLayer, 324 /** OMX_S32 */ 325 OMX_IndexParamQPStsart, 326 /** OMX_BOOL */ 327 OMX_IndexParamSkipFrame, 328 /** CodecTemperalLayerParam */ 329 OMX_IndexParamTemperalLayer, 330 /** OMX_S32 */ 331 OMX_IndexParamEncOutRealBitrate, 332 /** CodecEncOutMadParam */ 333 OMX_IndexParamEncOutMad, 334 /** OMX_S32 */ 335 OMX_IndexParamEncOutIRatio, 336 /** OMX_S32 */ 337 OMX_IndexParamEncOutFrameQp, 338 /** OMX_CONFIG_BOOLEANTYPE */ 339 OMX_IndexParamSupportPackInput, 340 /** OMX_CONFIG_BOOLEANTYPE */ 341 OMX_IndexParamIsMvUpload, 342 }; 343 344 /** 345 * @brief Enumerates the Other Control Rate Type. 346 */ 347 typedef enum OmxVideoControlRateVendorExtType { 348 /** constant bit rate mode with Rlambda */ 349 OMX_Video_ControlRateConstantWithRlambda = OMX_Video_ControlRateVendorStartUnused + 0x1, 350 } OmxVideoControlRateVendorExtType; 351 352 /** 353 * @brief Enumerates the Other extended codec indexes. 354 */ 355 enum OmxIndexCodecOtherExtType { 356 /** Extended Config AutoFramerate Conversion */ 357 OMX_IndexCodecExtConfigAutoFramerateConversion = OMX_IndexOtherStartUnused + 0x1, 358 /** Extended Config Priority */ 359 OMX_IndexCodecExtConfigPriority, 360 /** Extended Config OperatingRate index */ 361 OMX_IndexCodecExtConfigOperatingRate, 362 }; 363 364 enum OmxIndexCodecVendorExtType { 365 /** Extended Channel Attributes index */ 366 OMX_IndexCodecExtChannelAttributes = OMX_IndexVendorStartUnused + 0x1, 367 /** CodecEnableNativeBufferParams */ 368 OMX_IndexCodecExtEnableNativeBuffer, 369 }; 370 371 /** 372 * @brief Structure for controlling HEVC video encoding 373 */ 374 struct CodecVideoParamHevc { 375 uint32_t size; /** Size of the structure */ 376 union OMX_VERSIONTYPE version; /** Component version */ 377 uint32_t portIndex; /** Port index */ 378 enum CodecHevcProfile profile; /** Hevc profile. For details, see {@link CodecHevcProfile}. */ 379 enum CodecHevcLevel level; /** Hevc level. For details, see {@link CodecHevcLevel}. */ 380 uint32_t keyFrameInterval; /** Distance between consecutive I-frames (including one of the I frams). 381 0 means interval is unspecified and can be freely chosen by the codec. 382 1 means a stream of only I frams. other means the real value. */ 383 }; 384 385 /** 386 * @brief Defines the <b>CodecEnableNativeBufferParams</b>. 387 */ 388 struct CodecEnableNativeBufferParams { 389 uint32_t size; /** Size of the structure */ 390 union OMX_VERSIONTYPE version; /** Component version */ 391 uint32_t portIndex; /** Port index */ 392 bool enable; /** Enable NativeBuffer */ 393 }; 394 395 struct ColorAspects { 396 bool range; 397 uint8_t primaries; 398 uint8_t transfer; 399 uint8_t matrixCoeffs; 400 }; 401 402 /** 403 * @brief Structure for controlling color space 404 */ 405 struct CodecVideoColorspace { 406 uint32_t size; /** Size of the structure */ 407 union OMX_VERSIONTYPE version; /** Component version */ 408 uint32_t portIndex; /** Port index */ 409 uint32_t requestingDataSpace; 410 uint32_t dataSpaceChanged; 411 uint32_t pixeFormat; 412 uint32_t dataSpace; 413 struct ColorAspects aspects; 414 }; 415 416 /** 417 * @brief Structure for pAppPrivate data of OMX_BUFFERHEADERTYPE 418 */ 419 struct OMXBufferAppPrivateData { 420 int32_t fd; /** dma fd or secure dma fd allocated by vender */ 421 uint32_t sizeOfParam; 422 void *param; 423 }; 424 425 struct CodecLTRParam { 426 uint32_t size; /** Size of the structure */ 427 union OMX_VERSIONTYPE version; /** Component version */ 428 uint32_t ltrFrameListLen; 429 }; 430 431 struct CodecLTRPerFrameParam { 432 bool markAsLTR; 433 bool useLTR; 434 uint32_t useLTRPoc; 435 }; 436 437 struct CodecEncOutLTRParam { 438 bool isLTR; 439 uint32_t poc; 440 }; 441 442 struct CodecQPRangeParam { 443 uint32_t size; /** Size of the structure */ 444 union OMX_VERSIONTYPE version; /** Component version */ 445 uint32_t minQp; 446 uint32_t maxQp; 447 }; 448 449 struct CodecTemperalLayerParam { 450 uint32_t size; /** Size of the structure */ 451 union OMX_VERSIONTYPE version; /** Component version */ 452 uint32_t layerCnt; 453 }; 454 455 struct CodecParamOverlayBuffer { 456 uint32_t size; /** Size of the structure */ 457 union OMX_VERSIONTYPE version; /** Component version */ 458 bool enable; 459 uint32_t dstX; 460 uint32_t dstY; 461 uint32_t dstW; 462 uint32_t dstH; 463 void* bufferHandle; 464 }; 465 466 struct CodecEncOutMadParam { 467 int32_t frameMadi; 468 int32_t frameMadp; 469 int32_t sumMadi; 470 }; 471 472 #ifdef __cplusplus 473 #if __cplusplus 474 } 475 #endif 476 #endif /* __cplusplus */ 477 478 #endif // CODEC_OMX_EXT_H