Commit eaf2fc20 authored by Anton Mitrofanov's avatar Anton Mitrofanov

Various cosmetics of semicolon use

parent aae177c5
...@@ -3430,7 +3430,7 @@ uint8_t *x264_get_ref_msa( uint8_t *p_dst, intptr_t *p_dst_stride, ...@@ -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, x264_mc_weight_w8_msa( p_dst, *p_dst_stride,
p_dst, *p_dst_stride, p_dst, *p_dst_stride,
pWeight, i_h4w ); 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; uint64_t temp0;
v16i8 zero = {0}; v16i8 zero = {0};
...@@ -3666,7 +3666,7 @@ uint8_t *x264_get_ref_msa( uint8_t *p_dst, intptr_t *p_dst_stride, ...@@ -3666,7 +3666,7 @@ uint8_t *x264_get_ref_msa( uint8_t *p_dst, intptr_t *p_dst_stride,
pWeight, i_h4w ); pWeight, i_h4w );
p_src1 = src1_org + i_h4w * i_src_stride; 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; uint64_t u_temp0;
v16i8 zero = {0}; v16i8 zero = {0};
......
...@@ -370,8 +370,8 @@ static ALWAYS_INLINE int x264_mb_predict_mv_direct16x16_spatial( x264_t *h, int ...@@ -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]; 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_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_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 *l1ref0 = &h->fref[1][0]->ref[0][i_mb_8x8];
int8_t *l1ref1 = &h->fref[1][0]->ref[1][i_mb_8x8]; int8_t *l1ref1 = &h->fref[1][0]->ref[1][i_mb_8x8];
......
...@@ -71,7 +71,7 @@ int x264_quant_4x4_altivec( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] ...@@ -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_u32_t multEvenvA, multOddvA;
vec_u16_t mfvA; vec_u16_t mfvA;
vec_u16_t biasvA; 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; vec_s16_t nz = zero_s16v;
vector bool short mskB; 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] ...@@ -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_u32_t multEvenvA, multOddvA;
vec_u16_t mfvA; vec_u16_t mfvA;
vec_u16_t biasvA; 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; vec_s16_t nz = zero_s16v;
vector bool short mskB; vector bool short mskB;
......
...@@ -863,7 +863,7 @@ static void ALWAYS_INLINE x264_cabac_block_residual_internal( x264_t *h, x264_ca ...@@ -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 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] ) if( l[i] )
{ {
......
...@@ -708,7 +708,7 @@ static ALWAYS_INLINE void x264_macroblock_encode_internal( x264_t *h, int plane_ ...@@ -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 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]]; 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 ); 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_ ...@@ -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 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]]; 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]]; int i_mode = h->mb.cache.intra4x4_pred_mode[x264_scan8[i]];
......
...@@ -48,14 +48,14 @@ char **x264_split_options( const char *opt_str, const char * const *options ) ...@@ -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 )) ) while( *option && (strlen( *option ) != length || strncmp( opt, *option, length )) )
option++; option++;
RETURN_IF_ERROR( !*option, "Invalid option '%.*s'\n", length, opt ) RETURN_IF_ERROR( !*option, "Invalid option '%.*s'\n", length, opt );
found_named = 1; found_named = 1;
length += strcspn( opt + length, "," ); length += strcspn( opt + length, "," );
} }
else else
{ {
RETURN_IF_ERROR( opt_count >= options_count, "Too many options given\n" ) 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( found_named, "Ordered option given after named\n" );
size += strlen( options[opt_count] ) + 1; size += strlen( options[opt_count] ) + 1;
} }
opt_count++; opt_count++;
...@@ -65,7 +65,7 @@ char **x264_split_options( const char *opt_str, const char * const *options ) ...@@ -65,7 +65,7 @@ char **x264_split_options( const char *opt_str, const char * const *options )
int offset = 2 * (opt_count+1) * sizeof(char*); int offset = 2 * (opt_count+1) * sizeof(char*);
size += offset + (opt - opt_str); size += offset + (opt - opt_str);
char **opts = calloc( 1, size ); char **opts = calloc( 1, size );
RETURN_IF_ERROR( !opts, "malloc failed\n" ) RETURN_IF_ERROR( !opts, "malloc failed\n" );
#define insert_opt( src, length )\ #define insert_opt( src, length )\
do {\ do {\
......
...@@ -52,18 +52,18 @@ static int handle_opts( crop_hnd_t *h, video_info_t *info, char **opts, const ch ...@@ -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++ ) for( int i = 0; i < 4; i++ )
{ {
char *opt = x264_get_option( optlist[i], opts ); 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 ); 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; 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; return 0;
} }
static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x264_param_t *param, char *opt_string ) 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) ); crop_hnd_t *h = calloc( 1, sizeof(crop_hnd_t) );
if( !h ) if( !h )
return -1; return -1;
...@@ -81,7 +81,7 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2 ...@@ -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[2] = info->width - h->dims[0] - h->dims[2];
h->dims[3] = info->height - h->dims[1] - h->dims[3]; 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] ) 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] ); x264_cli_log( NAME, X264_LOG_INFO, "cropping to %dx%d\n", h->dims[2], h->dims[3] );
......
...@@ -217,13 +217,13 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, ...@@ -217,13 +217,13 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info,
ret = 1; ret = 1;
} }
FAIL_IF_ERROR( bit_depth != X264_BIT_DEPTH, "this build supports only bit depth %d\n", X264_BIT_DEPTH ) 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( ret, "unsupported bit depth conversion.\n" );
/* only add the filter to the chain if it's needed */ /* only add the filter to the chain if it's needed */
if( change_fmt || bit_depth != 8 * x264_cli_csp_depth_factor( csp ) ) 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) ); depth_hnd_t *h = x264_malloc( sizeof(depth_hnd_t) + (info->width+1)*sizeof(int16_t) );
if( !h ) if( !h )
......
...@@ -39,7 +39,7 @@ void x264_cli_plane_copy( uint8_t *dst, int i_dst, uint8_t *src, int i_src, int ...@@ -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 x264_cli_pic_copy( cli_pic_t *out, cli_pic_t *in )
{ {
int csp = in->img.csp & X264_CSP_MASK; 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 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" ); || in->img.width != out->img.width, "incompatible frame properties\n" );
/* copy data */ /* copy data */
......
...@@ -265,7 +265,7 @@ static int handle_opts( const char * const *optlist, char **opts, video_info_t * ...@@ -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 ) && 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 ), 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 else
out_sar_w = out_sar_h = 1; out_sar_w = out_sar_h = 1;
...@@ -275,19 +275,19 @@ static int handle_opts( const char * const *optlist, char **opts, video_info_t * ...@@ -275,19 +275,19 @@ static int handle_opts( const char * const *optlist, char **opts, video_info_t *
if( !strcasecmp( fittobox, "both" ) ) if( !strcasecmp( fittobox, "both" ) )
{ {
FAIL_IF_ERROR( width <= 0 || height <= 0, "invalid box resolution %sx%s\n", FAIL_IF_ERROR( width <= 0 || height <= 0, "invalid box resolution %sx%s\n",
x264_otos( str_width, "<unset>" ), x264_otos( str_height, "<unset>" ) ) x264_otos( str_width, "<unset>" ), x264_otos( str_height, "<unset>" ) );
} }
else if( !strcasecmp( fittobox, "width" ) ) else if( !strcasecmp( fittobox, "width" ) )
{ {
FAIL_IF_ERROR( width <= 0, "invalid box width `%s'\n", x264_otos( str_width, "<unset>" ) ) FAIL_IF_ERROR( width <= 0, "invalid box width `%s'\n", x264_otos( str_width, "<unset>" ) );
height = INT_MAX; height = INT_MAX;
} }
else if( !strcasecmp( fittobox, "height" ) ) else if( !strcasecmp( fittobox, "height" ) )
{ {
FAIL_IF_ERROR( height <= 0, "invalid box height `%s'\n", x264_otos( str_height, "<unset>" ) ) FAIL_IF_ERROR( height <= 0, "invalid box height `%s'\n", x264_otos( str_height, "<unset>" ) );
width = INT_MAX; 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 */ /* maximally fit the new coded resolution to the box */
const x264_cli_csp_t *csp = x264_cli_get_csp( h->dst_csp ); 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 * ...@@ -313,7 +313,7 @@ static int handle_opts( const char * const *optlist, char **opts, video_info_t *
if( str_width || str_height ) if( str_width || str_height )
{ {
FAIL_IF_ERROR( width <= 0 || height <= 0, "invalid resolution %sx%s\n", FAIL_IF_ERROR( width <= 0 || height <= 0, "invalid resolution %sx%s\n",
x264_otos( str_width, "<unset>" ), x264_otos( str_height, "<unset>" ) ) x264_otos( str_width, "<unset>" ), x264_otos( str_height, "<unset>" ) );
if( !str_sar ) /* res only -> adjust sar */ if( !str_sar ) /* res only -> adjust sar */
{ {
/* new_sar = (new_h * old_w * old_sar_w) / (old_h * new_w * old_sar_h) */ /* 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 ) ...@@ -403,7 +403,7 @@ static int check_resizer( resizer_hnd_t *h, cli_pic_t *in )
return -1; return -1;
h->buffer_allocated = 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; return 0;
} }
...@@ -440,7 +440,7 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2 ...@@ -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->variable_input = 1;
h->dst_csp = pick_closest_supported_csp( info->csp ); h->dst_csp = pick_closest_supported_csp( info->csp );
FAIL_IF_ERROR( h->dst_csp == X264_CSP_NONE, 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 else
{ {
...@@ -479,17 +479,17 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2 ...@@ -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, 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 ), "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 ); 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, 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 ), "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 ); 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, 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 */ /* confirm that the desired resolution meets the colorspace requirements */
const x264_cli_csp_t *csp = x264_cli_get_csp( h->dst_csp ); 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, 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 ) 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 ); 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 ...@@ -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 */ /* 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; return 0;
} }
......
...@@ -67,16 +67,16 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2 ...@@ -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 ); int val = x264_otoi( tok, -1 );
if( p ) 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; h->step_size = val;
continue; continue;
} }
FAIL_IF_ERROR( val < 0 || val >= h->step_size, "invalid offset `%s'\n", tok ) 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( h->pattern_len >= MAX_PATTERN_SIZE, "max pattern size %d reached\n", MAX_PATTERN_SIZE );
offsets[h->pattern_len++] = val; offsets[h->pattern_len++] = val;
} }
FAIL_IF_ERROR( !h->step_size, "no step size provided\n" ) 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->pattern_len, "no offsets supplied\n" );
h->pattern = malloc( h->pattern_len * sizeof(int) ); h->pattern = malloc( h->pattern_len * sizeof(int) );
if( !h->pattern ) if( !h->pattern )
......
...@@ -159,9 +159,9 @@ static float get_avs_version( avs_hnd_t *h ) ...@@ -159,9 +159,9 @@ static float get_avs_version( avs_hnd_t *h )
#if USE_AVXSYNTH #if USE_AVXSYNTH
return 2.58f; return 2.58f;
#else #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 ); 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" ); FAIL_IF_ERROR( !avs_is_float( ver ), "VersionNumber did not return a float value\n" );
float ret = avs_as_float( ver ); float ret = avs_as_float( ver );
h->func.avs_release_value( 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 ...@@ -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) ); avs_hnd_t *h = malloc( sizeof(avs_hnd_t) );
if( !h ) if( !h )
return -1; 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 ); h->env = h->func.avs_create_script_environment( AVS_INTERFACE_25 );
if( h->func.avs_get_error ) 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 ...@@ -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" ) ) if( !strcasecmp( filename_ext, "avs" ) )
{ {
res = h->func.avs_invoke( h->env, "Import", arg, NULL ); 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. /* check if the user is using a multi-threaded script and apply distributor if necessary.
adapted from avisynth's vfw interface */ adapted from avisynth's vfw interface */
AVS_Value mt_test = h->func.avs_invoke( h->env, "GetMTMode", avs_new_value_bool( 0 ), NULL ); 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 ...@@ -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" ); 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 ); h->clip = h->func.avs_take_clip( res, h->env );
const AVS_VideoInfo *vi = h->func.avs_get_video_info( h->clip ); 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 the clip is made of fields instead of frames, call weave to make them frames */
if( avs_is_field_based( vi ) ) if( avs_is_field_based( vi ) )
{ {
x264_cli_log( "avs", X264_LOG_WARNING, "detected fieldbased (separated) input, weaving to frames\n" ); 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 ); 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 ); res = update_clip( h, &vi, tmp, res );
info->interlaced = 1; info->interlaced = 1;
info->tff = avs_is_tff( vi ); 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 ...@@ -267,7 +267,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
#if !HAVE_SWSCALE #if !HAVE_SWSCALE
/* if swscale is not available, convert the CSP if necessary */ /* 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), 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 )) || 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 )) ) (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 ...@@ -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"; opt->output_csp == X264_CSP_I444 ? "YV24" : "RGB";
x264_cli_log( "avs", X264_LOG_WARNING, "converting input clip to %s\n", csp ); 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), 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), 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), 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]; char conv_func[14];
snprintf( conv_func, sizeof(conv_func), "ConvertTo%s", csp ); snprintf( conv_func, sizeof(conv_func), "ConvertTo%s", csp );
char matrix[7] = ""; char matrix[7] = "";
...@@ -302,7 +302,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c ...@@ -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[1] = avs_new_value_bool( info->interlaced );
arg_arr[2] = avs_new_value_string( matrix ); 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 ); 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 ); 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 */ /* 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 ...@@ -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 ); arg_arr[1] = avs_new_value_string( levels );
const char *arg_name[] = { NULL, "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 ); 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 ); res = update_clip( h, &vi, res2, res );
// notification that the input range has changed to the desired one // notification that the input range has changed to the desired one
opt->input_range = opt->output_range; opt->input_range = opt->output_range;
...@@ -381,7 +381,7 @@ static int read_frame( cli_pic_t *pic, hnd_t handle, int i_frame ) ...@@ -381,7 +381,7 @@ static int read_frame( cli_pic_t *pic, hnd_t handle, int i_frame )
return -1; return -1;
AVS_VideoFrame *frm = pic->opaque = h->func.avs_get_frame( h->clip, i_frame ); 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 ); 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++ ) for( int i = 0; i < pic->img.planes; i++ )
{ {
/* explicitly cast away the const attribute to avoid a warning */ /* explicitly cast away the const attribute to avoid a warning */
......
...@@ -102,14 +102,14 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c ...@@ -102,14 +102,14 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
if( !idx ) if( !idx )
{ {
FFMS_Indexer *indexer = FFMS_CreateIndexer( psz_filename, &e ); 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 ) if( opt->progress )
FFMS_SetProgressCallback( indexer, update_progress, &h->time ); FFMS_SetProgressCallback( indexer, update_progress, &h->time );
idx = FFMS_DoIndexing2( indexer, FFMS_IEH_ABORT, &e ); idx = FFMS_DoIndexing2( indexer, FFMS_IEH_ABORT, &e );
fprintf( stderr, "%*c", PROGRESS_LENGTH+1, '\r' ); 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 ) ) if( opt->index_file && FFMS_WriteIndex( opt->index_file, idx, &e ) )
x264_cli_log( "ffms", X264_LOG_WARNING, "could not write index file\n" ); 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 ...@@ -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 ); h->video_source = FFMS_CreateVideoSource( psz_filename, trackno, idx, 1, seekmode, &e );
FFMS_DestroyIndex( idx ); FFMS_DestroyIndex( idx );
FAIL_IF_ERROR( trackno < 0, "could not find video track\n" ) 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( !h->video_source, "could not create video source\n" );
const FFMS_VideoProperties *videop = FFMS_GetVideoProperties( h->video_source ); const FFMS_VideoProperties *videop = FFMS_GetVideoProperties( h->video_source );
info->num_frames = h->num_frames = videop->NumFrames; 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 ...@@ -134,7 +134,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
info->thread_safe = 0; info->thread_safe = 0;
const FFMS_Frame *frame = FFMS_GetFrame( h->video_source, 0, &e ); 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->fullrange = 0;
info->width = frame->EncodedWidth; info->width = frame->EncodedWidth;
...@@ -185,7 +185,7 @@ static int read_frame( cli_pic_t *pic, hnd_t handle, int i_frame ) ...@@ -185,7 +185,7 @@ static int read_frame( cli_pic_t *pic, hnd_t handle, int i_frame )
FFMS_ErrorInfo e; FFMS_ErrorInfo e;
e.BufferSize = 0; e.BufferSize = 0;
const FFMS_Frame *frame = FFMS_GetFrame( h->video_source, i_frame, &e ); 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.stride, frame->Linesize, sizeof(pic->img.stride) );
memcpy( pic->img.plane, frame->Data, sizeof(pic->img.plane) ); 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 ) ...@@ -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 ); const FFMS_FrameInfo *info = FFMS_GetFrameInfo( h->track, i_frame );
FAIL_IF_ERROR( info->PTS == AV_NOPTS_VALUE, "invalid timestamp. " 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->pts = info->PTS >> h->reduce_pts;
pic->duration = 0; pic->duration = 0;
......
...@@ -168,15 +168,15 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c ...@@ -168,15 +168,15 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
if( opt->format ) if( opt->format )
FAIL_IF_ERROR( !(format = av_find_input_format( opt->format )), "unknown file format: %s\n", 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 ) if( options )
av_dict_free( &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; int i = 0;
while( i < h->lavf->nb_streams && h->lavf->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO ) while( i < h->lavf->nb_streams && h->lavf->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO )
i++; 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->stream_id = i;
h->next_frame = 0; h->next_frame = 0;
AVCodecContext *c = h->lavf->streams[i]->codec; 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 ...@@ -188,13 +188,13 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
info->thread_safe = 0; info->thread_safe = 0;
h->vfr_input = info->vfr; h->vfr_input = info->vfr;
FAIL_IF_ERROR( avcodec_open2( c, avcodec_find_decoder( c->codec_id ), NULL ), 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 */ /* prefetch the first frame and set/confirm flags */
h->first_pic = malloc( sizeof(cli_pic_t) ); 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 ), FAIL_IF_ERROR( !h->first_pic || lavf_input.picture_alloc( h->first_pic, h, X264_CSP_OTHER, info->width, info->height ),