Commit 9591b038 authored by Loren Merritt's avatar Loren Merritt

smarter parsing of resolution from commandline


git-svn-id: svn://svn.videolan.org/x264/trunk@149 df754926-b1dd-0310-bc7b-ec298dee348c
parent 4337ee8d
......@@ -477,41 +477,30 @@ static int Parse( int argc, char **argv,
if( !(*pb_decompress) )
{
char *psz_size = NULL;
char *p;
if( optind > argc - 1 )
{
char *psz = psz_filename;
char *x = NULL;
char *psz;
/* try to parse the file name */
while( *psz )
for( psz = psz_filename; *psz; psz++ )
{
while( *psz && ( *psz < '0' || *psz > '9' ) ) psz++;
x = strchr( psz, 'x' );
if( !x )
break;
if( ( x[1] >= '0' && x[1] <= '9' ) )
if( *psz >= '0' && *psz <= '9'
&& sscanf( psz, "%ux%u", &param->i_width, &param->i_height ) == 2 )
{
psz_size = psz;
fprintf( stderr, "x264: file name gives %dx%d\n", param->i_width, param->i_height );
break;
}
}
if( psz_size == NULL )
{
Help( &defaults );
return -1;
}
fprintf( stderr, "x264: file name gives %dx%d\n", atoi(psz), atoi(x+1) );
}
else
{
psz_size = argv[optind++];
sscanf( argv[optind++], "%ux%u", &param->i_width, &param->i_height );
}
param->i_width = strtol( psz_size, &p, 0 );
param->i_height = strtol( p+1, &p, 0 );
if( !param->i_width || !param->i_height )
{
Help( &defaults );
return -1;
}
}
/* open the input */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment