-#include "macroblock.h"
-
-static const uint8_t block_idx_x[16] =
-{
- 0, 1, 0, 1, 2, 3, 2, 3, 0, 1, 0, 1, 2, 3, 2, 3
-};
-static const uint8_t block_idx_y[16] =
-{
- 0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3
-};
-static const uint8_t block_idx_xy[4][4] =
-{
- { 0, 2, 8, 10},
- { 1, 3, 9, 11},
- { 4, 6, 12, 14},
- { 5, 7, 13, 15}
-};
-
-static const int dequant_mf[6][4][4] =
-{
- { {10, 13, 10, 13}, {13, 16, 13, 16}, {10, 13, 10, 13}, {13, 16, 13, 16} },
- { {11, 14, 11, 14}, {14, 18, 14, 18}, {11, 14, 11, 14}, {14, 18, 14, 18} },
- { {13, 16, 13, 16}, {16, 20, 16, 20}, {13, 16, 13, 16}, {16, 20, 16, 20} },
- { {14, 18, 14, 18}, {18, 23, 18, 23}, {14, 18, 14, 18}, {18, 23, 18, 23} },
- { {16, 20, 16, 20}, {20, 25, 20, 25}, {16, 20, 16, 20}, {20, 25, 20, 25} },
- { {18, 23, 18, 23}, {23, 29, 23, 29}, {18, 23, 18, 23}, {23, 29, 23, 29} }
-};
-
-#if 0
-static const int i_chroma_qp_table[52] =
-{
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
- 29, 30, 31, 32, 32, 33, 34, 34, 35, 35,
- 36, 36, 37, 37, 37, 38, 38, 38, 39, 39,
- 39, 39
-};
-#endif
-
-int x264_mb_predict_intra4x4_mode( x264_t *h, int idx )
-{
- const int ma = h->mb.cache.intra4x4_pred_mode[x264_scan8[idx] - 1];
- const int mb = h->mb.cache.intra4x4_pred_mode[x264_scan8[idx] - 8];
- const int m = X264_MIN( ma, mb );
-
- if( m < 0 )
- return I_PRED_4x4_DC;
-
- return m;
-}
-
-int x264_mb_predict_non_zero_code( x264_t *h, int idx )
-{
- const int za = h->mb.cache.non_zero_count[x264_scan8[idx] - 1];
- const int zb = h->mb.cache.non_zero_count[x264_scan8[idx] - 8];
-
- int i_ret = za + zb;
-
- if( i_ret < 0x80 )
- {
- i_ret = ( i_ret + 1 ) >> 1;
- }
- return i_ret & 0x7f;
-}
-
-/****************************************************************************
- * Scan and Quant functions
- ****************************************************************************/
-void x264_mb_dequant_2x2_dc( int16_t dct[2][2], int i_qscale )
-{
- const int i_qbits = i_qscale/6 - 1;
-
- if( i_qbits >= 0 )
- {
- const int i_dmf = dequant_mf[i_qscale%6][0][0] << i_qbits;
-
- dct[0][0] = dct[0][0] * i_dmf;
- dct[0][1] = dct[0][1] * i_dmf;
- dct[1][0] = dct[1][0] * i_dmf;
- dct[1][1] = dct[1][1] * i_dmf;
- }
- else
- {
- const int i_dmf = dequant_mf[i_qscale%6][0][0];
-
- dct[0][0] = ( dct[0][0] * i_dmf ) >> 1;
- dct[0][1] = ( dct[0][1] * i_dmf ) >> 1;
- dct[1][0] = ( dct[1][0] * i_dmf ) >> 1;
- dct[1][1] = ( dct[1][1] * i_dmf ) >> 1;
- }
-}
-
-void x264_mb_dequant_4x4_dc( int16_t dct[4][4], int i_qscale )
-{
- const int i_qbits = i_qscale/6 - 2;
- int x,y;
-
- if( i_qbits >= 0 )
- {
- const int i_dmf = dequant_mf[i_qscale%6][0][0] << i_qbits;
-
- for( y = 0; y < 4; y++ )
- {
- for( x = 0; x < 4; x++ )
- {
- dct[y][x] = dct[y][x] * i_dmf;
- }
- }
- }
- else
- {
- const int i_dmf = dequant_mf[i_qscale%6][0][0];
- const int f = 1 << ( 1 + i_qbits );
-
- for( y = 0; y < 4; y++ )
- {
- for( x = 0; x < 4; x++ )
- {
- dct[y][x] = ( dct[y][x] * i_dmf + f ) >> (-i_qbits);
- }
- }
- }
-}
-
-void x264_mb_dequant_4x4( int16_t dct[4][4], int i_qscale )
-{
- const int i_mf = i_qscale%6;
- const int i_qbits = i_qscale/6;
- int y;
-
- for( y = 0; y < 4; y++ )
- {
- dct[y][0] = ( dct[y][0] * dequant_mf[i_mf][y][0] ) << i_qbits;
- dct[y][1] = ( dct[y][1] * dequant_mf[i_mf][y][1] ) << i_qbits;
- dct[y][2] = ( dct[y][2] * dequant_mf[i_mf][y][2] ) << i_qbits;
- dct[y][3] = ( dct[y][3] * dequant_mf[i_mf][y][3] ) << i_qbits;
- }
-}