]> git.sesse.net Git - mlt/blobdiff - src/modules/decklink/common.cpp
Fix compile error on Windows.
[mlt] / src / modules / decklink / common.cpp
index 84ef72fb8aa41ac47a9f5c501dc2a5dbf9ecb579..144bc9f50b0e7035fc0f5ca6bc95c6e0000db6e8 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "common.h"
 #include <stdlib.h>
+#include <unistd.h>
 
 #ifdef __DARWIN__
 
@@ -39,6 +40,38 @@ void freeDLString( DLString aDLString )
        if ( aDLString ) CFRelease( aDLString );
 }
 
+#elif defined(WIN32)
+
+char* getCString( DLString aDLString )
+{
+       char* CString = NULL;
+       if ( aDLString )
+       {
+               int size = WideCharToMultiByte( CP_UTF8, 0, aDLString, -1, NULL, 0, NULL, NULL );
+               if (size)
+               {
+                       CString = new char[ size ];
+                       size = WideCharToMultiByte( CP_UTF8, 0, aDLString, -1, CString, size, NULL, NULL );
+                       if ( !size )
+                       {
+                               delete[] CString;
+                               CString = NULL;
+                       }
+               }
+       }
+       return CString;
+}
+
+void freeCString( char* aCString )
+{
+       delete[] aCString;
+}
+
+void freeDLString( DLString aDLString )
+{
+       if ( aDLString ) free( (void*) aDLString );
+}
+
 #else
 
 char* getCString( DLString aDLString )
@@ -57,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);
+};