?? x264.c
字號(hào):
#define ENC_CIF
static int Init_param(x264_param_t *param, cli_opt_t *opt )
{
char *psz_filename = NULL;
// x264_param_t defaults = *param;
#ifdef ENC_CIF
char *Input_filename = "J:\\videos\\clip_cif_4250.yuv";
char *Output_filename = "G:\\test\\clip_cif_pc.264";
#else
char *Input_filename = "J:\\videos\\clip_D1.yuv";
char *Output_filename = "G:\\test\\clip_D1_test.264";
#endif
// char *psz;
int b_avis = 0;
int b_y4m = 0;
int b_thread_input = 0;
memset( opt, 0, sizeof(cli_opt_t) );
/* Default input file driver */
p_open_infile = open_file_yuv;
p_get_frame_total = get_frame_total_yuv;
p_read_frame = read_frame_yuv;
p_close_infile = close_file_yuv;
/* Default output file driver */
p_open_outfile = open_file_bsf;
p_set_outfile_param = set_param_bsf;
p_write_nalu = write_nalu_bsf;
p_set_eop = set_eop_bsf;
p_close_outfile = close_file_bsf;
param->i_log_level = X264_LOG_DEBUG;
param->i_keyint_max = 50;
param->i_bframe = 0;
param->b_cabac = 0;
param->analyse.i_me_method = 1; //hex
param->analyse.i_subpel_refine = 1;
param->rc.i_rc_method = X264_RC_ABR;
#ifndef CONST_QP
param->rc.i_rc_method = X264_RC_CQP;
param->rc.i_qp_constant = 28;
#endif
#ifdef ENC_CIF
param->i_frame_total = 4250;
param->i_width = 352;
param->i_height = 288;
param->rc.i_bitrate = 300;
#else
param->i_frame_total = 750;
param->i_width = 720;
param->i_height = 480;
param->rc.i_bitrate = 1000;
#endif
/* Parse command line options */
if( p_open_outfile( Output_filename, &opt->hout ) )
{
fprintf( stderr, "x264 [error]: can't open output file `%s'\n", optarg );
return -1;
}
if( p_open_infile( Input_filename, &opt->hin, param ) )
{
fprintf( stderr, "x264 [error]: could not open input file '%s'\n", psz_filename );
return -1;
}
return 0;
}
static int Parse( int argc, char **argv,
x264_param_t *param, cli_opt_t *opt )
{
char *psz_filename = NULL;
x264_param_t defaults = *param;
char *psz;
int b_avis = 0;
int b_y4m = 0;
int b_thread_input = 0;
memset( opt, 0, sizeof(cli_opt_t) );
/* Default input file driver */
p_open_infile = open_file_yuv;
p_get_frame_total = get_frame_total_yuv;
p_read_frame = read_frame_yuv;
p_close_infile = close_file_yuv;
/* Default output file driver */
p_open_outfile = open_file_bsf;
p_set_outfile_param = set_param_bsf;
p_write_nalu = write_nalu_bsf;
p_set_eop = set_eop_bsf;
p_close_outfile = close_file_bsf;
/* Parse command line options */
for( ;; )
{
int b_error = 0;
int long_options_index = -1;
#define OPT_FRAMES 256
#define OPT_SEEK 257
#define OPT_QPFILE 258
#define OPT_THREAD_INPUT 259
#define OPT_QUIET 260
#define OPT_PROGRESS 261
#define OPT_VISUALIZE 262
#define OPT_LONGHELP 263
static struct option long_options[] =
{
{ "help", no_argument, NULL, 'h' },
{ "longhelp",no_argument, NULL, OPT_LONGHELP },
{ "version", no_argument, NULL, 'V' },
{ "bitrate", required_argument, NULL, 'B' },
{ "bframes", required_argument, NULL, 'b' },
{ "no-b-adapt", no_argument, NULL, 0 },
{ "b-bias", required_argument, NULL, 0 },
{ "b-pyramid", no_argument, NULL, 0 },
{ "min-keyint",required_argument,NULL,'i' },
{ "keyint", required_argument, NULL, 'I' },
{ "scenecut",required_argument, NULL, 0 },
{ "nf", no_argument, NULL, 0 },
{ "filter", required_argument, NULL, 'f' },
{ "no-cabac",no_argument, NULL, 0 },
{ "qp", required_argument, NULL, 'q' },
{ "qpmin", required_argument, NULL, 0 },
{ "qpmax", required_argument, NULL, 0 },
{ "qpstep", required_argument, NULL, 0 },
{ "crf", required_argument, NULL, 0 },
{ "ref", required_argument, NULL, 'r' },
{ "no-asm", no_argument, NULL, 0 },
{ "sar", required_argument, NULL, 0 },
{ "fps", required_argument, NULL, 0 },
{ "frames", required_argument, NULL, OPT_FRAMES },
{ "seek", required_argument, NULL, OPT_SEEK },
{ "output", required_argument, NULL, 'o' },
{ "analyse", required_argument, NULL, 'A' },
{ "direct", required_argument, NULL, 0 },
{ "weightb", no_argument, NULL, 'w' },
{ "me", required_argument, NULL, 0 },
{ "merange", required_argument, NULL, 0 },
{ "subme", required_argument, NULL, 'm' },
{ "b-rdo", no_argument, NULL, 0 },
{ "mixed-refs", no_argument, NULL, 0 },
{ "no-chroma-me", no_argument, NULL, 0 },
{ "bime", no_argument, NULL, 0 },
{ "8x8dct", no_argument, NULL, '8' },
{ "trellis", required_argument, NULL, 't' },
{ "no-fast-pskip", no_argument, NULL, 0 },
{ "no-dct-decimate", no_argument, NULL, 0 },
{ "level", required_argument, NULL, 0 },
{ "ratetol", required_argument, NULL, 0 },
{ "vbv-maxrate", required_argument, NULL, 0 },
{ "vbv-bufsize", required_argument, NULL, 0 },
{ "vbv-init", required_argument,NULL, 0 },
{ "ipratio", required_argument, NULL, 0 },
{ "pbratio", required_argument, NULL, 0 },
{ "chroma-qp-offset", required_argument, NULL, 0 },
{ "pass", required_argument, NULL, 'p' },
{ "stats", required_argument, NULL, 0 },
{ "rceq", required_argument, NULL, 0 },
{ "qcomp", required_argument, NULL, 0 },
{ "qblur", required_argument, NULL, 0 },
{ "cplxblur",required_argument, NULL, 0 },
{ "zones", required_argument, NULL, 0 },
{ "qpfile", required_argument, NULL, OPT_QPFILE },
{ "threads", required_argument, NULL, 0 },
{ "thread-input", no_argument, NULL, OPT_THREAD_INPUT },
{ "no-psnr", no_argument, NULL, 0 },
{ "quiet", no_argument, NULL, OPT_QUIET },
{ "verbose", no_argument, NULL, 'v' },
{ "progress",no_argument, NULL, OPT_PROGRESS },
{ "visualize",no_argument, NULL, OPT_VISUALIZE },
{ "sps-id", required_argument, NULL, 0 },
{ "aud", no_argument, NULL, 0 },
{ "nr", required_argument, NULL, 0 },
{ "cqm", required_argument, NULL, 0 },
{ "cqmfile", required_argument, NULL, 0 },
{ "cqm4", required_argument, NULL, 0 },
{ "cqm4i", required_argument, NULL, 0 },
{ "cqm4iy", required_argument, NULL, 0 },
{ "cqm4ic", required_argument, NULL, 0 },
{ "cqm4p", required_argument, NULL, 0 },
{ "cqm4py", required_argument, NULL, 0 },
{ "cqm4pc", required_argument, NULL, 0 },
{ "cqm8", required_argument, NULL, 0 },
{ "cqm8i", required_argument, NULL, 0 },
{ "cqm8p", required_argument, NULL, 0 },
{ "overscan", required_argument, NULL, 0 },
{ "videoformat", required_argument, NULL, 0 },
{ "fullrange", required_argument, NULL, 0 },
{ "colorprim", required_argument, NULL, 0 },
{ "transfer", required_argument, NULL, 0 },
{ "colormatrix", required_argument, NULL, 0 },
{ "chromaloc", required_argument, NULL, 0 },
{0, 0, 0, 0}
};
int c = getopt_long( argc, argv, "8A:B:b:f:hI:i:m:o:p:q:r:t:Vvw",
long_options, &long_options_index);
if( c == -1 )
{
break;
}
switch( c )
{
case 'h':
Help( &defaults, 0 );
exit(0);
case OPT_LONGHELP:
Help( &defaults, 1 );
exit(0);
case 'V':
#ifdef X264_POINTVER
printf( "x264 "X264_POINTVER"\n" );
#else
printf( "x264 0.%d.X\n", X264_BUILD );
#endif
exit(0);
case OPT_FRAMES:
param->i_frame_total = atoi( optarg );
break;
case OPT_SEEK:
opt->i_seek = atoi( optarg );
break;
case 'o':
if( !strncasecmp(optarg + strlen(optarg) - 4, ".mp4", 4) )
{
#ifdef MP4_OUTPUT
p_open_outfile = open_file_mp4;
p_write_nalu = write_nalu_mp4;
p_set_outfile_param = set_param_mp4;
p_set_eop = set_eop_mp4;
p_close_outfile = close_file_mp4;
#else
fprintf( stderr, "x264 [error]: not compiled with MP4 output support\n" );
return -1;
#endif
}
else if( !strncasecmp(optarg + strlen(optarg) - 4, ".mkv", 4) )
{
p_open_outfile = open_file_mkv;
p_write_nalu = write_nalu_mkv;
p_set_outfile_param = set_param_mkv;
p_set_eop = set_eop_mkv;
p_close_outfile = close_file_mkv;
}
if( !strcmp(optarg, "-") )
opt->hout = stdout;
else if( p_open_outfile( optarg, &opt->hout ) )
{
fprintf( stderr, "x264 [error]: can't open output file `%s'\n", optarg );
return -1;
}
break;
case OPT_QPFILE:
opt->qpfile = fopen( optarg, "r" );
if( !opt->qpfile )
{
fprintf( stderr, "x264 [error]: can't open `%s'\n", optarg );
return -1;
}
param->i_scenecut_threshold = -1;
param->b_bframe_adaptive = 0;
break;
case OPT_THREAD_INPUT:
b_thread_input = 1;
break;
case OPT_QUIET:
param->i_log_level = X264_LOG_NONE;
param->analyse.b_psnr = 0;
break;
case 'v':
param->i_log_level = X264_LOG_DEBUG;
break;
case OPT_PROGRESS:
opt->b_progress = 1;
break;
case OPT_VISUALIZE:
#ifdef VISUALIZE
param->b_visualize = 1;
b_exit_on_ctrl_c = 1;
#else
fprintf( stderr, "x264 [warning]: not compiled with visualization support\n" );
#endif
break;
default:
{
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -