mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 11:24:05 +00:00
coeff_abs_level_greater1_flag coding fixes
This commit is contained in:
parent
b260108f99
commit
b0916abfbc
|
@ -261,7 +261,9 @@ void cabac_finish(cabac_data* data)
|
||||||
*/
|
*/
|
||||||
void cabac_encodeBinTrm(cabac_data* data, uint8_t binValue )
|
void cabac_encodeBinTrm(cabac_data* data, uint8_t binValue )
|
||||||
{
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
printf("\tencodeBinTrm m_uiRange %d uivalue %d\n", data->uiRange, data->uiLow);
|
printf("\tencodeBinTrm m_uiRange %d uivalue %d\n", data->uiRange, data->uiLow);
|
||||||
|
#endif
|
||||||
data->uiBinsCoded += data->binCountIncrement;
|
data->uiBinsCoded += data->binCountIncrement;
|
||||||
data->uiRange -= 2;
|
data->uiRange -= 2;
|
||||||
if( binValue )
|
if( binValue )
|
||||||
|
|
|
@ -266,6 +266,7 @@ cabac_ctx g_CuCtxLastY_luma[15];
|
||||||
cabac_ctx g_CuCtxLastY_chroma[15];
|
cabac_ctx g_CuCtxLastY_chroma[15];
|
||||||
cabac_ctx g_CuCtxLastX_luma[15];
|
cabac_ctx g_CuCtxLastX_luma[15];
|
||||||
cabac_ctx g_CuCtxLastX_chroma[15];
|
cabac_ctx g_CuCtxLastX_chroma[15];
|
||||||
|
cabac_ctx g_CUOneSCModel_luma[24];
|
||||||
|
|
||||||
|
|
||||||
void encode_slice_data(encoder_control* encoder)
|
void encode_slice_data(encoder_control* encoder)
|
||||||
|
@ -305,12 +306,13 @@ void encode_slice_data(encoder_control* encoder)
|
||||||
|
|
||||||
for(i = 0; i < 24; i++)
|
for(i = 0; i < 24; i++)
|
||||||
{
|
{
|
||||||
|
ctx_init(&g_CUOneSCModel_luma[i], encoder->QP, INIT_ONE_FLAG[SLICE_I][i]);
|
||||||
|
|
||||||
ctx_init(&g_CUSigSCModel_luma[i], encoder->QP, INIT_SIG_FLAG[SLICE_I][i]);
|
ctx_init(&g_CUSigSCModel_luma[i], encoder->QP, INIT_SIG_FLAG[SLICE_I][i]);
|
||||||
if(i < 21)
|
if(i < 21)
|
||||||
{
|
{
|
||||||
ctx_init(&g_CUSigSCModel_chroma[i], encoder->QP, INIT_SIG_FLAG[SLICE_I][i+24]);
|
ctx_init(&g_CUSigSCModel_chroma[i], encoder->QP, INIT_SIG_FLAG[SLICE_I][i+24]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
encoder->in.cur_pic.CU[1][0].type = CU_INTRA;
|
encoder->in.cur_pic.CU[1][0].type = CU_INTRA;
|
||||||
|
@ -457,9 +459,9 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
|
||||||
uint8_t CbY = 0,CbU = 0,CbV = 0;
|
uint8_t CbY = 0,CbU = 0,CbV = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Quant and transform ...
|
Quant and transform here...
|
||||||
*/
|
*/
|
||||||
CbY = 1; /* Let's pretend we have LUMA coefficients */
|
CbY = 1; /* Let's pretend we have luma coefficients */
|
||||||
|
|
||||||
/* Non-zero chroma U Tcoeffs */
|
/* Non-zero chroma U Tcoeffs */
|
||||||
cabac.ctx = &g_QtCbfSCModelU[0];
|
cabac.ctx = &g_QtCbfSCModelU[0];
|
||||||
|
@ -476,38 +478,48 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
|
||||||
/* CoeffNxN */
|
/* CoeffNxN */
|
||||||
if(CbY)
|
if(CbY)
|
||||||
{
|
{
|
||||||
int c1;
|
int c1,c1_num;
|
||||||
|
int patternSigCtx;
|
||||||
|
int numNonZero = 16;
|
||||||
|
/* scanCG == g_sigLastScanCG32x32 */
|
||||||
/* Residual Coding */
|
/* Residual Coding */
|
||||||
/* LastSignificantXY */
|
/* LastSignificantXY */
|
||||||
encode_lastSignificantXY(encoder,31, 31, 32, 32, 0, 0);
|
encode_lastSignificantXY(encoder,31/*last_coeff_x */, 31/* last_coeff_y */, 32, 32, 0, 0);
|
||||||
|
|
||||||
for(i = 15; i >= 0; i-- )
|
for(i = 15; i >= 0; i-- )
|
||||||
{
|
{
|
||||||
/* significant_coeff_flag */
|
/* 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.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");
|
CABAC_BIN(&cabac,1,"significant_coeff_flag");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* n = 15 .. 0 coeff_abs_level_greater1_flag[ n ] */
|
||||||
|
|
||||||
|
/* coeff_abs_level_greater2_flag[ firstGreater1CoeffIdx] */
|
||||||
|
|
||||||
c1 = 1;
|
c1 = 1;
|
||||||
for(i = 0; i < 8; i++)
|
c1_num = MIN(numNonZero,C1FLAG_NUMBER);
|
||||||
|
for(i = 0; i < c1_num; i++)
|
||||||
{
|
{
|
||||||
|
int val = 0;
|
||||||
/* significant_coeff_flag */
|
/* significant_coeff_flag */
|
||||||
cabac.ctx = &g_CUSigSCModel_luma[8+c1]; /* 8 = 4 * uiCtxSet */
|
cabac.ctx = &g_CUOneSCModel_luma[4*2+c1]; /* 4 * uiCtxSet +c1 */
|
||||||
CABAC_BIN(&cabac,0,"significant_coeff_flag");
|
CABAC_BIN(&cabac,val,"coeff_abs_level_greater1_flag");
|
||||||
if(c1 < 3)
|
if(val)
|
||||||
{
|
{
|
||||||
c1 ++;
|
c1 = 0;
|
||||||
|
}
|
||||||
|
else if(c1 < 3)
|
||||||
|
{
|
||||||
|
c1++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end Residual Coding */
|
/* end Residual Coding */
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end Transform tree */
|
/* end Transform tree */
|
||||||
/* end Coeff */
|
/* end Coeff */
|
||||||
|
|
||||||
}
|
}
|
||||||
//endif
|
//endif
|
||||||
/* end prediction unit */
|
/* end prediction unit */
|
||||||
|
@ -521,13 +533,12 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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_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 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;
|
uint8_t shift_x = type?(TOBITS(width)):((TOBITS(width)+3)>>2), shift_y = shift_x;
|
||||||
int uiGroupIdxX = g_uiGroupIdx[ lastpos_x ];
|
int uiGroupIdxX = g_uiGroupIdx[lastpos_x];
|
||||||
int uiGroupIdxY = g_uiGroupIdx[ lastpos_y ];
|
int uiGroupIdxY = g_uiGroupIdx[lastpos_y];
|
||||||
int last_x,last_y,i;
|
int last_x,last_y,i;
|
||||||
|
|
||||||
if(width != height)
|
if(width != height)
|
||||||
|
|
|
@ -113,6 +113,15 @@ static const uint8_t INIT_LAST[3][30] =
|
||||||
108, 123, 63, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU }
|
108, 123, 63, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const uint8_t INIT_ONE_FLAG[3][24] =
|
||||||
|
{
|
||||||
|
{154,196,167,167,154,152,167,182,182,134,149,136,153,121,136,122,169,208,166,167,154,152,167,182},
|
||||||
|
{154,196,196,167,154,152,167,182,182,134,149,136,153,121,136,137,169,194,166,167,154,167,137,182},
|
||||||
|
{140, 92,137,138,140,152,138,139,153, 74,149, 92,139,107,122,152,140,179,166,182,140,227,122,197}
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint8_t* g_auiSigLastScan[4][7];
|
||||||
|
|
||||||
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_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 const uint8_t g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24};
|
||||||
static const uint8_t g_sigLastScanCG32x32[ 64 ] =
|
static const uint8_t g_sigLastScanCG32x32[ 64 ] =
|
||||||
|
@ -141,4 +150,8 @@ static const uint8_t g_toBits[129] =
|
||||||
#define TOBITS(len) g_toBits[len]
|
#define TOBITS(len) g_toBits[len]
|
||||||
|
|
||||||
|
|
||||||
|
#define C1FLAG_NUMBER 8 // maximum number of largerThan1 flag coded in one chunk
|
||||||
|
#define C2FLAG_NUMBER 1 // maximum number of largerThan2 flag coded in one chunk
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue