for( j = 0; j < h->param.i_bframe + 2; j++ )
CHECKED_MALLOC( frame->i_row_satds[i][j], i_lines/16 * sizeof(int) );
- pthread_mutex_init( &frame->mutex, NULL );
- pthread_cond_init( &frame->cv, NULL );
+ x264_pthread_mutex_init( &frame->mutex, NULL );
+ x264_pthread_cond_init( &frame->cv, NULL );
return frame;
x264_free( frame->mv[1] );
x264_free( frame->ref[0] );
x264_free( frame->ref[1] );
- pthread_mutex_destroy( &frame->mutex );
- pthread_cond_destroy( &frame->cv );
+ x264_pthread_mutex_destroy( &frame->mutex );
+ x264_pthread_cond_destroy( &frame->cv );
x264_free( frame );
}
#ifdef HAVE_PTHREAD
void x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed )
{
- pthread_mutex_lock( &frame->mutex );
+ x264_pthread_mutex_lock( &frame->mutex );
frame->i_lines_completed = i_lines_completed;
- pthread_cond_broadcast( &frame->cv );
- pthread_mutex_unlock( &frame->mutex );
+ x264_pthread_cond_broadcast( &frame->cv );
+ x264_pthread_mutex_unlock( &frame->mutex );
}
void x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed )
{
- pthread_mutex_lock( &frame->mutex );
+ x264_pthread_mutex_lock( &frame->mutex );
while( frame->i_lines_completed < i_lines_completed )
- pthread_cond_wait( &frame->cv, &frame->mutex );
- pthread_mutex_unlock( &frame->mutex );
+ x264_pthread_cond_wait( &frame->cv, &frame->mutex );
+ x264_pthread_mutex_unlock( &frame->mutex );
}
#else
#endif
/* threads */
-#if defined(__WIN32__) && defined(HAVE_PTHREAD)
-#include <pthread.h>
-#define USE_CONDITION_VAR
-
-#elif defined(SYS_BEOS)
+#if defined(SYS_BEOS)
#include <kernel/OS.h>
-#define pthread_t thread_id
-#define pthread_create(t,u,f,d) { *(t)=spawn_thread(f,"",10,d); \
- resume_thread(*(t)); }
-#define pthread_join(t,s) { long tmp; \
- wait_for_thread(t,(s)?(long*)(s):&tmp); }
+#define x264_pthread_t thread_id
+#define x264_pthread_create(t,u,f,d) { *(t)=spawn_thread(f,"",10,d); \
+ resume_thread(*(t)); }
+#define x264_pthread_join(t,s) { long tmp; \
+ wait_for_thread(t,(s)?(long*)(s):&tmp); }
#ifndef usleep
-#define usleep(t) snooze(t)
+#define usleep(t) snooze(t)
#endif
#define HAVE_PTHREAD 1
#elif defined(HAVE_PTHREAD)
#include <pthread.h>
-#define USE_CONDITION_VAR
+#define USE_REAL_PTHREAD
+
#else
-#define pthread_t int
-#define pthread_create(t,u,f,d)
-#define pthread_join(t,s)
+#define x264_pthread_t int
+#define x264_pthread_create(t,u,f,d)
+#define x264_pthread_join(t,s)
#endif //SYS_*
-#ifndef USE_CONDITION_VAR
-#define pthread_mutex_t int
-#define pthread_mutex_init(m,f)
-#define pthread_mutex_destroy(m)
-#define pthread_mutex_lock(m)
-#define pthread_mutex_unlock(m)
-#define pthread_cond_t int
-#define pthread_cond_init(c,f)
-#define pthread_cond_destroy(c)
-#define pthread_cond_broadcast(c)
-#define pthread_cond_wait(c,m) usleep(100)
+#ifdef USE_REAL_PTHREAD
+#define x264_pthread_t pthread_t
+#define x264_pthread_create pthread_create
+#define x264_pthread_join pthread_join
+#define x264_pthread_mutex_t pthread_mutex_t
+#define x264_pthread_mutex_init pthread_mutex_init
+#define x264_pthread_mutex_destroy pthread_mutex_destroy
+#define x264_pthread_mutex_lock pthread_mutex_lock
+#define x264_pthread_mutex_unlock pthread_mutex_unlock
+#define x264_pthread_cond_t pthread_cond_t
+#define x264_pthread_cond_init pthread_cond_init
+#define x264_pthread_cond_destroy pthread_cond_destroy
+#define x264_pthread_cond_broadcast pthread_cond_broadcast
+#define x264_pthread_cond_wait pthread_cond_wait
+#else
+#define x264_pthread_mutex_t int
+#define x264_pthread_mutex_init(m,f)
+#define x264_pthread_mutex_destroy(m)
+#define x264_pthread_mutex_lock(m)
+#define x264_pthread_mutex_unlock(m)
+#define x264_pthread_cond_t int
+#define x264_pthread_cond_init(c,f)
+#define x264_pthread_cond_destroy(c)
+#define x264_pthread_cond_broadcast(c)
+#define x264_pthread_cond_wait(c,m) usleep(100)
#endif
#endif //_OSDEP_H
/* Write frame */
if( h->param.i_threads > 1 )
{
- pthread_create( &h->thread_handle, NULL, (void*)x264_slices_write, h );
+ x264_pthread_create( &h->thread_handle, NULL, (void*)x264_slices_write, h );
h->b_thread_active = 1;
}
else
if( h->b_thread_active )
{
- pthread_join( h->thread_handle, NULL );
+ x264_pthread_join( h->thread_handle, NULL );
h->b_thread_active = 0;
}
if( !h->out.i_nal )
{
// don't strictly have to wait for the other threads, but it's simpler than cancelling them
if( h->thread[i]->b_thread_active )
- pthread_join( h->thread[i]->thread_handle, NULL );
+ x264_pthread_join( h->thread[i]->thread_handle, NULL );
}
#ifdef DEBUG_BENCHMARK
int (*p_close_infile)( hnd_t handle );
hnd_t p_handle;
x264_picture_t pic;
- pthread_t tid;
+ x264_pthread_t tid;
int next_frame;
int frame_total;
struct thread_input_arg_t *next_args;
if( h->next_frame >= 0 )
{
- pthread_join( h->tid, &stuff );
+ x264_pthread_join( h->tid, &stuff );
ret |= h->next_args->status;
}
h->next_frame =
h->next_args->i_frame = i_frame+1;
h->next_args->pic = &h->pic;
- pthread_create( &h->tid, NULL, (void*)read_frame_thread_int, h->next_args );
+ x264_pthread_create( &h->tid, NULL, (void*)read_frame_thread_int, h->next_args );
}
else
h->next_frame = -1;