From 64fa70e78c459688197ce907326b21bf4799f8ab Mon Sep 17 00:00:00 2001 From: Anton Mitrofanov Date: Tue, 8 Jun 2010 02:43:37 +0400 Subject: [PATCH] Warn about shadowed variable declarations Also get rid of a few instances of variable shadowing. --- common/ppc/pixel.c | 12 ++++++------ configure | 4 ++++ encoder/ratecontrol.c | 30 ++++++++++++++---------------- encoder/slicetype.c | 4 ++-- input/ffms.c | 22 +++++++++++----------- input/input.h | 2 +- x264.c | 6 +++--- 7 files changed, 41 insertions(+), 39 deletions(-) diff --git a/common/ppc/pixel.c b/common/ppc/pixel.c index 439e9d2d..832ec50b 100644 --- a/common/ppc/pixel.c +++ b/common/ppc/pixel.c @@ -1900,9 +1900,9 @@ static const vec_u8_t hadamard_permtab[] = static uint64_t x264_pixel_hadamard_ac_16x16_altivec( uint8_t *pix, int stride ) { - int index = ((uintptr_t)pix & 8) >> 3; - vec_u8_t permh = hadamard_permtab[index]; - vec_u8_t perml = hadamard_permtab[!index]; + int idx = ((uintptr_t)pix & 8) >> 3; + vec_u8_t permh = hadamard_permtab[idx]; + vec_u8_t perml = hadamard_permtab[!idx]; uint64_t sum = pixel_hadamard_ac_altivec( pix, stride, permh ); sum += pixel_hadamard_ac_altivec( pix+8, stride, perml ); sum += pixel_hadamard_ac_altivec( pix+8*stride, stride, permh ); @@ -1912,9 +1912,9 @@ static uint64_t x264_pixel_hadamard_ac_16x16_altivec( uint8_t *pix, int stride ) static uint64_t x264_pixel_hadamard_ac_16x8_altivec( uint8_t *pix, int stride ) { - int index = ((uintptr_t)pix & 8) >> 3; - vec_u8_t permh = hadamard_permtab[index]; - vec_u8_t perml = hadamard_permtab[!index]; + int idx = ((uintptr_t)pix & 8) >> 3; + vec_u8_t permh = hadamard_permtab[idx]; + vec_u8_t perml = hadamard_permtab[!idx]; uint64_t sum = pixel_hadamard_ac_altivec( pix, stride, permh ); sum += pixel_hadamard_ac_altivec( pix+8, stride, perml ); return ((sum>>34)<<32) + ((uint32_t)sum>>1); diff --git a/configure b/configure index 68b41684..3a38cb5c 100755 --- a/configure +++ b/configure @@ -636,6 +636,10 @@ elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then define ftell ftello64 fi +if cc_check '' -Wshadow ; then + CFLAGS="-Wshadow $CFLAGS" +fi + rm -f conftest* # generate config files diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c index 71b138d4..bf0d9d1c 100644 --- a/encoder/ratecontrol.c +++ b/encoder/ratecontrol.c @@ -241,8 +241,6 @@ void x264_adaptive_quant_frame( x264_t *h, x264_frame_t *frame, float *quant_off * FIXME: while they're written in 5 significant digits, they're only tuned to 2. */ float strength; float avg_adj = 0.f; - int width = h->mb.i_mb_width; - int height = h->mb.i_mb_height; /* Initialize frame stats */ for( int i = 0; i < 3; i++ ) { @@ -276,8 +274,8 @@ void x264_adaptive_quant_frame( x264_t *h, x264_frame_t *frame, float *quant_off /* Need variance data for weighted prediction */ if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_FAKE || h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART ) { - for( int mb_y = 0; mb_y < height; mb_y++ ) - for( int mb_x = 0; mb_x < width; mb_x++ ) + for( int mb_y = 0; mb_y < h->mb.i_mb_height; mb_y++ ) + for( int mb_x = 0; mb_x < h->mb.i_mb_width; mb_x++ ) x264_ac_energy_mb( h, mb_x, mb_y, frame ); } else @@ -289,8 +287,8 @@ void x264_adaptive_quant_frame( x264_t *h, x264_frame_t *frame, float *quant_off if( h->param.rc.i_aq_mode == X264_AQ_AUTOVARIANCE ) { float avg_adj_pow2 = 0.f; - for( int mb_y = 0; mb_y < height; mb_y++ ) - for( int mb_x = 0; mb_x < width; mb_x++ ) + for( int mb_y = 0; mb_y < h->mb.i_mb_height; mb_y++ ) + for( int mb_x = 0; mb_x < h->mb.i_mb_width; mb_x++ ) { uint32_t energy = x264_ac_energy_mb( h, mb_x, mb_y, frame ); float qp_adj = powf( energy + 1, 0.125f ); @@ -306,8 +304,8 @@ void x264_adaptive_quant_frame( x264_t *h, x264_frame_t *frame, float *quant_off else strength = h->param.rc.f_aq_strength * 1.0397f; - for( int mb_y = 0; mb_y < height; mb_y++ ) - for( int mb_x = 0; mb_x < width; mb_x++ ) + for( int mb_y = 0; mb_y < h->mb.i_mb_height; mb_y++ ) + for( int mb_x = 0; mb_x < h->mb.i_mb_width; mb_x++ ) { float qp_adj; int mb_xy = mb_x + mb_y*h->mb.i_mb_stride; @@ -335,9 +333,9 @@ void x264_adaptive_quant_frame( x264_t *h, x264_frame_t *frame, float *quant_off { uint64_t ssd = frame->i_pixel_ssd[i]; uint64_t sum = frame->i_pixel_sum[i]; - int w = width*16>>!!i; - int h = height*16>>!!i; - frame->i_pixel_ssd[i] = ssd - (sum * sum + w * h / 2) / (w * h); + int width = h->mb.i_mb_width*16>>!!i; + int height = h->mb.i_mb_height*16>>!!i; + frame->i_pixel_ssd[i] = ssd - (sum * sum + width * height / 2) / (width * height); } } @@ -2568,14 +2566,14 @@ static int init_pass2( x264_t *h ) for( int j = 0; j < filter_size; j++ ) { - int index = i+j-filter_size/2; - double d = index-i; + int idx = i+j-filter_size/2; + double d = idx-i; double coeff = qblur==0 ? 1.0 : exp( -d*d/(qblur*qblur) ); - if( index < 0 || index >= rcc->num_entries ) + if( idx < 0 || idx >= rcc->num_entries ) continue; - if( rce->pict_type != rcc->entry[index].pict_type ) + if( rce->pict_type != rcc->entry[idx].pict_type ) continue; - q += qscale[index] * coeff; + q += qscale[idx] * coeff; sum += coeff; } blurred_qscale[i] = q/sum; diff --git a/encoder/slicetype.c b/encoder/slicetype.c index 8aff7eae..0717c9c5 100644 --- a/encoder/slicetype.c +++ b/encoder/slicetype.c @@ -1405,10 +1405,10 @@ void x264_slicetype_decide( x264_t *h ) int i_coded = h->lookahead->next.list[0]->i_frame; if( bframes ) { - int index[] = { brefs+1, 1 }; + int idx_list[] = { brefs+1, 1 }; for( int i = 0; i < bframes; i++ ) { - int idx = index[h->lookahead->next.list[i]->i_type == X264_TYPE_BREF]++; + int idx = idx_list[h->lookahead->next.list[i]->i_type == X264_TYPE_BREF]++; frames[idx] = h->lookahead->next.list[i]; frames[idx]->i_reordered_pts = h->lookahead->next.list[idx]->i_pts; } diff --git a/input/ffms.c b/input/ffms.c index 08ac21f1..b2a253e7 100644 --- a/input/ffms.c +++ b/input/ffms.c @@ -74,35 +74,35 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c e.BufferSize = 0; int seekmode = opt->seek ? FFMS_SEEK_NORMAL : FFMS_SEEK_LINEAR_NO_RW; - FFMS_Index *index = NULL; - if( opt->index ) + FFMS_Index *idx = NULL; + if( opt->index_file ) { struct stat index_s, input_s; - if( !stat( opt->index, &index_s ) && !stat( psz_filename, &input_s ) && + if( !stat( opt->index_file, &index_s ) && !stat( psz_filename, &input_s ) && input_s.st_mtime < index_s.st_mtime ) - index = FFMS_ReadIndex( opt->index, &e ); + idx = FFMS_ReadIndex( opt->index_file, &e ); } - if( !index ) + if( !idx ) { - index = FFMS_MakeIndex( psz_filename, 0, 0, NULL, NULL, 0, update_progress, NULL, &e ); + idx = FFMS_MakeIndex( psz_filename, 0, 0, NULL, NULL, 0, update_progress, NULL, &e ); fprintf( stderr, " \r" ); - if( !index ) + if( !idx ) { fprintf( stderr, "ffms [error]: could not create index\n" ); return -1; } - if( opt->index && FFMS_WriteIndex( opt->index, index, &e ) ) + if( opt->index_file && FFMS_WriteIndex( opt->index_file, idx, &e ) ) fprintf( stderr, "ffms [warning]: could not write index file\n" ); } - int trackno = FFMS_GetFirstTrackOfType( index, FFMS_TYPE_VIDEO, &e ); + int trackno = FFMS_GetFirstTrackOfType( idx, FFMS_TYPE_VIDEO, &e ); if( trackno < 0 ) { fprintf( stderr, "ffms [error]: could not find video track\n" ); return -1; } - h->video_source = FFMS_CreateVideoSource( psz_filename, trackno, index, 1, seekmode, &e ); + h->video_source = FFMS_CreateVideoSource( psz_filename, trackno, idx, 1, seekmode, &e ); if( !h->video_source ) { fprintf( stderr, "ffms [error]: could not create video source\n" ); @@ -111,7 +111,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c h->track = FFMS_GetTrackFromVideo( h->video_source ); - FFMS_DestroyIndex( index ); + FFMS_DestroyIndex( idx ); const FFMS_VideoProperties *videop = FFMS_GetVideoProperties( h->video_source ); h->total_frames = videop->NumFrames; info->sar_height = videop->SARDen; diff --git a/input/input.h b/input/input.h index eb62fdd4..f89b13b1 100644 --- a/input/input.h +++ b/input/input.h @@ -28,7 +28,7 @@ /* options that are used by only some demuxers */ typedef struct { - char *index; + char *index_file; char *resolution; /* resolution string parsed by raw yuv input */ char *timebase; int seek; diff --git a/x264.c b/x264.c index 50498936..8e6a3b77 100644 --- a/x264.c +++ b/x264.c @@ -177,10 +177,10 @@ int main( int argc, char **argv ) return ret; } -static char const *strtable_lookup( const char * const table[], int index ) +static char const *strtable_lookup( const char * const table[], int idx ) { int i = 0; while( table[i] ) i++; - return ( ( index >= 0 && index < i ) ? table[ index ] : "???" ); + return ( ( idx >= 0 && idx < i ) ? table[ idx ] : "???" ); } static char *stringify_names( char *buf, const char * const names[] ) @@ -1006,7 +1006,7 @@ static int Parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt ) } break; case OPT_INDEX: - input_opt.index = optarg; + input_opt.index_file = optarg; break; case OPT_QPFILE: opt->qpfile = fopen( optarg, "rb" ); -- 2.40.0