From eaf2fc20c8579714a48523b7ab8c05373708a25f Mon Sep 17 00:00:00 2001 From: Anton Mitrofanov Date: Thu, 18 Aug 2016 22:14:22 +0300 Subject: [PATCH] Various cosmetics of semicolon use --- common/mips/mc-c.c | 4 +-- common/mvpred.c | 4 +-- common/ppc/quant.c | 4 +-- encoder/cabac.c | 2 +- encoder/macroblock.c | 4 +-- filters/filters.c | 8 ++--- filters/video/crop.c | 10 +++--- filters/video/depth.c | 6 ++-- filters/video/internal.c | 2 +- filters/video/resize.c | 26 ++++++++-------- filters/video/select_every.c | 10 +++--- input/avs.c | 30 +++++++++--------- input/ffms.c | 14 ++++----- input/lavf.c | 12 ++++---- input/raw.c | 2 +- input/thread.c | 2 +- input/timecode.c | 34 ++++++++++----------- input/y4m.c | 14 ++++----- output/matroska_ebml.c | 2 +- output/mp4.c | 8 ++--- output/mp4_lsmash.c | 22 +++++++++----- tools/checkasm.c | 2 +- x264.c | 59 +++++++++++++++++++----------------- x264cli.h | 11 ++++--- 24 files changed, 152 insertions(+), 140 deletions(-) diff --git a/common/mips/mc-c.c b/common/mips/mc-c.c index 04086bc8..cdf25ece 100644 --- a/common/mips/mc-c.c +++ b/common/mips/mc-c.c @@ -3430,7 +3430,7 @@ uint8_t *x264_get_ref_msa( uint8_t *p_dst, intptr_t *p_dst_stride, x264_mc_weight_w8_msa( p_dst, *p_dst_stride, p_dst, *p_dst_stride, pWeight, i_h4w ); - for( i_cnt = i_h4w; i_cnt < i_height ; i_cnt++ ) + for( i_cnt = i_h4w; i_cnt < i_height; i_cnt++ ) { uint64_t temp0; v16i8 zero = {0}; @@ -3666,7 +3666,7 @@ uint8_t *x264_get_ref_msa( uint8_t *p_dst, intptr_t *p_dst_stride, pWeight, i_h4w ); p_src1 = src1_org + i_h4w * i_src_stride; - for( i_cnt = i_h4w; i_cnt < i_height ; i_cnt++ ) + for( i_cnt = i_h4w; i_cnt < i_height; i_cnt++ ) { uint64_t u_temp0; v16i8 zero = {0}; diff --git a/common/mvpred.c b/common/mvpred.c index 2ab5d99c..067b93a8 100644 --- a/common/mvpred.c +++ b/common/mvpred.c @@ -370,8 +370,8 @@ static ALWAYS_INLINE int x264_mb_predict_mv_direct16x16_spatial( x264_t *h, int h->mb.i_partition = partition_col[0]; } } - int i_mb_4x4 = b_interlaced ? 4 * (h->mb.i_b4_stride*mb_y + mb_x) : h->mb.i_b4_xy ; - int i_mb_8x8 = b_interlaced ? 2 * (h->mb.i_b8_stride*mb_y + mb_x) : h->mb.i_b8_xy ; + int i_mb_4x4 = b_interlaced ? 4 * (h->mb.i_b4_stride*mb_y + mb_x) : h->mb.i_b4_xy; + int i_mb_8x8 = b_interlaced ? 2 * (h->mb.i_b8_stride*mb_y + mb_x) : h->mb.i_b8_xy; int8_t *l1ref0 = &h->fref[1][0]->ref[0][i_mb_8x8]; int8_t *l1ref1 = &h->fref[1][0]->ref[1][i_mb_8x8]; diff --git a/common/ppc/quant.c b/common/ppc/quant.c index 9cf05894..52d02a50 100644 --- a/common/ppc/quant.c +++ b/common/ppc/quant.c @@ -71,7 +71,7 @@ int x264_quant_4x4_altivec( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] vec_u32_t multEvenvA, multOddvA; vec_u16_t mfvA; vec_u16_t biasvA; - vec_s16_t one = vec_splat_s16(1);; + vec_s16_t one = vec_splat_s16(1); vec_s16_t nz = zero_s16v; vector bool short mskB; @@ -216,7 +216,7 @@ int x264_quant_8x8_altivec( int16_t dct[64], uint16_t mf[64], uint16_t bias[64] vec_u32_t multEvenvA, multOddvA; vec_u16_t mfvA; vec_u16_t biasvA; - vec_s16_t one = vec_splat_s16(1);; + vec_s16_t one = vec_splat_s16(1); vec_s16_t nz = zero_s16v; vector bool short mskB; diff --git a/encoder/cabac.c b/encoder/cabac.c index 26f6b72c..f1149a5b 100644 --- a/encoder/cabac.c +++ b/encoder/cabac.c @@ -863,7 +863,7 @@ static void ALWAYS_INLINE x264_cabac_block_residual_internal( x264_t *h, x264_ca x264_cabac_encode_bypass( cb, 0 ); // sign } - for( int i = last-1 ; i >= 0; i-- ) + for( int i = last-1; i >= 0; i-- ) { if( l[i] ) { diff --git a/encoder/macroblock.c b/encoder/macroblock.c index d5ac1aa5..81814f71 100644 --- a/encoder/macroblock.c +++ b/encoder/macroblock.c @@ -708,7 +708,7 @@ static ALWAYS_INLINE void x264_macroblock_encode_internal( x264_t *h, int plane_ } for( int p = 0; p < plane_count; p++, i_qp = h->mb.i_chroma_qp ) { - for( int i = (p == 0 && h->mb.i_skip_intra) ? 3 : 0 ; i < 4; i++ ) + for( int i = (p == 0 && h->mb.i_skip_intra) ? 3 : 0; i < 4; i++ ) { int i_mode = h->mb.cache.intra4x4_pred_mode[x264_scan8[4*i]]; x264_mb_encode_i8x8( h, p, i, i_qp, i_mode, NULL, 1 ); @@ -733,7 +733,7 @@ static ALWAYS_INLINE void x264_macroblock_encode_internal( x264_t *h, int plane_ } for( int p = 0; p < plane_count; p++, i_qp = h->mb.i_chroma_qp ) { - for( int i = (p == 0 && h->mb.i_skip_intra) ? 15 : 0 ; i < 16; i++ ) + for( int i = (p == 0 && h->mb.i_skip_intra) ? 15 : 0; i < 16; i++ ) { pixel *p_dst = &h->mb.pic.p_fdec[p][block_idx_xy_fdec[i]]; int i_mode = h->mb.cache.intra4x4_pred_mode[x264_scan8[i]]; diff --git a/filters/filters.c b/filters/filters.c index 204dda53..1d3108e7 100644 --- a/filters/filters.c +++ b/filters/filters.c @@ -48,14 +48,14 @@ char **x264_split_options( const char *opt_str, const char * const *options ) while( *option && (strlen( *option ) != length || strncmp( opt, *option, length )) ) option++; - RETURN_IF_ERROR( !*option, "Invalid option '%.*s'\n", length, opt ) + RETURN_IF_ERROR( !*option, "Invalid option '%.*s'\n", length, opt ); found_named = 1; length += strcspn( opt + length, "," ); } else { - RETURN_IF_ERROR( opt_count >= options_count, "Too many options given\n" ) - RETURN_IF_ERROR( found_named, "Ordered option given after named\n" ) + RETURN_IF_ERROR( opt_count >= options_count, "Too many options given\n" ); + RETURN_IF_ERROR( found_named, "Ordered option given after named\n" ); size += strlen( options[opt_count] ) + 1; } opt_count++; @@ -65,7 +65,7 @@ char **x264_split_options( const char *opt_str, const char * const *options ) int offset = 2 * (opt_count+1) * sizeof(char*); size += offset + (opt - opt_str); char **opts = calloc( 1, size ); - RETURN_IF_ERROR( !opts, "malloc failed\n" ) + RETURN_IF_ERROR( !opts, "malloc failed\n" ); #define insert_opt( src, length )\ do {\ diff --git a/filters/video/crop.c b/filters/video/crop.c index 280347da..c27a3e42 100644 --- a/filters/video/crop.c +++ b/filters/video/crop.c @@ -52,18 +52,18 @@ static int handle_opts( crop_hnd_t *h, video_info_t *info, char **opts, const ch for( int i = 0; i < 4; i++ ) { char *opt = x264_get_option( optlist[i], opts ); - FAIL_IF_ERROR( !opt, "%s crop value not specified\n", optlist[i] ) + FAIL_IF_ERROR( !opt, "%s crop value not specified\n", optlist[i] ); h->dims[i] = x264_otoi( opt, -1 ); - FAIL_IF_ERROR( h->dims[i] < 0, "%s crop value `%s' is less than 0\n", optlist[i], opt ) + FAIL_IF_ERROR( h->dims[i] < 0, "%s crop value `%s' is less than 0\n", optlist[i], opt ); int dim_mod = i&1 ? (h->csp->mod_height << info->interlaced) : h->csp->mod_width; - FAIL_IF_ERROR( h->dims[i] % dim_mod, "%s crop value `%s' is not a multiple of %d\n", optlist[i], opt, dim_mod ) + FAIL_IF_ERROR( h->dims[i] % dim_mod, "%s crop value `%s' is not a multiple of %d\n", optlist[i], opt, dim_mod ); } return 0; } static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x264_param_t *param, char *opt_string ) { - FAIL_IF_ERROR( x264_cli_csp_is_invalid( info->csp ), "invalid csp %d\n", info->csp ) + FAIL_IF_ERROR( x264_cli_csp_is_invalid( info->csp ), "invalid csp %d\n", info->csp ); crop_hnd_t *h = calloc( 1, sizeof(crop_hnd_t) ); if( !h ) return -1; @@ -81,7 +81,7 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2 h->dims[2] = info->width - h->dims[0] - h->dims[2]; h->dims[3] = info->height - h->dims[1] - h->dims[3]; - FAIL_IF_ERROR( h->dims[2] <= 0 || h->dims[3] <= 0, "invalid output resolution %dx%d\n", h->dims[2], h->dims[3] ) + FAIL_IF_ERROR( h->dims[2] <= 0 || h->dims[3] <= 0, "invalid output resolution %dx%d\n", h->dims[2], h->dims[3] ); if( info->width != h->dims[2] || info->height != h->dims[3] ) x264_cli_log( NAME, X264_LOG_INFO, "cropping to %dx%d\n", h->dims[2], h->dims[3] ); diff --git a/filters/video/depth.c b/filters/video/depth.c index 000ec1ef..887e2971 100644 --- a/filters/video/depth.c +++ b/filters/video/depth.c @@ -217,13 +217,13 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, ret = 1; } - FAIL_IF_ERROR( bit_depth != X264_BIT_DEPTH, "this build supports only bit depth %d\n", X264_BIT_DEPTH ) - FAIL_IF_ERROR( ret, "unsupported bit depth conversion.\n" ) + FAIL_IF_ERROR( bit_depth != X264_BIT_DEPTH, "this build supports only bit depth %d\n", X264_BIT_DEPTH ); + FAIL_IF_ERROR( ret, "unsupported bit depth conversion.\n" ); /* only add the filter to the chain if it's needed */ if( change_fmt || bit_depth != 8 * x264_cli_csp_depth_factor( csp ) ) { - FAIL_IF_ERROR( !depth_filter_csp_is_supported(csp), "unsupported colorspace.\n" ) + FAIL_IF_ERROR( !depth_filter_csp_is_supported(csp), "unsupported colorspace.\n" ); depth_hnd_t *h = x264_malloc( sizeof(depth_hnd_t) + (info->width+1)*sizeof(int16_t) ); if( !h ) diff --git a/filters/video/internal.c b/filters/video/internal.c index 516d2d48..ed64d262 100644 --- a/filters/video/internal.c +++ b/filters/video/internal.c @@ -39,7 +39,7 @@ void x264_cli_plane_copy( uint8_t *dst, int i_dst, uint8_t *src, int i_src, int int x264_cli_pic_copy( cli_pic_t *out, cli_pic_t *in ) { int csp = in->img.csp & X264_CSP_MASK; - FAIL_IF_ERROR( x264_cli_csp_is_invalid( in->img.csp ), "invalid colorspace arg %d\n", in->img.csp ) + FAIL_IF_ERROR( x264_cli_csp_is_invalid( in->img.csp ), "invalid colorspace arg %d\n", in->img.csp ); FAIL_IF_ERROR( in->img.csp != out->img.csp || in->img.height != out->img.height || in->img.width != out->img.width, "incompatible frame properties\n" ); /* copy data */ diff --git a/filters/video/resize.c b/filters/video/resize.c index 1c061ea4..38af5efe 100644 --- a/filters/video/resize.c +++ b/filters/video/resize.c @@ -265,7 +265,7 @@ static int handle_opts( const char * const *optlist, char **opts, video_info_t * { FAIL_IF_ERROR( 2 != sscanf( str_sar, "%u:%u", &out_sar_w, &out_sar_h ) && 2 != sscanf( str_sar, "%u/%u", &out_sar_w, &out_sar_h ), - "invalid sar `%s'\n", str_sar ) + "invalid sar `%s'\n", str_sar ); } else out_sar_w = out_sar_h = 1; @@ -275,19 +275,19 @@ static int handle_opts( const char * const *optlist, char **opts, video_info_t * if( !strcasecmp( fittobox, "both" ) ) { FAIL_IF_ERROR( width <= 0 || height <= 0, "invalid box resolution %sx%s\n", - x264_otos( str_width, "" ), x264_otos( str_height, "" ) ) + x264_otos( str_width, "" ), x264_otos( str_height, "" ) ); } else if( !strcasecmp( fittobox, "width" ) ) { - FAIL_IF_ERROR( width <= 0, "invalid box width `%s'\n", x264_otos( str_width, "" ) ) + FAIL_IF_ERROR( width <= 0, "invalid box width `%s'\n", x264_otos( str_width, "" ) ); height = INT_MAX; } else if( !strcasecmp( fittobox, "height" ) ) { - FAIL_IF_ERROR( height <= 0, "invalid box height `%s'\n", x264_otos( str_height, "" ) ) + FAIL_IF_ERROR( height <= 0, "invalid box height `%s'\n", x264_otos( str_height, "" ) ); width = INT_MAX; } - else FAIL_IF_ERROR( 1, "invalid fittobox mode `%s'\n", fittobox ) + else FAIL_IF_ERROR( 1, "invalid fittobox mode `%s'\n", fittobox ); /* maximally fit the new coded resolution to the box */ const x264_cli_csp_t *csp = x264_cli_get_csp( h->dst_csp ); @@ -313,7 +313,7 @@ static int handle_opts( const char * const *optlist, char **opts, video_info_t * if( str_width || str_height ) { FAIL_IF_ERROR( width <= 0 || height <= 0, "invalid resolution %sx%s\n", - x264_otos( str_width, "" ), x264_otos( str_height, "" ) ) + x264_otos( str_width, "" ), x264_otos( str_height, "" ) ); if( !str_sar ) /* res only -> adjust sar */ { /* new_sar = (new_h * old_w * old_sar_w) / (old_h * new_w * old_sar_h) */ @@ -403,7 +403,7 @@ static int check_resizer( resizer_hnd_t *h, cli_pic_t *in ) return -1; h->buffer_allocated = 1; } - FAIL_IF_ERROR( x264_init_sws_context( h ), "swscale init failed\n" ) + FAIL_IF_ERROR( x264_init_sws_context( h ), "swscale init failed\n" ); return 0; } @@ -440,7 +440,7 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2 h->variable_input = 1; h->dst_csp = pick_closest_supported_csp( info->csp ); FAIL_IF_ERROR( h->dst_csp == X264_CSP_NONE, - "filter get invalid input pixel format %d (colorspace %d)\n", convert_csp_to_pix_fmt( info->csp ), info->csp ) + "filter get invalid input pixel format %d (colorspace %d)\n", convert_csp_to_pix_fmt( info->csp ), info->csp ); } else { @@ -479,17 +479,17 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2 FAIL_IF_ERROR( src_pix_fmt == AV_PIX_FMT_NONE && src_pix_fmt_inv != AV_PIX_FMT_NONE, "input colorspace %s with bit depth %d is not supported\n", av_get_pix_fmt_name( src_pix_fmt_inv ), info->csp & X264_CSP_HIGH_DEPTH ? 16 : 8 ); - FAIL_IF_ERROR( !sws_isSupportedInput( src_pix_fmt ), "input colorspace %s is not supported\n", av_get_pix_fmt_name( src_pix_fmt ) ) + FAIL_IF_ERROR( !sws_isSupportedInput( src_pix_fmt ), "input colorspace %s is not supported\n", av_get_pix_fmt_name( src_pix_fmt ) ); FAIL_IF_ERROR( h->dst.pix_fmt == AV_PIX_FMT_NONE && dst_pix_fmt_inv != AV_PIX_FMT_NONE, "input colorspace %s with bit depth %d is not supported\n", av_get_pix_fmt_name( dst_pix_fmt_inv ), h->dst_csp & X264_CSP_HIGH_DEPTH ? 16 : 8 ); - FAIL_IF_ERROR( !sws_isSupportedOutput( h->dst.pix_fmt ), "output colorspace %s is not supported\n", av_get_pix_fmt_name( h->dst.pix_fmt ) ) + FAIL_IF_ERROR( !sws_isSupportedOutput( h->dst.pix_fmt ), "output colorspace %s is not supported\n", av_get_pix_fmt_name( h->dst.pix_fmt ) ); FAIL_IF_ERROR( h->dst.height != info->height && info->interlaced, - "swscale is not compatible with interlaced vertical resizing\n" ) + "swscale is not compatible with interlaced vertical resizing\n" ); /* confirm that the desired resolution meets the colorspace requirements */ const x264_cli_csp_t *csp = x264_cli_get_csp( h->dst_csp ); FAIL_IF_ERROR( h->dst.width % csp->mod_width || h->dst.height % csp->mod_height, - "resolution %dx%d is not compliant with colorspace %s\n", h->dst.width, h->dst.height, csp->name ) + "resolution %dx%d is not compliant with colorspace %s\n", h->dst.width, h->dst.height, csp->name ); if( h->dst.width != info->width || h->dst.height != info->height ) x264_cli_log( NAME, X264_LOG_INFO, "resizing to %dx%d\n", h->dst.width, h->dst.height ); @@ -580,7 +580,7 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2 } /* pass if nothing needs to be done, otherwise fail */ - FAIL_IF_ERROR( ret, "not compiled with swscale support\n" ) + FAIL_IF_ERROR( ret, "not compiled with swscale support\n" ); return 0; } diff --git a/filters/video/select_every.c b/filters/video/select_every.c index 5510fdb8..028a701d 100644 --- a/filters/video/select_every.c +++ b/filters/video/select_every.c @@ -67,16 +67,16 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2 int val = x264_otoi( tok, -1 ); if( p ) { - FAIL_IF_ERROR( val <= 0, "invalid step `%s'\n", tok ) + FAIL_IF_ERROR( val <= 0, "invalid step `%s'\n", tok ); h->step_size = val; continue; } - FAIL_IF_ERROR( val < 0 || val >= h->step_size, "invalid offset `%s'\n", tok ) - FAIL_IF_ERROR( h->pattern_len >= MAX_PATTERN_SIZE, "max pattern size %d reached\n", MAX_PATTERN_SIZE ) + FAIL_IF_ERROR( val < 0 || val >= h->step_size, "invalid offset `%s'\n", tok ); + FAIL_IF_ERROR( h->pattern_len >= MAX_PATTERN_SIZE, "max pattern size %d reached\n", MAX_PATTERN_SIZE ); offsets[h->pattern_len++] = val; } - FAIL_IF_ERROR( !h->step_size, "no step size provided\n" ) - FAIL_IF_ERROR( !h->pattern_len, "no offsets supplied\n" ) + FAIL_IF_ERROR( !h->step_size, "no step size provided\n" ); + FAIL_IF_ERROR( !h->pattern_len, "no offsets supplied\n" ); h->pattern = malloc( h->pattern_len * sizeof(int) ); if( !h->pattern ) diff --git a/input/avs.c b/input/avs.c index 25732e41..98ba3676 100644 --- a/input/avs.c +++ b/input/avs.c @@ -159,9 +159,9 @@ static float get_avs_version( avs_hnd_t *h ) #if USE_AVXSYNTH return 2.58f; #else - FAIL_IF_ERROR( !h->func.avs_function_exists( h->env, "VersionNumber" ), "VersionNumber does not exist\n" ) + FAIL_IF_ERROR( !h->func.avs_function_exists( h->env, "VersionNumber" ), "VersionNumber does not exist\n" ); AVS_Value ver = h->func.avs_invoke( h->env, "VersionNumber", avs_new_value_array( NULL, 0 ), NULL ); - FAIL_IF_ERROR( avs_is_error( ver ), "unable to determine avisynth version: %s\n", avs_as_error( ver ) ) + FAIL_IF_ERROR( avs_is_error( ver ), "unable to determine avisynth version: %s\n", avs_as_error( ver ) ); FAIL_IF_ERROR( !avs_is_float( ver ), "VersionNumber did not return a float value\n" ); float ret = avs_as_float( ver ); h->func.avs_release_value( ver ); @@ -181,7 +181,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c avs_hnd_t *h = malloc( sizeof(avs_hnd_t) ); if( !h ) return -1; - FAIL_IF_ERROR( x264_avs_load_library( h ), "failed to load avisynth\n" ) + FAIL_IF_ERROR( x264_avs_load_library( h ), "failed to load avisynth\n" ); h->env = h->func.avs_create_script_environment( AVS_INTERFACE_25 ); if( h->func.avs_get_error ) { @@ -208,7 +208,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c if( !strcasecmp( filename_ext, "avs" ) ) { res = h->func.avs_invoke( h->env, "Import", arg, NULL ); - FAIL_IF_ERROR( avs_is_error( res ), "%s\n", avs_as_string( res ) ) + FAIL_IF_ERROR( avs_is_error( res ), "%s\n", avs_as_string( res ) ); /* check if the user is using a multi-threaded script and apply distributor if necessary. adapted from avisynth's vfw interface */ AVS_Value mt_test = h->func.avs_invoke( h->env, "GetMTMode", avs_new_value_bool( 0 ), NULL ); @@ -248,18 +248,18 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c } x264_cli_printf( X264_LOG_INFO, "failed\n" ); } - FAIL_IF_ERROR( !filter[i], "unable to find source filter to open `%s'\n", psz_filename ) + FAIL_IF_ERROR( !filter[i], "unable to find source filter to open `%s'\n", psz_filename ); } - FAIL_IF_ERROR( !avs_is_clip( res ), "`%s' didn't return a video clip\n", psz_filename ) + FAIL_IF_ERROR( !avs_is_clip( res ), "`%s' didn't return a video clip\n", psz_filename ); h->clip = h->func.avs_take_clip( res, h->env ); const AVS_VideoInfo *vi = h->func.avs_get_video_info( h->clip ); - FAIL_IF_ERROR( !avs_has_video( vi ), "`%s' has no video data\n", psz_filename ) + FAIL_IF_ERROR( !avs_has_video( vi ), "`%s' has no video data\n", psz_filename ); /* if the clip is made of fields instead of frames, call weave to make them frames */ if( avs_is_field_based( vi ) ) { x264_cli_log( "avs", X264_LOG_WARNING, "detected fieldbased (separated) input, weaving to frames\n" ); AVS_Value tmp = h->func.avs_invoke( h->env, "Weave", res, NULL ); - FAIL_IF_ERROR( avs_is_error( tmp ), "couldn't weave fields into frames\n" ) + FAIL_IF_ERROR( avs_is_error( tmp ), "couldn't weave fields into frames\n" ); res = update_clip( h, &vi, tmp, res ); info->interlaced = 1; info->tff = avs_is_tff( vi ); @@ -267,7 +267,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c #if !HAVE_SWSCALE /* if swscale is not available, convert the CSP if necessary */ FAIL_IF_ERROR( avs_version < 2.6f && (opt->output_csp == X264_CSP_I422 || opt->output_csp == X264_CSP_I444), - "avisynth >= 2.6 is required for i422/i444 output\n" ) + "avisynth >= 2.6 is required for i422/i444 output\n" ); if( (opt->output_csp == X264_CSP_I420 && !avs_is_yv12( vi )) || (opt->output_csp == X264_CSP_I422 && !avs_is_yv16( vi )) || (opt->output_csp == X264_CSP_I444 && !avs_is_yv24( vi )) || (opt->output_csp == X264_CSP_RGB && !avs_is_rgb( vi )) ) { @@ -277,11 +277,11 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c opt->output_csp == X264_CSP_I444 ? "YV24" : "RGB"; x264_cli_log( "avs", X264_LOG_WARNING, "converting input clip to %s\n", csp ); FAIL_IF_ERROR( opt->output_csp < X264_CSP_I444 && (vi->width&1), - "input clip width not divisible by 2 (%dx%d)\n", vi->width, vi->height ) + "input clip width not divisible by 2 (%dx%d)\n", vi->width, vi->height ); FAIL_IF_ERROR( opt->output_csp == X264_CSP_I420 && info->interlaced && (vi->height&3), - "input clip height not divisible by 4 (%dx%d)\n", vi->width, vi->height ) + "input clip height not divisible by 4 (%dx%d)\n", vi->width, vi->height ); FAIL_IF_ERROR( (opt->output_csp == X264_CSP_I420 || info->interlaced) && (vi->height&1), - "input clip height not divisible by 2 (%dx%d)\n", vi->width, vi->height ) + "input clip height not divisible by 2 (%dx%d)\n", vi->width, vi->height ); char conv_func[14]; snprintf( conv_func, sizeof(conv_func), "ConvertTo%s", csp ); char matrix[7] = ""; @@ -302,7 +302,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c arg_arr[1] = avs_new_value_bool( info->interlaced ); arg_arr[2] = avs_new_value_string( matrix ); AVS_Value res2 = h->func.avs_invoke( h->env, conv_func, avs_new_value_array( arg_arr, arg_count ), arg_name ); - FAIL_IF_ERROR( avs_is_error( res2 ), "couldn't convert input clip to %s\n", csp ) + FAIL_IF_ERROR( avs_is_error( res2 ), "couldn't convert input clip to %s\n", csp ); res = update_clip( h, &vi, res2, res ); } /* if swscale is not available, change the range if necessary. This only applies to YUV-based CSPs however */ @@ -315,7 +315,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c arg_arr[1] = avs_new_value_string( levels ); const char *arg_name[] = { NULL, "levels" }; AVS_Value res2 = h->func.avs_invoke( h->env, "ColorYUV", avs_new_value_array( arg_arr, 2 ), arg_name ); - FAIL_IF_ERROR( avs_is_error( res2 ), "couldn't convert range: %s\n", avs_as_error( res2 ) ) + FAIL_IF_ERROR( avs_is_error( res2 ), "couldn't convert range: %s\n", avs_as_error( res2 ) ); res = update_clip( h, &vi, res2, res ); // notification that the input range has changed to the desired one opt->input_range = opt->output_range; @@ -381,7 +381,7 @@ static int read_frame( cli_pic_t *pic, hnd_t handle, int i_frame ) return -1; AVS_VideoFrame *frm = pic->opaque = h->func.avs_get_frame( h->clip, i_frame ); const char *err = h->func.avs_clip_get_error( h->clip ); - FAIL_IF_ERROR( err, "%s occurred while reading frame %d\n", err, i_frame ) + FAIL_IF_ERROR( err, "%s occurred while reading frame %d\n", err, i_frame ); for( int i = 0; i < pic->img.planes; i++ ) { /* explicitly cast away the const attribute to avoid a warning */ diff --git a/input/ffms.c b/input/ffms.c index a2a87cef..67233705 100644 --- a/input/ffms.c +++ b/input/ffms.c @@ -102,14 +102,14 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c if( !idx ) { FFMS_Indexer *indexer = FFMS_CreateIndexer( psz_filename, &e ); - FAIL_IF_ERROR( !indexer, "could not create indexer\n" ) + FAIL_IF_ERROR( !indexer, "could not create indexer\n" ); if( opt->progress ) FFMS_SetProgressCallback( indexer, update_progress, &h->time ); idx = FFMS_DoIndexing2( indexer, FFMS_IEH_ABORT, &e ); fprintf( stderr, "%*c", PROGRESS_LENGTH+1, '\r' ); - FAIL_IF_ERROR( !idx, "could not create index\n" ) + FAIL_IF_ERROR( !idx, "could not create index\n" ); if( opt->index_file && FFMS_WriteIndex( opt->index_file, idx, &e ) ) x264_cli_log( "ffms", X264_LOG_WARNING, "could not write index file\n" ); @@ -120,8 +120,8 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c h->video_source = FFMS_CreateVideoSource( psz_filename, trackno, idx, 1, seekmode, &e ); FFMS_DestroyIndex( idx ); - FAIL_IF_ERROR( trackno < 0, "could not find video track\n" ) - FAIL_IF_ERROR( !h->video_source, "could not create video source\n" ) + FAIL_IF_ERROR( trackno < 0, "could not find video track\n" ); + FAIL_IF_ERROR( !h->video_source, "could not create video source\n" ); const FFMS_VideoProperties *videop = FFMS_GetVideoProperties( h->video_source ); info->num_frames = h->num_frames = videop->NumFrames; @@ -134,7 +134,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c info->thread_safe = 0; const FFMS_Frame *frame = FFMS_GetFrame( h->video_source, 0, &e ); - FAIL_IF_ERROR( !frame, "could not read frame 0\n" ) + FAIL_IF_ERROR( !frame, "could not read frame 0\n" ); info->fullrange = 0; info->width = frame->EncodedWidth; @@ -185,7 +185,7 @@ static int read_frame( cli_pic_t *pic, hnd_t handle, int i_frame ) FFMS_ErrorInfo e; e.BufferSize = 0; const FFMS_Frame *frame = FFMS_GetFrame( h->video_source, i_frame, &e ); - FAIL_IF_ERROR( !frame, "could not read frame %d \n", i_frame ) + FAIL_IF_ERROR( !frame, "could not read frame %d \n", i_frame ); memcpy( pic->img.stride, frame->Linesize, sizeof(pic->img.stride) ); memcpy( pic->img.plane, frame->Data, sizeof(pic->img.plane) ); @@ -194,7 +194,7 @@ static int read_frame( cli_pic_t *pic, hnd_t handle, int i_frame ) { const FFMS_FrameInfo *info = FFMS_GetFrameInfo( h->track, i_frame ); FAIL_IF_ERROR( info->PTS == AV_NOPTS_VALUE, "invalid timestamp. " - "Use --force-cfr and specify a framerate with --fps\n" ) + "Use --force-cfr and specify a framerate with --fps\n" ); pic->pts = info->PTS >> h->reduce_pts; pic->duration = 0; diff --git a/input/lavf.c b/input/lavf.c index 4a1e5911..14ed174d 100644 --- a/input/lavf.c +++ b/input/lavf.c @@ -168,15 +168,15 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c if( opt->format ) FAIL_IF_ERROR( !(format = av_find_input_format( opt->format )), "unknown file format: %s\n", opt->format ); - FAIL_IF_ERROR( avformat_open_input( &h->lavf, psz_filename, format, &options ), "could not open input file\n" ) + FAIL_IF_ERROR( avformat_open_input( &h->lavf, psz_filename, format, &options ), "could not open input file\n" ); if( options ) av_dict_free( &options ); - FAIL_IF_ERROR( avformat_find_stream_info( h->lavf, NULL ) < 0, "could not find input stream info\n" ) + FAIL_IF_ERROR( avformat_find_stream_info( h->lavf, NULL ) < 0, "could not find input stream info\n" ); int i = 0; while( i < h->lavf->nb_streams && h->lavf->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO ) i++; - FAIL_IF_ERROR( i == h->lavf->nb_streams, "could not find video stream\n" ) + FAIL_IF_ERROR( i == h->lavf->nb_streams, "could not find video stream\n" ); h->stream_id = i; h->next_frame = 0; AVCodecContext *c = h->lavf->streams[i]->codec; @@ -188,13 +188,13 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c info->thread_safe = 0; h->vfr_input = info->vfr; FAIL_IF_ERROR( avcodec_open2( c, avcodec_find_decoder( c->codec_id ), NULL ), - "could not find decoder for video stream\n" ) + "could not find decoder for video stream\n" ); /* prefetch the first frame and set/confirm flags */ h->first_pic = malloc( sizeof(cli_pic_t) ); FAIL_IF_ERROR( !h->first_pic || lavf_input.picture_alloc( h->first_pic, h, X264_CSP_OTHER, info->width, info->height ), - "malloc failed\n" ) - else if( read_frame_internal( h->first_pic, h, 0, info ) ) + "malloc failed\n" ); + if( read_frame_internal( h->first_pic, h, 0, info ) ) return -1; info->width = c->width; diff --git a/input/raw.c b/input/raw.c index 07322143..53a22f51 100644 --- a/input/raw.c +++ b/input/raw.c @@ -54,7 +54,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c } else sscanf( opt->resolution, "%dx%d", &info->width, &info->height ); - FAIL_IF_ERROR( !info->width || !info->height, "raw input requires a resolution.\n" ) + FAIL_IF_ERROR( !info->width || !info->height, "raw input requires a resolution.\n" ); if( opt->colorspace ) { for( info->csp = X264_CSP_CLI_MAX-1; info->csp > X264_CSP_NONE; info->csp-- ) diff --git a/input/thread.c b/input/thread.c index ad3b6f3f..f6007440 100644 --- a/input/thread.c +++ b/input/thread.c @@ -49,7 +49,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c { thread_hnd_t *h = malloc( sizeof(thread_hnd_t) ); FAIL_IF_ERR( !h || cli_input.picture_alloc( &h->pic, *p_handle, info->csp, info->width, info->height ), - "x264", "malloc failed\n" ) + "x264", "malloc failed\n" ); h->input = cli_input; h->p_handle = *p_handle; h->next_frame = -1; diff --git a/input/timecode.c b/input/timecode.c index 36b55b61..9a94ccab 100644 --- a/input/timecode.c +++ b/input/timecode.c @@ -61,7 +61,7 @@ static double correct_fps( double fps, timecode_hnd_t *h ) fps_den = i * h->timebase_num; fps_num = round( fps_den * fps_sig ) * exponent; FAIL_IF_ERROR( fps_num > UINT32_MAX, "tcfile fps correction failed.\n" - " Specify an appropriate timebase manually or remake tcfile.\n" ) + " Specify an appropriate timebase manually or remake tcfile.\n" ); if( fabs( ((double)fps_num / fps_den) / exponent - fps_sig ) < DOUBLE_EPSILON ) break; ++i; @@ -87,7 +87,7 @@ static int try_mkv_timebase_den( double *fpss, timecode_hnd_t *h, int loop_num ) fps_den = round( MKV_TIMEBASE_DEN / fps_sig ) / exponent; h->timebase_num = fps_den && h->timebase_num ? gcd( h->timebase_num, fps_den ) : fps_den; FAIL_IF_ERROR( h->timebase_num > UINT32_MAX || !h->timebase_num, "automatic timebase generation failed.\n" - " Specify timebase manually.\n" ) + " Specify timebase manually.\n" ); } return 0; } @@ -100,7 +100,7 @@ static int parse_tcfile( FILE *tcfile_in, timecode_hnd_t *h, video_info_t *info double *fpss = NULL; ret = fscanf( tcfile_in, "# timecode format v%d", &tcfv ); - FAIL_IF_ERROR( ret != 1 || (tcfv != 1 && tcfv != 2), "unsupported timecode format\n" ) + FAIL_IF_ERROR( ret != 1 || (tcfv != 1 && tcfv != 2), "unsupported timecode format\n" ); #define NO_TIMECODE_LINE (buff[0] == '#' || buff[0] == '\n' || buff[0] == '\r') if( tcfv == 1 ) { @@ -115,10 +115,10 @@ static int parse_tcfile( FILE *tcfile_in, timecode_hnd_t *h, video_info_t *info if( NO_TIMECODE_LINE ) continue; FAIL_IF_ERROR( sscanf( buff, "assume %lf", &h->assume_fps ) != 1 && sscanf( buff, "Assume %lf", &h->assume_fps ) != 1, - "tcfile parsing error: assumed fps not found\n" ) + "tcfile parsing error: assumed fps not found\n" ); break; } - FAIL_IF_ERROR( h->assume_fps <= 0, "invalid assumed fps %.6f\n", h->assume_fps ) + FAIL_IF_ERROR( h->assume_fps <= 0, "invalid assumed fps %.6f\n", h->assume_fps ); file_pos = ftell( tcfile_in ); h->stored_pts_num = 0; @@ -131,9 +131,9 @@ static int parse_tcfile( FILE *tcfile_in, timecode_hnd_t *h, video_info_t *info continue; } ret = sscanf( buff, "%d,%d,%lf", &start, &end, &seq_fps ); - FAIL_IF_ERROR( ret != 3 && ret != EOF, "invalid input tcfile\n" ) + FAIL_IF_ERROR( ret != 3 && ret != EOF, "invalid input tcfile\n" ); FAIL_IF_ERROR( start > end || start <= prev_start || end <= prev_end || seq_fps <= 0, - "invalid input tcfile at line %d: %s\n", num, buff ) + "invalid input tcfile at line %d: %s\n", num, buff ); prev_start = start; prev_end = end; if( h->auto_timebase_den || h->auto_timebase_num ) @@ -234,7 +234,7 @@ static int parse_tcfile( FILE *tcfile_in, timecode_hnd_t *h, video_info_t *info h->stored_pts_num++; } timecodes_num = h->stored_pts_num; - FAIL_IF_ERROR( !timecodes_num, "input tcfile doesn't have any timecodes!\n" ) + FAIL_IF_ERROR( !timecodes_num, "input tcfile doesn't have any timecodes!\n" ); fseek( tcfile_in, file_pos, SEEK_SET ); timecodes = malloc( timecodes_num * sizeof(double) ); @@ -246,7 +246,7 @@ static int parse_tcfile( FILE *tcfile_in, timecode_hnd_t *h, video_info_t *info { ret = sscanf( buff, "%lf", &timecodes[0] ); timecodes[0] *= 1e-3; /* Timecode format v2 is expressed in milliseconds. */ - FAIL_IF_ERROR( ret != 1, "invalid input tcfile for frame 0\n" ) + FAIL_IF_ERROR( ret != 1, "invalid input tcfile for frame 0\n" ); for( num = 1; num < timecodes_num && fgets( buff, sizeof(buff), tcfile_in ) != NULL; ) { if( NO_TIMECODE_LINE ) @@ -254,11 +254,11 @@ static int parse_tcfile( FILE *tcfile_in, timecode_hnd_t *h, video_info_t *info ret = sscanf( buff, "%lf", &timecodes[num] ); timecodes[num] *= 1e-3; /* Timecode format v2 is expressed in milliseconds. */ FAIL_IF_ERROR( ret != 1 || timecodes[num] <= timecodes[num - 1], - "invalid input tcfile for frame %d\n", num ) + "invalid input tcfile for frame %d\n", num ); ++num; } } - FAIL_IF_ERROR( num < timecodes_num, "failed to read input tcfile for frame %d", num ) + FAIL_IF_ERROR( num < timecodes_num, "failed to read input tcfile for frame %d", num ); if( timecodes_num == 1 ) h->timebase_den = info->fps_num; @@ -314,7 +314,7 @@ static int parse_tcfile( FILE *tcfile_in, timecode_hnd_t *h, video_info_t *info x264_cli_log( "timecode", X264_LOG_INFO, "automatic timebase generation %"PRIu64"/%"PRIu64"\n", h->timebase_num, h->timebase_den ); } else FAIL_IF_ERROR( h->timebase_den > UINT32_MAX || !h->timebase_den, "automatic timebase generation failed.\n" - " Specify an appropriate timebase manually.\n" ) + " Specify an appropriate timebase manually.\n" ); h->pts = malloc( h->stored_pts_num * sizeof(int64_t) ); if( !h->pts ) @@ -322,7 +322,7 @@ static int parse_tcfile( FILE *tcfile_in, timecode_hnd_t *h, video_info_t *info for( num = 0; num < h->stored_pts_num; num++ ) { h->pts[num] = timecodes[num] * ((double)h->timebase_den / h->timebase_num) + 0.5; - FAIL_IF_ERROR( num > 0 && h->pts[num] <= h->pts[num - 1], "invalid timebase or timecode for frame %d\n", num ) + FAIL_IF_ERROR( num > 0 && h->pts[num] <= h->pts[num - 1], "invalid timebase or timecode for frame %d\n", num ); } free( timecodes ); @@ -344,7 +344,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c int ret = 0; FILE *tcfile_in; timecode_hnd_t *h = malloc( sizeof(timecode_hnd_t) ); - FAIL_IF_ERROR( !h, "malloc failed\n" ) + FAIL_IF_ERROR( !h, "malloc failed\n" ); h->input = cli_input; h->p_handle = *p_handle; h->pts = NULL; @@ -357,7 +357,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c h->timebase_den = 0; /* set later by auto timebase generation */ } FAIL_IF_ERROR( h->timebase_num > UINT32_MAX || h->timebase_den > UINT32_MAX, - "timebase you specified exceeds H.264 maximum\n" ) + "timebase you specified exceeds H.264 maximum\n" ); } h->auto_timebase_num = !ret; h->auto_timebase_den = ret < 2; @@ -367,8 +367,8 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c h->timebase_den = 0; /* set later by auto timebase generation */ tcfile_in = x264_fopen( psz_filename, "rb" ); - FAIL_IF_ERROR( !tcfile_in, "can't open `%s'\n", psz_filename ) - else if( !x264_is_regular_file( tcfile_in ) ) + FAIL_IF_ERROR( !tcfile_in, "can't open `%s'\n", psz_filename ); + if( !x264_is_regular_file( tcfile_in ) ) { x264_cli_log( "timecode", X264_LOG_ERROR, "tcfile input incompatible with non-regular file `%s'\n", psz_filename ); fclose( tcfile_in ); diff --git a/input/y4m.c b/input/y4m.c index b8893ab1..46a9ec38 100644 --- a/input/y4m.c +++ b/input/y4m.c @@ -99,8 +99,8 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c break; } } - FAIL_IF_ERROR( strncmp( header, Y4M_MAGIC, sizeof(Y4M_MAGIC)-1 ), "bad sequence header magic\n" ) - FAIL_IF_ERROR( i == MAX_YUV4_HEADER, "bad sequence header length\n" ) + FAIL_IF_ERROR( strncmp( header, Y4M_MAGIC, sizeof(Y4M_MAGIC)-1 ), "bad sequence header magic\n" ); + FAIL_IF_ERROR( i == MAX_YUV4_HEADER, "bad sequence header length\n" ); /* Scan properties */ header_end = &header[i+1]; /* Include space */ @@ -187,7 +187,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c h->bit_depth = 8; } - FAIL_IF_ERROR( colorspace <= X264_CSP_NONE || colorspace >= X264_CSP_MAX, "colorspace unhandled\n" ) + FAIL_IF_ERROR( colorspace <= X264_CSP_NONE || colorspace >= X264_CSP_MAX, "colorspace unhandled\n" ); FAIL_IF_ERROR( h->bit_depth < 8 || h->bit_depth > 16, "unsupported bit depth `%d'\n", h->bit_depth ); info->thread_safe = 1; @@ -215,7 +215,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c int len = 1; while( len <= MAX_FRAME_HEADER && fgetc( h->fh ) != '\n' ) len++; - FAIL_IF_ERROR( len > MAX_FRAME_HEADER || len < sizeof(Y4M_FRAME_MAGIC), "bad frame header length\n" ) + FAIL_IF_ERROR( len > MAX_FRAME_HEADER || len < sizeof(Y4M_FRAME_MAGIC), "bad frame header length\n" ); h->frame_header_len = len; h->frame_size += len; @@ -252,7 +252,7 @@ static int read_frame_internal( cli_pic_t *pic, y4m_hnd_t *h, int bit_depth_uc ) * produces y4m files with variable-length frame headers so just error out if that happens. */ while( i <= h->frame_header_len && header[i-1] != '\n' ) i++; - FAIL_IF_ERROR( i != h->frame_header_len, "bad frame header length\n" ) + FAIL_IF_ERROR( i != h->frame_header_len, "bad frame header length\n" ); } else { @@ -261,9 +261,9 @@ static int read_frame_internal( cli_pic_t *pic, y4m_hnd_t *h, int bit_depth_uc ) return -1; while( i <= MAX_FRAME_HEADER && fgetc( h->fh ) != '\n' ) i++; - FAIL_IF_ERROR( i > MAX_FRAME_HEADER, "bad frame header length\n" ) + FAIL_IF_ERROR( i > MAX_FRAME_HEADER, "bad frame header length\n" ); } - FAIL_IF_ERROR( memcmp( header, Y4M_FRAME_MAGIC, slen ), "bad frame header magic\n" ) + FAIL_IF_ERROR( memcmp( header, Y4M_FRAME_MAGIC, slen ), "bad frame header magic\n" ); for( i = 0; i < pic->img.planes; i++ ) { diff --git a/output/matroska_ebml.c b/output/matroska_ebml.c index 6d6c760e..f2b04c7d 100644 --- a/output/matroska_ebml.c +++ b/output/matroska_ebml.c @@ -245,7 +245,7 @@ static int mk_write_bin( mk_context *c, unsigned id, const void *data, unsigned { CHECK( mk_write_id( c, id ) ); CHECK( mk_write_size( c, size ) ); - CHECK( mk_append_context_data( c, data, size ) ) ; + CHECK( mk_append_context_data( c, data, size ) ); return 0; } diff --git a/output/mp4.c b/output/mp4.c index c852ce21..f21619a9 100644 --- a/output/mp4.c +++ b/output/mp4.c @@ -171,7 +171,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, cli_output_opt_t *opt return -1; int b_regular = x264_is_regular_file( fh ); fclose( fh ); - FAIL_IF_ERR( !b_regular, "mp4", "MP4 output is incompatible with non-regular file `%s'\n", psz_filename ) + FAIL_IF_ERR( !b_regular, "mp4", "MP4 output is incompatible with non-regular file `%s'\n", psz_filename ); mp4_hnd_t *p_mp4 = calloc( 1, sizeof(mp4_hnd_t) ); if( !p_mp4 ) @@ -180,7 +180,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, cli_output_opt_t *opt #ifdef _WIN32 /* GPAC doesn't support Unicode filenames. */ char ansi_filename[MAX_PATH]; - FAIL_IF_ERR( !x264_ansi_filename( psz_filename, ansi_filename, MAX_PATH, 1 ), "mp4", "invalid ansi filename\n" ) + FAIL_IF_ERR( !x264_ansi_filename( psz_filename, ansi_filename, MAX_PATH, 1 ), "mp4", "invalid ansi filename\n" ); p_mp4->p_file = gf_isom_open( ansi_filename, GF_ISOM_OPEN_WRITE, NULL ); #else p_mp4->p_file = gf_isom_open( psz_filename, GF_ISOM_OPEN_WRITE, NULL ); @@ -210,7 +210,7 @@ static int set_param( hnd_t handle, x264_param_t *p_param ) p_mp4->i_time_res = (uint64_t)p_param->i_timebase_den * p_mp4->i_dts_compress_multiplier; p_mp4->i_time_inc = (uint64_t)p_param->i_timebase_num * p_mp4->i_dts_compress_multiplier; - FAIL_IF_ERR( p_mp4->i_time_res > UINT32_MAX, "mp4", "MP4 media timescale %"PRIu64" exceeds maximum\n", p_mp4->i_time_res ) + FAIL_IF_ERR( p_mp4->i_time_res > UINT32_MAX, "mp4", "MP4 media timescale %"PRIu64" exceeds maximum\n", p_mp4->i_time_res ); p_mp4->i_track = gf_isom_new_track( p_mp4->p_file, 0, GF_ISOM_MEDIA_VISUAL, p_mp4->i_time_res ); @@ -230,7 +230,7 @@ static int set_param( hnd_t handle, x264_param_t *p_param ) uint64_t dh = p_param->i_height << 16; double sar = (double)p_param->vui.i_sar_width / p_param->vui.i_sar_height; if( sar > 1.0 ) - dw *= sar ; + dw *= sar; else dh /= sar; gf_isom_set_pixel_aspect_ratio( p_mp4->p_file, p_mp4->i_track, p_mp4->i_descidx, p_param->vui.i_sar_width, p_param->vui.i_sar_height ); diff --git a/output/mp4_lsmash.c b/output/mp4_lsmash.c index 10f8f1f3..6a10a518 100644 --- a/output/mp4_lsmash.c +++ b/output/mp4_lsmash.c @@ -41,19 +41,25 @@ /* For close_file() */ #define MP4_LOG_IF_ERR( cond, ... )\ -if( cond )\ +do\ {\ - MP4_LOG_ERROR( __VA_ARGS__ );\ -} + if( cond )\ + {\ + MP4_LOG_ERROR( __VA_ARGS__ );\ + }\ +} while( 0 ) /* For open_file() */ #define MP4_FAIL_IF_ERR_EX( cond, ... )\ -if( cond )\ +do\ {\ - remove_mp4_hnd( p_mp4 );\ - MP4_LOG_ERROR( __VA_ARGS__ );\ - return -1;\ -} + if( cond )\ + {\ + remove_mp4_hnd( p_mp4 );\ + MP4_LOG_ERROR( __VA_ARGS__ );\ + return -1;\ + }\ +} while( 0 ) /*******************/ diff --git a/tools/checkasm.c b/tools/checkasm.c index b075760a..ce7518e6 100644 --- a/tools/checkasm.c +++ b/tools/checkasm.c @@ -2201,7 +2201,7 @@ static int check_quant( int cpu_ref, int cpu_new ) int dmf = h->dequant4_mf[CQM_4IC][qpdc%6][0] << qpdc/6; \ if( dmf > 32*64 ) \ continue; \ - for( int i = 16; ; i <<= 1 ) \ + for( int i = 16;; i <<= 1 ) \ { \ int res_c, res_asm; \ int max = X264_MIN( i, PIXEL_MAX*16 ); \ diff --git a/x264.c b/x264.c index 1894a45a..6834996d 100644 --- a/x264.c +++ b/x264.c @@ -355,10 +355,10 @@ int main( int argc, char **argv ) cli_opt_t opt = {0}; int ret = 0; - FAIL_IF_ERROR( x264_threading_init(), "unable to initialize threading\n" ) + FAIL_IF_ERROR( x264_threading_init(), "unable to initialize threading\n" ); #ifdef _WIN32 - FAIL_IF_ERROR( !get_argv_utf8( &argc, &argv ), "unable to convert command line to UTF-8\n" ) + FAIL_IF_ERROR( !get_argv_utf8( &argc, &argv ), "unable to convert command line to UTF-8\n" ); GetConsoleTitleW( org_console_title, CONSOLE_TITLE_SIZE ); _setmode( _fileno( stdin ), _O_BINARY ); @@ -1256,7 +1256,7 @@ static int select_input( const char *demuxer, char *used_demuxer, char *filename cli_input = raw_input; } - FAIL_IF_ERROR( !(*p_handle), "could not open input file `%s' via any method!\n", filename ) + FAIL_IF_ERROR( !(*p_handle), "could not open input file `%s' via any method!\n", filename ); } strcpy( used_demuxer, module ); @@ -1432,17 +1432,17 @@ static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt ) output_filename = optarg; break; case OPT_MUXER: - FAIL_IF_ERROR( parse_enum_name( optarg, muxer_names, &muxer ), "Unknown muxer `%s'\n", optarg ) + FAIL_IF_ERROR( parse_enum_name( optarg, muxer_names, &muxer ), "Unknown muxer `%s'\n", optarg ); break; case OPT_DEMUXER: - FAIL_IF_ERROR( parse_enum_name( optarg, demuxer_names, &demuxer ), "Unknown demuxer `%s'\n", optarg ) + FAIL_IF_ERROR( parse_enum_name( optarg, demuxer_names, &demuxer ), "Unknown demuxer `%s'\n", optarg ); break; case OPT_INDEX: input_opt.index_file = optarg; break; case OPT_QPFILE: opt->qpfile = x264_fopen( optarg, "rb" ); - FAIL_IF_ERROR( !opt->qpfile, "can't open qpfile `%s'\n", optarg ) + FAIL_IF_ERROR( !opt->qpfile, "can't open qpfile `%s'\n", optarg ); if( !x264_is_regular_file( opt->qpfile ) ) { x264_cli_log( "x264", X264_LOG_ERROR, "qpfile incompatible with non-regular file `%s'\n", optarg ); @@ -1493,13 +1493,13 @@ static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt ) break; case OPT_TCFILE_OUT: opt->tcfile_out = x264_fopen( optarg, "wb" ); - FAIL_IF_ERROR( !opt->tcfile_out, "can't open `%s'\n", optarg ) + FAIL_IF_ERROR( !opt->tcfile_out, "can't open `%s'\n", optarg ); break; case OPT_TIMEBASE: input_opt.timebase = optarg; break; case OPT_PULLDOWN: - FAIL_IF_ERROR( parse_enum_value( optarg, pulldown_names, &opt->i_pulldown ), "Unknown pulldown `%s'\n", optarg ) + FAIL_IF_ERROR( parse_enum_value( optarg, pulldown_names, &opt->i_pulldown ), "Unknown pulldown `%s'\n", optarg ); break; case OPT_VIDEO_FILTER: vid_filters = optarg; @@ -1520,7 +1520,7 @@ static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt ) output_opt.use_dts_compress = 1; break; case OPT_OUTPUT_CSP: - FAIL_IF_ERROR( parse_enum_value( optarg, output_csp_names, &output_csp ), "Unknown output csp `%s'\n", optarg ) + FAIL_IF_ERROR( parse_enum_value( optarg, output_csp_names, &output_csp ), "Unknown output csp `%s'\n", optarg ); // correct the parsed value to the libx264 csp value #if X264_CHROMA_FORMAT static const uint8_t output_csp_fix[] = { X264_CHROMA_FORMAT, X264_CSP_RGB }; @@ -1530,7 +1530,7 @@ static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt ) param->i_csp = output_csp = output_csp_fix[output_csp]; break; case OPT_INPUT_RANGE: - FAIL_IF_ERROR( parse_enum_value( optarg, range_names, &input_opt.input_range ), "Unknown input range `%s'\n", optarg ) + FAIL_IF_ERROR( parse_enum_value( optarg, range_names, &input_opt.input_range ), "Unknown input range `%s'\n", optarg ); input_opt.input_range += RANGE_AUTO; break; case OPT_RANGE: @@ -1577,11 +1577,11 @@ generic_option: /* Get the file name */ FAIL_IF_ERROR( optind > argc - 1 || !output_filename, "No %s file. Run x264 --help for a list of options.\n", - optind > argc - 1 ? "input" : "output" ) + optind > argc - 1 ? "input" : "output" ); if( select_output( muxer, output_filename, param ) ) return -1; - FAIL_IF_ERROR( cli_output.open_file( output_filename, &opt->hout, &output_opt ), "could not open output file `%s'\n", output_filename ) + FAIL_IF_ERROR( cli_output.open_file( output_filename, &opt->hout, &output_opt ), "could not open output file `%s'\n", output_filename ); input_filename = argv[optind++]; video_info_t info = {0}; @@ -1609,7 +1609,7 @@ generic_option: return -1; FAIL_IF_ERROR( !opt->hin && cli_input.open_file( input_filename, &opt->hin, &info, &input_opt ), - "could not open input file `%s'\n", input_filename ) + "could not open input file `%s'\n", input_filename ); x264_reduce_fraction( &info.sar_width, &info.sar_height ); x264_reduce_fraction( &info.fps_num, &info.fps_den ); @@ -1619,11 +1619,11 @@ generic_option: if( tcfile_name ) { - FAIL_IF_ERROR( b_user_fps, "--fps + --tcfile-in is incompatible.\n" ) - FAIL_IF_ERROR( timecode_input.open_file( tcfile_name, &opt->hin, &info, &input_opt ), "timecode input failed\n" ) + FAIL_IF_ERROR( b_user_fps, "--fps + --tcfile-in is incompatible.\n" ); + FAIL_IF_ERROR( timecode_input.open_file( tcfile_name, &opt->hin, &info, &input_opt ), "timecode input failed\n" ); cli_input = timecode_input; } - else FAIL_IF_ERROR( !info.vfr && input_opt.timebase, "--timebase is incompatible with cfr input\n" ) + else FAIL_IF_ERROR( !info.vfr && input_opt.timebase, "--timebase is incompatible with cfr input\n" ); /* init threaded input while the information about the input video is unaltered by filtering */ #if HAVE_THREAD @@ -1660,14 +1660,14 @@ generic_option: uint64_t i_user_timebase_num; uint64_t i_user_timebase_den; int ret = sscanf( input_opt.timebase, "%"SCNu64"/%"SCNu64, &i_user_timebase_num, &i_user_timebase_den ); - FAIL_IF_ERROR( !ret, "invalid argument: timebase = %s\n", input_opt.timebase ) - else if( ret == 1 ) + FAIL_IF_ERROR( !ret, "invalid argument: timebase = %s\n", input_opt.timebase ); + if( ret == 1 ) { i_user_timebase_num = info.timebase_num; i_user_timebase_den = strtoul( input_opt.timebase, NULL, 10 ); } FAIL_IF_ERROR( i_user_timebase_num > UINT32_MAX || i_user_timebase_den > UINT32_MAX, - "timebase you specified exceeds H.264 maximum\n" ) + "timebase you specified exceeds H.264 maximum\n" ); opt->timebase_convert_multiplier = ((double)i_user_timebase_den / info.timebase_den) * ((double)info.timebase_num / i_user_timebase_num); info.timebase_num = i_user_timebase_num; @@ -1719,7 +1719,7 @@ generic_option: if( input_opt.output_range == RANGE_AUTO ) param->vui.b_fullrange = RANGE_PC; /* otherwise fail if they specified tv */ - FAIL_IF_ERROR( !param->vui.b_fullrange, "RGB must be PC range" ) + FAIL_IF_ERROR( !param->vui.b_fullrange, "RGB must be PC range" ); } /* Automatically reduce reference frame count to match the user's target level @@ -1840,12 +1840,15 @@ static void convert_cli_to_lib_pic( x264_picture_t *lib, cli_pic_t *cli ) } #define FAIL_IF_ERROR2( cond, ... )\ -if( cond )\ +do\ {\ - x264_cli_log( "x264", X264_LOG_ERROR, __VA_ARGS__ );\ - retval = -1;\ - goto fail;\ -} + if( cond )\ + {\ + x264_cli_log( "x264", X264_LOG_ERROR, __VA_ARGS__ );\ + retval = -1;\ + goto fail;\ + }\ +} while( 0 ) static int encode( x264_param_t *param, cli_opt_t *opt ) { @@ -1881,7 +1884,7 @@ static int encode( x264_param_t *param, cli_opt_t *opt ) pulldown = &pulldown_values[opt->i_pulldown]; param->i_timebase_num = param->i_fps_den; FAIL_IF_ERROR2( fmod( param->i_fps_num * pulldown->fps_factor, 1 ), - "unsupported framerate for chosen pulldown\n" ) + "unsupported framerate for chosen pulldown\n" ); param->i_timebase_den = param->i_fps_num * pulldown->fps_factor; } @@ -1896,7 +1899,7 @@ static int encode( x264_param_t *param, cli_opt_t *opt ) /* ticks/frame = ticks/second / frames/second */ ticks_per_frame = (int64_t)param->i_timebase_den * param->i_fps_den / param->i_timebase_num / param->i_fps_num; - FAIL_IF_ERROR2( ticks_per_frame < 1 && !param->b_vfr_input, "ticks_per_frame invalid: %"PRId64"\n", ticks_per_frame ) + FAIL_IF_ERROR2( ticks_per_frame < 1 && !param->b_vfr_input, "ticks_per_frame invalid: %"PRId64"\n", ticks_per_frame ); ticks_per_frame = X264_MAX( ticks_per_frame, 1 ); if( !param->b_repeat_headers ) @@ -1905,7 +1908,7 @@ static int encode( x264_param_t *param, cli_opt_t *opt ) x264_nal_t *headers; int i_nal; - FAIL_IF_ERROR2( x264_encoder_headers( h, &headers, &i_nal ) < 0, "x264_encoder_headers failed\n" ) + FAIL_IF_ERROR2( x264_encoder_headers( h, &headers, &i_nal ) < 0, "x264_encoder_headers failed\n" ); FAIL_IF_ERROR2( (i_file = cli_output.write_headers( opt->hout, headers )) < 0, "error writing headers to output file\n" ); } diff --git a/x264cli.h b/x264cli.h index cc7a8225..71be64d8 100644 --- a/x264cli.h +++ b/x264cli.h @@ -71,11 +71,14 @@ int x264_ansi_filename( const char *filename, char *ansi_filename, int size, int #endif #define RETURN_IF_ERR( cond, name, ret, ... )\ -if( cond )\ +do\ {\ - x264_cli_log( name, X264_LOG_ERROR, __VA_ARGS__ );\ - return ret;\ -} + if( cond )\ + {\ + x264_cli_log( name, X264_LOG_ERROR, __VA_ARGS__ );\ + return ret;\ + }\ +} while( 0 ) #define FAIL_IF_ERR( cond, name, ... ) RETURN_IF_ERR( cond, name, -1, __VA_ARGS__ ) -- 2.40.0