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 23extern "C" { 24#endif 25#endif /* __cplusplus */ 26 27#define PROCESS_NAME_LEN 50 28 29/** 30 * @brief Enumerates the extended AVC profile. 31 */ 32enum 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 */ 42enum 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 */ 51enum 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 */ 65enum 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 */ 99enum CodecColorFormatExt { 100 CODEC_COLOR_FORMAT_RGBA8888 = OMX_COLOR_FormatVendorStartUnused + 100, 101}; 102 103/** 104 * @brief Enumerates the buffer types. 105 */ 106enum 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 */ 124struct 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 */ 134struct 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 */ 144struct 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 */ 154struct 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 */ 167struct 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 */ 177struct 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 */ 186struct 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 */ 195struct 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 */ 204struct 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 */ 217enum 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 /** CodecTemperalLayerParam */ 259 OMX_IndexParamTemperalLayer, 260 /** OMX_CONFIG_BOOLEANTYPE */ 261 OMX_IndexParamEncParamsFeedback, 262 /** OMX_S32 */ 263 OMX_IndexParamEncOutFrameLayer, 264 /** OMX_S32 */ 265 OMX_IndexParamQPStsart, 266 /** OMX_BOOL */ 267 OMX_IndexParamSkipFrame, 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 /** OMX_CONFIG_BOOLEANTYPE */ 279 OMX_IndexParamIsMvUpload, 280}; 281 282/** 283 * @brief Enumerates the Other Control Rate Type. 284 */ 285typedef enum OmxVideoControlRateVendorExtType { 286 /** constant bit rate mode with Rlambda */ 287 OMX_Video_ControlRateConstantWithRlambda = OMX_Video_ControlRateVendorStartUnused + 0x1, 288} OmxVideoControlRateVendorExtType; 289 290/** 291 * @brief Enumerates the Other extended codec indexes. 292 */ 293enum OmxIndexCodecOtherExtType { 294 /** Extended Config AutoFramerate Conversion */ 295 OMX_IndexCodecExtConfigAutoFramerateConversion = OMX_IndexOtherStartUnused + 0x1, 296 /** Extended Config Priority */ 297 OMX_IndexCodecExtConfigPriority, 298 /** Extended Config OperatingRate index */ 299 OMX_IndexCodecExtConfigOperatingRate, 300}; 301 302enum OmxIndexCodecVendorExtType { 303 /** Extended Channel Attributes index */ 304 OMX_IndexCodecExtChannelAttributes = OMX_IndexVendorStartUnused + 0x1, 305 /** CodecEnableNativeBufferParams */ 306 OMX_IndexCodecExtEnableNativeBuffer, 307}; 308 309/** 310 * @brief Structure for controlling HEVC video encoding 311 */ 312struct CodecVideoParamHevc { 313 uint32_t size; /** Size of the structure */ 314 union OMX_VERSIONTYPE version; /** Component version */ 315 uint32_t portIndex; /** Port index */ 316 enum CodecHevcProfile profile; /** Hevc profile. For details, see {@link CodecHevcProfile}. */ 317 enum CodecHevcLevel level; /** Hevc level. For details, see {@link CodecHevcLevel}. */ 318 uint32_t keyFrameInterval; /** Distance between consecutive I-frames (including one of the I frams). 319 0 means interval is unspecified and can be freely chosen by the codec. 320 1 means a stream of only I frams. other means the real value. */ 321}; 322 323/** 324 * @brief Defines the <b>CodecEnableNativeBufferParams</b>. 325 */ 326struct CodecEnableNativeBufferParams { 327 uint32_t size; /** Size of the structure */ 328 union OMX_VERSIONTYPE version; /** Component version */ 329 uint32_t portIndex; /** Port index */ 330 bool enable; /** Enable NativeBuffer */ 331}; 332 333struct ColorAspects { 334 bool range; 335 uint8_t primaries; 336 uint8_t transfer; 337 uint8_t matrixCoeffs; 338}; 339 340/** 341 * @brief Structure for controlling color space 342*/ 343struct CodecVideoColorspace { 344 uint32_t size; /** Size of the structure */ 345 union OMX_VERSIONTYPE version; /** Component version */ 346 uint32_t portIndex; /** Port index */ 347 uint32_t requestingDataSpace; 348 uint32_t dataSpaceChanged; 349 uint32_t pixeFormat; 350 uint32_t dataSpace; 351 struct ColorAspects aspects; 352}; 353 354/** 355 * @brief Structure for pAppPrivate data of OMX_BUFFERHEADERTYPE 356*/ 357struct OMXBufferAppPrivateData { 358 int32_t fd; /** dma fd or secure dma fd allocated by vender */ 359 uint32_t sizeOfParam; 360 void *param; 361}; 362 363struct CodecLTRParam { 364 uint32_t size; /** Size of the structure */ 365 union OMX_VERSIONTYPE version; /** Component version */ 366 uint32_t ltrFrameListLen; 367}; 368 369struct CodecLTRPerFrameParam { 370 bool markAsLTR; 371 bool useLTR; 372 uint32_t useLTRPoc; 373}; 374 375struct CodecEncOutLTRParam { 376 bool isLTR; 377 uint32_t poc; 378}; 379 380struct CodecQPRangeParam { 381 uint32_t size; /** Size of the structure */ 382 union OMX_VERSIONTYPE version; /** Component version */ 383 uint32_t minQp; 384 uint32_t maxQp; 385}; 386 387struct CodecTemperalLayerParam { 388 uint32_t size; /** Size of the structure */ 389 union OMX_VERSIONTYPE version; /** Component version */ 390 uint32_t layerCnt; 391}; 392 393struct CodecParamOverlayBuffer { 394 uint32_t size; /** Size of the structure */ 395 union OMX_VERSIONTYPE version; /** Component version */ 396 bool enable; 397 uint32_t dstX; 398 uint32_t dstY; 399 uint32_t dstW; 400 uint32_t dstH; 401 void* bufferHandle; 402}; 403 404struct CodecEncOutMadParam { 405 int32_t frameMadi; 406 int32_t frameMadp; 407 int32_t sumMadi; 408}; 409 410#ifdef __cplusplus 411#if __cplusplus 412} 413#endif 414#endif /* __cplusplus */ 415 416#endif // CODEC_OMX_EXT_H