Home | History | Annotate | Download | only in common
      1 /******************************************************************************
      2 *
      3 * Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore
      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 /**
     19 *******************************************************************************
     20 * @file
     21 *  ihevc_trans_tables.c
     22 *
     23 * @brief
     24 *  Contains tables used in forward and inverse quantization
     25 *
     26 * @author
     27 *  100189
     28 *
     29 * @par List of Functions:
     30 *
     31 * @remarks
     32 *  None
     33 *
     34 *******************************************************************************
     35 */
     36 
     37 #include "ihevc_typedefs.h"
     38 #include "ihevc_func_selector.h"
     39 #include "ihevc_quant_tables.h"
     40 #include "ihevc_defs.h"
     41 
     42 
     43 
     44 /**  Default flat Scaling matrix for 32x32 transform
     45  * Since the values are same, 32x32 matrix will be used for all sizes
     46  */
     47 const WORD16 gi2_flat_scale_mat_32x32[] =
     48 {
     49     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     50     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     51     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     52     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     53     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     54     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     55     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     56     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     57     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     58     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     59     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     60     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     61     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     62     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     63     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     64     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     65     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     66     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     67     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     68     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     69     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     70     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     71     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     72     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     73     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     74     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     75     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     76     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     77     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     78     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     79     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
     80     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
     81 
     82 };
     83 
     84 /**
     85 *
     86 * @brief default scaling matrix as specified by standard
     87 * 8x8 intra matrix
     88 *
     89 */
     90 const WORD16 gi2_intra_default_scale_mat_8x8[] =
     91 {
     92     16, 16, 16, 16, 17, 18, 21, 24,
     93     16, 16, 16, 16, 17, 19, 22, 25,
     94     16, 16, 17, 18, 20, 22, 25, 29,
     95     16, 16, 18, 21, 24, 27, 31, 36,
     96     17, 17, 20, 24, 30, 35, 41, 47,
     97     18, 19, 22, 27, 35, 44, 54, 65,
     98     21, 22, 25, 31, 41, 54, 70, 88,
     99     24, 25, 29, 36, 47, 65, 88, 115
    100 };
    101 /**
    102 *
    103 * @brief default scaling matrix as specified by standard
    104 * 8x8 inter matrix
    105 *
    106 */
    107 const WORD16 gi2_inter_default_scale_mat_8x8[] =
    108 {
    109     16, 16, 16, 16, 17, 18, 20, 24,
    110     16, 16, 16, 17, 18, 20, 24, 25,
    111     16, 16, 17, 18, 20, 24, 25, 28,
    112     16, 17, 18, 20, 24, 25, 28, 33,
    113     17, 18, 20, 24, 25, 28, 33, 41,
    114     18, 20, 24, 25, 28, 33, 41, 54,
    115     20, 24, 25, 28, 33, 41, 54, 71,
    116     24, 25, 28, 33, 41, 54, 71, 91
    117 };
    118 /**
    119 *
    120 * @brief default scaling matrix as specified by standard
    121 * 16x16 intra matrix
    122 *
    123 */
    124 const WORD16 gi2_intra_default_scale_mat_16x16[] =
    125 {
    126     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 21, 21, 24,  24,
    127     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 21, 21, 24,  24,
    128     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 19, 19, 22, 22, 25,  25,
    129     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 19, 19, 22, 22, 25,  25,
    130     16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 22, 22, 25, 25, 29,  29,
    131     16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 22, 22, 25, 25, 29,  29,
    132     16, 16, 16, 16, 18, 18, 21, 21, 24, 24, 27, 27, 31, 31, 36,  36,
    133     16, 16, 16, 16, 18, 18, 21, 21, 24, 24, 27, 27, 31, 31, 36,  36,
    134     17, 17, 17, 17, 20, 20, 24, 24, 30, 30, 35, 35, 41, 41, 47,  47,
    135     17, 17, 17, 17, 20, 20, 24, 24, 30, 30, 35, 35, 41, 41, 47,  47,
    136     18, 18, 19, 19, 22, 22, 27, 27, 35, 35, 44, 44, 54, 54, 65,  65,
    137     18, 18, 19, 19, 22, 22, 27, 27, 35, 35, 44, 44, 54, 54, 65,  65,
    138     21, 21, 22, 22, 25, 25, 31, 31, 41, 41, 54, 54, 70, 70, 88,  88,
    139     21, 21, 22, 22, 25, 25, 31, 31, 41, 41, 54, 54, 70, 70, 88,  88,
    140     24, 24, 25, 25, 29, 29, 36, 36, 47, 47, 65, 65, 88, 88, 115, 115,
    141     24, 24, 25, 25, 29, 29, 36, 36, 47, 47, 65, 65, 88, 88, 115, 115
    142 };
    143 /**
    144 *
    145 * @brief default scaling matrix as specified by standard
    146 * 16x16 inter matrix
    147 *
    148 */
    149 const WORD16 gi2_inter_default_scale_mat_16x16[] =
    150 {
    151     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24,
    152     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24,
    153     16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25,
    154     16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25,
    155     16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28,
    156     16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28,
    157     16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33,
    158     16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33,
    159     17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41,
    160     17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41,
    161     18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54,
    162     18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54,
    163     20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54, 71, 71,
    164     20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54, 71, 71,
    165     24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54, 71, 71, 91, 91,
    166     24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54, 71, 71, 91, 91
    167 };
    168 
    169 /**
    170 *
    171 * @brief default scaling matrix as specified by standard
    172 * 32x32 intra matrix
    173 *
    174 */
    175 const WORD16 gi2_intra_default_scale_mat_32x32[] =
    176 {
    177     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 21, 21, 21, 21, 24,  24,  24,  24,
    178     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 21, 21, 21, 21, 24,  24,  24,  24,
    179     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 21, 21, 21, 21, 24,  24,  24,  24,
    180     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 21, 21, 21, 21, 24,  24,  24,  24,
    181     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 19, 19, 19, 19, 22, 22, 22, 22, 25,  25,  25,  25,
    182     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 19, 19, 19, 19, 22, 22, 22, 22, 25,  25,  25,  25,
    183     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 19, 19, 19, 19, 22, 22, 22, 22, 25,  25,  25,  25,
    184     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 19, 19, 19, 19, 22, 22, 22, 22, 25,  25,  25,  25,
    185     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 22, 22, 22, 22, 25, 25, 25, 25, 29,  29,  29,  29,
    186     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 22, 22, 22, 22, 25, 25, 25, 25, 29,  29,  29,  29,
    187     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 22, 22, 22, 22, 25, 25, 25, 25, 29,  29,  29,  29,
    188     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 22, 22, 22, 22, 25, 25, 25, 25, 29,  29,  29,  29,
    189     16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 21, 21, 21, 21, 24, 24, 24, 24, 27, 27, 27, 27, 31, 31, 31, 31, 36,  36,  36,  36,
    190     16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 21, 21, 21, 21, 24, 24, 24, 24, 27, 27, 27, 27, 31, 31, 31, 31, 36,  36,  36,  36,
    191     16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 21, 21, 21, 21, 24, 24, 24, 24, 27, 27, 27, 27, 31, 31, 31, 31, 36,  36,  36,  36,
    192     16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 21, 21, 21, 21, 24, 24, 24, 24, 27, 27, 27, 27, 31, 31, 31, 31, 36,  36,  36,  36,
    193     17, 17, 17, 17, 17, 17, 17, 17, 20, 20, 20, 20, 24, 24, 24, 24, 30, 30, 30, 30, 35, 35, 35, 35, 41, 41, 41, 41, 47,  47,  47,  47,
    194     17, 17, 17, 17, 17, 17, 17, 17, 20, 20, 20, 20, 24, 24, 24, 24, 30, 30, 30, 30, 35, 35, 35, 35, 41, 41, 41, 41, 47,  47,  47,  47,
    195     17, 17, 17, 17, 17, 17, 17, 17, 20, 20, 20, 20, 24, 24, 24, 24, 30, 30, 30, 30, 35, 35, 35, 35, 41, 41, 41, 41, 47,  47,  47,  47,
    196     17, 17, 17, 17, 17, 17, 17, 17, 20, 20, 20, 20, 24, 24, 24, 24, 30, 30, 30, 30, 35, 35, 35, 35, 41, 41, 41, 41, 47,  47,  47,  47,
    197     18, 18, 18, 18, 19, 19, 19, 19, 22, 22, 22, 22, 27, 27, 27, 27, 35, 35, 35, 35, 44, 44, 44, 44, 54, 54, 54, 54, 65,  65,  65,  65,
    198     18, 18, 18, 18, 19, 19, 19, 19, 22, 22, 22, 22, 27, 27, 27, 27, 35, 35, 35, 35, 44, 44, 44, 44, 54, 54, 54, 54, 65,  65,  65,  65,
    199     18, 18, 18, 18, 19, 19, 19, 19, 22, 22, 22, 22, 27, 27, 27, 27, 35, 35, 35, 35, 44, 44, 44, 44, 54, 54, 54, 54, 65,  65,  65,  65,
    200     18, 18, 18, 18, 19, 19, 19, 19, 22, 22, 22, 22, 27, 27, 27, 27, 35, 35, 35, 35, 44, 44, 44, 44, 54, 54, 54, 54, 65,  65,  65,  65,
    201     21, 21, 21, 21, 22, 22, 22, 22, 25, 25, 25, 25, 31, 31, 31, 31, 41, 41, 41, 41, 54, 54, 54, 54, 70, 70, 70, 70, 88,  88,  88,  88,
    202     21, 21, 21, 21, 22, 22, 22, 22, 25, 25, 25, 25, 31, 31, 31, 31, 41, 41, 41, 41, 54, 54, 54, 54, 70, 70, 70, 70, 88,  88,  88,  88,
    203     21, 21, 21, 21, 22, 22, 22, 22, 25, 25, 25, 25, 31, 31, 31, 31, 41, 41, 41, 41, 54, 54, 54, 54, 70, 70, 70, 70, 88,  88,  88,  88,
    204     21, 21, 21, 21, 22, 22, 22, 22, 25, 25, 25, 25, 31, 31, 31, 31, 41, 41, 41, 41, 54, 54, 54, 54, 70, 70, 70, 70, 88,  88,  88,  88,
    205     24, 24, 24, 24, 25, 25, 25, 25, 29, 29, 29, 29, 36, 36, 36, 36, 47, 47, 47, 47, 65, 65, 65, 65, 88, 88, 88, 88, 115, 115, 115, 115,
    206     24, 24, 24, 24, 25, 25, 25, 25, 29, 29, 29, 29, 36, 36, 36, 36, 47, 47, 47, 47, 65, 65, 65, 65, 88, 88, 88, 88, 115, 115, 115, 115,
    207     24, 24, 24, 24, 25, 25, 25, 25, 29, 29, 29, 29, 36, 36, 36, 36, 47, 47, 47, 47, 65, 65, 65, 65, 88, 88, 88, 88, 115, 115, 115, 115,
    208     24, 24, 24, 24, 25, 25, 25, 25, 29, 29, 29, 29, 36, 36, 36, 36, 47, 47, 47, 47, 65, 65, 65, 65, 88, 88, 88, 88, 115, 115, 115, 115
    209 };
    210 
    211 /**
    212 *
    213 * @brief default scaling matrix as specified by standard
    214 * 32x32 inter matrix
    215 *
    216 */
    217 const WORD16 gi2_inter_default_scale_mat_32x32[] =
    218 {
    219     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24,
    220     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24,
    221     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24,
    222     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24,
    223     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25,
    224     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25,
    225     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25,
    226     16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25,
    227     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28,
    228     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28,
    229     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28,
    230     16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28,
    231     16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33,
    232     16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33,
    233     16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33,
    234     16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33,
    235     17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41,
    236     17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41,
    237     17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41,
    238     17, 17, 17, 17, 18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41,
    239     18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54,
    240     18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54,
    241     18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54,
    242     18, 18, 18, 18, 20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54,
    243     20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54, 71, 71, 71, 71,
    244     20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54, 71, 71, 71, 71,
    245     20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54, 71, 71, 71, 71,
    246     20, 20, 20, 20, 24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54, 71, 71, 71, 71,
    247     24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54, 71, 71, 71, 71, 91, 91, 91, 91,
    248     24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54, 71, 71, 71, 71, 91, 91, 91, 91,
    249     24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54, 71, 71, 71, 71, 91, 91, 91, 91,
    250     24, 24, 24, 24, 25, 25, 25, 25, 28, 28, 28, 28, 33, 33, 33, 33, 41, 41, 41, 41, 54, 54, 54, 54, 71, 71, 71, 71, 91, 91, 91, 91
    251 };
    252 
    253 
    254 
    255 /**  Default flat ReScaling matrix for 32x32 transform
    256   * used for quantization
    257   * value[i] = ceil(((1 << 15) -1) / gi2_default_scale_mat_4x4[i])
    258   * Since the values are same, 32x32 matrix will be used for all sizes
    259   */
    260 
    261 const WORD16 gi2_flat_rescale_mat_32x32[] =
    262 {
    263     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    264     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    265     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    266     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    267     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    268     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    269     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    270     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    271     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    272     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    273     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    274     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    275     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    276     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    277     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    278     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    279     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    280     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    281     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    282     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    283     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    284     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    285     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    286     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    287     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    288     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    289     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    290     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    291     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    292     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    293     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
    294     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048
    295 
    296 };
    297 
    298 
    299 /**
    300 * Default ReScaling matrix for 8x8 intra transform as defined by standard
    301 * used for quantization
    302 * value[i] = ceil(((1 << 15)-1) / gi2_default_scale_mat_4x4[i])
    303 */
    304 
    305 const WORD16 gi2_intra_default_rescale_mat_8x8[] =
    306 {
    307     2048, 2048, 2048, 2048, 1928, 1821, 1561, 1366,
    308     2048, 2048, 2048, 2048, 1928, 1725, 1490, 1311,
    309     2048, 2048, 1928, 1821, 1639, 1490, 1311, 1130,
    310     2048, 2048, 1821, 1561, 1366, 1214, 1057, 911,
    311     1928, 1928, 1639, 1366, 1093, 937,  800,  698,
    312     1821, 1725, 1490, 1214, 937,  745,  607,  505,
    313     1561, 1490, 1311, 1057, 800,  607,  469,  373,
    314     1366, 1311, 1130, 911,  698,  505,  373,  285
    315 };
    316 
    317 /**
    318 *
    319 * @brief default rescaling scaling matrix as specified by standard
    320 * 8x8 inter matrix
    321 * value[i] = ceil(((1 << 15)-1) / gi2_default_scale_mat_4x4[i])
    322 *
    323 */
    324 const WORD16 gi2_inter_default_rescale_mat_8x8[] =
    325 {
    326     2048, 2048, 2048, 2048, 1928, 1821, 1639, 1366,
    327     2048, 2048, 2048, 1928, 1821, 1639, 1366, 1311,
    328     2048, 2048, 1928, 1821, 1639, 1366, 1311, 1171,
    329     2048, 1928, 1821, 1639, 1366, 1311, 1171, 993,
    330     1928, 1821, 1639, 1366, 1311, 1171, 993,  800,
    331     1821, 1639, 1366, 1311, 1171, 993,  800,  607,
    332     1639, 1366, 1311, 1171, 993,  800,  607,  462,
    333     1366, 1311, 1171, 993,  800,  607,  462,  361
    334 };
    335 
    336 /**
    337 *
    338 * @brief default Rescaling scaling matrix as specified by standard
    339 * 16x16 intra matrix
    340 *
    341 */
    342 const WORD16 gi2_intra_default_rescale_mat_16x16[] =
    343 {
    344     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1561, 1561, 1366, 1366,
    345     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1561, 1561, 1366, 1366,
    346     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1725, 1725, 1490, 1490, 1311, 1311,
    347     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1725, 1725, 1490, 1490, 1311, 1311,
    348     2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1490, 1490, 1311, 1311, 1130, 1130,
    349     2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1490, 1490, 1311, 1311, 1130, 1130,
    350     2048, 2048, 2048, 2048, 1821, 1821, 1561, 1561, 1366, 1366, 1214, 1214, 1057, 1057, 911,  911,
    351     2048, 2048, 2048, 2048, 1821, 1821, 1561, 1561, 1366, 1366, 1214, 1214, 1057, 1057, 911,  911,
    352     1928, 1928, 1928, 1928, 1639, 1639, 1366, 1366, 1093, 1093, 937,  937,  800,  800,  698,  698,
    353     1928, 1928, 1928, 1928, 1639, 1639, 1366, 1366, 1093, 1093, 937,  937,  800,  800,  698,  698,
    354     1821, 1821, 1725, 1725, 1490, 1490, 1214, 1214, 937,  937,  745,  745,  607,  607,  505,  505,
    355     1821, 1821, 1725, 1725, 1490, 1490, 1214, 1214, 937,  937,  745,  745,  607,  607,  505,  505,
    356     1561, 1561, 1490, 1490, 1311, 1311, 1057, 1057, 800,  800,  607,  607,  469,  469,  373,  373,
    357     1561, 1561, 1490, 1490, 1311, 1311, 1057, 1057, 800,  800,  607,  607,  469,  469,  373,  373,
    358     1366, 1366, 1311, 1311, 1130, 1130, 911,  911,  698,  698,  505,  505,  373,  373,  285,  285,
    359     1366, 1366, 1311, 1311, 1130, 1130, 911,  911,  698,  698,  505,  505,  373,  373,  285,  285
    360 };
    361 
    362 /**
    363 *
    364 * @brief default rescaling scaling matrix as specified by standard
    365 * 16x16 intra matrix
    366 *
    367 */
    368 const WORD16 gi2_inter_default_rescale_mat_16x16[] =
    369 {
    370     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366,
    371     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366,
    372     2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311,
    373     2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311,
    374     2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,
    375     2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,
    376     2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,
    377     2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,
    378     1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,
    379     1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,
    380     1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,
    381     1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,
    382     1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,  462,  462,
    383     1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,  462,  462,
    384     1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,  462,  462,  361,  361,
    385     1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,  462,  462,  361,  361
    386 };
    387 
    388 /**
    389 *
    390 * @brief default rescaled scaling matrix as specified by standard
    391 * 32x32 intra matrix
    392 *
    393 */
    394 const WORD16 gi2_intra_default_rescale_mat_32x32[] =
    395 {
    396     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1561, 1561, 1561, 1561, 1366, 1366, 1366, 1366,
    397     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1561, 1561, 1561, 1561, 1366, 1366, 1366, 1366,
    398     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1561, 1561, 1561, 1561, 1366, 1366, 1366, 1366,
    399     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1561, 1561, 1561, 1561, 1366, 1366, 1366, 1366,
    400     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1725, 1725, 1725, 1725, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311,
    401     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1725, 1725, 1725, 1725, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311,
    402     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1725, 1725, 1725, 1725, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311,
    403     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1725, 1725, 1725, 1725, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311,
    404     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311, 1130, 1130, 1130, 1130,
    405     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311, 1130, 1130, 1130, 1130,
    406     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311, 1130, 1130, 1130, 1130,
    407     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311, 1130, 1130, 1130, 1130,
    408     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1821, 1821, 1821, 1821, 1561, 1561, 1561, 1561, 1366, 1366, 1366, 1366, 1214, 1214, 1214, 1214, 1057, 1057, 1057, 1057,  911,  911,  911,  911,
    409     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1821, 1821, 1821, 1821, 1561, 1561, 1561, 1561, 1366, 1366, 1366, 1366, 1214, 1214, 1214, 1214, 1057, 1057, 1057, 1057,  911,  911,  911,  911,
    410     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1821, 1821, 1821, 1821, 1561, 1561, 1561, 1561, 1366, 1366, 1366, 1366, 1214, 1214, 1214, 1214, 1057, 1057, 1057, 1057,  911,  911,  911,  911,
    411     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1821, 1821, 1821, 1821, 1561, 1561, 1561, 1561, 1366, 1366, 1366, 1366, 1214, 1214, 1214, 1214, 1057, 1057, 1057, 1057,  911,  911,  911,  911,
    412     1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1093, 1093, 1093, 1093,  937,  937,  937,  937,  800,  800,  800,  800,  698,  698,  698,  698,
    413     1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1093, 1093, 1093, 1093,  937,  937,  937,  937,  800,  800,  800,  800,  698,  698,  698,  698,
    414     1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1093, 1093, 1093, 1093,  937,  937,  937,  937,  800,  800,  800,  800,  698,  698,  698,  698,
    415     1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1093, 1093, 1093, 1093,  937,  937,  937,  937,  800,  800,  800,  800,  698,  698,  698,  698,
    416     1821, 1821, 1821, 1821, 1725, 1725, 1725, 1725, 1490, 1490, 1490, 1490, 1214, 1214, 1214, 1214,  937,  937,  937,  937,  745,  745,  745,  745,  607,  607,  607,  607,  505,  505,  505,  505,
    417     1821, 1821, 1821, 1821, 1725, 1725, 1725, 1725, 1490, 1490, 1490, 1490, 1214, 1214, 1214, 1214,  937,  937,  937,  937,  745,  745,  745,  745,  607,  607,  607,  607,  505,  505,  505,  505,
    418     1821, 1821, 1821, 1821, 1725, 1725, 1725, 1725, 1490, 1490, 1490, 1490, 1214, 1214, 1214, 1214,  937,  937,  937,  937,  745,  745,  745,  745,  607,  607,  607,  607,  505,  505,  505,  505,
    419     1821, 1821, 1821, 1821, 1725, 1725, 1725, 1725, 1490, 1490, 1490, 1490, 1214, 1214, 1214, 1214,  937,  937,  937,  937,  745,  745,  745,  745,  607,  607,  607,  607,  505,  505,  505,  505,
    420     1561, 1561, 1561, 1561, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311, 1057, 1057, 1057, 1057,  800,  800,  800,  800,  607,  607,  607,  607,  469,  469,  469,  469,  373,  373,  373,  373,
    421     1561, 1561, 1561, 1561, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311, 1057, 1057, 1057, 1057,  800,  800,  800,  800,  607,  607,  607,  607,  469,  469,  469,  469,  373,  373,  373,  373,
    422     1561, 1561, 1561, 1561, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311, 1057, 1057, 1057, 1057,  800,  800,  800,  800,  607,  607,  607,  607,  469,  469,  469,  469,  373,  373,  373,  373,
    423     1561, 1561, 1561, 1561, 1490, 1490, 1490, 1490, 1311, 1311, 1311, 1311, 1057, 1057, 1057, 1057,  800,  800,  800,  800,  607,  607,  607,  607,  469,  469,  469,  469,  373,  373,  373,  373,
    424     1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1130, 1130, 1130, 1130,  911,  911,  911,  911,  698,  698,  698,  698,  505,  505,  505,  505,  373,  373,  373,  373,  285,  285,  285,  285,
    425     1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1130, 1130, 1130, 1130,  911,  911,  911,  911,  698,  698,  698,  698,  505,  505,  505,  505,  373,  373,  373,  373,  285,  285,  285,  285,
    426     1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1130, 1130, 1130, 1130,  911,  911,  911,  911,  698,  698,  698,  698,  505,  505,  505,  505,  373,  373,  373,  373,  285,  285,  285,  285,
    427     1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1130, 1130, 1130, 1130,  911,  911,  911,  911,  698,  698,  698,  698,  505,  505,  505,  505,  373,  373,  373,  373,  285,  285,  285,  285
    428 };
    429 
    430 /**
    431 *
    432 * @brief default rescaled scaling matrix as specified by standard
    433 * 32x32 inter matrix
    434 *
    435 */
    436 const WORD16 gi2_inter_default_rescale_mat_32x32[] =
    437 {
    438     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366,
    439     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366,
    440     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366,
    441     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366,
    442     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311,
    443     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311,
    444     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311,
    445     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311,
    446     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,
    447     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,
    448     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,
    449     2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,
    450     2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,
    451     2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,
    452     2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,
    453     2048, 2048, 2048, 2048, 1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,
    454     1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,
    455     1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,
    456     1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,
    457     1928, 1928, 1928, 1928, 1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,
    458     1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,
    459     1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,
    460     1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,
    461     1821, 1821, 1821, 1821, 1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,
    462     1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,  462,  462,  462,  462,
    463     1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,  462,  462,  462,  462,
    464     1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,  462,  462,  462,  462,
    465     1639, 1639, 1639, 1639, 1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,  462,  462,  462,  462,
    466     1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,  462,  462,  462,  462,  361,  361,  361,  361,
    467     1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,  462,  462,  462,  462,  361,  361,  361,  361,
    468     1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,  462,  462,  462,  462,  361,  361,  361,  361,
    469     1366, 1366, 1366, 1366, 1311, 1311, 1311, 1311, 1171, 1171, 1171, 1171,  993,  993,  993,  993,  800,  800,  800,  800,  607,  607,  607,  607,  462,  462,  462,  462,  361,  361,  361,  361
    470 };
    471 
    472