Faster VC-1 C loopfilter using lots of xor magic

Originally committed as revision 16670 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Jason Garrett-Glaser 2009-01-18 07:14:36 +00:00
parent 2a839eeb02
commit 0a359cf157

View File

@ -314,30 +314,39 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v)
* @return whether other 3 pairs should be filtered or not * @return whether other 3 pairs should be filtered or not
* @see 8.6 * @see 8.6
*/ */
static int vc1_filter_line(uint8_t* src, int stride, int pq){ static int av_always_inline vc1_filter_line(uint8_t* src, int stride, int pq){
int a0, a1, a2, a3, d, clip, filt3 = 0;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
a0 = (2*(src[-2*stride] - src[ 1*stride]) - 5*(src[-1*stride] - src[ 0*stride]) + 4) >> 3; int a0 = (2*(src[-2*stride] - src[ 1*stride]) - 5*(src[-1*stride] - src[ 0*stride]) + 4) >> 3;
if(FFABS(a0) < pq){ int a0_sign = a0 >> 31; /* Store sign */
a1 = (2*(src[-4*stride] - src[-1*stride]) - 5*(src[-3*stride] - src[-2*stride]) + 4) >> 3; a0 = (a0 ^ a0_sign) - a0_sign; /* a0 = FFABS(a0); */
a2 = (2*(src[ 0*stride] - src[ 3*stride]) - 5*(src[ 1*stride] - src[ 2*stride]) + 4) >> 3; if(a0 < pq){
a3 = FFMIN(FFABS(a1), FFABS(a2)); int a1 = FFABS((2*(src[-4*stride] - src[-1*stride]) - 5*(src[-3*stride] - src[-2*stride]) + 4) >> 3);
if(a3 < FFABS(a0)){ int a2 = FFABS((2*(src[ 0*stride] - src[ 3*stride]) - 5*(src[ 1*stride] - src[ 2*stride]) + 4) >> 3);
d = 5 * ((a0 >=0 ? a3 : -a3) - a0) / 8; if(a1 < a0 || a2 < a0){
clip = (src[-1*stride] - src[ 0*stride])/2; int clip = src[-1*stride] - src[ 0*stride];
int clip_sign = clip >> 31;
clip = ((clip ^ clip_sign) - clip_sign)>>1;
if(clip){ if(clip){
filt3 = 1; int a3 = FFMIN(a1, a2);
if(clip > 0) int d = 5 * (a3 - a0);
d = av_clip(d, 0, clip); int d_sign = (d >> 31);
else d = ((d ^ d_sign) - d_sign) >> 3;
d = av_clip(d, clip, 0); d_sign ^= a0_sign;
src[-1*stride] = cm[src[-1*stride] - d];
src[ 0*stride] = cm[src[ 0*stride] + d]; if( (d_sign ^ clip_sign) | ~d )
d = 0;
else{
d = FFMIN(d, clip);
d = (d ^ d_sign) - d_sign; /* Restore sign */
src[-1*stride] = cm[src[-1*stride] - d];
src[ 0*stride] = cm[src[ 0*stride] + d];
}
return 1;
} }
} }
} }
return filt3; return 0;
} }
/** /**