[vlc-commits] video_filter: gradient: use C99 loop declarations

Tristan Matthews git at videolan.org
Mon Aug 31 20:11:03 CEST 2015


vlc | branch: master | Tristan Matthews <tmatth at videolan.org> | Mon Aug 31 13:16:58 2015 -0400| [95390baccafa21eb08ce89a33fcac041cf6ebebf] | committer: Tristan Matthews

video_filter: gradient: use C99 loop declarations

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=95390baccafa21eb08ce89a33fcac041cf6ebebf
---

 modules/video_filter/gradient.c |   37 ++++++++++++++++---------------------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/modules/video_filter/gradient.c b/modules/video_filter/gradient.c
index 0c3d515..43eee55 100644
--- a/modules/video_filter/gradient.c
+++ b/modules/video_filter/gradient.c
@@ -294,10 +294,9 @@ static void GaussianConvolution( picture_t *p_inpic, uint32_t *p_smooth )
     const int i_src_visible = p_inpic->p[Y_PLANE].i_visible_pitch;
     const int i_num_lines = p_inpic->p[Y_PLANE].i_visible_lines;
 
-    int x,y;
-    for( y = 2; y < i_num_lines - 2; y++ )
+    for( int y = 2; y < i_num_lines - 2; y++ )
     {
-        for( x = 2; x < i_src_visible - 2; x++ )
+        for( int x = 2; x < i_src_visible - 2; x++ )
         {
             p_smooth[y*i_src_visible+x] = (uint32_t)(
               /* 2 rows up */
@@ -341,7 +340,6 @@ static void GaussianConvolution( picture_t *p_inpic, uint32_t *p_smooth )
 static void FilterGradient( filter_t *p_filter, picture_t *p_inpic,
                                                 picture_t *p_outpic )
 {
-    int x, y;
     const int i_src_pitch = p_inpic->p[Y_PLANE].i_pitch;
     const int i_src_visible = p_inpic->p[Y_PLANE].i_visible_pitch;
     const int i_dst_pitch = p_outpic->p[Y_PLANE].i_pitch;
@@ -380,9 +378,9 @@ static void FilterGradient( filter_t *p_filter, picture_t *p_inpic,
      | -1 0 1 |     | -1 -2 -1 | */
 
 #define FOR                                                     \
-    for( y = 1; y < i_num_lines - 1; y++ )                      \
+    for( int y = 1; y < i_num_lines - 1; y++ )                  \
     {                                                           \
-        for( x = 1; x < i_src_visible - 1; x++ )                \
+        for( int x = 1; x < i_src_visible - 1; x++ )            \
         {                                                       \
             const uint32_t a =                                  \
             (                                                   \
@@ -467,8 +465,6 @@ static void FilterGradient( filter_t *p_filter, picture_t *p_inpic,
 static void FilterEdge( filter_t *p_filter, picture_t *p_inpic,
                                             picture_t *p_outpic )
 {
-    int x, y;
-
     const int i_src_pitch = p_inpic->p[Y_PLANE].i_pitch;
     const int i_src_visible = p_inpic->p[Y_PLANE].i_visible_pitch;
     const int i_dst_pitch = p_outpic->p[Y_PLANE].i_pitch;
@@ -521,9 +517,9 @@ static void FilterEdge( filter_t *p_filter, picture_t *p_inpic,
      | -2 0 2 | and |  0  0  0 |
      | -1 0 1 |     | -1 -2 -1 | */
 
-    for( y = 1; y < i_num_lines - 1; y++ )
+    for( int y = 1; y < i_num_lines - 1; y++ )
     {
-        for( x = 1; x < i_src_visible - 1; x++ )
+        for( int x = 1; x < i_src_visible - 1; x++ )
         {
 
             const int gradx =
@@ -559,9 +555,9 @@ static void FilterEdge( filter_t *p_filter, picture_t *p_inpic,
     }
 
     /* edge computing */
-    for( y = 1; y < i_num_lines - 1; y++ )
+    for( int y = 1; y < i_num_lines - 1; y++ )
     {
-        for( x = 1; x < i_src_visible - 1; x++ )
+        for( int x = 1; x < i_src_visible - 1; x++ )
         {
             if( p_grad[y*i_src_visible+x] > 40 )
             {
@@ -627,7 +623,6 @@ static void FilterEdge( filter_t *p_filter, picture_t *p_inpic,
 static void FilterHough( filter_t *p_filter, picture_t *p_inpic,
                                              picture_t *p_outpic )
 {
-    int x, y, i;
     int i_src_visible = p_inpic->p[Y_PLANE].i_visible_pitch;
     int i_dst_pitch = p_outpic->p[Y_PLANE].i_pitch;
     int i_num_lines = p_inpic->p[Y_PLANE].i_visible_lines;
@@ -663,12 +658,12 @@ static void FilterHough( filter_t *p_filter, picture_t *p_inpic,
             free( p_hough );
             return;
         }
-        for( i = 0 ; i < i_nb_steps ; i++)
+        for( int i = 0; i < i_nb_steps; i++)
         {
             d_sin = sin(d_step * i);
             d_cos = cos(d_step * i);
-            for( y = 0 ; y < i_num_lines ; y++ )
-                for( x = 0 ; x < i_src_visible ; x++ )
+            for( int y = 0; y < i_num_lines; y++ )
+                for( int x = 0; x < i_src_visible; x++ )
                 {
                     p_pre_hough[(i*i_num_lines+y)*i_src_visible + x] =
                         ceil(x*d_sin + y*d_cos);
@@ -694,9 +689,9 @@ static void FilterHough( filter_t *p_filter, picture_t *p_inpic,
     i_max = 0;
     i_rho_max = 0;
     i_phi_max = 0;
-    for( y = 4; y < i_num_lines - 4; y++ )
+    for( int y = 4; y < i_num_lines - 4; y++ )
     {
-        for( x = 4; x < i_src_visible - 4; x++ )
+        for( int x = 4; x < i_src_visible - 4; x++ )
         {
             uint32_t a =
             (
@@ -720,7 +715,7 @@ static void FilterHough( filter_t *p_filter, picture_t *p_inpic,
             );
             if( a>>8 )
             {
-                for( i = 0 ; i < i_nb_steps ; i ++ )
+                for( int i = 0; i < i_nb_steps; i++ )
                 {
                     i_rho = p_pre_hough[(i*i_num_lines+y)*i_src_visible + x];
                     if( p_hough[i_rho + i_diag/2 + i * i_diag]++ > i_max )
@@ -738,9 +733,9 @@ static void FilterHough( filter_t *p_filter, picture_t *p_inpic,
     d_cos = cos(i_phi_max*d_step);
     if( d_cos != 0 )
     {
-        for( x = 0 ; x < i_src_visible ; x++ )
+        for( int x = 0; x < i_src_visible; x++ )
         {
-            y = (i_rho_max - x * d_sin) / d_cos;
+            int y = (i_rho_max - x * d_sin) / d_cos;
             if( y >= 0 && y < i_num_lines )
                 p_outpix[y*i_dst_pitch+x] = 255;
         }



More information about the vlc-commits mailing list