[vlc-commits] vhs: refactor integers

Alexandre Janniaux git at videolan.org
Mon Oct 5 20:45:21 CEST 2020


vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Sun Sep 20 18:00:06 2020 +0200| [8a44e3b5b89dc0f3251a112da1d037f875842e9e] | committer: Alexandre Janniaux

vhs: refactor integers

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

 modules/video_filter/vhs.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/modules/video_filter/vhs.c b/modules/video_filter/vhs.c
index a76bc9500a..28661d4c58 100644
--- a/modules/video_filter/vhs.c
+++ b/modules/video_filter/vhs.c
@@ -43,7 +43,7 @@ static inline int64_t MOD(int64_t a, int64_t b) {
 #define MAX_BLUE_RED_LINES 100
 
 typedef struct {
-    int32_t  i_offset;
+    unsigned  i_offset;
     uint16_t i_intensity;
     bool     b_blue_red;
     vlc_tick_t  i_stop_trigger;
@@ -54,7 +54,7 @@ typedef struct
 
     /* general data */
     bool b_init;
-    int32_t  i_planes;
+    size_t  i_planes;
     int32_t i_height[VOUT_MAX_PLANES]; /* note: each plane may have different dimensions */
     int32_t i_width[VOUT_MAX_PLANES];
     int32_t i_visible_pitch[VOUT_MAX_PLANES];
@@ -63,11 +63,11 @@ typedef struct
     vlc_tick_t  i_cur_time;
 
     /* sliding & offset effect */
-    int32_t  i_phase_speed;
-    int32_t  i_phase_ofs;
-    int32_t  i_offset_ofs;
-    int32_t  i_sliding_ofs;
-    int32_t  i_sliding_speed;
+    int  i_phase_speed;
+    int  i_phase_ofs;
+    int  i_offset_ofs;
+    int  i_sliding_ofs;
+    int  i_sliding_speed;
     vlc_tick_t  i_offset_trigger;
     vlc_tick_t  i_sliding_trigger;
     vlc_tick_t  i_sliding_stop_trig;
@@ -224,7 +224,7 @@ static int vhs_allocate_data( filter_t *p_filter, picture_t *p_pic_in ) {
     */
     p_sys->i_planes = p_pic_in->i_planes;
 
-    for ( int32_t i_p = 0; i_p < p_sys->i_planes; i_p++) {
+    for ( size_t i_p = 0; i_p < p_sys->i_planes; i_p++) {
         p_sys->i_visible_pitch [i_p] = (int) p_pic_in->p[i_p].i_visible_pitch;
         p_sys->i_height[i_p] = (int) p_pic_in->p[i_p].i_visible_lines;
         p_sys->i_width [i_p] = (int) p_pic_in->p[i_p].i_visible_pitch / p_pic_in->p[i_p].i_pixel_pitch;
@@ -260,7 +260,7 @@ static int vhs_blue_red_line_effect( filter_t *p_filter, picture_t *p_pic_out )
 
     /* generate new blue or red lines */
     if ( p_sys->i_BR_line_trigger <= p_sys->i_cur_time ) {
-        for ( uint32_t i_b = 0; i_b < MAX_BLUE_RED_LINES; i_b++ )
+        for ( size_t i_b = 0; i_b < MAX_BLUE_RED_LINES; i_b++ )
             if (p_sys->p_BR_lines[i_b] == NULL) {
                 /* allocate data */
                 p_sys->p_BR_lines[i_b] = calloc( 1, sizeof(blue_red_line_t) );
@@ -283,7 +283,7 @@ static int vhs_blue_red_line_effect( filter_t *p_filter, picture_t *p_pic_out )
 
 
     /* manage and apply current blue/red lines */
-    for ( uint8_t i_b = 0; i_b < MAX_BLUE_RED_LINES; i_b++ )
+    for ( size_t i_b = 0; i_b < MAX_BLUE_RED_LINES; i_b++ )
         if ( p_sys->p_BR_lines[i_b] ) {
             /* remove outdated ones */
             if ( p_sys->p_BR_lines[i_b]->i_stop_trigger <= p_sys->i_cur_time ) {
@@ -292,7 +292,7 @@ static int vhs_blue_red_line_effect( filter_t *p_filter, picture_t *p_pic_out )
             }
 
             /* otherwise apply */
-            for ( int32_t i_p=0; i_p < p_sys->i_planes; i_p++ ) {
+            for ( size_t i_p=0; i_p < p_sys->i_planes; i_p++ ) {
                 uint32_t i_pix_ofs = p_sys->p_BR_lines[i_b]->i_offset
                                    * p_pic_out->p[i_p].i_visible_lines
                                    / p_sys->i_height[Y_PLANE]
@@ -340,7 +340,7 @@ static void vhs_blue_red_dots_effect( filter_t *p_filter, picture_t *p_pic_out )
         uint16_t i_y = (unsigned)vlc_mrand48() % p_sys->i_height[Y_PLANE];
         bool b_color = ( ( (unsigned)vlc_mrand48() % 2 ) == 0);
 
-        for ( int32_t i_p = 0; i_p < p_sys->i_planes; i_p++ ) {
+        for ( size_t i_p = 0; i_p < p_sys->i_planes; i_p++ ) {
             uint32_t i_pix_ofs = i_y
                                * p_pic_out->p[i_p].i_visible_lines
                                / p_sys->i_height[Y_PLANE]
@@ -481,7 +481,7 @@ static int vhs_sliding_effect_apply( filter_t *p_filter, picture_t *p_pic_out )
 {
     filter_sys_t *p_sys = p_filter->p_sys;
 
-    for ( uint8_t i_p = 0; i_p < p_pic_out->i_planes; i_p++ ) {
+    for ( size_t i_p = 0; i_p < p_sys->i_planes; i_p++ ) {
         /* first allocate temporary buffer for swap operation */
         uint8_t *p_temp_buf;
         if ( !p_sys->i_sliding_type_duplicate ) {
@@ -496,9 +496,10 @@ static int vhs_sliding_effect_apply( filter_t *p_filter, picture_t *p_pic_out )
             p_temp_buf = p_pic_out->p[i_p].p_pixels;
 
         /* copy lines to output_pic */
-        for ( int32_t i_y = 0; i_y < p_pic_out->p[i_p].i_visible_lines; i_y++ )
+        size_t lines = p_pic_out->p[i_p].i_visible_lines;
+        for ( size_t i_y = 0; i_y < lines; i_y++ )
         {
-            int32_t i_ofs = p_sys->i_offset_ofs + p_sys->i_sliding_ofs;
+            int i_ofs = p_sys->i_offset_ofs + p_sys->i_sliding_ofs;
 
             if ( ( p_sys->i_sliding_speed == 0 ) || !p_sys->i_sliding_type_duplicate )
                 i_ofs += p_sys->i_phase_ofs;



More information about the vlc-commits mailing list