From 28eb46a832356d6615bf1788464a37d8a1782716 Mon Sep 17 00:00:00 2001 From: nick Date: Tue, 6 Nov 2001 16:21:38 +0000 Subject: optimized rgb24to16 stuff git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2741 b3059339-0415-0410-9bf9-f77b7e298cf2 --- postproc/rgb2rgb_template.c | 68 ++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 25 deletions(-) (limited to 'postproc/rgb2rgb_template.c') diff --git a/postproc/rgb2rgb_template.c b/postproc/rgb2rgb_template.c index d38a2a95d1..bb74bbda0c 100644 --- a/postproc/rgb2rgb_template.c +++ b/postproc/rgb2rgb_template.c @@ -19,6 +19,9 @@ static const uint64_t mask24h __attribute__((aligned(8))) = 0x0000FFFFFF000000U static const uint64_t mask15b __attribute__((aligned(8))) = 0x001F001F001F001FULL; /* 00000000 00011111 xxB */ static const uint64_t mask15rg __attribute__((aligned(8))) = 0x7FE07FE07FE07FE0ULL; /* 01111111 11100000 RGx */ static const uint64_t mask15s __attribute__((aligned(8))) = 0xFFE0FFE0FFE0FFE0ULL; +static const uint64_t red_mask __attribute__((aligned(8))) = 0x0000f8000000f800ULL; +static const uint64_t green_mask __attribute__((aligned(8)))= 0x000007e0000007e0ULL; +static const uint64_t blue_mask __attribute__((aligned(8))) = 0x0000001f0000001fULL; #endif void rgb24to32(const uint8_t *src,uint8_t *dst,unsigned src_size) @@ -32,9 +35,9 @@ void rgb24to32(const uint8_t *src,uint8_t *dst,unsigned src_size) end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); - mm_end = (uint8_t*)((((unsigned long)end)/(MMREG_SIZE*2))*(MMREG_SIZE*2)); + mm_end = (uint8_t*)((((unsigned long)end)/(MMREG_SIZE*4))*(MMREG_SIZE*4)); __asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory"); - if(mm_end == end) mm_end -= MMREG_SIZE*2; + if(mm_end == end) mm_end -= MMREG_SIZE*4; while(s < mm_end) { __asm __volatile( @@ -253,26 +256,24 @@ void rgb32to15(const uint8_t *src, uint8_t *dst, unsigned src_size) void rgb24to16(const uint8_t *src, uint8_t *dst, unsigned src_size) { - unsigned j,i,num_pixels=src_size/3; +#ifdef HAVE_MMX + const uint8_t *s = src; + const uint8_t *end,*mm_end; uint16_t *d = (uint16_t *)dst; -#if 0/*def HAVE_MMX*/ - unsigned mm_npix; - const uint64_t mm_fc = 0xFCFCFCFCFCFCFCFCULL, mm_f8 = 0xF8F8F8F8F8F8F8F8ULL; - mm_npix = ((num_pixels)/(MMREG_SIZE*2))*(MMREG_SIZE*2); - num_pixels -= mm_npix; + end = s + src_size; + mm_end = (uint8_t*)((((unsigned long)end)/(MMREG_SIZE*2))*(MMREG_SIZE*2)); __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); __asm __volatile( "movq %0, %%mm7\n\t" "movq %1, %%mm6\n\t" - ::"m"(mm_fc),"m"(mm_f8)); - - for(j=0,i=0;j>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8); + } + __asm __volatile(SFENCE:::"memory"); + __asm __volatile(EMMS:::"memory"); +#else + unsigned j,i,num_pixels=src_size/3; + uint16_t *d = (uint16_t *)dst; for(i=0,j=0; j>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8); } +#endif } void rgb24to15(const uint8_t *src, uint8_t *dst, unsigned src_size) -- cgit v1.2.3