diff --git a/configure b/configure index 412cc6b..c4a0e6e 100755 --- a/configure +++ b/configure @@ -8,6 +8,7 @@ echo "available options:" echo "" echo " --help print this message" echo " --disable-avis-input disables avisynth input (win32 only)" +echo " --disable-lavf-input disables libavformat input" echo " --disable-ffms-input disables ffmpegsource input" echo " --disable-mp4-output disables mp4 output (using gpac)" echo " --disable-pthread disables multithreaded encoding" @@ -53,6 +54,7 @@ includedir='${prefix}/include' DEVNULL='/dev/null' avis_input="auto" +lavf_input="auto" ffms_input="auto" mp4_output="auto" pthread="auto" @@ -103,6 +105,12 @@ for opt do --disable-avis-input) avis_input="no" ;; + --enable-lavf-input) + lavf_input="yes" + ;; + --disable-lavf-input) + lavf_input="no" + ;; --enable-ffms-input) ffms_input="yes" ;; @@ -431,9 +439,18 @@ if [ "$avis_input" = "yes" ] ; then fi fi +if [ "$lavf_input" = "auto" ] ; then + lavf_input="no" + cc_check "libavformat/avformat.h" "-lavformat" && lavf_input="yes" +fi +if [ "$lavf_input" = "yes" ] ; then + echo "#define LAVF_INPUT" >> config.h + LDFLAGS="$LDFLAGS -lavformat -lavcodec -lavutil" +fi + if [ "$ffms_input" = "auto" ] ; then ffms_input="no" - cc_check "ffms.h" "-lFFMS2" && ffms_input="yes" + cc_check "ffms.h" "-lFFMS2" && [ "$lavf_input" = "yes" ] && ffms_input="yes" fi if [ "$ffms_input" = "yes" ] ; then echo "#define FFMS_INPUT" >> config.h @@ -541,6 +558,7 @@ echo "Platform: $ARCH" echo "System: $SYS" echo "asm: $asm" echo "avis input: $avis_input" +echo "lavf input: $lavf_input" echo "ffms input: $ffms_input" echo "mp4 output: $mp4_output" echo "pthread: $pthread" diff --git a/muxers.c b/muxers.c index 7abb704..7fbb006 100644 --- a/muxers.c +++ b/muxers.c @@ -40,6 +40,9 @@ #ifdef FFMS_INPUT #include +#endif + +#ifdef LAVF_INPUT #include #endif @@ -335,7 +338,7 @@ int close_file_y4m(hnd_t handle) /* libavformat input file support */ -#ifdef FFMS_INPUT +#ifdef LAVF_INPUT typedef struct { AVFormatContext *context; @@ -404,9 +407,11 @@ int close_file_lavf( hnd_t handle ) free( handle ); return 0; } +#endif /* ffmpegsource input file support */ +#ifdef FFMS_INPUT typedef struct { FFMS_VideoSource *video_source; @@ -641,7 +646,7 @@ int read_frame_thread( x264_picture_t *p_pic, hnd_t handle, int i_frame ) ret |= h->p_read_frame( p_pic, h->p_handle, i_frame ); } - if( !h->frame_total || i_frame+1 < h->frame_total ) + if( 0 && (!h->frame_total || i_frame+1 < h->frame_total )) { h->next_frame = h->next_args->i_frame = i_frame+1; diff --git a/x264.c b/x264.c index 454cc14..33fa1e8 100644 --- a/x264.c +++ b/x264.c @@ -40,7 +40,7 @@ #define SetConsoleTitle(t) #endif -#ifdef FFMS_INPUT +#ifdef LAVF_INPUT #include #endif @@ -63,7 +63,7 @@ typedef struct { hnd_t hin; hnd_t hout; FILE *qpfile; - int b_ffms; + int b_lavf; } cli_opt_t; /* input file operation function pointers */ @@ -404,7 +404,7 @@ static void Help( x264_param_t *defaults, int longhelp ) #define OPT_SLOWFIRSTPASS 267 #define OPT_FULLHELP 268 #define OPT_FPS 269 -#define OPT_FFMS_INPUT 270 +#define OPT_LAVF_INPUT 270 static char short_options[] = "8A:B:b:f:hI:i:m:o:p:q:r:t:Vvw"; static struct option long_options[] = @@ -528,7 +528,7 @@ static struct option long_options[] = { "transfer", required_argument, NULL, 0 }, { "colormatrix", required_argument, NULL, 0 }, { "chromaloc", required_argument, NULL, 0 }, - { "ffms-input", no_argument, NULL, OPT_FFMS_INPUT }, + { "lavf-input", no_argument, NULL, OPT_LAVF_INPUT }, {0, 0, 0, 0} }; @@ -852,8 +852,8 @@ static int Parse( int argc, char **argv, fprintf( stderr, "x264 [warning]: not compiled with visualization support\n" ); #endif break; - case OPT_FFMS_INPUT: - opt->b_ffms = 1; + case OPT_LAVF_INPUT: + opt->b_lavf = 1; break; case OPT_TUNE: case OPT_PRESET: @@ -970,7 +970,7 @@ generic_option: if( !strncasecmp( psz, ".y4m", 4 ) ) b_y4m = 1; - if( !(b_avis || b_y4m || opt->b_ffms) ) // raw yuv + if( !(b_avis || b_y4m || opt->b_lavf) ) // raw yuv { if( optind > argc - 1 ) { @@ -994,7 +994,7 @@ generic_option: } } - if( !(b_avis || b_y4m || opt->b_ffms) && ( !param->i_width || !param->i_height ) ) + if( !(b_avis || b_y4m || opt->b_lavf) && ( !param->i_width || !param->i_height ) ) { fprintf( stderr, "x264 [error]: Rawyuv input requires a resolution.\n" ); return -1; @@ -1023,9 +1023,9 @@ generic_option: p_read_frame = read_frame_y4m; p_close_infile = close_file_y4m; } -#ifdef FFMS_INPUT - if( opt->b_ffms ) + if( opt->b_lavf ) { +#ifdef LAVF_INPUT int b_use_pipe = 0; if( strcmp( psz_filename, "-") ) { @@ -1053,16 +1053,23 @@ generic_option: } else { +#ifdef FFMS_INPUT p_open_infile = open_file_ffms; p_get_frame_total = get_frame_total_ffms; p_read_frame = read_frame_ffms; p_close_infile = close_file_ffms; +#else + p_open_infile = open_file_lavf; + p_get_frame_total = get_frame_total_lavf; + p_read_frame = read_frame_lavf; + p_close_infile = close_file_lavf; +#endif } - } #else - fprintf( stderr, "x264 [error]: not compiled with FFMS input support\n" ); - return -1; + fprintf( stderr, "x264 [error]: not compiled with libavformat input support\n" ); + return -1; #endif + } if( p_open_infile( psz_filename, &opt->hin, param ) ) { @@ -1296,7 +1303,7 @@ static int Encode( x264_param_t *param, cli_opt_t *opt ) } i_end = x264_mdate(); - if( !opt->b_ffms ) + if( !opt->b_lavf ) x264_picture_clean( &pic ); /* Erase progress indicator before printing encoding stats. */ if( opt->b_progress )