1 /* 2 * Copyright(c) 2019 Intel Corporation 3 * 4 * This source code is subject to the terms of the BSD 2 Clause License and 5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 6 * was not distributed with this source code in the LICENSE file, you can 7 * obtain it at https://www.aomedia.org/license/software-license. If the Alliance for Open 8 * Media Patent License 1.0 was not distributed with this source code in the 9 * PATENTS file, you can obtain it at https://www.aomedia.org/license/patent-license. 10 */ 11 12 #ifndef EbSvtAv1_h 13 #define EbSvtAv1_h 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif // __cplusplus 18 19 #include <stdint.h> 20 #include "EbSvtAv1Formats.h" 21 #include "EbDebugMacros.h" 22 23 struct SvtMetadataArray; 24 25 // API Version 26 #define SVT_VERSION_MAJOR 0 27 #define SVT_VERSION_MINOR 8 28 #define SVT_VERSION_PATCHLEVEL 7 29 30 #if defined(_WIN32) 31 #define EB_HELPER_EXPORT __declspec(dllexport) 32 #define EB_HELPER_IMPORT __declspec(dllimport) 33 #elif defined(__GNUC__) && __GNUC__ >= 4 34 #define EB_HELPER_EXPORT __attribute__((visibility("default"))) 35 #define EB_HELPER_IMPORT 36 #else 37 #define EB_HELPER_EXPORT 38 #define EB_HELPER_IMPORT 39 #endif 40 41 #if defined(EB_DLL) 42 #if defined(EB_BUILDING_SHARED_LIBS) 43 #define EB_API EB_HELPER_EXPORT 44 #else 45 #define EB_API EB_HELPER_IMPORT 46 #endif // if defined(EB_BUILDING_SHARED_LIBS) 47 #else 48 #define EB_API 49 #endif //if defined(EB_DLL) 50 51 #define EB_MAX_NUM_OPERATING_POINTS 32 52 53 #define MAX_TEMPORAL_LAYERS 6 54 55 #define EB_MAX_TEMPORAL_LAYERS MAX_TEMPORAL_LAYERS 56 57 /******************************** 58 * Defines 59 ********************************/ 60 #define EB_PICTURE uint32_t 61 62 typedef enum EbAv1PictureType { 63 EB_AV1_INTER_PICTURE = 0, 64 EB_AV1_ALT_REF_PICTURE = 1, 65 EB_AV1_INTRA_ONLY_PICTURE = 2, 66 EB_AV1_KEY_PICTURE = 3, 67 EB_AV1_NON_REF_PICTURE = 4, 68 EB_AV1_SHOW_EXISTING_PICTURE = 6, 69 EB_AV1_FW_KEY_PICTURE = 5, 70 EB_AV1_SWITCH_PICTURE = 7, 71 EB_AV1_INVALID_PICTURE = 0xFF 72 } EbAv1PictureType; 73 74 /** The EbBool type is intended to be used to represent a true or a false 75 value when passing parameters to and from the eBrisk API. The 76 EbBool is a 32 bit quantity and is aligned on a 32 bit word boundary. 77 */ 78 79 #define EbBool uint8_t 80 #define EB_FALSE 0 81 #define EB_TRUE 1 82 83 typedef struct EbBufferHeaderType { 84 // EbBufferHeaderType size 85 uint32_t size; 86 87 // picture (input or output) buffer 88 uint8_t *p_buffer; 89 uint32_t n_filled_len; 90 uint32_t n_alloc_len; 91 92 // pic private data 93 void *p_app_private; 94 void *wrapper_ptr; 95 96 // pic timing param 97 uint32_t n_tick_count; 98 int64_t dts; 99 int64_t pts; 100 101 // pic info 102 uint32_t qp; 103 uint32_t pic_type; 104 uint32_t luma_sse; 105 uint32_t cr_sse; 106 uint32_t cb_sse; 107 // pic flags 108 uint32_t flags; 109 110 double luma_ssim; 111 double cr_ssim; 112 double cb_ssim; 113 114 struct SvtMetadataArray *metadata; 115 } EbBufferHeaderType; 116 117 typedef struct EbComponentType { 118 uint32_t size; 119 void * p_component_private; 120 void * p_application_private; 121 } EbComponentType; 122 123 typedef enum EbErrorType { 124 EB_ErrorNone = 0, 125 EB_DecUnsupportedBitstream = (int32_t)0x40001000, 126 EB_DecNoOutputPicture = (int32_t)0x40001004, 127 EB_DecDecodingError = (int32_t)0x40001008, 128 EB_Corrupt_Frame = (int32_t)0x4000100C, 129 EB_ErrorInsufficientResources = (int32_t)0x80001000, 130 EB_ErrorUndefined = (int32_t)0x80001001, 131 EB_ErrorInvalidComponent = (int32_t)0x80001004, 132 EB_ErrorBadParameter = (int32_t)0x80001005, 133 EB_ErrorDestroyThreadFailed = (int32_t)0x80002012, 134 EB_ErrorSemaphoreUnresponsive = (int32_t)0x80002021, 135 EB_ErrorDestroySemaphoreFailed = (int32_t)0x80002022, 136 EB_ErrorCreateMutexFailed = (int32_t)0x80002030, 137 EB_ErrorMutexUnresponsive = (int32_t)0x80002031, 138 EB_ErrorDestroyMutexFailed = (int32_t)0x80002032, 139 EB_NoErrorEmptyQueue = (int32_t)0x80002033, 140 EB_NoErrorFifoShutdown = (int32_t)0x80002034, 141 EB_ErrorMax = 0x7FFFFFFF 142 } EbErrorType; 143 144 /* AV1 bistream profile (seq_profile syntax element) */ 145 typedef enum EbAv1SeqProfile { 146 MAIN_PROFILE = 0, 147 HIGH_PROFILE = 1, 148 PROFESSIONAL_PROFILE = 2 149 } EbAv1SeqProfile; 150 151 typedef enum AomBitDepth { 152 AOM_BITS_8 = 8, /**< 8 bits */ 153 AOM_BITS_10 = 10, /**< 10 bits */ 154 AOM_BITS_12 = 12, /**< 12 bits */ 155 } AomBitDepth; 156 157 // For 8-bit and 10-bit packed inputs and outputs, the luma, cb, and cr fields should be used 158 // for the three input picture planes. However, for 10-bit unpacked planes the 159 // lumaExt, cbExt, and crExt fields should be used hold the extra 2-bits of 160 // precision while the luma, cb, and cr fields hold the 8-bit data. 161 typedef struct EbSvtIOFormat //former EbSvtEncInput 162 { 163 // Hosts 8 bit or 16 bit input YUV420p / YUV420p10le 164 uint8_t *luma; 165 uint8_t *cb; 166 uint8_t *cr; 167 168 // Hosts LSB 2 bits of 10bit input/output when the compressed 10bit format is used 169 uint8_t *luma_ext; 170 uint8_t *cb_ext; 171 uint8_t *cr_ext; 172 173 uint32_t y_stride; 174 uint32_t cr_stride; 175 uint32_t cb_stride; 176 177 uint32_t width; 178 uint32_t height; 179 180 uint32_t origin_x; 181 uint32_t origin_y; 182 183 EbColorFormat color_fmt; 184 EbBitDepth bit_depth; 185 } EbSvtIOFormat; 186 187 typedef struct BitstreamLevel { 188 uint8_t major; 189 uint8_t minor; 190 } BitstreamLevel; 191 192 typedef struct EbOperatingParametersInfo { 193 /*!<Specifies the time interval between the arrival of the first bit in the 194 * smoothing buffer and the subsequent removal of the data that belongs to 195 * the first coded frame for operating point*/ 196 uint32_t decoder_buffer_delay; 197 198 /*!<Specifies, in combination with decoder_buffer_delay[op] syntax element, 199 * the first bit arrival time of frames to be decoded to the smoothing 200 * buffer */ 201 uint32_t encoder_buffer_delay; 202 203 /*!< Equal to 1 indicates that the smoothing buffer operates in low-delay 204 * mode for operating point*/ 205 uint8_t low_delay_mode_flag; 206 207 } EbOperatingParametersInfo; 208 209 typedef struct EbAV1OperatingPoint { 210 uint32_t op_idc; 211 uint32_t seq_level_idx; 212 uint32_t seq_tier; 213 214 /*!< 1 -> Indicates that there is a decoder model associated with operating 215 point, 216 * 0 -> Indicates that there is not a decoder model associated with 217 operating point*/ 218 uint8_t decoder_model_present_for_this_op; 219 220 /*!< Operating Parameters Information structure*/ 221 EbOperatingParametersInfo operating_parameters_info; 222 223 uint32_t initial_display_delay_present_for_this_op; 224 uint32_t initial_display_delay; 225 226 } EbAv1OperatingPoint; 227 228 typedef struct EbColorConfig { 229 /*!< bit depth */ 230 uint32_t bit_depth; 231 232 /*!< 1: Indicates that the video does not contain U and V color planes. 233 * 0: Indicates that the video contains Y, U, and V color planes. */ 234 EbBool mono_chrome; 235 236 /*!< Specify the chroma subsampling format */ 237 uint8_t subsampling_x; 238 239 /*!< Specify the chroma subsampling format */ 240 uint8_t subsampling_y; 241 242 /*!< 1: Specifies that color_primaries, transfer_characteristics, and 243 matrix_coefficients are present. color_description_present_flag 244 * 0: Specifies that color_primaries, transfer_characteristics and 245 matrix_coefficients are not present */ 246 EbBool color_description_present_flag; 247 248 /*!< An integer that is defined by the "Color primaries" section of 249 * ISO/IEC 23091-4/ITU-T H.273 */ 250 EbColorPrimaries color_primaries; 251 252 /*!< An integer that is defined by the "Transfer characteristics" section 253 * of ISO/IEC 23091-4/ITU-T H.273 */ 254 EbTransferCharacteristics transfer_characteristics; 255 256 /*!< An integer that is defined by the "Matrix coefficients" section of 257 * ISO/IEC 23091-4/ITU-T H.273 */ 258 EbMatrixCoefficients matrix_coefficients; 259 260 /*!< 0: shall be referred to as the studio swing representation 261 * 1: shall be referred to as the full swing representation */ 262 EbColorRange color_range; 263 264 /*!< Specifies the sample position for subsampled streams */ 265 EbChromaSamplePosition chroma_sample_position; 266 267 /*!< 1: Indicates that the U and V planes may have separate delta quantizer 268 * 0: Indicates that the U and V planes will share the same delta 269 quantizer value */ 270 EbBool separate_uv_delta_q; 271 272 } EbColorConfig; 273 274 typedef struct EbTimingInfo { 275 /*!< Timing info present flag */ 276 EbBool timing_info_present; 277 278 /*!< Number of time units of a clock operating at the frequency time_scale 279 * Hz that corresponds to one increment of a clock tick counter*/ 280 uint32_t num_units_in_display_tick; 281 282 /*!< Number of time units that pass in one second*/ 283 uint32_t time_scale; 284 285 /*!< Equal to 1 indicates that pictures should be displayed according to 286 * their output order with the number of ticks between two consecutive 287 * pictures specified by num_ticks_per_picture.*/ 288 uint8_t equal_picture_interval; 289 290 /*!< Specifies the number of clock ticks corresponding to output time 291 * between two consecutive pictures in the output order. 292 * Range - [0 to (1 << 32) - 2]*/ 293 uint32_t num_ticks_per_picture; 294 295 } EbTimingInfo; 296 297 /** 298 CPU FLAGS 299 */ 300 typedef uint64_t CPU_FLAGS; 301 #define CPU_FLAGS_MMX (1 << 0) 302 #define CPU_FLAGS_SSE (1 << 1) 303 #define CPU_FLAGS_SSE2 (1 << 2) 304 #define CPU_FLAGS_SSE3 (1 << 3) 305 #define CPU_FLAGS_SSSE3 (1 << 4) 306 #define CPU_FLAGS_SSE4_1 (1 << 5) 307 #define CPU_FLAGS_SSE4_2 (1 << 6) 308 #define CPU_FLAGS_AVX (1 << 7) 309 #define CPU_FLAGS_AVX2 (1 << 8) 310 #define CPU_FLAGS_AVX512F (1 << 9) 311 #define CPU_FLAGS_AVX512CD (1 << 10) 312 #define CPU_FLAGS_AVX512DQ (1 << 11) 313 #define CPU_FLAGS_AVX512ER (1 << 12) 314 #define CPU_FLAGS_AVX512PF (1 << 13) 315 #define CPU_FLAGS_AVX512BW (1 << 14) 316 #define CPU_FLAGS_AVX512VL (1 << 15) 317 #define CPU_FLAGS_ALL ((CPU_FLAGS_AVX512VL << 1) - 1) 318 #define CPU_FLAGS_INVALID (1ULL << (sizeof(CPU_FLAGS) * 8ULL - 1ULL)) 319 320 #ifdef __cplusplus 321 } 322 #endif // __cplusplus 323 324 #endif // EbSvtAv1_h 325