]> git.sesse.net Git - x264/commitdiff
Warn about shadowed variable declarations
authorAnton Mitrofanov <BugMaster@narod.ru>
Mon, 7 Jun 2010 22:43:37 +0000 (02:43 +0400)
committerFiona Glaser <fiona@x264.com>
Wed, 9 Jun 2010 18:36:43 +0000 (11:36 -0700)
Also get rid of a few instances of variable shadowing.

common/ppc/pixel.c
configure
encoder/ratecontrol.c
encoder/slicetype.c
input/ffms.c
input/input.h
x264.c

index 439e9d2d785021776a4af13ae384b3876e5e7cb1..832ec50bcc1273a10c68414075f12e4989262e0c 100644 (file)
@@ -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);
index 68b4168412c184ebb69efe3909bd9ddf9f87d136..3a38cb5c9eb6291b58862e1786eca2e7a6bfb904 100755 (executable)
--- 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
index 71b138d4fa482857b6c77e6703be94701798fe86..bf0d9d1cb67b34abc26a4809d5a4ec0acfcf19ec 100644 (file)
@@ -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;
index 8aff7eaee6fdddc767b20e7dfc7e4df975412438..0717c9c51fe454a17e5e5186eee729b12a4272d1 100644 (file)
@@ -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;
         }
index 08ac21f1cddf5f42b771e3aa6aa6050a643cdbda..b2a253e7d3a3ac3f8500c968156ec483df97bab4 100644 (file)
@@ -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;
index eb62fdd441c70bb5e47351c867a30f7c503afb13..f89b13b1ee0149f6450be73385b29c50967bec17 100644 (file)
@@ -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 504989366ebb67de39b9644f731ec79726044341..8e6a3b77b40059eb50deea76b9d4f4b767330e1b 100644 (file)
--- 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" );