From a715df2ea0c51be771f0888adf444be5841281d6 Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Thu, 16 Dec 2010 04:41:17 -0800 Subject: [PATCH] MMX/SSE2 high bit depth interleave functions Patch from Google Code-In. --- common/frame.c | 3 +- common/mc.c | 8 +-- common/mc.h | 4 +- common/x86/mc-a2.asm | 116 +++++++++++++++++-------------------------- common/x86/mc-c.c | 30 +++++------ 5 files changed, 70 insertions(+), 91 deletions(-) diff --git a/common/frame.c b/common/frame.c index 3f79f7c6..faf6f3a7 100644 --- a/common/frame.c +++ b/common/frame.c @@ -300,7 +300,8 @@ int x264_frame_copy_picture( x264_t *h, x264_frame_t *dst, x264_picture_t *src ) get_plane_ptr( h, src, &pix[1], &stride[1], i_csp==X264_CSP_I420 ? 1 : 2, 1, 1 ); get_plane_ptr( h, src, &pix[2], &stride[2], i_csp==X264_CSP_I420 ? 2 : 1, 1, 1 ); h->mc.plane_copy_interleave( dst->plane[1], dst->i_stride[1], - pix[1], stride[1], pix[2], stride[2], + (pixel*)pix[1], stride[1]/sizeof(pixel), + (pixel*)pix[2], stride[2]/sizeof(pixel), h->param.i_width>>1, h->param.i_height>>1 ); } return 0; diff --git a/common/mc.c b/common/mc.c index 36322663..96cc6508 100644 --- a/common/mc.c +++ b/common/mc.c @@ -291,14 +291,14 @@ void x264_plane_copy_c( pixel *dst, int i_dst, } void x264_plane_copy_interleave_c( pixel *dst, int i_dst, - uint8_t *srcu, int i_srcu, - uint8_t *srcv, int i_srcv, int w, int h ) + pixel *srcu, int i_srcu, + pixel *srcv, int i_srcv, int w, int h ) { for( int y=0; y2*w -cglobal plane_copy_interleave_core_%1, 6,7 - mov r6d, r6m +cglobal plane_copy_interleave_core_%1, 7,7 + FIX_STRIDES r1d, r3d, r5d, r6d +%ifdef HIGH_BIT_DEPTH + mov r1m, r1d + mov r3m, r3d + mov r6m, r6d +%endif movsxdifnidn r1, r1d movsxdifnidn r3, r3d movsxdifnidn r5, r5d + movsxdifnidn r6, r6d lea r0, [r0+r6*2] add r2, r6 add r4, r6 @@ -1024,10 +994,10 @@ cglobal plane_copy_interleave_core_%1, 6,7 %else DECLARE_REG_TMP 1,3 %endif + mov t1, r1 + shr t1, SIZEOF_PIXEL + sub t1, r6 mov t0d, r7m - mov t1d, r1d - shr t1d, 1 - sub t1d, r6d .loopy: mov r6d, r6m neg r6 @@ -1039,21 +1009,25 @@ cglobal plane_copy_interleave_core_%1, 6,7 mov r6d, r6m neg r6 .loopx: - INTERLEAVE r0+r6*2, r2+r6, r4+r6, u, nt - INTERLEAVE r0+r6*2+16, r2+r6+8, r4+r6+8, u, nt - add r6, 16 + INTERLEAVE r0+r6*2+ 0*SIZEOF_PIXEL, r2+r6+0*SIZEOF_PIXEL, r4+r6+0*SIZEOF_PIXEL, u, nt + INTERLEAVE r0+r6*2+16*SIZEOF_PIXEL, r2+r6+8*SIZEOF_PIXEL, r4+r6+8*SIZEOF_PIXEL, u, nt + add r6, 16*SIZEOF_PIXEL jl .loopx .pad: +%assign n 0 +%rep SIZEOF_PIXEL %if mmsize==8 - movntq [r0+r6*2], m0 - movntq [r0+r6*2+8], m0 - movntq [r0+r6*2+16], m0 - movntq [r0+r6*2+24], m0 + movntq [r0+r6*2+(n+ 0)], m0 + movntq [r0+r6*2+(n+ 8)], m0 + movntq [r0+r6*2+(n+16)], m0 + movntq [r0+r6*2+(n+24)], m0 %else - movntdq [r0+r6*2], m0 - movntdq [r0+r6*2+16], m0 + movntdq [r0+r6*2+(n+ 0)], m0 + movntdq [r0+r6*2+(n+16)], m0 %endif - add r6, 16 + %assign n n+32 +%endrep + add r6, 16*SIZEOF_PIXEL cmp r6, t1 jl .pad add r0, r1mp @@ -1070,17 +1044,17 @@ cglobal plane_copy_interleave_core_%1, 6,7 ;----------------------------------------------------------------------------- cglobal store_interleave_8x8x2_%1, 4,5 mov r4d, 4 + FIX_STRIDES r1d .loop: - INTERLEAVE r0, r2, r3, a - INTERLEAVE r0+r1, r2+FDEC_STRIDE, r3+FDEC_STRIDE, a - add r2, FDEC_STRIDE*2 - add r3, FDEC_STRIDE*2 + INTERLEAVE r0+ 0, r2+ 0, r3+ 0, a + INTERLEAVE r0+r1, r2+FDEC_STRIDEB, r3+FDEC_STRIDEB, a + add r2, FDEC_STRIDEB*2 + add r3, FDEC_STRIDEB*2 lea r0, [r0+r1*2] dec r4d jg .loop REP_RET %endmacro ; PLANE_INTERLEAVE -%endif ; !HIGH_BIT_DEPTH %macro DEINTERLEAVE_START 1 %ifdef HIGH_BIT_DEPTH @@ -1161,8 +1135,10 @@ cglobal load_deinterleave_8x8x2_fdec_%1, 3,4 %ifdef HIGH_BIT_DEPTH INIT_MMX +PLANE_INTERLEAVE mmxext PLANE_DEINTERLEAVE mmx INIT_XMM +PLANE_INTERLEAVE sse2 PLANE_DEINTERLEAVE sse2 %else INIT_MMX diff --git a/common/x86/mc-c.c b/common/x86/mc-c.c index e53afe89..8ddcfc0c 100644 --- a/common/x86/mc-c.c +++ b/common/x86/mc-c.c @@ -86,15 +86,15 @@ void x264_prefetch_fenc_mmxext( uint8_t *, int, uint8_t *, int, int ); void x264_prefetch_ref_mmxext( uint8_t *, int, int ); void x264_plane_copy_core_mmxext( uint8_t *, int, uint8_t *, int, int w, int h); void x264_plane_copy_c( uint8_t *, int, uint8_t *, int, int w, int h ); -void x264_plane_copy_interleave_core_mmxext( uint8_t *dst, int i_dst, - uint8_t *srcu, int i_srcu, - uint8_t *srcv, int i_srcv, int w, int h ); -void x264_plane_copy_interleave_core_sse2( uint8_t *dst, int i_dst, - uint8_t *srcu, int i_srcu, - uint8_t *srcv, int i_srcv, int w, int h ); -void x264_plane_copy_interleave_c( uint8_t *dst, int i_dst, - uint8_t *srcu, int i_srcu, - uint8_t *srcv, int i_srcv, int w, int h ); +void x264_plane_copy_interleave_core_mmxext( pixel *dst, int i_dst, + pixel *srcu, int i_srcu, + pixel *srcv, int i_srcv, int w, int h ); +void x264_plane_copy_interleave_core_sse2( pixel *dst, int i_dst, + pixel *srcu, int i_srcu, + pixel *srcv, int i_srcv, int w, int h ); +void x264_plane_copy_interleave_c( pixel *dst, int i_dst, + pixel *srcu, int i_srcu, + pixel *srcv, int i_srcv, int w, int h ); void x264_plane_copy_deinterleave_mmx( pixel *dstu, int i_dstu, pixel *dstv, int i_dstv, pixel *src, int i_src, int w, int h ); @@ -442,11 +442,12 @@ static void x264_plane_copy_mmxext( uint8_t *dst, int i_dst, uint8_t *src, int i x264_plane_copy_core_mmxext( dst+i_dst, i_dst, src+i_src, i_src, (w+15)&~15, h-1 ); } } +#endif // HIGH_BIT_DEPTH #define PLANE_INTERLEAVE(cpu) \ -static void x264_plane_copy_interleave_##cpu( uint8_t *dst, int i_dst,\ - uint8_t *srcu, int i_srcu,\ - uint8_t *srcv, int i_srcv, int w, int h )\ +static void x264_plane_copy_interleave_##cpu( pixel *dst, int i_dst,\ + pixel *srcu, int i_srcu,\ + pixel *srcv, int i_srcv, int w, int h )\ {\ if( !(w&15) ) {\ x264_plane_copy_interleave_core_##cpu( dst, i_dst, srcu, i_srcu, srcv, i_srcv, w, h );\ @@ -463,7 +464,6 @@ static void x264_plane_copy_interleave_##cpu( uint8_t *dst, int i_dst,\ PLANE_INTERLEAVE(mmxext) PLANE_INTERLEAVE(sse2) -#endif // HIGH_BIT_DEPTH void x264_mc_init_mmx( int cpu, x264_mc_functions_t *pf ) { @@ -488,6 +488,8 @@ void x264_mc_init_mmx( int cpu, x264_mc_functions_t *pf ) if( !(cpu&X264_CPU_MMXEXT) ) return; + pf->plane_copy_interleave = x264_plane_copy_interleave_mmxext; + pf->avg[PIXEL_16x16] = x264_pixel_avg_16x16_mmxext; pf->avg[PIXEL_16x8] = x264_pixel_avg_16x8_mmxext; pf->avg[PIXEL_8x16] = x264_pixel_avg_8x16_mmxext; @@ -513,6 +515,7 @@ void x264_mc_init_mmx( int cpu, x264_mc_functions_t *pf ) pf->load_deinterleave_8x8x2_fenc = x264_load_deinterleave_8x8x2_fenc_sse2; pf->load_deinterleave_8x8x2_fdec = x264_load_deinterleave_8x8x2_fdec_sse2; + pf->plane_copy_interleave = x264_plane_copy_interleave_sse2; pf->plane_copy_deinterleave = x264_plane_copy_deinterleave_sse2; if( cpu&X264_CPU_SSE2_IS_FAST ) @@ -560,7 +563,6 @@ void x264_mc_init_mmx( int cpu, x264_mc_functions_t *pf ) pf->load_deinterleave_8x8x2_fdec = x264_load_deinterleave_8x8x2_fdec_mmx; pf->plane_copy = x264_plane_copy_mmxext; - pf->plane_copy_interleave = x264_plane_copy_interleave_mmxext; pf->plane_copy_deinterleave = x264_plane_copy_deinterleave_mmx; pf->frame_init_lowres_core = x264_frame_init_lowres_core_mmxext; -- 2.47.3