#define x264_prefetch(x)
#endif
-#if HAVE_POSIXTHREAD
-#if SYS_WINDOWS
-#define x264_lower_thread_priority(p)\
-{\
- x264_pthread_t handle = pthread_self();\
- struct sched_param sp;\
- int policy = SCHED_OTHER;\
- pthread_getschedparam( handle, &policy, &sp );\
- sp.sched_priority -= p;\
- pthread_setschedparam( handle, policy, &sp );\
-}
-#elif SYS_HAIKU
-#include <OS.h>
-#define x264_lower_thread_priority(p)\
- { UNUSED status_t nice_ret = set_thread_priority( find_thread( NULL ), B_LOW_PRIORITY ); }
-#else
-#include <unistd.h>
-#define x264_lower_thread_priority(p) { UNUSED int nice_ret = nice(p); }
-#endif /* SYS_WINDOWS */
-#elif HAVE_WIN32THREAD
-#define x264_lower_thread_priority(p) SetThreadPriority( GetCurrentThread(), X264_MAX( -2, -p ) )
-#else
-#define x264_lower_thread_priority(p)
-#endif
-
#endif /* X264_OSDEP_H */
volatile int exit;
int threads;
x264_pthread_t *thread_handle;
- void (*init_func)(void *);
- void *init_arg;
/* requires a synchronized list structure and associated methods,
so use what is already implemented for frames */
REALIGN_STACK static void *threadpool_thread( x264_threadpool_t *pool )
{
- if( pool->init_func )
- pool->init_func( pool->init_arg );
-
while( !pool->exit )
{
x264_threadpool_job_t *job = NULL;
return NULL;
}
-int x264_threadpool_init( x264_threadpool_t **p_pool, int threads,
- void (*init_func)(void *), void *init_arg )
+int x264_threadpool_init( x264_threadpool_t **p_pool, int threads )
{
if( threads <= 0 )
return -1;
CHECKED_MALLOCZERO( pool, sizeof(x264_threadpool_t) );
*p_pool = pool;
- pool->init_func = init_func;
- pool->init_arg = init_arg;
pool->threads = threads;
CHECKED_MALLOC( pool->thread_handle, pool->threads * sizeof(x264_pthread_t) );
#if HAVE_THREAD
#define x264_threadpool_init x264_template(threadpool_init)
-X264_API int x264_threadpool_init( x264_threadpool_t **p_pool, int threads,
- void (*init_func)(void *), void *init_arg );
+X264_API int x264_threadpool_init( x264_threadpool_t **p_pool, int threads );
#define x264_threadpool_run x264_template(threadpool_run)
X264_API void x264_threadpool_run( x264_threadpool_t *pool, void *(*func)(void *), void *arg );
#define x264_threadpool_wait x264_template(threadpool_wait)
#define x264_threadpool_delete x264_template(threadpool_delete)
X264_API void x264_threadpool_delete( x264_threadpool_t *pool );
#else
-#define x264_threadpool_init(p,t,f,a) -1
+#define x264_threadpool_init(p,t) -1
#define x264_threadpool_run(p,f,a)
#define x264_threadpool_wait(p,a) NULL
#define x264_threadpool_delete(p)
return bitstream_check_buffer_internal( h, filler, 0, -1 );
}
-#if HAVE_THREAD
-static void encoder_thread_init( x264_t *h )
-{
- if( h->param.i_sync_lookahead )
- x264_lower_thread_priority( 10 );
-}
-#endif
-
/****************************************************************************
*
****************************************************************************
CHECKED_MALLOC( h->reconfig_h, sizeof(x264_t) );
if( h->param.i_threads > 1 &&
- x264_threadpool_init( &h->threadpool, h->param.i_threads, (void*)encoder_thread_init, h ) )
+ x264_threadpool_init( &h->threadpool, h->param.i_threads ) )
goto fail;
if( h->param.i_lookahead_threads > 1 &&
- x264_threadpool_init( &h->lookaheadpool, h->param.i_lookahead_threads, NULL, NULL ) )
+ x264_threadpool_init( &h->lookaheadpool, h->param.i_lookahead_threads ) )
goto fail;
#if HAVE_OPENCL
h->next_args->status = 0;
h->frame_total = info->num_frames;
- if( x264_threadpool_init( &h->pool, 1, NULL, NULL ) )
+ if( x264_threadpool_init( &h->pool, 1 ) )
return -1;
*p_handle = h;