mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-23 18:14:06 +00:00
Refactor: encoder.h renaming
This commit is contained in:
parent
0a6c38a8e9
commit
0bf4f65a55
|
@ -31,7 +31,7 @@ void close_cu_file(FILE *fp) {
|
|||
*/
|
||||
unsigned render_cu_file(encoder_control *encoder, unsigned depth, uint16_t xCtb, uint16_t yCtb, FILE *fp)
|
||||
{
|
||||
CU_info *cu = &encoder->in.cur_pic->CU[depth][xCtb + yCtb * (encoder->in.width_in_LCU<<MAX_DEPTH)];
|
||||
CU_info *cu = &encoder->in.cur_pic->CU[depth][xCtb + yCtb * (encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
unsigned lambda_cost = (4 * g_lambda_cost[encoder->QP]) << 4;
|
||||
unsigned sum = 0;
|
||||
unsigned best_cost = -1;
|
||||
|
|
|
@ -168,8 +168,8 @@
|
|||
encoder->in.video_format = FORMAT_420;
|
||||
/* deblocking */
|
||||
encoder->deblock_enable = 1;
|
||||
encoder->betaOffsetdiv2 = 0;
|
||||
encoder->tcOffsetdiv2 = 0;
|
||||
encoder->beta_offset_div2 = 0;
|
||||
encoder->tc_offset_div2 = 0;
|
||||
/* SAO */
|
||||
encoder->sao_enable = 0;
|
||||
|
||||
|
@ -222,7 +222,7 @@
|
|||
/* Add current picture as reference */
|
||||
picture_list_add(encoder->ref, encoder->in.cur_pic);
|
||||
/* Allocate new memory to current picture */
|
||||
encoder->in.cur_pic = picture_init(encoder->in.width, encoder->in.height, encoder->in.width_in_LCU, encoder->in.height_in_LCU);
|
||||
encoder->in.cur_pic = picture_init(encoder->in.width, encoder->in.height, encoder->in.width_in_lcu, encoder->in.height_in_lcu);
|
||||
|
||||
encoder->frame++;
|
||||
}
|
||||
|
|
136
src/encoder.c
136
src/encoder.c
|
@ -35,7 +35,7 @@
|
|||
#include "search.h"
|
||||
|
||||
int16_t g_lambda_cost[55];
|
||||
uint32_t* g_auiSigLastScan[3][7];
|
||||
uint32_t* g_sig_last_scan[3][7];
|
||||
|
||||
/* Local functions. */
|
||||
static void add_checksum(encoder_control* encoder);
|
||||
|
@ -55,7 +55,7 @@ void initSigLastScan(uint32_t* pBuffD, uint32_t* pBuffH, uint32_t* pBuffV, int32
|
|||
uint32_t* pBuffTemp = pBuffD;
|
||||
if( iWidth == 8 )
|
||||
{
|
||||
pBuffTemp = (uint32_t *)g_sigLastScanCG32x32;
|
||||
pBuffTemp = (uint32_t *)g_sig_last_scan_32x32;
|
||||
}
|
||||
for( uiScanLine = 0; uiNextScanPos < uiNumScanPos; uiScanLine++ )
|
||||
{
|
||||
|
@ -79,15 +79,15 @@ void initSigLastScan(uint32_t* pBuffD, uint32_t* pBuffH, uint32_t* pBuffV, int32
|
|||
{
|
||||
uint32_t uiNumBlkSide = iWidth >> 2;
|
||||
uint32_t uiNumBlks = uiNumBlkSide * uiNumBlkSide;
|
||||
uint32_t log2Blk = g_aucConvertToBit[ uiNumBlkSide ] + 1;
|
||||
uint32_t log2Blk = g_convert_to_bit[ uiNumBlkSide ] + 1;
|
||||
|
||||
for(uiBlk = 0; uiBlk < uiNumBlks; uiBlk++ )
|
||||
{
|
||||
uint32_t initBlkPos = g_auiSigLastScan[ SCAN_DIAG ][ log2Blk ][ uiBlk ];
|
||||
uint32_t initBlkPos = g_sig_last_scan[ SCAN_DIAG ][ log2Blk ][ uiBlk ];
|
||||
uiNextScanPos = 0;
|
||||
if( iWidth == 32 )
|
||||
{
|
||||
initBlkPos = g_sigLastScanCG32x32[ uiBlk ];
|
||||
initBlkPos = g_sig_last_scan_32x32[ uiBlk ];
|
||||
}
|
||||
{
|
||||
uint32_t offsetY = initBlkPos / uiNumBlkSide;
|
||||
|
@ -179,22 +179,22 @@ void init_tables(void)
|
|||
{
|
||||
int i;
|
||||
int c = 0;
|
||||
memset( g_aucConvertToBit,-1, sizeof( g_aucConvertToBit ) );
|
||||
memset( g_convert_to_bit,-1, sizeof( g_convert_to_bit ) );
|
||||
for ( i=4; i<(1<<7); i*=2 )
|
||||
{
|
||||
g_aucConvertToBit[i] = c;
|
||||
g_convert_to_bit[i] = c;
|
||||
c++;
|
||||
}
|
||||
g_aucConvertToBit[i] = c;
|
||||
g_convert_to_bit[i] = c;
|
||||
|
||||
c = 2;
|
||||
for ( i=0; i<7; i++ )
|
||||
{
|
||||
g_auiSigLastScan[0][i] = (uint32_t*)malloc(c*c*sizeof(uint32_t));
|
||||
g_auiSigLastScan[1][i] = (uint32_t*)malloc(c*c*sizeof(uint32_t));
|
||||
g_auiSigLastScan[2][i] = (uint32_t*)malloc(c*c*sizeof(uint32_t));
|
||||
g_sig_last_scan[0][i] = (uint32_t*)malloc(c*c*sizeof(uint32_t));
|
||||
g_sig_last_scan[1][i] = (uint32_t*)malloc(c*c*sizeof(uint32_t));
|
||||
g_sig_last_scan[2][i] = (uint32_t*)malloc(c*c*sizeof(uint32_t));
|
||||
|
||||
initSigLastScan( g_auiSigLastScan[0][i], g_auiSigLastScan[1][i], g_auiSigLastScan[2][i], c, c);
|
||||
initSigLastScan( g_sig_last_scan[0][i], g_sig_last_scan[1][i], g_sig_last_scan[2][i], c, c);
|
||||
c <<= 1;
|
||||
}
|
||||
|
||||
|
@ -231,21 +231,21 @@ void init_encoder_input(encoder_input* input,FILE* inputfile, int32_t width, int
|
|||
input->height += CU_MIN_SIZE_PIXELS - (height % CU_MIN_SIZE_PIXELS);
|
||||
}
|
||||
|
||||
input->height_in_LCU = input->height / LCU_WIDTH;
|
||||
input->width_in_LCU = input->width / LCU_WIDTH;
|
||||
input->height_in_lcu = input->height / LCU_WIDTH;
|
||||
input->width_in_lcu = input->width / LCU_WIDTH;
|
||||
|
||||
/* Add one extra LCU when image not divisible by LCU_WIDTH */
|
||||
if(input->height_in_LCU * LCU_WIDTH < height)
|
||||
if(input->height_in_lcu * LCU_WIDTH < height)
|
||||
{
|
||||
input->height_in_LCU++;
|
||||
input->height_in_lcu++;
|
||||
}
|
||||
if(input->width_in_LCU * LCU_WIDTH < width)
|
||||
if(input->width_in_lcu * LCU_WIDTH < width)
|
||||
{
|
||||
input->width_in_LCU++;
|
||||
input->width_in_lcu++;
|
||||
}
|
||||
|
||||
/* Allocate the picture and CU array */
|
||||
input->cur_pic = picture_init(input->width, input->height, input->width_in_LCU,input->height_in_LCU);
|
||||
input->cur_pic = picture_init(input->width, input->height, input->width_in_lcu,input->height_in_lcu);
|
||||
|
||||
if(!input->cur_pic)
|
||||
{
|
||||
|
@ -517,8 +517,8 @@ void encode_pic_parameter_set(encoder_control* encoder)
|
|||
//IF !disabled
|
||||
if(encoder->deblock_enable)
|
||||
{
|
||||
WRITE_SE(encoder->stream, encoder->betaOffsetdiv2, "beta_offset_div2");
|
||||
WRITE_SE(encoder->stream, encoder->tcOffsetdiv2, "tc_offset_div2");
|
||||
WRITE_SE(encoder->stream, encoder->beta_offset_div2, "beta_offset_div2");
|
||||
WRITE_SE(encoder->stream, encoder->tc_offset_div2, "tc_offset_div2");
|
||||
}
|
||||
//ENDIF
|
||||
//ENDIF
|
||||
|
@ -801,12 +801,12 @@ void encode_slice_data(encoder_control* encoder)
|
|||
init_contexts(encoder,encoder->in.cur_pic->slicetype);
|
||||
|
||||
/* Loop through every LCU in the slice */
|
||||
for(yCtb = 0; yCtb < encoder->in.height_in_LCU; yCtb++)
|
||||
for(yCtb = 0; yCtb < encoder->in.height_in_lcu; yCtb++)
|
||||
{
|
||||
uint8_t lastCUy = (yCtb == (encoder->in.height_in_LCU-1))?1:0;
|
||||
for(xCtb = 0; xCtb < encoder->in.width_in_LCU; xCtb++)
|
||||
uint8_t lastCUy = (yCtb == (encoder->in.height_in_lcu-1))?1:0;
|
||||
for(xCtb = 0; xCtb < encoder->in.width_in_lcu; xCtb++)
|
||||
{
|
||||
uint8_t lastCUx = (xCtb == (encoder->in.width_in_LCU-1))?1:0;
|
||||
uint8_t lastCUx = (xCtb == (encoder->in.width_in_lcu-1))?1:0;
|
||||
uint8_t depth = 0;
|
||||
|
||||
/* Recursive function for looping through all the sub-blocks */
|
||||
|
@ -823,7 +823,7 @@ void encode_slice_data(encoder_control* encoder)
|
|||
|
||||
void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, uint8_t depth)
|
||||
{
|
||||
CU_info *cur_CU = &encoder->in.cur_pic->CU[depth][xCtb+yCtb*(encoder->in.width_in_LCU<<MAX_DEPTH)];
|
||||
CU_info *cur_CU = &encoder->in.cur_pic->CU[depth][xCtb+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
uint8_t split_flag = cur_CU->split;
|
||||
uint8_t split_model = 0;
|
||||
|
||||
|
@ -842,11 +842,11 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
|
|||
if(!border)
|
||||
{
|
||||
/* Get left and top block split_flags and if they are present and true, increase model number */
|
||||
if(xCtb > 0 && GET_SPLITDATA(&(encoder->in.cur_pic->CU[depth][xCtb-1+yCtb*(encoder->in.width_in_LCU<<MAX_DEPTH)]),depth) == 1)
|
||||
if(xCtb > 0 && GET_SPLITDATA(&(encoder->in.cur_pic->CU[depth][xCtb-1+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)]),depth) == 1)
|
||||
{
|
||||
split_model++;
|
||||
}
|
||||
if(yCtb > 0 && GET_SPLITDATA(&(encoder->in.cur_pic->CU[depth][xCtb+(yCtb-1)*(encoder->in.width_in_LCU<<MAX_DEPTH)]),depth) == 1)
|
||||
if(yCtb > 0 && GET_SPLITDATA(&(encoder->in.cur_pic->CU[depth][xCtb+(yCtb-1)*(encoder->in.width_in_lcu<<MAX_DEPTH)]),depth) == 1)
|
||||
{
|
||||
split_model++;
|
||||
}
|
||||
|
@ -1112,7 +1112,7 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
|
|||
transform_info ti;
|
||||
memset(&ti, 0, sizeof(transform_info));
|
||||
|
||||
ti.xCtb = xCtb; ti.yCtb = yCtb;
|
||||
ti.x_ctb = xCtb; ti.y_ctb = yCtb;
|
||||
|
||||
/* Coded block pattern */
|
||||
ti.cb_top[0] = 0;
|
||||
|
@ -1275,25 +1275,25 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
|
|||
transform_info ti;
|
||||
memset(&ti, 0, sizeof(transform_info));
|
||||
|
||||
ti.xCtb = xCtb; ti.yCtb = yCtb;
|
||||
ti.x_ctb = xCtb; ti.y_ctb = yCtb;
|
||||
|
||||
/* Base pointers */
|
||||
ti.base = base; ti.baseU = baseU; ti.baseV = baseV;
|
||||
ti.base = base; ti.base_u = baseU; ti.base_v = baseV;
|
||||
ti.base_stride = encoder->in.width;
|
||||
|
||||
/* Prediction pointers */
|
||||
ti.pred = pred; ti.predU = predU; ti.predV = predV;
|
||||
ti.pred = pred; ti.pred_u = predU; ti.pred_v = predV;
|
||||
ti.pred_stride = (LCU_WIDTH>>depth);
|
||||
|
||||
/* Reconstruction pointers */
|
||||
ti.recbase = recbase; ti.recbaseU = recbaseU; ti.recbaseV = recbaseV;
|
||||
ti.recbase = recbase; ti.recbase_u = recbaseU; ti.recbase_v = recbaseV;
|
||||
ti.recbase_stride = encoder->in.width;
|
||||
|
||||
/* Coeff pointers */
|
||||
ti.coeff[0] = coeff; ti.coeff[1] = coeffU; ti.coeff[2] = coeffV;
|
||||
|
||||
/* Prediction info */
|
||||
ti.intraPredMode = intraPredMode; ti.intraPredModeChroma = intraPredModeChroma;
|
||||
ti.intra_pred_mode = intraPredMode; ti.intra_pred_mode_chroma = intraPredModeChroma;
|
||||
|
||||
/* Handle transforms, quant and reconstruction */
|
||||
ti.idx = 0;
|
||||
|
@ -1385,11 +1385,11 @@ void encode_transform_tree(encoder_control* encoder,transform_info* ti,uint8_t d
|
|||
{
|
||||
uint8_t change = 1<<(MAX_DEPTH-1-depth);
|
||||
ti->idx = 0; encode_transform_tree(encoder,ti,depth+1);
|
||||
ti->xCtb += change;
|
||||
ti->x_ctb += change;
|
||||
ti->idx = 1; encode_transform_tree(encoder,ti,depth+1);
|
||||
ti->xCtb -= change; ti->yCtb += change;
|
||||
ti->x_ctb -= change; ti->y_ctb += change;
|
||||
ti->idx = 2; encode_transform_tree(encoder,ti,depth+1);
|
||||
ti->xCtb += change;
|
||||
ti->x_ctb += change;
|
||||
ti->idx = 3; encode_transform_tree(encoder,ti,depth+1);
|
||||
return;
|
||||
}
|
||||
|
@ -1410,16 +1410,16 @@ void encode_transform_tree(encoder_control* encoder,transform_info* ti,uint8_t d
|
|||
int32_t pred_offset_c[4] = {0, width>>1, (ti->pred_stride>>1)*(width>>1) , (ti->pred_stride>>1)*(width>>1) +(width>>1)};
|
||||
|
||||
uint8_t* base = &ti->base[base_offset[ti->idx]];
|
||||
uint8_t* baseU = &ti->baseU[base_offset_c[ti->idx]];
|
||||
uint8_t* baseV = &ti->baseV[base_offset_c[ti->idx]];
|
||||
uint8_t* baseU = &ti->base_u[base_offset_c[ti->idx]];
|
||||
uint8_t* baseV = &ti->base_v[base_offset_c[ti->idx]];
|
||||
|
||||
uint8_t* recbase = &ti->recbase[recbase_offset[ti->idx]];
|
||||
uint8_t* recbaseU = &ti->recbaseU[recbase_offset_c[ti->idx]];
|
||||
uint8_t* recbaseV = &ti->recbaseV[recbase_offset_c[ti->idx]];
|
||||
uint8_t* recbaseU = &ti->recbase_u[recbase_offset_c[ti->idx]];
|
||||
uint8_t* recbaseV = &ti->recbase_v[recbase_offset_c[ti->idx]];
|
||||
|
||||
int16_t* pred = &ti->pred[pred_offset[ti->idx]];
|
||||
int16_t* predU = &ti->predU[pred_offset_c[ti->idx]];
|
||||
int16_t* predV = &ti->predV[pred_offset_c[ti->idx]];
|
||||
int16_t* predU = &ti->pred_u[pred_offset_c[ti->idx]];
|
||||
int16_t* predV = &ti->pred_v[pred_offset_c[ti->idx]];
|
||||
|
||||
int16_t* coeff = &ti->coeff[0][ti->idx*coeff_fourth];
|
||||
int16_t* coeffU = &ti->coeff[1][ti->idx*coeff_fourth>>1];
|
||||
|
@ -1440,25 +1440,25 @@ void encode_transform_tree(encoder_control* encoder,transform_info* ti,uint8_t d
|
|||
uint32_t ac_sum = 0;
|
||||
|
||||
/* Build reconstructed block to use in prediction with extrapolated borders */
|
||||
intra_buildReferenceBorder(encoder->in.cur_pic, ti->xCtb, ti->yCtb,(LCU_WIDTH>>(depth))*2+8, rec, (LCU_WIDTH>>(depth))*2+8, 0);
|
||||
intra_recon(recShift,(LCU_WIDTH>>(depth))*2+8,ti->xCtb*(LCU_WIDTH>>(MAX_DEPTH)),ti->yCtb*(LCU_WIDTH>>(MAX_DEPTH)),width,pred,pred_stride,ti->intraPredMode,0);
|
||||
intra_buildReferenceBorder(encoder->in.cur_pic, ti->x_ctb, ti->y_ctb,(LCU_WIDTH>>(depth))*2+8, rec, (LCU_WIDTH>>(depth))*2+8, 0);
|
||||
intra_recon(recShift,(LCU_WIDTH>>(depth))*2+8,ti->x_ctb*(LCU_WIDTH>>(MAX_DEPTH)),ti->y_ctb*(LCU_WIDTH>>(MAX_DEPTH)),width,pred,pred_stride,ti->intra_pred_mode,0);
|
||||
|
||||
/* Filter DC-prediction */
|
||||
if(ti->intraPredMode == 1 && width < 32)
|
||||
if(ti->intra_pred_mode == 1 && width < 32)
|
||||
{
|
||||
intra_DCPredFiltering(recShift,(LCU_WIDTH>>(depth))*2+8,pred,width,LCU_WIDTH>>depth,LCU_WIDTH>>depth);
|
||||
}
|
||||
if(ti->intraPredModeChroma != 36 && ti->intraPredModeChroma == ti->intraPredMode)
|
||||
if(ti->intra_pred_mode_chroma != 36 && ti->intra_pred_mode_chroma == ti->intra_pred_mode)
|
||||
{
|
||||
ti->intraPredModeChroma = 36;
|
||||
ti->intra_pred_mode_chroma = 36;
|
||||
}
|
||||
intra_buildReferenceBorder(encoder->in.cur_pic, ti->xCtb, ti->yCtb,(LCU_WIDTH>>(depth+1))*2+8, rec, (LCU_WIDTH>>(depth+1))*2+8, 1);
|
||||
intra_recon(recShiftU,(LCU_WIDTH>>(depth+1))*2+8,ti->xCtb*(LCU_WIDTH>>(MAX_DEPTH+1)),ti->yCtb*(LCU_WIDTH>>(MAX_DEPTH+1)),width>>1,predU,pred_stride>>1,ti->intraPredModeChroma!=36?ti->intraPredModeChroma:ti->intraPredMode,1);
|
||||
intra_buildReferenceBorder(encoder->in.cur_pic, ti->xCtb, ti->yCtb,(LCU_WIDTH>>(depth+1))*2+8, rec, (LCU_WIDTH>>(depth+1))*2+8, 2);
|
||||
intra_recon(recShiftU,(LCU_WIDTH>>(depth+1))*2+8,ti->xCtb*(LCU_WIDTH>>(MAX_DEPTH+1)),ti->yCtb*(LCU_WIDTH>>(MAX_DEPTH+1)),width>>1,predV,pred_stride>>1,ti->intraPredModeChroma!=36?ti->intraPredModeChroma:ti->intraPredMode,1);
|
||||
intra_buildReferenceBorder(encoder->in.cur_pic, ti->x_ctb, ti->y_ctb,(LCU_WIDTH>>(depth+1))*2+8, rec, (LCU_WIDTH>>(depth+1))*2+8, 1);
|
||||
intra_recon(recShiftU,(LCU_WIDTH>>(depth+1))*2+8,ti->x_ctb*(LCU_WIDTH>>(MAX_DEPTH+1)),ti->y_ctb*(LCU_WIDTH>>(MAX_DEPTH+1)),width>>1,predU,pred_stride>>1,ti->intra_pred_mode_chroma!=36?ti->intra_pred_mode_chroma:ti->intra_pred_mode,1);
|
||||
intra_buildReferenceBorder(encoder->in.cur_pic, ti->x_ctb, ti->y_ctb,(LCU_WIDTH>>(depth+1))*2+8, rec, (LCU_WIDTH>>(depth+1))*2+8, 2);
|
||||
intra_recon(recShiftU,(LCU_WIDTH>>(depth+1))*2+8,ti->x_ctb*(LCU_WIDTH>>(MAX_DEPTH+1)),ti->y_ctb*(LCU_WIDTH>>(MAX_DEPTH+1)),width>>1,predV,pred_stride>>1,ti->intra_pred_mode_chroma!=36?ti->intra_pred_mode_chroma:ti->intra_pred_mode,1);
|
||||
|
||||
/* This affects reconstruction, do after that */
|
||||
picture_setBlockCoded(encoder->in.cur_pic, ti->xCtb, ti->yCtb, depth, 1);
|
||||
picture_setBlockCoded(encoder->in.cur_pic, ti->x_ctb, ti->y_ctb, depth, 1);
|
||||
|
||||
/* INTRA PREDICTION ENDS HERE */
|
||||
|
||||
|
@ -1649,7 +1649,7 @@ void encode_transform_coeff(encoder_control* encoder,transform_info* ti,int8_t d
|
|||
|
||||
if(depth != 0 && depth != MAX_DEPTH+1)
|
||||
{
|
||||
cabac.ctx = &g_trans_subdiv_model[5-((g_aucConvertToBit[LCU_WIDTH]+2)-depth)];
|
||||
cabac.ctx = &g_trans_subdiv_model[5-((g_convert_to_bit[LCU_WIDTH]+2)-depth)];
|
||||
CABAC_BIN(&cabac,split,"TransformSubdivFlag");
|
||||
}
|
||||
|
||||
|
@ -1710,7 +1710,7 @@ void encode_transform_coeff(encoder_control* encoder,transform_info* ti,int8_t d
|
|||
if(CbY)
|
||||
{
|
||||
/* Luma (Intra) scanmode */
|
||||
uiDirMode = ti->intraPredMode;
|
||||
uiDirMode = ti->intra_pred_mode;
|
||||
if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size
|
||||
{
|
||||
uiScanIdx = abs((int32_t) uiDirMode - 26) < 5 ? 1 : (abs((int32_t)uiDirMode - 10) < 5 ? 2 : 0);
|
||||
|
@ -1722,11 +1722,11 @@ void encode_transform_coeff(encoder_control* encoder,transform_info* ti,int8_t d
|
|||
int8_t chromaWidth = width>>1;
|
||||
/* Chroma scanmode */
|
||||
uiCTXIdx++;
|
||||
uiDirMode = ti->intraPredModeChroma;
|
||||
uiDirMode = ti->intra_pred_mode_chroma;
|
||||
if(uiDirMode==36)
|
||||
{
|
||||
/* TODO: support NxN */
|
||||
uiDirMode = ti->intraPredMode;
|
||||
uiDirMode = ti->intra_pred_mode;
|
||||
}
|
||||
uiScanIdx = SCAN_DIAG;
|
||||
if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size
|
||||
|
@ -1766,8 +1766,8 @@ void encode_CoeffNxN(encoder_control* encoder,int16_t* coeff, uint8_t width, uin
|
|||
|
||||
/* CONSTANTS */
|
||||
const uint32_t uiNumBlkSide = width >> shift;
|
||||
const uint32_t uiLog2BlockSize = g_aucConvertToBit[ width ] + 2;
|
||||
const uint32_t* scan = g_auiSigLastScan[ scanMode ][ uiLog2BlockSize - 1 ];
|
||||
const uint32_t uiLog2BlockSize = g_convert_to_bit[ width ] + 2;
|
||||
const uint32_t* scan = g_sig_last_scan[ scanMode ][ uiLog2BlockSize - 1 ];
|
||||
const uint32_t* scanCG = NULL;
|
||||
|
||||
/* Init base contexts according to block type */
|
||||
|
@ -1784,14 +1784,14 @@ void encode_CoeffNxN(encoder_control* encoder,int16_t* coeff, uint8_t width, uin
|
|||
}
|
||||
}
|
||||
|
||||
scanCG = g_auiSigLastScan[ scanMode ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-3 : 0 ];
|
||||
scanCG = g_sig_last_scan[ scanMode ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-3 : 0 ];
|
||||
if( uiLog2BlockSize == 3 )
|
||||
{
|
||||
scanCG = g_sigLastScan8x8[ scanMode ];
|
||||
scanCG = g_sig_last_scan_8x8[ scanMode ];
|
||||
}
|
||||
else if( uiLog2BlockSize == 5 )
|
||||
{
|
||||
scanCG = g_sigLastScanCG32x32;
|
||||
scanCG = g_sig_last_scan_32x32;
|
||||
}
|
||||
|
||||
scanPosLast = -1;
|
||||
|
@ -1989,8 +1989,8 @@ void encode_lastSignificantXY(encoder_control* encoder,uint8_t lastpos_x, uint8_
|
|||
{
|
||||
SWAP( lastpos_x, lastpos_y,uint8_t );
|
||||
}
|
||||
uiGroupIdxX = g_uiGroupIdx[lastpos_x];
|
||||
uiGroupIdxY = g_uiGroupIdx[lastpos_y];
|
||||
uiGroupIdxX = g_group_idx[lastpos_x];
|
||||
uiGroupIdxY = g_group_idx[lastpos_y];
|
||||
|
||||
/* Last X binarization */
|
||||
for(last_x = 0; last_x < uiGroupIdxX ; last_x++)
|
||||
|
@ -1998,7 +1998,7 @@ void encode_lastSignificantXY(encoder_control* encoder,uint8_t lastpos_x, uint8_
|
|||
cabac.ctx = &basectxX[offset_x+(last_x>>shift_x)];
|
||||
CABAC_BIN(&cabac,1,"LastSignificantX");
|
||||
}
|
||||
if(uiGroupIdxX < g_uiGroupIdx[width-1])
|
||||
if(uiGroupIdxX < g_group_idx[width-1])
|
||||
{
|
||||
cabac.ctx = &basectxX[offset_x+(last_x>>shift_x)];
|
||||
CABAC_BIN(&cabac,0,"LastSignificantX");
|
||||
|
@ -2010,7 +2010,7 @@ void encode_lastSignificantXY(encoder_control* encoder,uint8_t lastpos_x, uint8_
|
|||
cabac.ctx = &basectxY[offset_y+(last_y>>shift_y)];
|
||||
CABAC_BIN(&cabac,1,"LastSignificantY");
|
||||
}
|
||||
if(uiGroupIdxY < g_uiGroupIdx[height-1])
|
||||
if(uiGroupIdxY < g_group_idx[height-1])
|
||||
{
|
||||
cabac.ctx = &basectxY[offset_y+(last_y>>shift_y)];
|
||||
CABAC_BIN(&cabac,0,"LastSignificantY");
|
||||
|
@ -2019,7 +2019,7 @@ void encode_lastSignificantXY(encoder_control* encoder,uint8_t lastpos_x, uint8_
|
|||
/* Last X */
|
||||
if(uiGroupIdxX > 3)
|
||||
{
|
||||
lastpos_x -= g_uiMinInGroup[uiGroupIdxX];
|
||||
lastpos_x -= g_min_in_group[uiGroupIdxX];
|
||||
for(i = ((uiGroupIdxX-2)>>1)-1; i>=0; i--)
|
||||
{
|
||||
CABAC_BIN_EP(&cabac,(lastpos_x>>i) & 1,"LastSignificantX");
|
||||
|
@ -2028,7 +2028,7 @@ void encode_lastSignificantXY(encoder_control* encoder,uint8_t lastpos_x, uint8_
|
|||
/* Last Y */
|
||||
if(uiGroupIdxY > 3)
|
||||
{
|
||||
lastpos_y -= g_uiMinInGroup[uiGroupIdxY];
|
||||
lastpos_y -= g_min_in_group[uiGroupIdxY];
|
||||
for(i = ((uiGroupIdxY-2)>>1)-1; i>=0; i--)
|
||||
{
|
||||
CABAC_BIN_EP(&cabac,(lastpos_y>>i) & 1,"LastSignificantY");
|
||||
|
|
|
@ -39,8 +39,8 @@ typedef struct
|
|||
int32_t height; /*!< \brief input picture height */
|
||||
int32_t real_width; /*!< \brief real input picture width */
|
||||
int32_t real_height; /*!< \brief real input picture width */
|
||||
int32_t height_in_LCU; /*!< \brief input picture width in LCU*/
|
||||
int32_t width_in_LCU; /*!< \brief input picture height in LCU */
|
||||
int32_t height_in_lcu; /*!< \brief input picture width in LCU*/
|
||||
int32_t width_in_lcu; /*!< \brief input picture height in LCU */
|
||||
picture *cur_pic;
|
||||
int8_t video_format;
|
||||
int8_t bitdepth; /*!< \brief input bit depth (8,10) */
|
||||
|
@ -64,24 +64,24 @@ typedef struct
|
|||
/* Filtering */
|
||||
int8_t deblock_enable; /*!< \brief Flag to enable deblocking filter */
|
||||
int8_t sao_enable; /*!< \brief Flag to enable sample adaptive offset filter */
|
||||
int8_t betaOffsetdiv2; /*!< \brief (deblocking) beta offset (div 2), range -6...6 */
|
||||
int8_t tcOffsetdiv2; /*!< \brief (deblocking)tc offset (div 2), range -6...6 */
|
||||
int8_t beta_offset_div2; /*!< \brief (deblocking) beta offset (div 2), range -6...6 */
|
||||
int8_t tc_offset_div2; /*!< \brief (deblocking)tc offset (div 2), range -6...6 */
|
||||
} encoder_control;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int8_t idx;
|
||||
uint8_t *base;
|
||||
uint8_t *baseU;
|
||||
uint8_t *baseV;
|
||||
uint8_t *base_u;
|
||||
uint8_t *base_v;
|
||||
|
||||
uint8_t *recbase;
|
||||
uint8_t *recbaseU;
|
||||
uint8_t *recbaseV;
|
||||
uint8_t *recbase_u;
|
||||
uint8_t *recbase_v;
|
||||
|
||||
int16_t *pred;
|
||||
int16_t *predU;
|
||||
int16_t *predV;
|
||||
int16_t *pred_u;
|
||||
int16_t *pred_v;
|
||||
|
||||
int32_t base_stride;
|
||||
int32_t recbase_stride;
|
||||
|
@ -91,11 +91,11 @@ typedef struct
|
|||
int16_t *coeff[3];
|
||||
int8_t cb_top[3];
|
||||
int8_t cb[4];
|
||||
int8_t intraPredMode;
|
||||
int8_t intraPredModeChroma;
|
||||
int8_t intra_pred_mode;
|
||||
int8_t intra_pred_mode_chroma;
|
||||
int32_t split[4];
|
||||
|
||||
int32_t xCtb,yCtb;
|
||||
int32_t x_ctb,y_ctb;
|
||||
|
||||
} transform_info;
|
||||
|
||||
|
@ -111,24 +111,24 @@ void encode_pic_parameter_set(encoder_control* encoder);
|
|||
void encode_vid_parameter_set(encoder_control* encoder);
|
||||
void encode_slice_data(encoder_control* encoder);
|
||||
void encode_slice_header(encoder_control* encoder);
|
||||
void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, uint8_t depth);
|
||||
void encode_coding_tree(encoder_control* encoder,uint16_t x_ctb,uint16_t y_ctb, uint8_t depth);
|
||||
void encode_lastSignificantXY(encoder_control* encoder,uint8_t lastpos_x, uint8_t lastpos_y, uint8_t width, uint8_t height, uint8_t type, uint8_t scan);
|
||||
void encode_CoeffNxN(encoder_control* encoder,int16_t* coeff, uint8_t width, uint8_t type, int8_t scanMode);
|
||||
void encode_CoeffNxN(encoder_control* encoder,int16_t* coeff, uint8_t width, uint8_t type, int8_t scan_mode);
|
||||
void encode_transform_tree(encoder_control* encoder,transform_info* ti,uint8_t depth);
|
||||
void encode_transform_coeff(encoder_control* encoder,transform_info* ti,int8_t depth, int8_t trDepth);
|
||||
void encode_transform_coeff(encoder_control* encoder,transform_info* ti,int8_t depth, int8_t tr_depth);
|
||||
|
||||
extern int16_t g_lambda_cost[55];
|
||||
extern uint32_t* g_auiSigLastScan[3][7];
|
||||
int8_t g_aucConvertToBit[LCU_WIDTH+1];
|
||||
static int8_t g_bitDepth = 8;
|
||||
static int8_t g_uiBitIncrement = 0;
|
||||
extern uint32_t* g_sig_last_scan[3][7];
|
||||
int8_t g_convert_to_bit[LCU_WIDTH+1];
|
||||
static int8_t g_bitdepth = 8;
|
||||
static int8_t g_bit_increment = 0;
|
||||
|
||||
#define MAX_NUM_SPU_W ((1<<(MAX_DEPTH))/4)
|
||||
static uint32_t g_auiZscanToRaster [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
|
||||
static uint32_t g_auiRasterToZscan [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
|
||||
static const uint8_t g_uiGroupIdx[ 32 ] = {0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9};
|
||||
static const uint8_t g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24};
|
||||
static uint32_t g_sigLastScanCG32x32[ 64 ] =
|
||||
static uint32_t g_z_scan_to_raster [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
|
||||
static uint32_t g_raster_to_z_scan [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
|
||||
static const uint8_t g_group_idx[ 32 ] = {0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9};
|
||||
static const uint8_t g_min_in_group[ 10 ] = {0,1,2,3,4,6,8,12,16,24};
|
||||
static uint32_t g_sig_last_scan_32x32[ 64 ] =
|
||||
{ 0, 8, 1,16, 9, 2,24,17,
|
||||
10, 3,32,25,18,11, 4,40,
|
||||
33,26,19,12, 5,48,41,34,
|
||||
|
@ -138,7 +138,7 @@ static uint32_t g_sigLastScanCG32x32[ 64 ] =
|
|||
23,59,52,45,38,31,60,53,
|
||||
46,39,61,54,47,62,55,63 };
|
||||
|
||||
static const uint32_t g_sigLastScan8x8[ 3 ][ 4 ] =
|
||||
static const uint32_t g_sig_last_scan_8x8[ 3 ][ 4 ] =
|
||||
{ {0, 2, 1, 3},
|
||||
{0, 1, 2, 3},
|
||||
{0, 2, 1, 3}
|
||||
|
@ -147,7 +147,7 @@ static const uint32_t g_sigLastScan8x8[ 3 ][ 4 ] =
|
|||
//
|
||||
//4 8 16 32 64 128
|
||||
//0 1 2 3 4 5
|
||||
static const uint8_t g_toBits[129] =
|
||||
static const uint8_t g_to_bits[129] =
|
||||
{
|
||||
0,
|
||||
0,0,0,0,
|
||||
|
@ -157,7 +157,7 @@ static const uint8_t g_toBits[129] =
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
|
||||
};
|
||||
#define TOBITS(len) g_toBits[len]
|
||||
#define TOBITS(len) g_to_bits[len]
|
||||
|
||||
|
||||
#define C1FLAG_NUMBER 8 /*!< maximum number of largerThan1 flag coded in one chunk */
|
||||
|
|
32
src/filter.c
32
src/filter.c
|
@ -66,19 +66,19 @@ INLINE void filter_deblock_luma( uint8_t* src, int32_t offset, int32_t tc , int8
|
|||
{
|
||||
int32_t tc2 = tc>>1;
|
||||
delta = CLIP(-tc, tc, delta);
|
||||
src[-offset] = CLIP(0,(1 << g_bitDepth)-1,(m3+delta));
|
||||
src[0] = CLIP(0,(1 << g_bitDepth)-1,(m4-delta));
|
||||
src[-offset] = CLIP(0,(1 << g_bitdepth)-1,(m3+delta));
|
||||
src[0] = CLIP(0,(1 << g_bitdepth)-1,(m4-delta));
|
||||
|
||||
|
||||
if(filter_second_P)
|
||||
{
|
||||
int32_t delta1 = CLIP(-tc2, tc2, (( ((m1+m3+1)>>1)- m2+delta)>>1));
|
||||
src[-offset*2] = CLIP(0,(1 << g_bitDepth)-1,(m2+delta1));
|
||||
src[-offset*2] = CLIP(0,(1 << g_bitdepth)-1,(m2+delta1));
|
||||
}
|
||||
if(filter_second_Q)
|
||||
{
|
||||
int32_t delta2 = CLIP(-tc2, tc2, (( ((m6+m4+1)>>1)- m5-delta)>>1));
|
||||
src[ offset] = CLIP(0,(1 << g_bitDepth)-1,(m5+delta2));
|
||||
src[ offset] = CLIP(0,(1 << g_bitdepth)-1,(m5+delta2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,11 +109,11 @@ INLINE void filter_deblock_chroma( uint8_t* src, int32_t offset, int32_t tc ,int
|
|||
delta = CLIP(-tc,tc, (((( m4 - m3 ) << 2 ) + m2 - m5 + 4 ) >> 3) );
|
||||
if(!part_P_nofilter)
|
||||
{
|
||||
src[-offset] = CLIP(0,(1 << g_bitDepth)-1,m3+delta);
|
||||
src[-offset] = CLIP(0,(1 << g_bitdepth)-1,m3+delta);
|
||||
}
|
||||
if(!part_Q_nofilter)
|
||||
{
|
||||
src[0] = CLIP(0,(1 << g_bitDepth)-1,m4-delta);
|
||||
src[0] = CLIP(0,(1 << g_bitdepth)-1,m4-delta);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,8 +121,8 @@ void filter_deblock_edge_luma(encoder_control* encoder, int32_t xpos, int32_t yp
|
|||
{
|
||||
int32_t stride = encoder->in.cur_pic->width;
|
||||
int32_t offset = stride;
|
||||
int32_t betaOffsetDiv2 = encoder->betaOffsetdiv2;
|
||||
int32_t tcOffsetDiv2 = encoder->tcOffsetdiv2;
|
||||
int32_t betaOffsetDiv2 = encoder->beta_offset_div2;
|
||||
int32_t tcOffsetDiv2 = encoder->tc_offset_div2;
|
||||
int8_t uiBs = 2; /* Filter strength */
|
||||
/* TODO: support 10+bits */
|
||||
uint8_t* origsrc = &encoder->in.cur_pic->yRecData[xpos+ypos*stride];
|
||||
|
@ -138,7 +138,7 @@ void filter_deblock_edge_luma(encoder_control* encoder, int32_t xpos, int32_t yp
|
|||
|
||||
{
|
||||
int32_t QP = encoder->QP;
|
||||
int32_t bitdepth_scale = 1 << (g_bitDepth-8);
|
||||
int32_t bitdepth_scale = 1 << (g_bitdepth-8);
|
||||
int32_t TC_index = CLIP(0, 51+2, (int32_t)(QP + 2*(uiBs-1) + (tcOffsetDiv2 << 1)));
|
||||
int32_t B_index = CLIP(0, 51, QP + (betaOffsetDiv2 << 1));
|
||||
int32_t Tc = tctable_8x8[TC_index]*bitdepth_scale;
|
||||
|
@ -195,7 +195,7 @@ void filter_deblock_edge_luma(encoder_control* encoder, int32_t xpos, int32_t yp
|
|||
void filter_deblock_edge_chroma(encoder_control* encoder,int32_t xpos, int32_t ypos, int8_t depth, int8_t dir)
|
||||
{
|
||||
int32_t stride = encoder->in.cur_pic->width>>1;
|
||||
int32_t tcOffsetDiv2 = encoder->tcOffsetdiv2;
|
||||
int32_t tcOffsetDiv2 = encoder->tc_offset_div2;
|
||||
int8_t uiNumParts = 1;
|
||||
/* TODO: support 10+bits */
|
||||
uint8_t* srcU = &encoder->in.cur_pic->uRecData[xpos+ypos*stride];
|
||||
|
@ -219,7 +219,7 @@ void filter_deblock_edge_chroma(encoder_control* encoder,int32_t xpos, int32_t y
|
|||
// For each subpart
|
||||
{
|
||||
int32_t QP = g_aucChromaScale[encoder->QP];
|
||||
int32_t bitdepth_scale = 1 << (g_bitDepth-8);
|
||||
int32_t bitdepth_scale = 1 << (g_bitdepth-8);
|
||||
int32_t TC_index = CLIP(0, 51+2, (int32_t)(QP + 2 + (tcOffsetDiv2 << 1)));
|
||||
int32_t Tc = tctable_8x8[TC_index]*bitdepth_scale;
|
||||
uint32_t blocks_in_part= (LCU_WIDTH>>(depth+1)) / 4;
|
||||
|
@ -254,7 +254,7 @@ void filter_deblock_edge_chroma(encoder_control* encoder,int32_t xpos, int32_t y
|
|||
*/
|
||||
void filter_deblock_CU(encoder_control* encoder, int32_t xCtb, int32_t yCtb, int8_t depth, int32_t edge)
|
||||
{
|
||||
CU_info *cur_CU = &encoder->in.cur_pic->CU[depth][xCtb+yCtb*(encoder->in.width_in_LCU<<MAX_DEPTH)];
|
||||
CU_info *cur_CU = &encoder->in.cur_pic->CU[depth][xCtb+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
uint8_t split_flag = (cur_CU->depth > depth)?1:0;
|
||||
uint8_t border_x = ((encoder->in.width)<( xCtb*(LCU_WIDTH>>MAX_DEPTH) + (LCU_WIDTH>>depth) ))?1:0;
|
||||
uint8_t border_y = ((encoder->in.height)<( yCtb*(LCU_WIDTH>>MAX_DEPTH) + (LCU_WIDTH>>depth) ))?1:0;
|
||||
|
@ -307,18 +307,18 @@ void filter_deblock(encoder_control* encoder)
|
|||
|
||||
/* TODO: Optimization: add thread for each LCU */
|
||||
/* Loop through every LCU in the slice */
|
||||
for(yCtb = 0; yCtb < encoder->in.height_in_LCU; yCtb++)
|
||||
for(yCtb = 0; yCtb < encoder->in.height_in_lcu; yCtb++)
|
||||
{
|
||||
for(xCtb = 0; xCtb < encoder->in.width_in_LCU; xCtb++)
|
||||
for(xCtb = 0; xCtb < encoder->in.width_in_lcu; xCtb++)
|
||||
{
|
||||
filter_deblock_CU(encoder, xCtb<<MAX_DEPTH, yCtb<<MAX_DEPTH, 0, EDGE_VER);
|
||||
}
|
||||
}
|
||||
|
||||
/* Loop through every LCU in the slice */
|
||||
for(yCtb = 0; yCtb < encoder->in.height_in_LCU; yCtb++)
|
||||
for(yCtb = 0; yCtb < encoder->in.height_in_lcu; yCtb++)
|
||||
{
|
||||
for(xCtb = 0; xCtb < encoder->in.width_in_LCU; xCtb++)
|
||||
for(xCtb = 0; xCtb < encoder->in.width_in_lcu; xCtb++)
|
||||
{
|
||||
filter_deblock_CU(encoder, xCtb<<MAX_DEPTH, yCtb<<MAX_DEPTH, 0, EDGE_HOR);
|
||||
}
|
||||
|
|
14
src/inter.c
14
src/inter.c
|
@ -33,7 +33,7 @@ void inter_setBlockMode(picture* pic,uint32_t xCtb, uint32_t yCtb, uint8_t depth
|
|||
{
|
||||
uint32_t x,y,d;
|
||||
/* Width in smallest CU */
|
||||
int width_in_SCU = pic->width_in_LCU<<MAX_DEPTH;
|
||||
int width_in_SCU = pic->width_in_lcu<<MAX_DEPTH;
|
||||
int block_SCU_width = (LCU_WIDTH>>depth)/(LCU_WIDTH>>MAX_DEPTH);
|
||||
for(y = yCtb; y < yCtb+block_SCU_width; y++)
|
||||
{
|
||||
|
@ -182,23 +182,23 @@ void inter_get_mv_cand(encoder_control *encoder,int32_t xCtb, int32_t yCtb,int8_
|
|||
b0 = b1 = b2 = a0 = a1 = NULL;
|
||||
|
||||
if (xCtb != 0) {
|
||||
a1 = &encoder->in.cur_pic->CU[depth][xCtb-1+(yCtb+cur_block_in_scu-1)*(encoder->in.width_in_LCU<<MAX_DEPTH)];
|
||||
a1 = &encoder->in.cur_pic->CU[depth][xCtb-1+(yCtb+cur_block_in_scu-1)*(encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
if(!a1->coded) a1 = NULL;
|
||||
|
||||
if (yCtb+cur_block_in_scu < encoder->in.height_in_LCU<<MAX_DEPTH) {
|
||||
a0 = &encoder->in.cur_pic->CU[depth][xCtb-1+(yCtb+cur_block_in_scu)*(encoder->in.width_in_LCU<<MAX_DEPTH)];
|
||||
if (yCtb+cur_block_in_scu < encoder->in.height_in_lcu<<MAX_DEPTH) {
|
||||
a0 = &encoder->in.cur_pic->CU[depth][xCtb-1+(yCtb+cur_block_in_scu)*(encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
if(!a0->coded) a0 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (yCtb != 0) {
|
||||
b0 = &encoder->in.cur_pic->CU[depth][xCtb+cur_block_in_scu+(yCtb-1)*(encoder->in.width_in_LCU<<MAX_DEPTH)];
|
||||
b0 = &encoder->in.cur_pic->CU[depth][xCtb+cur_block_in_scu+(yCtb-1)*(encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
if (!b0->coded) b0 = NULL;
|
||||
b1 = &encoder->in.cur_pic->CU[depth][xCtb+cur_block_in_scu-1+(yCtb-1)*(encoder->in.width_in_LCU<<MAX_DEPTH)];
|
||||
b1 = &encoder->in.cur_pic->CU[depth][xCtb+cur_block_in_scu-1+(yCtb-1)*(encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
if (!b1->coded) b1 = NULL;
|
||||
|
||||
if (xCtb != 0) {
|
||||
b2 = &encoder->in.cur_pic->CU[depth][xCtb-1+(yCtb-1)*(encoder->in.width_in_LCU<<MAX_DEPTH)];
|
||||
b2 = &encoder->in.cur_pic->CU[depth][xCtb-1+(yCtb-1)*(encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
if(!b2->coded) b2 = NULL;
|
||||
}
|
||||
}
|
||||
|
|
24
src/intra.c
24
src/intra.c
|
@ -37,7 +37,7 @@ void intra_setBlockMode(picture* pic,uint32_t xCtb, uint32_t yCtb, uint8_t depth
|
|||
{
|
||||
uint32_t x,y,d;
|
||||
/* Width in smallest CU */
|
||||
int width_in_SCU = pic->width_in_LCU<<MAX_DEPTH;
|
||||
int width_in_SCU = pic->width_in_lcu<<MAX_DEPTH;
|
||||
int block_SCU_width = (LCU_WIDTH>>depth)/(LCU_WIDTH>>MAX_DEPTH);
|
||||
for(y = yCtb; y < yCtb+block_SCU_width; y++)
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ void intra_setBlockMode(picture* pic,uint32_t xCtb, uint32_t yCtb, uint8_t depth
|
|||
int8_t intra_getBlockMode(picture* pic,uint32_t xCtb, uint32_t yCtb, uint8_t depth)
|
||||
{
|
||||
//Width in smallest CU
|
||||
int width_in_SCU = pic->width_in_LCU<<MAX_DEPTH;
|
||||
int width_in_SCU = pic->width_in_lcu<<MAX_DEPTH;
|
||||
int CUpos = yCtb*width_in_SCU+xCtb;
|
||||
if(pic->CU[depth][CUpos].type == CU_INTRA)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ int8_t intra_getBlockMode(picture* pic,uint32_t xCtb, uint32_t yCtb, uint8_t dep
|
|||
int16_t intra_getDCPred(int16_t* pic, uint16_t picwidth,uint32_t xpos, uint32_t ypos, uint8_t width)
|
||||
{
|
||||
int32_t i, iSum = 0;
|
||||
int16_t pDcVal = 1<<(g_bitDepth-1);
|
||||
int16_t pDcVal = 1<<(g_bitdepth-1);
|
||||
|
||||
/* Average of pixels on top and left */
|
||||
for (i = -picwidth; i < width-picwidth ; i++)
|
||||
|
@ -115,7 +115,7 @@ int8_t intra_getDirLumaPredictor(picture* pic,uint32_t xCtb, uint32_t yCtb, uint
|
|||
{
|
||||
int32_t iLeftIntraDir = 1; //DC_IDX
|
||||
int32_t iAboveIntraDir = 1; //DC_IDX
|
||||
int width_in_SCU = pic->width_in_LCU<<MAX_DEPTH;
|
||||
int width_in_SCU = pic->width_in_lcu<<MAX_DEPTH;
|
||||
int32_t CUpos = yCtb*width_in_SCU+xCtb;
|
||||
|
||||
// Left PU predictor
|
||||
|
@ -247,7 +247,7 @@ int16_t intra_prediction(uint8_t* orig,int32_t origstride,int16_t* rec,int32_t r
|
|||
uint8_t *origShift = &orig[xpos+ypos*origstride];
|
||||
int8_t filter = (width<32); //TODO: chroma support
|
||||
SADfunction SADarray[5] = {&SAD4x4,&SAD8x8,&SAD16x16,&SAD32x32,&SAD64x64}; //TODO: get SAD functions from parameters
|
||||
uint8_t threshold = intraHorVerDistThres[g_toBits[width]]; /*!< Intra filtering threshold */
|
||||
uint8_t threshold = intraHorVerDistThres[g_to_bits[width]]; /*!< Intra filtering threshold */
|
||||
#define COPY_PRED_TO_DST() for(y = 0; y < (int32_t)width; y++) { for(x = 0; x < (int32_t)width; x++) { dst[x+y*dststride] = pred[x+y*width]; } }
|
||||
#define CHECK_FOR_BEST(mode, sad) SAD = calcSAD(pred,width,origBlock,width); \
|
||||
SAD += sad;\
|
||||
|
@ -259,7 +259,7 @@ int16_t intra_prediction(uint8_t* orig,int32_t origstride,int16_t* rec,int32_t r
|
|||
}
|
||||
|
||||
/* Choose SAD function according to width */
|
||||
calcSAD = SADarray[g_toBits[width]];
|
||||
calcSAD = SADarray[g_to_bits[width]];
|
||||
|
||||
/* Store original block for SAD computation */
|
||||
i = 0;
|
||||
|
@ -345,7 +345,7 @@ void intra_recon(int16_t* rec,uint32_t recstride, uint32_t xpos, uint32_t ypos,u
|
|||
/* Filtering apply if luma and not DC */
|
||||
if(!chroma && mode != 1 /*&& width > 4*/)
|
||||
{
|
||||
uint8_t threshold = intraHorVerDistThres[g_toBits[width]];
|
||||
uint8_t threshold = intraHorVerDistThres[g_to_bits[width]];
|
||||
if(MIN(abs(mode-26),abs(mode-10)) > threshold)
|
||||
{
|
||||
intra_filter(rec,recstride,width,0);
|
||||
|
@ -394,14 +394,14 @@ void intra_buildReferenceBorder(picture* pic, int32_t xCtb, int32_t yCtb,int16_t
|
|||
int32_t leftColumn; /*!< left column iterator */
|
||||
int16_t val; /*!< variable to store extrapolated value */
|
||||
int32_t i; /*!< index iterator */
|
||||
int16_t dcVal = 1<<(g_bitDepth-1); /*!< default predictor value */
|
||||
int16_t dcVal = 1<<(g_bitdepth-1); /*!< default predictor value */
|
||||
int32_t topRow; /*!< top row iterator */
|
||||
int32_t srcWidth = (pic->width>>(chroma?1:0)); /*!< source picture width */
|
||||
int32_t srcHeight = (pic->height>>(chroma?1:0));/*!< source picture height */
|
||||
uint8_t* srcPic = (!chroma)?pic->yRecData: ((chroma==1)?pic->uRecData: pic->vRecData); /*!< input picture pointer */
|
||||
int16_t SCU_width = LCU_WIDTH>>(MAX_DEPTH+(chroma?1:0)); /*!< Smallest Coding Unit width */
|
||||
uint8_t* srcShifted = &srcPic[xCtb*SCU_width+(yCtb*SCU_width)*srcWidth]; /*!< input picture pointer shifted to start from the left-top corner of the current block */
|
||||
int width_in_SCU = pic->width_in_LCU<<MAX_DEPTH; /*!< picture width in SCU */
|
||||
int width_in_SCU = pic->width_in_lcu<<MAX_DEPTH; /*!< picture width in SCU */
|
||||
|
||||
/* Fill left column */
|
||||
if(xCtb)
|
||||
|
@ -579,7 +579,7 @@ void intra_getAngularPred(int16_t* pSrc, int32_t srcStride, int16_t* rpDst, int3
|
|||
for (k=0;k<blkSize;k++)
|
||||
{
|
||||
pDst[k*dstStride] = //(pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1)) & (1<<g_bitDepth)-1;
|
||||
CLIP(0, (1<<g_bitDepth)-1, pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) );
|
||||
CLIP(0, (1<<g_bitdepth)-1, pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -672,13 +672,13 @@ void intra_DCPredFiltering(int16_t* pSrc, int32_t iSrcStride, int16_t* rpDst, in
|
|||
*/
|
||||
void intra_getPlanarPred(int16_t* src,int32_t srcstride, uint32_t xpos, uint32_t ypos,uint32_t width, int16_t* dst,int32_t dststride)
|
||||
{
|
||||
int16_t pDcVal = 1<<(g_bitDepth-1);
|
||||
int16_t pDcVal = 1<<(g_bitdepth-1);
|
||||
int32_t k, l, bottomLeft, topRight;
|
||||
int32_t horPred;
|
||||
int32_t leftColumn[LCU_WIDTH+1], topRow[LCU_WIDTH+1], bottomRow[LCU_WIDTH+1], rightColumn[LCU_WIDTH+1];
|
||||
uint32_t blkSize = width;
|
||||
uint32_t offset2D = width;
|
||||
uint32_t shift1D = g_aucConvertToBit[ width ] + 2;
|
||||
uint32_t shift1D = g_convert_to_bit[ width ] + 2;
|
||||
uint32_t shift2D = shift1D + 1;
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void picture_setBlockSplit(picture* pic,uint32_t xCtb, uint32_t yCtb, uint8_t de
|
|||
{
|
||||
uint32_t x,y;//,d;
|
||||
//Width in smallest CU
|
||||
int width_in_SCU = pic->width_in_LCU<<MAX_DEPTH;
|
||||
int width_in_SCU = pic->width_in_lcu<<MAX_DEPTH;
|
||||
int block_SCU_width = (LCU_WIDTH>>depth)/(LCU_WIDTH>>MAX_DEPTH);
|
||||
for(y = yCtb; y < yCtb+block_SCU_width; y++)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ void picture_setBlockCoded(picture* pic,uint32_t xCtb, uint32_t yCtb, uint8_t de
|
|||
{
|
||||
uint32_t x,y,d;
|
||||
//Width in smallest CU
|
||||
int width_in_SCU = pic->width_in_LCU<<MAX_DEPTH;
|
||||
int width_in_SCU = pic->width_in_lcu<<MAX_DEPTH;
|
||||
int block_SCU_width = (LCU_WIDTH>>depth)/(LCU_WIDTH>>MAX_DEPTH);
|
||||
for(y = yCtb; y < yCtb+block_SCU_width; y++)
|
||||
{
|
||||
|
@ -247,8 +247,8 @@ void picture_setBlockCoded(picture* pic,uint32_t xCtb, uint32_t yCtb, uint8_t de
|
|||
|
||||
pic->width = width;
|
||||
pic->height = height;
|
||||
pic->width_in_LCU = width_in_LCU;
|
||||
pic->height_in_LCU = height_in_LCU;
|
||||
pic->width_in_lcu = width_in_LCU;
|
||||
pic->height_in_lcu = height_in_LCU;
|
||||
pic->referenced = 0;
|
||||
/* Allocate buffers */
|
||||
pic->yData = (uint8_t *)malloc(luma_size);
|
||||
|
|
|
@ -87,8 +87,8 @@ typedef struct
|
|||
|
||||
int32_t width; /*!< \brief Picture width */
|
||||
int32_t height; /*!< \brief Picture height */
|
||||
int32_t height_in_LCU; /*!< \brief input picture width in number of LCU's */
|
||||
int32_t width_in_LCU; /*!< \brief input picture height in number of LCU's */
|
||||
int32_t height_in_lcu; /*!< \brief input picture width in number of LCU's */
|
||||
int32_t width_in_lcu; /*!< \brief input picture height in number of LCU's */
|
||||
uint8_t referenced; /*!< \brief Is this picture referenced */
|
||||
CU_info** CU; /*!< \brief info for each CU at each depth */
|
||||
uint8_t type;
|
||||
|
|
12
src/search.c
12
src/search.c
|
@ -70,14 +70,14 @@ void search_buildReferenceBorder(picture* pic, int32_t xCtb, int32_t yCtb,int16_
|
|||
int32_t leftColumn; /*!< left column iterator */
|
||||
int16_t val; /*!< variable to store extrapolated value */
|
||||
int32_t i; /*!< index iterator */
|
||||
int16_t dcVal = 1<<(g_bitDepth-1); /*!< default predictor value */
|
||||
int16_t dcVal = 1<<(g_bitdepth-1); /*!< default predictor value */
|
||||
int32_t topRow; /*!< top row iterator */
|
||||
int32_t srcWidth = (pic->width>>(chroma?1:0)); /*!< source picture width */
|
||||
int32_t srcHeight = (pic->height>>(chroma?1:0));/*!< source picture height */
|
||||
uint8_t* srcPic = (!chroma)?pic->yData: ((chroma==1)?pic->uData: pic->vData); /*!< input picture pointer */
|
||||
int16_t SCU_width = LCU_WIDTH>>(MAX_DEPTH+(chroma?1:0)); /*!< Smallest Coding Unit width */
|
||||
uint8_t* srcShifted = &srcPic[xCtb*SCU_width+(yCtb*SCU_width)*srcWidth]; /*!< input picture pointer shifted to start from the left-top corner of the current block */
|
||||
int32_t width_in_SCU = pic->width_in_LCU<<MAX_DEPTH; /*!< picture width in SCU */
|
||||
int32_t width_in_SCU = pic->width_in_lcu<<MAX_DEPTH; /*!< picture width in SCU */
|
||||
|
||||
/* Fill left column */
|
||||
if(xCtb)
|
||||
|
@ -162,7 +162,7 @@ void search_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, uint8_t d
|
|||
uint8_t border_split_x = ((encoder->in.width) < ( (xCtb+1)*(LCU_WIDTH>>MAX_DEPTH) + (LCU_WIDTH>>(depth+1)) ))?0:1;
|
||||
uint8_t border_split_y = ((encoder->in.height) < ( (yCtb+1)*(LCU_WIDTH>>MAX_DEPTH) + (LCU_WIDTH>>(depth+1)) ))?0:1;
|
||||
uint8_t border = border_x | border_y; /*!< are we in any border CU */
|
||||
CU_info *cur_CU = &encoder->in.cur_pic->CU[depth][xCtb+yCtb*(encoder->in.width_in_LCU<<MAX_DEPTH)];
|
||||
CU_info *cur_CU = &encoder->in.cur_pic->CU[depth][xCtb+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
|
||||
cur_CU->intra.cost = 0xffffffff;
|
||||
cur_CU->inter.cost = 0xffffffff;
|
||||
|
@ -257,7 +257,7 @@ void search_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, uint8_t d
|
|||
|
||||
uint32_t search_best_mode(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, uint8_t depth)
|
||||
{
|
||||
CU_info *cur_CU = &encoder->in.cur_pic->CU[depth][xCtb+yCtb*(encoder->in.width_in_LCU<<MAX_DEPTH)];
|
||||
CU_info *cur_CU = &encoder->in.cur_pic->CU[depth][xCtb+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
uint32_t bestIntraCost = cur_CU->intra.cost;
|
||||
uint32_t bestInterCost = cur_CU->inter.cost;
|
||||
uint32_t bestCost = 0;
|
||||
|
@ -328,9 +328,9 @@ void search_slice_data(encoder_control* encoder)
|
|||
|
||||
|
||||
/* Loop through every LCU in the slice */
|
||||
for(yCtb = 0; yCtb < encoder->in.height_in_LCU; yCtb++)
|
||||
for(yCtb = 0; yCtb < encoder->in.height_in_lcu; yCtb++)
|
||||
{
|
||||
for(xCtb = 0; xCtb < encoder->in.width_in_LCU; xCtb++)
|
||||
for(xCtb = 0; xCtb < encoder->in.width_in_lcu; xCtb++)
|
||||
{
|
||||
uint8_t depth = 0;
|
||||
/* Recursive function for looping through all the sub-blocks */
|
||||
|
|
|
@ -694,8 +694,8 @@ void partialButterflyInverse32(int16_t *src,int16_t *dst,int32_t shift, int32_t
|
|||
void transform2d(int16_t *block,int16_t *coeff, int8_t blockSize, int32_t uiMode)
|
||||
{
|
||||
|
||||
int32_t shift_1st = g_aucConvertToBit[blockSize] + 1 + g_uiBitIncrement; // log2(iWidth) - 1 + g_uiBitIncrement
|
||||
int32_t shift_2nd = g_aucConvertToBit[blockSize] + 8; // log2(iHeight) + 6
|
||||
int32_t shift_1st = g_convert_to_bit[blockSize] + 1 + g_bit_increment; // log2(iWidth) - 1 + g_uiBitIncrement
|
||||
int32_t shift_2nd = g_convert_to_bit[blockSize] + 8; // log2(iHeight) + 6
|
||||
|
||||
int16_t tmp[LCU_WIDTH*LCU_WIDTH];
|
||||
|
||||
|
@ -749,7 +749,7 @@ void itransform2d(int16_t *block,int16_t *coeff, int8_t blockSize, int32_t uiMod
|
|||
//(Int bitDepth, Short *coeff,Short *block, Int iWidth, Int iHeight, UInt uiMode)
|
||||
{
|
||||
int32_t shift_1st = 7;
|
||||
int32_t shift_2nd = 12 - (g_bitDepth-8);
|
||||
int32_t shift_2nd = 12 - (g_bitdepth-8);
|
||||
int16_t tmp[LCU_WIDTH*LCU_WIDTH];
|
||||
|
||||
if( blockSize == 4)
|
||||
|
@ -793,8 +793,8 @@ void quant(encoder_control* encoder, int16_t* pSrc, int16_t* pDes, int32_t iWidt
|
|||
|
||||
|
||||
int8_t useRDOQForTransformSkip = 0;
|
||||
uint32_t log2BlockSize = g_aucConvertToBit[ iWidth ] + 2;
|
||||
uint32_t* scan = g_auiSigLastScan[ scanIdx ][ log2BlockSize - 1 ];
|
||||
uint32_t log2BlockSize = g_convert_to_bit[ iWidth ] + 2;
|
||||
uint32_t* scan = g_sig_last_scan[ scanIdx ][ log2BlockSize - 1 ];
|
||||
//uint32_t scanIdx = SCAN_DIAG;
|
||||
|
||||
#if ENABLE_SIGN_HIDING == 1
|
||||
|
@ -827,12 +827,12 @@ void quant(encoder_control* encoder, int16_t* pSrc, int16_t* pDes, int32_t iWidt
|
|||
int32_t n;
|
||||
uint32_t dir = 0;//SCALING_LIST_SQT;
|
||||
|
||||
uint32_t uiLog2TrSize = g_aucConvertToBit[ iWidth ] + 2;
|
||||
uint32_t uiLog2TrSize = g_convert_to_bit[ iWidth ] + 2;
|
||||
int32_t scalingListType = (/*pcCU->isint32_tra(uiAbsPartIdx)*/0 ? 0 : 3) + (int8_t)("\0\3\1\2"[eTType]);
|
||||
|
||||
int32_t *piQuantCoeff = g_quant_coeff[uiLog2TrSize-2][scalingListType][/*m_cQP.m_iRem*/qpScaled%6];
|
||||
|
||||
uint32_t uiBitDepth = g_bitDepth;
|
||||
uint32_t uiBitDepth = g_bitdepth;
|
||||
|
||||
int32_t iTransformShift = /*MAX_TR_DYNAMIC_RANGE*/15 - uiBitDepth - uiLog2TrSize; // Represents scaling through forward transform
|
||||
int32_t iQBits = QUANT_SHIFT + /*cQpBase.m_iPer +*/qpScaled/6 + iTransformShift;
|
||||
|
@ -981,10 +981,10 @@ void quant(encoder_control* encoder, int16_t* pSrc, int16_t* pDes, int32_t iWidt
|
|||
void dequant(encoder_control* encoder, int16_t* piQCoef, int16_t* piCoef, int32_t iWidth, int32_t iHeight,int8_t eTType)
|
||||
{
|
||||
int32_t iShift,iAdd,iCoeffQ;
|
||||
uint32_t uiLog2TrSize = g_aucConvertToBit[ iWidth ] + 2;
|
||||
uint32_t uiLog2TrSize = g_convert_to_bit[ iWidth ] + 2;
|
||||
int16_t clipQCoef;
|
||||
int32_t n;
|
||||
int32_t iTransformShift = 15 - g_bitDepth - (g_aucConvertToBit[ iWidth ] + 2);
|
||||
int32_t iTransformShift = 15 - g_bitdepth - (g_convert_to_bit[ iWidth ] + 2);
|
||||
int32_t qpScaled;
|
||||
int32_t iQpBase = encoder->QP;
|
||||
int32_t scalingListType = (/*pcCU->isintra(uiAbsPartIdx)*/1 ? 0 : 3) + (int8_t)("\0\3\1\2"[eTType]);
|
||||
|
|
Loading…
Reference in a new issue