x264.c sscanf( t, "%ux%u", &w, &h )

    //x264.c中的代码

    psz_filename = argv[optind++];

    psz = psz_filename + strlen(psz_filename) - 1; 
    while( psz > psz_filename && *psz != '.' )
 {
        psz--; 
 }

 //这儿psz代表后缀“.avi /.avs/.y4m”

    if( !strncasecmp( psz, ".avi", 4 ) || !strncasecmp( psz, ".avs", 4 ) ) 
        b_avis = 1; 

    if( !strncasecmp( psz, ".y4m", 4 ) )

        b_y4m = 1;


    if( !(b_avis || b_y4m) )

    {      
        if( optind > argc - 1 )
        {

           //psz这儿重新赋值了,又是完整的文件名了

            for( psz = psz_filename; *psz; psz++ )
            {
                if( *psz >= '0' && *psz <= '9'
                    && sscanf( psz, "%ux%u", &param->i_width, &param->i_height ) == 2 ) 
                {
                    if( param->i_log_level >= X264_LOG_INFO )
                        fprintf( stderr, "x264 [info]: file name gives %dx%d\n", param->i_width, param->i_height );
                    break;
                }
            }
        }
        else
        {
            sscanf( argv[optind++], "%ux%u", &param->i_width, &param->i_height );

        }
    }
       
    if( !(b_avis || b_y4m) && ( !param->i_width || !param->i_height ) )
    {
        fprintf( stderr, "x264 [error]: Rawyuv input requires a resolution.\n" );
        return -1;
    }

 1
   

测试:

 #include "stdafx.h"
#include <string.h>
#include <iostream.h>

int main(int argc, char* argv[])
{

 char *t="100x200.yuv";
 int w,h;
 cout<<" "<< sscanf( t, "%ux%u", &w, &h ) <<"\n"; //返回值:成功则返回参数数目,失败则返回-1,错误原因存于errno中

 cout<<"w="<<w<<"\n";
 cout<<"h="<<h<<"\n";

 return 0;
}

 
x264.c sscanf( t, "%ux%u", &w, &h )
 
   

参考:

C/C++ char*类型字符串结尾符的问题:

http://social.msdn.microsoft.com/Forums/zh-CN/visualcpluszhchs/thread/d7d63cd2-f8db-4b08-8179-4f04bb7ccec6