Splitted transform tree to a function

This commit is contained in:
Marko Viitanen 2013-03-25 12:48:19 +02:00
parent 902ffb6a67
commit 43122a1f0a
4 changed files with 317 additions and 284 deletions

View file

@ -20,8 +20,6 @@
#include "context.h"
/* CONTEXTS */
/* ToDo: move somewhere else */
cabac_ctx *SplitFlagSCModel;
cabac_ctx g_SplitFlagSCModel[3]; /*<! \brief split flag context models */
cabac_ctx g_IntraModeSCModel; /*<! \brief intra mode context models */
cabac_ctx g_ChromaPredSCModel[2];
@ -120,16 +118,14 @@ uint32_t context_get_sigCoeffGroup( uint32_t* uiSigCoeffGroupFlag,
}
//uint8_t get_context_coeff_abs_significant_flag(uint8_t
/** Pattern decision for context derivation process of significant_coeff_flag
* \param sigCoeffGroupFlag pointer to prior coded significant coeff group
* \param posXCG column of current coefficient group
* \param posYCG row of current coefficient group
* \param width width of the block
* \param height height of the block
* \returns pattern for current coefficient group
/*!
\brief Pattern decision for context derivation process of significant_coeff_flag
\param sigCoeffGroupFlag pointer to prior coded significant coeff group
\param posXCG column of current coefficient group
\param posYCG row of current coefficient group
\param width width of the block
\param height height of the block
\returns pattern for current coefficient group
*/
int32_t context_calcPatternSigCtx( const uint32_t* sigCoeffGroupFlag, uint32_t posXCG, uint32_t posYCG, int32_t width)
@ -154,14 +150,15 @@ int32_t context_calcPatternSigCtx( const uint32_t* sigCoeffGroupFlag, uint32_t
}
/** Context derivation process of coeff_abs_significant_flag
* \param patternSigCtx pattern for current coefficient group
* \param posX column of current scan position
* \param posY row of current scan position
* \param blockType log2 value of block size if square block, or 4 otherwise
* \param width width of the block
* \param textureType texture type (TEXT_LUMA...)
* \returns ctxInc for current scan position
/*!
\brief Context derivation process of coeff_abs_significant_flag
\param patternSigCtx pattern for current coefficient group
\param posX column of current scan position
\param posY row of current scan position
\param blockType log2 value of block size if square block, or 4 otherwise
\param width width of the block
\param textureType texture type (TEXT_LUMA...)
\returns ctxInc for current scan position
*/
int32_t context_getSigCtxInc(int32_t patternSigCtx,uint32_t scanIdx,int32_t posX,

View file

@ -30,7 +30,6 @@ int32_t context_getSigCtxInc(int32_t patternSigCtx,uint32_t scanIdx,int32_t posX
/* CONTEXTS */
extern cabac_ctx *SplitFlagSCModel;
extern cabac_ctx g_SplitFlagSCModel[3];
extern cabac_ctx g_IntraModeSCModel;
extern cabac_ctx g_ChromaPredSCModel[2];

View file

@ -630,7 +630,7 @@ void encode_slice_data(encoder_control* encoder)
void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, uint8_t depth)
{
uint8_t split_flag = (depth<3)?1:0; /* ToDo: get from CU data */
uint8_t split_flag = (depth<2)?1:0; /* ToDo: get from CU data */
uint8_t split_model = 0;
/* Check for slice border */
@ -845,10 +845,100 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
/* Coeff */
/* Transform tree */
encode_transform_tree(encoder,base, baseU, baseV, encoder->in.width,
recbase,recbaseU, recbaseV, encoder->in.width,
pred,predU,predV,LCU_WIDTH,
depth, intraPredMode, intraPredModeChroma);
/* end Transform tree */
/* end Coeff */
}
#if ENABLE_PCM == 1
/* Code IPCM block */
else if(cur_CU->type == CU_PCM || cur_CU->type == CU_NOTSET) /* also handling NOTSET conditions */
{
cabac_encodeBinTrm(&cabac, 1); /* IPCMFlag == 1 */
cabac_finish(&cabac);
bitstream_align(cabac.stream);
/* PCM sample */
{
uint8_t *base = &encoder->in.cur_pic.yData[xCtb*(LCU_WIDTH>>(MAX_DEPTH)) + (yCtb*(LCU_WIDTH>>(MAX_DEPTH)))*encoder->in.width];
uint8_t *baseCb = &encoder->in.cur_pic.uData[(xCtb*(LCU_WIDTH>>(MAX_DEPTH+1)) + (yCtb*(LCU_WIDTH>>(MAX_DEPTH+1)))*encoder->in.width/2)];
uint8_t *baseCr = &encoder->in.cur_pic.vData[(xCtb*(LCU_WIDTH>>(MAX_DEPTH+1)) + (yCtb*(LCU_WIDTH>>(MAX_DEPTH+1)))*encoder->in.width/2)];
for(y = 0; y < LCU_WIDTH>>depth; y++)
{
for(x = 0; x < LCU_WIDTH>>depth; x++)
{
bitstream_put(cabac.stream, base[x+y*encoder->in.width], 8);
}
}
if(encoder->in.video_format != FORMAT_400)
{
/* Cb */
for(y = 0; y < LCU_WIDTH>>(depth+1); y++)
{
for(x = 0; x < LCU_WIDTH>>(depth+1); x++)
{
bitstream_put(cabac.stream, baseCb[x+y*(encoder->in.width>>1)], 8);
}
}
/* Cr */
for(y = 0; y < LCU_WIDTH>>(depth+1); y++)
{
for(x = 0; x < LCU_WIDTH>>(depth+1); x++)
{
bitstream_put(cabac.stream, baseCr[x+y*(encoder->in.width>>1)], 8);
}
}
}
}
/* end PCM sample */
cabac_start(&cabac);
} /* end Code IPCM block */
#endif /* END ENABLE_PCM */
else /* Should not happend */
{
printf("UNHANDLED TYPE!\r\n");
exit(1);
}
/* end prediction unit */
/* end coding_unit */
}
void encode_transform_tree(encoder_control* encoder,uint8_t *base, uint8_t *baseU, uint8_t *baseV,int32_t base_stride,
uint8_t *recbase,uint8_t *recbaseU, uint8_t *recbaseV,int32_t recbase_stride,
int16_t *pred, int16_t *predU, int16_t *predV,int32_t pred_stride,
uint8_t depth, int8_t intraPredMode, int8_t intraPredModeChroma)
{
int x,y,i;
int32_t width = LCU_WIDTH>>depth;
int8_t split = 0;
if(depth < MAX_DEPTH)
{
cabac.ctx = &g_TransSubdivSCModel[5-(g_aucConvertToBit[LCU_WIDTH]+2-depth)];
CABAC_BIN(&cabac,0,"TransformSubdivFlag");
CABAC_BIN(&cabac,split,"TransformSubdivFlag");
}
if(split)
{
encode_transform_tree(encoder,base, baseU, baseV, base_stride,
recbase,recbaseU, recbaseV, recbase_stride,
pred,predU,predV,pred_stride,
depth+1, intraPredMode, intraPredModeChroma);
encode_transform_tree(encoder,base, baseU, baseV, base_stride,
recbase,recbaseU, recbaseV, recbase_stride,
pred,predU,predV,pred_stride,
depth+1, intraPredMode, intraPredModeChroma);
encode_transform_tree(encoder,base, baseU, baseV, base_stride,
recbase,recbaseU, recbaseV, recbase_stride,
pred,predU,predV,pred_stride,
depth+1, intraPredMode, intraPredModeChroma);
encode_transform_tree(encoder,base, baseU, baseV, base_stride,
recbase,recbaseU, recbaseV, recbase_stride,
pred,predU,predV,pred_stride,
depth+1, intraPredMode, intraPredModeChroma);
}
/* We don't subdiv and we have 64>>depth transform size */
@ -1099,67 +1189,11 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
}
}
}
/* end Residual Coding */
}
/* end Transform tree */
/* end Coeff */
}
#if ENABLE_PCM == 1
/* Code IPCM block */
else if(cur_CU->type == CU_PCM || cur_CU->type == CU_NOTSET) /* also handling NOTSET conditions */
{
cabac_encodeBinTrm(&cabac, 1); /* IPCMFlag == 1 */
cabac_finish(&cabac);
bitstream_align(cabac.stream);
/* PCM sample */
{
uint8_t *base = &encoder->in.cur_pic.yData[xCtb*(LCU_WIDTH>>(MAX_DEPTH)) + (yCtb*(LCU_WIDTH>>(MAX_DEPTH)))*encoder->in.width];
uint8_t *baseCb = &encoder->in.cur_pic.uData[(xCtb*(LCU_WIDTH>>(MAX_DEPTH+1)) + (yCtb*(LCU_WIDTH>>(MAX_DEPTH+1)))*encoder->in.width/2)];
uint8_t *baseCr = &encoder->in.cur_pic.vData[(xCtb*(LCU_WIDTH>>(MAX_DEPTH+1)) + (yCtb*(LCU_WIDTH>>(MAX_DEPTH+1)))*encoder->in.width/2)];
for(y = 0; y < LCU_WIDTH>>depth; y++)
{
for(x = 0; x < LCU_WIDTH>>depth; x++)
{
bitstream_put(cabac.stream, base[x+y*encoder->in.width], 8);
}
}
if(encoder->in.video_format != FORMAT_400)
{
/* Cb */
for(y = 0; y < LCU_WIDTH>>(depth+1); y++)
{
for(x = 0; x < LCU_WIDTH>>(depth+1); x++)
{
bitstream_put(cabac.stream, baseCb[x+y*(encoder->in.width>>1)], 8);
}
}
/* Cr */
for(y = 0; y < LCU_WIDTH>>(depth+1); y++)
{
for(x = 0; x < LCU_WIDTH>>(depth+1); x++)
{
bitstream_put(cabac.stream, baseCr[x+y*(encoder->in.width>>1)], 8);
}
}
}
}
/* end PCM sample */
cabac_start(&cabac);
} /* end Code IPCM block */
#endif /* END ENABLE_PCM */
else /* Should not happend */
{
printf("UNHANDLED TYPE!\r\n");
exit(1);
}
/* end prediction unit */
/* end coding_unit */
}
void encode_CoeffNxN(encoder_control* encoder,int16_t* coeff, uint8_t width, uint8_t type, int8_t scanMode)
{

View file

@ -68,7 +68,10 @@ 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);
void encode_CoeffNxN(encoder_control* encoder,int16_t* coeff, uint8_t width, uint8_t type, int8_t scanMode);
void encode_transform_tree(encoder_control* encoder,uint8_t *base, uint8_t *baseU, uint8_t *baseV,int32_t base_stride,
uint8_t *recbase,uint8_t *recbaseU, uint8_t *recbaseV,int32_t recbase_stride,
int16_t *pred, int16_t *predU, int16_t *predV,int32_t pred_stride,
uint8_t depth, int8_t intraPredMode, int8_t intraPredModeChroma);
void init_tables(void);
static uint32_t* g_auiSigLastScan[3][7];