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 <stdbool.h> 20 #ifdef __cplusplus 21 #if __cplusplus 22 extern "C" { 23 #endif 24 #endif /* __cplusplus */ 25 26 #define PROCESS_NAME_LEN 50 27 28 /** 29 * @brief Enumerates the extended codec codingtyps. 30 */ 31 enum CodecVideoExType { 32 CODEC_OMX_VIDEO_CodingVP9 = 10, /** VP9 Index in Codec HDI */ 33 CODEC_OMX_VIDEO_CodingHEVC = 11, /** HEVC Index in Codec HDI */ 34 }; 35 36 /** 37 * @brief Enumerates the extended HEVC profile. 38 */ 39 enum CodecHevcProfile { 40 CODEC_HEVC_PROFILE_INVALID = 0x0, 41 CODEC_HEVC_PROFILE_MAIN = 0x1, 42 CODEC_HEVC_PROFILE_MAIN10 = 0x2, 43 CODEC_HEVC_PROFILE_MAIN_STILL = 0x3, 44 // main_10 profile with HDR SEI support. 45 CODEC_HEVC_PROFILE_MAIN10_HDR10 = 0x1000, 46 CODEC_HEVC_PROFILE_MAIN10_HDR10_PLUS = 0x2000, 47 CODEC_HEVC_PROFILE_MAX = 0x7FFFFFFF 48 }; 49 50 /** 51 * @brief Enumerates the extended HEVC level. 52 */ 53 enum CodecHevcLevel { 54 CODEC_HEVC_LEVEL_INVALID = 0x0, 55 CODEC_HEVC_MAIN_TIER_LEVEL1 = 0x1, 56 CODEC_HEVC_HIGH_TIER_LEVEL1 = 0x2, 57 CODEC_HEVC_MAIN_TIER_LEVEL2 = 0x4, 58 CODEC_HEVC_HIGH_TIER_LEVEL2 = 0x8, 59 CODEC_HEVC_MAIN_TIER_LEVEL21 = 0x10, 60 CODEC_HEVC_HIGH_TIER_LEVEL21 = 0x20, 61 CODEC_HEVC_MAIN_TIER_LEVEL3 = 0x40, 62 CODEC_HEVC_HIGH_TIER_LEVEL3 = 0x80, 63 CODEC_HEVC_MAIN_TIER_LEVEL31 = 0x100, 64 CODEC_HEVC_HIGH_TIER_LEVEL31 = 0x200, 65 CODEC_HEVC_MAIN_TIER_LEVEL4 = 0x400, 66 CODEC_HEVC_HIGH_TIER_LEVEL4 = 0x800, 67 CODEC_HEVC_MAIN_TIER_LEVEL41 = 0x1000, 68 CODEC_HEVC_HIGH_TIER_LEVEL41 = 0x2000, 69 CODEC_HEVC_MAIN_TIER_LEVEL5 = 0x4000, 70 CODEC_HEVC_HIGH_TIER_LEVEL5 = 0x8000, 71 CODEC_HEVC_MAIN_TIER_LEVEL51 = 0x10000, 72 CODEC_HEVC_HIGH_TIER_LEVEL51 = 0x20000, 73 CODEC_HEVC_MAIN_TIER_LEVEL52 = 0x40000, 74 CODEC_HEVC_HIGH_TIER_LEVEL52 = 0x80000, 75 CODEC_HEVC_MAIN_TIER_LEVEL6 = 0x100000, 76 CODEC_HEVC_HIGH_TIER_LEVEL6 = 0x200000, 77 CODEC_HEVC_MAIN_TIER_LEVEL61 = 0x400000, 78 CODEC_HEVC_HIGH_TIER_LEVEL61 = 0x800000, 79 CODEC_HEVC_MAIN_TIER_LEVEL62 = 0x1000000, 80 CODEC_HEVC_HIGH_TIER_LEVEL62 = 0x2000000, 81 CODEC_HEVC_HIGH_TIER_MAX = 0x7FFFFFFF 82 }; 83 84 /** 85 * @brief Enumerates the extended codec color format. 86 */ 87 enum CodecColorFormatExt { 88 CODEC_COLOR_FORMAT_RGBA8888 = OMX_COLOR_FormatVendorStartUnused + 100, 89 }; 90 91 /** 92 * @brief Enumerates the buffer types. 93 */ 94 enum CodecBufferType { 95 /** Invalid buffer type. */ 96 CODEC_BUFFER_TYPE_INVALID = 0, 97 /** Virtual address type. */ 98 CODEC_BUFFER_TYPE_VIRTUAL_ADDR = 0x1, 99 /** Shared memory. */ 100 CODEC_BUFFER_TYPE_AVSHARE_MEM_FD = 0x2, 101 /** Handle. */ 102 CODEC_BUFFER_TYPE_HANDLE = 0x4, 103 /** Dynamic handle. */ 104 CODEC_BUFFER_TYPE_DYNAMIC_HANDLE = 0x8, 105 /** DMA memory. */ 106 CODEC_BUFFER_TYPE_DMA_MEM_FD = 0x10, 107 }; 108 109 /** 110 * @brief Defines the <b>SupportBuffer</b>. 111 */ 112 struct SupportBufferType { 113 uint32_t size; /** Size of the structure */ 114 union OMX_VERSIONTYPE version; /** Component version */ 115 uint32_t portIndex; /** Port index */ 116 uint32_t bufferTypes; /** Supported buffer types */ 117 }; 118 119 /** 120 * @brief Define the <b>UseBuffer</b>. 121 */ 122 struct UseBufferType { 123 uint32_t size; /** Size of the structure */ 124 union OMX_VERSIONTYPE version; /** Component version */ 125 uint32_t portIndex; /** Port index */ 126 uint32_t bufferType; /** Buffer type */ 127 }; 128 129 /** 130 * @brief Defines the <b>BufferHandleUsage</b>. 131 */ 132 struct GetBufferHandleUsageParams { 133 uint32_t size; /** Size of the structure */ 134 union OMX_VERSIONTYPE version; /** Component version */ 135 uint32_t portIndex; /** Port index */ 136 uint64_t usage; /** Usage */ 137 }; 138 139 /** 140 * @brief Defines the <b>CodecVideoPortFormatParam</b>. 141 */ 142 struct CodecVideoPortFormatParam { 143 uint32_t size; /** Size of the structure */ 144 union OMX_VERSIONTYPE version; /** Component version */ 145 uint32_t portIndex; /** Port index */ 146 uint32_t codecColorIndex; /** Color format index */ 147 uint32_t codecColorFormat; /** Color format defined in Display */ 148 uint32_t codecCompressFormat; /** See */ 149 uint32_t framerate; /** Q16 format */ 150 }; 151 152 /** 153 * @brief Defines the <b>ControlRateConstantQuality</b>. 154 */ 155 struct ControlRateConstantQuality { 156 uint32_t size; /** Size of the structure */ 157 union OMX_VERSIONTYPE version; /** Component version */ 158 uint32_t portIndex; /** Port index */ 159 uint32_t qualityValue; /** Control rate constant quality */ 160 }; 161 162 /** 163 * @brief Defines the <b>PassthroughParam</b>. 164 */ 165 struct PassthroughParam { 166 int32_t key; /**< Parameter type index */ 167 void *val; /**< Pointer to the parameter value */ 168 int size; /**< Parameter value size */ 169 }; 170 171 /** 172 * @brief Defines the <b>WorkingFrequencyParam</b>. 173 */ 174 struct WorkingFrequencyParam { 175 uint32_t size; /** Size of the structure */ 176 union OMX_VERSIONTYPE version; /** Component version */ 177 uint32_t level; /** Working Frequency level */ 178 }; 179 180 /** 181 * @brief Defines the <b>ProcessNameParam</b>. 182 */ 183 struct ProcessNameParam { 184 uint32_t size; /** Size of the structure */ 185 union OMX_VERSIONTYPE version; /** Component version */ 186 char processName[PROCESS_NAME_LEN]; /** Process name array */ 187 }; 188 /** 189 * @brief Enumerates the extended codec indexes. 190 */ 191 enum OmxIndexCodecExType { 192 /** Extended BufferType index */ 193 OMX_IndexExtBufferTypeStartUnused = OMX_IndexKhronosExtensions + 0x00a00000, 194 /** SupportBuffer */ 195 OMX_IndexParamSupportBufferType, 196 /** UseBuffer */ 197 OMX_IndexParamUseBufferType, 198 /** GetBufferHandleUsage */ 199 OMX_IndexParamGetBufferHandleUsage, 200 /** CodecVideoPortFormatParam */ 201 OMX_IndexCodecVideoPortFormat, 202 /** ControlRateConstantQuality */ 203 OMX_IndexParamControlRateConstantQuality, 204 /** PassthroughParam */ 205 OMX_IndexParamPassthrough, 206 /** OMX_IndexParamVideoHevc */ 207 OMX_IndexParamVideoHevc, 208 /** range/primary/transfer/matrix */ 209 OMX_IndexColorAspects, 210 /** WorkingFrequencyParam */ 211 OMX_IndexParamWorkingFrequency, 212 /** ProcessNameParam */ 213 OMX_IndexParamProcessName, 214 }; 215 216 /** 217 * @brief Enumerates the Other extended codec indexes. 218 */ 219 enum OmxIndexCodecOtherExtType { 220 /** Extended Config AutoFramerate Conversion */ 221 OMX_IndexCodecExtConfigAutoFramerateConversion = OMX_IndexOtherStartUnused + 0x1, 222 /** Extended Config Priority */ 223 OMX_IndexCodecExtConfigPriority, 224 /** Extended Config OperatingRate index */ 225 OMX_IndexCodecExtConfigOperatingRate, 226 }; 227 228 enum OmxIndexCodecVendorExtType { 229 /** Extended Channel Attributes index */ 230 OMX_IndexCodecExtChannelAttributes = OMX_IndexVendorStartUnused + 0x1, 231 /** CodecEnableNativeBufferParams */ 232 OMX_IndexCodecExtEnableNativeBuffer, 233 }; 234 235 /** 236 * @brief Structure for controlling HEVC video encoding 237 */ 238 struct CodecVideoParamHevc { 239 uint32_t size; /** Size of the structure */ 240 union OMX_VERSIONTYPE version; /** Component version */ 241 uint32_t portIndex; /** Port index */ 242 enum CodecHevcProfile profile; /** Hevc profile. For details, see {@link CodecHevcProfile}. */ 243 enum CodecHevcLevel level; /** Hevc level. For details, see {@link CodecHevcLevel}. */ 244 uint32_t keyFrameInterval; /** Distance between consecutive I-frames (including one of the I frams). 245 0 means interval is unspecified and can be freely chosen by the codec. 246 1 means a stream of only I frams. other means the real value. */ 247 }; 248 249 /** 250 * @brief Defines the <b>CodecEnableNativeBufferParams</b>. 251 */ 252 struct CodecEnableNativeBufferParams { 253 uint32_t size; /** Size of the structure */ 254 union OMX_VERSIONTYPE version; /** Component version */ 255 uint32_t portIndex; /** Port index */ 256 bool enable; /** Enable NativeBuffer */ 257 }; 258 259 enum RangeType { 260 RANGE_UNSPECIFIED, 261 RANGE_FULL, 262 RANGE_LIMITED, 263 RANGE_MAX = 0xff, 264 }; 265 266 enum Primaries { 267 PRIMARIES_UNSPECIFIED, 268 PRIMARIES_BT709, //Rec. ITU-R BT.709-6 269 PRIMARIES_BT470_6M, //Rec. ITU-R BT.470-6 System M 270 PRIMARIES_BT601_625, //Rec. ITU-R BT.601-7 625 or Rec. ITU-R BT.470-6 System B,G 271 PRIMARIES_BT601_525, //Rec. ITU-R BT.601-7 525 or SMPTE ST 170 or SMPTE ST 240 272 PRIMARIES_GENERICFILM, //Generic Film 273 PRIMARIES_BT2020, //Rec. ITU-R BT.2020-2 or Rec. ITU-R BT.2100-2 274 PRIMARIES_MAX = 0xff, 275 }; 276 277 enum Transfer { 278 TRANSFER_UNSPECIFIED, 279 TRANSFER_LINEAR, //Linear transfer characteristics 280 TRANSFER_SRGB, //IEC 61966-2-1 sRGB 281 TRANSFER_SMPTE170, //SMPTE ST 170 or Rec. ITU-R BT.709-6 or BT.601-7 or BT.2020-2 282 TRANSFER_GAMMA22, //Rec. ITU-R BT.470-6 System M 283 TRANSFER_GAMMA28, //Rec. ITU-R BT.470-6 System B,G 284 TRANSFER_PQ, //Rec. ITU-R BT.2100-2 perceptual quantization (PQ) system 285 TRANSFER_HLG, //Rec. ITU-R BT.2100-2 hybrid log gamma (HLG) system 286 TRANSFER_SMPTE240 = 0x40, //SMPTE ST 240 287 TRANSFER_XVYCC, //IEC 61966-2-4 288 TRANSFER_BT1361, //Rec. ITU-R BT.1361-0 extended colour gamut system 289 TRANSFER_ST428, //SMPTE ST 428-1 290 TRANSFER_MAX = 0xff, 291 }; 292 293 enum MatrixCoeffs { 294 MATRIX_UNSPECIFED, 295 MATRIX_BT709, //Rec. ITU-R BT.709-6 296 MATRIX_FCC, //United States Federal Communications Commission 297 MATRIX_BT601, //Rec. ITU-R BT.601-7 or Rec. ITU-R BT.470-6 System B,G 298 MATRIX_SMPTE240, //SMPTE ST 240 299 MATRIX_BT2020, //Rec. ITU-R BT.2100-2 (non-constant luminance) 300 MATRIX_BT2020CONSTANT, //Rec. ITU-R BT.2100-2 (constant luminance) 301 MATRIX_MAX = 0xff, 302 }; 303 304 struct ColorAspects { 305 enum RangeType range; 306 enum Primaries primaries; 307 enum Transfer transfer; 308 enum MatrixCoeffs matrixCoeffs; 309 }; 310 311 /** 312 * @brief Structure for controlling color space 313 */ 314 struct CodecVideoColorspace { 315 uint32_t size; /** Size of the structure */ 316 union OMX_VERSIONTYPE version; /** Component version */ 317 uint32_t portIndex; /** Port index */ 318 uint32_t requestingDataSpace; 319 uint32_t dataSpaceChanged; 320 uint32_t pixeFormat; 321 uint32_t dataSpace; 322 struct ColorAspects aspects; 323 }; 324 325 /** 326 * @brief Structure for pAppPrivate data of OMX_BUFFERHEADERTYPE 327 */ 328 struct OMXBufferAppPrivateData { 329 int32_t fd; /** dma fd or secure dma fd allocated by vender */ 330 uint32_t sizeOfParam; 331 void *param; 332 }; 333 334 #ifdef __cplusplus 335 #if __cplusplus 336 } 337 #endif 338 #endif /* __cplusplus */ 339 340 #endif // CODEC_OMX_EXT_H