Moved coding of lastSignificantXY to a function

This commit is contained in:
Marko Viitanen 2012-06-14 13:09:34 +03:00
parent 2e3c313932
commit b260108f99
2 changed files with 89 additions and 68 deletions

View file

@ -476,23 +476,66 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
/* CoeffNxN */
if(CbY)
{
int c1;
/* Residual Coding */
/* LastSignificantXY */
/* ToDo: separate to a function */
//encode_lastSignificantXY(uint8_t lastpos_x, uint8_t lastpos_y, uint8_t width, uint8_t height, uint8_t type, uint8_t scan)
uint8_t lastpos_x = 31, lastpos_y = 31;
uint8_t last_x = 1, last_y = 1;
uint8_t offset_x = 10,offset_y = 10;
uint8_t shift_x = 1, shift_y = 1;
encode_lastSignificantXY(encoder,31, 31, 32, 32, 0, 0);
for(i = 15; i >= 0; i-- )
{
/* significant_coeff_flag */
cabac.ctx = &g_CUSigSCModel_luma[21+((i<7)?1:0)]; /* 21 = uiCtxSig =TComTrQuant::getSigCtxInc( patternSigCtx, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );*/
CABAC_BIN(&cabac,0,"significant_coeff_flag");
}
c1 = 1;
for(i = 0; i < 8; i++)
{
/* significant_coeff_flag */
cabac.ctx = &g_CUSigSCModel_luma[8+c1]; /* 8 = 4 * uiCtxSet */
CABAC_BIN(&cabac,0,"significant_coeff_flag");
if(c1 < 3)
{
c1 ++;
}
}
/* end Residual Coding */
}
}
/* end Transform tree */
/* end Coeff */
}
//endif
/* end prediction unit */
//cabac_encodeBin(&cabac, 0); //prev_intra_luma_pred_flag
//cabac_encodeBin(&cabac, 1); //rem_intra_luma_pred_mode
/* end coding_unit */
}
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)
{
uint8_t offset_x = type?0:((TOBITS(width)*3) + ((TOBITS(width)+1)>>2)),offset_y = offset_x;
uint8_t shift_x = type?(TOBITS(width)):((TOBITS(width)+3)>>2), shift_y = shift_x;
int uiGroupIdxX = g_uiGroupIdx[ lastpos_x ];
int uiGroupIdxY = g_uiGroupIdx[ lastpos_y ];
int temp;
/*
blkSizeOffsetX = eTType ? 0: (g_aucConvertToBit[ width ] *3 + ((g_aucConvertToBit[ width ] +1)>>2));
blkSizeOffsetY = eTType ? 0: (g_aucConvertToBit[ height ]*3 + ((g_aucConvertToBit[ height ]+1)>>2));
shiftX= eTType ? g_aucConvertToBit[ width ] :((g_aucConvertToBit[ width ]+3)>>2);
shiftY= eTType ? g_aucConvertToBit[ height ] :((g_aucConvertToBit[ height ]+3)>>2);
*/
int last_x,last_y,i;
if(width != height)
{
shift_y = (TOBITS(height)+3)>>2;
offset_y = TOBITS(height)*3 + ((TOBITS(height)+1)>>2);
}
/* Last X binarization */
for(last_x = 0; last_x < uiGroupIdxX ; last_x++)
{
@ -526,7 +569,6 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
CABAC_BIN_EP(&cabac,(lastpos_x>>i) & 1,"LastSignificantX");
}
}
/* Last Y */
if(uiGroupIdxY > 3)
{
@ -537,39 +579,4 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
}
}
/* end LastSignificantXY */
for(i = 15; i >= 0; i-- )
{
/* significant_coeff_flag */
cabac.ctx = &g_CUSigSCModel_luma[21]; /* 21 = uiCtxSig =TComTrQuant::getSigCtxInc( patternSigCtx, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );*/
CABAC_BIN(&cabac,0,"significant_coeff_flag");
}
for(i = 0; i < 8; i++)
{
/* significant_coeff_flag */
cabac.ctx = &g_CUSigSCModel_luma[8]; /* 8 = 4 * uiCtxSet */
CABAC_BIN(&cabac,0,"significant_coeff_flag");
}
/* end Residual Coding */
}
}
/* end Transform tree */
/* end Coeff */
}
//endif
/* end prediction unit */
//cabac_encodeBin(&cabac, 0); //prev_intra_luma_pred_flag
//cabac_encodeBin(&cabac, 1); //rem_intra_luma_pred_mode
/* end coding_unit */
}

View file

@ -64,7 +64,7 @@ void encode_pic_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_lastSignificantXY(encoder_control* encoder,uint8_t lastpos_x, uint8_t lastpos_y, uint8_t width, uint8_t height, uint8_t type, uint8_t scan);
static const uint8_t INIT_SPLIT_FLAG[3][3] =
{ { 107, 139, 126 },
@ -125,6 +125,20 @@ static const uint8_t g_sigLastScanCG32x32[ 64 ] =
23,59,52,45,38,31,60,53,
46,39,61,54,47,62,55,63 };
//
//4 8 16 32 64 128
//0 1 2 3 4 5
static const uint8_t g_toBits[129] =
{
0,
0,0,0,0,
0,0,0,1,
0,0,0,0,0,0,0,2,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,
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]
#endif