Guest User

Untitled

a guest
Jun 30th, 2010
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. From: Alexander Prikhodko <[email protected]>
  2. Subject: [PATCH] Utilize internal threading in lavf/ffms
  3.  
  4. input/ffms.c | 2 +-
  5. input/input.h | 1 +
  6. input/lavf.c | 4 ++++
  7. x264.c | 8 ++++++++
  8. 4 files changed, 14 insertions(+), 1 deletions(-)
  9.  
  10. Index: input/ffms.c
  11. ===================================================================
  12. --- input/ffms_orig.c
  13. +++ input/ffms.c
  14. @@ -102,7 +102,7 @@ static int open_file( char *psz_filename
  15. return -1;
  16. }
  17.  
  18. - h->video_source = FFMS_CreateVideoSource( psz_filename, trackno, idx, 1, seekmode, &e );
  19. + h->video_source = FFMS_CreateVideoSource( psz_filename, trackno, idx, opt->demuxer_threads, seekmode, &e );
  20. if( !h->video_source )
  21. {
  22. fprintf( stderr, "ffms [error]: could not create video source\n" );
  23. Index: input/input.h
  24. ===================================================================
  25. --- input/input_orig.h
  26. +++ input/input.h
  27. @@ -32,6 +32,7 @@ typedef struct
  28. char *resolution; /* resolution string parsed by raw yuv input */
  29. char *timebase;
  30. int seek;
  31. + int demuxer_threads;
  32. } cli_input_opt_t;
  33.  
  34. /* properties of the source given by the demuxer */
  35. Index: input/lavf.c
  36. ===================================================================
  37. --- input/lavf_orig.c
  38. +++ input/lavf.c
  39. @@ -210,6 +210,10 @@ static int open_file( char *psz_filename
  40. fprintf( stderr, "lavf [warning]: converting from %s to YV12\n",
  41. avcodec_get_pix_fmt_name( h->cur_pix_fmt ) );
  42.  
  43. + if( opt->demuxer_threads > 1 )
  44. + if( avcodec_thread_init( c, opt->demuxer_threads ) )
  45. + c->thread_count = 1;
  46. +
  47. if( avcodec_open( c, avcodec_find_decoder( c->codec_id ) ) )
  48. {
  49. fprintf( stderr, "lavf [error]: could not find decoder for video stream\n" );
  50. Index: x264.c
  51. ===================================================================
  52. --- x264_orig.c
  53. +++ x264.c
  54. @@ -574,6 +574,7 @@ static void Help( x264_param_t *defaults
  55. H1( " --psnr Enable PSNR computation\n" );
  56. H1( " --ssim Enable SSIM computation\n" );
  57. H1( " --threads <integer> Force a specific number of threads\n" );
  58. + H1( " --demuxer-threads <integer> Force a specific number of threads for demuxer (lavf, ffms)\n" );
  59. H2( " --sliced-threads Low-latency but lower-efficiency threading\n" );
  60. H2( " --thread-input Run Avisynth in its own thread\n" );
  61. H2( " --sync-lookahead <integer> Number of buffer frames for threaded lookahead\n" );
  62. @@ -616,6 +617,7 @@ enum {
  63. OPT_TCFILE_OUT,
  64. OPT_TIMEBASE,
  65. OPT_PULLDOWN,
  66. + OPT_DEMUXER_THREADS,
  67. } OptionsOPT;
  68.  
  69. static char short_options[] = "8A:B:b:f:hI:i:m:o:p:q:r:t:Vvw";
  70. @@ -717,6 +719,7 @@ static struct option long_options[] =
  71. { "zones", required_argument, NULL, 0 },
  72. { "qpfile", required_argument, NULL, OPT_QPFILE },
  73. { "threads", required_argument, NULL, 0 },
  74. + { "demuxer-threads", required_argument, NULL, OPT_DEMUXER_THREADS },
  75. { "sliced-threads", no_argument, NULL, 0 },
  76. { "no-sliced-threads", no_argument, NULL, 0 },
  77. { "slice-max-size", required_argument, NULL, 0 },
  78. @@ -923,6 +926,7 @@ static int Parse( int argc, char **argv,
  79. x264_param_t defaults;
  80. char *profile = NULL;
  81. int b_thread_input = 0;
  82. + int i_demuxer_threads = 1;
  83. int b_turbo = 1;
  84. int b_user_ref = 0;
  85. int b_user_fps = 0;
  86. @@ -1037,6 +1041,9 @@ static int Parse( int argc, char **argv,
  87. case OPT_THREAD_INPUT:
  88. b_thread_input = 1;
  89. break;
  90. + case OPT_DEMUXER_THREADS:
  91. + i_demuxer_threads = atoi( optarg );
  92. + break;
  93. case OPT_QUIET:
  94. param->i_log_level = X264_LOG_NONE;
  95. break;
  96. @@ -1147,6 +1154,7 @@ generic_option:
  97.  
  98. input_filename = argv[optind++];
  99. input_opt.resolution = optind < argc ? argv[optind++] : NULL;
  100. + input_opt.demuxer_threads = X264_MAX( i_demuxer_threads, 1 );
  101. video_info_t info = {0};
  102. char demuxername[5];
Advertisement
Add Comment
Please, Sign In to add comment