OSDN Git Service

LinGui: don't disable subme 10 when psy-rd is 0
[handbrake-jp/handbrake-jp-git.git] / libhb / encx264.c
index d004794..5e3fbc0 100644 (file)
@@ -86,7 +86,11 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
     hb_get_tempory_filename( job->h, pv->filename, "x264.log" );
 
     x264_param_default( &param );
-
+    
+    /* Enable metrics */
+    param.analyse.b_psnr = 1;
+    param.analyse.b_ssim = 1;
+    
     param.i_threads    = ( hb_get_cpu_count() * 3 / 2 );
     param.i_width      = job->width;
     param.i_height     = job->height;
@@ -98,15 +102,28 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
      */
     if (job->vrate_base != 1080000)
     {
-        int fps = job->vrate / job->vrate_base;
-
-        /* adjust +1 when fps has remainder to bump { 23.976, 29.976, 59.94 } to { 24, 30, 60 } */
-        if (job->vrate % job->vrate_base)
-            fps += 1;
+        if (job->pass == 2 && !job->cfr )
+        {
+            /* Even though the framerate might be different due to VFR,
+               we still want the same keyframe intervals as the 1st pass,
+               so the 1st pass stats won't conflict on frame decisions.    */
+            hb_interjob_t * interjob = hb_interjob_get( job->h );
+            param.i_keyint_min     = ( interjob->vrate / interjob->vrate_base ) + 1;
+            param.i_keyint_max = ( 10 * interjob->vrate / interjob->vrate_base ) + 1;
+        }
+        else
+        {
+            int fps = job->vrate / job->vrate_base;
 
-        param.i_keyint_min = fps;
-        param.i_keyint_max = fps * 10;
+            /* adjust +1 when fps has remainder to bump
+               { 23.976, 29.976, 59.94 } to { 24, 30, 60 } */
+            if (job->vrate % job->vrate_base)
+                fps += 1;
 
+            param.i_keyint_min = fps;
+            param.i_keyint_max = fps * 10;
+        }
+        
         hb_log("encx264: keyint-min: %i, keyint-max: %i", param.i_keyint_min, param.i_keyint_max);
     }
 
@@ -583,7 +600,7 @@ static hb_buffer_t *x264_encode( hb_work_object_t *w, hb_buffer_t *in )
      */
     if( pv->last_stop != in->start )
     {
-        hb_log("encx264 input continuity err: last stop %lld  start %lld",
+        hb_log("encx264 input continuity err: last stop %"PRId64"  start %"PRId64,
                 pv->last_stop, in->start);
     }
     pv->last_stop = in->stop;