Imported Upstream version 1.4+222+hg5f9f7194267b
[deb_x265.git] / source / common / constants.h
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 initZscanToRaster(uint32_t maxFullDepth, uint32_t depth, uint32_t startVal, uint32_t*& curIdx);
33 void initRasterToZscan(uint32_t maxFullDepth);
34
35 extern double x265_lambda_tab[QP_MAX_MAX + 1];
36 extern double x265_lambda2_tab[QP_MAX_MAX + 1];
37 extern const uint16_t x265_chroma_lambda2_offset_tab[MAX_CHROMA_LAMBDA_OFFSET + 1];
38
39 enum { ChromaQPMappingTableSize = 70 };
40 enum { AngleMapping422TableSize = 36 };
41
42 extern const uint8_t g_chromaScale[ChromaQPMappingTableSize];
43 extern const uint8_t g_chroma422IntraAngleMappingTable[AngleMapping422TableSize];
44
45 // flexible conversion from relative to absolute index
46 extern uint32_t g_zscanToRaster[MAX_NUM_PARTITIONS];
47 extern uint32_t g_rasterToZscan[MAX_NUM_PARTITIONS];
48
49 // conversion of partition index to picture pel position
50 extern const uint8_t g_zscanToPelX[MAX_NUM_PARTITIONS];
51 extern const uint8_t g_zscanToPelY[MAX_NUM_PARTITIONS];
52 extern const uint8_t g_log2Size[MAX_CU_SIZE + 1]; // from size to log2(size)
53
54 // global variable (CTU width/height, max. CU depth)
55 extern uint32_t g_maxLog2CUSize;
56 extern uint32_t g_maxCUSize;
57 extern uint32_t g_maxCUDepth;
58 extern uint32_t g_maxFullDepth;
59
60 extern const int16_t g_t4[4][4];
61 extern const int16_t g_t8[8][8];
62 extern const int16_t g_t16[16][16];
63 extern const int16_t g_t32[32][32];
64
65 // Subpel interpolation defines and constants
66
67 #define NTAPS_LUMA 8 // Number of taps for luma
68 #define NTAPS_CHROMA 4 // Number of taps for chroma
69 #define IF_INTERNAL_PREC 14 // Number of bits for internal precision
70 #define IF_FILTER_PREC 6 // Log2 of sum of filter taps
71 #define IF_INTERNAL_OFFS (1 << (IF_INTERNAL_PREC - 1)) // Offset used internally
72 #define SLFASE_CONSTANT 0x5f4e4a53
73
74 extern const int16_t g_lumaFilter[4][NTAPS_LUMA]; // Luma filter taps
75 extern const int16_t g_chromaFilter[8][NTAPS_CHROMA]; // Chroma filter taps
76
77 // Scanning order & context mapping table
78
79 #define NUM_SCAN_SIZE 4
80
81 extern const uint16_t* const g_scanOrder[NUM_SCAN_TYPE][NUM_SCAN_SIZE];
82 extern const uint16_t* const g_scanOrderCG[NUM_SCAN_TYPE][NUM_SCAN_SIZE];
83 extern const uint16_t g_scan8x8diag[8 * 8];
84 extern const uint16_t g_scan4x4[NUM_SCAN_TYPE][4 * 4];
85
86 extern const uint8_t g_minInGroup[10];
87 extern const uint8_t g_goRiceRange[5]; // maximum value coded with Rice codes
88
89 // CABAC tables
90 extern const uint8_t g_lpsTable[64][4];
91 extern const uint8_t x265_exp2_lut[64];
92
93 // Intra tables
94 extern const uint8_t g_intraFilterFlags[NUM_INTRA_MODE];
95
96 extern const uint32_t g_depthInc[3][4];
97 extern const uint32_t g_depthScanIdx[8][8];
98
99 }
100
101 #endif