[x264-devel] Native win32 threads
Gianluigi Tiesi
mplayer at netfarm.it
Sun Jun 5 03:40:52 CEST 2005
This patch make use of win32 native threads without support
of pthreads, Tested with mingw32, I've problem compiling x264 with msvc6 for it but I
don't care since I need mingw32 version, but it shouldn't be a problem
with msvc since the patch is very simple.
Bye
--
Gianluigi Tiesi <sherpya at netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/
-------------- next part --------------
Index: encoder/encoder.c
===================================================================
--- encoder/encoder.c (revision 248)
+++ encoder/encoder.c (working copy)
@@ -36,6 +36,10 @@
#include <pthread.h>
#endif
#endif
+
+#ifdef __WIN32__
+#include <windows.h>
+#endif
#include "common/common.h"
#include "common/cpu.h"
@@ -368,7 +372,7 @@
h->param.i_threads = x264_clip3( h->param.i_threads, 1, X264_SLICE_MAX );
h->param.i_threads = X264_MIN( h->param.i_threads, h->param.i_height / 16 );
-#if !(HAVE_PTHREAD)
+#if !(__WIN32__) && !(HAVE_PTHREAD)
if( h->param.i_threads > 1 )
{
x264_log( h, X264_LOG_WARNING, "not compiled with pthread support!\n");
@@ -1055,6 +1059,18 @@
for( i = 0; i < h->param.i_threads; i++ )
pthread_join( handles[i], &status );
}
+#elif defined(__WIN32__)
+ {
+ HANDLE handles[X264_SLICE_MAX];
+ DWORD tid;
+ for( i = 0; i < h->param.i_threads; i++ )
+ handles[i] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) x264_slice_write, (LPVOID) h->thread[i], 0, &tid);
+ for( i = 0; i < h->param.i_threads; i++ )
+ {
+ WaitForSingleObject(handles[i], INFINITE);
+ CloseHandle(handles[i]);
+ }
+ }
#else
for( i = 0; i < h->param.i_threads; i++ )
x264_slice_write( h->thread[i] );
More information about the x264-devel
mailing list