Commit 01e1db24 authored by Loren Merritt's avatar Loren Merritt

enable thread synchronization primitives on linux too


git-svn-id: svn://svn.videolan.org/x264/trunk@613 df754926-b1dd-0310-bc7b-ec298dee348c
parent 34c6fb35
......@@ -64,6 +64,7 @@
#elif defined(HAVE_PTHREAD)
#include <pthread.h>
#define USE_CONDITION_VAR
#else
#define pthread_t int
#define pthread_create(t,u,f,d)
......
......@@ -761,26 +761,24 @@ void x264_deblock_init( int cpu, x264_deblock_function_t *pf )
/* threading */
#ifdef HAVE_PTHREAD
void x264_frame_cond_broadcast( x264_frame_t *frame )
void x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed )
{
pthread_mutex_lock( &frame->mutex );
frame->i_lines_completed = i_lines_completed;
pthread_cond_broadcast( &frame->cv );
pthread_mutex_unlock( &frame->mutex );
}
void x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed )
{
if( frame->i_lines_completed < i_lines_completed )
{
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 );
}
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 );
}
#else
void x264_frame_cond_broadcast( x264_frame_t *frame )
void x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed )
{}
void x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed )
{}
......
......@@ -110,7 +110,7 @@ void x264_frame_init_lowres( int cpu, x264_frame_t *frame );
void x264_deblock_init( int cpu, x264_deblock_function_t *pf );
void x264_frame_cond_broadcast( x264_frame_t *frame );
void x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed );
void x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed );
void x264_frame_push( x264_frame_t **list, x264_frame_t *frame );
......
......@@ -920,10 +920,9 @@ static void x264_fdec_filter_row( x264_t *h, int mb_y )
x264_frame_expand_border_filtered( h, h->fdec, min_y, b_end );
}
if( h->param.i_threads > 1 )
if( h->param.i_threads > 1 && h->fdec->b_kept_as_ref )
{
h->fdec->i_lines_completed = mb_y*16 + (b_end ? 10000 : -(X264_THREAD_HEIGHT << h->sh.b_mbaff));
x264_frame_cond_broadcast( h->fdec );
x264_frame_cond_broadcast( h->fdec, mb_y*16 + (b_end ? 10000 : -(X264_THREAD_HEIGHT << h->sh.b_mbaff)) );
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment