X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmodules%2Fdecklink%2Fcommon.cpp;h=144bc9f50b0e7035fc0f5ca6bc95c6e0000db6e8;hb=11ceb3a29fd27c05bfac2b05463eff1790309a81;hp=83f5e531b099fb103e8dc724a42975d56ef67028;hpb=297cdfddc3d868e3178a151dd295c017f16e1a36;p=mlt diff --git a/src/modules/decklink/common.cpp b/src/modules/decklink/common.cpp index 83f5e531..144bc9f5 100644 --- a/src/modules/decklink/common.cpp +++ b/src/modules/decklink/common.cpp @@ -19,6 +19,7 @@ #include "common.h" #include +#include #ifdef __DARWIN__ @@ -89,3 +90,46 @@ void freeDLString( DLString aDLString ) #endif + +void swab2( const void *from, void *to, int n ) +{ +#if defined(USE_SSE) +#define SWAB_STEP 16 + __asm__ volatile + ( + "loop_start: \n\t" + + /* load */ + "movdqa 0(%[from]), %%xmm0 \n\t" + "add $0x10, %[from] \n\t" + + /* duplicate to temp registers */ + "movdqa %%xmm0, %%xmm1 \n\t" + + /* shift right temp register */ + "psrlw $8, %%xmm1 \n\t" + + /* shift left main register */ + "psllw $8, %%xmm0 \n\t" + + /* compose them back */ + "por %%xmm0, %%xmm1 \n\t" + + /* save */ + "movdqa %%xmm1, 0(%[to]) \n\t" + "add $0x10, %[to] \n\t" + + "dec %[cnt] \n\t" + "jnz loop_start \n\t" + + : + : [from]"r"(from), [to]"r"(to), [cnt]"r"(n / SWAB_STEP) + //: "xmm0", "xmm1" + ); + + from = (unsigned char*) from + n - (n % SWAB_STEP); + to = (unsigned char*) to + n - (n % SWAB_STEP); + n = (n % SWAB_STEP); +#endif + swab((char*) from, (char*) to, n); +};