]> git.videolan.org Git - x264.git/commitdiff
enable thread synchronization primitives on linux too
authorLoren Merritt <pengvado@videolan.org>
Tue, 19 Dec 2006 21:24:47 +0000 (21:24 +0000)
committerLoren Merritt <pengvado@videolan.org>
Tue, 19 Dec 2006 21:24:47 +0000 (21:24 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@613 df754926-b1dd-0310-bc7b-ec298dee348c

common/common.h
common/frame.c
common/frame.h
encoder/encoder.c

index d69d894b2eb8bce1b17fecaf3b279f918d1c8e2c..7c21a8c4000792704f7018e14ac7d8112e92dfd2 100644 (file)
@@ -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)
index 803466679ba140ad72b8d0926730ccca89931f47..57dfbd785982d197a4c269127b33c9f4b306f2a9 100644 (file)
@@ -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 )
 {}
index 099a1f577db9adec2dfd4e132c85ec5c1d5a8105..7e138620a72b83f486177a5d77978546b8b37723 100644 (file)
@@ -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 );
index b278f6bba65d777a2b6a0f64e6075c87fd864803..fb9a2bd7ac975c77c15d26bcc8d56b1ff5dce075 100644 (file)
@@ -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)) );
     }
 }