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

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, ...@@ -477,41 +477,30 @@ static int Parse( int argc, char **argv,
if( !(*pb_decompress) ) if( !(*pb_decompress) )
{ {
char *psz_size = NULL;
char *p;
if( optind > argc - 1 ) if( optind > argc - 1 )
{ {
char *psz = psz_filename; char *psz;
char *x = NULL;
/* try to parse the file name */ /* try to parse the file name */
while( *psz ) for( psz = psz_filename; *psz; psz++ )
{ {
while( *psz && ( *psz < '0' || *psz > '9' ) ) psz++; if( *psz >= '0' && *psz <= '9'
x = strchr( psz, 'x' ); && sscanf( psz, "%ux%u", &param->i_width, &param->i_height ) == 2 )
if( !x )
break;
if( ( x[1] >= '0' && x[1] <= '9' ) )
{ {
psz_size = psz; fprintf( stderr, "x264: file name gives %dx%d\n", param->i_width, param->i_height );
break; break;
} }
} }
if( psz_size == NULL )
{
Help( &defaults );
return -1;
}
fprintf( stderr, "x264: file name gives %dx%d\n", atoi(psz), atoi(x+1) );
} }
else else
{ {
psz_size = argv[optind++]; sscanf( argv[optind++], "%ux%u", &param->i_width, &param->i_height );
} }
param->i_width = strtol( psz_size, &p, 0 ); if( !param->i_width || !param->i_height )
param->i_height = strtol( p+1, &p, 0 ); {
Help( &defaults );
return -1;
}
} }
/* open the input */ /* 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