/******************************************************************************
*
* Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/**
*******************************************************************************
* @file
*  ihevc_trans_tables.c
*
* @brief
*  Contains tables used in forward and inverse quantization
*
* @author
*  100189
*
* @par List of Functions:
*
* @remarks
*  None
*
*******************************************************************************
*/

#include "ihevc_typedefs.h"
#include "ihevc_func_selector.h"
#include "ihevc_quant_tables.h"
#include "ihevc_defs.h"



/**  Default flat Scaling matrix for 32x32 transform
 * Since the values are same, 32x32 matrix will be used for all sizes
 */
const WORD16 gi2_flat_scale_mat_32x32[] =
{
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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

};

/**
*
* @brief default scaling matrix as specified by standard
* 8x8 intra matrix
*
*/
const WORD16 gi2_intra_default_scale_mat_8x8[] =
{
    16, 16, 16, 16, 17, 18, 21, 24,
    16, 16, 16, 16, 17, 19, 22, 25,
    16, 16, 17, 18, 20, 22, 25, 29,
    16, 16, 18, 21, 24, 27, 31, 36,
    17, 17, 20, 24, 30, 35, 41, 47,
    18, 19, 22, 27, 35, 44, 54, 65,
    21, 22, 25, 31, 41, 54, 70, 88,
    24, 25, 29, 36, 47, 65, 88, 115
};
/**
*
* @brief default scaling matrix as specified by standard
* 8x8 inter matrix
*
*/
const WORD16 gi2_inter_default_scale_mat_8x8[] =
{
    16, 16, 16, 16, 17, 18, 20, 24,
    16, 16, 16, 17, 18, 20, 24, 25,
    16, 16, 17, 18, 20, 24, 25, 28,
    16, 17, 18, 20, 24, 25, 28, 33,
    17, 18, 20, 24, 25, 28, 33, 41,
    18, 20, 24, 25, 28, 33, 41, 54,
    20, 24, 25, 28, 33, 41, 54, 71,
    24, 25, 28, 33, 41, 54, 71, 91
};
/**
*
* @brief default scaling matrix as specified by standard
* 16x16 intra matrix
*
*/
const WORD16 gi2_intra_default_scale_mat_16x16[] =
{
    16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 21, 21, 24,  24,
    16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 21, 21, 24,  24,
    16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 19, 19, 22, 22, 25,  25,
    16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 19, 19, 22, 22, 25,  25,
    16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 22, 22, 25, 25, 29,  29,
    16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 22, 22, 25, 25, 29,  29,
    16, 16, 16, 16, 18, 18, 21, 21, 24, 24, 27, 27, 31, 31, 36,  36,
    16, 16, 16, 16, 18, 18, 21, 21, 24, 24, 27, 27, 31, 31, 36,  36,
    17, 17, 17, 17, 20, 20, 24, 24, 30, 30, 35, 35, 41, 41, 47,  47,
    17, 17, 17, 17, 20, 20, 24, 24, 30, 30, 35, 35, 41, 41, 47,  47,
    18, 18, 19, 19, 22, 22, 27, 27, 35, 35, 44, 44, 54, 54, 65,  65,
    18, 18, 19, 19, 22, 22, 27, 27, 35, 35, 44, 44, 54, 54, 65,  65,
    21, 21, 22, 22, 25, 25, 31, 31, 41, 41, 54, 54, 70, 70, 88,  88,
    21, 21, 22, 22, 25, 25, 31, 31, 41, 41, 54, 54, 70, 70, 88,  88,
    24, 24, 25, 25, 29, 29, 36, 36, 47, 47, 65, 65, 88, 88, 115, 115,
    24, 24, 25, 25, 29, 29, 36, 36, 47, 47, 65, 65, 88, 88, 115, 115
};
/**
*
* @brief default scaling matrix as specified by standard
* 16x16 inter matrix
*
*/
const WORD16 gi2_inter_default_scale_mat_16x16[] =
{
    16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24,
    16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24,
    16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25,
    16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25,
    16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28,
    16, 16, 16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28,
    16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33,
    16, 16, 17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33,
    17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41,
    17, 17, 18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41,
    18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54,
    18, 18, 20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54,
    20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54, 71, 71,
    20, 20, 24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54, 71, 71,
    24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54, 71, 71, 91, 91,
    24, 24, 25, 25, 28, 28, 33, 33, 41, 41, 54, 54, 71, 71, 91, 91
};

/**
*
* @brief default scaling matrix as specified by standard
* 32x32 intra matrix
*
*/
const WORD16 gi2_intra_default_scale_mat_32x32[] =
{
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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
};

/**
*
* @brief default scaling matrix as specified by standard
* 32x32 inter matrix
*
*/
const WORD16 gi2_inter_default_scale_mat_32x32[] =
{
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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
};



/**  Default flat ReScaling matrix for 32x32 transform
  * used for quantization
  * value[i] = ceil(((1 << 15) -1) / gi2_default_scale_mat_4x4[i])
  * Since the values are same, 32x32 matrix will be used for all sizes
  */

const WORD16 gi2_flat_rescale_mat_32x32[] =
{
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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

};


/**
* Default ReScaling matrix for 8x8 intra transform as defined by standard
* used for quantization
* value[i] = ceil(((1 << 15)-1) / gi2_default_scale_mat_4x4[i])
*/

const WORD16 gi2_intra_default_rescale_mat_8x8[] =
{
    2048, 2048, 2048, 2048, 1928, 1821, 1561, 1366,
    2048, 2048, 2048, 2048, 1928, 1725, 1490, 1311,
    2048, 2048, 1928, 1821, 1639, 1490, 1311, 1130,
    2048, 2048, 1821, 1561, 1366, 1214, 1057, 911,
    1928, 1928, 1639, 1366, 1093, 937,  800,  698,
    1821, 1725, 1490, 1214, 937,  745,  607,  505,
    1561, 1490, 1311, 1057, 800,  607,  469,  373,
    1366, 1311, 1130, 911,  698,  505,  373,  285
};

/**
*
* @brief default rescaling scaling matrix as specified by standard
* 8x8 inter matrix
* value[i] = ceil(((1 << 15)-1) / gi2_default_scale_mat_4x4[i])
*
*/
const WORD16 gi2_inter_default_rescale_mat_8x8[] =
{
    2048, 2048, 2048, 2048, 1928, 1821, 1639, 1366,
    2048, 2048, 2048, 1928, 1821, 1639, 1366, 1311,
    2048, 2048, 1928, 1821, 1639, 1366, 1311, 1171,
    2048, 1928, 1821, 1639, 1366, 1311, 1171, 993,
    1928, 1821, 1639, 1366, 1311, 1171, 993,  800,
    1821, 1639, 1366, 1311, 1171, 993,  800,  607,
    1639, 1366, 1311, 1171, 993,  800,  607,  462,
    1366, 1311, 1171, 993,  800,  607,  462,  361
};

/**
*
* @brief default Rescaling scaling matrix as specified by standard
* 16x16 intra matrix
*
*/
const WORD16 gi2_intra_default_rescale_mat_16x16[] =
{
    2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1561, 1561, 1366, 1366,
    2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1561, 1561, 1366, 1366,
    2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1725, 1725, 1490, 1490, 1311, 1311,
    2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1725, 1725, 1490, 1490, 1311, 1311,
    2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1490, 1490, 1311, 1311, 1130, 1130,
    2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1490, 1490, 1311, 1311, 1130, 1130,
    2048, 2048, 2048, 2048, 1821, 1821, 1561, 1561, 1366, 1366, 1214, 1214, 1057, 1057, 911,  911,
    2048, 2048, 2048, 2048, 1821, 1821, 1561, 1561, 1366, 1366, 1214, 1214, 1057, 1057, 911,  911,
    1928, 1928, 1928, 1928, 1639, 1639, 1366, 1366, 1093, 1093, 937,  937,  800,  800,  698,  698,
    1928, 1928, 1928, 1928, 1639, 1639, 1366, 1366, 1093, 1093, 937,  937,  800,  800,  698,  698,
    1821, 1821, 1725, 1725, 1490, 1490, 1214, 1214, 937,  937,  745,  745,  607,  607,  505,  505,
    1821, 1821, 1725, 1725, 1490, 1490, 1214, 1214, 937,  937,  745,  745,  607,  607,  505,  505,
    1561, 1561, 1490, 1490, 1311, 1311, 1057, 1057, 800,  800,  607,  607,  469,  469,  373,  373,
    1561, 1561, 1490, 1490, 1311, 1311, 1057, 1057, 800,  800,  607,  607,  469,  469,  373,  373,
    1366, 1366, 1311, 1311, 1130, 1130, 911,  911,  698,  698,  505,  505,  373,  373,  285,  285,
    1366, 1366, 1311, 1311, 1130, 1130, 911,  911,  698,  698,  505,  505,  373,  373,  285,  285
};

/**
*
* @brief default rescaling scaling matrix as specified by standard
* 16x16 intra matrix
*
*/
const WORD16 gi2_inter_default_rescale_mat_16x16[] =
{
    2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366,
    2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366,
    2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311,
    2048, 2048, 2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311,
    2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,
    2048, 2048, 2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,
    2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,
    2048, 2048, 1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,
    1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,
    1928, 1928, 1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,
    1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,
    1821, 1821, 1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,
    1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,  462,  462,
    1639, 1639, 1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,  462,  462,
    1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,  462,  462,  361,  361,
    1366, 1366, 1311, 1311, 1171, 1171,  993,  993,  800,  800,  607,  607,  462,  462,  361,  361
};

/**
*
* @brief default rescaled scaling matrix as specified by standard
* 32x32 intra matrix
*
*/
const WORD16 gi2_intra_default_rescale_mat_32x32[] =
{
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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
};

/**
*
* @brief default rescaled scaling matrix as specified by standard
* 32x32 inter matrix
*
*/
const WORD16 gi2_inter_default_rescale_mat_32x32[] =
{
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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,
    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
};