X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=common%2Fcommon.c;h=4b8f803a839e530fff09ec06571f5ba59f3b76d1;hb=54fd697668d0a04246ad0b0e9955a6583b2bb8b6;hp=28eec1f8b5e49a1af6ce96540d337c788cc53521;hpb=936e8da1a4f9d0431b181d0877bb1602d4de9441;p=x264 diff --git a/common/common.c b/common/common.c index 28eec1f8..4b8f803a 100644 --- a/common/common.c +++ b/common/common.c @@ -1,7 +1,7 @@ /***************************************************************************** * common.c: misc common functions ***************************************************************************** - * Copyright (C) 2003-2015 x264 project + * Copyright (C) 2003-2016 x264 project * * Authors: Loren Merritt * Laurent Aimar @@ -582,7 +582,6 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value ) int errortype = X264_PARAM_BAD_VALUE; int name_was_bool; int value_was_null = !value; - int i; if( !name ) return X264_PARAM_BAD_NAME; @@ -603,10 +602,11 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value ) name = name_buf; } - if( (!strncmp( name, "no-", 3 ) && (i = 3)) || - (!strncmp( name, "no", 2 ) && (i = 2)) ) + if( !strncmp( name, "no", 2 ) ) { - name += i; + name += 2; + if( name[0] == '-' ) + name++; value = atobool(value) ? "false" : "true"; } name_was_bool = 0; @@ -628,7 +628,9 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value ) p->cpu = 0; for( init=buf; (tok=strtok_r(init, ",", &saveptr)); init=NULL ) { - for( i=0; x264_cpu_names[i].flags && strcasecmp(tok, x264_cpu_names[i].name); i++ ); + int i = 0; + while( x264_cpu_names[i].flags && strcasecmp(tok, x264_cpu_names[i].name) ) + i++; p->cpu |= x264_cpu_names[i].flags; if( !x264_cpu_names[i].flags ) b_error = 1; @@ -703,14 +705,12 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value ) } OPT("fps") { - if( sscanf( value, "%u/%u", &p->i_fps_num, &p->i_fps_den ) == 2 ) - ; - else + if( sscanf( value, "%u/%u", &p->i_fps_num, &p->i_fps_den ) != 2 ) { - float fps = atof(value); - if( fps > 0 && fps <= INT_MAX/1000 ) + double fps = atof(value); + if( fps > 0.0 && fps <= INT_MAX/1000.0 ) { - p->i_fps_num = (int)(fps * 1000 + .5); + p->i_fps_num = (int)(fps * 1000.0 + .5); p->i_fps_den = 1000; } else @@ -1142,6 +1142,7 @@ int x264_picture_alloc( x264_picture_t *pic, int i_csp, int i_width, int i_heigh [X264_CSP_I420] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256/2, 256/2 } }, [X264_CSP_YV12] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256/2, 256/2 } }, [X264_CSP_NV12] = { 2, { 256*1, 256*1 }, { 256*1, 256/2 }, }, + [X264_CSP_NV21] = { 2, { 256*1, 256*1 }, { 256*1, 256/2 }, }, [X264_CSP_I422] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256*1, 256*1 } }, [X264_CSP_YV16] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256*1, 256*1 } }, [X264_CSP_NV16] = { 2, { 256*1, 256*1 }, { 256*1, 256*1 }, },