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