X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=x264_speed_control.cpp;h=719cf28d3ef5a47773bd133206a283ba18b1579f;hb=refs%2Ftags%2F1.7.4;hp=530feb74b41f375847b6cc28fa4cc571805f2880;hpb=c574aef4437253dcf0e6c1fed4c9cab1033b33f9;p=nageru diff --git a/x264_speed_control.cpp b/x264_speed_control.cpp index 530feb7..719cf28 100644 --- a/x264_speed_control.cpp +++ b/x264_speed_control.cpp @@ -16,7 +16,7 @@ using namespace std; using namespace std::chrono; -#define SC_PRESETS 26 +#define SC_PRESETS 23 X264SpeedControl::X264SpeedControl(x264_t *x264, float f_speed, int i_buffer_size, float f_buffer_init) : dyn(load_x264_for_bit_depth(global_flags.x264_bit_depth)), @@ -71,17 +71,16 @@ typedef struct int mix; int trellis; int partitions; - int badapt; - int bframes; int direct; int merange; } sc_preset_t; // The actual presets, including the equivalent commandline options. Note that // all presets are benchmarked with --weightp 1 --mbtree --rc-lookahead 20 -// 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. +// --b-adapt 1 --bframes 3 on top of the given settings (equivalent settings to +// the "faster" preset). Timings and SSIM measurements were done on a four cores +// of a 6-core Coffee Lake i5 2.8 GHz on the first 1000 frames of “Elephants +// Dream” in 1080p. See experiments/measure-x264.pl for a way to reproduce. // // 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 @@ -92,83 +91,76 @@ static const sc_preset_t presets[SC_PRESETS] = { #define P4 X264_ANALYSE_PSUB8x8 #define P8 X264_ANALYSE_PSUB16x16 #define B8 X264_ANALYSE_BSUB16x16 - // Preset 0: 14.179db, --preset superfast --b-adapt 0 --bframes 0 - { .time= 1.000, .subme=1, .me=X264_ME_DIA, .refs=1, .mix=0, .trellis=0, .partitions=I8|I4, .badapt=0, .bframes=0, .direct=0, .merange=16 }, - // Preset 1: 14.459db, --preset superfast - { .time= 1.283, .subme=1, .me=X264_ME_DIA, .refs=1, .mix=0, .trellis=0, .partitions=I8|I4, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 0: 17.386db, --preset superfast + { .time= 1.000, .subme=1, .me=X264_ME_DIA, .refs=1, .mix=0, .trellis=0, .partitions=I8|I4, .direct=1, .merange=16 }, - // Preset 2: 14.761db, --preset superfast --subme 2 - { .time= 1.603, .subme=2, .me=X264_ME_DIA, .refs=1, .mix=0, .trellis=0, .partitions=I8|I4, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 1: 17.919db, --preset superfast --subme 2 + { .time= 1.707, .subme=2, .me=X264_ME_DIA, .refs=1, .mix=0, .trellis=0, .partitions=I8|I4, .direct=1, .merange=16 }, - // Preset 3: 15.543db, --preset veryfast - { .time= 1.843, .subme=2, .me=X264_ME_HEX, .refs=1, .mix=0, .trellis=0, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 2: 18.051db, --preset veryfast + { .time= 1.832, .subme=2, .me=X264_ME_HEX, .refs=1, .mix=0, .trellis=0, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 4: 15.716db, --preset veryfast --subme 3 - { .time= 2.452, .subme=3, .me=X264_ME_HEX, .refs=1, .mix=0, .trellis=0, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 3: 18.422db, --preset veryfast --subme 3 + { .time= 1.853, .subme=3, .me=X264_ME_HEX, .refs=1, .mix=0, .trellis=0, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 5: 15.786db, --preset veryfast --subme 3 --ref 2 - { .time= 2.733, .subme=3, .me=X264_ME_HEX, .refs=2, .mix=0, .trellis=0, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 4: 18.514db, --preset veryfast --subme 3 --ref 2 + { .time= 1.925, .subme=3, .me=X264_ME_HEX, .refs=2, .mix=0, .trellis=0, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 6: 15.813db, --preset veryfast --subme 4 --ref 2 - { .time= 3.085, .subme=4, .me=X264_ME_HEX, .refs=2, .mix=0, .trellis=0, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 5: 18.564db, --preset veryfast --subme 4 --ref 2 + { .time= 2.111, .subme=4, .me=X264_ME_HEX, .refs=2, .mix=0, .trellis=0, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 7: 15.849db, --preset faster - { .time= 3.101, .subme=4, .me=X264_ME_HEX, .refs=2, .mix=0, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 6: 18.411db, --preset faster + { .time= 2.240, .subme=4, .me=X264_ME_HEX, .refs=2, .mix=0, .trellis=1, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 8: 15.857db, --preset faster --mixed-refs - { .time= 3.284, .subme=4, .me=X264_ME_HEX, .refs=2, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 7: 18.429db, --preset faster --mixed-refs + { .time= 2.414, .subme=4, .me=X264_ME_HEX, .refs=2, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 9: 15.869db, --preset faster --mixed-refs --subme 5 - { .time= 3.587, .subme=5, .me=X264_ME_HEX, .refs=2, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 8: 18.454db, --preset faster --mixed-refs --subme 5 + { .time= 2.888, .subme=5, .me=X264_ME_HEX, .refs=2, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 10: 16.051db, --preset fast - { .time= 3.947, .subme=6, .me=X264_ME_HEX, .refs=2, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 9: 18.528db, --preset fast + { .time= 3.570, .subme=6, .me=X264_ME_HEX, .refs=2, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 11: 16.356db, --preset fast --subme 7 - { .time= 4.041, .subme=7, .me=X264_ME_HEX, .refs=2, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 10: 18.762db, --preset fast --subme 7 + { .time= 3.698, .subme=7, .me=X264_ME_HEX, .refs=2, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 12: 16.418db, --preset fast --subme 7 --ref 3 - { .time= 4.406, .subme=7, .me=X264_ME_HEX, .refs=3, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 11: 18.819db, --preset medium + { .time= 4.174, .subme=7, .me=X264_ME_HEX, .refs=3, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 13: 16.460db, --preset medium - { .time= 4.707, .subme=7, .me=X264_ME_HEX, .refs=3, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 12: 18.889db, --preset medium --subme 8 + { .time= 5.155, .subme=8, .me=X264_ME_HEX, .refs=3, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 14: 16.517db, --preset medium --subme 8 - { .time= 5.133, .subme=8, .me=X264_ME_HEX, .refs=3, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 13: 19.127db, --preset medium --subme 8 --trellis 2 + { .time= 7.237, .subme=8, .me=X264_ME_HEX, .refs=3, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8, .direct=1, .merange=16 }, - // Preset 15: 16.523db, --preset medium --subme 8 --me umh - { .time= 6.050, .subme=8, .me=X264_ME_UMH, .refs=3, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=1, .bframes=3, .direct=1, .merange=16 }, + // Preset 14: 19.118db, --preset medium --subme 8 --trellis 2 --direct auto + { .time= 7.240, .subme=8, .me=X264_ME_HEX, .refs=3, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8, .direct=3, .merange=16 }, - // Preset 16: 16.543db, --preset medium --subme 8 --me umh --direct auto --b-adapt 2 - { .time= 6.849, .subme=8, .me=X264_ME_UMH, .refs=3, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=2, .bframes=3, .direct=3, .merange=16 }, + // Preset 15: 19.172db, --preset slow + { .time= 7.910, .subme=8, .me=X264_ME_HEX, .refs=5, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8, .direct=3, .merange=16 }, - // Preset 17: 16.613db, --preset slow - { .time= 8.042, .subme=8, .me=X264_ME_UMH, .refs=5, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=2, .bframes=3, .direct=3, .merange=16 }, + // Preset 16: 19.208db, --preset slow --subme 9 + { .time= 8.091, .subme=9, .me=X264_ME_HEX, .refs=5, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8, .direct=3, .merange=16 }, - // Preset 18: 16.641db, --preset slow --subme 9 - { .time= 8.972, .subme=9, .me=X264_ME_UMH, .refs=5, .mix=1, .trellis=1, .partitions=I8|I4|P8|B8, .badapt=2, .bframes=3, .direct=3, .merange=16 }, + // Preset 17: 19.216db, --preset slow --subme 9 --me umh + { .time= 9.539, .subme=9, .me=X264_ME_UMH, .refs=5, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8, .direct=3, .merange=16 }, - // Preset 19: 16.895db, --preset slow --subme 9 --trellis 2 - { .time=10.073, .subme=9, .me=X264_ME_UMH, .refs=5, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8, .badapt=2, .bframes=3, .direct=3, .merange=16 }, + // Preset 18: 19.253db, --preset slow --subme 9 --me umh --ref 6 + { .time=10.521, .subme=9, .me=X264_ME_UMH, .refs=6, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8, .direct=3, .merange=16 }, - // Preset 20: 16.918db, --preset slow --subme 9 --trellis 2 --ref 6 - { .time=11.147, .subme=9, .me=X264_ME_UMH, .refs=6, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8, .badapt=2, .bframes=3, .direct=3, .merange=16 }, + // Preset 19: 19.275db, --preset slow --subme 9 --me umh --ref 7 + { .time=11.461, .subme=9, .me=X264_ME_UMH, .refs=7, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8, .direct=3, .merange=16 }, - // Preset 21: 16.934db, --preset slow --subme 9 --trellis 2 --ref 7 - { .time=12.267, .subme=9, .me=X264_ME_UMH, .refs=7, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8, .badapt=2, .bframes=3, .direct=3, .merange=16 }, + // Preset 20: 19.314db, --preset slower + { .time=13.145, .subme=9, .me=X264_ME_UMH, .refs=8, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8|P4, .direct=3, .merange=16 }, - // Preset 22: 16.948db, --preset slower - { .time=13.829, .subme=9, .me=X264_ME_UMH, .refs=8, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8|P4, .badapt=2, .bframes=3, .direct=3, .merange=16 }, + // Preset 21: 19.407db, --preset slower --subme 10 + { .time=16.386, .subme=10, .me=X264_ME_UMH, .refs=8, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8|P4, .direct=3, .merange=16 }, - // Preset 23: 17.058db, --preset slower --subme 10 - { .time=14.831, .subme=10, .me=X264_ME_UMH, .refs=8, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8|P4, .badapt=2, .bframes=3, .direct=3, .merange=16 }, + // Preset 22: 19.483db, --preset veryslow + { .time=26.861, .subme=10, .me=X264_ME_UMH, .refs=16, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8|P4, .direct=3, .merange=24 }, - // Preset 24: 17.268db, --preset slower --subme 10 --bframes 8 - { .time=18.705, .subme=10, .me=X264_ME_UMH, .refs=8, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8|P4, .badapt=2, .bframes=8, .direct=3, .merange=16 }, - - // Preset 25: 17.297db, --preset veryslow - { .time=31.419, .subme=10, .me=X264_ME_UMH, .refs=16, .mix=1, .trellis=2, .partitions=I8|I4|P8|B8|P4, .badapt=2, .bframes=8, .direct=3, .merange=24 }, #undef I4 #undef I8 #undef P4 @@ -299,6 +291,7 @@ void X264SpeedControl::set_buffer_size(int new_buffer_size) buffer_size = new_buffer_size * uspf; cplx_decay = 1 - 1./new_buffer_size; compensation_period = buffer_size/4; + metric_x264_speedcontrol_buffer_size_seconds = buffer_size * 1e-6; } int X264SpeedControl::dither_preset(float f) @@ -325,8 +318,6 @@ void X264SpeedControl::apply_preset(int new_preset) dyn.x264_encoder_parameters(x264, &p); p.i_frame_reference = s->refs; - p.i_bframe_adaptive = s->badapt; - p.i_bframe = s->bframes; p.analyse.inter = s->partitions; p.analyse.i_subpel_refine = s->subme; p.analyse.i_me_method = s->me;