Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From: Alexander Prikhodko <[email protected]>
- Subject: [PATCH] Utilize internal threading in lavf/ffms
- input/ffms.c | 2 +-
- input/input.h | 1 +
- input/lavf.c | 4 ++++
- x264.c | 8 ++++++++
- 4 files changed, 14 insertions(+), 1 deletions(-)
- Index: input/ffms.c
- ===================================================================
- --- input/ffms_orig.c
- +++ input/ffms.c
- @@ -102,7 +102,7 @@ static int open_file( char *psz_filename
- return -1;
- }
- - 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 );
- if( !h->video_source )
- {
- fprintf( stderr, "ffms [error]: could not create video source\n" );
- Index: input/input.h
- ===================================================================
- --- input/input_orig.h
- +++ input/input.h
- @@ -32,6 +32,7 @@ typedef struct
- char *resolution; /* resolution string parsed by raw yuv input */
- char *timebase;
- int seek;
- + int demuxer_threads;
- } cli_input_opt_t;
- /* properties of the source given by the demuxer */
- Index: input/lavf.c
- ===================================================================
- --- input/lavf_orig.c
- +++ input/lavf.c
- @@ -210,6 +210,10 @@ static int open_file( char *psz_filename
- fprintf( stderr, "lavf [warning]: converting from %s to YV12\n",
- avcodec_get_pix_fmt_name( h->cur_pix_fmt ) );
- + if( opt->demuxer_threads > 1 )
- + if( avcodec_thread_init( c, opt->demuxer_threads ) )
- + c->thread_count = 1;
- +
- if( avcodec_open( c, avcodec_find_decoder( c->codec_id ) ) )
- {
- fprintf( stderr, "lavf [error]: could not find decoder for video stream\n" );
- Index: x264.c
- ===================================================================
- --- x264_orig.c
- +++ x264.c
- @@ -574,6 +574,7 @@ static void Help( x264_param_t *defaults
- H1( " --psnr Enable PSNR computation\n" );
- H1( " --ssim Enable SSIM computation\n" );
- H1( " --threads <integer> Force a specific number of threads\n" );
- + H1( " --demuxer-threads <integer> 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 <integer> Number of buffer frames for threaded lookahead\n" );
- @@ -616,6 +617,7 @@ enum {
- OPT_TCFILE_OUT,
- OPT_TIMEBASE,
- OPT_PULLDOWN,
- + OPT_DEMUXER_THREADS,
- } OptionsOPT;
- static char short_options[] = "8A:B:b:f:hI:i:m:o:p:q:r:t:Vvw";
- @@ -717,6 +719,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 },
- @@ -923,6 +926,7 @@ static int Parse( int argc, char **argv,
- x264_param_t defaults;
- char *profile = NULL;
- int b_thread_input = 0;
- + int i_demuxer_threads = 1;
- int b_turbo = 1;
- int b_user_ref = 0;
- int b_user_fps = 0;
- @@ -1037,6 +1041,9 @@ static int Parse( int argc, char **argv,
- case OPT_THREAD_INPUT:
- b_thread_input = 1;
- break;
- + case OPT_DEMUXER_THREADS:
- + i_demuxer_threads = atoi( optarg );
- + break;
- case OPT_QUIET:
- param->i_log_level = X264_LOG_NONE;
- break;
- @@ -1147,6 +1154,7 @@ generic_option:
- input_filename = argv[optind++];
- input_opt.resolution = optind < argc ? argv[optind++] : NULL;
- + input_opt.demuxer_threads = X264_MAX( i_demuxer_threads, 1 );
- video_info_t info = {0};
- char demuxername[5];
Advertisement
Add Comment
Please, Sign In to add comment