From: Loren Merritt Date: Wed, 22 Dec 2004 20:52:13 +0000 (+0000) Subject: option '--frames' limits number of frames to encode. X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=457eaa93110fa95c393794d85bde7943b2d325bd;p=x264.git option '--frames' limits number of frames to encode. patch by Tuukka Toivonen git-svn-id: svn://svn.videolan.org/x264/trunk@70 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/common/common.c b/common/common.c index 243396fa..7b515606 100644 --- a/common/common.c +++ b/common/common.c @@ -54,6 +54,7 @@ void x264_param_default( x264_param_t *param ) param->vui.i_sar_height= 0; param->i_fps_num = 25; param->i_fps_den = 1; + param->i_maxframes = 0; /* Encoder parameters */ param->i_frame_reference = 1; diff --git a/x264.c b/x264.c index 3c1185e3..7ab863e5 100644 --- a/x264.c +++ b/x264.c @@ -138,6 +138,7 @@ static void Help( void ) " --subme Subpixel motion estimation quality\n" "\n" " -s, --sar width:height Specify Sample Aspect Ratio\n" + " --frames Maximum number of frames to encode\n" " -o, --output Specify output file\n" "\n" " --no-asm Disable any CPU optims\n" @@ -184,6 +185,7 @@ static int Parse( int argc, char **argv, #define OPT_SCENECUT 270 #define OPT_QBLUR 271 #define OPT_CPLXBLUR 272 +#define OPT_FRAMES 273 static struct option long_options[] = { @@ -203,6 +205,7 @@ static int Parse( int argc, char **argv, { "ref", required_argument, NULL, 'r' }, { "no-asm", no_argument, NULL, 'C' }, { "sar", required_argument, NULL, 's' }, + { "frames", required_argument, NULL, OPT_FRAMES }, { "output", required_argument, NULL, 'o' }, { "analyse", required_argument, NULL, 'A' }, { "subme", required_argument, NULL, OPT_SUBME }, @@ -293,6 +296,9 @@ static int Parse( int argc, char **argv, case 'C': param->cpu = 0; break; + case OPT_FRAMES: + param->i_maxframes = atoi( optarg ); + break; case'o': if( ( *p_fout = fopen( optarg, "wb" ) ) == NULL ) { @@ -620,6 +626,9 @@ static int Encode( x264_param_t *param, FILE *fyuv, FILE *fout ) int i; + if (param->i_maxframes!=0 && i_frame>=param->i_maxframes) + break; + /* read a frame */ if( fread( pic.img.plane[0], 1, param->i_width * param->i_height, fyuv ) <= 0 || fread( pic.img.plane[1], 1, param->i_width * param->i_height / 4, fyuv ) <= 0 || diff --git a/x264.h b/x264.h index 8c662921..bb2e1342 100644 --- a/x264.h +++ b/x264.h @@ -104,6 +104,7 @@ typedef struct int i_fps_num; int i_fps_den; + int i_maxframes; /* Maximum number of frames to read from input file and encode, 0=unlimited */ /* Bitstream parameters */ int i_frame_reference; /* Maximum number of reference frames */