#elif defined(HAVE_PTHREAD)
#include <pthread.h>
+#define USE_CONDITION_VAR
#else
#define pthread_t int
#define pthread_create(t,u,f,d)
/* 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 )
{}
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 );
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)) );
}
}