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 codec color format. 98 */ 99 enum CodecColorFormatExt { 100 CODEC_COLOR_FORMAT_RGBA8888 = OMX_COLOR_FormatVendorStartUnused + 100, 101 }; 102 103 /** 104 * @brief Enumerates the buffer types. 105 */ 106 enum CodecBufferType { 107 /** Invalid buffer type. */ 108 CODEC_BUFFER_TYPE_INVALID = 0, 109 /** Virtual address type. */ 110 CODEC_BUFFER_TYPE_VIRTUAL_ADDR = 0x1, 111 /** Shared memory. */ 112 CODEC_BUFFER_TYPE_AVSHARE_MEM_FD = 0x2, 113 /** Handle. */ 114 CODEC_BUFFER_TYPE_HANDLE = 0x4, 115 /** Dynamic handle. */ 116 CODEC_BUFFER_TYPE_DYNAMIC_HANDLE = 0x8, 117 /** DMA memory. */ 118 CODEC_BUFFER_TYPE_DMA_MEM_FD = 0x10, 119 }; 120 121 /** 122 * @brief Defines the <b>SupportBuffer</b>. 123 */ 124 struct SupportBufferType { 125 uint32_t size; /** Size of the structure */ 126 union OMX_VERSIONTYPE version; /** Component version */ 127 uint32_t portIndex; /** Port index */ 128 uint32_t bufferTypes; /** Supported buffer types */ 129 }; 130 131 /** 132 * @brief Define the <b>UseBuffer</b>. 133 */ 134 struct UseBufferType { 135 uint32_t size; /** Size of the structure */ 136 union OMX_VERSIONTYPE version; /** Component version */ 137 uint32_t portIndex; /** Port index */ 138 uint32_t bufferType; /** Buffer type */ 139 }; 140 141 /** 142 * @brief Defines the <b>BufferHandleUsage</b>. 143 */ 144 struct GetBufferHandleUsageParams { 145 uint32_t size; /** Size of the structure */ 146 union OMX_VERSIONTYPE version; /** Component version */ 147 uint32_t portIndex; /** Port index */ 148 uint64_t usage; /** Usage */ 149 }; 150 151 /** 152 * @brief Defines the <b>CodecVideoPortFormatParam</b>. 153 */ 154 struct CodecVideoPortFormatParam { 155 uint32_t size; /** Size of the structure */ 156 union OMX_VERSIONTYPE version; /** Component version */ 157 uint32_t portIndex; /** Port index */ 158 uint32_t codecColorIndex; /** Color format index */ 159 uint32_t codecColorFormat; /** Color format defined in Display */ 160 uint32_t codecCompressFormat; /** See */ 161 uint32_t framerate; /** Q16 format */ 162 }; 163 164 /** 165 * @brief Defines the <b>ControlRateConstantQuality</b>. 166 */ 167 struct ControlRateConstantQuality { 168 uint32_t size; /** Size of the structure */ 169 union OMX_VERSIONTYPE version; /** Component version */ 170 uint32_t portIndex; /** Port index */ 171 uint32_t qualityValue; /** Control rate constant quality */ 172 }; 173 174 /** 175 * @brief Defines the <b>PassthroughParam</b>. 176 */ 177 struct PassthroughParam { 178 int32_t key; /**< Parameter type index */ 179 void *val; /**< Pointer to the parameter value */ 180 int size; /**< Parameter value size */ 181 }; 182 183 /** 184 * @brief Defines the <b>WorkingFrequencyParam</b>. 185 */ 186 struct WorkingFrequencyParam { 187 uint32_t size; /** Size of the structure */ 188 union OMX_VERSIONTYPE version; /** Component version */ 189 uint32_t level; /** Working Frequency level */ 190 }; 191 192 /** 193 * @brief Defines the <b>ProcessNameParam</b>. 194 */ 195 struct ProcessNameParam { 196 uint32_t size; /** Size of the structure */ 197 union OMX_VERSIONTYPE version; /** Component version */ 198 char processName[PROCESS_NAME_LEN]; /** Process name array */ 199 }; 200 201 /** 202 * @brief Defines the <b>AudioCodecParam</b>. 203 */ 204 struct AudioCodecParam { 205 uint32_t size; /** Size of the structure */ 206 union OMX_VERSIONTYPE version; /** Component version */ 207 uint32_t sampleRate; /** Sample Rate */ 208 uint32_t sampleFormat; /** Sample Format */ 209 uint32_t channels; /** Channels */ 210 uint32_t bitRate; /** Bit Rate */ 211 uint32_t reserved; /** reserved word */ 212 }; 213 214 /** 215 * @brief Enumerates the extended codec indexes. 216 */ 217 enum OmxIndexCodecExType { 218 /** Extended BufferType index */ 219 OMX_IndexExtBufferTypeStartUnused = OMX_IndexKhronosExtensions + 0x00a00000, 220 /** SupportBuffer */ 221 OMX_IndexParamSupportBufferType, 222 /** UseBuffer */ 223 OMX_IndexParamUseBufferType, 224 /** GetBufferHandleUsage */ 225 OMX_IndexParamGetBufferHandleUsage, 226 /** CodecVideoPortFormatParam */ 227 OMX_IndexCodecVideoPortFormat, 228 /** ControlRateConstantQuality */ 229 OMX_IndexParamControlRateConstantQuality, 230 /** PassthroughParam */ 231 OMX_IndexParamPassthrough, 232 /** OMX_IndexParamVideoHevc */ 233 OMX_IndexParamVideoHevc, 234 /** range/primary/transfer/matrix */ 235 OMX_IndexColorAspects, 236 /** WorkingFrequencyParam */ 237 OMX_IndexParamWorkingFrequency, 238 /** ProcessNameParam */ 239 OMX_IndexParamProcessName, 240 /** AudioCodecParam */ 241 OMX_IndexParamAudioCodec, 242 /** CodecParamOverlayBuffer */ 243 OMX_IndexParamOverlayBuffer, 244 /** CodecLTRParam/CodecLTRPerFrameParam */ 245 OMX_IndexParamLTR, 246 /** CodecQPRangeParam */ 247 OMX_IndexParamQPRange, 248 /** OMX_CONFIG_BOOLEANTYPE */ 249 OMX_IndexParamLowLatency, 250 /** WirelessLowDelay */ 251 OMX_IndexParamWirelessLowDelay, 252 /** OMX_S32 */ 253 OMX_IndexParamEncOutQp, 254 /** double */ 255 OMX_IndexParamEncOutMse, 256 /** CodecEncOutLTRParam */ 257 OMX_IndexParamEncOutLTR, 258 /** OMX_CONFIG_BOOLEANTYPE */ 259 OMX_IndexParamEncParamsFeedback, 260 /** OMX_S32 */ 261 OMX_IndexParamEncOutFrameLayer, 262 /** OMX_S32 */ 263 OMX_IndexParamQPStsart, 264 /** OMX_BOOL */ 265 OMX_IndexParamSkipFrame, 266 /** CodecTemperalLayerParam */ 267 OMX_IndexParamTemperalLayer, 268 /** OMX_S32 */ 269 OMX_IndexParamEncOutRealBitrate, 270 /** CodecEncOutMadParam */ 271 OMX_IndexParamEncOutMad, 272 /** OMX_S32 */ 273 OMX_IndexParamEncOutIRatio, 274 /** OMX_S32 */ 275 OMX_IndexParamEncOutFrameQp, 276 /** OMX_CONFIG_BOOLEANTYPE */ 277 OMX_IndexParamSupportPackInput, 278 }; 279 280 /** 281 * @brief Enumerates the Other Control Rate Type. 282 */ 283 typedef enum OmxVideoControlRateVendorExtType { 284 /** constant bit rate mode with Rlambda */ 285 OMX_Video_ControlRateConstantWithRlambda = OMX_Video_ControlRateVendorStartUnused + 0x1, 286 } OmxVideoControlRateVendorExtType; 287 288 /** 289 * @brief Enumerates the Other extended codec indexes. 290 */ 291 enum OmxIndexCodecOtherExtType { 292 /** Extended Config AutoFramerate Conversion */ 293 OMX_IndexCodecExtConfigAutoFramerateConversion = OMX_IndexOtherStartUnused + 0x1, 294 /** Extended Config Priority */ 295 OMX_IndexCodecExtConfigPriority, 296 /** Extended Config OperatingRate index */ 297 OMX_IndexCodecExtConfigOperatingRate, 298 }; 299 300 enum OmxIndexCodecVendorExtType { 301 /** Extended Channel Attributes index */ 302 OMX_IndexCodecExtChannelAttributes = OMX_IndexVendorStartUnused + 0x1, 303 /** CodecEnableNativeBufferParams */ 304 OMX_IndexCodecExtEnableNativeBuffer, 305 }; 306 307 /** 308 * @brief Structure for controlling HEVC video encoding 309 */ 310 struct CodecVideoParamHevc { 311 uint32_t size; /** Size of the structure */ 312 union OMX_VERSIONTYPE version; /** Component version */ 313 uint32_t portIndex; /** Port index */ 314 enum CodecHevcProfile profile; /** Hevc profile. For details, see {@link CodecHevcProfile}. */ 315 enum CodecHevcLevel level; /** Hevc level. For details, see {@link CodecHevcLevel}. */ 316 uint32_t keyFrameInterval; /** Distance between consecutive I-frames (including one of the I frams). 317 0 means interval is unspecified and can be freely chosen by the codec. 318 1 means a stream of only I frams. other means the real value. */ 319 }; 320 321 /** 322 * @brief Defines the <b>CodecEnableNativeBufferParams</b>. 323 */ 324 struct CodecEnableNativeBufferParams { 325 uint32_t size; /** Size of the structure */ 326 union OMX_VERSIONTYPE version; /** Component version */ 327 uint32_t portIndex; /** Port index */ 328 bool enable; /** Enable NativeBuffer */ 329 }; 330 331 struct ColorAspects { 332 bool range; 333 uint8_t primaries; 334 uint8_t transfer; 335 uint8_t matrixCoeffs; 336 }; 337 338 /** 339 * @brief Structure for controlling color space 340 */ 341 struct CodecVideoColorspace { 342 uint32_t size; /** Size of the structure */ 343 union OMX_VERSIONTYPE version; /** Component version */ 344 uint32_t portIndex; /** Port index */ 345 uint32_t requestingDataSpace; 346 uint32_t dataSpaceChanged; 347 uint32_t pixeFormat; 348 uint32_t dataSpace; 349 struct ColorAspects aspects; 350 }; 351 352 /** 353 * @brief Structure for pAppPrivate data of OMX_BUFFERHEADERTYPE 354 */ 355 struct OMXBufferAppPrivateData { 356 int32_t fd; /** dma fd or secure dma fd allocated by vender */ 357 uint32_t sizeOfParam; 358 void *param; 359 }; 360 361 struct CodecLTRParam { 362 uint32_t size; /** Size of the structure */ 363 union OMX_VERSIONTYPE version; /** Component version */ 364 uint32_t ltrFrameListLen; 365 }; 366 367 struct CodecLTRPerFrameParam { 368 bool markAsLTR; 369 bool useLTR; 370 uint32_t useLTRPoc; 371 }; 372 373 struct CodecEncOutLTRParam { 374 bool isLTR; 375 uint32_t poc; 376 }; 377 378 struct CodecQPRangeParam { 379 uint32_t size; /** Size of the structure */ 380 union OMX_VERSIONTYPE version; /** Component version */ 381 uint32_t minQp; 382 uint32_t maxQp; 383 }; 384 385 struct CodecTemperalLayerParam { 386 uint32_t size; /** Size of the structure */ 387 union OMX_VERSIONTYPE version; /** Component version */ 388 uint32_t layerCnt; 389 }; 390 391 struct CodecParamOverlayBuffer { 392 uint32_t size; /** Size of the structure */ 393 union OMX_VERSIONTYPE version; /** Component version */ 394 bool enable; 395 uint32_t dstX; 396 uint32_t dstY; 397 uint32_t dstW; 398 uint32_t dstH; 399 void* bufferHandle; 400 }; 401 402 struct CodecEncOutMadParam { 403 int32_t frameMadi; 404 int32_t frameMadp; 405 int32_t sumMadi; 406 }; 407 408 #ifdef __cplusplus 409 #if __cplusplus 410 } 411 #endif 412 #endif /* __cplusplus */ 413 414 #endif // CODEC_OMX_EXT_H