diff -uNrp src/input/ffms.c src.new/input/ffms.c --- src/input/ffms.c 2011-12-06 18:57:13 +0300 +++ src.new/input/ffms.c 2011-12-06 18:59:45 +0300 @@ -112,7 +112,7 @@ static int open_file( char *psz_filename int trackno = FFMS_GetFirstTrackOfType( idx, FFMS_TYPE_VIDEO, &e ); FAIL_IF_ERROR( trackno < 0, "could not find video track\n" ) - h->video_source = FFMS_CreateVideoSource( psz_filename, trackno, idx, 1, seekmode, &e ); + h->video_source = FFMS_CreateVideoSource( psz_filename, trackno, idx, opt->demuxer_threads, seekmode, &e ); FAIL_IF_ERROR( !h->video_source, "could not create video source\n" ) h->track = FFMS_GetTrackFromVideo( h->video_source ); diff -uNrp src/input/input.h src.new/input/input.h --- src/input/input.h 2011-12-06 18:57:13 +0300 +++ src.new/input/input.h 2011-12-06 19:00:00 +0300 @@ -44,6 +44,7 @@ typedef struct int output_csp; /* convert to this csp, if applicable */ int output_range; /* user desired output range */ int input_range; /* user override input range */ + int demuxer_threads; } cli_input_opt_t; /* properties of the source given by the demuxer */ diff -uNrp src/input/lavf.c src.new/input/lavf.c --- src/input/lavf.c 2011-12-06 18:57:13 +0300 +++ src.new/input/lavf.c 2011-12-06 19:00:20 +0300 @@ -184,6 +184,7 @@ static int open_file( char *psz_filename /* lavf is thread unsafe as calling av_read_frame invalidates previously read AVPackets */ info->thread_safe = 0; h->vfr_input = info->vfr; + c->thread_count = opt->demuxer_threads; FAIL_IF_ERROR( avcodec_open2( c, avcodec_find_decoder( c->codec_id ), NULL ), "could not find decoder for video stream\n" ) diff -uNrp src/x264.c src.new/x264.c --- src/x264.c 2011-12-06 18:58:20 +0300 +++ src.new/x264.c 2011-12-06 19:01:26 +0300 @@ -794,6 +794,7 @@ static void help( x264_param_t *defaults H1( " --psnr Enable PSNR computation\n" ); H1( " --ssim Enable SSIM computation\n" ); H1( " --threads Force a specific number of threads\n" ); + H2( " --demuxer-threads Force a specific number of threads for demuxer (lavf, ffms)\n" ); H2( " --sliced-threads Low-latency but lower-efficiency threading\n" ); H2( " --thread-input Run Avisynth in its own thread\n" ); H2( " --sync-lookahead Number of buffer frames for threaded lookahead\n" ); @@ -851,6 +852,7 @@ typedef enum OPT_TIMEBASE, OPT_PULLDOWN, OPT_LOG_LEVEL, + OPT_DEMUXER_THREADS, OPT_VIDEO_FILTER, OPT_INPUT_FMT, OPT_INPUT_RES, @@ -962,6 +964,7 @@ static struct option long_options[] = { "zones", required_argument, NULL, 0 }, { "qpfile", required_argument, NULL, OPT_QPFILE }, { "threads", required_argument, NULL, 0 }, + { "demuxer-threads", required_argument, NULL, OPT_DEMUXER_THREADS }, { "sliced-threads", no_argument, NULL, 0 }, { "no-sliced-threads", no_argument, NULL, 0 }, { "slice-max-size", required_argument, NULL, 0 }, @@ -1329,6 +1332,9 @@ static int parse( int argc, char **argv, case OPT_THREAD_INPUT: b_thread_input = 1; break; + case OPT_DEMUXER_THREADS: + input_opt.demuxer_threads = atoi( optarg ); + break; case OPT_QUIET: cli_log_level = param->i_log_level = X264_LOG_NONE; break; @@ -1485,6 +1491,7 @@ generic_option: input_opt.seek = opt->i_seek; input_opt.progress = opt->b_progress; input_opt.output_csp = output_csp; + input_opt.demuxer_threads = x264_clip3( input_opt.demuxer_threads, 1, X264_THREAD_MAX ); if( select_input( demuxer, demuxername, input_filename, &opt->hin, &info, &input_opt ) ) return -1;