ih264_common_tables.c revision 23461c3cb019e6246ed841ac82564742ae288db3
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/**
21*******************************************************************************
22* @file
23*  ih264_common_tables.c
24*
25* @brief
26*  Contains common global tables
27*
28* @author
29*  Harish M
30*
31* @par List of Functions:
32*
33* @remarks
34*  None
35*
36*******************************************************************************
37*/
38
39/*****************************************************************************/
40/* File Includes                                                             */
41/*****************************************************************************/
42
43/* User include files */
44#include "ih264_typedefs.h"
45#include "ih264_defs.h"
46#include "ih264_macros.h"
47#include "ih264_structs.h"
48#include "ih264_common_tables.h"
49
50
51/*****************************************************************************/
52/* Extern global definitions                                                 */
53/*****************************************************************************/
54
55/**
56 ******************************************************************************
57 * @brief  while encoding, basing on the input configuration parameters, the
58 * the level of the bitstream is computed basing on the table below.
59 * input  : table_idx
60 * output : level_idc or cpb size
61 * @remarks Table A-1 � level table limits
62 ******************************************************************************
63 */
64const level_tables_t gas_ih264_lvl_tbl[16] =
65{
66    { IH264_LEVEL_10,    1485,       99,         297,       64,         175,         64  },
67    { IH264_LEVEL_11,    1485,       99,         297,       128,        350,         64  },
68    { IH264_LEVEL_1B,    3000,       396,        675,       192,        500,         128 },
69    { IH264_LEVEL_12,    6000,       396,        1782,      384,        1000,        128 },
70    { IH264_LEVEL_13,    11880,      396,        1782,      768,        2000,        128 },
71    { IH264_LEVEL_20,    11880,      396,        1782,      2000,       2000,        128 },
72    { IH264_LEVEL_21,    19800,      792,        3564,      4000,       4000,        256 },
73    { IH264_LEVEL_22,    20250,      1620,       6075,      4000,       4000,        256 },
74    { IH264_LEVEL_30,    40500,      1620,       6075,      10000,      10000,       256 },
75    { IH264_LEVEL_31,    108000,     3600,       13500,     14000,      14000,       512 },
76    { IH264_LEVEL_32,    216000,     5120,       15360,     20000,      20000,       512 },
77    { IH264_LEVEL_40,    245760,     8192,       24576,     20000,      25000,       512 },
78    { IH264_LEVEL_41,    245760,     8192,       24576,     50000,      62500,       512 },
79    { IH264_LEVEL_42,    522240,     8704,       26112,     50000,      62500,       512 },
80    { IH264_LEVEL_50,    589824,     22080,      82800,     135000,     135000,      512 },
81    { IH264_LEVEL_51,    983040,     36864,      138240,    240000,     240000,      512 },
82};
83
84
85/**
86 * Array containing supported levels
87 */
88const WORD32 gai4_ih264_levels[] =
89{
90    IH264_LEVEL_10,
91    IH264_LEVEL_11,
92    IH264_LEVEL_12,
93    IH264_LEVEL_13,
94    IH264_LEVEL_20,
95    IH264_LEVEL_21,
96    IH264_LEVEL_22,
97    IH264_LEVEL_30,
98    IH264_LEVEL_31,
99    IH264_LEVEL_32,
100    IH264_LEVEL_40,
101    IH264_LEVEL_41,
102    IH264_LEVEL_42,
103    IH264_LEVEL_50,
104    IH264_LEVEL_51,
105};
106
107
108/**
109 * Array giving size of max luma samples in a picture for a given level
110 */
111const WORD32 gai4_ih264_max_luma_pic_size[] =
112{
113    /* Level 1 */
114    25344,
115    /* Level 1.1 */
116    101376,
117    /* Level 1.2 */
118    101376,
119    /* Level 1.3 */
120    101376,
121    /* Level 2 */
122    101376,
123    /* Level 2.1 */
124    202752,
125    /* Level 2.2 */
126    414720,
127    /* Level 3 */
128    414720,
129    /* Level 3.1 */
130    921600,
131    /* Level 3.2 */
132    1310720,
133    /* Level 4 */
134    2097152,
135    /* Level 4.1 */
136    2097152,
137    /* Level 4.2 */
138    2228224,
139    /* Level 5 */
140    5652480,
141    /* Level 5.1 */
142    9437184
143};
144
145
146/** Max width and height allowed for a given level */
147/** This is derived as SQRT(8 * gai4_ih264_max_luma_pic_size[]) */
148const WORD32 gai4_ih264_max_wd_ht[] =
149{
150    /* Level 1 */
151    451,
152    /* Level 1.1 */
153    901,
154    /* Level 1.2 */
155    901,
156    /* Level 1.3 */
157    901,
158    /* Level 2 */
159    901,
160    /* Level 2.1 */
161    1274,
162    /* Level 2.2 */
163    1822,
164    /* Level 3 */
165    1822,
166    /* Level 3.1 */
167    2716,
168    /* Level 3.2 */
169    3239,
170    /* Level 4 */
171    4096,
172    /* Level 4.1 */
173    4096,
174    /* Level 4.2 */
175    4223,
176    /* Level 5 */
177    6725,
178    /* Level 5.1 */
179    8689
180};
181
182/** Min width and height allowed for a given level */
183/** This is derived as gai4_ih264_max_luma_pic_size[]/gai4_ih264_max_wd_ht[] */
184const WORD32 gai4_ih264_min_wd_ht[] =
185{
186    /* Level 1 */
187    57,
188    /* Level 1.1 */
189    113,
190    /* Level 1.2 */
191    113,
192    /* Level 1.3 */
193    113,
194    /* Level 2 */
195    113,
196    /* Level 2.1 */
197    160,
198    /* Level 2.2 */
199    228,
200    /* Level 3 */
201    228,
202    /* Level 3.1 */
203    340,
204    /* Level 3.2 */
205    405,
206    /* Level 4 */
207    512,
208    /* Level 4.1 */
209    512,
210    /* Level 4.2 */
211    528,
212    /* Level 5 */
213    841,
214    /* Level 5.1 */
215    1087
216
217};
218
219
220/** Table 7-11 Macroblock types for I slices */
221intra_mbtype_info_t gas_ih264_i_mbtype_info[] =
222{
223    /* For first entry, if transform_size_8x8_flag is 1, mode will be MBPART_I8x8 */
224    /* This has to be taken care while accessing the table */
225    {0, MBPART_I4x4,   VERT_I16x16,     0,  0},
226    {0, MBPART_I16x16, VERT_I16x16,     0,  0},
227    {0, MBPART_I16x16, HORZ_I16x16,     0,  0},
228    {0, MBPART_I16x16, DC_I16x16,       0,  0},
229    {0, MBPART_I16x16, PLANE_I16x16,    0,  0},
230    {0, MBPART_I16x16, VERT_I16x16,     1,  0},
231    {0, MBPART_I16x16, HORZ_I16x16,     1,  0},
232    {0, MBPART_I16x16, DC_I16x16,       1,  0},
233    {0, MBPART_I16x16, PLANE_I16x16,    1,  0},
234    {0, MBPART_I16x16, VERT_I16x16,     2,  0},
235    {0, MBPART_I16x16, HORZ_I16x16,     2,  0},
236    {0, MBPART_I16x16, DC_I16x16,       2,  0},
237    {0, MBPART_I16x16, PLANE_I16x16,    2,  0},
238    {0, MBPART_I16x16, VERT_I16x16,     0,  15},
239    {0, MBPART_I16x16, HORZ_I16x16,     0,  15},
240    {0, MBPART_I16x16, DC_I16x16,       0,  15},
241    {0, MBPART_I16x16, PLANE_I16x16,    0,  15},
242    {0, MBPART_I16x16, VERT_I16x16,     1,  15},
243    {0, MBPART_I16x16, HORZ_I16x16,     1,  15},
244    {0, MBPART_I16x16, DC_I16x16,       1,  15},
245    {0, MBPART_I16x16, PLANE_I16x16,    1,  15},
246    {0, MBPART_I16x16, VERT_I16x16,     2,  15},
247    {0, MBPART_I16x16, HORZ_I16x16,     2,  15},
248    {0, MBPART_I16x16, DC_I16x16,       2,  15},
249    {0, MBPART_I16x16, PLANE_I16x16,    2,  15},
250    {0, MBPART_IPCM,   VERT_I16x16,     0,  0}
251};
252
253/** Table 7-13 Macroblock types for P slices */
254inter_mbtype_info_t gas_ih264_p_mbtype_info[] =
255{
256    {1, MBPART_L0,  MBPART_NA,  16, 16},
257    {2, MBPART_L0,  MBPART_L0,  16, 8},
258    {2, MBPART_L0,  MBPART_L0,  8,  16},
259    {4, MBPART_NA,  MBPART_NA,  8,  8},
260    {4, MBPART_NA,  MBPART_NA,  8,  8},
261};
262
263/** Table 7-14 Macroblock types for B slices */
264inter_mbtype_info_t gas_ih264_b_mbtype_info[] =
265{
266    {0, MBPART_DIRECT,  MBPART_NA,  8,  8,  },
267    {1, MBPART_L0,      MBPART_NA,  16, 16, },
268    {1, MBPART_L1,      MBPART_NA,  16, 16, },
269    {1, MBPART_BI,      MBPART_NA,  16, 16, },
270    {2, MBPART_L0,      MBPART_L0,  16, 8,  },
271    {2, MBPART_L0,      MBPART_L0,  8,  16, },
272    {2, MBPART_L1,      MBPART_L1,  16, 8,  },
273    {2, MBPART_L1,      MBPART_L1,  8,  16, },
274    {2, MBPART_L0,      MBPART_L1,  16, 8,  },
275    {2, MBPART_L0,      MBPART_L1,  8,  16, },
276    {2, MBPART_L1,      MBPART_L0,  16, 8,  },
277    {2, MBPART_L1,      MBPART_L0,  8,  16, },
278    {2, MBPART_L0,      MBPART_BI,  16, 8,  },
279    {2, MBPART_L0,      MBPART_BI,  8,  16, },
280    {2, MBPART_L1,      MBPART_BI,  16, 8,  },
281    {2, MBPART_L1,      MBPART_BI,  8,  16, },
282    {2, MBPART_BI,      MBPART_L0,  16, 8,  },
283    {2, MBPART_BI,      MBPART_L0,  8,  16, },
284    {2, MBPART_BI,      MBPART_L1,  16, 8,  },
285    {2, MBPART_BI,      MBPART_L1,  8,  16, },
286    {2, MBPART_BI,      MBPART_BI,  16, 8,  },
287    {2, MBPART_BI,      MBPART_BI,  8,  16, },
288    {4, MBPART_NA,      MBPART_NA,  8,  8,  },
289};
290
291/** Table 7-17 � Sub-macroblock types in P macroblocks */
292submbtype_info_t gas_ih264_p_submbtype_info[] =
293{
294   {1, MBPART_L0, 8,  8},
295   {2, MBPART_L0, 8,  4},
296   {2, MBPART_L0, 4,  8},
297   {4, MBPART_L0, 4,  4},
298};
299
300/** Table 7-18 � Sub-macroblock types in B macroblocks */
301submbtype_info_t gas_ih264_b_submbtype_info[] =
302{
303    {4, MBPART_DIRECT,  4,  4},
304    {1, MBPART_L0,      8,  8},
305    {1, MBPART_L1,      8,  8},
306    {1, MBPART_BI,      8,  8},
307    {2, MBPART_L0,      8,  4},
308    {2, MBPART_L0,      4,  8},
309    {2, MBPART_L1,      8,  4},
310    {2, MBPART_L1,      4,  8},
311    {2, MBPART_BI,      8,  4},
312    {2, MBPART_BI,      4,  8},
313    {4, MBPART_L0,      4,  4},
314    {4, MBPART_L1,      4,  4},
315    {4, MBPART_BI,      4,  4},
316};
317
318
319
320
321const UWORD8 gau1_ih264_inv_scan_prog4x4[] =
322{
323    0,   1,  4,  8,
324    5,   2,  3,  6,
325    9,  12, 13, 10,
326    7,  11, 14, 15
327};
328
329const UWORD8 gau1_ih264_inv_scan_int4x4[] =
330{
331     0, 4,  1,  8,
332    12, 5,  9,  13,
333     2, 6, 10,  14,
334     3, 7, 11,  15
335};
336
337/** Inverse scan tables for individual 4x4 blocks of 8x8 transform coeffs of CAVLC */
338/* progressive */
339const UWORD8 gau1_ih264_inv_scan_prog8x8_cavlc[64] =
340{
341     0,  9, 17, 18, 12, 40, 27,  7,
342    35, 57, 29, 30, 58, 38, 53, 47,
343     1,  2, 24, 11, 19, 48, 20, 14,
344    42, 50, 22, 37, 59, 31, 60, 55,
345     8,  3, 32,  4, 26, 41, 13, 21,
346    49, 43, 15, 44, 52, 39, 61, 62,
347    16, 10, 25,  5, 33, 34,  6, 28,
348    56, 36, 23, 51, 45, 46, 54, 63
349};
350
351/* interlace */
352const UWORD8 gau1_ih264_inv_scan_int8x8_cavlc[64] =
353{
354     0,  9,  2, 56, 18, 26, 34, 27,
355    35, 28, 36, 29, 45,  7, 54, 39,
356     8, 24, 25, 33, 41, 11, 42, 12,
357    43, 13, 44, 14, 53, 15, 62, 47,
358    16, 32, 40, 10, 49,  4, 50,  5,
359    51,  6, 52, 22, 61, 38, 23, 55,
360     1, 17, 48,  3, 57, 19, 58, 20,
361    59, 21, 60, 37, 30, 46, 31, 63
362};
363
364
365
366/*Inverse scan tables for individual 8x8 blocks of 8x8 transform coeffs of CABAC */
367/* progressive */
368
369const UWORD8 gau1_ih264_inv_scan_prog8x8_cabac[64] =
370{
371     0,  1,  8, 16,  9, 2,   3, 10,
372    17, 24, 32, 25, 18, 11,  4,  5,
373    12, 19, 26, 33, 40, 48, 41, 34,
374    27, 20, 13,  6,  7, 14, 21, 28,
375    35, 42, 49, 56, 57, 50, 43, 36,
376    29, 22, 15, 23, 30, 37, 44, 51,
377    58, 59, 52, 45, 38, 31, 39, 46,
378    53, 60, 61, 54, 47, 55, 62, 63
379};
380
381
382/* interlace */
383
384const UWORD8 gau1_ih264_inv_scan_int8x8_cabac[64] =
385{
386     0,  8, 16,  1,  9, 24, 32, 17,
387     2, 25, 40, 48, 56, 33, 10, 3,
388    18, 41, 49, 57, 26, 11,  4, 19,
389    34, 42, 50, 58, 27, 12,  5, 20,
390    35, 43, 51, 59, 28, 13,  6, 21,
391    36, 44, 52, 60, 29, 14, 22, 37,
392    45, 53, 61, 30,  7, 15, 38, 46,
393    54, 62, 23, 31, 39, 47, 55, 63
394};
395
396
397const UWORD8 *gpau1_ih264_inv_scan8x8[] =
398{
399     gau1_ih264_inv_scan_prog8x8_cavlc,
400     gau1_ih264_inv_scan_int8x8_cavlc,
401     gau1_ih264_inv_scan_prog8x8_cabac,
402     gau1_ih264_inv_scan_int8x8_cabac
403};
404
405const UWORD8 *gpau1_ih264_inv_scan4x4[] =
406{
407     gau1_ih264_inv_scan_prog4x4,
408     gau1_ih264_inv_scan_int4x4,
409};
410
411const UWORD8 gau1_ih264_8x8_subblk_idx[] =
412{
413      0,    1,   4,  5,
414      2,    3,   6,  7,
415      8,    9,  12, 13,
416     10,   11,  14, 15
417};
418
419
420/* Table 8-15 Chroma QP offset table */
421const UWORD8 gau1_ih264_chroma_qp[] =
422{
423      0,  1,  2,  3,  4,  5,  6,  7,
424      8,  9, 10, 11, 12, 13, 14, 15,
425     16, 17, 18, 19, 20, 21, 22, 23,
426     24, 25, 26, 27, 28, 29, 29, 30,
427     31, 32, 32, 33, 34, 34, 35, 35,
428     36, 36, 37, 37, 37, 38, 38, 38,
429     39, 39, 39, 39
430};
431
432
433/**
434******************************************************************************
435* @brief  look up table to compute neigbour availability of 4x4 blocks
436* input  : subblk idx, mb neighbor availability
437* output : sub blk neighbor availability
438* @remarks
439******************************************************************************
440*/
441const UWORD8 gau1_ih264_4x4_ngbr_avbl[16][16] =
442{
443    {  0x0, 0x1, 0xc, 0x7, 0x1, 0x1, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 },
444    {  0x1, 0x1, 0xf, 0x7, 0x1, 0x1, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 },
445    {  0x2, 0x1, 0xc, 0x7, 0x1, 0x1, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 },
446    {  0x3, 0x1, 0xf, 0x7, 0x1, 0x1, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 },
447
448    {  0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 },
449    {  0xd, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 },
450    {  0xe, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 },
451    {  0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 },
452
453    {  0x0, 0x1, 0xc, 0x7, 0x1, 0x9, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 },
454    {  0x1, 0x1, 0xf, 0x7, 0x1, 0x9, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 },
455    {  0x2, 0x1, 0xc, 0x7, 0x1, 0x9, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 },
456    {  0x3, 0x1, 0xf, 0x7, 0x1, 0x9, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 },
457
458    {  0xc, 0xf, 0xc, 0x7, 0xf, 0xf, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 },
459    {  0xd, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 },
460    {  0xe, 0xf, 0xc, 0x7, 0xf, 0xf, 0xf, 0x7, 0xc, 0xf, 0xc, 0x7, 0xf, 0x7, 0xf, 0x7 },
461    {  0xf, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0x7, 0xf, 0x7, 0xf, 0x7 },
462};
463
464
465/**
466******************************************************************************
467* @brief  look up table to compute neigbour availability of 8x8 blocks
468* input  : subblk idx, mb neighbor availability
469* output : sub blk neighbor availability
470* @remarks
471******************************************************************************
472*/
473const UWORD8 gau1_ih264_8x8_ngbr_avbl[16][4] =
474{
475    {  0x0, 0x1, 0xc, 0x7 },
476    {  0x1, 0x1, 0xf, 0x7 },
477    {  0x2, 0x1, 0xc, 0x7 },
478    {  0x3, 0x1, 0xf, 0x7 },
479
480    {  0xc, 0x7, 0xc, 0x7 },
481    {  0xd, 0x7, 0xf, 0x7 },
482    {  0xe, 0x7, 0xc, 0x7 },
483    {  0xf, 0x7, 0xf, 0x7 },
484
485    {  0x0, 0x9, 0xc, 0x7 },
486    {  0x1, 0x9, 0xf, 0x7 },
487    {  0x2, 0x9, 0xc, 0x7 },
488    {  0x3, 0x9, 0xf, 0x7 },
489
490    {  0xc, 0xf, 0xc, 0x7 },
491    {  0xd, 0xf, 0xf, 0x7 },
492    {  0xe, 0xf, 0xc, 0x7 },
493    {  0xf, 0xf, 0xf, 0x7 },
494};
495
496/** Table 7-3 Default intra 4x4 scaling list */
497const UWORD16 gau2_ih264_default_intra4x4_scaling_list[] =
498{
499     6, 13, 13, 20,
500    20, 20, 28, 28,
501    28, 28, 32, 32,
502    32, 37, 37, 42
503};
504
505/** Table 7-3 Default inter 4x4 scaling list */
506const UWORD16 gau2_ih264_default_inter4x4_scaling_list[] =
507{
508    10, 14, 14, 20,
509    20, 20, 24, 24,
510    24, 24, 27, 27,
511    27, 30, 30, 34
512};
513
514/* Inverse scanned output of gau2_ih264_default_intra4x4_scaling_list */
515const UWORD16 gau2_ih264_default_intra4x4_weight_scale[] =
516{
517     6, 13, 20, 28,
518    13, 20, 28, 32,
519    20, 28, 32, 37,
520    28, 32, 37, 42
521};
522
523/* Inverse scanned output of gau2_ih264_default_inter4x4_scaling_list */
524const UWORD16 gau2_ih264_default_inter4x4_weight_scale[] =
525{
526     10, 14, 20, 24,
527     14, 20, 24, 27,
528     20, 24, 27, 30,
529     24, 27, 30, 34
530};
531
532/** Table 7-4 Default intra 8x8 scaling list */
533const UWORD16 gau2_ih264_default_intra8x8_scaling_list[] =
534{
535     6, 10, 10, 13, 11, 13, 16, 16,
536    16, 16, 18, 18, 18, 18, 18, 23,
537    23, 23, 23, 23, 23, 25, 25, 25,
538    25, 25, 25, 25, 27, 27, 27, 27,
539    27, 27, 27, 27, 29, 29, 29, 29,
540    29, 29, 29, 31, 31, 31, 31, 31,
541    31, 33, 33, 33, 33, 33, 36, 36,
542    36, 36, 38, 38, 38, 40, 40, 42
543};
544
545/** Table 7-4 Default inter 8x8 scaling list */
546const UWORD16 gau2_ih264_default_inter8x8_scaling_list[] =
547{
548    9,  13, 13, 15, 13, 15, 17, 17,
549    17, 17, 19, 19, 19, 19, 19, 21,
550    21, 21, 21, 21, 21, 22, 22, 22,
551    22, 22, 22, 22, 24, 24, 24, 24,
552    24, 24, 24, 24, 25, 25, 25, 25,
553    25, 25, 25, 27, 27, 27, 27, 27,
554    27, 28, 28, 28, 28, 28, 30, 30,
555    30, 30, 32, 32, 32, 33, 33, 35
556};
557
558/* Inverse scanned output of gau2_ih264_default_intra8x8_scaling_list */
559const UWORD16 gau2_ih264_default_intra8x8_weight_scale[] =
560{
561     6, 10, 13, 16, 18, 23, 25, 27,
562    10, 11, 16, 18, 23, 25, 27, 29,
563    13, 16, 18, 23, 25, 27, 29, 31,
564    16, 18, 23, 25, 27, 29, 31, 33,
565    18, 23, 25, 27, 29, 31, 33, 36,
566    23, 25, 27, 29, 31, 33, 36, 38,
567    25, 27, 29, 31, 33, 36, 38, 40,
568    27, 29, 31, 33, 36, 38, 40, 42
569};
570
571/* Inverse scanned output of gau2_ih264_default_inter8x8_scaling_list */
572const UWORD16 gau2_ih264_default_inter8x8_weight_scale[] =
573{
574     9, 13, 15, 17, 19, 21, 22, 24,
575    13, 13, 17, 19, 21, 22, 24, 25,
576    15, 17, 19, 21, 22, 24, 25, 27,
577    17, 19, 21, 22, 24, 25, 27, 28,
578    19, 21, 22, 24, 25, 27, 28, 30,
579    21, 22, 24, 25, 27, 28, 30, 32,
580    22, 24, 25, 27, 28, 30, 32, 33,
581    24, 25, 27, 28, 30, 32, 33, 35
582};
583/* Eq 7-8 Flat scaling matrix for 4x4 */
584const UWORD16 gau2_ih264_flat_4x4_weight_scale[] =
585{
586    16, 16, 16, 16,
587    16, 16, 16, 16,
588    16, 16, 16, 16,
589    16, 16, 16, 16
590};
591
592/* Eq 7-9 Flat scaling matrix for 8x8 */
593const UWORD16 gau2_ih264_flat_8x8_weight_scale[] =
594{
595    16, 16, 16, 16, 16, 16, 16, 16,
596    16, 16, 16, 16, 16, 16, 16, 16,
597    16, 16, 16, 16, 16, 16, 16, 16,
598    16, 16, 16, 16, 16, 16, 16, 16,
599    16, 16, 16, 16, 16, 16, 16, 16,
600    16, 16, 16, 16, 16, 16, 16, 16,
601    16, 16, 16, 16, 16, 16, 16, 16,
602    16, 16, 16, 16, 16, 16, 16, 16
603};
604
605
606/**
607 ******************************************************************************
608 * @brief  Scale Table for inverse quantizing 4x4 subblock. To inverse quantize
609 * a given 4x4 quantized block, the coefficient at index location (i,j) is scaled
610 * by one of the constants in this table and right shift the result by abs (4 -
611 * floor(qp/6)), here qp is the quantization parameter used to quantize the mb.
612 *
613 * input   : 16 * qp%6, index location (i,j)
614 * output  : scale constant.
615 *
616 * @remarks 16 constants for each index position of the subblock and 6 for each
617 * qp%6 in the range 0-5 inclusive.
618 ******************************************************************************
619 */
620
621const UWORD16 gau2_ih264_iquant_scale_matrix_4x4[96] =
622{
623      10,  13,  10,  13,
624      13,  16,  13,  16,
625      10,  13,  10,  13,
626      13,  16,  13,  16,
627
628      11,  14,  11,  14,
629      14,  18,  14,  18,
630      11,  14,  11,  14,
631      14,  18,  14,  18,
632
633      13,  16,  13,  16,
634      16,  20,  16,  20,
635      13,  16,  13,  16,
636      16,  20,  16,  20,
637
638      14,  18,  14,  18,
639      18,  23,  18,  23,
640      14,  18,  14,  18,
641      18,  23,  18,  23,
642
643      16,  20,  16,  20,
644      20,  25,  20,  25,
645      16,  20,  16,  20,
646      20,  25,  20,  25,
647
648      18,  23,  18,  23,
649      23,  29,  23,  29,
650      18,  23,  18,  23,
651      23,  29,  23,  29,
652
653};
654
655/**
656 ******************************************************************************
657 * @brief  Scale Table for inverse quantizing 8x8 subblock. To inverse quantize
658 * a given 8x8 quantized block, the coefficient at index location (i,j) is scaled
659 * by one of the constants in this table and right shift the result by abs (4 -
660 * floor(qp/6)), here qp is the quantization parameter used to quantize the mb.
661 *
662 * input   : qp%6, index location (i,j)
663 * output  : scale constant.
664 *
665 * @remarks 64 constants for each index position of the subblock and 6 for each
666 * qp%6 in the range 0-5 inclusive.
667 ******************************************************************************
668 */
669const UWORD16 gau2_ih264_iquant_scale_matrix_8x8 [384] =
670{
671      20,  19,  25,  19,  20,  19,  25,  19,
672      19,  18,  24,  18,  19,  18,  24,  18,
673      25,  24,  32,  24,  25,  24,  32,  24,
674      19,  18,  24,  18,  19,  18,  24,  18,
675      20,  19,  25,  19,  20,  19,  25,  19,
676      19,  18,  24,  18,  19,  18,  24,  18,
677      25,  24,  32,  24,  25,  24,  32,  24,
678      19,  18,  24,  18,  19,  18,  24,  18,
679
680      22,  21,  28,  21,  22,  21,  28,  21,
681      21,  19,  26,  19,  21,  19,  26,  19,
682      28,  26,  35,  26,  28,  26,  35,  26,
683      21,  19,  26,  19,  21,  19,  26,  19,
684      22,  21,  28,  21,  22,  21,  28,  21,
685      21,  19,  26,  19,  21,  19,  26,  19,
686      28,  26,  35,  26,  28,  26,  35,  26,
687      21,  19,  26,  19,  21,  19,  26,  19,
688
689      26,  24,  33,  24,  26,  24,  33,  24,
690      24,  23,  31,  23,  24,  23,  31,  23,
691      33,  31,  42,  31,  33,  31,  42,  31,
692      24,  23,  31,  23,  24,  23,  31,  23,
693      26,  24,  33,  24,  26,  24,  33,  24,
694      24,  23,  31,  23,  24,  23,  31,  23,
695      33,  31,  42,  31,  33,  31,  42,  31,
696      24,  23,  31,  23,  24,  23,  31,  23,
697
698      28,  26,  35,  26,  28,  26,  35,  26,
699      26,  25,  33,  25,  26,  25,  33,  25,
700      35,  33,  45,  33,  35,  33,  45,  33,
701      26,  25,  33,  25,  26,  25,  33,  25,
702      28,  26,  35,  26,  28,  26,  35,  26,
703      26,  25,  33,  25,  26,  25,  33,  25,
704      35,  33,  45,  33,  35,  33,  45,  33,
705      26,  25,  33,  25,  26,  25,  33,  25,
706
707      32,  30,  40,  30,  32,  30,  40,  30,
708      30,  28,  38,  28,  30,  28,  38,  28,
709      40,  38,  51,  38,  40,  38,  51,  38,
710      30,  28,  38,  28,  30,  28,  38,  28,
711      32,  30,  40,  30,  32,  30,  40,  30,
712      30,  28,  38,  28,  30,  28,  38,  28,
713      40,  38,  51,  38,  40,  38,  51,  38,
714      30,  28,  38,  28,  30,  28,  38,  28,
715
716      36,  34,  46,  34,  36,  34,  46,  34,
717      34,  32,  43,  32,  34,  32,  43,  32,
718      46,  43,  58,  43,  46,  43,  58,  43,
719      34,  32,  43,  32,  34,  32,  43,  32,
720      36,  34,  46,  34,  36,  34,  46,  34,
721      34,  32,  43,  32,  34,  32,  43,  32,
722      46,  43,  58,  43,  46,  43,  58,  43,
723      34,  32,  43,  32,  34,  32,  43,  32,
724
725};
726