From 1cab251509f48fd605616c0c2d1c769552abbc71 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Mon, 19 Nov 2007 17:10:57 +0000 Subject: [PATCH] cosmetics: reorder mc_luma/mc_chroma/get_ref arguments for consistency with other functions git-svn-id: svn://svn.videolan.org/x264/trunk@694 df754926-b1dd-0310-bc7b-ec298dee348c --- common/amd64/mc-a.asm | 48 +++++++++++++++++-------------------- common/i386/mc-a.asm | 20 ++++++++-------- common/i386/mc-c.c | 8 +++---- common/macroblock.c | 56 +++++++++++++++++++++---------------------- common/mc.c | 18 +++++++------- common/mc.h | 6 ++--- common/ppc/mc.c | 24 +++++++++---------- encoder/analyse.c | 50 +++++++++++++++++++------------------- encoder/macroblock.c | 20 ++++++++-------- encoder/me.c | 20 ++++++++-------- encoder/slicetype.c | 4 ++-- tools/checkasm.c | 38 +++++++++++++++++++++-------- 12 files changed, 164 insertions(+), 148 deletions(-) diff --git a/common/amd64/mc-a.asm b/common/amd64/mc-a.asm index cafce508..bd533291 100644 --- a/common/amd64/mc-a.asm +++ b/common/amd64/mc-a.asm @@ -421,8 +421,8 @@ ALIGN 4 ;============================================================================= ;----------------------------------------------------------------------------- -; void x264_mc_chroma_mmxext( uint8_t *src, int i_src_stride, -; uint8_t *dst, int i_dst_stride, +; void x264_mc_chroma_mmxext( uint8_t *dst, int i_dst_stride, +; uint8_t *src, int i_src_stride, ; int dx, int dy, ; int i_width, int i_height ) ;----------------------------------------------------------------------------- @@ -431,12 +431,12 @@ cglobal x264_mc_chroma_mmxext mov r11d, parm5d sar r10d, 3 sar r11d, 3 - imul r10d, parm2d + imul r10d, parm4d pxor mm3, mm3 add r10d, r11d movsxd r10, r10d mov r11d, parm8d - add parm1q, r10 ; src += (dx>>3) + (dy>>3) * src_stride + add parm3q, r10 ; src += (dx>>3) + (dy>>3) * src_stride and parm5d, 7 ; dx &= 7 je .mc1d and parm6d, 7 ; dy &= 7 @@ -460,13 +460,13 @@ cglobal x264_mc_chroma_mmxext pmullw mm6, mm4 ; mm6 = (8-dx)*dy = cC pmullw mm4, mm0 ; mm4 = (8-dx)*(8-dy) = cA - mov rax, parm1q - mov r10, parm3q + mov rax, parm3q + mov r10, parm1q ALIGN 4 .height_loop - movd mm1, [rax+parm2q] + movd mm1, [rax+parm4q] movd mm0, [rax] punpcklbw mm1, mm3 ; 00 px1 | 00 px2 | 00 px3 | 00 px4 punpcklbw mm0, mm3 @@ -476,7 +476,7 @@ ALIGN 4 paddw mm0, mm1 ; mm0 <- result movd mm2, [rax+1] - movd mm1, [rax+parm2q+1] + movd mm1, [rax+parm4q+1] punpcklbw mm2, mm3 punpcklbw mm1, mm3 @@ -491,16 +491,16 @@ ALIGN 4 packuswb mm0, mm3 ; 00 00 00 00 px1 px2 px3 px4 movd [r10], mm0 - add rax, parm2q - add r10, parm4q ; i_dst_stride + add rax, parm4q + add r10, parm2q ; i_dst_stride dec r11d jnz .height_loop sub parm7d, 8 jnz .finish ; width != 8 so assume 4 - mov r10, parm3q ; dst - mov rax, parm1q ; src + mov r10, parm1q ; dst + mov rax, parm3q ; src mov r11d, parm8d ; i_height add r10, 4 add rax, 4 @@ -511,17 +511,13 @@ ALIGN 4 ALIGN 4 .mc1d -%ifdef WIN64 -%define pel_offset rsi -%else -%define pel_offset r9 -%endif +%define pel_offset temp1q mov eax, parm5d or eax, parm6d and eax, 7 cmp parm5d, 0 mov pel_offset, 1 - cmove pel_offset, parm2q ; pel_offset = dx ? 1 : src_stride + cmove pel_offset, parm4q ; pel_offset = dx ? 1 : src_stride movd mm6, eax movq mm5, [pw_8 GLOBAL] pshufw mm6, mm6, 0 @@ -533,8 +529,8 @@ ALIGN 4 ALIGN 4 .height_loop1_w4 - movd mm0, [parm1q+pel_offset] - movd mm1, [parm1q] + movd mm0, [parm3q+pel_offset] + movd mm1, [parm3q] punpcklbw mm0, mm3 punpcklbw mm1, mm3 pmullw mm0, mm6 @@ -543,17 +539,17 @@ ALIGN 4 paddw mm0, mm1 psrlw mm0, 3 packuswb mm0, mm3 - movd [parm3q], mm0 - add parm1q, parm2q + movd [parm1q], mm0 add parm3q, parm4q + add parm1q, parm2q dec r11d jnz .height_loop1_w4 rep ret ALIGN 4 .height_loop1_w8 - movq mm0, [parm1q+pel_offset] - movq mm1, [parm1q] + movq mm0, [parm3q+pel_offset] + movq mm1, [parm3q] movq mm2, mm0 movq mm4, mm1 punpcklbw mm0, mm3 @@ -571,9 +567,9 @@ ALIGN 4 psrlw mm0, 3 psrlw mm2, 3 packuswb mm0, mm2 - movq [parm3q], mm0 - add parm1q, parm2q + movq [parm1q], mm0 add parm3q, parm4q + add parm1q, parm2q dec r11d jnz .height_loop1_w8 rep ret diff --git a/common/i386/mc-a.asm b/common/i386/mc-a.asm index 71910739..991b0966 100644 --- a/common/i386/mc-a.asm +++ b/common/i386/mc-a.asm @@ -484,8 +484,8 @@ ALIGN 4 ;============================================================================= ;----------------------------------------------------------------------------- -; void x264_mc_chroma_mmxext( uint8_t *src, int i_src_stride, -; uint8_t *dst, int i_dst_stride, +; void x264_mc_chroma_mmxext( uint8_t *dst, int i_dst_stride, +; uint8_t *src, int i_src_stride, ; int dx, int dy, ; int i_width, int i_height ) ;----------------------------------------------------------------------------- @@ -501,9 +501,9 @@ cglobal x264_mc_chroma_mmxext mov edi, edx sar ecx, 3 sar edx, 3 - imul ecx, [picesp+4+8] + imul ecx, [picesp+4+16] add ecx, edx - add [picesp+4+4], ecx ; src += (dx>>3) + (dy>>3) * src_stride + add [picesp+4+12], ecx ; src += (dx>>3) + (dy>>3) * src_stride pxor mm3, mm3 @@ -526,9 +526,9 @@ cglobal x264_mc_chroma_mmxext pmullw mm6, mm4 ; mm6 = (8-dx)*dy = cC pmullw mm4, mm0 ; mm4 = (8-dx)*(8-dy) = cA - mov eax, [picesp+4+4] ; src - mov edi, [picesp+4+12] ; dst - mov ecx, [picesp+4+8] ; i_src_stride + mov eax, [picesp+4+12] ; src + mov edi, [picesp+4+4] ; dst + mov ecx, [picesp+4+16] ; i_src_stride mov edx, [picesp+4+32] ; i_height ALIGN 4 @@ -560,7 +560,7 @@ ALIGN 4 movd [edi], mm0 add eax, ecx - add edi, [picesp+4+16] + add edi, [picesp+4+8] dec edx jnz .height_loop @@ -568,8 +568,8 @@ ALIGN 4 sub [picesp+4+28], dword 8 jnz .finish ; width != 8 so assume 4 - mov edi, [picesp+4+12] ; dst - mov eax, [picesp+4+4] ; src + mov edi, [picesp+4+4] ; dst + mov eax, [picesp+4+12] ; src mov edx, [picesp+4+32] ; i_height add edi, 4 add eax, 4 diff --git a/common/i386/mc-c.c b/common/i386/mc-c.c index e60c15f3..8ac3bf66 100644 --- a/common/i386/mc-c.c +++ b/common/i386/mc-c.c @@ -84,8 +84,8 @@ static void (* const x264_mc_copy_wtab_mmx[5])( uint8_t *, int, uint8_t *, int, static const int hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1}; static const int hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; -void mc_luma_mmx( uint8_t *src[4], int i_src_stride, - uint8_t *dst, int i_dst_stride, +void mc_luma_mmx( uint8_t *dst, int i_dst_stride, + uint8_t *src[4], int i_src_stride, int mvx, int mvy, int i_width, int i_height ) { @@ -107,8 +107,8 @@ void mc_luma_mmx( uint8_t *src[4], int i_src_stride, } } -uint8_t *get_ref_mmx( uint8_t *src[4], int i_src_stride, - uint8_t *dst, int *i_dst_stride, +uint8_t *get_ref_mmx( uint8_t *dst, int *i_dst_stride, + uint8_t *src[4], int i_src_stride, int mvx, int mvy, int i_width, int i_height ) { diff --git a/common/macroblock.c b/common/macroblock.c index 6bd2c83b..86c82dbb 100644 --- a/common/macroblock.c +++ b/common/macroblock.c @@ -589,21 +589,21 @@ static inline void x264_mb_mc_0xywh( x264_t *h, int x, int y, int width, int hei const int mvx = x264_clip3( h->mb.cache.mv[0][i8][0], h->mb.mv_min[0], h->mb.mv_max[0] ); int mvy = x264_clip3( h->mb.cache.mv[0][i8][1], h->mb.mv_min[1], h->mb.mv_max[1] ); - h->mc.mc_luma( h->mb.pic.p_fref[0][i_ref], h->mb.pic.i_stride[0], - &h->mb.pic.p_fdec[0][4*y*FDEC_STRIDE+4*x], FDEC_STRIDE, - mvx + 4*4*x, mvy + 4*4*y, 4*width, 4*height ); + h->mc.mc_luma( &h->mb.pic.p_fdec[0][4*y*FDEC_STRIDE+4*x], FDEC_STRIDE, + h->mb.pic.p_fref[0][i_ref], h->mb.pic.i_stride[0], + mvx + 4*4*x, mvy + 4*4*y, 4*width, 4*height ); // chroma is offset if MCing from a field of opposite parity if( h->mb.b_interlaced & i_ref ) mvy += (h->mb.i_mb_y & 1)*4 - 2; - h->mc.mc_chroma( &h->mb.pic.p_fref[0][i_ref][4][2*y*h->mb.pic.i_stride[1]+2*x], h->mb.pic.i_stride[1], - &h->mb.pic.p_fdec[1][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, - mvx, mvy, 2*width, 2*height ); + h->mc.mc_chroma( &h->mb.pic.p_fdec[1][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, + &h->mb.pic.p_fref[0][i_ref][4][2*y*h->mb.pic.i_stride[1]+2*x], h->mb.pic.i_stride[1], + mvx, mvy, 2*width, 2*height ); - h->mc.mc_chroma( &h->mb.pic.p_fref[0][i_ref][5][2*y*h->mb.pic.i_stride[2]+2*x], h->mb.pic.i_stride[2], - &h->mb.pic.p_fdec[2][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, - mvx, mvy, 2*width, 2*height ); + h->mc.mc_chroma( &h->mb.pic.p_fdec[2][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, + &h->mb.pic.p_fref[0][i_ref][5][2*y*h->mb.pic.i_stride[2]+2*x], h->mb.pic.i_stride[2], + mvx, mvy, 2*width, 2*height ); } static inline void x264_mb_mc_1xywh( x264_t *h, int x, int y, int width, int height ) { @@ -612,20 +612,20 @@ static inline void x264_mb_mc_1xywh( x264_t *h, int x, int y, int width, int hei const int mvx = x264_clip3( h->mb.cache.mv[1][i8][0], h->mb.mv_min[0], h->mb.mv_max[0] ); int mvy = x264_clip3( h->mb.cache.mv[1][i8][1], h->mb.mv_min[1], h->mb.mv_max[1] ); - h->mc.mc_luma( h->mb.pic.p_fref[1][i_ref], h->mb.pic.i_stride[0], - &h->mb.pic.p_fdec[0][4*y*FDEC_STRIDE+4*x], FDEC_STRIDE, - mvx + 4*4*x, mvy + 4*4*y, 4*width, 4*height ); + h->mc.mc_luma( &h->mb.pic.p_fdec[0][4*y*FDEC_STRIDE+4*x], FDEC_STRIDE, + h->mb.pic.p_fref[1][i_ref], h->mb.pic.i_stride[0], + mvx + 4*4*x, mvy + 4*4*y, 4*width, 4*height ); if( h->mb.b_interlaced & i_ref ) mvy += (h->mb.i_mb_y & 1)*4 - 2; - h->mc.mc_chroma( &h->mb.pic.p_fref[1][i_ref][4][2*y*h->mb.pic.i_stride[1]+2*x], h->mb.pic.i_stride[1], - &h->mb.pic.p_fdec[1][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, - mvx, mvy, 2*width, 2*height ); + h->mc.mc_chroma( &h->mb.pic.p_fdec[1][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, + &h->mb.pic.p_fref[1][i_ref][4][2*y*h->mb.pic.i_stride[1]+2*x], h->mb.pic.i_stride[1], + mvx, mvy, 2*width, 2*height ); - h->mc.mc_chroma( &h->mb.pic.p_fref[1][i_ref][5][2*y*h->mb.pic.i_stride[2]+2*x], h->mb.pic.i_stride[2], - &h->mb.pic.p_fdec[2][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, - mvx, mvy, 2*width, 2*height ); + h->mc.mc_chroma( &h->mb.pic.p_fdec[2][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, + &h->mb.pic.p_fref[1][i_ref][5][2*y*h->mb.pic.i_stride[2]+2*x], h->mb.pic.i_stride[2], + mvx, mvy, 2*width, 2*height ); } static inline void x264_mb_mc_01xywh( x264_t *h, int x, int y, int width, int height ) @@ -640,8 +640,8 @@ static inline void x264_mb_mc_01xywh( x264_t *h, int x, int y, int width, int he x264_mb_mc_0xywh( h, x, y, width, height ); - h->mc.mc_luma( h->mb.pic.p_fref[1][i_ref1], h->mb.pic.i_stride[0], - tmp, 16, mvx1 + 4*4*x, mvy1 + 4*4*y, 4*width, 4*height ); + h->mc.mc_luma( tmp, 16, h->mb.pic.p_fref[1][i_ref1], h->mb.pic.i_stride[0], + mvx1 + 4*4*x, mvy1 + 4*4*y, 4*width, 4*height ); if( h->mb.b_interlaced & i_ref1 ) mvy1 += (h->mb.i_mb_y & 1)*4 - 2; @@ -653,24 +653,24 @@ static inline void x264_mb_mc_01xywh( x264_t *h, int x, int y, int width, int he h->mc.avg_weight[i_mode]( &h->mb.pic.p_fdec[0][4*y*FDEC_STRIDE+4*x], FDEC_STRIDE, tmp, 16, weight ); - h->mc.mc_chroma( &h->mb.pic.p_fref[1][i_ref1][4][2*y*h->mb.pic.i_stride[1]+2*x], h->mb.pic.i_stride[1], - tmp, 16, mvx1, mvy1, 2*width, 2*height ); + h->mc.mc_chroma( tmp, 16, &h->mb.pic.p_fref[1][i_ref1][4][2*y*h->mb.pic.i_stride[1]+2*x], h->mb.pic.i_stride[1], + mvx1, mvy1, 2*width, 2*height ); h->mc.avg_weight[i_mode+3]( &h->mb.pic.p_fdec[1][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, tmp, 16, weight ); - h->mc.mc_chroma( &h->mb.pic.p_fref[1][i_ref1][5][2*y*h->mb.pic.i_stride[2]+2*x], h->mb.pic.i_stride[2], - tmp, 16, mvx1, mvy1, 2*width, 2*height ); + h->mc.mc_chroma( tmp, 16, &h->mb.pic.p_fref[1][i_ref1][5][2*y*h->mb.pic.i_stride[2]+2*x], h->mb.pic.i_stride[2], + mvx1, mvy1, 2*width, 2*height ); h->mc.avg_weight[i_mode+3]( &h->mb.pic.p_fdec[2][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, tmp, 16, weight ); } else { h->mc.avg[i_mode]( &h->mb.pic.p_fdec[0][4*y*FDEC_STRIDE+4*x], FDEC_STRIDE, tmp, 16 ); - h->mc.mc_chroma( &h->mb.pic.p_fref[1][i_ref1][4][2*y*h->mb.pic.i_stride[1]+2*x], h->mb.pic.i_stride[1], - tmp, 16, mvx1, mvy1, 2*width, 2*height ); + h->mc.mc_chroma( tmp, 16, &h->mb.pic.p_fref[1][i_ref1][4][2*y*h->mb.pic.i_stride[1]+2*x], h->mb.pic.i_stride[1], + mvx1, mvy1, 2*width, 2*height ); h->mc.avg[i_mode+3]( &h->mb.pic.p_fdec[1][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, tmp, 16 ); - h->mc.mc_chroma( &h->mb.pic.p_fref[1][i_ref1][5][2*y*h->mb.pic.i_stride[2]+2*x], h->mb.pic.i_stride[2], - tmp, 16, mvx1, mvy1, 2*width, 2*height ); + h->mc.mc_chroma( tmp, 16, &h->mb.pic.p_fref[1][i_ref1][5][2*y*h->mb.pic.i_stride[2]+2*x], h->mb.pic.i_stride[2], + mvx1, mvy1, 2*width, 2*height ); h->mc.avg[i_mode+3]( &h->mb.pic.p_fdec[2][2*y*FDEC_STRIDE+2*x], FDEC_STRIDE, tmp, 16 ); } } diff --git a/common/mc.c b/common/mc.c index a88e8845..00547adb 100644 --- a/common/mc.c +++ b/common/mc.c @@ -231,8 +231,8 @@ static void hpel_filter( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, uint8_t *s static const int hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1}; static const int hpel_ref1[16] = {0,0,0,0,2,2,3,2,2,2,3,2,2,2,3,2}; -static void mc_luma( uint8_t *src[4], int i_src_stride, - uint8_t *dst, int i_dst_stride, +static void mc_luma( uint8_t *dst, int i_dst_stride, + uint8_t *src[4], int i_src_stride, int mvx, int mvy, int i_width, int i_height ) { @@ -252,8 +252,8 @@ static void mc_luma( uint8_t *src[4], int i_src_stride, } } -static uint8_t *get_ref( uint8_t *src[4], int i_src_stride, - uint8_t *dst, int *i_dst_stride, +static uint8_t *get_ref( uint8_t *dst, int *i_dst_stride, + uint8_t *src[4], int i_src_stride, int mvx, int mvy, int i_width, int i_height ) { @@ -276,10 +276,10 @@ static uint8_t *get_ref( uint8_t *src[4], int i_src_stride, } /* full chroma mc (ie until 1/8 pixel)*/ -static void motion_compensation_chroma( uint8_t *src, int i_src_stride, - uint8_t *dst, int i_dst_stride, - int mvx, int mvy, - int i_width, int i_height ) +static void mc_chroma( uint8_t *dst, int i_dst_stride, + uint8_t *src, int i_src_stride, + int mvx, int mvy, + int i_width, int i_height ) { uint8_t *srcp; int x, y; @@ -340,7 +340,7 @@ void x264_mc_init( int cpu, x264_mc_functions_t *pf ) { pf->mc_luma = mc_luma; pf->get_ref = get_ref; - pf->mc_chroma = motion_compensation_chroma; + pf->mc_chroma = mc_chroma; pf->avg[PIXEL_16x16]= pixel_avg_16x16; pf->avg[PIXEL_16x8] = pixel_avg_16x8; diff --git a/common/mc.h b/common/mc.h index 80db9d42..1a2f64f9 100644 --- a/common/mc.h +++ b/common/mc.h @@ -33,18 +33,18 @@ typedef struct { - void (*mc_luma)(uint8_t **, int, uint8_t *, int, + void (*mc_luma)(uint8_t *dst, int i_dst, uint8_t **src, int i_src, int mvx, int mvy, int i_width, int i_height ); /* may round up the dimensions if they're not a power of 2 */ - uint8_t* (*get_ref)(uint8_t **, int, uint8_t *, int *, + uint8_t* (*get_ref)(uint8_t *dst, int *i_dst, uint8_t **src, int i_src, int mvx, int mvy, int i_width, int i_height ); /* mc_chroma may write up to 2 bytes of garbage to the right of dst, * so it must be run from left to right. */ - void (*mc_chroma)(uint8_t *, int, uint8_t *, int, + void (*mc_chroma)(uint8_t *dst, int i_dst, uint8_t *src, int i_src, int mvx, int mvy, int i_width, int i_height ); diff --git a/common/ppc/mc.c b/common/ppc/mc.c index bd6c514a..bd524c27 100644 --- a/common/ppc/mc.c +++ b/common/ppc/mc.c @@ -132,8 +132,8 @@ MC_COPY( mc_copy_w4, 4 ) MC_COPY( mc_copy_w8, 8 ) MC_COPY( mc_copy_w16, 16 ) -void mc_luma_altivec( uint8_t *src[4], int i_src_stride, - uint8_t *dst, int i_dst_stride, +void mc_luma_altivec( uint8_t *dst, int i_dst_stride, + uint8_t *src[4], int i_src_stride, int mvx, int mvy, int i_width, int i_height ) { @@ -190,8 +190,8 @@ void mc_luma_altivec( uint8_t *src[4], int i_src_stride, } } -uint8_t *get_ref_altivec( uint8_t *src[4], int i_src_stride, - uint8_t *dst, int * i_dst_stride, +uint8_t *get_ref_altivec( uint8_t *dst, int * i_dst_stride, + uint8_t *src[4], int i_src_stride, int mvx, int mvy, int i_width, int i_height ) { @@ -253,8 +253,8 @@ uint8_t *get_ref_altivec( uint8_t *src[4], int i_src_stride, src##a##v_16 = vec_mladd( coeff##a##v, src##a##v_16, zero_u16v ); \ dstv_16 = vec_add( dstv_16, src##a##v_16 ) -static void mc_chroma_altivec_4xh( uint8_t *src, int i_src_stride, - uint8_t *dst, int i_dst_stride, +static void mc_chroma_altivec_4xh( uint8_t *dst, int i_dst_stride, + uint8_t *src, int i_src_stride, int mvx, int mvy, int i_height ) { @@ -319,8 +319,8 @@ static void mc_chroma_altivec_4xh( uint8_t *src, int i_src_stride, } } -static void mc_chroma_altivec_8xh( uint8_t *src, int i_src_stride, - uint8_t *dst, int i_dst_stride, +static void mc_chroma_altivec_8xh( uint8_t *dst, int i_dst_stride, + uint8_t *src, int i_src_stride, int mvx, int mvy, int i_height ) { @@ -385,19 +385,19 @@ static void mc_chroma_altivec_8xh( uint8_t *src, int i_src_stride, } } -static void mc_chroma_altivec( uint8_t *src, int i_src_stride, - uint8_t *dst, int i_dst_stride, +static void mc_chroma_altivec( uint8_t *dst, int i_dst_stride, + uint8_t *src, int i_src_stride, int mvx, int mvy, int i_width, int i_height ) { if( i_width == 8 ) { - mc_chroma_altivec_8xh( src, i_src_stride, dst, i_dst_stride, + mc_chroma_altivec_8xh( dst, i_dst_stride, src, i_src_stride, mvx, mvy, i_height ); } else { - mc_chroma_altivec_4xh( src, i_src_stride, dst, i_dst_stride, + mc_chroma_altivec_4xh( dst, i_dst_stride, src, i_src_stride, mvx, mvy, i_height ); } } diff --git a/encoder/analyse.c b/encoder/analyse.c index 1e1db9ea..c403d415 100644 --- a/encoder/analyse.c +++ b/encoder/analyse.c @@ -1236,8 +1236,8 @@ static int x264_mb_analyse_inter_p4x4_chroma( x264_t *h, x264_mb_analysis_t *a, const int oe = 4*(i8x8&1) + 2*(i8x8&2)*FENC_STRIDE; #define CHROMA4x4MC( width, height, me, x, y ) \ - h->mc.mc_chroma( &p_fref[4][or+x+y*i_stride], i_stride, &pix1[x+y*16], 16, (me).mv[0], (me).mv[1], width, height ); \ - h->mc.mc_chroma( &p_fref[5][or+x+y*i_stride], i_stride, &pix2[x+y*16], 16, (me).mv[0], (me).mv[1], width, height ); + h->mc.mc_chroma( &pix1[x+y*16], 16, &p_fref[4][or+x+y*i_stride], i_stride, (me).mv[0], (me).mv[1], width, height ); \ + h->mc.mc_chroma( &pix2[x+y*16], 16, &p_fref[5][or+x+y*i_stride], i_stride, (me).mv[0], (me).mv[1], width, height ); if( pixel == PIXEL_4x4 ) { @@ -1488,27 +1488,29 @@ static void x264_mb_analyse_inter_b16x16( x264_t *h, x264_mb_analysis_t *a ) if ( ((a->l0.me16x16.mv[0] | a->l0.me16x16.mv[1]) & 1) == 0 ) { /* l0 reference is halfpel, so get_ref on it will make it faster */ - src2 = h->mc.get_ref( h->mb.pic.p_fref[0][a->l0.i_ref], h->mb.pic.i_stride[0], - pix2, &stride2, - a->l0.me16x16.mv[0], a->l0.me16x16.mv[1], - 16, 16 ); - h->mc.mc_luma( h->mb.pic.p_fref[1][a->l1.i_ref], h->mb.pic.i_stride[0], - pix1, 16, - a->l1.me16x16.mv[0], a->l1.me16x16.mv[1], - 16, 16 ); + src2 = + h->mc.get_ref( pix2, &stride2, + h->mb.pic.p_fref[0][a->l0.i_ref], h->mb.pic.i_stride[0], + a->l0.me16x16.mv[0], a->l0.me16x16.mv[1], + 16, 16 ); + h->mc.mc_luma( pix1, 16, + h->mb.pic.p_fref[1][a->l1.i_ref], h->mb.pic.i_stride[0], + a->l1.me16x16.mv[0], a->l1.me16x16.mv[1], + 16, 16 ); weight = 64 - weight; } else { /* if l0 was qpel, we'll use get_ref on l1 instead */ - h->mc.mc_luma( h->mb.pic.p_fref[0][a->l0.i_ref], h->mb.pic.i_stride[0], - pix1, 16, - a->l0.me16x16.mv[0], a->l0.me16x16.mv[1], - 16, 16 ); - src2 = h->mc.get_ref( h->mb.pic.p_fref[1][a->l1.i_ref], h->mb.pic.i_stride[0], - pix2, &stride2, - a->l1.me16x16.mv[0], a->l1.me16x16.mv[1], - 16, 16 ); + h->mc.mc_luma( pix1, 16, + h->mb.pic.p_fref[0][a->l0.i_ref], h->mb.pic.i_stride[0], + a->l0.me16x16.mv[0], a->l0.me16x16.mv[1], + 16, 16 ); + src2 = + h->mc.get_ref( pix2, &stride2, + h->mb.pic.p_fref[1][a->l1.i_ref], h->mb.pic.i_stride[0], + a->l1.me16x16.mv[0], a->l1.me16x16.mv[1], + 16, 16 ); } if( h->param.analyse.b_weighted_bipred ) @@ -1650,8 +1652,8 @@ static void x264_mb_analyse_inter_b8x8( x264_t *h, x264_mb_analysis_t *a ) x264_macroblock_cache_mv( h, 2*x8, 2*y8, 2, 2, l, m->mv[0], m->mv[1] ); /* BI mode */ - h->mc.mc_luma( m->p_fref, m->i_stride[0], pix[l], 8, - m->mv[0], m->mv[1], 8, 8 ); + h->mc.mc_luma( pix[l], 8, m->p_fref, m->i_stride[0], + m->mv[0], m->mv[1], 8, 8 ); i_part_cost_bi += m->cost_mv; /* FIXME: ref cost */ } @@ -1715,8 +1717,8 @@ static void x264_mb_analyse_inter_b16x8( x264_t *h, x264_mb_analysis_t *a ) x264_me_search( h, m, mvc, 2 ); /* BI mode */ - h->mc.mc_luma( m->p_fref, m->i_stride[0], pix[l], 16, - m->mv[0], m->mv[1], 16, 8 ); + h->mc.mc_luma( pix[l], 16, m->p_fref, m->i_stride[0], + m->mv[0], m->mv[1], 16, 8 ); /* FIXME: ref cost */ i_part_cost_bi += m->cost_mv; } @@ -1785,8 +1787,8 @@ static void x264_mb_analyse_inter_b8x16( x264_t *h, x264_mb_analysis_t *a ) x264_me_search( h, m, mvc, 2 ); /* BI mode */ - h->mc.mc_luma( m->p_fref, m->i_stride[0], pix[l], 8, - m->mv[0], m->mv[1], 8, 16 ); + h->mc.mc_luma( pix[l], 8, m->p_fref, m->i_stride[0], + m->mv[0], m->mv[1], 8, 16 ); /* FIXME: ref cost */ i_part_cost_bi += m->cost_mv; } diff --git a/encoder/macroblock.c b/encoder/macroblock.c index c0967fe0..9a96181f 100644 --- a/encoder/macroblock.c +++ b/encoder/macroblock.c @@ -296,17 +296,17 @@ void x264_macroblock_encode_pskip( x264_t *h ) h->mb.mv_min[1], h->mb.mv_max[1] ); /* Motion compensation XXX probably unneeded */ - h->mc.mc_luma( h->mb.pic.p_fref[0][0], h->mb.pic.i_stride[0], - h->mb.pic.p_fdec[0], FDEC_STRIDE, + h->mc.mc_luma( h->mb.pic.p_fdec[0], FDEC_STRIDE, + h->mb.pic.p_fref[0][0], h->mb.pic.i_stride[0], mvx, mvy, 16, 16 ); /* Chroma MC */ - h->mc.mc_chroma( h->mb.pic.p_fref[0][0][4], h->mb.pic.i_stride[1], - h->mb.pic.p_fdec[1], FDEC_STRIDE, + h->mc.mc_chroma( h->mb.pic.p_fdec[1], FDEC_STRIDE, + h->mb.pic.p_fref[0][0][4], h->mb.pic.i_stride[1], mvx, mvy, 8, 8 ); - h->mc.mc_chroma( h->mb.pic.p_fref[0][0][5], h->mb.pic.i_stride[2], - h->mb.pic.p_fdec[2], FDEC_STRIDE, + h->mc.mc_chroma( h->mb.pic.p_fdec[2], FDEC_STRIDE, + h->mb.pic.p_fref[0][0][5], h->mb.pic.i_stride[2], mvx, mvy, 8, 8 ); x264_macroblock_encode_skip( h ); @@ -618,8 +618,8 @@ int x264_macroblock_probe_skip( x264_t *h, const int b_bidir ) mvp[1] = x264_clip3( h->mb.cache.pskip_mv[1], h->mb.mv_min[1], h->mb.mv_max[1] ); /* Motion compensation */ - h->mc.mc_luma( h->mb.pic.p_fref[0][0], h->mb.pic.i_stride[0], - h->mb.pic.p_fdec[0], FDEC_STRIDE, + h->mc.mc_luma( h->mb.pic.p_fdec[0], FDEC_STRIDE, + h->mb.pic.p_fref[0][0], h->mb.pic.i_stride[0], mvp[0], mvp[1], 16, 16 ); } @@ -657,8 +657,8 @@ int x264_macroblock_probe_skip( x264_t *h, const int b_bidir ) if( !b_bidir ) { - h->mc.mc_chroma( h->mb.pic.p_fref[0][0][4+ch], h->mb.pic.i_stride[1+ch], - h->mb.pic.p_fdec[1+ch], FDEC_STRIDE, + h->mc.mc_chroma( h->mb.pic.p_fdec[1+ch], FDEC_STRIDE, + h->mb.pic.p_fref[0][0][4+ch], h->mb.pic.i_stride[1+ch], mvp[0], mvp[1], 8, 8 ); } diff --git a/encoder/me.c b/encoder/me.c index 374cf812..9adcc6cb 100644 --- a/encoder/me.c +++ b/encoder/me.c @@ -63,7 +63,7 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite #define COST_MV_HPEL( mx, my ) \ { \ int stride = 16; \ - uint8_t *src = h->mc.get_ref( m->p_fref, m->i_stride[0], pix, &stride, mx, my, bw, bh ); \ + uint8_t *src = h->mc.get_ref( pix, &stride, m->p_fref, m->i_stride[0], mx, my, bw, bh ); \ int cost = h->pixf.sad[i_pixel]( m->p_fenc[0], FENC_STRIDE, src, stride ) \ + p_cost_mvx[ mx ] + p_cost_mvy[ my ]; \ COPY3_IF_LT( bpred_cost, cost, bpred_mx, mx, bpred_my, my ); \ @@ -552,7 +552,7 @@ void x264_me_refine_qpel( x264_t *h, x264_me_t *m ) #define COST_MV_SAD( mx, my ) \ { \ int stride = 16; \ - uint8_t *src = h->mc.get_ref( m->p_fref, m->i_stride[0], pix[0], &stride, mx, my, bw, bh ); \ + uint8_t *src = h->mc.get_ref( pix[0], &stride, m->p_fref, m->i_stride[0], mx, my, bw, bh ); \ int cost = h->pixf.sad[i_pixel]( m->p_fenc[0], FENC_STRIDE, src, stride ) \ + p_cost_mvx[ mx ] + p_cost_mvy[ my ]; \ COPY3_IF_LT( bcost, cost, bmx, mx, bmy, my ); \ @@ -562,16 +562,16 @@ void x264_me_refine_qpel( x264_t *h, x264_me_t *m ) if( b_refine_qpel || (dir^1) != odir ) \ { \ int stride = 16; \ - uint8_t *src = h->mc.get_ref( m->p_fref, m->i_stride[0], pix[0], &stride, mx, my, bw, bh ); \ + uint8_t *src = h->mc.get_ref( pix[0], &stride, m->p_fref, m->i_stride[0], mx, my, bw, bh ); \ int cost = h->pixf.mbcmp[i_pixel]( m->p_fenc[0], FENC_STRIDE, src, stride ) \ + p_cost_mvx[ mx ] + p_cost_mvy[ my ]; \ if( b_chroma_me && cost < bcost ) \ { \ - h->mc.mc_chroma( m->p_fref[4], m->i_stride[1], pix[0], 8, mx, my, bw/2, bh/2 ); \ + h->mc.mc_chroma( pix[0], 8, m->p_fref[4], m->i_stride[1], mx, my, bw/2, bh/2 ); \ cost += h->pixf.mbcmp[i_pixel+3]( m->p_fenc[1], FENC_STRIDE, pix[0], 8 ); \ if( cost < bcost ) \ { \ - h->mc.mc_chroma( m->p_fref[5], m->i_stride[1], pix[0], 8, mx, my, bw/2, bh/2 ); \ + h->mc.mc_chroma( pix[0], 8, m->p_fref[5], m->i_stride[1], mx, my, bw/2, bh/2 ); \ cost += h->pixf.mbcmp[i_pixel+3]( m->p_fenc[2], FENC_STRIDE, pix[0], 8 ); \ } \ } \ @@ -619,8 +619,8 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite int costs[4]; int stride = 32; // candidates are either all hpel or all qpel, so one stride is enough uint8_t *src0, *src1, *src2, *src3; - src0 = h->mc.get_ref( m->p_fref, m->i_stride[0], pix[0], &stride, omx, omy-2, bw, bh+1 ); - src2 = h->mc.get_ref( m->p_fref, m->i_stride[0], pix[1], &stride, omx-2, omy, bw+4, bh ); + src0 = h->mc.get_ref( pix[0], &stride, m->p_fref, m->i_stride[0], omx, omy-2, bw, bh+1 ); + src2 = h->mc.get_ref( pix[1], &stride, m->p_fref, m->i_stride[0], omx-2, omy, bw+4, bh ); src1 = src0 + stride; src3 = src2 + 1; h->pixf.sad_x4[i_pixel]( m->p_fenc[0], src0, src1, src2, src3, stride, costs ); @@ -688,8 +688,8 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite #define BIME_CACHE( dx, dy ) \ { \ int i = 4 + 3*dx + dy; \ - h->mc.mc_luma( m0->p_fref, m0->i_stride[0], pix0[i], bw, om0x+dx, om0y+dy, bw, bh ); \ - h->mc.mc_luma( m1->p_fref, m1->i_stride[0], pix1[i], bw, om1x+dx, om1y+dy, bw, bh ); \ + h->mc.mc_luma( pix0[i], bw, m0->p_fref, m0->i_stride[0], om0x+dx, om0y+dy, bw, bh ); \ + h->mc.mc_luma( pix1[i], bw, m1->p_fref, m1->i_stride[0], om1x+dx, om1y+dy, bw, bh ); \ } #define BIME_CACHE2(a,b) \ @@ -803,7 +803,7 @@ int x264_me_refine_bidir( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight #define COST_MV_SATD( mx, my, dst ) \ { \ int stride = 16; \ - uint8_t *src = h->mc.get_ref( m->p_fref, m->i_stride[0], pix, &stride, mx, my, bw*4, bh*4 ); \ + uint8_t *src = h->mc.get_ref( pix, &stride, m->p_fref, m->i_stride[0], mx, my, bw*4, bh*4 ); \ dst = h->pixf.mbcmp[i_pixel]( m->p_fenc[0], FENC_STRIDE, src, stride ) \ + p_cost_mvx[mx] + p_cost_mvy[my]; \ COPY1_IF_LT( bsatd, dst ); \ diff --git a/encoder/slicetype.c b/encoder/slicetype.c index bfe44e57..f3faa5da 100644 --- a/encoder/slicetype.c +++ b/encoder/slicetype.c @@ -107,9 +107,9 @@ int x264_slicetype_mb_cost( x264_t *h, x264_mb_analysis_t *a, int stride2 = 16; \ uint8_t *src2; \ int i_cost; \ - h->mc.mc_luma( m[0].p_fref, m[0].i_stride[0], pix1, 16, \ + h->mc.mc_luma( pix1, 16, m[0].p_fref, m[0].i_stride[0], \ (mv0)[0], (mv0)[1], 8, 8 ); \ - src2 = h->mc.get_ref( m[1].p_fref, m[1].i_stride[0], pix2, &stride2, \ + src2 = h->mc.get_ref( pix2, &stride2, m[1].p_fref, m[1].i_stride[0], \ (mv1)[0], (mv1)[1], 8, 8 ); \ h->mc.avg[PIXEL_8x8]( pix1, 16, src2, stride2 ); \ i_cost = penalty + h->pixf.mbcmp[PIXEL_8x8]( \ diff --git a/tools/checkasm.c b/tools/checkasm.c index 07c9210f..beddffc2 100644 --- a/tools/checkasm.c +++ b/tools/checkasm.c @@ -301,6 +301,7 @@ static int check_mc( int cpu_ref, int cpu_new ) x264_mc_functions_t mc_c; x264_mc_functions_t mc_ref; x264_mc_functions_t mc_a; + x264_pixel_function_t pixel; uint8_t *src = &buf1[2*32+2]; uint8_t *src2[4] = { &buf1[2*32+2], &buf1[7*32+2], @@ -314,6 +315,7 @@ static int check_mc( int cpu_ref, int cpu_new ) x264_mc_init( 0, &mc_c ); x264_mc_init( cpu_ref, &mc_ref ); x264_mc_init( cpu_new, &mc_a ); + x264_pixel_init( 0, &pixel ); #define MC_TEST_LUMA( w, h ) \ if( mc_a.mc_luma != mc_ref.mc_luma ) \ @@ -321,11 +323,26 @@ static int check_mc( int cpu_ref, int cpu_new ) used_asm = 1; \ memset(buf3, 0xCD, 1024); \ memset(buf4, 0xCD, 1024); \ - mc_c.mc_luma( src2, 32, dst1, 16, dx, dy, w, h ); \ - mc_a.mc_luma( src2, 32, dst2, 16, dx, dy, w, h ); \ - if( memcmp( buf3, buf4, 1024 ) ) \ + mc_c.mc_luma( dst1, 16, src2, 32, dx, dy, w, h ); \ + mc_a.mc_luma( dst2, 16, src2, 32, dx, dy, w, h ); \ + if( memcmp( buf3, buf4, 1024 ) ) \ { \ - fprintf( stderr, "mc_luma[mv(%d,%d) %2dx%-2d] [FAILED]\n", dx, dy, w, h ); \ + fprintf( stderr, "mc_luma[mv(%d,%d) %2dx%-2d] [FAILED]\n", dx, dy, w, h ); \ + ok = 0; \ + } \ + } \ + if( mc_a.get_ref != mc_ref.get_ref ) \ + { \ + uint8_t *ref = dst2; \ + int ref_stride = 16; \ + used_asm = 1; \ + memset(buf3, 0xCD, 1024); \ + memset(buf4, 0xCD, 1024); \ + mc_c.mc_luma( dst1, 16, src2, 32, dx, dy, w, h ); \ + ref = mc_a.get_ref( ref, &ref_stride, src2, 32, dx, dy, w, h ); \ + if( pixel.sad[PIXEL_##w##x##h]( dst1, 16, ref, ref_stride ) ) \ + { \ + fprintf( stderr, "get_ref[mv(%d,%d) %2dx%-2d] [FAILED]\n", dx, dy, w, h ); \ ok = 0; \ } \ } @@ -336,21 +353,21 @@ static int check_mc( int cpu_ref, int cpu_new ) used_asm = 1; \ memset(buf3, 0xCD, 1024); \ memset(buf4, 0xCD, 1024); \ - mc_c.mc_chroma( src, 32, dst1, 16, dx, dy, w, h ); \ - mc_a.mc_chroma( src, 32, dst2, 16, dx, dy, w, h ); \ + mc_c.mc_chroma( dst1, 16, src, 32, dx, dy, w, h ); \ + mc_a.mc_chroma( dst2, 16, src, 32, dx, dy, w, h ); \ /* mc_chroma width=2 may write garbage to the right of dst. ignore that. */\ for( j=0; j