Mercurial > libavcodec.hg
diff dsputil.c @ 1644:835cf346975e libavcodec
h263 loop filter
fixed h263 modified quantization
CODEC_FLAG_OBMC
author | michael |
---|---|
date | Mon, 01 Dec 2003 15:23:14 +0000 |
parents | 932d306bf1dc |
children | 901f928ec1f6 |
line wrap: on
line diff
--- a/dsputil.c Sun Nov 30 19:04:56 2003 +0000 +++ b/dsputil.c Mon Dec 01 15:23:14 2003 +0000 @@ -2261,6 +2261,75 @@ wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8); } +static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){ + int x; + const int strength= ff_h263_loop_filter_strength[qscale]; + + for(x=0; x<8; x++){ + int d1, d2, ad1; + int p0= src[x-2*stride]; + int p1= src[x-1*stride]; + int p2= src[x+0*stride]; + int p3= src[x+1*stride]; + int d = (p0 - p3 + 4*(p2 - p1)) / 8; + + if (d<-2*strength) d1= 0; + else if(d<- strength) d1=-2*strength - d; + else if(d< strength) d1= d; + else if(d< 2*strength) d1= 2*strength - d; + else d1= 0; + + p1 += d1; + p2 -= d1; + if(p1&256) p1= ~(p1>>31); + if(p2&256) p2= ~(p2>>31); + + src[x-1*stride] = p1; + src[x+0*stride] = p2; + + ad1= ABS(d1); + + d2= clip((p0-p3)/4, -ad1, ad1); + + src[x-2*stride] = p0 - d2; + src[x+ stride] = p3 + d2; + } +} + +static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){ + int y; + const int strength= ff_h263_loop_filter_strength[qscale]; + + for(y=0; y<8; y++){ + int d1, d2, ad1; + int p0= src[y*stride-2]; + int p1= src[y*stride-1]; + int p2= src[y*stride+0]; + int p3= src[y*stride+1]; + int d = (p0 - p3 + 4*(p2 - p1)) / 8; + + if (d<-2*strength) d1= 0; + else if(d<- strength) d1=-2*strength - d; + else if(d< strength) d1= d; + else if(d< 2*strength) d1= 2*strength - d; + else d1= 0; + + p1 += d1; + p2 -= d1; + if(p1&256) p1= ~(p1>>31); + if(p2&256) p2= ~(p2>>31); + + src[y*stride-1] = p1; + src[y*stride+0] = p2; + + ad1= ABS(d1)>>1; + + d2= clip((p0-p3)/4, -ad1, ad1); + + src[y*stride-2] = p0 - d2; + src[y*stride+1] = p3 + d2; + } +} static inline int pix_abs16x16_c(uint8_t *pix1, uint8_t *pix2, int line_size) { @@ -3048,6 +3117,9 @@ c->diff_bytes= diff_bytes_c; c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c; c->bswap_buf= bswap_buf; + + c->h263_h_loop_filter= h263_h_loop_filter_c; + c->h263_v_loop_filter= h263_v_loop_filter_c; #ifdef HAVE_MMX dsputil_init_mmx(c, avctx);