]> granicus.if.org Git - libx264/commitdiff
Fix some issues with 3-pass statsfile handling
authorAnton Mitrofanov <BugMaster@narod.ru>
Sat, 26 Sep 2009 19:44:53 +0000 (12:44 -0700)
committerFiona Glaser <fiona@x264.com>
Wed, 7 Oct 2009 00:24:01 +0000 (17:24 -0700)
The value of i_frame during encoder_close was incorrect.

encoder/encoder.c

index 919db08f6125dce508caf77158f10b988da54440..6c66c80e8b9ed4fbf7b4a00b8c5d73d37a210ab5 100644 (file)
@@ -774,7 +774,7 @@ x264_t *x264_encoder_open( x264_param_t *param )
     x264_reduce_fraction( &h->param.i_fps_num, &h->param.i_fps_den );
 
     /* Init x264_t */
-    h->i_frame = 0;
+    h->i_frame = -1;
     h->i_frame_num = 0;
     h->i_idr_pic_id = 0;
 
@@ -1238,9 +1238,6 @@ static void x264_fdec_filter_row( x264_t *h, int mb_y )
 
 static inline int x264_reference_update( x264_t *h )
 {
-    if( h->fdec->i_frame >= 0 )
-        h->i_frame++;
-
     if( !h->fdec->b_kept_as_ref )
     {
         if( h->param.i_threads > 1 )
@@ -1712,6 +1709,7 @@ int     x264_encoder_encode( x264_t *h,
         x264_pthread_cond_broadcast( &h->lookahead->ifbuf.cv_fill );
     }
 
+    h->i_frame++;
     /* 3: The picture is analyzed in the lookahead */
     if( !h->frames.current[0] )
         x264_lookahead_get_frames( h );
@@ -2080,6 +2078,17 @@ void    x264_encoder_close  ( x264_t *h )
         }
     }
 
+    if( h->param.i_threads > 1 )
+    {
+        x264_t *thread_prev;
+
+        thread_prev = h->thread[ h->i_thread_phase % h->param.i_threads ];
+        x264_thread_sync_ratecontrol( h, thread_prev, h );
+        x264_thread_sync_ratecontrol( thread_prev, thread_prev, h );
+        h->i_frame = thread_prev->i_frame + 1 - h->param.i_threads;
+    }
+    h->i_frame++;
+
     /* Slices used and PSNR */
     for( i=0; i<5; i++ )
     {