#include "contributors.h"
#include <math.h>
#include "global.h"
#include "enc_statistics.h"
#include "memalloc.h"
#include "image.h"
#include "mb_access.h"
#include "block.h"
#include "vlc.h"
#include "transform.h"
#include "mc_prediction.h"
#include "q_offsets.h"
#include "q_matrix.h"
#include "quant4x4.h"
#include "quantChroma.h"

Go to the source code of this file.
Defines | |
| #define | P_X (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]) |
Functions | |
| static int | Residual_DPCM_4x4_for_Intra16x16 (int **m7, int ipmode) |
| static int | Inv_Residual_DPCM_4x4_for_Intra16x16 (int **m7, int ipmode) |
| static int | Residual_DPCM_4x4 (int ipmode, int **mb_ores, int **mb_rres, int block_y, int block_x) |
| static int | Inv_Residual_DPCM_4x4 (int **m7, int block_y, int block_x) |
| int | allocate_block_mem (void) |
| void | free_block_mem (void) |
| void | intrapred_4x4 (Macroblock *currMB, ColorPlane pl, int img_x, int img_y, int *left_available, int *up_available, int *all_available) |
| void | intrapred_16x16 (Macroblock *currMB, ColorPlane pl) |
| int | dct_16x16 (Macroblock *currMB, ColorPlane pl, int new_intra_mode, int is_cavlc) |
| int | dct_16x16_ls (Macroblock *currMB, ColorPlane pl, int new_intra_mode, int is_cavlc) |
| int | dct_4x4 (Macroblock *currMB, ColorPlane pl, int block_x, int block_y, int *coeff_cost, int intra, int is_cavlc) |
| int | dct_4x4_ls (Macroblock *currMB, ColorPlane pl, int block_x, int block_y, int *coeff_cost, int intra, int is_cavlc) |
| int | dct_chroma (Macroblock *currMB, int uv, int cr_cbp, int is_cavlc) |
| int | dct_chroma_ls (Macroblock *currMB, int uv, int cr_cbp, int is_cavlc) |
| int | dct_4x4_sp (Macroblock *currMB, ColorPlane pl, int block_x, int block_y, int *coeff_cost, int intra, int is_cavlc) |
| int | dct_chroma_sp (Macroblock *currMB, int uv, int cr_cbp, int is_cavlc) |
| int | dct_chroma_sp_old (Macroblock *currMB, int uv, int cr_cbp, int is_cavlc) |
| void | copyblock_sp (Macroblock *currMB, ColorPlane pl, int block_x, int block_y) |
| int | dct_4x4_sp2 (Macroblock *currMB, ColorPlane pl, int block_x, int block_y, int *coeff_cost, int intra, int is_cavlc) |
| int | dct_chroma_sp2 (Macroblock *currMB, int uv, int cr_cbp, int is_cavlc) |
| void | select_dct (ImageParameters *img, Macroblock *currMB) |
Variables | |
| static const byte | COEFF_COST4x4 [2][16] |
| static const byte | SCAN_YUV420 [4][2] |
| static const byte | SCAN_YUV422 [8][2] |
| static const unsigned char | hor_offset [4][4][4] |
| static const unsigned char | ver_offset [4][4][4] |
| static const int | A [4][4] |
| static unsigned char | cbp_blk_chroma [8][4] |
| const byte | SNGL_SCAN [16][2] |
| const byte | FIELD_SCAN [16][2] |
| int **** | ptLevelOffset4x4 |
| static int ** | levelscale = NULL |
| static int ** | leveloffset = NULL |
| static int ** | invlevelscale = NULL |
| static int ** | levelscale_sp = NULL |
| static int ** | leveloffset_sp = NULL |
| static int ** | invlevelscale_sp = NULL |
| static int ** | fadjust4x4 = NULL |
| static int ** | fadjust2x2 = NULL |
| static int ** | fadjust4x2 = NULL |
| static int ** | levelscaleDC = NULL |
| static int ** | leveloffsetDC = NULL |
| static int ** | invlevelscaleDC = NULL |
| static int ** | M1 = NULL |
| static int ** | M4 = NULL |
Definition in file block.c.
| void copyblock_sp | ( | Macroblock * | currMB, | |
| ColorPlane | pl, | |||
| int | block_x, | |||
| int | block_y | |||
| ) |
The routine performs transform,quantization,inverse transform, adds the diff. to the prediction and writes the result to the decoded luma frame. Includes the RD constrained quantization also.
Definition at line 2456 of file block.c.
References ImageParameters::bitdepth_luma_qp_scale, ImageParameters::max_imgpel_value, ImageParameters::mb_ores, ImageParameters::mb_pred, ImageParameters::mb_rres, storable_picture::p_curr_img, ImageParameters::pix_x, ImageParameters::pix_y, and macroblock::qpsp.
Referenced by LumaResidualCoding(), and LumaResidualCoding8x8().
| int dct_16x16 | ( | Macroblock * | currMB, | |
| ColorPlane | pl, | |||
| int | new_intra_mode, | |||
| int | is_cavlc | |||
| ) |
For new intra pred routines.
Definition at line 673 of file block.c.
References ImageParameters::AdaptiveRounding, ImageParameters::ARCofAdj4x4, COEFF_COST4x4, ImageParameters::cofAC, ImageParameters::cofDC, InputParameters::disthres, FIELD_SCAN, macroblock::is_field_mode, ImageParameters::max_imgpel_value, ImageParameters::mpr_16x16, ImageParameters::opix_x, ImageParameters::opix_y, storable_picture::p_curr_img, pCurImg, ImageParameters::pix_x, ImageParameters::pix_y, macroblock::qp_scaled, SNGL_SCAN, ImageParameters::subblock_x, ImageParameters::subblock_y, and ImageParameters::type.
| int dct_16x16_ls | ( | Macroblock * | currMB, | |
| ColorPlane | pl, | |||
| int | new_intra_mode, | |||
| int | is_cavlc | |||
| ) |
For new intra pred routines.
For residual DPCM. inv. residual DCPM
Definition at line 819 of file block.c.
References ImageParameters::cofAC, ImageParameters::cofDC, FIELD_SCAN, Inv_Residual_DPCM_4x4_for_Intra16x16(), macroblock::is_field_mode, ImageParameters::mpr_16x16, ImageParameters::opix_x, ImageParameters::opix_y, storable_picture::p_curr_img, pCurImg, ImageParameters::pix_x, ImageParameters::pix_y, Residual_DPCM_4x4_for_Intra16x16(), SNGL_SCAN, and ImageParameters::type.

| int dct_4x4 | ( | Macroblock * | currMB, | |
| ColorPlane | pl, | |||
| int | block_x, | |||
| int | block_y, | |||
| int * | coeff_cost, | |||
| int | intra, | |||
| int | is_cavlc | |||
| ) |
The routine performs transform,quantization,inverse transform, adds the diff to the prediction and writes the result to the decoded luma frame.
Definition at line 977 of file block.c.
References ImageParameters::AdaptiveRounding, macroblock::ar_mode, ImageParameters::ARCofAdj4x4, COEFF_COST4x4, ImageParameters::cofAC, InputParameters::disthres, FIELD_SCAN, macroblock::is_field_mode, ImageParameters::max_imgpel_value, ImageParameters::mb_ores, ImageParameters::mb_pred, ImageParameters::mb_rres, storable_picture::p_curr_img, ImageParameters::pix_x, ImageParameters::pix_y, macroblock::qp_scaled, SNGL_SCAN, ImageParameters::subblock_x, and ImageParameters::subblock_y.
| int dct_4x4_ls | ( | Macroblock * | currMB, | |
| ColorPlane | pl, | |||
| int | block_x, | |||
| int | block_y, | |||
| int * | coeff_cost, | |||
| int | intra, | |||
| int | is_cavlc | |||
| ) |
Process for lossless coding of coefficients. The routine performs transform, quantization,inverse transform, adds the diff to the prediction and writes the result to the decoded luma frame.
Definition at line 1059 of file block.c.
References ImageParameters::AdaptiveRounding, macroblock::ar_mode, ImageParameters::ARCofAdj4x4, ImageParameters::cofAC, FIELD_SCAN, Inv_Residual_DPCM_4x4(), macroblock::is_field_mode, MAX_VALUE, ImageParameters::mb_ores, ImageParameters::mb_pred, ImageParameters::mb_rres, storable_picture::p_curr_img, ImageParameters::pix_x, ImageParameters::pix_y, Residual_DPCM_4x4(), and SNGL_SCAN.

| int dct_4x4_sp | ( | Macroblock * | currMB, | |
| ColorPlane | pl, | |||
| int | block_x, | |||
| int | block_y, | |||
| int * | coeff_cost, | |||
| int | intra, | |||
| int | is_cavlc | |||
| ) |
The routine performs transform,quantization,inverse transform, adds the diff. to the prediction and writes the result to the decoded luma frame. Includes the RD constrained quantization also.
Definition at line 1778 of file block.c.
References COEFF_COST4x4, ImageParameters::cofAC, InputParameters::disthres, FIELD_SCAN, macroblock::is_field_mode, levrun_linfo_inter(), ImageParameters::max_imgpel_value, MAX_VALUE, ImageParameters::mb_ores, ImageParameters::mb_pred, ImageParameters::mb_rres, storable_picture::p_curr_img, ImageParameters::pix_x, ImageParameters::pix_y, macroblock::qp_scaled, macroblock::qpsp, and SNGL_SCAN.

| int dct_4x4_sp2 | ( | Macroblock * | currMB, | |
| ColorPlane | pl, | |||
| int | block_x, | |||
| int | block_y, | |||
| int * | coeff_cost, | |||
| int | intra, | |||
| int | is_cavlc | |||
| ) |
Eric Setton Encoding of a secondary SP / SI frame. For an SI frame the predicted block should only come from spatial pred. The original image signal is the error coefficients of a primary SP in the raw data stream the difference with the primary SP are :
Definition at line 2537 of file block.c.
References COEFF_COST4x4, ImageParameters::cofAC, InputParameters::disthres, FIELD_SCAN, macroblock::is_field_mode, ImageParameters::max_imgpel_value, MAX_VALUE, ImageParameters::mb_pred, ImageParameters::mb_rres, storable_picture::p_curr_img, ImageParameters::pix_x, ImageParameters::pix_y, macroblock::qpsp, and SNGL_SCAN.
| int dct_chroma | ( | Macroblock * | currMB, | |
| int | uv, | |||
| int | cr_cbp, | |||
| int | is_cavlc | |||
| ) |
Transform,quantization,inverse transform for chroma. The main reason why this is done in a separate routine is the additional 2x2 transform of DC-coeffs. This routine is called once for each of the chroma components.
Definition at line 1343 of file block.c.
References _CHROMA_COEFF_COST_, ImageParameters::AdaptiveRounding, macroblock::ar_mode, ImageParameters::ARCofAdj4x4, ImageParameters::bitdepth_chroma_qp_scale, macroblock::cbp_blk, COEFF_COST4x4, ImageParameters::cofAC, ImageParameters::cofDC, InputParameters::disthres, FIELD_SCAN, hor_offset, storable_picture::imgUV, macroblock::is_field_mode, ImageParameters::is_v_block, macroblock::luma_transform_size_8x8_flag, ImageParameters::max_imgpel_value_comp, ImageParameters::mb_cr_size_x, ImageParameters::mb_cr_size_y, ImageParameters::mb_ores, ImageParameters::mb_pred, ImageParameters::mb_rres, macroblock::mb_type, ImageParameters::num_blk8x8_uv, ImageParameters::pix_c_x, ImageParameters::pix_c_y, macroblock::qpc, SCAN_YUV422, SNGL_SCAN, subblk_offset_x, ImageParameters::subblock_x, ImageParameters::subblock_y, YUV420, YUV422, and ImageParameters::yuv_format.
| int dct_chroma_ls | ( | Macroblock * | currMB, | |
| int | uv, | |||
| int | cr_cbp, | |||
| int | is_cavlc | |||
| ) |
Transform,quantization,inverse transform for chroma. The main reason why this is done in a separate routine is the additional 2x2 transform of DC-coeffs. This routine is called once for each of the chroma components.
Definition at line 1579 of file block.c.
References ImageParameters::AdaptiveRounding, macroblock::ar_mode, ImageParameters::ARCofAdj4x4, macroblock::cbp_blk, ImageParameters::cofAC, ImageParameters::cofDC, FIELD_SCAN, hor_offset, storable_picture::imgUV, macroblock::is_field_mode, macroblock::luma_transform_size_8x8_flag, MAX_VALUE, ImageParameters::mb_cr_size_x, ImageParameters::mb_cr_size_y, ImageParameters::mb_ores, ImageParameters::mb_pred, ImageParameters::mb_rres, macroblock::mb_type, ImageParameters::num_blk8x8_uv, ImageParameters::pix_c_x, ImageParameters::pix_c_y, SCAN_YUV422, SNGL_SCAN, YUV420, YUV422, and ImageParameters::yuv_format.
| int dct_chroma_sp | ( | Macroblock * | currMB, | |
| int | uv, | |||
| int | cr_cbp, | |||
| int | is_cavlc | |||
| ) |
Transform,quantization,inverse transform for chroma. The main reason why this is done in a separate routine is the additional 2x2 transform of DC-coeffs. This routine is called once for each of the chroma components.
Definition at line 1958 of file block.c.
References _CHROMA_COEFF_COST_, ImageParameters::AdaptiveRounding, macroblock::ar_mode, ImageParameters::ARCofAdj4x4, ImageParameters::bitdepth_chroma_qp_scale, macroblock::cbp_blk, COEFF_COST4x4, ImageParameters::cofAC, ImageParameters::cofDC, InputParameters::disthres, FIELD_SCAN, hor_offset, storable_picture::imgUV, macroblock::is_field_mode, macroblock::luma_transform_size_8x8_flag, ImageParameters::max_imgpel_value_comp, ImageParameters::mb_cr_size_x, ImageParameters::mb_cr_size_y, ImageParameters::mb_ores, ImageParameters::mb_pred, ImageParameters::mb_rres, macroblock::mb_type, ImageParameters::num_blk8x8_uv, ImageParameters::pix_c_x, ImageParameters::pix_c_y, macroblock::qpc, SCAN_YUV422, SNGL_SCAN, YUV420, YUV422, and ImageParameters::yuv_format.
Referenced by ChromaResidualCoding().
| int dct_chroma_sp2 | ( | Macroblock * | currMB, | |
| int | uv, | |||
| int | cr_cbp, | |||
| int | is_cavlc | |||
| ) |
Eric Setton Encoding of the chroma of a secondary SP / SI frame. For an SI frame the predicted block should only come from spatial pred. The original image signal is the error coefficients of a primary SP in the raw data stream the difference with the primary SP are :
Definition at line 2657 of file block.c.
References ImageParameters::bitdepth_chroma_qp_scale, macroblock::cbp_blk, COEFF_COST4x4, ImageParameters::cofAC, ImageParameters::cofDC, InputParameters::disthres, FIELD_SCAN, storable_picture::imgUV, macroblock::is_field_mode, ImageParameters::max_imgpel_value, MAX_VALUE, ImageParameters::mb_pred, ImageParameters::mb_rres, ImageParameters::pix_c_x, ImageParameters::pix_c_y, macroblock::qpc, macroblock::qpsp, and SNGL_SCAN.
Referenced by ChromaResidualCoding().
| void intrapred_16x16 | ( | Macroblock * | currMB, | |
| ColorPlane | pl | |||
| ) |
16x16 based luma prediction
< pixel position p(0,-1)
< pixel positions p(-1, -1..15)
Definition at line 542 of file block.c.
References pix_pos::available, ImageParameters::dc_pred_value, ImageParameters::intra_block, ImageParameters::max_imgpel_value, pix_pos::mb_addr, ImageParameters::mb_size, ImageParameters::mpr_16x16, storable_picture::p_curr_img, pix_pos::pos_x, pix_pos::pos_y, and InputParameters::UseConstrainedIntraPred.
Referenced by encode_one_macroblock_low(), and Intra16x16_Mode_Decision().
| void intrapred_4x4 | ( | Macroblock * | currMB, | |
| ColorPlane | pl, | |||
| int | img_x, | |||
| int | img_y, | |||
| int * | left_available, | |||
| int * | up_available, | |||
| int * | all_available | |||
| ) |
Make intra 4x4 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 .
Definition at line 233 of file block.c.
References pix_pos::available, ImageParameters::dc_pred_value, ImageParameters::intra_block, pix_pos::mb_addr, ImageParameters::mb_size, ImageParameters::mpr_4x4, storable_picture::p_curr_img, pix_pos::pos_x, pix_pos::pos_y, and InputParameters::UseConstrainedIntraPred.
Referenced by Mode_Decision_for_4x4IntraBlocks_JM_High(), and Mode_Decision_for_4x4IntraBlocks_JM_Low().
| static int Inv_Residual_DPCM_4x4 | ( | int ** | m7, | |
| int | block_y, | |||
| int | block_x | |||
| ) | [static] |
Inverse residual DPCM for Intra lossless coding.
Definition at line 1203 of file block.c.
Referenced by dct_4x4_ls().
| static int Inv_Residual_DPCM_4x4_for_Intra16x16 | ( | int ** | mb_ores, | |
| int | ipmode | |||
| ) | [static] |
Inverse residual DPCM for Intra lossless coding.
Definition at line 1286 of file block.c.
Referenced by dct_16x16_ls().
| static int Residual_DPCM_4x4 | ( | int | ipmode, | |
| int ** | mb_ores, | |||
| int ** | mb_rres, | |||
| int | block_y, | |||
| int | block_x | |||
| ) | [static] |
Residual DPCM for Intra lossless coding.
Definition at line 1149 of file block.c.
Referenced by dct_4x4_ls().
| static int Residual_DPCM_4x4_for_Intra16x16 | ( | int ** | mb_ores, | |
| int | ipmode | |||
| ) | [static] |
Residual DPCM for Intra lossless coding.
Definition at line 1252 of file block.c.
Referenced by dct_16x16_ls().
const int A[4][4] [static] |
unsigned char cbp_blk_chroma[8][4] [static] |
const byte COEFF_COST4x4[2][16] [static] |
Initial value:
{
{3,2,2,1,1,1,0,0,0,0,0,0,0,0,0,0},
{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9}
}
Definition at line 67 of file block.c.
Referenced by dct_16x16(), dct_4x4(), dct_4x4_sp(), dct_4x4_sp2(), dct_chroma(), dct_chroma_sp(), and dct_chroma_sp2().
| const byte FIELD_SCAN[16][2] |
Initial value:
{
{0,0},{0,1},{1,0},{0,2},
{0,3},{1,1},{1,2},{1,3},
{2,0},{2,1},{2,2},{2,3},
{3,0},{3,1},{3,2},{3,3}
}
Definition at line 173 of file block.c.
Referenced by dct_16x16(), dct_16x16_ls(), dct_4x4(), dct_4x4_ls(), dct_4x4_sp(), dct_4x4_sp2(), dct_chroma(), dct_chroma_ls(), dct_chroma_sp(), and dct_chroma_sp2().
const unsigned char hor_offset[4][4][4] [static] |
Initial value:
{
{
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 4, 0, 4},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 4, 0, 4},
{0, 4, 0, 4},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 4, 0, 4},
{8,12, 8,12},
{0, 4, 0, 4},
{8,12, 8,12}
}
}
Definition at line 91 of file block.c.
Referenced by dct_chroma(), dct_chroma_ls(), and dct_chroma_sp().
const byte SCAN_YUV420[4][2] [static] |
const byte SCAN_YUV422[8][2] [static] |
Initial value:
{
{0,0},{0,1},
{1,0},{0,2},
{0,3},{1,1},
{1,2},{1,3}
}
Definition at line 82 of file block.c.
Referenced by dct_chroma(), dct_chroma_ls(), and dct_chroma_sp().
Initial value:
{
{0,0},{1,0},{0,1},{0,2},
{1,1},{2,0},{3,0},{2,1},
{1,2},{0,3},{1,3},{2,2},
{3,1},{3,2},{2,3},{3,3}
}
Definition at line 164 of file block.c.
Referenced by dct_16x16(), dct_16x16_ls(), dct_4x4(), dct_4x4_ls(), dct_4x4_sp(), dct_4x4_sp2(), dct_chroma(), dct_chroma_ls(), dct_chroma_sp(), and dct_chroma_sp2().
const unsigned char ver_offset[4][4][4] [static] |