📄 loopfilter.cpp
字号:
indexA = IClip(0, MAX_QP, QP + AlphaC0Offset);
indexB = IClip(0, MAX_QP, QP + BetaOffset);
Alpha=ALPHA_TABLE[indexA];
Beta=BETA_TABLE[indexB];
ClipTab=CLIP_TAB[indexA];
L0 = SrcPtrP[0] ;
R0 = SrcPtrQ[0] ;
L1 = SrcPtrP[-incP] ;
R1 = SrcPtrQ[ incQ] ;
L2 = SrcPtrP[-incP*2] ;
R2 = SrcPtrQ[ incQ*2] ;
L3 = SrcPtrP[-incP*3] ;
R3 = SrcPtrQ[ incQ*3] ;
if( (Strng = Strength[StrengthIdx]) )
{
AbsDelta = abs( Delta = R0 - L0 ) ;
if( AbsDelta < Alpha )
{
C0 = ClipTab[ Strng ] ;
if( ((abs( R0 - R1) - Beta ) & (abs(L0 - L1) - Beta )) < 0 )
{
if( !yuv)
{
aq = (abs( R0 - R2) - Beta ) < 0 ;
ap = (abs( L0 - L2) - Beta ) < 0 ;
}
RL0 = L0 + R0 ;
if(Strng == 4 ) // INTRA strong filtering
{
if( yuv) // Chroma
{
SrcPtrQ[0] = ((R1 << 1) + R0 + L1 + 2) >> 2;
SrcPtrP[0] = ((L1 << 1) + L0 + R1 + 2) >> 2;
}
else // Luma
{
small_gap = (AbsDelta < ((Alpha >> 2) + 2));
aq &= small_gap;
ap &= small_gap;
SrcPtrQ[0] = aq ? ( L1 + ((R1 + RL0) << 1) + R2 + 4) >> 3 : ((R1 << 1) + R0 + L1 + 2) >> 2 ;
SrcPtrP[0] = ap ? ( R1 + ((L1 + RL0) << 1) + L2 + 4) >> 3 : ((L1 << 1) + L0 + R1 + 2) >> 2 ;
SrcPtrQ[ incQ] = aq ? ( R2 + R0 + R1 + L0 + 2) >> 2 : R1;
SrcPtrP[-incP] = ap ? ( L2 + L1 + L0 + R0 + 2) >> 2 : L1;
SrcPtrQ[ incQ*2] = aq ? (((R3 + R2) <<1) + R2 + R1 + RL0 + 4) >> 3 : R2;
SrcPtrP[-incP*2] = ap ? (((L3 + L2) <<1) + L2 + L1 + RL0 + 4) >> 3 : L2;
}
}
else // normal filtering
{
c0 = yuv? (C0+1):(C0 + ap + aq) ;
dif = IClip( -c0, c0, ( (Delta << 2) + (L1 - R1) + 4) >> 3 ) ;
SrcPtrP[0] = IClip(0, 255, L0 + dif) ;
SrcPtrQ[0] = IClip(0, 255, R0 - dif) ;
if( !yuv )
{
if( ap )
SrcPtrP[-incP] += IClip( -C0, C0, ( L2 + ((RL0 + 1) >> 1) - (L1<<1)) >> 1 ) ;
if( aq )
SrcPtrQ[ incQ] += IClip( -C0, C0, ( R2 + ((RL0 + 1) >> 1) - (R1<<1)) >> 1 ) ;
} ;
} ;
} ;
} ;
} ;
} ;
}
}*/
void EdgeLoopLuma(byte** Img, byte Strength[16],struct img_par *img, int MbQAddr, int AlphaC0Offset, int BetaOffset,
int dir, int edge, int width)
{
int pel, ap = 0, aq = 0, Strng ;
int incP, incQ;
int C0, c0, Delta, dif, AbsDelta ;
int L2 = 0, L1, L0, R0, R1, R2 = 0, RL0, L3, R3 ;
int Alpha = 0, Beta = 0 ;
byte* ClipTab = NULL;
int small_gap;
int indexA, indexB;
byte *SrcPtrP, *SrcPtrQ;
int QP;
int xP, xQ, yP, yQ;
Macroblock *MbQ, *MbP;
PixelPos pixP, pixQ;
for( pel=0 ; pel<16 ; pel++ )
{
xQ = dir ? pel : edge << 2;
yQ = dir ? (edge < 4 ? edge << 2 : 1) : pel;
getLumaNeighbour(MbQAddr, xQ, yQ, &pixQ);
getLumaNeighbour(MbQAddr, xQ - (1 - dir), yQ - dir, &pixP);
xP = pixP.x;
yP = pixP.y;
MbQ = &(img->mb_data[MbQAddr]);
MbP = &(img->mb_data[pixP.mb_addr]);
if (pixP.available || (MbQ->LFDisableIdc== 0)) {
incQ = dir ? width : 1;
incP = dir ? width : 1;
SrcPtrQ = &(Img[pixQ.pos_y][pixQ.pos_x]);
SrcPtrP = &(Img[pixP.pos_y][pixP.pos_x]);
// Average QP of the two blocks
QP = (MbP->qp + MbQ->qp + 1) >> 1;
indexA = IClip(0, MAX_QP, QP + AlphaC0Offset);
indexB = IClip(0, MAX_QP, QP + BetaOffset);
Alpha=ALPHA_TABLE[indexA];
Beta=BETA_TABLE[indexB];
ClipTab=CLIP_TAB[indexA];
L0 = SrcPtrP[0] ;
R0 = SrcPtrQ[0] ;
L1 = SrcPtrP[-incP] ;
R1 = SrcPtrQ[ incQ] ;
L2 = SrcPtrP[-incP*2] ;
R2 = SrcPtrQ[ incQ*2] ;
L3 = SrcPtrP[-incP*3] ;
R3 = SrcPtrQ[ incQ*3] ;
if( (Strng = Strength[pel]) )
{
AbsDelta = abs( Delta = R0 - L0 ) ;
if( AbsDelta < Alpha )
{
C0 = ClipTab[ Strng ] ;
if( ((abs( R0 - R1) - Beta ) & (abs(L0 - L1) - Beta )) < 0 )
{
aq = (abs( R0 - R2) - Beta ) < 0 ;
ap = (abs( L0 - L2) - Beta ) < 0 ;
RL0 = L0 + R0 ;
if(Strng == 4 ) // INTRA strong filtering
{
small_gap = (AbsDelta < ((Alpha >> 2) + 2));
aq &= small_gap;
ap &= small_gap;
SrcPtrQ[0] = aq ? ( L1 + ((R1 + RL0) << 1) + R2 + 4) >> 3 : ((R1 << 1) + R0 + L1 + 2) >> 2 ;
SrcPtrP[0] = ap ? ( R1 + ((L1 + RL0) << 1) + L2 + 4) >> 3 : ((L1 << 1) + L0 + R1 + 2) >> 2 ;
SrcPtrQ[ incQ] = aq ? ( R2 + R0 + R1 + L0 + 2) >> 2 : R1;
SrcPtrP[-incP] = ap ? ( L2 + L1 + L0 + R0 + 2) >> 2 : L1;
SrcPtrQ[ incQ*2] = aq ? (((R3 + R2) <<1) + R2 + R1 + RL0 + 4) >> 3 : R2;
SrcPtrP[-incP*2] = ap ? (((L3 + L2) <<1) + L2 + L1 + RL0 + 4) >> 3 : L2;
}
else // normal filtering
{
c0 = C0 + ap + aq ;
dif = IClip( -c0, c0, ( (Delta << 2) + (L1 - R1) + 4) >> 3 ) ;
SrcPtrP[0] = IClip(0, 255, L0 + dif) ;
SrcPtrQ[0] = IClip(0, 255, R0 - dif) ;
if( ap )
SrcPtrP[-incP] += IClip( -C0, C0, ( L2 + ((RL0 + 1) >> 1) - (L1<<1)) >> 1 ) ;
if( aq )
SrcPtrQ[ incQ] += IClip( -C0, C0, ( R2 + ((RL0 + 1) >> 1) - (R1<<1)) >> 1 ) ;
} ;
} ;
} ;
} ;
} ;
}
}
void EdgeLoopChroma(byte** Img, byte Strength[16],struct img_par *img, int MbQAddr, int AlphaC0Offset, int BetaOffset,
int dir, int edge, int width)
{
int pel, ap = 0, aq = 0, Strng ;
int incP, incQ;
int C0, c0, Delta, dif, AbsDelta ;
int L1, L0, R0, R1;
int Alpha = 0, Beta = 0 ;
byte* ClipTab = NULL;
int indexA, indexB;
int StrengthIdx;
byte *SrcPtrP, *SrcPtrQ;
int QP;
int xP, xQ, yP, yQ;
Macroblock *MbQ, *MbP;
PixelPos pixP, pixQ;
for( pel=0 ; pel<8; pel++ )
{
xQ = dir ? pel : edge << 2;
yQ = dir ? (edge < 4 ? edge << 2 : 1) : pel;
getChromaNeighbour(MbQAddr, xQ, yQ, &pixQ);
getChromaNeighbour(MbQAddr, xQ - (1 - dir), yQ - dir, &pixP);
xP = pixP.x;
yP = pixP.y;
MbQ = &(img->mb_data[MbQAddr]);
MbP = &(img->mb_data[pixP.mb_addr]);
StrengthIdx = ((pel>>1)<<2)+(pel&0x0001) ;
if (pixP.available || (MbQ->LFDisableIdc== 0)) {
incQ = dir ? width : 1;
incP = dir ? width : 1;
SrcPtrQ = &(Img[pixQ.pos_y][pixQ.pos_x]);
SrcPtrP = &(Img[pixP.pos_y][pixP.pos_x]);
// Average QP of the two blocks
QP = (QP_SCALE_CR[CQPOF(MbP->qp)] + QP_SCALE_CR[CQPOF(MbQ->qp)] + 1) >> 1 ;
indexA = IClip(0, MAX_QP, QP + AlphaC0Offset);
indexB = IClip(0, MAX_QP, QP + BetaOffset);
Alpha=ALPHA_TABLE[indexA];
Beta=BETA_TABLE[indexB];
ClipTab=CLIP_TAB[indexA];
L0 = SrcPtrP[0] ;
R0 = SrcPtrQ[0] ;
L1 = SrcPtrP[-incP] ;
R1 = SrcPtrQ[ incQ] ;
if( (Strng = Strength[StrengthIdx]) )
{
AbsDelta = abs( Delta = R0 - L0 ) ;
if( AbsDelta < Alpha )
{
C0 = ClipTab[ Strng ] ;
if( ((abs( R0 - R1) - Beta ) & (abs(L0 - L1) - Beta )) < 0 )
{
if(Strng == 4 ) // INTRA strong filtering
{
SrcPtrQ[0] = ((R1 << 1) + R0 + L1 + 2) >> 2;
SrcPtrP[0] = ((L1 << 1) + L0 + R1 + 2) >> 2;
}
else // normal filtering
{
c0 = C0+1;
dif = IClip( -c0, c0, ( (Delta << 2) + (L1 - R1) + 4) >> 3 ) ;
SrcPtrP[0] = IClip(0, 255, L0 + dif) ;
SrcPtrQ[0] = IClip(0, 255, R0 - dif) ;
} ;
} ;
} ;
} ;
} ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -