📄 transform8x8.c
字号:
/*!
***************************************************************************
* \file transform8x8.c
*
* \brief
* 8x8 transform functions
*
* \author
* Main contributors (see contributors.h for copyright, address and affiliation details)
* - Yuri Vatis
* - Jan Muenster
*
* \date
* 12. October 2003
**************************************************************************
*/
#include "global.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "image.h"
#include "mb_access.h"
#include "elements.h"
#include "transform8x8.h"
#define Q_BITS_8 16
#define DQ_BITS_8 6
const int quant_coef8[6][8][8] =
{
{
{13107, 12222, 16777, 12222, 13107, 12222, 16777, 12222},
{12222, 11428, 15481, 11428, 12222, 11428, 15481, 11428},
{16777, 15481, 20972, 15481, 16777, 15481, 20972, 15481},
{12222, 11428, 15481, 11428, 12222, 11428, 15481, 11428},
{13107, 12222, 16777, 12222, 13107, 12222, 16777, 12222},
{12222, 11428, 15481, 11428, 12222, 11428, 15481, 11428},
{16777, 15481, 20972, 15481, 16777, 15481, 20972, 15481},
{12222, 11428, 15481, 11428, 12222, 11428, 15481, 11428}
},
{
{11916, 11058, 14980, 11058, 11916, 11058, 14980, 11058},
{11058, 10826, 14290, 10826, 11058, 10826, 14290, 10826},
{14980, 14290, 19174, 14290, 14980, 14290, 19174, 14290},
{11058, 10826, 14290, 10826, 11058, 10826, 14290, 10826},
{11916, 11058, 14980, 11058, 11916, 11058, 14980, 11058},
{11058, 10826, 14290, 10826, 11058, 10826, 14290, 10826},
{14980, 14290, 19174, 14290, 14980, 14290, 19174, 14290},
{11058, 10826, 14290, 10826, 11058, 10826, 14290, 10826}
},
{
{10082, 9675, 12710, 9675, 10082, 9675, 12710, 9675},
{9675, 8943, 11985, 8943, 9675, 8943, 11985, 8943},
{12710, 11985, 15978, 11985, 12710, 11985, 15978, 11985},
{9675, 8943, 11985, 8943, 9675, 8943, 11985, 8943},
{10082, 9675, 12710, 9675, 10082, 9675, 12710, 9675},
{9675, 8943, 11985, 8943, 9675, 8943, 11985, 8943},
{12710, 11985, 15978, 11985, 12710, 11985, 15978, 11985},
{9675, 8943, 11985, 8943, 9675, 8943, 11985, 8943}
},
{
{9362, 8931, 11984, 8931, 9362, 8931, 11984, 8931},
{8931, 8228, 11259, 8228, 8931, 8228, 11259, 8228},
{11984, 11259, 14913, 11259, 11984, 11259, 14913, 11259},
{8931, 8228, 11259, 8228, 8931, 8228, 11259, 8228},
{9362, 8931, 11984, 8931, 9362, 8931, 11984, 8931},
{8931, 8228, 11259, 8228, 8931, 8228, 11259, 8228},
{11984, 11259, 14913, 11259, 11984, 11259, 14913, 11259},
{8931, 8228, 11259, 8228, 8931, 8228, 11259, 8228}
},
{
{8192, 7740, 10486, 7740, 8192, 7740, 10486, 7740},
{7740, 7346, 9777, 7346, 7740, 7346, 9777, 7346},
{10486, 9777, 13159, 9777, 10486, 9777, 13159, 9777},
{7740, 7346, 9777, 7346, 7740, 7346, 9777, 7346},
{8192, 7740, 10486, 7740, 8192, 7740, 10486, 7740},
{7740, 7346, 9777, 7346, 7740, 7346, 9777, 7346},
{10486, 9777, 13159, 9777, 10486, 9777, 13159, 9777},
{7740, 7346, 9777, 7346, 7740, 7346, 9777, 7346}
},
{
{7282, 6830, 9118, 6830, 7282, 6830, 9118, 6830},
{6830, 6428, 8640, 6428, 6830, 6428, 8640, 6428},
{9118, 8640, 11570, 8640, 9118, 8640, 11570, 8640},
{6830, 6428, 8640, 6428, 6830, 6428, 8640, 6428},
{7282, 6830, 9118, 6830, 7282, 6830, 9118, 6830},
{6830, 6428, 8640, 6428, 6830, 6428, 8640, 6428},
{9118, 8640, 11570, 8640, 9118, 8640, 11570, 8640},
{6830, 6428, 8640, 6428, 6830, 6428, 8640, 6428}
}
};
const int dequant_coef8[6][8][8] =
{
{
{20, 19, 25, 19, 20, 19, 25, 19},
{19, 18, 24, 18, 19, 18, 24, 18},
{25, 24, 32, 24, 25, 24, 32, 24},
{19, 18, 24, 18, 19, 18, 24, 18},
{20, 19, 25, 19, 20, 19, 25, 19},
{19, 18, 24, 18, 19, 18, 24, 18},
{25, 24, 32, 24, 25, 24, 32, 24},
{19, 18, 24, 18, 19, 18, 24, 18}
},
{
{22, 21, 28, 21, 22, 21, 28, 21},
{21, 19, 26, 19, 21, 19, 26, 19},
{28, 26, 35, 26, 28, 26, 35, 26},
{21, 19, 26, 19, 21, 19, 26, 19},
{22, 21, 28, 21, 22, 21, 28, 21},
{21, 19, 26, 19, 21, 19, 26, 19},
{28, 26, 35, 26, 28, 26, 35, 26},
{21, 19, 26, 19, 21, 19, 26, 19}
},
{
{26, 24, 33, 24, 26, 24, 33, 24},
{24, 23, 31, 23, 24, 23, 31, 23},
{33, 31, 42, 31, 33, 31, 42, 31},
{24, 23, 31, 23, 24, 23, 31, 23},
{26, 24, 33, 24, 26, 24, 33, 24},
{24, 23, 31, 23, 24, 23, 31, 23},
{33, 31, 42, 31, 33, 31, 42, 31},
{24, 23, 31, 23, 24, 23, 31, 23}
},
{
{28, 26, 35, 26, 28, 26, 35, 26},
{26, 25, 33, 25, 26, 25, 33, 25},
{35, 33, 45, 33, 35, 33, 45, 33},
{26, 25, 33, 25, 26, 25, 33, 25},
{28, 26, 35, 26, 28, 26, 35, 26},
{26, 25, 33, 25, 26, 25, 33, 25},
{35, 33, 45, 33, 35, 33, 45, 33},
{26, 25, 33, 25, 26, 25, 33, 25}
},
{
{32, 30, 40, 30, 32, 30, 40, 30},
{30, 28, 38, 28, 30, 28, 38, 28},
{40, 38, 51, 38, 40, 38, 51, 38},
{30, 28, 38, 28, 30, 28, 38, 28},
{32, 30, 40, 30, 32, 30, 40, 30},
{30, 28, 38, 28, 30, 28, 38, 28},
{40, 38, 51, 38, 40, 38, 51, 38},
{30, 28, 38, 28, 30, 28, 38, 28}
},
{
{36, 34, 46, 34, 36, 34, 46, 34},
{34, 32, 43, 32, 34, 32, 43, 32},
{46, 43, 58, 43, 46, 43, 58, 43},
{34, 32, 43, 32, 34, 32, 43, 32},
{36, 34, 46, 34, 36, 34, 46, 34},
{34, 32, 43, 32, 34, 32, 43, 32},
{46, 43, 58, 43, 46, 43, 58, 43},
{34, 32, 43, 32, 34, 32, 43, 32}
}
};
// function declarations
void LowPassForIntra8x8Pred(imgpel *PredPel, int block_up_left, int block_up, int block_left);
// Notation for comments regarding prediction and predictors.
// The pels of the 4x4 block are labeled a..p. The predictor pels above
// are labeled A..H, from the left I..P, and from above left X, as follows:
//
// Z A B C D E F G H I J K L M N O P
// Q a1 b1 c1 d1 e1 f1 g1 h1
// R a2 b2 c2 d2 e2 f2 g2 h2
// S a3 b3 c3 d3 e3 f3 g3 h3
// T a4 b4 c4 d4 e4 f4 g4 h4
// U a5 b5 c5 d5 e5 f5 g5 h5
// V a6 b6 c6 d6 e6 f6 g6 h6
// W a7 b7 c7 d7 e7 f7 g7 h7
// X a8 b8 c8 d8 e8 f8 g8 h8
// Predictor array index definitions
#define P_Z (PredPel[0])
#define P_A (PredPel[1])
#define P_B (PredPel[2])
#define P_C (PredPel[3])
#define P_D (PredPel[4])
#define P_E (PredPel[5])
#define P_F (PredPel[6])
#define P_G (PredPel[7])
#define P_H (PredPel[8])
#define P_I (PredPel[9])
#define P_J (PredPel[10])
#define P_K (PredPel[11])
#define P_L (PredPel[12])
#define P_M (PredPel[13])
#define P_N (PredPel[14])
#define P_O (PredPel[15])
#define P_P (PredPel[16])
#define P_Q (PredPel[17])
#define P_R (PredPel[18])
#define P_S (PredPel[19])
#define P_T (PredPel[20])
#define P_U (PredPel[21])
#define P_V (PredPel[22])
#define P_W (PredPel[23])
#define P_X (PredPel[24])
/*!
************************************************************************
* \brief
* Make intra 8x8 prediction according to all 9 prediction modes.
* The routine uses left and upper neighbouring points from
* previous coded blocks to do this (if available). Notice that
* inaccessible neighbouring points are signalled with a negative
* value in the predmode array .
*
* \par Input:
* Starting point of current 8x8 block image position
*
************************************************************************
*/
int intrapred8x8( struct img_par *img, //!< image parameters
int b8)
{
int i,j;
int s0;
imgpel PredPel[25]; // array of predictor pels
imgpel **imgY = dec_picture->imgY; // For MB level frame/field coding tools -- set default to imgY
int mb_nr=img->current_mb_nr;
PixelPos pix_a[8];
PixelPos pix_b, pix_c, pix_d;
int block_available_up;
int block_available_left;
int block_available_up_left;
int block_available_up_right;
int img_block_x = (img->mb_x << 2) + ((b8 & 0x01) << 1);
int img_block_y = (img->mb_y << 2) + ((b8 >> 1) << 1);
int ioff = (b8 & 0x01) << 3;
int joff = (b8 >> 1 ) << 3;
int jpos0 = joff , jpos1 = joff + 1, jpos2 = joff + 2, jpos3 = joff + 3;
int jpos4 = joff + 4, jpos5 = joff + 5, jpos6 = joff + 6, jpos7 = joff + 7;
int ipos0 = ioff , ipos1 = ioff + 1, ipos2 = ioff + 2, ipos3 = ioff + 3;
int ipos4 = ioff + 4, ipos5 = ioff + 5, ipos6 = ioff + 6, ipos7 = ioff + 7;
int jpos, ipos;
imgpel *pred_pels, (*mpr)[16] = img->mpr[LumaComp];
byte predmode = img->ipredmode[img_block_y][img_block_x];
for (i=0;i<8;i++)
{
getNeighbour(mb_nr, ioff - 1, joff + i, IS_LUMA, &pix_a[i]);
}
getNeighbour(mb_nr, ioff , joff - 1, IS_LUMA, &pix_b);
getNeighbour(mb_nr, ioff + 8, joff - 1, IS_LUMA, &pix_c);
getNeighbour(mb_nr, ioff - 1, joff - 1, IS_LUMA, &pix_d);
pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
if (active_pps->constrained_intra_pred_flag)
{
for (i=0, block_available_left=1; i<8;i++)
block_available_left &= pix_a[i].available ? img->intra_block[pix_a[i].mb_addr]: 0;
block_available_up = pix_b.available ? img->intra_block [pix_b.mb_addr] : 0;
block_available_up_right = pix_c.available ? img->intra_block [pix_c.mb_addr] : 0;
block_available_up_left = pix_d.available ? img->intra_block [pix_d.mb_addr] : 0;
}
else
{
block_available_left = pix_a[0].available;
block_available_up = pix_b.available;
block_available_up_right = pix_c.available;
block_available_up_left = pix_d.available;
}
// *left_available = block_available_left;
// *up_available = block_available_up;
// *all_available = block_available_up && block_available_left && block_available_up_left;
// form predictor pels
// form predictor pels
if (block_available_up)
{
pred_pels = &imgY[pix_b.pos_y][pix_b.pos_x];
P_A = pred_pels[0];
P_B = pred_pels[1];
P_C = pred_pels[2];
P_D = pred_pels[3];
P_E = pred_pels[4];
P_F = pred_pels[5];
P_G = pred_pels[6];
P_H = pred_pels[7];
}
else
{
P_A = P_B = P_C = P_D = P_E = P_F = P_G = P_H = img->dc_pred_value_luma;
}
if (block_available_up_right)
{
pred_pels = &imgY[pix_c.pos_y][pix_c.pos_x];
P_I = pred_pels[0];
P_J = pred_pels[1];
P_K = pred_pels[2];
P_L = pred_pels[3];
P_M = pred_pels[4];
P_N = pred_pels[5];
P_O = pred_pels[6];
P_P = pred_pels[7];
}
else
{
P_I = P_J = P_K = P_L = P_M = P_N = P_O = P_P = P_H;
}
if (block_available_left)
{
P_Q = imgY[pix_a[0].pos_y][pix_a[0].pos_x];
P_R = imgY[pix_a[1].pos_y][pix_a[1].pos_x];
P_S = imgY[pix_a[2].pos_y][pix_a[2].pos_x];
P_T = imgY[pix_a[3].pos_y][pix_a[3].pos_x];
P_U = imgY[pix_a[4].pos_y][pix_a[4].pos_x];
P_V = imgY[pix_a[5].pos_y][pix_a[5].pos_x];
P_W = imgY[pix_a[6].pos_y][pix_a[6].pos_x];
P_X = imgY[pix_a[7].pos_y][pix_a[7].pos_x];
}
else
{
P_Q = P_R = P_S = P_T = P_U = P_V = P_W = P_X = img->dc_pred_value_luma;
}
if (block_available_up_left)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -