From 263abc67c9c37d8cfddcb5bc9e9ddf768366429b Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Thu, 20 Mar 2008 22:08:07 -0600 Subject: [PATCH] simplify hpel_filter_c --- common/mc.c | 93 +++++++++++------------------------------------------ 1 file changed, 18 insertions(+), 75 deletions(-) diff --git a/common/mc.c b/common/mc.c index f7532041..d8d60648 100644 --- a/common/mc.c +++ b/common/mc.c @@ -31,15 +31,6 @@ #endif -static inline int x264_tapfilter( uint8_t *pix, int i_pix_next ) -{ - return pix[-2*i_pix_next] - 5*pix[-1*i_pix_next] + 20*(pix[0] + pix[1*i_pix_next]) - 5*pix[ 2*i_pix_next] + pix[ 3*i_pix_next]; -} -static inline int x264_tapfilter1( uint8_t *pix ) -{ - return pix[-2] - 5*pix[-1] + 20*(pix[0] + pix[1]) - 5*pix[ 2] + pix[ 3]; -} - static inline void pixel_avg( uint8_t *dst, int i_dst_stride, uint8_t *src1, int i_src1_stride, uint8_t *src2, int i_src2_stride, @@ -140,8 +131,6 @@ PIXEL_AVG_WEIGHT_C(2,2) #undef op_scale2 #undef PIXEL_AVG_WEIGHT_C -typedef void (*pf_mc_t)(uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_width, int i_height ); - static void mc_copy( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_width, int i_height ) { int y; @@ -154,77 +143,31 @@ static void mc_copy( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_str dst += i_dst_stride; } } -static inline void mc_hh( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_width, int i_height ) -{ - int x, y; - - for( y = 0; y < i_height; y++ ) - { - for( x = 0; x < i_width; x++ ) - { - dst[x] = x264_clip_uint8( ( x264_tapfilter1( &src[x] ) + 16 ) >> 5 ); - } - src += i_src_stride; - dst += i_dst_stride; - } -} -static inline void mc_hv( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_width, int i_height ) -{ - int x, y; - for( y = 0; y < i_height; y++ ) - { - for( x = 0; x < i_width; x++ ) - { - dst[x] = x264_clip_uint8( ( x264_tapfilter( &src[x], i_src_stride ) + 16 ) >> 5 ); - } - src += i_src_stride; - dst += i_dst_stride; - } -} -static inline void mc_hc( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_width, int i_height ) +#define TAPFILTER(pix, d) ((pix)[x-2*d] + (pix)[x+3*d] - 5*((pix)[x-d] + (pix)[x+2*d]) + 20*((pix)[x] + (pix)[x+d])) +static void hpel_filter( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, uint8_t *src, + int stride, int width, int height ) { - uint8_t *out; - uint8_t *pix; + int16_t *buf = x264_malloc((width+5)*sizeof(int16_t)); int x, y; - - for( x = 0; x < i_width; x++ ) + for( y=0; y> 10 ); - - /* Next line */ - pix += i_src_stride; - out += i_dst_stride; - tap[0] = tap[1]; - tap[1] = tap[2]; - tap[2] = tap[3]; - tap[3] = tap[4]; - tap[4] = tap[5]; + int v = TAPFILTER(src,stride); + dstv[x] = x264_clip_uint8((v + 16) >> 5); + buf[x+2] = v; } + for( x=0; x> 10); + for( x=0; x> 5); + dsth += stride; + dstv += stride; + dstc += stride; + src += stride; } -} - -static void hpel_filter( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, uint8_t *src, - int stride, int width, int height ) -{ - mc_hh( src, stride, dsth, stride, width, height ); - mc_hv( src, stride, dstv, stride, width, height ); - mc_hc( src, stride, dstc, stride, width, height ); + x264_free(buf); } static const int hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1}; -- GitLab