mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-23 18:14:06 +00:00
Added filter.c/.h and deblocking functions
This commit is contained in:
parent
d61f3a9d1b
commit
d0be802ced
|
@ -90,6 +90,7 @@
|
||||||
<ClCompile Include="..\..\src\context.c" />
|
<ClCompile Include="..\..\src\context.c" />
|
||||||
<ClCompile Include="..\..\src\encmain.c" />
|
<ClCompile Include="..\..\src\encmain.c" />
|
||||||
<ClCompile Include="..\..\src\encoder.c" />
|
<ClCompile Include="..\..\src\encoder.c" />
|
||||||
|
<ClCompile Include="..\..\src\filter.c" />
|
||||||
<ClCompile Include="..\..\src\intra.c" />
|
<ClCompile Include="..\..\src\intra.c" />
|
||||||
<ClCompile Include="..\..\src\nal.c" />
|
<ClCompile Include="..\..\src\nal.c" />
|
||||||
<ClCompile Include="..\..\src\picture.c" />
|
<ClCompile Include="..\..\src\picture.c" />
|
||||||
|
@ -101,6 +102,7 @@
|
||||||
<ClInclude Include="..\..\src\config.h" />
|
<ClInclude Include="..\..\src\config.h" />
|
||||||
<ClInclude Include="..\..\src\context.h" />
|
<ClInclude Include="..\..\src\context.h" />
|
||||||
<ClInclude Include="..\..\src\encoder.h" />
|
<ClInclude Include="..\..\src\encoder.h" />
|
||||||
|
<ClInclude Include="..\..\src\filter.h" />
|
||||||
<ClInclude Include="..\..\src\global.h" />
|
<ClInclude Include="..\..\src\global.h" />
|
||||||
<ClInclude Include="..\..\src\intra.h" />
|
<ClInclude Include="..\..\src\intra.h" />
|
||||||
<ClInclude Include="..\..\src\nal.h" />
|
<ClInclude Include="..\..\src\nal.h" />
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
<ClCompile Include="..\..\src\context.c">
|
<ClCompile Include="..\..\src\context.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\filter.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\src\global.h">
|
<ClInclude Include="..\..\src\global.h">
|
||||||
|
@ -77,5 +80,8 @@
|
||||||
<ClInclude Include="..\..\src\context.h">
|
<ClInclude Include="..\..\src\context.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\filter.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -53,6 +53,10 @@ typedef struct
|
||||||
picture_list *ref;
|
picture_list *ref;
|
||||||
uint8_t QP;
|
uint8_t QP;
|
||||||
uint8_t bitdepth;
|
uint8_t bitdepth;
|
||||||
|
|
||||||
|
/* Filtering */
|
||||||
|
int8_t betaOffset;
|
||||||
|
int8_t tcOffset;
|
||||||
} encoder_control;
|
} encoder_control;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -102,7 +106,7 @@ void init_tables(void);
|
||||||
|
|
||||||
static uint32_t* g_auiSigLastScan[3][7];
|
static uint32_t* g_auiSigLastScan[3][7];
|
||||||
int8_t g_aucConvertToBit[LCU_WIDTH+1];
|
int8_t g_aucConvertToBit[LCU_WIDTH+1];
|
||||||
static int8_t g_uiBitDepth = 8;
|
static int8_t g_bitDepth = 8;
|
||||||
static int8_t g_uiBitIncrement = 0;
|
static int8_t g_uiBitIncrement = 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_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};
|
||||||
|
|
179
src/filter.c
Normal file
179
src/filter.c
Normal file
|
@ -0,0 +1,179 @@
|
||||||
|
/**
|
||||||
|
* HEVC Encoder
|
||||||
|
* - Marko Viitanen ( fador at iki.fi ), Tampere University of Technology, Department of Computer Systems.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \file filter.c
|
||||||
|
\brief filtering
|
||||||
|
\author Marko Viitanen
|
||||||
|
\date 2013-04
|
||||||
|
|
||||||
|
Filtering functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "global.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "bitstream.h"
|
||||||
|
#include "picture.h"
|
||||||
|
#include "cabac.h"
|
||||||
|
#include "encoder.h"
|
||||||
|
#include "filter.h"
|
||||||
|
|
||||||
|
const uint8_t tctable_8x8[54] =
|
||||||
|
{
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,5,5,6,6,7,8,9,10,11,13,14,16,18,20,22,24
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t betatable_8x8[52] =
|
||||||
|
{
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void filter_luma( uint8_t* piSrc, int32_t iOffset, int32_t tc , int8_t sw, int8_t bPartPNoFilter, int8_t bPartQNoFilter, int32_t iThrCut, int8_t bFilterSecondP, int8_t bFilterSecondQ)
|
||||||
|
{
|
||||||
|
int32_t delta;
|
||||||
|
|
||||||
|
uint8_t m4 = piSrc[0];
|
||||||
|
uint8_t m3 = piSrc[-iOffset];
|
||||||
|
uint8_t m5 = piSrc[ iOffset];
|
||||||
|
uint8_t m2 = piSrc[-iOffset*2];
|
||||||
|
uint8_t m6 = piSrc[ iOffset*2];
|
||||||
|
uint8_t m1 = piSrc[-iOffset*3];
|
||||||
|
uint8_t m7 = piSrc[ iOffset*3];
|
||||||
|
uint8_t m0 = piSrc[-iOffset*4];
|
||||||
|
|
||||||
|
if (sw)
|
||||||
|
{
|
||||||
|
piSrc[-iOffset] = CLIP(m3-2*tc, m3+2*tc, ((m1 + 2*m2 + 2*m3 + 2*m4 + m5 + 4) >> 3));
|
||||||
|
piSrc[0] = CLIP(m4-2*tc, m4+2*tc, ((m2 + 2*m3 + 2*m4 + 2*m5 + m6 + 4) >> 3));
|
||||||
|
piSrc[-iOffset*2] = CLIP(m2-2*tc, m2+2*tc, ((m1 + m2 + m3 + m4 + 2)>>2));
|
||||||
|
piSrc[ iOffset] = CLIP(m5-2*tc, m5+2*tc, ((m3 + m4 + m5 + m6 + 2)>>2));
|
||||||
|
piSrc[-iOffset*3] = CLIP(m1-2*tc, m1+2*tc, ((2*m0 + 3*m1 + m2 + m3 + m4 + 4 )>>3));
|
||||||
|
piSrc[ iOffset*2] = CLIP(m6-2*tc, m6+2*tc, ((m3 + m4 + m5 + 3*m6 + 2*m7 +4 )>>3));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Weak filter
|
||||||
|
delta = (9*(m4-m3) -3*(m5-m2) + 8)>>4 ;
|
||||||
|
|
||||||
|
if ( abs(delta) < iThrCut )
|
||||||
|
{
|
||||||
|
int32_t tc2 = tc>>1;
|
||||||
|
delta = CLIP(-tc, tc, delta);
|
||||||
|
piSrc[-iOffset] = CLIP(0,(1 << g_bitDepth)-1,(m3+delta));
|
||||||
|
piSrc[0] = CLIP(0,(1 << g_bitDepth)-1,(m4-delta));
|
||||||
|
|
||||||
|
|
||||||
|
if(bFilterSecondP)
|
||||||
|
{
|
||||||
|
int32_t delta1 = CLIP(-tc2, tc2, (( ((m1+m3+1)>>1)- m2+delta)>>1));
|
||||||
|
piSrc[-iOffset*2] = CLIP(0,(1 << g_bitDepth)-1,(m2+delta1));
|
||||||
|
}
|
||||||
|
if(bFilterSecondQ)
|
||||||
|
{
|
||||||
|
int32_t delta2 = CLIP(-tc2, tc2, (( ((m6+m4+1)>>1)- m5-delta)>>1));
|
||||||
|
piSrc[ iOffset] = CLIP(0,(1 << g_bitDepth)-1,(m5+delta2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bPartPNoFilter)
|
||||||
|
{
|
||||||
|
piSrc[-iOffset] = m3;
|
||||||
|
piSrc[-iOffset*2] = m2;
|
||||||
|
piSrc[-iOffset*3] = m1;
|
||||||
|
}
|
||||||
|
if(bPartQNoFilter)
|
||||||
|
{
|
||||||
|
piSrc[0] = m4;
|
||||||
|
piSrc[ iOffset] = m5;
|
||||||
|
piSrc[ iOffset*2] = m6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
const int8_t scu_width = (LCU_WIDTH>>MAX_DEPTH);
|
||||||
|
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)];
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/* Check conditions for filtering */
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
src/filter.h
Normal file
22
src/filter.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/**
|
||||||
|
* HEVC Encoder
|
||||||
|
* - Marko Viitanen ( fador at iki.fi ), Tampere University of Technology, Department of Computer Systems 2012.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \file filter.h
|
||||||
|
\brief filter
|
||||||
|
\author Marko Viitanen
|
||||||
|
\date 2013-04
|
||||||
|
|
||||||
|
Filtering function headers
|
||||||
|
*/
|
||||||
|
#ifndef __FILTER_H
|
||||||
|
#define __FILTER_H
|
||||||
|
|
||||||
|
#define EDGE_VER 0
|
||||||
|
#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);
|
||||||
|
|
||||||
|
#endif
|
|
@ -83,7 +83,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)
|
int16_t intra_getDCPred(int16_t* pic, uint16_t picwidth,uint32_t xpos, uint32_t ypos, uint8_t width)
|
||||||
{
|
{
|
||||||
int32_t i, iSum = 0;
|
int32_t i, iSum = 0;
|
||||||
int16_t pDcVal = 1<<(g_uiBitDepth-1);
|
int16_t pDcVal = 1<<(g_bitDepth-1);
|
||||||
|
|
||||||
/* Average of pixels on top and left */
|
/* Average of pixels on top and left */
|
||||||
for (i = -picwidth; i < width-picwidth ; i++)
|
for (i = -picwidth; i < width-picwidth ; i++)
|
||||||
|
@ -367,7 +367,7 @@ void intra_buildReferenceBorder(picture* pic, int32_t xCtb, int32_t yCtb,int16_t
|
||||||
int32_t leftColumn; /*!< left column iterator */
|
int32_t leftColumn; /*!< left column iterator */
|
||||||
int16_t val; /*!< variable to store extrapolated value */
|
int16_t val; /*!< variable to store extrapolated value */
|
||||||
int32_t i; /*!< index iterator */
|
int32_t i; /*!< index iterator */
|
||||||
int16_t dcVal = 1<<(g_uiBitDepth-1); /*!< default predictor value */
|
int16_t dcVal = 1<<(g_bitDepth-1); /*!< default predictor value */
|
||||||
int32_t topRow; /*!< top row iterator */
|
int32_t topRow; /*!< top row iterator */
|
||||||
int32_t srcWidth = (pic->width>>(chroma?1:0)); /*!< source picture width */
|
int32_t srcWidth = (pic->width>>(chroma?1:0)); /*!< source picture width */
|
||||||
int32_t srcHeight = (pic->height>>(chroma?1:0));/*!< source picture height */
|
int32_t srcHeight = (pic->height>>(chroma?1:0));/*!< source picture height */
|
||||||
|
@ -546,7 +546,7 @@ void intra_getAngularPred(int16_t* pSrc, int32_t srcStride, int16_t* rpDst, int3
|
||||||
{
|
{
|
||||||
for (k=0;k<blkSize;k++)
|
for (k=0;k<blkSize;k++)
|
||||||
{
|
{
|
||||||
pDst[k*dstStride] = CLIP(0, (1<<g_uiBitDepth)-1, pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) );
|
pDst[k*dstStride] = CLIP(0, (1<<g_bitDepth)-1, pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -636,7 +636,7 @@ void intra_DCPredFiltering(uint8_t* pSrc, int32_t iSrcStride, uint8_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)
|
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_uiBitDepth-1);
|
int16_t pDcVal = 1<<(g_bitDepth-1);
|
||||||
int32_t k, l, bottomLeft, topRight;
|
int32_t k, l, bottomLeft, topRight;
|
||||||
int32_t horPred;
|
int32_t horPred;
|
||||||
int32_t leftColumn[LCU_WIDTH+1], topRow[LCU_WIDTH+1], bottomRow[LCU_WIDTH+1], rightColumn[LCU_WIDTH+1];
|
int32_t leftColumn[LCU_WIDTH+1], topRow[LCU_WIDTH+1], bottomRow[LCU_WIDTH+1], rightColumn[LCU_WIDTH+1];
|
||||||
|
|
260
src/picture.c
260
src/picture.c
|
@ -131,173 +131,173 @@
|
||||||
//Calculates image PSNR value
|
//Calculates image PSNR value
|
||||||
double imagePSNR(uint8_t *frame1, uint8_t *frame2, uint32_t x, uint32_t y)
|
double imagePSNR(uint8_t *frame1, uint8_t *frame2, uint32_t x, uint32_t y)
|
||||||
{
|
{
|
||||||
double MSE=0.0;
|
uint64_t MSE=0;
|
||||||
double MSEtemp=0.0;
|
uint64_t MSEtemp=0;
|
||||||
double psnr=0.0;
|
double psnr=0.0;
|
||||||
int32_t index;
|
int32_t index;
|
||||||
|
|
||||||
//Calculate MSE
|
//Calculate MSE
|
||||||
for(index=x*y-1;index>=0;index--)
|
for(index=x*y-1;index>=0;index--)
|
||||||
{
|
{
|
||||||
MSEtemp=abs(frame1[index]-frame2[index]);
|
MSEtemp=frame1[index]-frame2[index];
|
||||||
MSE+=MSEtemp*MSEtemp;
|
MSE+=MSEtemp*MSEtemp;
|
||||||
}
|
}
|
||||||
MSE/=x*y;
|
MSE/=x*y;
|
||||||
|
|
||||||
//Avoid division by zero
|
//Avoid division by zero
|
||||||
if(MSE==0) return 99.0;
|
if(MSE==0) return 99.0;
|
||||||
|
|
||||||
//The PSNR
|
//The PSNR
|
||||||
psnr=10*log10(PSNRMAX/MSE);
|
psnr=10*log10(PSNRMAX/MSE);
|
||||||
|
|
||||||
//Thats it.
|
//Thats it.
|
||||||
return psnr;
|
return psnr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sum of Absolute Difference for block
|
//Sum of Absolute Difference for block
|
||||||
uint32_t SAD(uint8_t *block,uint8_t* block2, uint32_t x, uint32_t y)
|
uint32_t SAD(uint8_t *block,uint8_t* block2, uint32_t x, uint32_t y)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint32_t sum=0;
|
uint32_t sum=0;
|
||||||
for(i=0;i<x*y;i+=4)
|
for(i=0;i<x*y;i+=4)
|
||||||
{
|
{
|
||||||
sum+=abs((int32_t)block[i]-(int32_t)block2[i]);
|
sum+=abs((int32_t)block[i]-(int32_t)block2[i]);
|
||||||
sum+=abs((int32_t)block[i+1]-(int32_t)block2[i+1]);
|
sum+=abs((int32_t)block[i+1]-(int32_t)block2[i+1]);
|
||||||
sum+=abs((int32_t)block[i+2]-(int32_t)block2[i+2]);
|
sum+=abs((int32_t)block[i+2]-(int32_t)block2[i+2]);
|
||||||
sum+=abs((int32_t)block[i+3]-(int32_t)block2[i+3]);
|
sum+=abs((int32_t)block[i+3]-(int32_t)block2[i+3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SAD64x64(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stride2)
|
uint32_t SAD64x64(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stride2)
|
||||||
{
|
{
|
||||||
int32_t i,ii,y,x;
|
int32_t i,ii,y,x;
|
||||||
uint32_t sum=0;
|
uint32_t sum=0;
|
||||||
for(y=0;y<64;y++)
|
for(y=0;y<64;y++)
|
||||||
|
{
|
||||||
|
i = y*stride1;
|
||||||
|
ii = y*stride2;
|
||||||
|
for(x = 0; x < 64;x++)
|
||||||
{
|
{
|
||||||
i = y*stride1;
|
sum+=abs((int32_t)block[i+x]-(int32_t)block2[ii+x]);
|
||||||
ii = y*stride2;
|
|
||||||
for(x = 0; x < 64;x++)
|
|
||||||
{
|
|
||||||
sum+=abs((int32_t)block[i+x]-(int32_t)block2[ii+x]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
}
|
||||||
|
|
||||||
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SAD32x32(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stride2)
|
uint32_t SAD32x32(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stride2)
|
||||||
{
|
{
|
||||||
int32_t i,ii,y;
|
int32_t i,ii,y;
|
||||||
uint32_t sum=0;
|
uint32_t sum=0;
|
||||||
for(y=0;y<32;y++)
|
for(y=0;y<32;y++)
|
||||||
{
|
{
|
||||||
i = y*stride1;
|
i = y*stride1;
|
||||||
ii = y*stride2;
|
ii = y*stride2;
|
||||||
sum+=abs((int32_t)block[i]-(int32_t)block2[ii]);
|
sum+=abs((int32_t)block[i]-(int32_t)block2[ii]);
|
||||||
sum+=abs((int32_t)block[i+1]-(int32_t)block2[ii+1]);
|
sum+=abs((int32_t)block[i+1]-(int32_t)block2[ii+1]);
|
||||||
sum+=abs((int32_t)block[i+2]-(int32_t)block2[ii+2]);
|
sum+=abs((int32_t)block[i+2]-(int32_t)block2[ii+2]);
|
||||||
sum+=abs((int32_t)block[i+3]-(int32_t)block2[ii+3]);
|
sum+=abs((int32_t)block[i+3]-(int32_t)block2[ii+3]);
|
||||||
sum+=abs((int32_t)block[i+4]-(int32_t)block2[ii+4]);
|
sum+=abs((int32_t)block[i+4]-(int32_t)block2[ii+4]);
|
||||||
sum+=abs((int32_t)block[i+5]-(int32_t)block2[ii+5]);
|
sum+=abs((int32_t)block[i+5]-(int32_t)block2[ii+5]);
|
||||||
sum+=abs((int32_t)block[i+6]-(int32_t)block2[ii+6]);
|
sum+=abs((int32_t)block[i+6]-(int32_t)block2[ii+6]);
|
||||||
sum+=abs((int32_t)block[i+7]-(int32_t)block2[ii+7]);
|
sum+=abs((int32_t)block[i+7]-(int32_t)block2[ii+7]);
|
||||||
sum+=abs((int32_t)block[i+8]-(int32_t)block2[ii+8]);
|
sum+=abs((int32_t)block[i+8]-(int32_t)block2[ii+8]);
|
||||||
sum+=abs((int32_t)block[i+9]-(int32_t)block2[ii+9]);
|
sum+=abs((int32_t)block[i+9]-(int32_t)block2[ii+9]);
|
||||||
sum+=abs((int32_t)block[i+10]-(int32_t)block2[ii+10]);
|
sum+=abs((int32_t)block[i+10]-(int32_t)block2[ii+10]);
|
||||||
sum+=abs((int32_t)block[i+11]-(int32_t)block2[ii+11]);
|
sum+=abs((int32_t)block[i+11]-(int32_t)block2[ii+11]);
|
||||||
sum+=abs((int32_t)block[i+12]-(int32_t)block2[ii+12]);
|
sum+=abs((int32_t)block[i+12]-(int32_t)block2[ii+12]);
|
||||||
sum+=abs((int32_t)block[i+13]-(int32_t)block2[ii+13]);
|
sum+=abs((int32_t)block[i+13]-(int32_t)block2[ii+13]);
|
||||||
sum+=abs((int32_t)block[i+14]-(int32_t)block2[ii+14]);
|
sum+=abs((int32_t)block[i+14]-(int32_t)block2[ii+14]);
|
||||||
sum+=abs((int32_t)block[i+15]-(int32_t)block2[ii+15]);
|
sum+=abs((int32_t)block[i+15]-(int32_t)block2[ii+15]);
|
||||||
sum+=abs((int32_t)block[i+16]-(int32_t)block2[ii+16]);
|
sum+=abs((int32_t)block[i+16]-(int32_t)block2[ii+16]);
|
||||||
sum+=abs((int32_t)block[i+17]-(int32_t)block2[ii+17]);
|
sum+=abs((int32_t)block[i+17]-(int32_t)block2[ii+17]);
|
||||||
sum+=abs((int32_t)block[i+18]-(int32_t)block2[ii+18]);
|
sum+=abs((int32_t)block[i+18]-(int32_t)block2[ii+18]);
|
||||||
sum+=abs((int32_t)block[i+19]-(int32_t)block2[ii+19]);
|
sum+=abs((int32_t)block[i+19]-(int32_t)block2[ii+19]);
|
||||||
sum+=abs((int32_t)block[i+20]-(int32_t)block2[ii+20]);
|
sum+=abs((int32_t)block[i+20]-(int32_t)block2[ii+20]);
|
||||||
sum+=abs((int32_t)block[i+21]-(int32_t)block2[ii+21]);
|
sum+=abs((int32_t)block[i+21]-(int32_t)block2[ii+21]);
|
||||||
sum+=abs((int32_t)block[i+22]-(int32_t)block2[ii+22]);
|
sum+=abs((int32_t)block[i+22]-(int32_t)block2[ii+22]);
|
||||||
sum+=abs((int32_t)block[i+23]-(int32_t)block2[ii+23]);
|
sum+=abs((int32_t)block[i+23]-(int32_t)block2[ii+23]);
|
||||||
sum+=abs((int32_t)block[i+24]-(int32_t)block2[ii+24]);
|
sum+=abs((int32_t)block[i+24]-(int32_t)block2[ii+24]);
|
||||||
sum+=abs((int32_t)block[i+25]-(int32_t)block2[ii+25]);
|
sum+=abs((int32_t)block[i+25]-(int32_t)block2[ii+25]);
|
||||||
sum+=abs((int32_t)block[i+26]-(int32_t)block2[ii+26]);
|
sum+=abs((int32_t)block[i+26]-(int32_t)block2[ii+26]);
|
||||||
sum+=abs((int32_t)block[i+27]-(int32_t)block2[ii+27]);
|
sum+=abs((int32_t)block[i+27]-(int32_t)block2[ii+27]);
|
||||||
sum+=abs((int32_t)block[i+28]-(int32_t)block2[ii+28]);
|
sum+=abs((int32_t)block[i+28]-(int32_t)block2[ii+28]);
|
||||||
sum+=abs((int32_t)block[i+29]-(int32_t)block2[ii+29]);
|
sum+=abs((int32_t)block[i+29]-(int32_t)block2[ii+29]);
|
||||||
sum+=abs((int32_t)block[i+30]-(int32_t)block2[ii+30]);
|
sum+=abs((int32_t)block[i+30]-(int32_t)block2[ii+30]);
|
||||||
sum+=abs((int32_t)block[i+31]-(int32_t)block2[ii+31]);
|
sum+=abs((int32_t)block[i+31]-(int32_t)block2[ii+31]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t SAD16x16(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stride2)
|
uint32_t SAD16x16(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stride2)
|
||||||
{
|
{
|
||||||
int32_t i,ii,y;
|
int32_t i,ii,y;
|
||||||
uint32_t sum=0;
|
uint32_t sum=0;
|
||||||
for(y=0;y<16;y++)
|
for(y=0;y<16;y++)
|
||||||
{
|
{
|
||||||
i = y*stride1;
|
i = y*stride1;
|
||||||
ii = y*stride2;
|
ii = y*stride2;
|
||||||
sum+=abs((int32_t)block[i]-(int32_t)block2[ii]);
|
sum+=abs((int32_t)block[i]-(int32_t)block2[ii]);
|
||||||
sum+=abs((int32_t)block[i+1]-(int32_t)block2[ii+1]);
|
sum+=abs((int32_t)block[i+1]-(int32_t)block2[ii+1]);
|
||||||
sum+=abs((int32_t)block[i+2]-(int32_t)block2[ii+2]);
|
sum+=abs((int32_t)block[i+2]-(int32_t)block2[ii+2]);
|
||||||
sum+=abs((int32_t)block[i+3]-(int32_t)block2[ii+3]);
|
sum+=abs((int32_t)block[i+3]-(int32_t)block2[ii+3]);
|
||||||
sum+=abs((int32_t)block[i+4]-(int32_t)block2[ii+4]);
|
sum+=abs((int32_t)block[i+4]-(int32_t)block2[ii+4]);
|
||||||
sum+=abs((int32_t)block[i+5]-(int32_t)block2[ii+5]);
|
sum+=abs((int32_t)block[i+5]-(int32_t)block2[ii+5]);
|
||||||
sum+=abs((int32_t)block[i+6]-(int32_t)block2[ii+6]);
|
sum+=abs((int32_t)block[i+6]-(int32_t)block2[ii+6]);
|
||||||
sum+=abs((int32_t)block[i+7]-(int32_t)block2[ii+7]);
|
sum+=abs((int32_t)block[i+7]-(int32_t)block2[ii+7]);
|
||||||
sum+=abs((int32_t)block[i+8]-(int32_t)block2[ii+8]);
|
sum+=abs((int32_t)block[i+8]-(int32_t)block2[ii+8]);
|
||||||
sum+=abs((int32_t)block[i+9]-(int32_t)block2[ii+9]);
|
sum+=abs((int32_t)block[i+9]-(int32_t)block2[ii+9]);
|
||||||
sum+=abs((int32_t)block[i+10]-(int32_t)block2[ii+10]);
|
sum+=abs((int32_t)block[i+10]-(int32_t)block2[ii+10]);
|
||||||
sum+=abs((int32_t)block[i+11]-(int32_t)block2[ii+11]);
|
sum+=abs((int32_t)block[i+11]-(int32_t)block2[ii+11]);
|
||||||
sum+=abs((int32_t)block[i+12]-(int32_t)block2[ii+12]);
|
sum+=abs((int32_t)block[i+12]-(int32_t)block2[ii+12]);
|
||||||
sum+=abs((int32_t)block[i+13]-(int32_t)block2[ii+13]);
|
sum+=abs((int32_t)block[i+13]-(int32_t)block2[ii+13]);
|
||||||
sum+=abs((int32_t)block[i+14]-(int32_t)block2[ii+14]);
|
sum+=abs((int32_t)block[i+14]-(int32_t)block2[ii+14]);
|
||||||
sum+=abs((int32_t)block[i+15]-(int32_t)block2[ii+15]);
|
sum+=abs((int32_t)block[i+15]-(int32_t)block2[ii+15]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t SAD8x8(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stride2)
|
uint32_t SAD8x8(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stride2)
|
||||||
{
|
{
|
||||||
int32_t i,ii,y;
|
int32_t i,ii,y;
|
||||||
uint32_t sum=0;
|
uint32_t sum=0;
|
||||||
for(y=0;y<8;y++)
|
for(y=0;y<8;y++)
|
||||||
{
|
{
|
||||||
i = y*stride1;
|
i = y*stride1;
|
||||||
ii = y*stride2;
|
ii = y*stride2;
|
||||||
sum+=abs((int32_t)block[i]-(int32_t)block2[ii]);
|
sum+=abs((int32_t)block[i]-(int32_t)block2[ii]);
|
||||||
sum+=abs((int32_t)block[i+1]-(int32_t)block2[ii+1]);
|
sum+=abs((int32_t)block[i+1]-(int32_t)block2[ii+1]);
|
||||||
sum+=abs((int32_t)block[i+2]-(int32_t)block2[ii+2]);
|
sum+=abs((int32_t)block[i+2]-(int32_t)block2[ii+2]);
|
||||||
sum+=abs((int32_t)block[i+3]-(int32_t)block2[ii+3]);
|
sum+=abs((int32_t)block[i+3]-(int32_t)block2[ii+3]);
|
||||||
sum+=abs((int32_t)block[i+4]-(int32_t)block2[ii+4]);
|
sum+=abs((int32_t)block[i+4]-(int32_t)block2[ii+4]);
|
||||||
sum+=abs((int32_t)block[i+5]-(int32_t)block2[ii+5]);
|
sum+=abs((int32_t)block[i+5]-(int32_t)block2[ii+5]);
|
||||||
sum+=abs((int32_t)block[i+6]-(int32_t)block2[ii+6]);
|
sum+=abs((int32_t)block[i+6]-(int32_t)block2[ii+6]);
|
||||||
sum+=abs((int32_t)block[i+7]-(int32_t)block2[ii+7]);
|
sum+=abs((int32_t)block[i+7]-(int32_t)block2[ii+7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SAD4x4(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stride2)
|
uint32_t SAD4x4(int16_t *block,uint32_t stride1,int16_t* block2, uint32_t stride2)
|
||||||
{
|
{
|
||||||
int32_t i,ii,y;
|
int32_t i,ii,y;
|
||||||
uint32_t sum=0;
|
uint32_t sum=0;
|
||||||
for(y=0;y<4;y++)
|
for(y=0;y<4;y++)
|
||||||
{
|
{
|
||||||
i = y*stride1;
|
i = y*stride1;
|
||||||
ii = y*stride2;
|
ii = y*stride2;
|
||||||
sum+=abs((int32_t)block[i]-(int32_t)block2[ii]);
|
sum+=abs((int32_t)block[i]-(int32_t)block2[ii]);
|
||||||
sum+=abs((int32_t)block[i+1]-(int32_t)block2[ii+1]);
|
sum+=abs((int32_t)block[i+1]-(int32_t)block2[ii+1]);
|
||||||
sum+=abs((int32_t)block[i+2]-(int32_t)block2[ii+2]);
|
sum+=abs((int32_t)block[i+2]-(int32_t)block2[ii+2]);
|
||||||
sum+=abs((int32_t)block[i+3]-(int32_t)block2[ii+3]);
|
sum+=abs((int32_t)block[i+3]-(int32_t)block2[ii+3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
|
@ -714,7 +714,7 @@ void itransform2d(int16_t *block,int16_t *coeff, int8_t blockSize, int8_t uiMode
|
||||||
//(Int bitDepth, Short *coeff,Short *block, Int iWidth, Int iHeight, UInt uiMode)
|
//(Int bitDepth, Short *coeff,Short *block, Int iWidth, Int iHeight, UInt uiMode)
|
||||||
{
|
{
|
||||||
int32_t shift_1st = 7;
|
int32_t shift_1st = 7;
|
||||||
int32_t shift_2nd = 12 - (g_uiBitDepth-8);
|
int32_t shift_2nd = 12 - (g_bitDepth-8);
|
||||||
int16_t tmp[LCU_WIDTH*LCU_WIDTH];
|
int16_t tmp[LCU_WIDTH*LCU_WIDTH];
|
||||||
|
|
||||||
if( blockSize == 4)
|
if( blockSize == 4)
|
||||||
|
@ -797,7 +797,7 @@ void quant(encoder_control* encoder, int16_t* pSrc, int16_t* pDes, int32_t iWidt
|
||||||
|
|
||||||
int32_t *piQuantCoeff = g_quant_coeff[uiLog2TrSize-2][scalingListType][/*m_cQP.m_iRem*/qpScaled%6];
|
int32_t *piQuantCoeff = g_quant_coeff[uiLog2TrSize-2][scalingListType][/*m_cQP.m_iRem*/qpScaled%6];
|
||||||
|
|
||||||
uint32_t uiBitDepth = g_uiBitDepth;
|
uint32_t uiBitDepth = g_bitDepth;
|
||||||
|
|
||||||
int32_t iTransformShift = /*MAX_TR_DYNAMIC_RANGE*/15 - uiBitDepth - uiLog2TrSize; // Represents scaling through forward transform
|
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;
|
int32_t iQBits = QUANT_SHIFT + /*cQpBase.m_iPer +*/qpScaled/6 + iTransformShift;
|
||||||
|
@ -831,7 +831,7 @@ void dequant(encoder_control* encoder, int16_t* piQCoef, int16_t* piCoef, int32_
|
||||||
uint32_t uiLog2TrSize = g_aucConvertToBit[ iWidth ] + 2;
|
uint32_t uiLog2TrSize = g_aucConvertToBit[ iWidth ] + 2;
|
||||||
int16_t clipQCoef;
|
int16_t clipQCoef;
|
||||||
int32_t n;
|
int32_t n;
|
||||||
int32_t iTransformShift = 15 - g_uiBitDepth - (g_aucConvertToBit[ iWidth ] + 2);
|
int32_t iTransformShift = 15 - g_bitDepth - (g_aucConvertToBit[ iWidth ] + 2);
|
||||||
int32_t qpScaled;
|
int32_t qpScaled;
|
||||||
int32_t iQpBase = encoder->QP;
|
int32_t iQpBase = encoder->QP;
|
||||||
int32_t scalingListType = (/*pcCU->isint32_tra(uiAbsPartIdx)*/0 ? 0 : 3) + (int8_t)("\0\3\1\2"[eTType]);
|
int32_t scalingListType = (/*pcCU->isint32_tra(uiAbsPartIdx)*/0 ? 0 : 3) + (int8_t)("\0\3\1\2"[eTType]);
|
||||||
|
|
Loading…
Reference in a new issue