Commit 90f8a479 authored by Nick Kurshev's avatar Nick Kurshev

More elegant solution

Originally committed as revision 2517 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc
parent 2f6b90b0
...@@ -2,30 +2,7 @@ ...@@ -2,30 +2,7 @@
#include "../config.h" #include "../config.h"
#include "rgb2rgb.h" #include "rgb2rgb.h"
#include "mmx.h" #include "mmx.h"
#include "../mmx_defs.h"
#ifdef HAVE_3DNOW
#define PREFETCH "prefetch"
#define PREFETCHW "prefetchw"
#elif defined ( HAVE_MMX2 )
#define PREFETCH "prefetchnta"
#define PREFETCHW "prefetcht0"
#endif
#ifdef HAVE_3DNOW
#define EMMS "femms"
#else
#define EMMS "emms"
#endif
#ifdef HAVE_MMX2
#define MOVNTQ "movntq"
#else
#define MOVNTQ "movq"
#endif
#ifdef HAVE_MMX2
#define SFENCE "sfence"
#endif
void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size) void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size)
{ {
...@@ -38,21 +15,14 @@ void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size) ...@@ -38,21 +15,14 @@ void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size)
#endif #endif
end = s + src_size; end = s + src_size;
#ifdef HAVE_MMX #ifdef HAVE_MMX
#ifdef PREFETCH __asm __volatile(PREFETCH" %0\n\t"::"m"(*s):"memory");
__asm __volatile( mm_end = (uint8_t*)((((unsigned long)end)/(MMREG_SIZE*2))*(MMREG_SIZE*2));
PREFETCH" %0\n\t"
::"m"(*s):"memory");
#endif
mm_end = (uint8_t*)((((unsigned long)end)/16)*16);
__asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory"); __asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory");
if(mm_end == end) mm_end -= MMREG_SIZE*2;
while(s < mm_end) while(s < mm_end)
{ {
#ifdef PREFETCH
__asm __volatile(
PREFETCH" 32%0\n\t"
::"m"(*s):"memory");
#endif
__asm __volatile( __asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t" "movd %1, %%mm0\n\t"
"movd 3%1, %%mm1\n\t" "movd 3%1, %%mm1\n\t"
"movd 6%1, %%mm2\n\t" "movd 6%1, %%mm2\n\t"
...@@ -69,9 +39,7 @@ void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size) ...@@ -69,9 +39,7 @@ void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size)
dest += 16; dest += 16;
s += 12; s += 12;
} }
#ifdef SFENCE
__asm __volatile(SFENCE:::"memory"); __asm __volatile(SFENCE:::"memory");
#endif
__asm __volatile(EMMS:::"memory"); __asm __volatile(EMMS:::"memory");
#endif #endif
while(s < end) while(s < end)
......
...@@ -2,30 +2,7 @@ ...@@ -2,30 +2,7 @@
#include "../config.h" #include "../config.h"
#include "rgb2rgb.h" #include "rgb2rgb.h"
#include "mmx.h" #include "mmx.h"
#include "../mmx_defs.h"
#ifdef HAVE_3DNOW
#define PREFETCH "prefetch"
#define PREFETCHW "prefetchw"
#elif defined ( HAVE_MMX2 )
#define PREFETCH "prefetchnta"
#define PREFETCHW "prefetcht0"
#endif
#ifdef HAVE_3DNOW
#define EMMS "femms"
#else
#define EMMS "emms"
#endif
#ifdef HAVE_MMX2
#define MOVNTQ "movntq"
#else
#define MOVNTQ "movq"
#endif
#ifdef HAVE_MMX2
#define SFENCE "sfence"
#endif
void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size) void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size)
{ {
...@@ -38,21 +15,14 @@ void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size) ...@@ -38,21 +15,14 @@ void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size)
#endif #endif
end = s + src_size; end = s + src_size;
#ifdef HAVE_MMX #ifdef HAVE_MMX
#ifdef PREFETCH __asm __volatile(PREFETCH" %0\n\t"::"m"(*s):"memory");
__asm __volatile( mm_end = (uint8_t*)((((unsigned long)end)/(MMREG_SIZE*2))*(MMREG_SIZE*2));
PREFETCH" %0\n\t"
::"m"(*s):"memory");
#endif
mm_end = (uint8_t*)((((unsigned long)end)/16)*16);
__asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory"); __asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory");
if(mm_end == end) mm_end -= MMREG_SIZE*2;
while(s < mm_end) while(s < mm_end)
{ {
#ifdef PREFETCH
__asm __volatile(
PREFETCH" 32%0\n\t"
::"m"(*s):"memory");
#endif
__asm __volatile( __asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t" "movd %1, %%mm0\n\t"
"movd 3%1, %%mm1\n\t" "movd 3%1, %%mm1\n\t"
"movd 6%1, %%mm2\n\t" "movd 6%1, %%mm2\n\t"
...@@ -69,9 +39,7 @@ void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size) ...@@ -69,9 +39,7 @@ void rgb24to32(uint8_t *src,uint8_t *dst,uint32_t src_size)
dest += 16; dest += 16;
s += 12; s += 12;
} }
#ifdef SFENCE
__asm __volatile(SFENCE:::"memory"); __asm __volatile(SFENCE:::"memory");
#endif
__asm __volatile(EMMS:::"memory"); __asm __volatile(EMMS:::"memory");
#endif #endif
while(s < end) while(s < end)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment