Hamsalekha S | 8d3d303 | 2015-03-13 21:24:58 +0530 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2015 The Android Open Source Project |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ***************************************************************************** |
| 18 | * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore |
| 19 | */ |
| 20 | #ifndef _IH264D_DEFS_H_ |
| 21 | #define _IH264D_DEFS_H_ |
| 22 | |
| 23 | /** |
| 24 | ************************************************************************ |
| 25 | * \file ih264d_defs.h |
| 26 | * |
| 27 | * \brief |
| 28 | * Type definitions used in the code |
| 29 | * |
| 30 | * \date |
| 31 | * 19/11/2002 |
| 32 | * |
| 33 | * \author Sriram Sethuraman |
| 34 | * |
| 35 | ************************************************************************ |
| 36 | */ |
| 37 | #define H264_MAX_FRAME_WIDTH 3840 |
| 38 | #define H264_MAX_FRAME_HEIGHT 2160 |
| 39 | |
| 40 | #define H264_MIN_FRAME_WIDTH 16 |
| 41 | #define H264_MIN_FRAME_HEIGHT 16 |
| 42 | |
| 43 | #define IH264DEC_MAX_NAL_UNIT_SIZE 311040 |
| 44 | #define IH264DEC_NUM_ZEROS_IN_START_CODE 2 |
| 45 | #define H264DEC_MEM_ALLOC_SUCCESS 1 |
| 46 | #define H264DEC_MEM_ALLOC_FAILURE 0 |
| 47 | #define H264DEC_CREATE_FAILED (NULL) |
| 48 | |
| 49 | #define H264_NO_BUF_TO_DISPLAY -1 |
| 50 | #define H264_DISPLAY_BUF_FOUND 0 |
| 51 | #define IH264DEC_YUV420 0 |
| 52 | #define IH264DEC_YUV422 1 |
| 53 | #define IH264DEC_YUV422INTERLACED 2 |
| 54 | #define IH264DEC_RGB 4 // Original Size |
| 55 | /* Ceiling of variables to the nearest power of 2 */ |
| 56 | #define FILL_POWEROF2(x,y) (size_t)(((x) & ((1<<(y))-1))?((1<<(y)) - ((x) & ((1<<(y))-1))): 0) |
| 57 | #define ALIGN_POWEROF2(x,y) (x) = (x)+FILL_POWEROF2((size_t)(x),y) |
| 58 | |
| 59 | /** Bit manipulation macros */ |
| 60 | #define CHECKBIT(a,i) ((a) & (1 << i)) |
| 61 | #define CLEARBIT(a,i) ((a) &= ~(1 << i)) |
| 62 | |
| 63 | /** Macro to convert a integer to a boolean value */ |
| 64 | #define BOOLEAN(x) (!!(x)) |
| 65 | |
| 66 | /** Arithmetic operations */ |
| 67 | #define MOD(x,y) ((x)%(y)) |
| 68 | #define DIV(x,y) ((x)/(y)) |
| 69 | #define MUL(x,y) ((x)*(y)) |
| 70 | #define SIGN_POW2_DIV(x, y) (((x) < 0) ? (-((-(x)) >> (y))) : ((x) >> (y))) |
| 71 | |
| 72 | #define MB_ENABLE_FILTERING 0x00 |
| 73 | #define MB_DISABLE_FILTERING 0x01 |
| 74 | #define MB_DISABLE_TOP_EDGE 0x02 |
| 75 | #define MB_DISABLE_LEFT_EDGE 0x04 |
| 76 | |
| 77 | /** Maximum number of reference pics */ |
| 78 | #define MAX_REF_BUFS 32 |
| 79 | #define MAX_DISP_BUFS_NEW 64 |
| 80 | #define MAX_FRAMES 16 |
| 81 | #define MAX_MBS_IN_ROW (720/16) |
| 82 | #define INVALID_FRAME_NUM 0x0fffffff |
| 83 | #define GAP_FRAME_NUM 0x1fffffff |
| 84 | #define MAX_PIC_SIZE 622080 // 720 * 576 * 1.5 |
| 85 | /** macros for reference picture lists, refIdx to POC mapping */ |
| 86 | // 1 extra entry into reference picture lists for refIdx = -1. |
| 87 | // this entry is always 0. this saves conditional checks in |
| 88 | // FillBs modules. |
| 89 | #define POC_LIST_L0_TO_L1_DIFF (( 2*MAX_FRAMES) + 1) |
| 90 | #define POC_LIST_L0_TO_L1_DIFF_1 ((MAX_FRAMES) + 1) |
| 91 | |
| 92 | #define FRM_LIST_L0 0 //0 |
| 93 | #define FRM_LIST_L1 1 * POC_LIST_L0_TO_L1_DIFF//FRM_LIST_L0 + POC_LIST_L0_TO_L1_DIFF //0+33 //(1 * POC_LIST_L0_TO_L1_DIFF) |
| 94 | #define TOP_LIST_FLD_L0 2 * POC_LIST_L0_TO_L1_DIFF//FRM_LIST_L1 + POC_LIST_L0_TO_L1_DIFF //0+33+33 //(2 * POC_LIST_L0_TO_L1_DIFF) |
| 95 | #define TOP_LIST_FLD_L1 3 * POC_LIST_L0_TO_L1_DIFF//TOP_LIST_FLD_L0 + POC_LIST_L0_TO_L1_DIFF_1 //0+33+33+17 //(3 * POC_LIST_L0_TO_L1_DIFF) |
| 96 | #define BOT_LIST_FLD_L0 4 * POC_LIST_L0_TO_L1_DIFF//TOP_LIST_FLD_L1 + POC_LIST_L0_TO_L1_DIFF_1 //0+33+33+17+17 |
| 97 | #define BOT_LIST_FLD_L1 5 * POC_LIST_L0_TO_L1_DIFF//BOT_LIST_FLD_L0 + POC_LIST_L0_TO_L1_DIFF_1 //0+33+33+17+17+17 |
| 98 | #define TOTAL_LIST_ENTRIES 6 * POC_LIST_L0_TO_L1_DIFF//BOT_LIST_FLD_L1 + POC_LIST_L0_TO_L1_DIFF_1 //0+33+33+17+17+17+17 |
| 99 | #define PAD_MV_BANK_ROW 64 |
| 100 | #define OFFSET_MV_BANK_ROW ((PAD_MV_BANK_ROW)>>1) |
| 101 | #define PAD_PUC_CURNNZ 32 |
| 102 | #define OFFSET_PUC_CURNNZ (PAD_PUC_CURNNZ) |
| 103 | #define PAD_MAP_IDX_POC (1) |
| 104 | #define OFFSET_MAP_IDX_POC (1) |
| 105 | |
| 106 | #define OFFSET_MAP_IDX_POC (1) |
| 107 | |
| 108 | #define NAL_REF_IDC(nal_first_byte) ((nal_first_byte >> 5) & 0x3) |
| 109 | #define NAL_FORBIDDEN_BIT(nal_first_byte) (nal_first_byte>>7) |
| 110 | #define NAL_UNIT_TYPE(nal_first_byte) (nal_first_byte & 0x1F) |
| 111 | |
| 112 | #define INT_PIC_TYPE_I (0x00) |
| 113 | |
| 114 | #define YIELD_CNT_THRESHOLD 8 |
| 115 | #define ENABLE_420P_UV_SHARING 1 |
| 116 | |
| 117 | #define OK 0 |
| 118 | #define END 1 |
| 119 | #define NOT_OK -1 |
| 120 | |
| 121 | /* For 420SP */ |
| 122 | #define YUV420SP_FACTOR 2 |
| 123 | |
| 124 | |
| 125 | /** |
| 126 | *************************************************************************** |
| 127 | * Enum to hold various mem records being request |
| 128 | **************************************************************************** |
| 129 | */ |
| 130 | enum |
| 131 | { |
| 132 | /** |
| 133 | * Codec Object at API level |
| 134 | */ |
| 135 | MEM_REC_IV_OBJ, |
| 136 | |
| 137 | /** |
| 138 | * Codec context |
| 139 | */ |
| 140 | MEM_REC_CODEC, |
| 141 | |
| 142 | /** |
| 143 | * Bitstream buffer which holds emulation prevention removed bytes |
| 144 | */ |
| 145 | MEM_REC_BITSBUF, |
| 146 | |
| 147 | /** |
| 148 | * Buffer to hold coeff data |
| 149 | */ |
| 150 | MEM_REC_COEFF_DATA, |
| 151 | |
| 152 | /** |
| 153 | * Motion vector bank |
| 154 | */ |
| 155 | MEM_REC_MVBANK, |
| 156 | |
| 157 | /** |
| 158 | * Holds mem records passed to the codec. |
| 159 | */ |
| 160 | MEM_REC_BACKUP, |
| 161 | |
| 162 | /** |
| 163 | * Holds SPS |
| 164 | */ |
| 165 | MEM_REC_SPS, |
| 166 | |
| 167 | /** |
| 168 | * Holds PPS |
| 169 | */ |
| 170 | MEM_REC_PPS, |
| 171 | |
| 172 | /** |
| 173 | * Holds Slice Headers |
| 174 | */ |
| 175 | MEM_REC_SLICE_HDR, |
| 176 | |
| 177 | /** |
| 178 | * Holds thread handles |
| 179 | */ |
| 180 | MEM_REC_THREAD_HANDLE, |
| 181 | |
| 182 | /** |
| 183 | * Contains i4_status map indicating parse i4_status per MB basis |
| 184 | */ |
| 185 | MEM_REC_PARSE_MAP, |
| 186 | |
| 187 | /** |
| 188 | * Contains i4_status map indicating processing i4_status per MB basis |
| 189 | */ |
| 190 | MEM_REC_PROC_MAP, |
| 191 | |
| 192 | /** |
| 193 | * Contains slice number info for each MB |
| 194 | */ |
| 195 | |
| 196 | MEM_REC_SLICE_NUM_MAP, |
| 197 | |
| 198 | /** |
| 199 | * Holds dpb manager context |
| 200 | */ |
| 201 | MEM_REC_DPB_MGR, |
| 202 | |
| 203 | /** |
| 204 | * Holds neighbors' info |
| 205 | */ |
| 206 | MEM_REC_NEIGHBOR_INFO, |
| 207 | |
| 208 | /** |
| 209 | * Holds neighbors' info |
| 210 | */ |
| 211 | MEM_REC_PRED_INFO, |
| 212 | |
| 213 | |
| 214 | /** |
| 215 | * Holds inter pred inforamation on packed format info |
| 216 | */ |
| 217 | MEM_REC_PRED_INFO_PKD, |
| 218 | /** |
| 219 | * Holds neighbors' info |
| 220 | */ |
| 221 | MEM_REC_MB_INFO, |
| 222 | |
| 223 | /** |
| 224 | * Holds deblock Mb info structure frame level) |
| 225 | */ |
| 226 | MEM_REC_DEBLK_MB_INFO, |
| 227 | |
| 228 | /** |
| 229 | * Holds reference picture buffers in non-shared mode |
| 230 | */ |
| 231 | MEM_REC_REF_PIC, |
| 232 | |
| 233 | /** |
| 234 | * Holds some misc intermediate_buffers |
| 235 | */ |
| 236 | MEM_REC_EXTRA_MEM, |
| 237 | |
| 238 | /** |
| 239 | * Holds some misc intermediate_buffers |
| 240 | */ |
| 241 | MEM_REC_INTERNAL_SCRATCH, |
| 242 | |
| 243 | /** |
| 244 | * Holds some misc intermediate_buffers |
| 245 | */ |
| 246 | MEM_REC_INTERNAL_PERSIST, |
| 247 | |
| 248 | /* holds structures related to picture buffer manager*/ |
| 249 | MEM_REC_PIC_BUF_MGR, |
| 250 | |
| 251 | /*holds structure related to MV buffer manager*/ |
| 252 | MEM_REC_MV_BUF_MGR, |
| 253 | |
| 254 | /** |
| 255 | * Place holder to compute number of memory records. |
| 256 | */ |
| 257 | MEM_REC_CNT |
| 258 | /* Do not add anything below */ |
| 259 | }; |
| 260 | |
| 261 | #ifdef DEBLOCK_THREAD |
| 262 | #define H264_MUTEX_LOCK(lock) ithread_mutex_lock(lock) |
| 263 | #define H264_MUTEX_UNLOCK(lock) ithread_mutex_unlock(lock) |
| 264 | #else //DEBLOCK_THREAD |
| 265 | #define H264_MUTEX_LOCK(lock) |
| 266 | #define H264_MUTEX_UNLOCK(lock) |
| 267 | |
| 268 | #define DEBUG_THREADS_PRINTF(...) |
| 269 | #define DEBUG_PERF_PRINTF(...) |
| 270 | |
| 271 | /** Profile Types*/ |
| 272 | #define BASE_PROFILE_IDC 66 |
| 273 | #define MAIN_PROFILE_IDC 77 |
| 274 | #define HIGH_PROFILE_IDC 100 |
| 275 | #define MAIN_PROFILE 1 |
| 276 | |
| 277 | #define MB_SIZE 16 |
| 278 | #define BLK8x8SIZE 8 |
| 279 | #define BLK_SIZE 4 |
| 280 | #define NUM_BLKS_PER_MB 24 |
| 281 | #define NUM_LUM_BLKS_PER_MB 16 |
| 282 | #define LUM_BLK 0 |
| 283 | #define CHROM_BLK 1 |
| 284 | #define NUM_PELS_IN_MB 64 |
| 285 | |
| 286 | /* Level Types */ |
| 287 | #define H264_LEVEL_1_0 10 |
| 288 | #define H264_LEVEL_1_1 11 |
| 289 | #define H264_LEVEL_1_2 12 |
| 290 | #define H264_LEVEL_1_3 13 |
| 291 | #define H264_LEVEL_2_0 20 |
| 292 | #define H264_LEVEL_2_1 21 |
| 293 | #define H264_LEVEL_2_2 22 |
| 294 | #define H264_LEVEL_3_0 30 |
| 295 | #define H264_LEVEL_3_1 31 |
| 296 | #define H264_LEVEL_3_2 32 |
| 297 | #define H264_LEVEL_4_0 40 |
| 298 | #define H264_LEVEL_4_1 41 |
| 299 | #define H264_LEVEL_4_2 42 |
| 300 | #define H264_LEVEL_5_0 50 |
| 301 | #define H264_LEVEL_5_1 51 |
| 302 | |
| 303 | #define MAX_MBS_LEVEL_51 36864 |
| 304 | #define MAX_MBS_LEVEL_50 22080 |
| 305 | #define MAX_MBS_LEVEL_42 8704 |
| 306 | #define MAX_MBS_LEVEL_41 8192 |
| 307 | #define MAX_MBS_LEVEL_40 8192 |
| 308 | #define MAX_MBS_LEVEL_32 5120 |
| 309 | #define MAX_MBS_LEVEL_31 3600 |
| 310 | #define MAX_MBS_LEVEL_30 1620 |
| 311 | #define MAX_MBS_LEVEL_22 1620 |
| 312 | #define MAX_MBS_LEVEL_21 792 |
| 313 | #define MAX_MBS_LEVEL_20 396 |
| 314 | #define MAX_MBS_LEVEL_13 396 |
| 315 | #define MAX_MBS_LEVEL_12 396 |
| 316 | #define MAX_MBS_LEVEL_11 396 |
| 317 | #define MAX_MBS_LEVEL_10 99 |
| 318 | |
| 319 | |
| 320 | /* |
| 321 | | Legend: |
| 322 | | LVL Level*10 |
| 323 | | MPR Macroblk processing rate |
| 324 | | MMF Max Mbs/Frm |
| 325 | | MDK Max DbpSize (in kB) |
| 326 | | MDB max DbpSize (in bytes) |
| 327 | | MFS FrmSizeYUV (in bytes) |
| 328 | | MDP Max DBPics |
| 329 | | MDC Ceiling DBPics |
| 330 | | FPS Frame/Second |
| 331 | | |
| 332 | | LVL MPR MMF MDK MDB MFS MDP MDC FPS |
| 333 | | 10 1485 99 148.5 152064 38016 4.00 4.00 15.00 |
| 334 | | 11 3000 396 337.5 345600 152064 2.27 3.00 7.58 |
| 335 | | 12 6000 396 891 912384 152064 6.00 6.00 15.15 |
| 336 | | 13 11880 396 891 912384 152064 6.00 6.00 30.00 |
| 337 | | 20 11880 396 891 912384 152064 6.00 6.00 30.00 |
| 338 | | 21 19800 792 1782 1824768 304128 6.00 6.00 25.00 |
| 339 | | 22 20250 1620 3037.5 3110400 622080 5.00 5.00 12.50 |
| 340 | | 30 40500 1620 3037.5 3110400 622080 5.00 5.00 25.00 |
| 341 | */ |
| 342 | #define MAX_REF_LEVEL_1_0 4 |
| 343 | #define MAX_REF_LEVEL_1_1 3 |
| 344 | #define MAX_REF_LEVEL_1_2 6 |
| 345 | #define MAX_REF_LEVEL_1_3 6 |
| 346 | #define MAX_REF_LEVEL_2_0 6 |
| 347 | #define MAX_REF_LEVEL_2_1 6 |
| 348 | #define MAX_REF_LEVEL_2_2 5 |
| 349 | #define MAX_REF_LEVEL_3_0 5 |
| 350 | #define H264_MAX_REF_PICS 16 |
| 351 | |
| 352 | #define MIN_LEVEL_SUPPORTED 10 |
| 353 | #define MAX_LEVEL_SUPPORTED 64 |
| 354 | |
| 355 | /** NAL Types */ |
| 356 | #define SLICE_NAL 1 |
| 357 | #define SLICE_DATA_PARTITION_A_NAL 2 |
| 358 | #define SLICE_DATA_PARTITION_B_NAL 3 |
| 359 | #define SLICE_DATA_PARTITION_C_NAL 4 |
| 360 | #define IDR_SLICE_NAL 5 |
| 361 | #define SEI_NAL 6 |
| 362 | #define SEQ_PARAM_NAL 7 |
| 363 | #define PIC_PARAM_NAL 8 |
| 364 | #define ACCESS_UNIT_DELIMITER_RBSP 9 |
| 365 | #define END_OF_SEQ_RBSP 10 |
| 366 | #define END_OF_STREAM_RBSP 11 |
| 367 | #define FILLER_DATA_NAL 12 |
| 368 | |
| 369 | /** Entropy coding modes */ |
| 370 | #define CAVLC 0 |
| 371 | #define CABAC 1 |
| 372 | |
| 373 | /** Picture Types */ |
| 374 | #define I_PIC 0 |
| 375 | #define IP_PIC 1 |
| 376 | #define IPB_PIC 2 |
| 377 | #define SI_PIC 3 |
| 378 | #define SIP_PIC 4 |
| 379 | #define ISI_PIC 5 |
| 380 | #define ISI_PSP_PIC 6 |
| 381 | #define ALL_PIC 7 |
| 382 | |
| 383 | /* Frame or field picture type */ |
| 384 | #define FRM_PIC 0x00 |
| 385 | #define TOP_FLD 0x01 |
| 386 | #define BOT_FLD 0x02 |
| 387 | #define COMP_FLD_PAIR 0x03 /* TOP_FLD | BOT_FLD */ |
| 388 | #define AFRM_PIC 0x04 |
| 389 | #define TOP_REF 0x08 |
| 390 | #define BOT_REF 0x10 |
| 391 | #define PIC_MASK 0x03 |
| 392 | #define NON_EXISTING 0xff |
| 393 | |
| 394 | /* field picture type for display */ |
| 395 | #define DISP_TOP_FLD 0x00 |
| 396 | #define DISP_BOT_FLD 0x01 |
| 397 | |
| 398 | /** Slice Types */ |
| 399 | #define P_SLICE 0 |
| 400 | #define B_SLICE 1 |
| 401 | #define I_SLICE 2 |
| 402 | #define SP_SLICE 3 |
| 403 | #define SI_SLICE 4 |
| 404 | |
| 405 | /* Definition for picture skip */ |
| 406 | #define SKIP_NONE (0x0) |
| 407 | #define I_SLC_BIT (0x1) |
| 408 | #define P_SLC_BIT (0x2) |
| 409 | #define B_SLC_BIT (0x4) |
| 410 | |
| 411 | /** Macros used for Deblocking */ |
| 412 | #define D_INTER_MB 0 |
| 413 | #define D_INTRA_MB 1 |
| 414 | #define D_PRED_NON_16x16 2 |
| 415 | #define D_B_SLICE 4 |
| 416 | #define D_B_SUBMB 6 //D_B_SLICE | D_PRED_NON_16x16 | D_INTER_MB |
| 417 | #define D_FLD_MB 0x80 |
| 418 | |
| 419 | /** Macros for Cabac checks */ |
| 420 | /** MbType */ |
| 421 | /** |x|x|I_PCM|SKIP| |
| 422 | |S|Inter/Intra|P/B|NON-BD16x16/BD16x16,I16x16/I4x4| */ |
| 423 | #define CAB_INTRA 0x00 /* 0000 00xx */ |
| 424 | #define CAB_INTER 0x04 /* 0000 01xx */ |
| 425 | #define CAB_I4x4 0x00 /* 0000 00x0 */ |
| 426 | #define CAB_I16x16 0x01 /* 0000 00x1 */ |
| 427 | #define CAB_BD16x16 0x04 /* 0000 0100 */ |
| 428 | #define CAB_NON_BD16x16 0x05 /* 0000 0101 */ |
| 429 | #define CAB_P 0x07 /* 0000 0111 */ |
| 430 | #define CAB_SI4x4 0x08 /* 0000 10x0 */ |
| 431 | #define CAB_SI16x16 0x09 /* 0000 10x1 */ |
| 432 | #define CAB_SKIP_MASK 0x10 /* 0001 0000 */ |
| 433 | #define CAB_SKIP 0x10 /* 0001 0000 */ |
| 434 | #define CAB_P_SKIP 0x16 /* 0001 x11x */ |
| 435 | #define CAB_B_SKIP 0x14 /* 0001 x100 */ |
| 436 | #define CAB_BD16x16_MASK 0x07 /* 0000 0111 */ |
| 437 | #define CAB_INTRA_MASK 0x04 /* 0000 0100 */ |
| 438 | #define CAB_I_PCM 0x20 /* 001x xxxx */ |
| 439 | |
| 440 | /**< Binarization types for CABAC */ |
| 441 | /* |x|x|x|x|MSB_FIRST_FLC|FLC|TUNARY|UNARY| */ |
| 442 | #define UNARY 1 |
| 443 | #define TUNARY 2 |
| 444 | #define FLC 4 |
| 445 | #define MSB_FIRST_FLC 12 |
| 446 | |
| 447 | /** Macroblock Types */ |
| 448 | #define I_4x4_MB 0 |
| 449 | #define I_16x16_MB 1 |
| 450 | #define P_MB 2 |
| 451 | #define B_MB 3 |
| 452 | #define SI_MB 4 |
| 453 | #define SP_MB 5 |
| 454 | #define I_PCM_MB 6 |
| 455 | |
| 456 | #define SI4x4_MB 0xFF |
| 457 | |
| 458 | /** Intra luma 16x16 and chroma 8x8 prediction modes */ |
| 459 | #define NUM_INTRA_PRED_MODES 4 |
| 460 | #define VERT 0 |
| 461 | #define HORIZ 1 |
| 462 | #define DC 2 |
| 463 | #define PLANE 3 |
| 464 | #define NOT_VALID -1 |
| 465 | #define DC_DC_DC_DC 0x02020202 /*packed 4 bytes used in Decode Intra Mb*/ |
| 466 | |
| 467 | /** Intra luma 4x4 prediction modes */ |
| 468 | #define NUM_INTRA4x4_PRED_MODES 9 |
| 469 | |
| 470 | /** VERT, HORIZ, DC are applicable to 4x4 as well */ |
| 471 | /** D - Down; U - Up; L - Left; R - Right */ |
| 472 | #define DIAG_DL 3 |
| 473 | #define DIAG_DR 4 |
| 474 | #define VERT_R 5 |
| 475 | #define HORIZ_D 6 |
| 476 | #define VERT_L 7 |
| 477 | #define HORIZ_U 8 |
| 478 | |
| 479 | /** P_MB prediction modes */ |
| 480 | #define NUM_INTER_MB_PRED_MODES 5 |
| 481 | #define PRED_16x16 0 |
| 482 | #define PRED_16x8 1 |
| 483 | #define PRED_8x16 2 |
| 484 | #define PRED_8x8 3 |
| 485 | #define PRED_8x8R0 4 |
| 486 | #define MAGIC_16x16 5 |
| 487 | #define MB_SKIP 255 |
| 488 | |
| 489 | /* P_MB submb modes */ |
| 490 | #define P_L0_8x8 0 |
| 491 | #define P_L0_8x4 1 |
| 492 | #define P_L0_4x8 2 |
| 493 | #define P_L0_4x4 3 |
| 494 | |
| 495 | /* B_MB submb modes */ |
| 496 | #define B_DIRECT_8x8 0 |
| 497 | #define B_L0_8x8 1 |
| 498 | #define B_L1_8x8 2 |
| 499 | #define B_BI_8x8 3 |
| 500 | #define B_L0_8x4 4 |
| 501 | #define B_L0_4x8 5 |
| 502 | #define B_L1_8x4 6 |
| 503 | #define B_L1_4x8 7 |
| 504 | #define B_BI_8x4 8 |
| 505 | #define B_BI_4x8 9 |
| 506 | #define B_L0_4x4 10 |
| 507 | #define B_L1_4x4 11 |
| 508 | #define B_BI_4x4 12 |
| 509 | |
| 510 | /** B_MB prediction modes */ |
| 511 | #define B_8x8 22 |
| 512 | #define PRED_INVALID -1 |
| 513 | #define B_DIRECT 0 |
| 514 | #define PRED_L0 1 |
| 515 | #define PRED_L1 2 |
| 516 | #define BI_PRED 3 |
| 517 | #define B_DIRECT_BI_PRED 23 |
| 518 | #define B_DIRECT_PRED_L0 24 |
| 519 | #define B_DIRECT_PRED_L1 25 |
| 520 | #define B_DIRECT_SPATIAL 26 |
| 521 | |
| 522 | #define B_DIRECT8x8_BI_PRED 13 |
| 523 | #define B_DIRECT8x8_PRED_L0 14 |
| 524 | #define B_DIRECT8x8_PRED_L1 15 |
| 525 | |
| 526 | #define ONE_TO_ONE 0 |
| 527 | #define FRM_TO_FLD 1 |
| 528 | #define FLD_TO_FRM 2 |
| 529 | |
| 530 | /** Inter Sub MB Pred modes */ |
| 531 | #define NUM_INTER_SUBMB_PRED_MODES 4 |
| 532 | #define SUBMB_8x8 0 |
| 533 | #define SUBMB_8x4 1 |
| 534 | #define SUBMB_4x8 2 |
| 535 | #define SUBMB_4x4 3 |
| 536 | |
| 537 | /** Coded Block Pattern - Chroma */ |
| 538 | #define CBPC_ALLZERO 0 |
| 539 | #define CBPC_ACZERO 1 |
| 540 | #define CBPC_NONZERO 2 |
| 541 | |
| 542 | /** Index for accessing the left MB in the MV predictor array */ |
| 543 | #define LEFT 0 |
| 544 | /** Index for accessing the top MB in the MV predictor array */ |
| 545 | #define TOP 1 |
| 546 | /** Index for accessing the top right MB in the MV predictor array */ |
| 547 | #define TOP_R 2 |
| 548 | /** Index for accessing the top Left MB in the MV predictor array */ |
| 549 | #define TOP_L 3 |
| 550 | |
| 551 | /** Maximum number of Sequence Parameter sets */ |
| 552 | #define MAX_NUM_SEQ_PARAMS 32 |
| 553 | |
| 554 | /** Maximum number of Picture Parameter sets */ |
| 555 | #define MAX_NUM_PIC_PARAMS 256 |
| 556 | |
| 557 | #define MASK_ERR_SEQ_SET_ID (0xFFFFFFE0) |
| 558 | #define MASK_ERR_PIC_SET_ID (0xFFFFFF00) |
| 559 | |
| 560 | #define MAX_PIC_ORDER_CNT_TYPE 2 |
| 561 | |
| 562 | #define MAX_BITS_IN_FRAME_NUM 16 |
| 563 | #define MAX_BITS_IN_POC_LSB 16 |
| 564 | |
| 565 | #define H264_MAX_REF_PICS 16 |
| 566 | #define H264_MAX_REF_IDX 32 |
| 567 | #define MAX_WEIGHT_BIPRED_IDC 2 |
| 568 | #define MAX_CABAC_INIT_IDC 2 |
| 569 | |
| 570 | #define H264_DEFAULT_NUM_CORES 1 |
| 571 | #define DEFAULT_SEPARATE_PARSE (H264_DEFAULT_NUM_CORES == 2)? 1 :0 |
| 572 | |
| 573 | /** Maximum number of Slice groups */ |
| 574 | #define MAX_NUM_SLICE_GROUPS 8 |
| 575 | #define MAX_NUM_REF_FRAMES_OFFSET 255 |
| 576 | |
| 577 | /** Deblocking modes for a slice */ |
| 578 | #define SLICE_BOUNDARY_DBLK_DISABLED 2 |
| 579 | #define DBLK_DISABLED 1 |
| 580 | #define DBLK_ENABLED 0 |
| 581 | #define MIN_DBLK_FIL_OFF -12 |
| 582 | #define MAX_DBLK_FIL_OFF 12 |
| 583 | |
| 584 | /** Width of the predictor buffers used for MC */ |
| 585 | #define MB_SIZE 16 |
| 586 | #define BLK8x8SIZE 8 |
| 587 | #define BLK_SIZE 4 |
| 588 | #define NUM_BLKS_PER_MB 24 |
| 589 | #define NUM_LUM_BLKS_PER_MB 16 |
| 590 | |
| 591 | #define SUB_BLK_WIDTH 4 |
| 592 | #define SUB_SUB_BLK_SIZE 4 /* 2x2 pixel i4_size */ |
| 593 | #define SUB_BLK_SIZE ((SUB_BLK_WIDTH) * (SUB_BLK_WIDTH)) |
| 594 | #define MB_LUM_SIZE 256 |
| 595 | #define MB_CHROM_SIZE 64 |
| 596 | |
| 597 | /**< Width to pad the luminance frame buff */ |
| 598 | /**< Height to pad the luminance frame buff */ |
| 599 | /**< Width to pad the chrominance frame buff */ |
| 600 | /**< Height to pad the chrominance frame buff */ |
| 601 | |
| 602 | #define PAD_LEN_Y_H 32 |
| 603 | #define PAD_LEN_Y_V 20 |
| 604 | #define PAD_LEN_UV_H 16 |
| 605 | #define PAD_LEN_UV_V 8 |
| 606 | |
| 607 | #define PAD_MV_BANK_ROW 64 |
| 608 | |
| 609 | /**< Maimum u4_ofst by which the Mvs could point outside the frame buffers |
| 610 | horizontally in the left and vertically in the top direction */ |
| 611 | #define MAX_OFFSET_OUTSIDE_X_FRM -20 |
| 612 | #define MAX_OFFSET_OUTSIDE_Y_FRM -20 |
| 613 | #define MAX_OFFSET_OUTSIDE_UV_FRM -8 |
| 614 | |
| 615 | /** UVLC parsing macros */ |
| 616 | #define UEV 1 |
| 617 | #define SEV 2 |
| 618 | #define TEV 3 |
| 619 | |
| 620 | /** Defines for Boolean values */ |
| 621 | #ifndef TRUE |
| 622 | #define TRUE 1 |
| 623 | #define FALSE 0 |
| 624 | #endif |
| 625 | |
| 626 | #define UNUSED_FOR_REF 0 |
| 627 | #define IS_SHORT_TERM 1 |
| 628 | #define IS_LONG_TERM 2 |
| 629 | |
| 630 | /** Defines for which field gets displayed first */ |
| 631 | #define MAX_FRAMES 16 |
| 632 | #define INVALID_FRAME_NUM 0x0fffffff |
| 633 | #define DO_NOT_DISP 254 |
| 634 | #define DISP_FLD_FIRST_UNDEF 0 |
| 635 | #define DISP_TOP_FLD_FIRST 1 |
| 636 | #define DISP_BOT_FLD_FIRST 2 |
| 637 | |
| 638 | /** Misc error resilience requirements*/ |
| 639 | #define MASK_LOG2_WEIGHT_DENOM 0xFFFFFFF8 |
| 640 | #define MASK_PRED_WEIGHT_OFFSET 0xFFFFFF00 |
| 641 | #define MAX_REDUNDANT_PIC_CNT 127 |
| 642 | |
| 643 | #define DPB_HACK 0 |
| 644 | #define DPB_HACK_NEW 0 |
| 645 | |
| 646 | |
| 647 | |
| 648 | #define PD_MB_BUF_SIZE (H264_MAX_FRAME_WIDTH * H264_MAX_FRAME_WIDTH / 256) |
| 649 | #define PD_MB_BUF_SIZE_MOD 0xffffffff |
| 650 | #define MAX_PRED_INFO_LIMIT (PD_MB_BUF_SIZE * 32 * 2) |
| 651 | |
| 652 | #endif //DEBLOCK_THREAD |
| 653 | |
| 654 | |
| 655 | #define NO_DC_SB 0 |
| 656 | #define SUB_BLK_MASK 0xFFFFFF00 |
| 657 | #define NUM_COEFFS_IN_4x4BLK 16 |
| 658 | |
| 659 | |
| 660 | #define MEMSET_16BYTES(pu4_start,value) \ |
| 661 | { \ |
| 662 | memset(pu4_start,value,16); \ |
| 663 | } |
| 664 | |
| 665 | #define MEMCPY_16BYTES(dst,src) \ |
| 666 | { \ |
| 667 | memcpy(dst,src,16); \ |
| 668 | } |
| 669 | |
| 670 | |
| 671 | #endif /*_IH264D_DEFS_H_*/ |