#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"
#include "md_common.h"
#include "transform8x8.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 (Macroblock *currMB, int **m7, int block_y, int block_x) |
void | intrapred_16x16 (Macroblock *currMB, ColorPlane pl) |
int | dct_16x16 (Macroblock *currMB, ColorPlane pl) |
int | dct_16x16_ls (Macroblock *currMB, ColorPlane pl) |
static int | check_zero (int **mb_ores, int block_x) |
int | dct_4x4 (Macroblock *currMB, ColorPlane pl, int block_x, int block_y, int *coeff_cost, int intra) |
int | dct_4x4_ls (Macroblock *currMB, ColorPlane pl, int block_x, int block_y, int *coeff_cost, int intra) |
int | dct_chroma (Macroblock *currMB, int uv, int cr_cbp) |
int | dct_chroma_ls (Macroblock *currMB, int uv, int cr_cbp) |
int | dct_4x4_sp (Macroblock *currMB, ColorPlane pl, int block_x, int block_y, int *coeff_cost, int intra) |
int | dct_chroma_sp (Macroblock *currMB, int uv, int cr_cbp) |
int | dct_chroma_sp_old (Macroblock *currMB, int uv, int cr_cbp) |
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 | dct_chroma_sp2 (Macroblock *currMB, int uv, int cr_cbp) |
void | select_dct (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 const unsigned char | cbp_blk_chroma [8][4] |
static const byte | SNGL_SCAN [16][2] |
static const byte | FIELD_SCAN [16][2] |
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 2205 of file block.c.
References img_par::max_imgpel_value, slice::mb_ores, slice::mb_pred, slice::mb_rres, storable_picture::p_curr_img, macroblock::p_slice, macroblock::pix_x, macroblock::pix_y, and slice::tblk16x16.
Referenced by luma_residual_coding(), luma_residual_coding_16x16(), luma_residual_coding_8x8(), luma_residual_coding_p444(), luma_residual_coding_p444_16x16(), and luma_residual_coding_p444_8x8().
int dct_16x16 | ( | Macroblock * | currMB, | |
ColorPlane | pl | |||
) |
For new intra pred routines.
Definition at line 350 of file block.c.
References img_par::AdaptiveRounding, img_par::ARCofAdj4x4, COEFF_COST4x4, slice::cofAC, slice::cofDC, FIELD_SCAN, img_par::max_imgpel_value, slice::mpr_16x16, macroblock::opix_y, storable_picture::p_curr_img, macroblock::p_slice, img_par::pCurImg, macroblock::pix_x, macroblock::pix_y, macroblock::qp_scaled, slice::slice_type, SNGL_SCAN, macroblock::subblock_x, macroblock::subblock_y, slice::tblk16x16, and slice::tblk4x4.
int dct_16x16_ls | ( | Macroblock * | currMB, | |
ColorPlane | pl | |||
) |
For new intra pred routines.
For residual DPCM. inv. residual DCPM
Definition at line 508 of file block.c.
References slice::cofAC, slice::cofDC, FIELD_SCAN, Inv_Residual_DPCM_4x4_for_Intra16x16(), slice::mpr_16x16, macroblock::opix_y, storable_picture::p_curr_img, macroblock::p_slice, img_par::pCurImg, macroblock::pix_x, macroblock::pix_y, Residual_DPCM_4x4_for_Intra16x16(), slice::slice_type, SNGL_SCAN, slice::tblk16x16, and slice::tblk4x4.
int dct_4x4 | ( | Macroblock * | currMB, | |
ColorPlane | pl, | |||
int | block_x, | |||
int | block_y, | |||
int * | coeff_cost, | |||
int | intra | |||
) |
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 686 of file block.c.
References img_par::AdaptiveRounding, macroblock::ar_mode, img_par::ARCofAdj4x4, COEFF_COST4x4, slice::cofAC, copy_image_data_4x4(), FIELD_SCAN, img_par::max_imgpel_value, slice::mb_ores, slice::mb_pred, slice::mb_rres, storable_picture::p_curr_img, macroblock::p_slice, macroblock::pix_x, macroblock::pix_y, macroblock::qp_scaled, SNGL_SCAN, macroblock::subblock_x, macroblock::subblock_y, and slice::tblk16x16.
int dct_4x4_ls | ( | Macroblock * | currMB, | |
ColorPlane | pl, | |||
int | block_x, | |||
int | block_y, | |||
int * | coeff_cost, | |||
int | intra | |||
) |
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 776 of file block.c.
References img_par::AdaptiveRounding, macroblock::ar_mode, img_par::ARCofAdj4x4, slice::cofAC, FIELD_SCAN, Inv_Residual_DPCM_4x4(), MAX_VALUE, slice::mb_ores, slice::mb_pred, slice::mb_rres, storable_picture::p_curr_img, macroblock::p_slice, macroblock::pix_x, macroblock::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 | |||
) |
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 1514 of file block.c.
References COEFF_COST4x4, slice::cofAC, FIELD_SCAN, levrun_linfo_inter(), img_par::max_imgpel_value, MAX_VALUE, slice::mb_ores, slice::mb_pred, slice::mb_rres, storable_picture::p_curr_img, macroblock::p_Img, macroblock::p_slice, macroblock::pix_x, macroblock::pix_y, macroblock::qp_scaled, SNGL_SCAN, and slice::tblk16x16.
int dct_4x4_sp2 | ( | Macroblock * | currMB, | |
ColorPlane | pl, | |||
int | block_x, | |||
int | block_y, | |||
int * | coeff_cost, | |||
int | intra | |||
) |
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 2286 of file block.c.
References COEFF_COST4x4, slice::cofAC, FIELD_SCAN, img_par::max_imgpel_value, MAX_VALUE, slice::mb_pred, slice::mb_rres, storable_picture::p_curr_img, macroblock::p_slice, macroblock::pix_x, macroblock::pix_y, SNGL_SCAN, and slice::tblk16x16.
int dct_chroma | ( | Macroblock * | currMB, | |
int | uv, | |||
int | cr_cbp | |||
) |
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 1063 of file block.c.
References _CHROMA_COEFF_COST_, img_par::AdaptiveRounding, macroblock::ar_mode, img_par::ARCofAdj4x4, macroblock::cbp_blk, COEFF_COST4x4, slice::cofAC, slice::cofDC, copy_image_data(), FIELD_SCAN, hor_offset, storable_picture::imgUV, img_par::max_pel_value_comp, slice::mb_ores, slice::mb_pred, slice::mb_rres, macroblock::mb_type, macroblock::p_slice, macroblock::pix_c_x, macroblock::pix_c_y, macroblock::qpc, SCAN_YUV422, SNGL_SCAN, subblk_offset_x, macroblock::subblock_x, macroblock::subblock_y, slice::tblk4x4, YUV420, and YUV422.
int dct_chroma_ls | ( | Macroblock * | currMB, | |
int | uv, | |||
int | cr_cbp | |||
) |
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 1318 of file block.c.
References img_par::AdaptiveRounding, macroblock::ar_mode, img_par::ARCofAdj4x4, macroblock::cbp_blk, slice::cofAC, slice::cofDC, FIELD_SCAN, hor_offset, storable_picture::imgUV, MAX_VALUE, slice::mb_ores, slice::mb_pred, slice::mb_rres, macroblock::mb_type, macroblock::p_slice, macroblock::pix_c_x, macroblock::pix_c_y, SCAN_YUV422, SNGL_SCAN, slice::tblk4x4, YUV420, and YUV422.
int dct_chroma_sp | ( | Macroblock * | currMB, | |
int | uv, | |||
int | cr_cbp | |||
) |
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 1691 of file block.c.
References _CHROMA_COEFF_COST_, img_par::AdaptiveRounding, macroblock::ar_mode, img_par::ARCofAdj4x4, macroblock::cbp_blk, COEFF_COST4x4, slice::cofAC, slice::cofDC, copy_image_data(), FIELD_SCAN, hor_offset, storable_picture::imgUV, img_par::max_pel_value_comp, slice::mb_ores, slice::mb_pred, slice::mb_rres, macroblock::mb_type, macroblock::p_slice, macroblock::pix_c_x, macroblock::pix_c_y, macroblock::qpc, SCAN_YUV422, SNGL_SCAN, slice::tblk4x4, YUV420, and YUV422.
Referenced by chroma_residual_coding().
int dct_chroma_sp2 | ( | Macroblock * | currMB, | |
int | uv, | |||
int | cr_cbp | |||
) |
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 2404 of file block.c.
References macroblock::cbp_blk, COEFF_COST4x4, slice::cofAC, slice::cofDC, FIELD_SCAN, storable_picture::imgUV, img_par::max_imgpel_value, MAX_VALUE, slice::mb_pred, slice::mb_rres, macroblock::p_slice, macroblock::pix_c_x, macroblock::pix_c_y, macroblock::qpc, SNGL_SCAN, and slice::tblk16x16.
Referenced by chroma_residual_coding().
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 205 of file block.c.
References img_par::dc_pred_value, img_par::max_imgpel_value, slice::mpr_16x16, storable_picture::p_curr_img, macroblock::p_slice, and inp_par_enc::UseConstrainedIntraPred.
Referenced by encode_one_macroblock_low(), Intra16x16_Mode_Decision444(), Intra16x16_Mode_Decision_RDopt(), and Intra16x16_Mode_Decision_SAD().
static int Inv_Residual_DPCM_4x4 | ( | Macroblock * | currMB, | |
int ** | m7, | |||
int | block_y, | |||
int | block_x | |||
) | [static] |
Inverse residual DPCM for Intra lossless coding.
Definition at line 923 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 1006 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 869 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 972 of file block.c.
Referenced by dct_16x16_ls().
const int A[4][4] [static] |
const 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 71 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] [static] |
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 177 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 95 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 86 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 168 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] |