1 /*! 2 ************************************************************************** 3 * \file defines.h 4 * 5 * \brief 6 * Header file containing some useful global definitions 7 * 8 * \author 9 * Main contributors (see contributors.h for copyright, address and affiliation details) 10 * - Detlev Marpe 11 * - Karsten Suehring 12 * - Alexis Michael Tourapis <alexismt@ieee.org> 13 * 14 * 15 * \date 16 * 21. March 2001 17 ************************************************************************** 18 */ 19 20 21 #ifndef _DEFINES_H_ 22 #define _DEFINES_H_ 23 24 #if defined _DEBUG 25 # define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information 26 #else 27 # define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information 28 #endif 29 30 #define JM "19 (FRExt)" 31 #define VERSION "19.0" 32 #define EXT_VERSION "(FRExt)" 33 34 #define GET_METIME 1 //!< Enables or disables ME computation time 35 #define DUMP_DPB 0 //!< Dump DPB info for debug purposes 36 #define PRINTREFLIST 0 //!< Print ref list info for debug purposes 37 #define IMGTYPE 1 //!< Define imgpel size type. 0 implies byte (cannot handle >8 bit depths) and 1 implies unsigned short 38 #define ENABLE_FIELD_CTX 1 //!< Enables field context types for CABAC. If disabled, results in speedup for progressive content. 39 #define ENABLE_HIGH444_CTX 1 //!< Enables High 444 context types for CABAC. If disabled, results in speedup of non High444 profile encodings. 40 #define DEBUG_BITDEPTH 0 //!< Ensures that > 8 bit content have no values that would result in out of range results 41 #define ALLOW_GRAYSCALE 1 //!< Allow encoding in grayscale 42 #define ZEROSNR 1 //!< PSNR computation method 43 #define USE_RND_COST 0 //!< Perform ME RD decision using a rounding estimate of the motion cost 44 #define JM_INT_DIVIDE 1 45 #define JM_MEM_DISTORTION 0 46 #define JCOST_CALC_SCALEUP 1 //!< 1: J = (D<<LAMBDA_ACCURACY_BITS)+Lambda*R; 0: J = D + ((Lambda*R+Rounding)>>LAMBDA_ACCURACY_BITS) 47 #define INTRA_RDCOSTCALC_ET 1 //!< Early termination 48 #define INTRA_RDCOSTCALC_NNZ 1 //1: to recover block's nzn after rdcost calculation; 49 #define JCOST_OVERFLOWCHECK 0 //!<1: to check the J cost if it is overflow> 50 #define JM_PARALLEL_DEBLOCK 0 //!< Enables Parallel Deblocking 51 #define SIMULCAST_ENABLE 0 52 53 #define MVC_EXTENSION_ENABLE 1 //!< enable support for the Multiview High Profile 54 #define EOS_OUTPUT 0 55 56 #define EPZSREF 1 57 58 #define MAX_RC_MODE 3 59 #define RC_MAX_TEMPORAL_LEVELS 5 60 61 #define SSE_MEMORY_ALIGNMENT 16 62 #define MAX_NUM_DPB_LAYERS 2 63 //#define BEST_NZ_COEFF 1 // yuwen 2005.11.03 => for high complexity mode decision (CAVLC, #TotalCoeff) 64 65 // defines for creating similar coding structures like HM 66 #define OUTPUT_REF_LIST 0 //!< for debug purpose, output the reference picture list. do not support field 67 68 #define B0_MORE_REF 1 ///!< used for random access setting, treat POC(HM like poc, =JM poc/2)%(NumberOfBFrames+1)==0 as B0, i.e. use more references at temporal level 0 69 #define KEEP_B_SAME_LIST 1 ///!< keep B pictures using two identical reference picture lists 70 #define CRA 1 ///!< used for random access setting, HM CRA like random access point 71 ///!< using open GOP is not enough, for example, 32 is an Intra picture, when encoding 40, everything is OK. 72 ///!< but when encoding 36, there is one reference picture (32) in list0; actually, there should be two (32, 40) as HM. 73 ///!< setting number of reference frame to 1 at picture 40, using RPLR to let list1 use 32 as reference, 74 ///!< and marking all pictures unused for reference except 32 to solve this problem 75 #define HM50_LIKE_MMCO 1 ///!< use the HM-5.0 like MMCO, keep the identical referencing structure as HM-5.0 76 #define LD_REF_SETTING 1 ///!< used for low delay setting, 1+X referencing structure, as proposed in JCTVC-F701 77 78 79 //AVC Profile IDC definitions 80 extern enum { 81 NO_PROFILE = 0, //!< disable profile checking for experimental coding (enables FRExt, but disables MV) 82 FREXT_CAVLC444 = 44, //!< YUV 4:4:4/14 "CAVLC 4:4:4" 83 BASELINE = 66, //!< YUV 4:2:0/8 "Baseline" 84 MAIN = 77, //!< YUV 4:2:0/8 "Main" 85 EXTENDED = 88, //!< YUV 4:2:0/8 "Extended" 86 FREXT_HP = 100, //!< YUV 4:2:0/8 "High" 87 FREXT_Hi10P = 110, //!< YUV 4:2:0/10 "High 10" 88 FREXT_Hi422 = 122, //!< YUV 4:2:2/10 "High 4:2:2" 89 FREXT_Hi444 = 244, //!< YUV 4:4:4/14 "High 4:4:4" 90 MULTIVIEW_HIGH = 118, //!< YUV 4:2:0/8 "Multiview High" 91 STEREO_HIGH = 128 //!< YUV 4:2:0/8 "Stereo High" 92 } ProfileIDC; 93 94 // Some typedefs used in the software 95 #include "types.h" 96 97 #define FILE_NAME_SIZE 255 98 #define INPUT_TEXT_SIZE 1024 99 100 #define CAVLC_LEVEL_LIMIT 2063 101 102 #if (ENABLE_HIGH444_CTX == 1) 103 # define NUM_BLOCK_TYPES 22 104 #else 105 # define NUM_BLOCK_TYPES 10 106 #endif 107 108 #define _LEAKYBUCKET_ 109 110 // --------------------------------------------------------------------------------- 111 // FLAGS and DEFINES for new chroma intra prediction, Dzung Hoang 112 // Threshold values to zero out quantized transform coefficients. 113 // Recommend that _CHROMA_COEFF_COST_ be low to improve chroma quality 114 #define _LUMA_COEFF_COST_ 4 //!< threshold for luma coeffs 115 #define _CHROMA_COEFF_COST_ 4 //!< threshold for chroma coeffs, used to be 7 116 #define _LUMA_MB_COEFF_COST_ 5 //!< threshold for luma coeffs of inter Macroblocks 117 #define _LUMA_8x8_COEFF_COST_ 5 //!< threshold for luma coeffs of 8x8 Inter Partition 118 119 //#define IMG_PAD_SIZE 20 //!< Number of pixels padded around the reference frame (>=4) 120 //#define IMG_PAD_SIZE_TIMES4 80 //!< Number of pixels padded around the reference frame in subpel units(>=16) 121 #define IMG_PAD_SIZE_X 32 //!< Number of pixels padded around the reference frame (>=4) 122 #define IMG_PAD_SIZE_Y 20 //!< Number of pixels padded around the reference frame (>=4) 123 124 #define MAX_VALUE 999999 //!< used for start value for some variables 125 #define INVALIDINDEX (-135792468) 126 127 #define DUMMY 14 128 #define ET_SIZE 300 //!< size of error text buffer 129 130 #define LAMBDA_ACCURACY_BITS 5 131 #define LAMBDA_FACTOR(lambda) ((int)((double)(1 << LAMBDA_ACCURACY_BITS) * lambda + 0.5)) 132 133 #if (IMGTYPE == 0) 134 #define DISTBLK_MAX INT_MAX 135 #else 136 #define DISTBLK_MAX ((distblk) INT_MAX << LAMBDA_ACCURACY_BITS) 137 #endif 138 139 #define MAXSLICEPERPICTURE 100 140 #define MAX_REFERENCE_PICTURES 32 141 142 #define BLOCK_SHIFT 2 143 #define BLOCK_SIZE 4 144 #define BLOCK_SIZE_8x8 8 145 #define SMB_BLOCK_SIZE 8 146 #define BLOCK_PIXELS 16 147 #define MB_BLOCK_SIZE 16 148 #define MB_PIXELS 256 // MB_BLOCK_SIZE * MB_BLOCK_SIZE 149 #define MB_PIXELS_SHIFT 8 // log2(MB_BLOCK_SIZE * MB_BLOCK_SIZE) 150 #define MB_BLOCK_SHIFT 4 151 #define BLOCK_MULTIPLE 4 // (MB_BLOCK_SIZE/BLOCK_SIZE) 152 #define MB_BLOCK_PARTITIONS 16 // (BLOCK_MULTIPLE * BLOCK_MULTIPLE) 153 #define BLOCK_CONTEXT 64 // (4 * MB_BLOCK_PARTITIONS) 154 // These variables relate to the subpel accuracy supported by the software (1/4) 155 #define BLOCK_SIZE_SP 16 // BLOCK_SIZE << 2 156 #define BLOCK_SIZE_8x8_SP 32 // BLOCK_SIZE8x8 << 2 157 158 // wavelet based weighted PSNR wavelet levels 159 #define NUM_WAVELET_LEVEL 4 160 161 // RDOQ 162 #define MAX_PREC_COEFF 25 163 164 165 166 // Available MB modes 167 extern enum { 168 PSKIP = 0, 169 BSKIP_DIRECT = 0, 170 P16x16 = 1, 171 P16x8 = 2, 172 P8x16 = 3, 173 SMB8x8 = 4, 174 SMB8x4 = 5, 175 SMB4x8 = 6, 176 SMB4x4 = 7, 177 P8x8 = 8, 178 I4MB = 9, 179 I16MB = 10, 180 IBLOCK = 11, 181 SI4MB = 12, 182 I8MB = 13, 183 IPCM = 14, 184 MAXMODE = 15 185 } MBModeTypes; 186 187 // number of intra prediction modes 188 #define NO_INTRA_PMODE 9 189 190 // Direct Mode types 191 extern enum { 192 DIR_TEMPORAL = 0, //!< Temporal Direct Mode 193 DIR_SPATIAL = 1 //!< Spatial Direct Mode 194 } DirectModes; 195 196 // CAVLC block types 197 extern enum { 198 LUMA = 0, 199 LUMA_INTRA16x16DC = 1, 200 LUMA_INTRA16x16AC = 2, 201 CB = 3, 202 CB_INTRA16x16DC = 4, 203 CB_INTRA16x16AC = 5, 204 CR = 8, 205 CR_INTRA16x16DC = 9, 206 CR_INTRA16x16AC = 10 207 } CAVLCBlockTypes; 208 209 // CABAC block types 210 extern enum { 211 LUMA_16DC = 0, 212 LUMA_16AC = 1, 213 LUMA_8x8 = 2, 214 LUMA_8x4 = 3, 215 LUMA_4x8 = 4, 216 LUMA_4x4 = 5, 217 CHROMA_DC = 6, 218 CHROMA_AC = 7, 219 CHROMA_DC_2x4 = 8, 220 CHROMA_DC_4x4 = 9, 221 CB_16DC = 10, 222 CB_16AC = 11, 223 CB_8x8 = 12, 224 CB_8x4 = 13, 225 CB_4x8 = 14, 226 CB_4x4 = 15, 227 CR_16DC = 16, 228 CR_16AC = 17, 229 CR_8x8 = 18, 230 CR_8x4 = 19, 231 CR_4x8 = 20, 232 CR_4x4 = 21 233 } CABACBlockTypes; 234 235 // Color components 236 typedef enum { 237 Y_COMP = 0, // Y Component 238 U_COMP = 1, // U Component 239 V_COMP = 2, // V Component 240 R_COMP = 3, // R Component 241 G_COMP = 4, // G Component 242 B_COMP = 5, // B Component 243 T_COMP = 6 244 } ColorComponent_t; 245 246 extern ColorComponent_t ColorComponent; 247 248 #define LEVEL_NUM 6 249 #define TOTRUN_NUM 15 250 #define RUNBEFORE_NUM 7 251 #define RUNBEFORE_NUM_M1 6 252 253 // Quantization parameter range 254 #define MIN_QP 0 255 #define MAX_QP 51 256 #define SHIFT_QP 12 257 258 // 4x4 intra prediction modes 259 extern enum { 260 VERT_PRED = 0, 261 HOR_PRED = 1, 262 DC_PRED = 2, 263 DIAG_DOWN_LEFT_PRED = 3, 264 DIAG_DOWN_RIGHT_PRED = 4, 265 VERT_RIGHT_PRED = 5, 266 HOR_DOWN_PRED = 6, 267 VERT_LEFT_PRED = 7, 268 HOR_UP_PRED = 8 269 } I4x4PredModes; 270 271 // 16x16 intra prediction modes 272 extern enum { 273 VERT_PRED_16 = 0, 274 HOR_PRED_16 = 1, 275 DC_PRED_16 = 2, 276 PLANE_16 = 3 277 } I16x16PredModes; 278 279 // 8x8 chroma intra prediction modes 280 extern enum { 281 DC_PRED_8 = 0, 282 HOR_PRED_8 = 1, 283 VERT_PRED_8 = 2, 284 PLANE_8 = 3 285 } I8x8PredModes; 286 287 #define INIT_FRAME_RATE 30 288 enum { 289 EOS = 1, //!< End Of Sequence 290 SOP = 2, //!< Start Of Picture 291 SOS = 3 //!< Start Of Slice 292 }; 293 294 // MV Prediction types 295 extern enum { 296 MVPRED_MEDIAN = 0, 297 MVPRED_L = 1, 298 MVPRED_U = 2, 299 MVPRED_UR = 3 300 } MVPredTypes; 301 302 #define MAX_SYMBOLS_PER_MB 1200 //!< Maximum number of different syntax elements for one MB 303 // CAVLC needs more symbols per MB 304 305 306 #define MAX_PART_NR 3 /*!< Maximum number of different data partitions. 307 Some reasonable number which should reflect 308 what is currently defined in the SE2Partition map (elements.h) */ 309 310 //Start code and Emulation Prevention need this to be defined in identical manner at encoder and decoder 311 #define ZEROBYTES_SHORTSTARTCODE 2 //indicates the number of zero bytes in the short start-code prefix 312 313 #define Q_BITS 15 314 #define DQ_BITS 6 315 316 #define Q_BITS_8 16 317 #define DQ_BITS_8 6 318 319 // Context Adaptive Lagrange Multiplier (CALM) 320 #define CALM_MF_FACTOR_THRESHOLD 512.0 321 322 #define MAX_PLANE 3 323 324 #define MAXSLICEGROUPIDS 8 325 326 327 #define NUM_MB_TYPE_CTX 11 328 #define NUM_B8_TYPE_CTX 9 329 #define NUM_MV_RES_CTX 10 330 #define NUM_REF_NO_CTX 6 331 #define NUM_DELTA_QP_CTX 4 332 #define NUM_MB_AFF_CTX 4 333 334 #define NUM_TRANSFORM_SIZE_CTX 3 335 336 #define NUM_IPR_CTX 2 337 #define NUM_CIPR_CTX 4 338 #define NUM_CBP_CTX 4 339 #define NUM_BCBP_CTX 4 340 #define NUM_MAP_CTX 15 341 #define NUM_LAST_CTX 15 342 #define NUM_ONE_CTX 5 343 #define NUM_ABS_CTX 5 344 345 extern enum // JLT : on-the-fly levels/modes 346 { 347 OTF_L0 = 0, // Disable, interpolate & store all positions 348 OTF_L1 = 1, // Store full pel & interpolated 1/2 pel positions; 1/4 pel positions interpolate on-the-fly 349 OTF_L2 = 2 // Store only full pell positions; 1/2 & 1/4 pel positions interpolate on-the-fly 350 } OTFMode; 351 352 extern enum 353 { 354 OTF_ME = 0, 355 OTF_MC = 1 356 } OTFFunction; 357 358 #if IMGTYPE 359 #if JM_MEM_DISTORTION 360 #pragma message("JM_MEM_DISTORTION must be zero!") 361 #endif 362 #endif 363 364 365 #endif 366 367