~siretart/x264/trunk

« back to all changes in this revision

Viewing changes to x264.c

  • Committer: Fiona Glaser
  • Author(s): Steven Walters
  • Date: 2009-09-02 04:06:20 UTC
  • Revision ID: git-v1:6940dcaef140d8a0c43c9a62db158e9d71a8fdeb
Threaded lookahead
Move lookahead into a separate thread, set to higher priority than the other threads, for optimal performance.
Reduces the amount that lookahead bottlenecks encoding, greatly increasing performance with lookahead-intensive settings (e.g. b-adapt 2) on many-core CPUs.
Buffer size can be controlled with --sync-lookahead, which defaults to auto (threads+bframes buffer size).
Note that this buffer is separate from the rc-lookahead value.
Note also that this does not split lookahead itself into multiple threads yet; this may be added in the future.
Additionally, split frames into "fdec" and "fenc" frame types and keep the two separate.
This split greatly reduces memory usage, which helps compensate for the larger lookahead size.
Extremely special thanks to Michael Kazmier and Alex Giladi of Avail Media, the original authors of this patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
355
355
    H0( "      --ssim                  Enable SSIM computation\n" );
356
356
    H0( "      --threads <integer>     Force a specific number of threads\n" );
357
357
    H1( "      --thread-input          Run Avisynth in its own thread\n" );
 
358
    H1( "      --sync-lookahead <integer> Number of buffer frames for threaded lookahead\n" );
358
359
    H1( "      --non-deterministic     Slightly improve quality of SMP, at the cost of repeatability\n" );
359
360
    H1( "      --asm <integer>         Override CPU detection\n" );
360
361
    H1( "      --no-asm                Disable all CPU optimizations\n" );
467
468
    { "slice-max-mbs",     required_argument, NULL, 0 },
468
469
    { "slices",            required_argument, NULL, 0 },
469
470
    { "thread-input",      no_argument, NULL, OPT_THREAD_INPUT },
 
471
    { "sync-lookahead",    required_argument, NULL, 0 },
470
472
    { "non-deterministic", no_argument, NULL, 0 },
471
473
    { "psnr",              no_argument, NULL, 0 },
472
474
    { "ssim",              no_argument, NULL, 0 },
988
990
 
989
991
#ifdef HAVE_PTHREAD
990
992
    if( b_thread_input || param->i_threads > 1
991
 
        || (param->i_threads == 0 && x264_cpu_num_processors() > 1) )
 
993
        || (param->i_threads == X264_THREADS_AUTO && x264_cpu_num_processors() > 1) )
992
994
    {
993
995
        if( open_file_thread( NULL, &opt->hin, param ) )
994
996
        {