| 1 | /***************************************************************************** |
| 2 | * Copyright (C) 2014 x265 project |
| 3 | * |
| 4 | * Authors: Steve Borho <steve@borho.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. |
| 19 | * |
| 20 | * This program is also available under a commercial proprietary license. |
| 21 | * For more information, contact us at license @ x265.com. |
| 22 | *****************************************************************************/ |
| 23 | |
| 24 | #ifndef X265_CONSTANTS_H |
| 25 | #define X265_CONSTANTS_H |
| 26 | |
| 27 | #include "common.h" |
| 28 | |
| 29 | namespace x265 { |
| 30 | // private namespace |
| 31 | |
| 32 | void initROM(); |
| 33 | void destroyROM(); |
| 34 | |
| 35 | void initZscanToRaster(uint32_t maxFullDepth, uint32_t depth, uint32_t startVal, uint32_t*& curIdx); |
| 36 | void initRasterToZscan(uint32_t maxFullDepth); |
| 37 | |
| 38 | extern double x265_lambda_tab[QP_MAX_MAX + 1]; |
| 39 | extern double x265_lambda2_tab[QP_MAX_MAX + 1]; |
| 40 | extern const uint16_t x265_chroma_lambda2_offset_tab[MAX_CHROMA_LAMBDA_OFFSET + 1]; |
| 41 | |
| 42 | enum { ChromaQPMappingTableSize = 70 }; |
| 43 | enum { AngleMapping422TableSize = 36 }; |
| 44 | |
| 45 | extern const uint8_t g_chromaScale[ChromaQPMappingTableSize]; |
| 46 | extern const uint8_t g_chroma422IntraAngleMappingTable[AngleMapping422TableSize]; |
| 47 | |
| 48 | // flexible conversion from relative to absolute index |
| 49 | extern uint32_t g_zscanToRaster[MAX_NUM_PARTITIONS]; |
| 50 | extern uint32_t g_rasterToZscan[MAX_NUM_PARTITIONS]; |
| 51 | |
| 52 | // conversion of partition index to picture pel position |
| 53 | extern const uint8_t g_zscanToPelX[MAX_NUM_PARTITIONS]; |
| 54 | extern const uint8_t g_zscanToPelY[MAX_NUM_PARTITIONS]; |
| 55 | extern const uint8_t g_log2Size[MAX_CU_SIZE + 1]; // from size to log2(size) |
| 56 | |
| 57 | // global variable (CTU width/height, max. CU depth) |
| 58 | extern uint32_t g_maxLog2CUSize; |
| 59 | extern uint32_t g_maxCUSize; |
| 60 | extern uint32_t g_maxCUDepth; |
| 61 | extern uint32_t g_maxFullDepth; |
| 62 | |
| 63 | extern const int16_t g_t4[4][4]; |
| 64 | extern const int16_t g_t8[8][8]; |
| 65 | extern const int16_t g_t16[16][16]; |
| 66 | extern const int16_t g_t32[32][32]; |
| 67 | |
| 68 | // Subpel interpolation defines and constants |
| 69 | |
| 70 | #define NTAPS_LUMA 8 // Number of taps for luma |
| 71 | #define NTAPS_CHROMA 4 // Number of taps for chroma |
| 72 | #define IF_INTERNAL_PREC 14 // Number of bits for internal precision |
| 73 | #define IF_FILTER_PREC 6 // Log2 of sum of filter taps |
| 74 | #define IF_INTERNAL_OFFS (1 << (IF_INTERNAL_PREC - 1)) // Offset used internally |
| 75 | #define SLFASE_CONSTANT 0x5f4e4a53 |
| 76 | |
| 77 | extern const int16_t g_lumaFilter[4][NTAPS_LUMA]; // Luma filter taps |
| 78 | extern const int16_t g_chromaFilter[8][NTAPS_CHROMA]; // Chroma filter taps |
| 79 | |
| 80 | // Scanning order & context mapping table |
| 81 | |
| 82 | #define NUM_SCAN_SIZE 4 |
| 83 | |
| 84 | extern const uint16_t* const g_scanOrder[NUM_SCAN_TYPE][NUM_SCAN_SIZE]; |
| 85 | extern const uint16_t* const g_scanOrderCG[NUM_SCAN_TYPE][NUM_SCAN_SIZE]; |
| 86 | extern const uint16_t g_scan8x8diag[8 * 8]; |
| 87 | extern const uint16_t g_scan4x4[NUM_SCAN_TYPE][4 * 4]; |
| 88 | |
| 89 | extern const uint8_t g_minInGroup[10]; |
| 90 | extern const uint8_t g_goRiceRange[5]; // maximum value coded with Rice codes |
| 91 | |
| 92 | // CABAC tables |
| 93 | extern const uint8_t g_lpsTable[64][4]; |
| 94 | extern const uint8_t x265_exp2_lut[64]; |
| 95 | |
| 96 | // Intra tables |
| 97 | extern const uint8_t g_intraFilterFlags[NUM_INTRA_MODE]; |
| 98 | |
| 99 | extern const uint32_t g_depthInc[3][4]; |
| 100 | extern const uint32_t g_depthScanIdx[8][8]; |
| 101 | |
| 102 | } |
| 103 | |
| 104 | #endif |