[x264-devel] commit: Fix some issues with 3-pass statsfile handling (Anton Mitrofanov )

git version control git at videolan.org
Wed Oct 7 03:27:44 CEST 2009


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Sat Sep 26 12:44:53 2009 -0700| [83ca0f2cec3909b38d55e664bcd3f5c4b1546de8] | committer: Jason Garrett-Glaser 

Fix some issues with 3-pass statsfile handling
The value of i_frame during encoder_close was incorrect.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=83ca0f2cec3909b38d55e664bcd3f5c4b1546de8
---

 encoder/encoder.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index 9dfe397..c0b3b76 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -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++ )
     {



More information about the x264-devel mailing list