mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 11:24:05 +00:00
Fixed partsize context model initialization
This commit is contained in:
parent
a059965855
commit
d5ab9f0437
|
@ -27,7 +27,7 @@ cabac_ctx g_TransSubdivSCModel[3]; /*<! \brief intra mode context models */
|
|||
cabac_ctx g_QtCbfSCModelY[3];
|
||||
cabac_ctx g_QtCbfSCModelU[3];
|
||||
//cabac_ctx g_QtCbfSCModelV[3];
|
||||
cabac_ctx g_PartSizeSCModel;
|
||||
cabac_ctx g_PartSizeSCModel[4];
|
||||
cabac_ctx g_CUSigCoeffGroupSCModel[4];
|
||||
cabac_ctx g_CUSigSCModel_luma[27];
|
||||
cabac_ctx g_CUSigSCModel_chroma[15];
|
||||
|
@ -50,7 +50,7 @@ void init_contexts(encoder_control *encoder, int8_t SLICE)
|
|||
ctx_init(&g_SplitFlagSCModel[1], encoder->QP, INIT_SPLIT_FLAG[SLICE][1]);
|
||||
ctx_init(&g_SplitFlagSCModel[2], encoder->QP, INIT_SPLIT_FLAG[SLICE][2]);
|
||||
|
||||
ctx_init(&g_IntraModeSCModel, encoder->QP, INIT_INTRA_PRED_MODE[SLICE]);
|
||||
ctx_init(&g_IntraModeSCModel, encoder->QP, INIT_INTRA_PRED_MODE[SLICE]);
|
||||
|
||||
ctx_init(&g_ChromaPredSCModel[0], encoder->QP, INIT_CHROMA_PRED_MODE[SLICE][0]);
|
||||
ctx_init(&g_ChromaPredSCModel[1], encoder->QP, INIT_CHROMA_PRED_MODE[SLICE][1]);
|
||||
|
@ -62,6 +62,7 @@ void init_contexts(encoder_control *encoder, int8_t SLICE)
|
|||
{
|
||||
ctx_init(&g_CUSigCoeffGroupSCModel[i], encoder->QP, INIT_SIG_CG_FLAG[SLICE][i]);
|
||||
ctx_init(&g_cCUAbsSCModel_luma[i], encoder->QP, INIT_ABS_FLAG[SLICE][i]);
|
||||
ctx_init(&g_PartSizeSCModel[i], encoder->QP, INIT_PART_SIZE[SLICE][i]);
|
||||
}
|
||||
for(i = 0; i < 3; i++)
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ extern cabac_ctx g_ChromaPredSCModel[2];
|
|||
extern cabac_ctx g_TransSubdivSCModel[3];
|
||||
extern cabac_ctx g_QtCbfSCModelY[3];
|
||||
extern cabac_ctx g_QtCbfSCModelU[3];
|
||||
extern cabac_ctx g_PartSizeSCModel;
|
||||
extern cabac_ctx g_PartSizeSCModel[4];
|
||||
extern cabac_ctx g_CUSigCoeffGroupSCModel[4];
|
||||
extern cabac_ctx g_CUSigSCModel_luma[27];
|
||||
extern cabac_ctx g_CUSigSCModel_chroma[15];
|
||||
|
@ -49,6 +49,15 @@ extern cabac_ctx g_CUOneSCModel_chroma[8];
|
|||
extern cabac_ctx g_cCUAbsSCModel_luma[4];
|
||||
extern cabac_ctx g_cCUAbsSCModel_chroma[2];
|
||||
|
||||
#define CNU 154
|
||||
static const uint8_t
|
||||
INIT_PART_SIZE[3][4] =
|
||||
{
|
||||
{ 154, 139, CNU, CNU, },
|
||||
{ 154, 139, CNU, CNU, },
|
||||
{ 184, CNU, CNU, CNU, },
|
||||
};
|
||||
|
||||
static const uint8_t INIT_SPLIT_FLAG[3][3] =
|
||||
{ { 107, 139, 126 },
|
||||
{ 107, 139, 126 },
|
||||
|
@ -58,7 +67,7 @@ static const uint8_t INIT_INTRA_PRED_MODE[3] = { 183,154,184 };
|
|||
|
||||
static const uint8_t INIT_CHROMA_PRED_MODE[3][2] = { { 152, 139 }, { 152, 139 }, { 63, 139 } };
|
||||
|
||||
#define CNU 154
|
||||
|
||||
static const uint8_t INIT_TRANS_SUBDIV_FLAG[3][3] =
|
||||
{
|
||||
{ 224, 167, 122 },
|
||||
|
|
|
@ -132,6 +132,8 @@
|
|||
encoder->frame = 0;
|
||||
encoder->QP = 32;
|
||||
encoder->in.video_format = FORMAT_420;
|
||||
encoder->betaOffsetdiv2 = 0;
|
||||
encoder->tcOffsetdiv2 = 0;
|
||||
init_encoder_input(&encoder->in, input, cfg->width, cfg->height);
|
||||
|
||||
/* Start coding cycle */
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "context.h"
|
||||
#include "transform.h"
|
||||
#include "intra.h"
|
||||
#include "filter.h"
|
||||
|
||||
void initSigLastScan(uint32_t* pBuffD, uint32_t* pBuffH, uint32_t* pBuffV, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
|
@ -310,6 +311,10 @@ void encode_one_frame(encoder_control* encoder)
|
|||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
/* Filtering */
|
||||
//filter_deblock(encoder);
|
||||
|
||||
|
||||
/* Clear prediction data */
|
||||
/* ToDo: store as reference data */
|
||||
|
@ -360,7 +365,11 @@ void encode_pic_parameter_set(encoder_control* encoder)
|
|||
WRITE_U(encoder->stream, 1, 1, "deblocking_filter_control_present_flag");
|
||||
//IF deblocking_filter
|
||||
WRITE_U(encoder->stream, 0, 1, "deblocking_filter_override_enabled_flag");
|
||||
WRITE_U(encoder->stream, 1, 1, "pps_disable_deblocking_filter_flag");
|
||||
WRITE_U(encoder->stream, 0, 1, "pps_disable_deblocking_filter_flag");
|
||||
//IF !disabled
|
||||
WRITE_SE(encoder->stream, encoder->betaOffsetdiv2, "beta_offset_div2");
|
||||
WRITE_SE(encoder->stream, encoder->tcOffsetdiv2, "tc_offset_div2");
|
||||
//ENDIF
|
||||
//ENDIF
|
||||
WRITE_U(encoder->stream, 0, 1, "pps_scaling_list_data_present_flag");
|
||||
//IF scaling_list
|
||||
|
@ -631,7 +640,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<2)?1:0; /* ToDo: get from CU data */
|
||||
uint8_t split_flag = (depth<3)?1:0; /* ToDo: get from CU data */
|
||||
uint8_t split_model = 0;
|
||||
|
||||
/* Check for slice border */
|
||||
|
@ -686,12 +695,13 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
|
|||
cur_CU->type = CU_INTRA;
|
||||
}
|
||||
|
||||
/* Signal PartSize on max depth */
|
||||
/* Signal PartSize on max depth */
|
||||
if(depth == MAX_DEPTH)
|
||||
{
|
||||
cabac.ctx = &g_PartSizeSCModel;
|
||||
cabac.ctx = &g_PartSizeSCModel[0];
|
||||
CABAC_BIN(&cabac, 1, "PartSize");
|
||||
}
|
||||
|
||||
/*end partsize*/
|
||||
|
||||
if(cur_CU->type == CU_INTRA)
|
||||
|
@ -1183,9 +1193,9 @@ void encode_transform_coeff(encoder_control* encoder,transform_info* ti,int8_t d
|
|||
int8_t CbY,CbU,CbV;
|
||||
int32_t coeff_fourth = ((LCU_WIDTH>>(depth))*(LCU_WIDTH>>(depth)));
|
||||
|
||||
if(depth != 0 && depth != MAX_DEPTH)
|
||||
if(depth != 0 && depth != MAX_DEPTH+1)
|
||||
{
|
||||
cabac.ctx = &g_TransSubdivSCModel[5-(g_aucConvertToBit[LCU_WIDTH]+2-depth)];
|
||||
cabac.ctx = &g_TransSubdivSCModel[5-((g_aucConvertToBit[LCU_WIDTH]+2)-depth)];
|
||||
CABAC_BIN(&cabac,split,"TransformSubdivFlag");
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ typedef struct
|
|||
uint8_t bitdepth;
|
||||
|
||||
/* Filtering */
|
||||
int8_t betaOffset;
|
||||
int8_t tcOffset;
|
||||
int8_t betaOffsetdiv2;
|
||||
int8_t tcOffsetdiv2;
|
||||
} encoder_control;
|
||||
|
||||
typedef struct
|
||||
|
@ -109,6 +109,9 @@ int8_t g_aucConvertToBit[LCU_WIDTH+1];
|
|||
static int8_t g_bitDepth = 8;
|
||||
static int8_t g_uiBitIncrement = 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 ] =
|
||||
|
|
209
src/filter.c
209
src/filter.c
|
@ -96,13 +96,13 @@ void filter_luma( uint8_t* piSrc, int32_t iOffset, int32_t tc , int8_t sw, int8_
|
|||
}
|
||||
}
|
||||
|
||||
void filter_deblock_edge_luma(encoder_control* encoder, int32_t xpos, int32_t ypos, int8_t depth, int32_t edge, int8_t chroma, int8_t dir)
|
||||
void filter_deblock_edge_luma(encoder_control* encoder, int32_t xpos, int32_t ypos, int8_t depth, int32_t edge, int8_t dir)
|
||||
{
|
||||
int i,iIdx;
|
||||
int32_t iStride = encoder->in.cur_pic.width;
|
||||
int32_t iOffset = 0;
|
||||
int32_t betaOffsetDiv2 = encoder->betaOffset>>1;
|
||||
int32_t tcOffsetDiv2 = encoder->tcOffset>>1;
|
||||
int32_t betaOffsetDiv2 = encoder->betaOffsetdiv2;
|
||||
int32_t tcOffsetDiv2 = encoder->betaOffsetdiv2;
|
||||
const int8_t scu_width = (LCU_WIDTH>>MAX_DEPTH);
|
||||
const int8_t scu_width_log2 = TOBITS(scu_width);
|
||||
int8_t uiNumParts = 1;
|
||||
|
@ -176,4 +176,207 @@ void filter_deblock_edge_luma(encoder_control* encoder, int32_t xpos, int32_t yp
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void filter_deblock_edge_chroma(encoder_control* encoder,int32_t idx, int32_t xpos, int32_t ypos, int8_t depth, int32_t edge, int8_t dir)
|
||||
{
|
||||
int i,iIdx;
|
||||
int32_t iStride = encoder->in.cur_pic.width;
|
||||
int32_t iOffset = 0;
|
||||
int32_t tcOffsetDiv2 = encoder->betaOffsetdiv2;
|
||||
const int8_t scu_width = (LCU_WIDTH>>(MAX_DEPTH+1));
|
||||
const int8_t scu_width_log2 = TOBITS(scu_width);
|
||||
int8_t uiNumParts = 1;
|
||||
int8_t uiBs = 1; /* Filter strength */
|
||||
/* ToDo: support 10+bits */
|
||||
uint8_t* src = &encoder->in.cur_pic.yRecData[xpos+ypos*iStride];
|
||||
uint8_t* piTmpSrc = src;
|
||||
int32_t iSrcStep;
|
||||
CU_info* cu = &encoder->in.cur_pic.CU[0][(xpos>>scu_width_log2) + (ypos>>scu_width_log2)*(encoder->in.width>>scu_width_log2)];
|
||||
|
||||
uint32_t uiEdgeNumInLCUVert = g_auiZscanToRaster[idx]%(1<<MAX_DEPTH) + edge;
|
||||
uint32_t uiEdgeNumInLCUHor = g_auiZscanToRaster[idx]/(1<<MAX_DEPTH) + edge;
|
||||
|
||||
if ( (scu_width < 8) && (( (uiEdgeNumInLCUVert%(8/scu_width))&&(dir==0) ) || ( (uiEdgeNumInLCUHor%(8/scu_width))&& dir ) ))
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*
|
||||
|
||||
if(dir == EDGE_VER)
|
||||
{
|
||||
iOffset = 1;
|
||||
iSrcStep = iStride;
|
||||
piTmpSrc += edge*scu_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
iOffset = iStride;
|
||||
iSrcStep = 1;
|
||||
piTmpSrc += edge*scu_width*iStride;
|
||||
}
|
||||
|
||||
// For each subpart
|
||||
for(iIdx = 0; iIdx < uiNumParts; iIdx++)
|
||||
{
|
||||
int32_t iQP = encoder->QP;
|
||||
int32_t iBitdepthScale = 1 << (g_bitDepth-8);
|
||||
int32_t iIndexTC = CLIP(0, 51+2, (int32_t)(iQP + 2*(uiBs-1) + (tcOffsetDiv2 << 1)));
|
||||
int32_t iIndexB = CLIP(0, 51, iQP + (betaOffsetDiv2 << 1));
|
||||
int32_t iTc = tctable_8x8[iIndexTC]*iBitdepthScale;
|
||||
int32_t iBeta = betatable_8x8[iIndexB]*iBitdepthScale;
|
||||
int32_t iSideThreshold = (iBeta+(iBeta>>1))>>3;
|
||||
int32_t iThrCut = iTc*10;
|
||||
uint32_t uiBlocksInPart= scu_width / 4 ? scu_width / 4 : 1;
|
||||
uint32_t iBlkIdx;
|
||||
|
||||
for (iBlkIdx = 0; iBlkIdx < uiBlocksInPart; iBlkIdx++)
|
||||
{
|
||||
uint8_t* piTmpSrcShift;
|
||||
int32_t dp0,dq0,dp3,dq3,d0,d3,dp,dq,d;
|
||||
|
||||
|
||||
piTmpSrcShift = piTmpSrc+iSrcStep*(iIdx*scu_width+iBlkIdx*4+0);
|
||||
dp0 = abs( piTmpSrcShift[-iOffset*3] - 2*piTmpSrcShift[-iOffset*2] + piTmpSrcShift[-iOffset] );
|
||||
piTmpSrcShift = piTmpSrc+iSrcStep*(iIdx*scu_width+iBlkIdx*4+0);
|
||||
dq0 = abs( piTmpSrcShift[0] - 2*piTmpSrcShift[iOffset] + piTmpSrcShift[iOffset*2] );
|
||||
piTmpSrcShift = piTmpSrc+iSrcStep*(iIdx*scu_width+iBlkIdx*4+3);
|
||||
dp3 = abs( piTmpSrcShift[-iOffset*3] - 2*piTmpSrcShift[-iOffset*2] + piTmpSrcShift[-iOffset] );
|
||||
piTmpSrcShift = piTmpSrc+iSrcStep*(iIdx*scu_width+iBlkIdx*4+3);
|
||||
dq3 = abs( piTmpSrcShift[0] - 2*piTmpSrcShift[iOffset] + piTmpSrcShift[iOffset*2] );
|
||||
d0 = dp0 + dq0;
|
||||
d3 = dp3 + dq3;
|
||||
dp = dp0 + dp3;
|
||||
dq = dq0 + dq3;
|
||||
d = d0 + d3;
|
||||
|
||||
#if ENABLE_PCM == 1
|
||||
//ToDo: add PCM deblocking
|
||||
#endif
|
||||
if (d < iBeta)
|
||||
{
|
||||
int8_t bFilterP = (dp < iSideThreshold)?1:0;
|
||||
int8_t bFilterQ = (dq < iSideThreshold)?1:0;
|
||||
int8_t sw = 0;// xUseStrongFiltering( iOffset, 2*d0, iBeta, iTc, piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+0))
|
||||
//&& xUseStrongFiltering( iOffset, 2*d3, iBeta, iTc, piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+3));
|
||||
for (i = 0; i < 8/2; i++)
|
||||
{
|
||||
filter_luma( piTmpSrc+iSrcStep*(iIdx*scu_width+iBlkIdx*4+i), iOffset, iTc, sw, 0, 0, iThrCut, bFilterP, bFilterQ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void filter_deblock_CU(encoder_control* encoder, int32_t xpos, int32_t ypos, int8_t depth, int32_t edge, int8_t dir)
|
||||
{
|
||||
/*
|
||||
if(pcCU->getPic()==0||pcCU->getPartitionSize(uiAbsZorderIdx)==SIZE_NONE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TComPic* pcPic = pcCU->getPic();
|
||||
UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1);
|
||||
UInt uiQNumParts = uiCurNumParts>>2;
|
||||
|
||||
if( pcCU->getDepth(uiAbsZorderIdx) > uiDepth )
|
||||
{
|
||||
for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++, uiAbsZorderIdx+=uiQNumParts )
|
||||
{
|
||||
UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsZorderIdx] ];
|
||||
UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsZorderIdx] ];
|
||||
if( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
|
||||
{
|
||||
filter_deblock_CU( pcCU, uiAbsZorderIdx, uiDepth+1, Edge );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
xSetLoopfilterParam( pcCU, uiAbsZorderIdx );
|
||||
|
||||
xSetEdgefilterTU ( pcCU, uiAbsZorderIdx , uiAbsZorderIdx, uiDepth );
|
||||
xSetEdgefilterPU ( pcCU, uiAbsZorderIdx );
|
||||
|
||||
Int iDir = Edge;
|
||||
for( UInt uiPartIdx = uiAbsZorderIdx; uiPartIdx < uiAbsZorderIdx + uiCurNumParts; uiPartIdx++ )
|
||||
{
|
||||
UInt uiBSCheck;
|
||||
if( (g_uiMaxCUWidth >> g_uiMaxCUDepth) == 4 )
|
||||
{
|
||||
uiBSCheck = (iDir == EDGE_VER && uiPartIdx%2 == 0) || (iDir == EDGE_HOR && (uiPartIdx-((uiPartIdx>>2)<<2))/2 == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
uiBSCheck = 1;
|
||||
}
|
||||
|
||||
if ( m_aapbEdgeFilter[iDir][uiPartIdx] && uiBSCheck )
|
||||
{
|
||||
xGetBoundaryStrengthSingle ( pcCU, iDir, uiPartIdx );
|
||||
}
|
||||
}
|
||||
|
||||
UInt uiPelsInPart = g_uiMaxCUWidth >> g_uiMaxCUDepth;
|
||||
UInt PartIdxIncr = DEBLOCK_SMALLEST_BLOCK / uiPelsInPart ? DEBLOCK_SMALLEST_BLOCK / uiPelsInPart : 1 ;
|
||||
|
||||
UInt uiSizeInPU = pcPic->getNumPartInWidth()>>(uiDepth);
|
||||
|
||||
for ( UInt iEdge = 0; iEdge < uiSizeInPU ; iEdge+=PartIdxIncr)
|
||||
{
|
||||
xEdgeFilterLuma ( pcCU, uiAbsZorderIdx, uiDepth, iDir, iEdge );
|
||||
if ( (uiPelsInPart>DEBLOCK_SMALLEST_BLOCK) || (iEdge % ( (DEBLOCK_SMALLEST_BLOCK<<1)/uiPelsInPart ) ) == 0 )
|
||||
{
|
||||
xEdgeFilterChroma ( pcCU, uiAbsZorderIdx, uiDepth, iDir, iEdge );
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
void filter_deblock(encoder_control* encoder)
|
||||
{
|
||||
int x,y;
|
||||
const int8_t scu_width = (LCU_WIDTH>>(MAX_DEPTH));
|
||||
int16_t width = 32;
|
||||
/*
|
||||
// Horizontal filtering
|
||||
for ( UInt uiCUAddr = 0; uiCUAddr < pcPic->getNumCUsInFrame(); uiCUAddr++ )
|
||||
{
|
||||
TComDataCU* pcCU = pcPic->getCU( uiCUAddr );
|
||||
|
||||
::memset( m_aapucBS [EDGE_VER], 0, sizeof( UChar ) * m_uiNumPartitions );
|
||||
::memset( m_aapbEdgeFilter[EDGE_VER], 0, sizeof( Bool ) * m_uiNumPartitions );
|
||||
|
||||
// CU-based deblocking
|
||||
filter_deblock_CU( pcCU, 0, 0, EDGE_VER );
|
||||
}
|
||||
|
||||
// Vertical filtering
|
||||
for ( UInt uiCUAddr = 0; uiCUAddr < pcPic->getNumCUsInFrame(); uiCUAddr++ )
|
||||
{
|
||||
TComDataCU* pcCU = pcPic->getCU( uiCUAddr );
|
||||
|
||||
::memset( m_aapucBS [EDGE_HOR], 0, sizeof( UChar ) * m_uiNumPartitions );
|
||||
::memset( m_aapbEdgeFilter[EDGE_HOR], 0, sizeof( Bool ) * m_uiNumPartitions );
|
||||
|
||||
// CU-based deblocking
|
||||
filter_deblock_CU( pcCU, 0, 0, EDGE_HOR );
|
||||
}
|
||||
*/
|
||||
for(y = width-1; y < encoder->in.height-1; y+=width)
|
||||
{
|
||||
for(x = width-1; x < encoder->in.width-1; x+=width)
|
||||
{
|
||||
filter_deblock_edge_luma(encoder, x, y, 2, EDGE_VER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
for(y = width-1; y < encoder->in.height-1; y+=width)
|
||||
{
|
||||
for(x = width-1; x < encoder->in.width-1; x+=width)
|
||||
{
|
||||
filter_deblock_edge_luma(encoder, x, y, 2, EDGE_HOR, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
#define EDGE_HOR 1
|
||||
|
||||
|
||||
void filter_deblock_edge_luma(encoder_control* encoder, int32_t xpos, int32_t ypos, int8_t depth, int32_t edge, int8_t chroma, int8_t dir);
|
||||
|
||||
void filter_deblock_edge_luma(encoder_control* encoder, int32_t xpos, int32_t ypos, int8_t depth, int32_t edge, int8_t dir);
|
||||
void filter_deblock_edge_chroma(encoder_control* encoder,int32_t idx, int32_t xpos, int32_t ypos, int8_t depth, int32_t edge, int8_t dir);
|
||||
void filter_deblock(encoder_control* encoder);
|
||||
#endif
|
||||
|
|
14
src/intra.c
14
src/intra.c
|
@ -210,7 +210,7 @@ void intra_filter(int16_t* ref, uint32_t stride,uint32_t width, int8_t mode)
|
|||
#undef FWIDTH
|
||||
}
|
||||
|
||||
/*! \brief Function to test best intra prediction
|
||||
/*! \brief Function to test best intra prediction mode
|
||||
\param orig original picture data
|
||||
\param origstride original picture stride
|
||||
\param rec reconstructed picture data
|
||||
|
@ -270,7 +270,9 @@ int16_t intra_prediction(uint8_t* orig,uint32_t origstride,int16_t* rec,uint32_t
|
|||
for(x = 0; x < (int32_t)recstride; x++)
|
||||
{
|
||||
recFiltered[y-recstride] = rec[y-recstride];
|
||||
}
|
||||
}
|
||||
/*Apply filter*/
|
||||
intra_filter(recFiltered,recstride,width,0);
|
||||
|
||||
/* Test DC */
|
||||
|
||||
|
@ -292,8 +294,7 @@ int16_t intra_prediction(uint8_t* orig,uint32_t origstride,int16_t* rec,uint32_t
|
|||
}
|
||||
}
|
||||
|
||||
/*Apply filter*/
|
||||
intra_filter(recFiltered,recstride,width,0);
|
||||
/**** FROM THIS POINT FORWARD, USING FILTERED PREDICTION *****/
|
||||
|
||||
/* Test planar */
|
||||
intra_getPlanarPred(recFiltered, recstride, xpos, ypos, width, pred, width);
|
||||
|
@ -312,7 +313,8 @@ int16_t intra_prediction(uint8_t* orig,uint32_t origstride,int16_t* rec,uint32_t
|
|||
intra_getAngularPred(recFiltered,recstride,pred, width,width,width,i, xpos?1:0, ypos?1:0, filter);
|
||||
CHECK_FOR_BEST(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*sad = bestSAD;
|
||||
#undef COPY_PRED_TO_DST
|
||||
#undef CHECK_FOR_BEST
|
||||
|
@ -389,8 +391,6 @@ void intra_buildReferenceBorder(picture* pic, int32_t xCtb, int32_t yCtb,int16_t
|
|||
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 = srcWidth/SCU_width; /*!< picture width in SCU */
|
||||
|
||||
//memset(dst,0,outwidth*outwidth*sizeof(int16_t));
|
||||
|
||||
/* Fill left column */
|
||||
if(xCtb)
|
||||
{
|
||||
|
|
111
src/picture.c
111
src/picture.c
|
@ -154,6 +154,102 @@ double imagePSNR(uint8_t *frame1, uint8_t *frame2, uint32_t x, uint32_t y)
|
|||
return psnr;
|
||||
}
|
||||
|
||||
uint32_t Hadamard8x8(int16_t *piOrg, int16_t *piCur, int32_t iStrideOrg, int32_t iStrideCur)
|
||||
{
|
||||
int32_t k, i, j, jj, sad=0;
|
||||
int32_t diff[64], m1[8][8], m2[8][8], m3[8][8];
|
||||
for( k = 0; k < 64; k += 8 )
|
||||
{
|
||||
diff[k+0] = piOrg[0] - piCur[0];
|
||||
diff[k+1] = piOrg[1] - piCur[1];
|
||||
diff[k+2] = piOrg[2] - piCur[2];
|
||||
diff[k+3] = piOrg[3] - piCur[3];
|
||||
diff[k+4] = piOrg[4] - piCur[4];
|
||||
diff[k+5] = piOrg[5] - piCur[5];
|
||||
diff[k+6] = piOrg[6] - piCur[6];
|
||||
diff[k+7] = piOrg[7] - piCur[7];
|
||||
|
||||
piCur += iStrideCur;
|
||||
piOrg += iStrideOrg;
|
||||
}
|
||||
|
||||
//horizontal
|
||||
for (j=0; j < 8; j++)
|
||||
{
|
||||
jj = j << 3;
|
||||
m2[j][0] = diff[jj ] + diff[jj+4];
|
||||
m2[j][1] = diff[jj+1] + diff[jj+5];
|
||||
m2[j][2] = diff[jj+2] + diff[jj+6];
|
||||
m2[j][3] = diff[jj+3] + diff[jj+7];
|
||||
m2[j][4] = diff[jj ] - diff[jj+4];
|
||||
m2[j][5] = diff[jj+1] - diff[jj+5];
|
||||
m2[j][6] = diff[jj+2] - diff[jj+6];
|
||||
m2[j][7] = diff[jj+3] - diff[jj+7];
|
||||
|
||||
m1[j][0] = m2[j][0] + m2[j][2];
|
||||
m1[j][1] = m2[j][1] + m2[j][3];
|
||||
m1[j][2] = m2[j][0] - m2[j][2];
|
||||
m1[j][3] = m2[j][1] - m2[j][3];
|
||||
m1[j][4] = m2[j][4] + m2[j][6];
|
||||
m1[j][5] = m2[j][5] + m2[j][7];
|
||||
m1[j][6] = m2[j][4] - m2[j][6];
|
||||
m1[j][7] = m2[j][5] - m2[j][7];
|
||||
|
||||
m2[j][0] = m1[j][0] + m1[j][1];
|
||||
m2[j][1] = m1[j][0] - m1[j][1];
|
||||
m2[j][2] = m1[j][2] + m1[j][3];
|
||||
m2[j][3] = m1[j][2] - m1[j][3];
|
||||
m2[j][4] = m1[j][4] + m1[j][5];
|
||||
m2[j][5] = m1[j][4] - m1[j][5];
|
||||
m2[j][6] = m1[j][6] + m1[j][7];
|
||||
m2[j][7] = m1[j][6] - m1[j][7];
|
||||
}
|
||||
|
||||
//vertical
|
||||
for (i=0; i < 8; i++)
|
||||
{
|
||||
m3[0][i] = m2[0][i] + m2[4][i];
|
||||
m3[1][i] = m2[1][i] + m2[5][i];
|
||||
m3[2][i] = m2[2][i] + m2[6][i];
|
||||
m3[3][i] = m2[3][i] + m2[7][i];
|
||||
m3[4][i] = m2[0][i] - m2[4][i];
|
||||
m3[5][i] = m2[1][i] - m2[5][i];
|
||||
m3[6][i] = m2[2][i] - m2[6][i];
|
||||
m3[7][i] = m2[3][i] - m2[7][i];
|
||||
|
||||
m1[0][i] = m3[0][i] + m3[2][i];
|
||||
m1[1][i] = m3[1][i] + m3[3][i];
|
||||
m1[2][i] = m3[0][i] - m3[2][i];
|
||||
m1[3][i] = m3[1][i] - m3[3][i];
|
||||
m1[4][i] = m3[4][i] + m3[6][i];
|
||||
m1[5][i] = m3[5][i] + m3[7][i];
|
||||
m1[6][i] = m3[4][i] - m3[6][i];
|
||||
m1[7][i] = m3[5][i] - m3[7][i];
|
||||
|
||||
m2[0][i] = m1[0][i] + m1[1][i];
|
||||
m2[1][i] = m1[0][i] - m1[1][i];
|
||||
m2[2][i] = m1[2][i] + m1[3][i];
|
||||
m2[3][i] = m1[2][i] - m1[3][i];
|
||||
m2[4][i] = m1[4][i] + m1[5][i];
|
||||
m2[5][i] = m1[4][i] - m1[5][i];
|
||||
m2[6][i] = m1[6][i] + m1[7][i];
|
||||
m2[7][i] = m1[6][i] - m1[7][i];
|
||||
}
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
sad += abs(m2[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
sad=((sad+2)>>2);
|
||||
|
||||
return sad;
|
||||
}
|
||||
|
||||
|
||||
//Sum of Absolute Difference for block
|
||||
uint32_t SAD(uint8_t *block,uint8_t* block2, uint32_t x, uint32_t y)
|
||||
{
|
||||
|
@ -237,6 +333,20 @@ uint32_t SAD32x32(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stri
|
|||
uint32_t SAD16x16(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stride2)
|
||||
{
|
||||
int32_t i,ii,y;
|
||||
/*
|
||||
int32_t x,sum = 0;
|
||||
int32_t iOffsetOrg = stride1<<3;
|
||||
int32_t iOffsetCur = stride2<<3;
|
||||
for ( y=0; y<16; y+= 8 )
|
||||
{
|
||||
for ( x=0; x<16; x+= 8 )
|
||||
{
|
||||
sum += Hadamard8x8( &block[x], &block2[x], stride1, stride2 );
|
||||
}
|
||||
block += iOffsetOrg;
|
||||
block2 += iOffsetCur;
|
||||
}
|
||||
*/
|
||||
uint32_t sum=0;
|
||||
for(y=0;y<16;y++)
|
||||
{
|
||||
|
@ -259,7 +369,6 @@ uint32_t SAD16x16(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stri
|
|||
sum+=abs((int32_t)block[i+14]-(int32_t)block2[ii+14]);
|
||||
sum+=abs((int32_t)block[i+15]-(int32_t)block2[ii+15]);
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue