]> git.sesse.net Git - x264/blobdiff - encoder/speed.c
Switch to exponential interpolation between presets.
[x264] / encoder / speed.c
index c59f2c7f40c7a84ed6e07dbadf4db0d5febe0fc1..4f67640df8d0f71451d14a889dea7e9e939f203a 100644 (file)
@@ -105,6 +105,10 @@ typedef struct
 // on top of the given settings (equivalent settings to the "faster" preset).
 // Timings and SSIM measurements were done on a quadcore Haswell i5 3.2 GHz
 // on the first 1000 frames of "Tears of Steel" in 1080p.
+//
+// Note that the two first and the two last are also used for extrapolation
+// should the desired time be outside the range. Thus, it is disadvantageous if
+// they are chosen so that the timings are too close to each other.
 static const sc_preset_t presets[SC_PRESETS] = {
 #define I4 X264_ANALYSE_I4x4
 #define I8 X264_ANALYSE_I8x8
@@ -307,8 +311,9 @@ void x264_speedcontrol_frame( x264_t *h )
                 break;
             t0 = t1;
         }
-        // linear interpolation between states
-        set = i-1 + (target - t0) / (t1 - t0);
+        // exponential interpolation between states
+        set = i-1 + (log(target) - log(t0)) / (log(t1) - log(t0));
+        set = x264_clip3f( set, -5, (SC_PRESETS-1) + 5 );
         // Even if our time estimations in the SC_PRESETS array are off
         // this will push us towards our target fullness
         set += (40 * (filled-0.75));