X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=x264.c;h=414252c9b890badb4ce1cac440fc6c296f58d81c;hb=refs%2Fheads%2Fspeedcontrol;hp=c4a740094d861198a6c4ecaf2b4f329d07d27274;hpb=2b61248f4bcbb5f9df32d940732bc26d8feeda8c;p=x264 diff --git a/x264.c b/x264.c index c4a74009..414252c9 100644 --- a/x264.c +++ b/x264.c @@ -1,12 +1,14 @@ /***************************************************************************** - * x264: h264 encoder testing program. + * x264: top-level x264cli functions ***************************************************************************** - * Copyright (C) 2003-2008 x264 project + * Copyright (C) 2003-2016 x264 project * * Authors: Loren Merritt * Laurent Aimar * Steven Walters + * Fiona Glaser * Kieran Kunhya + * Henrik Gramner * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,33 +23,126 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. + * + * This program is also available under a commercial proprietary license. + * For more information, contact us at licensing@x264.com. *****************************************************************************/ -#include -#include +#ifdef _WIN32 +/* The following two defines must be located before the inclusion of any system header files. */ +#define WINVER 0x0500 +#define _WIN32_WINNT 0x0500 +#include +#include /* _setmode() */ +#include /* _O_BINARY */ +#endif #include -#define _GNU_SOURCE #include - #include "common/common.h" -#include "common/cpu.h" -#include "x264.h" -#include "muxers.h" +#include "x264cli.h" +#include "input/input.h" +#include "output/output.h" +#include "filters/filters.h" + +#define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "x264", __VA_ARGS__ ) + +#if HAVE_LAVF +#undef DECLARE_ALIGNED +#include +#include +#include +#endif + +#if HAVE_SWSCALE +#undef DECLARE_ALIGNED +#include +#endif + +#if HAVE_FFMS +#include +#endif #ifdef _WIN32 -#include -#else -#define SetConsoleTitle(t) +#define CONSOLE_TITLE_SIZE 200 +static wchar_t org_console_title[CONSOLE_TITLE_SIZE] = L""; + +void x264_cli_set_console_title( const char *title ) +{ + wchar_t title_utf16[CONSOLE_TITLE_SIZE]; + if( utf8_to_utf16( title, title_utf16 ) ) + SetConsoleTitleW( title_utf16 ); +} + +static int utf16_to_ansi( const wchar_t *utf16, char *ansi, int size ) +{ + int invalid; + return WideCharToMultiByte( CP_ACP, WC_NO_BEST_FIT_CHARS, utf16, -1, ansi, size, NULL, &invalid ) && !invalid; +} + +/* Some external libraries doesn't support Unicode in filenames, + * as a workaround we can try to get an ANSI filename instead. */ +int x264_ansi_filename( const char *filename, char *ansi_filename, int size, int create_file ) +{ + wchar_t filename_utf16[MAX_PATH]; + if( utf8_to_utf16( filename, filename_utf16 ) ) + { + if( create_file ) + { + /* Create the file using the Unicode filename if it doesn't already exist. */ + FILE *fh = _wfopen( filename_utf16, L"ab" ); + if( fh ) + fclose( fh ); + } + + /* Check if the filename already is valid ANSI. */ + if( utf16_to_ansi( filename_utf16, ansi_filename, size ) ) + return 1; + + /* Check for a legacy 8.3 short filename. */ + int short_length = GetShortPathNameW( filename_utf16, filename_utf16, MAX_PATH ); + if( short_length > 0 && short_length < MAX_PATH ) + if( utf16_to_ansi( filename_utf16, ansi_filename, size ) ) + return 1; + } + return 0; +} + +/* Retrieve command line arguments as UTF-8. */ +static int get_argv_utf8( int *argc_ptr, char ***argv_ptr ) +{ + int ret = 0; + wchar_t **argv_utf16 = CommandLineToArgvW( GetCommandLineW(), argc_ptr ); + if( argv_utf16 ) + { + int argc = *argc_ptr; + int offset = (argc+1) * sizeof(char*); + int size = offset; + + for( int i = 0; i < argc; i++ ) + size += WideCharToMultiByte( CP_UTF8, 0, argv_utf16[i], -1, NULL, 0, NULL, NULL ); + + char **argv = *argv_ptr = malloc( size ); + if( argv ) + { + for( int i = 0; i < argc; i++ ) + { + argv[i] = (char*)argv + offset; + offset += WideCharToMultiByte( CP_UTF8, 0, argv_utf16[i], -1, argv[i], size-offset, NULL, NULL ); + } + argv[argc] = NULL; + ret = 1; + } + LocalFree( argv_utf16 ); + } + return ret; +} #endif /* Ctrl-C handler */ -static int b_ctrl_c = 0; -static int b_exit_on_ctrl_c = 0; -static void SigIntHandler( int a ) +static volatile int b_ctrl_c = 0; +static void sigint_handler( int a ) { - if( b_exit_on_ctrl_c ) - exit(0); b_ctrl_c = 1; } @@ -62,22 +157,25 @@ typedef struct { int i_pulldown; } cli_opt_t; -/* i/o file operation function pointer structs */ -cli_input_t input; -static cli_output_t output; +/* file i/o operation structs */ +cli_input_t cli_input; +static cli_output_t cli_output; + +/* video filter operation struct */ +static cli_vid_filter_t filter; static const char * const demuxer_names[] = { "auto", - "yuv", + "raw", "y4m", -#ifdef AVS_INPUT +#if HAVE_AVS "avs", #endif -#ifdef LAVF_INPUT +#if HAVE_LAVF "lavf", #endif -#ifdef FFMS_INPUT +#if HAVE_FFMS "ffms", #endif 0 @@ -89,15 +187,39 @@ static const char * const muxer_names[] = "raw", "mkv", "flv", -#ifdef MP4_OUTPUT +#if HAVE_GPAC || HAVE_LSMASH "mp4", #endif 0 }; static const char * const pulldown_names[] = { "none", "22", "32", "64", "double", "triple", "euro", 0 }; +static const char * const log_level_names[] = { "none", "error", "warning", "info", "debug", 0 }; +static const char * const output_csp_names[] = +{ +#if !X264_CHROMA_FORMAT || X264_CHROMA_FORMAT == X264_CSP_I420 + "i420", +#endif +#if !X264_CHROMA_FORMAT || X264_CHROMA_FORMAT == X264_CSP_I422 + "i422", +#endif +#if !X264_CHROMA_FORMAT || X264_CHROMA_FORMAT == X264_CSP_I444 + "i444", "rgb", +#endif + 0 +}; +static const char * const chroma_format_names[] = +{ + [0] = "all", + [X264_CSP_I420] = "i420", + [X264_CSP_I422] = "i422", + [X264_CSP_I444] = "i444" +}; + +static const char * const range_names[] = { "auto", "tv", "pc", 0 }; -typedef struct{ +typedef struct +{ int mod; uint8_t pattern[24]; float fps_factor; @@ -137,50 +259,152 @@ static const cli_pulldown_t pulldown_values[] = // indexed by pic_struct enum static const float pulldown_frame_duration[10] = { 0.0, 1, 0.5, 0.5, 1, 1, 1.5, 1.5, 2, 3 }; -static void Help( x264_param_t *defaults, int longhelp ); -static int Parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt ); -static int Encode( x264_param_t *param, cli_opt_t *opt ); +static void help( x264_param_t *defaults, int longhelp ); +static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt ); +static int encode( x264_param_t *param, cli_opt_t *opt ); + +/* logging and printing for within the cli system */ +static int cli_log_level; +void x264_cli_log( const char *name, int i_level, const char *fmt, ... ) +{ + if( i_level > cli_log_level ) + return; + char *s_level; + switch( i_level ) + { + case X264_LOG_ERROR: + s_level = "error"; + break; + case X264_LOG_WARNING: + s_level = "warning"; + break; + case X264_LOG_INFO: + s_level = "info"; + break; + case X264_LOG_DEBUG: + s_level = "debug"; + break; + default: + s_level = "unknown"; + break; + } + fprintf( stderr, "%s [%s]: ", name, s_level ); + va_list arg; + va_start( arg, fmt ); + x264_vfprintf( stderr, fmt, arg ); + va_end( arg ); +} + +void x264_cli_printf( int i_level, const char *fmt, ... ) +{ + if( i_level > cli_log_level ) + return; + va_list arg; + va_start( arg, fmt ); + x264_vfprintf( stderr, fmt, arg ); + va_end( arg ); +} + +static void print_version_info( void ) +{ +#ifdef X264_POINTVER + printf( "x264 "X264_POINTVER"\n" ); +#else + printf( "x264 0.%d.X\n", X264_BUILD ); +#endif +#if HAVE_SWSCALE + printf( "(libswscale %d.%d.%d)\n", LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO ); +#endif +#if HAVE_LAVF + printf( "(libavformat %d.%d.%d)\n", LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO ); +#endif +#if HAVE_FFMS + printf( "(ffmpegsource %d.%d.%d.%d)\n", FFMS_VERSION >> 24, (FFMS_VERSION & 0xff0000) >> 16, (FFMS_VERSION & 0xff00) >> 8, FFMS_VERSION & 0xff ); +#endif + printf( "built on " __DATE__ ", " ); +#ifdef __INTEL_COMPILER + printf( "intel: %.2f (%d)\n", __INTEL_COMPILER / 100.f, __INTEL_COMPILER_BUILD_DATE ); +#elif defined(__GNUC__) + printf( "gcc: " __VERSION__ "\n" ); +#elif defined(_MSC_FULL_VER) + printf( "msvc: %.2f (%u)\n", _MSC_VER / 100.f, _MSC_FULL_VER ); +#else + printf( "using an unknown compiler\n" ); +#endif + printf( "x264 configuration: --bit-depth=%d --chroma-format=%s\n", X264_BIT_DEPTH, chroma_format_names[X264_CHROMA_FORMAT] ); + printf( "libx264 configuration: --bit-depth=%d --chroma-format=%s\n", x264_bit_depth, chroma_format_names[x264_chroma_format] ); + printf( "x264 license: " ); +#if HAVE_GPL + printf( "GPL version 2 or later\n" ); +#else + printf( "Non-GPL commercial\n" ); +#endif +#if HAVE_SWSCALE + const char *license = swscale_license(); + printf( "libswscale%s%s license: %s\n", HAVE_LAVF ? "/libavformat" : "", HAVE_FFMS ? "/ffmpegsource" : "" , license ); + if( !strcmp( license, "nonfree and unredistributable" ) || + (!HAVE_GPL && (!strcmp( license, "GPL version 2 or later" ) + || !strcmp( license, "GPL version 3 or later" )))) + printf( "WARNING: This binary is unredistributable!\n" ); +#endif +} -/**************************************************************************** - * main: - ****************************************************************************/ int main( int argc, char **argv ) { x264_param_t param; - cli_opt_t opt; - int ret; + cli_opt_t opt = {0}; + int ret = 0; -#ifdef PTW32_STATIC_LIB - pthread_win32_process_attach_np(); - pthread_win32_thread_attach_np(); -#endif + FAIL_IF_ERROR( x264_threading_init(), "unable to initialize threading\n" ) #ifdef _WIN32 - _setmode(_fileno(stdin), _O_BINARY); - _setmode(_fileno(stdout), _O_BINARY); + FAIL_IF_ERROR( !get_argv_utf8( &argc, &argv ), "unable to convert command line to UTF-8\n" ) + + GetConsoleTitleW( org_console_title, CONSOLE_TITLE_SIZE ); + _setmode( _fileno( stdin ), _O_BINARY ); + _setmode( _fileno( stdout ), _O_BINARY ); + _setmode( _fileno( stderr ), _O_BINARY ); #endif /* Parse command line */ - if( Parse( argc, argv, ¶m, &opt ) < 0 ) - return -1; + if( parse( argc, argv, ¶m, &opt ) < 0 ) + ret = -1; - /* Control-C handler */ - signal( SIGINT, SigIntHandler ); +#ifdef _WIN32 + /* Restore title; it can be changed by input modules */ + SetConsoleTitleW( org_console_title ); +#endif - ret = Encode( ¶m, &opt ); + /* Control-C handler */ + signal( SIGINT, sigint_handler ); + + if( !ret ) + ret = encode( ¶m, &opt ); + + /* clean up handles */ + if( filter.free ) + filter.free( opt.hin ); + else if( opt.hin ) + cli_input.close_file( opt.hin ); + if( opt.hout ) + cli_output.close_file( opt.hout, 0, 0 ); + if( opt.tcfile_out ) + fclose( opt.tcfile_out ); + if( opt.qpfile ) + fclose( opt.qpfile ); -#ifdef PTW32_STATIC_LIB - pthread_win32_thread_detach_np(); - pthread_win32_process_detach_np(); +#ifdef _WIN32 + SetConsoleTitleW( org_console_title ); + free( argv ); #endif return ret; } -static char const *strtable_lookup( const char * const table[], int index ) +static char const *strtable_lookup( const char * const table[], int idx ) { int i = 0; while( table[i] ) i++; - return ( ( index >= 0 && index < i ) ? table[ index ] : "???" ); + return ( ( idx >= 0 && idx < i ) ? table[ idx ] : "???" ); } static char *stringify_names( char *buf, const char * const names[] ) @@ -196,27 +420,70 @@ static char *stringify_names( char *buf, const char * const names[] ) return buf; } -/***************************************************************************** - * Help: - *****************************************************************************/ -static void Help( x264_param_t *defaults, int longhelp ) +static void print_csp_names( int longhelp ) +{ + if( longhelp < 2 ) + return; +# define INDENT " " + printf( " - valid csps for `raw' demuxer:\n" ); + printf( INDENT ); + for( int i = X264_CSP_NONE+1; i < X264_CSP_CLI_MAX; i++ ) + { + if( x264_cli_csps[i].name ) + { + printf( "%s", x264_cli_csps[i].name ); + if( i+1 < X264_CSP_CLI_MAX ) + printf( ", " ); + } + } +#if HAVE_LAVF + printf( "\n" ); + printf( " - valid csps for `lavf' demuxer:\n" ); + printf( INDENT ); + size_t line_len = strlen( INDENT ); + for( enum AVPixelFormat i = AV_PIX_FMT_NONE+1; i < AV_PIX_FMT_NB; i++ ) + { + const char *pfname = av_get_pix_fmt_name( i ); + if( pfname ) + { + size_t name_len = strlen( pfname ); + if( line_len + name_len > (80 - strlen( ", " )) ) + { + printf( "\n" INDENT ); + line_len = strlen( INDENT ); + } + printf( "%s", pfname ); + line_len += name_len; + if( i+1 < AV_PIX_FMT_NB ) + { + printf( ", " ); + line_len += 2; + } + } + } +#endif + printf( "\n" ); +} + +static void help( x264_param_t *defaults, int longhelp ) { char buf[50]; #define H0 printf #define H1 if(longhelp>=1) printf #define H2 if(longhelp==2) printf H0( "x264 core:%d%s\n" - "Syntax: x264 [options] -o outfile infile [widthxheight]\n" + "Syntax: x264 [options] -o outfile infile\n" "\n" - "Infile can be raw YUV 4:2:0 (in which case resolution is required),\n" - " or YUV4MPEG 4:2:0 (*.y4m),\n" + "Infile can be raw (in which case resolution is required),\n" + " or YUV4MPEG (*.y4m),\n" " or Avisynth if compiled with support (%s).\n" " or libav* formats if compiled with lavf support (%s) or ffms support (%s).\n" "Outfile type is selected by filename:\n" " .264 -> Raw bytestream\n" " .mkv -> Matroska\n" " .flv -> Flash Video\n" - " .mp4 -> MP4 if compiled with GPAC support (%s)\n" + " .mp4 -> MP4 if compiled with GPAC or L-SMASH support (%s)\n" + "Output bit depth: %d (configured at compile time)\n" "\n" "Options:\n" "\n" @@ -225,26 +492,29 @@ static void Help( x264_param_t *defaults, int longhelp ) " --fullhelp List all options\n" "\n", X264_BUILD, X264_VERSION, -#ifdef AVS_INPUT +#if HAVE_AVS "yes", #else "no", #endif -#ifdef LAVF_INPUT +#if HAVE_LAVF "yes", #else "no", #endif -#ifdef FFMS_INPUT +#if HAVE_FFMS "yes", #else "no", #endif -#ifdef MP4_OUTPUT - "yes" +#if HAVE_GPAC + "gpac", +#elif HAVE_LSMASH + "lsmash", #else - "no" + "no", #endif + x264_bit_depth ); H0( "Example usage:\n" ); H0( "\n" ); @@ -256,7 +526,7 @@ static void Help( x264_param_t *defaults, int longhelp ) H0( " x264 --pass 2 --bitrate 1000 -o \n" ); H0( "\n" ); H0( " Lossless:\n" ); - H0( " x264 --crf 0 -o \n" ); + H0( " x264 --qp 0 -o \n" ); H0( "\n" ); H0( " Maximum PSNR at the cost of speed and visual quality:\n" ); H0( " x264 --preset placebo --tune psnr -o \n" ); @@ -266,9 +536,12 @@ static void Help( x264_param_t *defaults, int longhelp ) H0( "\n" ); H0( "Presets:\n" ); H0( "\n" ); - H0( " --profile Force the limits of an H.264 profile [high]\n" + H0( " --profile Force the limits of an H.264 profile\n" " Overrides all settings.\n" ); - H2( " - baseline:\n" + H2( +#if X264_CHROMA_FORMAT <= X264_CSP_I420 +#if X264_BIT_DEPTH==8 + " - baseline:\n" " --no-8x8dct --bframes 0 --no-cabac\n" " --cqm flat --weightp 0\n" " No interlaced.\n" @@ -277,29 +550,56 @@ static void Help( x264_param_t *defaults, int longhelp ) " --no-8x8dct --cqm flat\n" " No lossless.\n" " - high:\n" - " No lossless.\n" ); - else H0( " - baseline,main,high\n" ); - H0( " --preset Use a preset to select encoding settings [medium]\n" + " No lossless.\n" +#endif + " - high10:\n" + " No lossless.\n" + " Support for bit depth 8-10.\n" +#endif +#if X264_CHROMA_FORMAT <= X264_CSP_I422 + " - high422:\n" + " No lossless.\n" + " Support for bit depth 8-10.\n" + " Support for 4:2:0/4:2:2 chroma subsampling.\n" +#endif + " - high444:\n" + " Support for bit depth 8-10.\n" + " Support for 4:2:0/4:2:2/4:4:4 chroma subsampling.\n" ); + else H0( + " - " +#if X264_CHROMA_FORMAT <= X264_CSP_I420 +#if X264_BIT_DEPTH==8 + "baseline,main,high," +#endif + "high10," +#endif +#if X264_CHROMA_FORMAT <= X264_CSP_I422 + "high422," +#endif + "high444\n" + ); + H0( " --preset Use a preset to select encoding settings [medium]\n" " Overridden by user settings.\n" ); H2( " - ultrafast:\n" " --no-8x8dct --aq-mode 0 --b-adapt 0\n" " --bframes 0 --no-cabac --no-deblock\n" " --no-mbtree --me dia --no-mixed-refs\n" - " --partitions none --ref 1 --scenecut 0\n" - " --subme 0 --trellis 0 --no-weightb\n" - " --weightp 0\n" + " --partitions none --rc-lookahead 0 --ref 1\n" + " --scenecut 0 --subme 0 --trellis 0\n" + " --no-weightb --weightp 0\n" " - superfast:\n" " --no-mbtree --me dia --no-mixed-refs\n" - " --partitions i8x8,i4x4 --ref 1\n" - " --subme 1 --trellis 0 --weightp 0\n" + " --partitions i8x8,i4x4 --rc-lookahead 0\n" + " --ref 1 --subme 1 --trellis 0 --weightp 1\n" " - veryfast:\n" - " --no-mbtree --no-mixed-refs --ref 1\n" - " --subme 2 --trellis 0 --weightp 0\n" + " --no-mixed-refs --rc-lookahead 10\n" + " --ref 1 --subme 2 --trellis 0 --weightp 1\n" " - faster:\n" " --no-mixed-refs --rc-lookahead 20\n" " --ref 2 --subme 4 --weightp 1\n" " - fast:\n" " --rc-lookahead 30 --ref 2 --subme 6\n" + " --weightp 1\n" " - medium:\n" " Default settings apply.\n" " - slow:\n" @@ -318,11 +618,11 @@ static void Help( x264_param_t *defaults, int longhelp ) " --bframes 16 --b-adapt 2 --direct auto\n" " --slow-firstpass --no-fast-pskip\n" " --me tesa --merange 24 --partitions all\n" - " --rc-lookahead 60 --ref 16 --subme 10\n" + " --rc-lookahead 60 --ref 16 --subme 11\n" " --trellis 2\n" ); else H0( " - ultrafast,superfast,veryfast,faster,fast\n" " - medium,slow,slower,veryslow,placebo\n" ); - H0( " --tune Tune the settings for a particular type of source\n" + H0( " --tune Tune the settings for a particular type of source\n" " or situation\n" " Overridden by user settings.\n" " Multiple tunings are separated by commas.\n" @@ -350,8 +650,9 @@ static void Help( x264_param_t *defaults, int longhelp ) " --no-cabac --no-deblock --no-weightb\n" " --weightp 0\n" " - zerolatency:\n" - " --bframes 0 --force-cfr --rc-lookahead 0\n" - " --sync-lookahead 0 --sliced-threads\n" ); + " --bframes 0 --force-cfr --no-mbtree\n" + " --sync-lookahead 0 --sliced-threads\n" + " --rc-lookahead 0\n" ); else H0( " - psy tunings: film,animation,grain,\n" " stillimage,psnr,ssim\n" " - other tunings: fastdecode,zerolatency\n" ); @@ -363,7 +664,7 @@ static void Help( x264_param_t *defaults, int longhelp ) H0( "\n" ); H0( "Frame-type options:\n" ); H0( "\n" ); - H0( " -I, --keyint Maximum GOP size [%d]\n", defaults->i_keyint_max ); + H0( " -I, --keyint Maximum GOP size [%d]\n", defaults->i_keyint_max ); H2( " -i, --min-keyint Minimum GOP size [auto]\n" ); H2( " --no-scenecut Disable adaptive I-frame decision\n" ); H2( " --scenecut How aggressively to insert extra I-frames [%d]\n", defaults->i_scenecut_threshold ); @@ -380,6 +681,8 @@ static void Help( x264_param_t *defaults, int longhelp ) " - strict: Strictly hierarchical pyramid\n" " - normal: Non-strict (not Blu-ray compatible)\n", strtable_lookup( x264_b_pyramid_names, defaults->i_bframe_pyramid ) ); + H1( " --open-gop Use recovery points to close GOPs\n" + " Only available with b-frames\n" ); H1( " --no-cabac Disable CABAC\n" ); H1( " -r, --ref Number of reference frames [%d]\n", defaults->i_frame_reference ); H1( " --no-deblock Disable loop filter\n" ); @@ -388,8 +691,11 @@ static void Help( x264_param_t *defaults, int longhelp ) H2( " --slices Number of slices per frame; forces rectangular\n" " slices and is overridden by other slicing options\n" ); else H1( " --slices Number of slices per frame\n" ); + H2( " --slices-max Absolute maximum slices per frame; overrides\n" + " slice-max-size/slice-max-mbs when necessary\n" ); H2( " --slice-max-size Limit the size of each slice in bytes\n"); - H2( " --slice-max-mbs Limit the size of each slice in macroblocks\n"); + H2( " --slice-max-mbs Limit the size of each slice in macroblocks (max)\n"); + H2( " --slice-min-mbs Limit the size of each slice in macroblocks (min)\n"); H0( " --tff Enable interlaced mode (top field first)\n" ); H0( " --bff Enable interlaced mode (bottom field first)\n" ); H2( " --constrained-intra Enable constrained intra prediction.\n" ); @@ -398,12 +704,21 @@ static void Help( x264_param_t *defaults, int longhelp ) H2( " --fake-interlaced Flag stream as interlaced but encode progressive.\n" " Makes it possible to encode 25p and 30p Blu-Ray\n" " streams. Ignored in interlaced mode.\n" ); + H2( " --frame-packing For stereoscopic videos define frame arrangement\n" + " - 0: checkerboard - pixels are alternatively from L and R\n" + " - 1: column alternation - L and R are interlaced by column\n" + " - 2: row alternation - L and R are interlaced by row\n" + " - 3: side by side - L is on the left, R on the right\n" + " - 4: top bottom - L is on top, R on bottom\n" + " - 5: frame alternation - one view per frame\n" + " - 6: mono - 2D frame without any frame packing\n" + " - 7: tile format - L is on top-left, R split across\n" ); H0( "\n" ); H0( "Ratecontrol:\n" ); H0( "\n" ); - H1( " -q, --qp Force constant QP (0-51, 0=lossless)\n" ); + H1( " -q, --qp Force constant QP (0-%d, 0=lossless)\n", QP_MAX ); H0( " -B, --bitrate Set bitrate (kbit/s)\n" ); - H0( " --crf Quality-based VBR (0-51, 0=lossless) [%.1f]\n", defaults->rc.f_rf_constant ); + H0( " --crf Quality-based VBR (%d-51) [%.1f]\n", 51 - QP_MAX_SPEC, defaults->rc.f_rf_constant ); H1( " --rc-lookahead Number of frames for frametype lookahead [%d]\n", defaults->rc.i_lookahead ); H0( " --vbv-maxrate Max local bitrate (kbit/s) [%d]\n", defaults->rc.i_vbv_max_bitrate ); H0( " --vbv-bufsize Set size of the VBV buffer (kbit) [%d]\n", defaults->rc.i_vbv_buffer_size ); @@ -420,7 +735,8 @@ static void Help( x264_param_t *defaults, int longhelp ) H2( " --aq-mode AQ method [%d]\n" " - 0: Disabled\n" " - 1: Variance AQ (complexity mask)\n" - " - 2: Auto-variance AQ (experimental)\n", defaults->rc.i_aq_mode ); + " - 2: Auto-variance AQ\n" + " - 3: Auto-variance AQ with bias to dark scenes\n", defaults->rc.i_aq_mode ); H1( " --aq-strength Reduces blocking and blurring in flat and\n" " textured areas. [%.1f]\n", defaults->rc.f_aq_strength ); H1( "\n" ); @@ -441,9 +757,18 @@ static void Help( x264_param_t *defaults, int longhelp ) " or b= (bitrate multiplier)\n" ); H2( " --qpfile Force frametypes and QPs for some or all frames\n" " Format of each line: framenumber frametype QP\n" - " QP of -1 lets x264 choose. Frametypes: I,i,P,B,b.\n" + " QP is optional (none lets x264 choose). Frametypes: I,i,K,P,B,b.\n" + " K= depending on open-gop setting\n" " QPs are restricted by qpmin/qpmax.\n" ); H1( "\n" ); + + H1( "Speedcontrol:\n" ); + H1( "\n" ); + H1( " --speed Automatically adjust other options to achieve this\n" ); + H1( " fraction of realtime.\n" ); + H1( " --speed-bufsize Averaging period for speed. (in frames) [%d]\n", defaults->sc.i_buffer_size ); + H1( "\n" ); + H1( "Analysis:\n" ); H1( "\n" ); H1( " -A, --partitions Partitions to consider [\"p8x8,b8x8,i8x8,i4x4\"]\n" @@ -456,8 +781,8 @@ static void Help( x264_param_t *defaults, int longhelp ) H2( " --no-weightb Disable weighted prediction for B-frames\n" ); H1( " --weightp Weighted prediction for P-frames [%d]\n" " - 0: Disabled\n" - " - 1: Blind offset\n" - " - 2: Smart analysis\n", defaults->analyse.i_weighted_pred ); + " - 1: Weighted refs\n" + " - 2: Weighted refs + Duplicates\n", defaults->analyse.i_weighted_pred ); H1( " --me Integer pixel motion estimation method [\"%s\"]\n", strtable_lookup( x264_motion_est_names, defaults->analyse.i_me_method ) ); H2( " - dia: diamond search, radius 1 (fast)\n" @@ -478,9 +803,10 @@ static void Help( x264_param_t *defaults, int longhelp ) " - 7: RD mode decision for all frames\n" " - 8: RD refinement for I/P-frames\n" " - 9: RD refinement for all frames\n" - " - 10: QP-RD - requires trellis=2, aq-mode>0\n" ); - else H1( " decision quality: 1=fast, 10=best.\n" ); - H1( " --psy-rd Strength of psychovisual optimization [\"%.1f:%.1f\"]\n" + " - 10: QP-RD - requires trellis=2, aq-mode>0\n" + " - 11: Full RD: disable all early terminations\n" ); + else H1( " decision quality: 1=fast, 11=best\n" ); + H1( " --psy-rd Strength of psychovisual optimization [\"%.1f:%.1f\"]\n" " #1: RD (requires subme>=6)\n" " #2: Trellis (requires trellis, experimental)\n", defaults->analyse.f_psy_rd, defaults->analyse.f_psy_trellis ); @@ -489,7 +815,7 @@ static void Help( x264_param_t *defaults, int longhelp ) H2( " --no-mixed-refs Don't decide references on a per partition basis\n" ); H2( " --no-chroma-me Ignore chroma in motion estimation\n" ); H1( " --no-8x8dct Disable adaptive spatial transform size\n" ); - H1( " -t, --trellis Trellis RD quantization. Requires CABAC. [%d]\n" + H1( " -t, --trellis Trellis RD quantization. [%d]\n" " - 0: disabled\n" " - 1: enabled only on the final encode of a MB\n" " - 2: enabled on all mode decisions\n", defaults->analyse.i_trellis ); @@ -508,9 +834,9 @@ static void Help( x264_param_t *defaults, int longhelp ) " Takes a comma-separated list of 16 integers.\n" ); H2( " --cqm8 Set all 8x8 quant matrices\n" " Takes a comma-separated list of 64 integers.\n" ); - H2( " --cqm4i, --cqm4p, --cqm8i, --cqm8p\n" + H2( " --cqm4i, --cqm4p, --cqm8i, --cqm8p \n" " Set both luma and chroma quant matrices\n" ); - H2( " --cqm4iy, --cqm4ic, --cqm4py, --cqm4pc\n" + H2( " --cqm4iy, --cqm4ic, --cqm4py, --cqm4pc \n" " Set individual quant matrices\n" ); H2( "\n" ); H2( "Video Usability Info (Annex E):\n" ); @@ -523,56 +849,83 @@ static void Help( x264_param_t *defaults, int longhelp ) H2( " --videoformat Specify video format [\"%s\"]\n" " - component, pal, ntsc, secam, mac, undef\n", strtable_lookup( x264_vidformat_names, defaults->vui.i_vidformat ) ); - H2( " --fullrange Specify full range samples setting [\"%s\"]\n" - " - off, on\n", - strtable_lookup( x264_fullrange_names, defaults->vui.b_fullrange ) ); + H2( " --range Specify color range [\"%s\"]\n" + " - %s\n", range_names[0], stringify_names( buf, range_names ) ); H2( " --colorprim Specify color primaries [\"%s\"]\n" - " - undef, bt709, bt470m, bt470bg\n" - " smpte170m, smpte240m, film\n", + " - undef, bt709, bt470m, bt470bg, smpte170m,\n" + " smpte240m, film, bt2020\n", strtable_lookup( x264_colorprim_names, defaults->vui.i_colorprim ) ); H2( " --transfer Specify transfer characteristics [\"%s\"]\n" - " - undef, bt709, bt470m, bt470bg, linear,\n" - " log100, log316, smpte170m, smpte240m\n", + " - undef, bt709, bt470m, bt470bg, smpte170m,\n" + " smpte240m, linear, log100, log316,\n" + " iec61966-2-4, bt1361e, iec61966-2-1,\n" + " bt2020-10, bt2020-12\n", strtable_lookup( x264_transfer_names, defaults->vui.i_transfer ) ); H2( " --colormatrix Specify color matrix setting [\"%s\"]\n" - " - undef, bt709, fcc, bt470bg\n" - " smpte170m, smpte240m, GBR, YCgCo\n", + " - undef, bt709, fcc, bt470bg, smpte170m,\n" + " smpte240m, GBR, YCgCo, bt2020nc, bt2020c\n", strtable_lookup( x264_colmatrix_names, defaults->vui.i_colmatrix ) ); H2( " --chromaloc Specify chroma sample location (0 to 5) [%d]\n", defaults->vui.i_chroma_loc ); H2( " --nal-hrd Signal HRD information (requires vbv-bufsize)\n" " - none, vbr, cbr (cbr not allowed in .mp4)\n" ); + H2( " --filler Force hard-CBR and generate filler (implied by\n" + " --nal-hrd cbr)\n" ); H2( " --pic-struct Force pic_struct in Picture Timing SEI\n" ); + H2( " --crop-rect Add 'left,top,right,bottom' to the bitstream-level\n" + " cropping rectangle\n" ); H0( "\n" ); H0( "Input/Output:\n" ); H0( "\n" ); - H0( " -o, --output Specify output file\n" ); + H0( " -o, --output Specify output file\n" ); H1( " --muxer Specify output container format [\"%s\"]\n" " - %s\n", muxer_names[0], stringify_names( buf, muxer_names ) ); H1( " --demuxer Specify input container format [\"%s\"]\n" " - %s\n", demuxer_names[0], stringify_names( buf, demuxer_names ) ); + H1( " --input-fmt Specify input file format (requires lavf support)\n" ); + H1( " --input-csp Specify input colorspace format for raw input\n" ); + print_csp_names( longhelp ); + H1( " --output-csp Specify output colorspace [\"%s\"]\n" + " - %s\n", output_csp_names[0], stringify_names( buf, output_csp_names ) ); + H1( " --input-depth Specify input bit depth for raw input\n" ); + H1( " --input-range Specify input color range [\"%s\"]\n" + " - %s\n", range_names[0], stringify_names( buf, range_names ) ); + H1( " --input-res Specify input resolution (width x height)\n" ); H1( " --index Filename for input index file\n" ); H0( " --sar width:height Specify Sample Aspect Ratio\n" ); H0( " --fps Specify framerate\n" ); H0( " --seek First frame to encode\n" ); H0( " --frames Maximum number of frames to encode\n" ); H0( " --level Specify level (as defined by Annex A)\n" ); + H1( " --bluray-compat Enable compatibility hacks for Blu-ray support\n" ); + H1( " --avcintra-class Use compatibility hacks for AVC-Intra class\n" + " - 50, 100, 200\n" ); + H1( " --stitchable Don't optimize headers based on video content\n" + " Ensures ability to recombine a segmented encode\n" ); H1( "\n" ); H1( " -v, --verbose Print stats for each frame\n" ); H1( " --no-progress Don't show the progress indicator while encoding\n" ); H0( " --quiet Quiet Mode\n" ); + H1( " --log-level Specify the maximum level of logging [\"%s\"]\n" + " - %s\n", strtable_lookup( log_level_names, cli_log_level - X264_LOG_NONE ), + stringify_names( buf, log_level_names ) ); H1( " --psnr Enable PSNR computation\n" ); H1( " --ssim Enable SSIM computation\n" ); H1( " --threads Force a specific number of threads\n" ); + H2( " --lookahead-threads Force a specific number of lookahead threads\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" ); H2( " --non-deterministic Slightly improve quality of SMP, at the cost of repeatability\n" ); + H2( " --cpu-independent Ensure exact reproducibility across different cpus,\n" + " as opposed to letting them select different algorithms\n" ); H2( " --asm Override CPU detection\n" ); H2( " --no-asm Disable all CPU optimizations\n" ); - H2( " --visualize Show MB types overlayed on the encoded video\n" ); + H2( " --opencl Enable use of OpenCL\n" ); + H2( " --opencl-clbin Specify path of compiled OpenCL kernel cache\n" ); + H2( " --opencl-device Specify OpenCL device ordinal\n" ); H2( " --dump-yuv Save reconstructed frames\n" ); H2( " --sps-id Set SPS and PPS id numbers [%d]\n", defaults->i_sps_id ); H2( " --aud Use access unit delimiters\n" ); @@ -582,31 +935,54 @@ static void Help( x264_param_t *defaults, int longhelp ) H2( " --timebase Specify timebase numerator and denominator\n" " Specify timebase numerator for input timecode file\n" " or specify timebase denominator for other input\n" ); + H2( " --dts-compress Eliminate initial delay with container DTS hack\n" ); + H0( "\n" ); + H0( "Filtering:\n" ); + H0( "\n" ); + H0( " --vf, --video-filter //... Apply video filtering to the input file\n" ); + H0( "\n" ); + H0( " Filter options may be specified in :