• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*!
2  * \copy
3  *     Copyright (c)  2013, Cisco Systems
4  *     All rights reserved.
5  *
6  *     Redistribution and use in source and binary forms, with or without
7  *     modification, are permitted provided that the following conditions
8  *     are met:
9  *
10  *        * Redistributions of source code must retain the above copyright
11  *          notice, this list of conditions and the following disclaimer.
12  *
13  *        * Redistributions in binary form must reproduce the above copyright
14  *          notice, this list of conditions and the following disclaimer in
15  *          the documentation and/or other materials provided with the
16  *          distribution.
17  *
18  *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24  *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28  *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  *     POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 #include "wels_common_defs.h"
34 
35 namespace WelsCommon {
36 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
37 
38 //////pNonZeroCount[16+8] mapping scan index
39 const uint8_t g_kuiMbCountScan4Idx[24] = {
40                    //  0   1 | 4  5      luma 8*8 block           pNonZeroCount[16+8]
41   0,  1,  4,  5,   //  2   3 | 6  7        0  |  1                  0   1   2   3
42   2,  3,  6,  7,   //---------------      ---------                 4   5   6   7
43   8,  9, 12, 13,   //  8   9 | 12 13       2  |  3                  8   9  10  11
44   10, 11, 14, 15,  // 10  11 | 14 15-----------------------------> 12  13  14  15
45   16, 17, 20, 21,  //----------------    chroma 8*8 block          16  17  18  19
46   18, 19, 22, 23   // 16  17 | 20 21        0    1                 20  21  22  23
47 };
48 
49 const uint8_t g_kuiCache48CountScan4Idx[24] = {
50   /* Luma */
51   9, 10, 17, 18,        // 1+1*8, 2+1*8, 1+2*8, 2+2*8,
52   11, 12, 19, 20,       // 3+1*8, 4+1*8, 3+2*8, 4+2*8,
53   25, 26, 33, 34,       // 1+3*8, 2+3*8, 1+4*8, 2+4*8,
54   27, 28, 35, 36,       // 3+3*8, 4+3*8, 3+4*8, 4+4*8,
55   /* Cb */
56   14, 15,               // 6+1*8, 7+1*8,
57   22, 23,               // 6+2*8, 7+2*8,
58 
59   /* Cr */
60   38, 39,               // 6+4*8, 7+4*8,
61   46, 47,               // 6+5*8, 7+5*8,
62 };
63 
64 const uint8_t g_kuiMatrixV[6][8][8] = { // generated from equation 8-317, 8-318
65   {
66     {20, 19, 25, 19, 20, 19, 25, 19},
67     {19, 18, 24, 18, 19, 18, 24, 18},
68     {25, 24, 32, 24, 25, 24, 32, 24},
69     {19, 18, 24, 18, 19, 18, 24, 18},
70     {20, 19, 25, 19, 20, 19, 25, 19},
71     {19, 18, 24, 18, 19, 18, 24, 18},
72     {25, 24, 32, 24, 25, 24, 32, 24},
73     {19, 18, 24, 18, 19, 18, 24, 18}
74   },
75   {
76     {22, 21, 28, 21, 22, 21, 28, 21},
77     {21, 19, 26, 19, 21, 19, 26, 19},
78     {28, 26, 35, 26, 28, 26, 35, 26},
79     {21, 19, 26, 19, 21, 19, 26, 19},
80     {22, 21, 28, 21, 22, 21, 28, 21},
81     {21, 19, 26, 19, 21, 19, 26, 19},
82     {28, 26, 35, 26, 28, 26, 35, 26},
83     {21, 19, 26, 19, 21, 19, 26, 19}
84   },
85   {
86     {26, 24, 33, 24, 26, 24, 33, 24},
87     {24, 23, 31, 23, 24, 23, 31, 23},
88     {33, 31, 42, 31, 33, 31, 42, 31},
89     {24, 23, 31, 23, 24, 23, 31, 23},
90     {26, 24, 33, 24, 26, 24, 33, 24},
91     {24, 23, 31, 23, 24, 23, 31, 23},
92     {33, 31, 42, 31, 33, 31, 42, 31},
93     {24, 23, 31, 23, 24, 23, 31, 23}
94   },
95   {
96     {28, 26, 35, 26, 28, 26, 35, 26},
97     {26, 25, 33, 25, 26, 25, 33, 25},
98     {35, 33, 45, 33, 35, 33, 45, 33},
99     {26, 25, 33, 25, 26, 25, 33, 25},
100     {28, 26, 35, 26, 28, 26, 35, 26},
101     {26, 25, 33, 25, 26, 25, 33, 25},
102     {35, 33, 45, 33, 35, 33, 45, 33},
103     {26, 25, 33, 25, 26, 25, 33, 25}
104   },
105   {
106     {32, 30, 40, 30, 32, 30, 40, 30},
107     {30, 28, 38, 28, 30, 28, 38, 28},
108     {40, 38, 51, 38, 40, 38, 51, 38},
109     {30, 28, 38, 28, 30, 28, 38, 28},
110     {32, 30, 40, 30, 32, 30, 40, 30},
111     {30, 28, 38, 28, 30, 28, 38, 28},
112     {40, 38, 51, 38, 40, 38, 51, 38},
113     {30, 28, 38, 28, 30, 28, 38, 28}
114   },
115   {
116     {36, 34, 46, 34, 36, 34, 46, 34},
117     {34, 32, 43, 32, 34, 32, 43, 32},
118     {46, 43, 58, 43, 46, 43, 58, 43},
119     {34, 32, 43, 32, 34, 32, 43, 32},
120     {36, 34, 46, 34, 36, 34, 46, 34},
121     {34, 32, 43, 32, 34, 32, 43, 32},
122     {46, 43, 58, 43, 46, 43, 58, 43},
123     {34, 32, 43, 32, 34, 32, 43, 32}
124   }
125 };
126 
127 //cache element equal to 30
128 const uint8_t g_kuiCache30ScanIdx[16] = { //mv or uiRefIndex cache scan index, 4*4 block as basic unit
129   7,  8, 13, 14,
130   9, 10, 15, 16,
131   19, 20, 25, 26,
132   21, 22, 27, 28
133 };
134 
135 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
136 
137 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
138 
139 
140 // extern at wels_common_defs.h
141 const uint8_t g_kuiChromaQpTable[52] = {
142   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
143   12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
144   28, 29, 29, 30, 31, 32, 32, 33, 34, 34, 35, 35, 36, 36, 37, 37,
145   37, 38, 38, 38, 39, 39, 39, 39
146 };
147 
148 /*
149  *  vcl type map for given NAL unit type and corresponding H264 type (0: AVC; 1: SVC).
150  */
151 const EVclType g_keTypeMap[32][2] = {
152   { NON_VCL,    NON_VCL },      // 0: NAL_UNIT_UNSPEC_0
153   { VCL,        VCL,    },      // 1: NAL_UNIT_CODED_SLICE
154   { VCL,        NOT_APP },      // 2: NAL_UNIT_CODED_SLICE_DPA
155   { VCL,        NOT_APP },      // 3: NAL_UNIT_CODED_SLICE_DPB
156   { VCL,        NOT_APP },      // 4: NAL_UNIT_CODED_SLICE_DPC
157   { VCL,        VCL     },      // 5: NAL_UNIT_CODED_SLICE_IDR
158   { NON_VCL,    NON_VCL },      // 6: NAL_UNIT_SEI
159   { NON_VCL,    NON_VCL },      // 7: NAL_UNIT_SPS
160   { NON_VCL,    NON_VCL },      // 8: NAL_UNIT_PPS
161   { NON_VCL,    NON_VCL },      // 9: NAL_UNIT_AU_DELIMITER
162   { NON_VCL,    NON_VCL },      // 10: NAL_UNIT_END_OF_SEQ
163   { NON_VCL,    NON_VCL },      // 11: NAL_UNIT_END_OF_STR
164   { NON_VCL,    NON_VCL },      // 12: NAL_UNIT_FILLER_DATA
165   { NON_VCL,    NON_VCL },      // 13: NAL_UNIT_SPS_EXT
166   { NON_VCL,    NON_VCL },      // 14: NAL_UNIT_PREFIX, NEED associate succeeded NAL to make a VCL
167   { NON_VCL,    NON_VCL },      // 15: NAL_UNIT_SUBSET_SPS
168   { NON_VCL,    NON_VCL },      // 16: NAL_UNIT_DEPTH_PARAM
169   { NON_VCL,    NON_VCL },      // 17: NAL_UNIT_RESV_17
170   { NON_VCL,    NON_VCL },      // 18: NAL_UNIT_RESV_18
171   { NON_VCL,    NON_VCL },      // 19: NAL_UNIT_AUX_CODED_SLICE
172   { NON_VCL,    VCL     },      // 20: NAL_UNIT_CODED_SLICE_EXT
173   { NON_VCL,    NON_VCL },      // 21: NAL_UNIT_MVC_SLICE_EXT
174   { NON_VCL,    NON_VCL },      // 22: NAL_UNIT_RESV_22
175   { NON_VCL,    NON_VCL },      // 23: NAL_UNIT_RESV_23
176   { NON_VCL,    NON_VCL },      // 24: NAL_UNIT_UNSPEC_24
177   { NON_VCL,    NON_VCL },      // 25: NAL_UNIT_UNSPEC_25
178   { NON_VCL,    NON_VCL },      // 26: NAL_UNIT_UNSPEC_26
179   { NON_VCL,    NON_VCL },      // 27: NAL_UNIT_UNSPEC_27
180   { NON_VCL,    NON_VCL },      // 28: NAL_UNIT_UNSPEC_28
181   { NON_VCL,    NON_VCL },      // 29: NAL_UNIT_UNSPEC_29
182   { NON_VCL,    NON_VCL },      // 30: NAL_UNIT_UNSPEC_30
183   { NON_VCL,    NON_VCL }       // 31: NAL_UNIT_UNSPEC_31
184 };
185 //default scaling list matrix value of 4x4
186 const uint8_t g_kuiDequantScaling4x4Default[2][16]={
187   {  6, 13, 20, 28, 13, 20, 28, 32, 20, 28, 32, 37, 28, 32, 37, 42 },
188   { 10, 14, 20, 24, 14, 20, 24, 27, 20, 24, 27, 30, 24, 27, 30, 34 }
189 };
190 //default scaling list matrix value of 8x8
191 const uint8_t g_kuiDequantScaling8x8Default[2][64]={
192   {  6, 10, 13, 16, 18, 23, 25, 27, 10, 11, 16, 18, 23, 25, 27, 29,
193       13, 16, 18, 23, 25, 27, 29, 31,
194       16, 18, 23, 25, 27, 29, 31, 33,
195       18, 23, 25, 27, 29, 31, 33, 36,
196       23, 25, 27, 29, 31, 33, 36, 38,
197       25, 27, 29, 31, 33, 36, 38, 40,
198       27, 29, 31, 33, 36, 38, 40, 42 },
199     {  9, 13, 15, 17, 19, 21, 22, 24,
200       13, 13, 17, 19, 21, 22, 24, 25,
201       15, 17, 19, 21, 22, 24, 25, 27,
202       17, 19, 21, 22, 24, 25, 27, 28,
203       19, 21, 22, 24, 25, 27, 28, 30,
204       21, 22, 24, 25, 27, 28, 30, 32,
205       22, 24, 25, 27, 28, 30, 32, 33,
206       24, 25, 27, 28, 30, 32, 33, 35 }
207 };
208 ALIGNED_DECLARE (const uint16_t, g_kuiDequantCoeff[52][8], 16) = {
209   /* 0*/{   10,   13,   10,   13,   13,   16,   13,   16 },     /* 1*/{   11,   14,   11,   14,   14,   18,   14,   18 },
210   /* 2*/{   13,   16,   13,   16,   16,   20,   16,   20 },     /* 3*/{   14,   18,   14,   18,   18,   23,   18,   23 },
211   /* 4*/{   16,   20,   16,   20,   20,   25,   20,   25 },     /* 5*/{   18,   23,   18,   23,   23,   29,   23,   29 },
212   /* 6*/{   20,   26,   20,   26,   26,   32,   26,   32 },     /* 7*/{   22,   28,   22,   28,   28,   36,   28,   36 },
213   /* 8*/{   26,   32,   26,   32,   32,   40,   32,   40 },     /* 9*/{   28,   36,   28,   36,   36,   46,   36,   46 },
214   /*10*/{   32,   40,   32,   40,   40,   50,   40,   50 },     /*11*/{   36,   46,   36,   46,   46,   58,   46,   58 },
215   /*12*/{   40,   52,   40,   52,   52,   64,   52,   64 },     /*13*/{   44,   56,   44,   56,   56,   72,   56,   72 },
216   /*14*/{   52,   64,   52,   64,   64,   80,   64,   80 },     /*15*/{   56,   72,   56,   72,   72,   92,   72,   92 },
217   /*16*/{   64,   80,   64,   80,   80,  100,   80,  100 },     /*17*/{   72,   92,   72,   92,   92,  116,   92,  116 },
218   /*18*/{   80,  104,   80,  104,  104,  128,  104,  128 },     /*19*/{   88,  112,   88,  112,  112,  144,  112,  144 },
219   /*20*/{  104,  128,  104,  128,  128,  160,  128,  160 },     /*21*/{  112,  144,  112,  144,  144,  184,  144,  184 },
220   /*22*/{  128,  160,  128,  160,  160,  200,  160,  200 },     /*23*/{  144,  184,  144,  184,  184,  232,  184,  232 },
221   /*24*/{  160,  208,  160,  208,  208,  256,  208,  256 },     /*25*/{  176,  224,  176,  224,  224,  288,  224,  288 },
222   /*26*/{  208,  256,  208,  256,  256,  320,  256,  320 },     /*27*/{  224,  288,  224,  288,  288,  368,  288,  368 },
223   /*28*/{  256,  320,  256,  320,  320,  400,  320,  400 },     /*29*/{  288,  368,  288,  368,  368,  464,  368,  464 },
224   /*30*/{  320,  416,  320,  416,  416,  512,  416,  512 },     /*31*/{  352,  448,  352,  448,  448,  576,  448,  576 },
225   /*32*/{  416,  512,  416,  512,  512,  640,  512,  640 },     /*33*/{  448,  576,  448,  576,  576,  736,  576,  736 },
226   /*34*/{  512,  640,  512,  640,  640,  800,  640,  800 },     /*35*/{  576,  736,  576,  736,  736,  928,  736,  928 },
227   /*36*/{  640,  832,  640,  832,  832, 1024,  832, 1024 },     /*37*/{  704,  896,  704,  896,  896, 1152,  896, 1152 },
228   /*38*/{  832, 1024,  832, 1024, 1024, 1280, 1024, 1280 },     /*39*/{  896, 1152,  896, 1152, 1152, 1472, 1152, 1472 },
229   /*40*/{ 1024, 1280, 1024, 1280, 1280, 1600, 1280, 1600 },     /*41*/{ 1152, 1472, 1152, 1472, 1472, 1856, 1472, 1856 },
230   /*42*/{ 1280, 1664, 1280, 1664, 1664, 2048, 1664, 2048 },     /*43*/{ 1408, 1792, 1408, 1792, 1792, 2304, 1792, 2304 },
231   /*44*/{ 1664, 2048, 1664, 2048, 2048, 2560, 2048, 2560 },     /*45*/{ 1792, 2304, 1792, 2304, 2304, 2944, 2304, 2944 },
232   /*46*/{ 2048, 2560, 2048, 2560, 2560, 3200, 2560, 3200 },     /*47*/{ 2304, 2944, 2304, 2944, 2944, 3712, 2944, 3712 },
233   /*48*/{ 2560, 3328, 2560, 3328, 3328, 4096, 3328, 4096 },     /*49*/{ 2816, 3584, 2816, 3584, 3584, 4608, 3584, 4608 },
234   /*50*/{ 3328, 4096, 3328, 4096, 4096, 5120, 4096, 5120 },     /*51*/{ 3584, 4608, 3584, 4608, 4608, 5888, 4608, 5888 },
235 };
236 
237 ALIGNED_DECLARE (const uint16_t, g_kuiDequantCoeff8x8[52][64], 16) = {
238 /* QP ==  0 */
239 { 320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288,  320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288 },
240 /* QP ==  1 */
241 { 352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304,  352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304 },
242 /* QP ==  2 */
243 { 416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368,  416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368 },
244 /* QP ==  3 */
245 { 448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400,  448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400 },
246 /* QP ==  4 */
247 { 512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448,  512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448 },
248 /* QP ==  5 */
249 { 576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512,  576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512 },
250 /* QP ==  6 */
251 { 320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288,  320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288 },
252 /* QP ==  7 */
253 { 352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304,  352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304 },
254 /* QP ==  8 */
255 { 416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368,  416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368 },
256 /* QP ==  9 */
257 { 448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400,  448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400 },
258 /* QP == 10 */
259 { 512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448,  512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448 },
260 /* QP == 11 */
261 { 576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512,  576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512 },
262 /* QP == 12 */
263 { 320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288,  320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288 },
264 /* QP == 13 */
265 { 352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304,  352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304 },
266 /* QP == 14 */
267 { 416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368,  416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368 },
268 /* QP == 15 */
269 { 448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400,  448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400 },
270 /* QP == 16 */
271 { 512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448,  512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448 },
272 /* QP == 17 */
273 { 576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512,  576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512 },
274 /* QP == 18 */
275 { 320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288,  320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288 },
276 /* QP == 19 */
277 { 352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304,  352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304 },
278 /* QP == 20 */
279 { 416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368,  416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368 },
280 /* QP == 21 */
281 { 448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400,  448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400 },
282 /* QP == 22 */
283 { 512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448,  512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448 },
284 /* QP == 23 */
285 { 576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512,  576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512 },
286 /* QP == 24 */
287 { 320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288,  320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288 },
288 /* QP == 25 */
289 { 352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304,  352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304 },
290 /* QP == 26 */
291 { 416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368,  416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368 },
292 /* QP == 27 */
293 { 448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400,  448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400 },
294 /* QP == 28 */
295 { 512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448,  512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448 },
296 /* QP == 29 */
297 { 576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512,  576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512 },
298 /* QP == 30 */
299 { 320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288,  320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288 },
300 /* QP == 31 */
301 { 352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304,  352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304 },
302 /* QP == 32 */
303 { 416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368,  416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368 },
304 /* QP == 33 */
305 { 448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400,  448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400 },
306 /* QP == 34 */
307 { 512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448,  512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448 },
308 /* QP == 35 */
309 { 576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512,  576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512 },
310 /* QP == 36 */
311 { 320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288,  320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288 },
312 /* QP == 37 */
313 { 352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304,  352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304 },
314 /* QP == 38 */
315 { 416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368,  416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368 },
316 /* QP == 39 */
317 { 448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400,  448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400 },
318 /* QP == 40 */
319 { 512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448,  512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448 },
320 /* QP == 41 */
321 { 576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512,  576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512 },
322 /* QP == 42 */
323 { 320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288,  320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288 },
324 /* QP == 43 */
325 { 352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304,  352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304 },
326 /* QP == 44 */
327 { 416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368,  416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368 },
328 /* QP == 45 */
329 { 448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400,  448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400 },
330 /* QP == 46 */
331 { 512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448,  512,  480,  640,  480,  512,  480,  640,  480,  480,  448,  608,  448,  480,  448,  608,  448,  640,  608,  816,  608,  640,  608,  816,  608,  480,  448,  608,  448,  480,  448,  608,  448 },
332 /* QP == 47 */
333 { 576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512,  576,  544,  736,  544,  576,  544,  736,  544,  544,  512,  688,  512,  544,  512,  688,  512,  736,  688,  928,  688,  736,  688,  928,  688,  544,  512,  688,  512,  544,  512,  688,  512 },
334 /* QP == 48 */
335 { 320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288,  320,  304,  400,  304,  320,  304,  400,  304,  304,  288,  384,  288,  304,  288,  384,  288,  400,  384,  512,  384,  400,  384,  512,  384,  304,  288,  384,  288,  304,  288,  384,  288 },
336 /* QP == 49 */
337 { 352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304,  352,  336,  448,  336,  352,  336,  448,  336,  336,  304,  416,  304,  336,  304,  416,  304,  448,  416,  560,  416,  448,  416,  560,  416,  336,  304,  416,  304,  336,  304,  416,  304 },
338 /* QP == 50 */
339 { 416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368,  416,  384,  528,  384,  416,  384,  528,  384,  384,  368,  496,  368,  384,  368,  496,  368,  528,  496,  672,  496,  528,  496,  672,  496,  384,  368,  496,  368,  384,  368,  496,  368 },
340 /* QP == 51 */
341 { 448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400,  448,  416,  560,  416,  448,  416,  560,  416,  416,  400,  528,  400,  416,  400,  528,  400,  560,  528,  720,  528,  560,  528,  720,  528,  416,  400,  528,  400,  416,  400,  528,  400 },
342 };
343 
344 // table A-1 - Level limits
345 const SLevelLimits g_ksLevelLimits[LEVEL_NUMBER] = {
346   {LEVEL_1_0, 1485, 99, 396, 64, 175, -256, 255, 2, 0x7fff}, /* level 1 */
347   {LEVEL_1_B, 1485, 99, 396, 128, 350, -256, 255, 2, 0x7fff}, /* level 1.b */
348   {LEVEL_1_1, 3000, 396, 900, 192, 500, -512, 511, 2, 0x7fff}, /* level 1.1 */
349   {LEVEL_1_2, 6000, 396, 2376, 384, 1000, -512, 511, 2, 0x7fff}, /* level 1.2 */
350   {LEVEL_1_3, 11880, 396, 2376, 768, 2000, -512, 511, 2, 0x7fff}, /* level 1.3 */
351 
352   {LEVEL_2_0, 11880, 396, 2376, 2000, 2000, -512, 511, 2, 0x7fff}, /* level 2 */
353   {LEVEL_2_1, 19800, 792, 4752, 4000, 4000, -1024, 1023, 2, 0x7fff}, /* level 2.1 */
354   {LEVEL_2_2, 20250, 1620, 8100, 4000, 4000, -1024, 1023, 2, 0x7fff}, /* level 2.2 */
355 
356   {LEVEL_3_0, 40500, 1620, 8100, 10000, 10000, -1024, 1023, 2, 32 }, /* level 3 */
357   {LEVEL_3_1, 108000, 3600, 18000, 14000, 14000, -2048, 2047, 4, 16}, /* level 3.1 */
358   {LEVEL_3_2, 216000, 5120, 20480, 20000, 20000, -2048, 2047, 4, 16}, /* level 3.2 */
359 
360   {LEVEL_4_0, 245760, 8192, 32768, 20000, 25000, -2048, 2047, 4, 16}, /* level 4 */
361   {LEVEL_4_1, 245760, 8192, 32768, 50000, 62500, -2048, 2047, 2, 16}, /* level 4.1 */
362   {LEVEL_4_2, 522240, 8704, 34816, 50000, 62500, -2048, 2047, 2, 16}, /* level 4.2 */
363 
364   {LEVEL_5_0, 589824, 22080, 110400, 135000, 135000, -2048, 2047, 2, 16}, /* level 5 */
365   {LEVEL_5_1, 983040, 36864, 184320, 240000, 240000, -2048, 2047, 2, 16}, /* level 5.1 */
366   {LEVEL_5_2, 2073600, 36864, 184320, 240000, 240000, -2048, 2047, 2, 16} /* level 5.2 */
367 };
368 const uint32_t g_kuiLevelMaps[LEVEL_NUMBER] = {
369   10, 9, 11, 12, 13, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51, 52
370 };
371 //for cabac
372 /* this table is from Table9-12 to Table 9-24 */
373 
374 const int8_t g_kiCabacGlobalContextIdx[WELS_CONTEXT_COUNT][4][2] = {
375   //0-10 Table 9-12
376   {{20, -15}, {20, -15}, {20, -15}, {20, -15}},
377   {{2, 54}, {2, 54}, {2, 54}, {2, 54}},
378   {{3, 74}, {3, 74}, {3, 74}, {3, 74}},
379   {{20, -15}, {20, -15}, {20, -15}, {20, -15}},
380   {{2, 54}, {2, 54}, {2, 54}, {2, 54}},
381   {{3, 74}, {3, 74}, {3, 74}, {3, 74}},
382   {{ -28, 127}, { -28, 127}, { -28, 127}, { -28, 127}},
383   {{ -23, 104}, { -23, 104}, { -23, 104}, { -23, 104}},
384   {{ -6, 53}, { -6, 53}, { -6, 53}, { -6, 53}},
385   {{ -1, 54}, { -1, 54}, { -1, 54}, { -1, 54}},
386   {{7, 51}, {7, 51}, {7, 51}, {7, 51}},
387   //11-23 Table 9-13
388   {{CTX_NA, CTX_NA}, {23, 33}, {22, 25}, {29, 16}},
389   {{CTX_NA, CTX_NA}, {23, 2}, {34, 0}, {25, 0}},
390   {{CTX_NA, CTX_NA}, {21, 0}, {16, 0}, {14, 0}},
391   {{CTX_NA, CTX_NA}, {1, 9}, { -2, 9}, { -10, 51}},
392   {{CTX_NA, CTX_NA}, {0, 49}, {4, 41}, { -3, 62}},
393   {{CTX_NA, CTX_NA}, { -37, 118}, { -29, 118}, { -27, 99}},
394   {{CTX_NA, CTX_NA}, {5, 57}, {2, 65}, {26, 16}},
395   {{CTX_NA, CTX_NA}, { -13, 78}, { -6, 71}, { -4, 85}},
396   {{CTX_NA, CTX_NA}, { -11, 65}, { -13, 79}, { -24, 102}},
397   {{CTX_NA, CTX_NA}, {1, 62}, {5, 52}, {5, 57}},
398   {{CTX_NA, CTX_NA}, {12, 49}, {9, 50}, {6, 57}},
399   {{CTX_NA, CTX_NA}, { -4, 73}, { -3, 70}, { -17, 73}},
400   {{CTX_NA, CTX_NA}, {17, 50}, {10, 54}, {14, 57}},
401   //24-39 Table9-14
402   {{CTX_NA, CTX_NA}, {18, 64}, {26, 34}, {20, 40}},
403   {{CTX_NA, CTX_NA}, {9, 43}, {19, 22}, {20, 10}},
404   {{CTX_NA, CTX_NA}, {29, 0}, {40, 0}, {29, 0}},
405   {{CTX_NA, CTX_NA}, {26, 67}, {57, 2}, {54, 0}},
406   {{CTX_NA, CTX_NA}, {16, 90}, {41, 36}, {37, 42}},
407   {{CTX_NA, CTX_NA}, {9, 104}, {26, 69}, {12, 97}},
408   {{CTX_NA, CTX_NA}, { -46, 127}, { -45, 127}, { -32, 127}},
409   {{CTX_NA, CTX_NA}, { -20, 104}, { -15, 101}, { -22, 117}},
410   {{CTX_NA, CTX_NA}, {1, 67}, { -4, 76}, { -2, 74}},
411   {{CTX_NA, CTX_NA}, { -13, 78}, { -6, 71}, { -4, 85}},
412   {{CTX_NA, CTX_NA}, { -11, 65}, { -13, 79}, { -24, 102}},
413   {{CTX_NA, CTX_NA}, {1, 62}, {5, 52}, {5, 57}},
414   {{CTX_NA, CTX_NA}, { -6, 86}, {6, 69}, { -6, 93}},
415   {{CTX_NA, CTX_NA}, { -17, 95}, { -13, 90}, { -14, 88}},
416   {{CTX_NA, CTX_NA}, { -6, 61}, {0, 52}, { -6, 44}},
417   {{CTX_NA, CTX_NA}, {9, 45}, {8, 43}, {4, 55}},
418   //40-53 Table 9-15
419   {{CTX_NA, CTX_NA}, { -3, 69}, { -2, 69}, { -11, 89}},
420   {{CTX_NA, CTX_NA}, { -6, 81}, { -5, 82}, { -15, 103}},
421   {{CTX_NA, CTX_NA}, { -11, 96}, { -10, 96}, { -21, 116}},
422   {{CTX_NA, CTX_NA}, {6, 55}, {2, 59}, {19, 57}},
423   {{CTX_NA, CTX_NA}, {7, 67}, {2, 75}, {20, 58}},
424   {{CTX_NA, CTX_NA}, { -5, 86}, { -3, 87}, {4, 84}},
425   {{CTX_NA, CTX_NA}, {2, 88}, { -3, 100}, {6, 96}},
426   {{CTX_NA, CTX_NA}, {0, 58}, {1, 56}, {1, 63}},
427   {{CTX_NA, CTX_NA}, { -3, 76}, { -3, 74}, { -5, 85}},
428   {{CTX_NA, CTX_NA}, { -10, 94}, { -6, 85}, { -13, 106}},
429   {{CTX_NA, CTX_NA}, {5, 54}, {0, 59}, {5, 63}},
430   {{CTX_NA, CTX_NA}, {4, 69}, { -3, 81}, {6, 75}},
431   {{CTX_NA, CTX_NA}, { -3, 81}, { -7, 86}, { -3, 90}},
432   {{CTX_NA, CTX_NA}, {0, 88}, { -5, 95}, { -1, 101}},
433   //54-59 Table 9-16
434   {{CTX_NA, CTX_NA}, { -7, 67}, { -1, 66}, {3, 55}},
435   {{CTX_NA, CTX_NA}, { -5, 74}, { -1, 77}, { -4, 79}},
436   {{CTX_NA, CTX_NA}, { -4, 74}, {1, 70}, { -2, 75}},
437   {{CTX_NA, CTX_NA}, { -5, 80}, { -2, 86}, { -12, 97}},
438   {{CTX_NA, CTX_NA}, { -7, 72}, { -5, 72}, { -7, 50}},
439   {{CTX_NA, CTX_NA}, {1, 58}, {0, 61}, {1, 60}},
440   //60-69 Table 9-17
441   {{0, 41}, {0, 41}, {0, 41}, {0, 41}},
442   {{0, 63}, {0, 63}, {0, 63}, {0, 63}},
443   {{0, 63}, {0, 63}, {0, 63}, {0, 63}},
444   {{0, 63}, {0, 63}, {0, 63}, {0, 63}},
445   {{ -9, 83}, { -9, 83}, { -9, 83}, { -9, 83}},
446   {{4, 86}, {4, 86}, {4, 86}, {4, 86}},
447   {{0, 97}, {0, 97}, {0, 97}, {0, 97}},
448   {{ -7, 72}, { -7, 72}, { -7, 72}, { -7, 72}},
449   {{13, 41}, {13, 41}, {13, 41}, {13, 41}},
450   {{3, 62}, {3, 62}, {3, 62}, {3, 62}},
451   //70-104 Table 9-18
452   {{0, 11}, {0, 45}, {13, 15}, {7, 34}},
453   {{1, 55}, { -4, 78}, {7, 51}, { -9, 88}},
454   {{0, 69}, { -3, 96}, {2, 80}, { -20, 127}},
455   {{ -17, 127}, { -27, 126}, { -39, 127}, { -36, 127}},
456   {{ -13, 102}, { -28, 98}, { -18, 91}, { -17, 91}},
457   {{0, 82}, { -25, 101}, { -17, 96}, { -14, 95}},
458   {{ -7, 74}, { -23, 67}, { -26, 81}, { -25, 84}},
459   {{ -21, 107}, { -28, 82}, { -35, 98}, { -25, 86}},
460   {{ -27, 127}, { -20, 94}, { -24, 102}, { -12, 89}},
461   {{ -31, 127}, { -16, 83}, { -23, 97}, { -17, 91}},
462   {{ -24, 127}, { -22, 110}, { -27, 119}, { -31, 127}},
463   {{ -18, 95}, { -21, 91}, { -24, 99}, { -14, 76}},
464   {{ -27, 127}, { -18, 102}, { -21, 110}, { -18, 103}},
465   {{ -21, 114}, { -13, 93}, { -18, 102}, { -13, 90}},
466   {{ -30, 127}, { -29, 127}, { -36, 127}, { -37, 127}},
467   {{ -17, 123}, { -7, 92}, {0, 80}, {11, 80}},
468   {{ -12, 115}, { -5, 89}, { -5, 89}, {5, 76}},
469   {{ -16, 122}, { -7, 96}, { -7, 94}, {2, 84}},
470   {{ -11, 115}, { -13, 108}, { -4, 92}, {5, 78}},
471   {{ -12, 63}, { -3, 46}, {0, 39}, { -6, 55}},
472   {{ -2, 68}, { -1, 65}, {0, 65}, {4, 61}},
473   {{ -15, 84}, { -1, 57}, { -15, 84}, { -14, 83}},
474   {{ -13, 104}, { -9, 93}, { -35, 127}, { -37, 127}},
475   {{ -3, 70}, { -3, 74}, { -2, 73}, { -5, 79}},
476   {{ -8, 93}, { -9, 92}, { -12, 104}, { -11, 104}},
477   {{ -10, 90}, { -8, 87}, { -9, 91}, { -11, 91}},
478   {{ -30, 127}, { -23, 126}, { -31, 127}, { -30, 127}},
479   {{ -1, 74}, {5, 54}, {3, 55}, {0, 65}},
480   {{ -6, 97}, {6, 60}, {7, 56}, { -2, 79}},
481   {{ -7, 91}, {6, 59}, {7, 55}, {0, 72}},
482   {{ -20, 127}, {6, 69}, {8, 61}, { -4, 92}},
483   {{ -4, 56}, { -1, 48}, { -3, 53}, { -6, 56}},
484   {{ -5, 82}, {0, 68}, {0, 68}, {3, 68}},
485   {{ -7, 76}, { -4, 69}, { -7, 74}, { -8, 71}},
486   {{ -22, 125}, { -8, 88}, { -9, 88}, { -13, 98}},
487   //105-165 Table 9-19
488   {{ -7, 93}, { -2, 85}, { -13, 103}, { -4, 86}},
489   {{ -11, 87}, { -6, 78}, { -13, 91}, { -12, 88}},
490   {{ -3, 77}, { -1, 75}, { -9, 89}, { -5, 82}},
491   {{ -5, 71}, { -7, 77}, { -14, 92}, { -3, 72}},
492   {{ -4, 63}, {2, 54}, { -8, 76}, { -4, 67}},
493   {{ -4, 68}, {5, 50}, { -12, 87}, { -8, 72}},
494   {{ -12, 84}, { -3, 68}, { -23, 110}, { -16, 89}},
495   {{ -7, 62}, {1, 50}, { -24, 105}, { -9, 69}},
496   {{ -7, 65}, {6, 42}, { -10, 78}, { -1, 59}},
497   {{8, 61}, { -4, 81}, { -20, 112}, {5, 66}},
498   {{5, 56}, {1, 63}, { -17, 99}, {4, 57}},
499   {{ -2, 66}, { -4, 70}, { -78, 127}, { -4, 71}},
500   {{1, 64}, {0, 67}, { -70, 127}, { -2, 71}},
501   {{0, 61}, {2, 57}, { -50, 127}, {2, 58}},
502   {{ -2, 78}, { -2, 76}, { -46, 127}, { -1, 74}},
503   {{1, 50}, {11, 35}, { -4, 66}, { -4, 44}},
504   {{7, 52}, {4, 64}, { -5, 78}, { -1, 69}},
505   {{10, 35}, {1, 61}, { -4, 71}, {0, 62}},
506   {{0, 44}, {11, 35}, { -8, 72}, { -7, 51}},
507   {{11, 38}, {18, 25}, {2, 59}, { -4, 47}},
508   {{1, 45}, {12, 24}, { -1, 55}, { -6, 42}},
509   {{0, 46}, {13, 29}, { -7, 70}, { -3, 41}},
510   {{5, 44}, {13, 36}, { -6, 75}, { -6, 53}},
511   {{31, 17}, { -10, 93}, { -8, 89}, {8, 76}},
512   {{1, 51}, { -7, 73}, { -34, 119}, { -9, 78}},
513   {{7, 50}, { -2, 73}, { -3, 75}, { -11, 83}},
514   {{28, 19}, {13, 46}, {32, 20}, {9, 52}},
515   {{16, 33}, {9, 49}, {30, 22}, {0, 67}},
516   {{14, 62}, { -7, 100}, { -44, 127}, { -5, 90}},
517   {{ -13, 108}, {9, 53}, {0, 54}, {1, 67}},
518   {{ -15, 100}, {2, 53}, { -5, 61}, { -15, 72}},
519   {{ -13, 101}, {5, 53}, {0, 58}, { -5, 75}},
520   {{ -13, 91}, { -2, 61}, { -1, 60}, { -8, 80}},
521   {{ -12, 94}, {0, 56}, { -3, 61}, { -21, 83}},
522   {{ -10, 88}, {0, 56}, { -8, 67}, { -21, 64}},
523   {{ -16, 84}, { -13, 63}, { -25, 84}, { -13, 31}},
524   {{ -10, 86}, { -5, 60}, { -14, 74}, { -25, 64}},
525   {{ -7, 83}, { -1, 62}, { -5, 65}, { -29, 94}},
526   {{ -13, 87}, {4, 57}, {5, 52}, {9, 75}},
527   {{ -19, 94}, { -6, 69}, {2, 57}, {17, 63}},
528   {{1, 70}, {4, 57}, {0, 61}, { -8, 74}},
529   {{0, 72}, {14, 39}, { -9, 69}, { -5, 35}},
530   {{ -5, 74}, {4, 51}, { -11, 70}, { -2, 27}},
531   {{18, 59}, {13, 68}, {18, 55}, {13, 91}},
532   {{ -8, 102}, {3, 64}, { -4, 71}, {3, 65}},
533   {{ -15, 100}, {1, 61}, {0, 58}, { -7, 69}},
534   {{0, 95}, {9, 63}, {7, 61}, {8, 77}},
535   {{ -4, 75}, {7, 50}, {9, 41}, { -10, 66}},
536   {{2, 72}, {16, 39}, {18, 25}, {3, 62}},
537   {{ -11, 75}, {5, 44}, {9, 32}, { -3, 68}},
538   {{ -3, 71}, {4, 52}, {5, 43}, { -20, 81}},
539   {{15, 46}, {11, 48}, {9, 47}, {0, 30}},
540   {{ -13, 69}, { -5, 60}, {0, 44}, {1, 7}},
541   {{0, 62}, { -1, 59}, {0, 51}, { -3, 23}},
542   {{0, 65}, {0, 59}, {2, 46}, { -21, 74}},
543   {{21, 37}, {22, 33}, {19, 38}, {16, 66}},
544   {{ -15, 72}, {5, 44}, { -4, 66}, { -23, 124}},
545   {{9, 57}, {14, 43}, {15, 38}, {17, 37}},
546   {{16, 54}, { -1, 78}, {12, 42}, {44, -18}},
547   {{0, 62}, {0, 60}, {9, 34}, {50, -34}},
548   {{12, 72}, {9, 69}, {0, 89}, { -22, 127}},
549   //166-226 Table 9-20
550   {{24, 0}, {11, 28}, {4, 45}, {4, 39}},
551   {{15, 9}, {2, 40}, {10, 28}, {0, 42}},
552   {{8, 25}, {3, 44}, {10, 31}, {7, 34}},
553   {{13, 18}, {0, 49}, {33, -11}, {11, 29}},
554   {{15, 9}, {0, 46}, {52, -43}, {8, 31}},
555   {{13, 19}, {2, 44}, {18, 15}, {6, 37}},
556   {{10, 37}, {2, 51}, {28, 0}, {7, 42}},
557   {{12, 18}, {0, 47}, {35, -22}, {3, 40}},
558   {{6, 29}, {4, 39}, {38, -25}, {8, 33}},
559   {{20, 33}, {2, 62}, {34, 0}, {13, 43}},
560   {{15, 30}, {6, 46}, {39, -18}, {13, 36}},
561   {{4, 45}, {0, 54}, {32, -12}, {4, 47}},
562   {{1, 58}, {3, 54}, {102, -94}, {3, 55}},
563   {{0, 62}, {2, 58}, {0, 0}, {2, 58}},
564   {{7, 61}, {4, 63}, {56, -15}, {6, 60}},
565   {{12, 38}, {6, 51}, {33, -4}, {8, 44}},
566   {{11, 45}, {6, 57}, {29, 10}, {11, 44}},
567   {{15, 39}, {7, 53}, {37, -5}, {14, 42}},
568   {{11, 42}, {6, 52}, {51, -29}, {7, 48}},
569   {{13, 44}, {6, 55}, {39, -9}, {4, 56}},
570   {{16, 45}, {11, 45}, {52, -34}, {4, 52}},
571   {{12, 41}, {14, 36}, {69, -58}, {13, 37}},
572   {{10, 49}, {8, 53}, {67, -63}, {9, 49}},
573   {{30, 34}, { -1, 82}, {44, -5}, {19, 58}},
574   {{18, 42}, {7, 55}, {32, 7}, {10, 48}},
575   {{10, 55}, { -3, 78}, {55, -29}, {12, 45}},
576   {{17, 51}, {15, 46}, {32, 1}, {0, 69}},
577   {{17, 46}, {22, 31}, {0, 0}, {20, 33}},
578   {{0, 89}, { -1, 84}, {27, 36}, {8, 63}},
579   {{26, -19}, {25, 7}, {33, -25}, {35, -18}},
580   {{22, -17}, {30, -7}, {34, -30}, {33, -25}},
581   {{26, -17}, {28, 3}, {36, -28}, {28, -3}},
582   {{30, -25}, {28, 4}, {38, -28}, {24, 10}},
583   {{28, -20}, {32, 0}, {38, -27}, {27, 0}},
584   {{33, -23}, {34, -1}, {34, -18}, {34, -14}},
585   {{37, -27}, {30, 6}, {35, -16}, {52, -44}},
586   {{33, -23}, {30, 6}, {34, -14}, {39, -24}},
587   {{40, -28}, {32, 9}, {32, -8}, {19, 17}},
588   {{38, -17}, {31, 19}, {37, -6}, {31, 25}},
589   {{33, -11}, {26, 27}, {35, 0}, {36, 29}},
590   {{40, -15}, {26, 30}, {30, 10}, {24, 33}},
591   {{41, -6}, {37, 20}, {28, 18}, {34, 15}},
592   {{38, 1}, {28, 34}, {26, 25}, {30, 20}},
593   {{41, 17}, {17, 70}, {29, 41}, {22, 73}},
594   {{30, -6}, {1, 67}, {0, 75}, {20, 34}},
595   {{27, 3}, {5, 59}, {2, 72}, {19, 31}},
596   {{26, 22}, {9, 67}, {8, 77}, {27, 44}},
597   {{37, -16}, {16, 30}, {14, 35}, {19, 16}},
598   {{35, -4}, {18, 32}, {18, 31}, {15, 36}},
599   {{38, -8}, {18, 35}, {17, 35}, {15, 36}},
600   {{38, -3}, {22, 29}, {21, 30}, {21, 28}},
601   {{37, 3}, {24, 31}, {17, 45}, {25, 21}},
602   {{38, 5}, {23, 38}, {20, 42}, {30, 20}},
603   {{42, 0}, {18, 43}, {18, 45}, {31, 12}},
604   {{35, 16}, {20, 41}, {27, 26}, {27, 16}},
605   {{39, 22}, {11, 63}, {16, 54}, {24, 42}},
606   {{14, 48}, {9, 59}, {7, 66}, {0, 93}},
607   {{27, 37}, {9, 64}, {16, 56}, {14, 56}},
608   {{21, 60}, { -1, 94}, {11, 73}, {15, 57}},
609   {{12, 68}, { -2, 89}, {10, 67}, {26, 38}},
610   {{2, 97}, { -9, 108}, { -10, 116}, { -24, 127}},
611   //227-275 Table 9-21
612   {{ -3, 71}, { -6, 76}, { -23, 112}, { -24, 115}},
613   {{ -6, 42}, { -2, 44}, { -15, 71}, { -22, 82}},
614   {{ -5, 50}, {0, 45}, { -7, 61}, { -9, 62}},
615   {{ -3, 54}, {0, 52}, {0, 53}, {0, 53}},
616   {{ -2, 62}, { -3, 64}, { -5, 66}, {0, 59}},
617   {{0, 58}, { -2, 59}, { -11, 77}, { -14, 85}},
618   {{1, 63}, { -4, 70}, { -9, 80}, { -13, 89}},
619   {{ -2, 72}, { -4, 75}, { -9, 84}, { -13, 94}},
620   {{ -1, 74}, { -8, 82}, { -10, 87}, { -11, 92}},
621   {{ -9, 91}, { -17, 102}, { -34, 127}, { -29, 127}},
622   {{ -5, 67}, { -9, 77}, { -21, 101}, { -21, 100}},
623   {{ -5, 27}, {3, 24}, { -3, 39}, { -14, 57}},
624   {{ -3, 39}, {0, 42}, { -5, 53}, { -12, 67}},
625   {{ -2, 44}, {0, 48}, { -7, 61}, { -11, 71}},
626   {{0, 46}, {0, 55}, { -11, 75}, { -10, 77}},
627   {{ -16, 64}, { -6, 59}, { -15, 77}, { -21, 85}},
628   {{ -8, 68}, { -7, 71}, { -17, 91}, { -16, 88}},
629   {{ -10, 78}, { -12, 83}, { -25, 107}, { -23, 104}},
630   {{ -6, 77}, { -11, 87}, { -25, 111}, { -15, 98}},
631   {{ -10, 86}, { -30, 119}, { -28, 122}, { -37, 127}},
632   {{ -12, 92}, {1, 58}, { -11, 76}, { -10, 82}},
633   {{ -15, 55}, { -3, 29}, { -10, 44}, { -8, 48}},
634   {{ -10, 60}, { -1, 36}, { -10, 52}, { -8, 61}},
635   {{ -6, 62}, {1, 38}, { -10, 57}, { -8, 66}},
636   {{ -4, 65}, {2, 43}, { -9, 58}, { -7, 70}},
637   {{ -12, 73}, { -6, 55}, { -16, 72}, { -14, 75}},
638   {{ -8, 76}, {0, 58}, { -7, 69}, { -10, 79}},
639   {{ -7, 80}, {0, 64}, { -4, 69}, { -9, 83}},
640   {{ -9, 88}, { -3, 74}, { -5, 74}, { -12, 92}},
641   {{ -17, 110}, { -10, 90}, { -9, 86}, { -18, 108}},
642   {{ -11, 97}, {0, 70}, {2, 66}, { -4, 79}},
643   {{ -20, 84}, { -4, 29}, { -9, 34}, { -22, 69}},
644   {{ -11, 79}, {5, 31}, {1, 32}, { -16, 75}},
645   {{ -6, 73}, {7, 42}, {11, 31}, { -2, 58}},
646   {{ -4, 74}, {1, 59}, {5, 52}, {1, 58}},
647   {{ -13, 86}, { -2, 58}, { -2, 55}, { -13, 78}},
648   {{ -13, 96}, { -3, 72}, { -2, 67}, { -9, 83}},
649   {{ -11, 97}, { -3, 81}, {0, 73}, { -4, 81}},
650   {{ -19, 117}, { -11, 97}, { -8, 89}, { -13, 99}},
651   {{ -8, 78}, {0, 58}, {3, 52}, { -13, 81}},
652   {{ -5, 33}, {8, 5}, {7, 4}, { -6, 38}},
653   {{ -4, 48}, {10, 14}, {10, 8}, { -13, 62}},
654   {{ -2, 53}, {14, 18}, {17, 8}, { -6, 58}},
655   {{ -3, 62}, {13, 27}, {16, 19}, { -2, 59}},
656   {{ -13, 71}, {2, 40}, {3, 37}, { -16, 73}},
657   {{ -10, 79}, {0, 58}, { -1, 61}, { -10, 76}},
658   {{ -12, 86}, { -3, 70}, { -5, 73}, { -13, 86}},
659   {{ -13, 90}, { -6, 79}, { -1, 70}, { -9, 83}},
660   {{ -14, 97}, { -8, 85}, { -4, 78}, { -10, 87}},
661   //276 no use
662   {{CTX_NA, CTX_NA}, {CTX_NA, CTX_NA}, {CTX_NA, CTX_NA}, {CTX_NA, CTX_NA}},
663   //277-337 Table 9-22
664   {{ -6, 93}, { -13, 106}, { -21, 126}, { -22, 127}},
665   {{ -6, 84}, { -16, 106}, { -23, 124}, { -25, 127}},
666   {{ -8, 79}, { -10, 87}, { -20, 110}, { -25, 120}},
667   {{0, 66}, { -21, 114}, { -26, 126}, { -27, 127}},
668   {{ -1, 71}, { -18, 110}, { -25, 124}, { -19, 114}},
669   {{0, 62}, { -14, 98}, { -17, 105}, { -23, 117}},
670   {{ -2, 60}, { -22, 110}, { -27, 121}, { -25, 118}},
671   {{ -2, 59}, { -21, 106}, { -27, 117}, { -26, 117}},
672   {{ -5, 75}, { -18, 103}, { -17, 102}, { -24, 113}},
673   {{ -3, 62}, { -21, 107}, { -26, 117}, { -28, 118}},
674   {{ -4, 58}, { -23, 108}, { -27, 116}, { -31, 120}},
675   {{ -9, 66}, { -26, 112}, { -33, 122}, { -37, 124}},
676   {{ -1, 79}, { -10, 96}, { -10, 95}, { -10, 94}},
677   {{0, 71}, { -12, 95}, { -14, 100}, { -15, 102}},
678   {{3, 68}, { -5, 91}, { -8, 95}, { -10, 99}},
679   {{10, 44}, { -9, 93}, { -17, 111}, { -13, 106}},
680   {{ -7, 62}, { -22, 94}, { -28, 114}, { -50, 127}},
681   {{15, 36}, { -5, 86}, { -6, 89}, { -5, 92}},
682   {{14, 40}, {9, 67}, { -2, 80}, {17, 57}},
683   {{16, 27}, { -4, 80}, { -4, 82}, { -5, 86}},
684   {{12, 29}, { -10, 85}, { -9, 85}, { -13, 94}},
685   {{1, 44}, { -1, 70}, { -8, 81}, { -12, 91}},
686   {{20, 36}, {7, 60}, { -1, 72}, { -2, 77}},
687   {{18, 32}, {9, 58}, {5, 64}, {0, 71}},
688   {{5, 42}, {5, 61}, {1, 67}, { -1, 73}},
689   {{1, 48}, {12, 50}, {9, 56}, {4, 64}},
690   {{10, 62}, {15, 50}, {0, 69}, { -7, 81}},
691   {{17, 46}, {18, 49}, {1, 69}, {5, 64}},
692   {{9, 64}, {17, 54}, {7, 69}, {15, 57}},
693   {{ -12, 104}, {10, 41}, { -7, 69}, {1, 67}},
694   {{ -11, 97}, {7, 46}, { -6, 67}, {0, 68}},
695   {{ -16, 96}, { -1, 51}, { -16, 77}, { -10, 67}},
696   {{ -7, 88}, {7, 49}, { -2, 64}, {1, 68}},
697   {{ -8, 85}, {8, 52}, {2, 61}, {0, 77}},
698   {{ -7, 85}, {9, 41}, { -6, 67}, {2, 64}},
699   {{ -9, 85}, {6, 47}, { -3, 64}, {0, 68}},
700   {{ -13, 88}, {2, 55}, {2, 57}, { -5, 78}},
701   {{4, 66}, {13, 41}, { -3, 65}, {7, 55}},
702   {{ -3, 77}, {10, 44}, { -3, 66}, {5, 59}},
703   {{ -3, 76}, {6, 50}, {0, 62}, {2, 65}},
704   {{ -6, 76}, {5, 53}, {9, 51}, {14, 54}},
705   {{10, 58}, {13, 49}, { -1, 66}, {15, 44}},
706   {{ -1, 76}, {4, 63}, { -2, 71}, {5, 60}},
707   {{ -1, 83}, {6, 64}, { -2, 75}, {2, 70}},
708   {{ -7, 99}, { -2, 69}, { -1, 70}, { -2, 76}},
709   {{ -14, 95}, { -2, 59}, { -9, 72}, { -18, 86}},
710   {{2, 95}, {6, 70}, {14, 60}, {12, 70}},
711   {{0, 76}, {10, 44}, {16, 37}, {5, 64}},
712   {{ -5, 74}, {9, 31}, {0, 47}, { -12, 70}},
713   {{0, 70}, {12, 43}, {18, 35}, {11, 55}},
714   {{ -11, 75}, {3, 53}, {11, 37}, {5, 56}},
715   {{1, 68}, {14, 34}, {12, 41}, {0, 69}},
716   {{0, 65}, {10, 38}, {10, 41}, {2, 65}},
717   {{ -14, 73}, { -3, 52}, {2, 48}, { -6, 74}},
718   {{3, 62}, {13, 40}, {12, 41}, {5, 54}},
719   {{4, 62}, {17, 32}, {13, 41}, {7, 54}},
720   {{ -1, 68}, {7, 44}, {0, 59}, { -6, 76}},
721   {{ -13, 75}, {7, 38}, {3, 50}, { -11, 82}},
722   {{11, 55}, {13, 50}, {19, 40}, { -2, 77}},
723   {{5, 64}, {10, 57}, {3, 66}, { -2, 77}},
724   {{12, 70}, {26, 43}, {18, 50}, {25, 42}},
725   //338-398 Table9-23
726   {{15, 6}, {14, 11}, {19, -6}, {17, -13}},
727   {{6, 19}, {11, 14}, {18, -6}, {16, -9}},
728   {{7, 16}, {9, 11}, {14, 0}, {17, -12}},
729   {{12, 14}, {18, 11}, {26, -12}, {27, -21}},
730   {{18, 13}, {21, 9}, {31, -16}, {37, -30}},
731   {{13, 11}, {23, -2}, {33, -25}, {41, -40}},
732   {{13, 15}, {32, -15}, {33, -22}, {42, -41}},
733   {{15, 16}, {32, -15}, {37, -28}, {48, -47}},
734   {{12, 23}, {34, -21}, {39, -30}, {39, -32}},
735   {{13, 23}, {39, -23}, {42, -30}, {46, -40}},
736   {{15, 20}, {42, -33}, {47, -42}, {52, -51}},
737   {{14, 26}, {41, -31}, {45, -36}, {46, -41}},
738   {{14, 44}, {46, -28}, {49, -34}, {52, -39}},
739   {{17, 40}, {38, -12}, {41, -17}, {43, -19}},
740   {{17, 47}, {21, 29}, {32, 9}, {32, 11}},
741   {{24, 17}, {45, -24}, {69, -71}, {61, -55}},
742   {{21, 21}, {53, -45}, {63, -63}, {56, -46}},
743   {{25, 22}, {48, -26}, {66, -64}, {62, -50}},
744   {{31, 27}, {65, -43}, {77, -74}, {81, -67}},
745   {{22, 29}, {43, -19}, {54, -39}, {45, -20}},
746   {{19, 35}, {39, -10}, {52, -35}, {35, -2}},
747   {{14, 50}, {30, 9}, {41, -10}, {28, 15}},
748   {{10, 57}, {18, 26}, {36, 0}, {34, 1}},
749   {{7, 63}, {20, 27}, {40, -1}, {39, 1}},
750   {{ -2, 77}, {0, 57}, {30, 14}, {30, 17}},
751   {{ -4, 82}, { -14, 82}, {28, 26}, {20, 38}},
752   {{ -3, 94}, { -5, 75}, {23, 37}, {18, 45}},
753   {{9, 69}, { -19, 97}, {12, 55}, {15, 54}},
754   {{ -12, 109}, { -35, 125}, {11, 65}, {0, 79}},
755   {{36, -35}, {27, 0}, {37, -33}, {36, -16}},
756   {{36, -34}, {28, 0}, {39, -36}, {37, -14}},
757   {{32, -26}, {31, -4}, {40, -37}, {37, -17}},
758   {{37, -30}, {27, 6}, {38, -30}, {32, 1}},
759   {{44, -32}, {34, 8}, {46, -33}, {34, 15}},
760   {{34, -18}, {30, 10}, {42, -30}, {29, 15}},
761   {{34, -15}, {24, 22}, {40, -24}, {24, 25}},
762   {{40, -15}, {33, 19}, {49, -29}, {34, 22}},
763   {{33, -7}, {22, 32}, {38, -12}, {31, 16}},
764   {{35, -5}, {26, 31}, {40, -10}, {35, 18}},
765   {{33, 0}, {21, 41}, {38, -3}, {31, 28}},
766   {{38, 2}, {26, 44}, {46, -5}, {33, 41}},
767   {{33, 13}, {23, 47}, {31, 20}, {36, 28}},
768   {{23, 35}, {16, 65}, {29, 30}, {27, 47}},
769   {{13, 58}, {14, 71}, {25, 44}, {21, 62}},
770   {{29, -3}, {8, 60}, {12, 48}, {18, 31}},
771   {{26, 0}, {6, 63}, {11, 49}, {19, 26}},
772   {{22, 30}, {17, 65}, {26, 45}, {36, 24}},
773   {{31, -7}, {21, 24}, {22, 22}, {24, 23}},
774   {{35, -15}, {23, 20}, {23, 22}, {27, 16}},
775   {{34, -3}, {26, 23}, {27, 21}, {24, 30}},
776   {{34, 3}, {27, 32}, {33, 20}, {31, 29}},
777   {{36, -1}, {28, 23}, {26, 28}, {22, 41}},
778   {{34, 5}, {28, 24}, {30, 24}, {22, 42}},
779   {{32, 11}, {23, 40}, {27, 34}, {16, 60}},
780   {{35, 5}, {24, 32}, {18, 42}, {15, 52}},
781   {{34, 12}, {28, 29}, {25, 39}, {14, 60}},
782   {{39, 11}, {23, 42}, {18, 50}, {3, 78}},
783   {{30, 29}, {19, 57}, {12, 70}, { -16, 123}},
784   {{34, 26}, {22, 53}, {21, 54}, {21, 53}},
785   {{29, 39}, {22, 61}, {14, 71}, {22, 56}},
786   {{19, 66}, {11, 86}, {11, 83}, {25, 61}},
787   {{31, 21}, {12, 40}, {25, 32}, {21, 33}},
788   {{31, 31}, {11, 51}, {21, 49}, {19, 50}},
789   {{25, 50}, {14, 59}, {21, 54}, {17, 61}},
790   //402-459 Table 9-24
791   {{ -17, 120}, { -4, 79}, { -5, 85}, { -3, 78}},
792   {{ -20, 112}, { -7, 71}, { -6, 81}, { -8, 74}},
793   {{ -18, 114}, { -5, 69}, { -10, 77}, { -9, 72}},
794   {{ -11, 85}, { -9, 70}, { -7, 81}, { -10, 72}},
795   {{ -15, 92}, { -8, 66}, { -17, 80}, { -18, 75}},
796   {{ -14, 89}, { -10, 68}, { -18, 73}, { -12, 71}},
797   {{ -26, 71}, { -19, 73}, { -4, 74}, { -11, 63}},
798   {{ -15, 81}, { -12, 69}, { -10, 83}, { -5, 70}},
799   {{ -14, 80}, { -16, 70}, { -9, 71}, { -17, 75}},
800   {{0, 68}, { -15, 67}, { -9, 67}, { -14, 72}},
801   {{ -14, 70}, { -20, 62}, { -1, 61}, { -16, 67}},
802   {{ -24, 56}, { -19, 70}, { -8, 66}, { -8, 53}},
803   {{ -23, 68}, { -16, 66}, { -14, 66}, { -14, 59}},
804   {{ -24, 50}, { -22, 65}, {0, 59}, { -9, 52}},
805   {{ -11, 74}, { -20, 63}, {2, 59}, { -11, 68}},
806   {{23, -13}, {9, -2}, {17, -10}, {9, -2}},
807   {{26, -13}, {26, -9}, {32, -13}, {30, -10}},
808   {{40, -15}, {33, -9}, {42, -9}, {31, -4}},
809   {{49, -14}, {39, -7}, {49, -5}, {33, -1}},
810   {{44, 3}, {41, -2}, {53, 0}, {33, 7}},
811   {{45, 6}, {45, 3}, {64, 3}, {31, 12}},
812   {{44, 34}, {49, 9}, {68, 10}, {37, 23}},
813   {{33, 54}, {45, 27}, {66, 27}, {31, 38}},
814   {{19, 82}, {36, 59}, {47, 57}, {20, 64}},
815   {{ -3, 75}, { -6, 66}, { -5, 71}, { -9, 71}},
816   {{ -1, 23}, { -7, 35}, {0, 24}, { -7, 37}},
817   {{1, 34}, { -7, 42}, { -1, 36}, { -8, 44}},
818   {{1, 43}, { -8, 45}, { -2, 42}, { -11, 49}},
819   {{0, 54}, { -5, 48}, { -2, 52}, { -10, 56}},
820   {{ -2, 55}, { -12, 56}, { -9, 57}, { -12, 59}},
821   {{0, 61}, { -6, 60}, { -6, 63}, { -8, 63}},
822   {{1, 64}, { -5, 62}, { -4, 65}, { -9, 67}},
823   {{0, 68}, { -8, 66}, { -4, 67}, { -6, 68}},
824   {{ -9, 92}, { -8, 76}, { -7, 82}, { -10, 79}},
825   {{ -14, 106}, { -5, 85}, { -3, 81}, { -3, 78}},
826   {{ -13, 97}, { -6, 81}, { -3, 76}, { -8, 74}},
827   {{ -15, 90}, { -10, 77}, { -7, 72}, { -9, 72}},
828   {{ -12, 90}, { -7, 81}, { -6, 78}, { -10, 72}},
829   {{ -18, 88}, { -17, 80}, { -12, 72}, { -18, 75}},
830   {{ -10, 73}, { -18, 73}, { -14, 68}, { -12, 71}},
831   {{ -9, 79}, { -4, 74}, { -3, 70}, { -11, 63}},
832   {{ -14, 86}, { -10, 83}, { -6, 76}, { -5, 70}},
833   {{ -10, 73}, { -9, 71}, { -5, 66}, { -17, 75}},
834   {{ -10, 70}, { -9, 67}, { -5, 62}, { -14, 72}},
835   {{ -10, 69}, { -1, 61}, {0, 57}, { -16, 67}},
836   {{ -5, 66}, { -8, 66}, { -4, 61}, { -8, 53}},
837   {{ -9, 64}, { -14, 66}, { -9, 60}, { -14, 59}},
838   {{ -5, 58}, {0, 59}, {1, 54}, { -9, 52}},
839   {{2, 59}, {2, 59}, {2, 58}, { -11, 68}},
840   {{21, -10}, {21, -13}, {17, -10}, {9, -2}},
841   {{24, -11}, {33, -14}, {32, -13}, {30, -10}},
842   {{28, -8}, {39, -7}, {42, -9}, {31, -4}},
843   {{28, -1}, {46, -2}, {49, -5}, {33, -1}},
844   {{29, 3}, {51, 2}, {53, 0}, {33, 7}},
845   {{29, 9}, {60, 6}, {64, 3}, {31, 12}},
846   {{35, 20}, {61, 17}, {68, 10}, {37, 23}},
847   {{29, 36}, {55, 34}, {66, 27}, {31, 38}},
848   {{14, 67}, {42, 62}, {47, 57}, {20, 64}},
849 };
850 
851 /*Table 9-44 – Specification of rangeTabLPS depending on pStateIdx and qCodIRangeIdx */
852 
853 const uint8_t g_kuiCabacRangeLps[64][4] = {
854   { 128, 176, 208, 240}, { 128, 167, 197, 227}, { 128, 158, 187, 216}, { 123, 150, 178, 205}, { 116, 142, 169, 195}, { 111, 135, 160, 185}, { 105, 128, 152, 175}, { 100, 122, 144, 166},
855   {  95, 116, 137, 158}, {  90, 110, 130, 150}, {  85, 104, 123, 142}, {  81,  99, 117, 135}, {  77,  94, 111, 128}, {  73,  89, 105, 122}, {  69,  85, 100, 116}, {  66,  80,  95, 110},
856   {  62,  76,  90, 104}, {  59,  72,  86,  99}, {  56,  69,  81,  94}, {  53,  65,  77,  89}, {  51,  62,  73,  85}, {  48,  59,  69,  80}, {  46,  56,  66,  76}, {  43,  53,  63,  72},
857   {  41,  50,  59,  69}, {  39,  48,  56,  65}, {  37,  45,  54,  62}, {  35,  43,  51,  59}, {  33,  41,  48,  56}, {  32,  39,  46,  53}, {  30,  37,  43,  50}, {  29,  35,  41,  48},
858   {  27,  33,  39,  45}, {  26,  31,  37,  43}, {  24,  30,  35,  41}, {  23,  28,  33,  39}, {  22,  27,  32,  37}, {  21,  26,  30,  35}, {  20,  24,  29,  33}, {  19,  23,  27,  31},
859   {  18,  22,  26,  30}, {  17,  21,  25,  28}, {  16,  20,  23,  27}, {  15,  19,  22,  25}, {  14,  18,  21,  24}, {  14,  17,  20,  23}, {  13,  16,  19,  22}, {  12,  15,  18,  21},
860   {  12,  14,  17,  20}, {  11,  14,  16,  19}, {  11,  13,  15,  18}, {  10,  12,  15,  17}, {  10,  12,  14,  16}, {   9,  11,  13,  15}, {   9,  11,  12,  14}, {   8,  10,  12,  14},
861   {   8,   9,  11,  13}, {   7,   9,  11,  12}, {   7,   9,  10,  12}, {   7,   8,  10,  11}, {   6,   8,   9,  11}, {   6,   7,   9,  10}, {   6,   7,   8,   9}, {   2,   2,   2,   2}
862 };
863 
864 /*Table 9-45 – State transition table*/
865 
866 const uint8_t g_kuiStateTransTable[64][2] = {
867 
868   {0, 1}, {0, 2}, {1, 3}, {2, 4}, {2, 5}, {4, 6}, {4, 7}, {5, 8}, {6, 9}, {7, 10},
869 
870   {8, 11}, {9, 12}, {9, 13}, {11, 14}, {11, 15}, {12, 16}, {13, 17}, {13, 18}, {15, 19}, {15, 20},
871 
872   {16, 21}, {16, 22}, {18, 23}, {18, 24}, {19, 25}, {19, 26}, {21, 27}, {21, 28}, {22, 29}, {22, 30},
873 
874   {23, 31}, {24, 32}, {24, 33}, {25, 34}, {26, 35}, {26, 36}, {27, 37}, {27, 38}, {28, 39}, {29, 40},
875 
876   {29, 41}, {30, 42}, {30, 43}, {30, 44}, {31, 45}, {32, 46}, {32, 47}, {33, 48}, {33, 49}, {33, 50},
877 
878   {34, 51}, {34, 52}, {35, 53}, {35, 54}, {35, 55}, {36, 56}, {36, 57}, {36, 58}, {37, 59}, {37, 60},
879 
880   {37, 61}, {38, 62}, {38, 62}, {63, 63}
881 
882 };
883 
884 // extern at svc_enc_golomb.h, golomb_common.h
885 
886 const uint32_t g_kuiGolombUELength[256] = {
887   1,  3,  3,  5,  5,  5,  5,  7,  7,  7,  7,  7,  7,  7,  7,     //14
888   9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9, //30
889   11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,//46
890   11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,//62
891   13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,//
892   13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
893   13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
894   13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
895   15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
896   15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
897   15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
898   15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
899   15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
900   15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
901   15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
902   15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
903   17
904 };
905 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
906 }
907