vlc | branch: master | Tristan Matthews <tma...@videolan.org> | Tue Jul 16 
15:53:22 2019 -0400| [11650366fbf9adf9f9c05a1dd996060d683aece2] | committer: 
Tristan Matthews

adjust: round when dividing

Fixes #22205

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

 modules/video_filter/adjust_sat_hue.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/modules/video_filter/adjust_sat_hue.c 
b/modules/video_filter/adjust_sat_hue.c
index f7a3d6142e..6968fcad1b 100644
--- a/modules/video_filter/adjust_sat_hue.c
+++ b/modules/video_filter/adjust_sat_hue.c
@@ -38,34 +38,34 @@
 
 #define PLANAR_WRITE_UV_CLIP( i_bpp ) \
     i_u = *p_in++ ; i_v = *p_in_v++ ; \
-    *p_out++ = VLC_CLIP( (( ((i_u * i_cos + i_v * i_sin - i_x) >> i_bpp) \
-                     * i_sat) >> i_bpp) + I_MID( i_bpp ), 0, I_MAX( i_bpp ) ); 
\
-    *p_out_v++ = VLC_CLIP( (( ((i_v * i_cos - i_u * i_sin - i_y) >> i_bpp) \
-                       * i_sat) >> i_bpp) + I_MID( i_bpp ), 0, I_MAX( i_bpp ) )
+    *p_out++ = VLC_CLIP( ((( (((i_u * i_cos + i_v * i_sin - i_x) + I_MID( 
i_bpp )) >> i_bpp) \
+                     * i_sat) + I_MID( i_bpp )) >> i_bpp) + I_MID( i_bpp ), 0, 
I_MAX( i_bpp ) ); \
+    *p_out_v++ = VLC_CLIP( ((( (((i_v * i_cos - i_u * i_sin - i_y) + I_MID( 
i_bpp )) >> i_bpp) \
+                       * i_sat) + I_MID( i_bpp )) >> i_bpp) + I_MID( i_bpp ), 
0, I_MAX( i_bpp ) )
 
 #define PLANAR_WRITE_UV( i_bpp ) \
     i_u = *p_in++ ; i_v = *p_in_v++ ; \
-    *p_out++ = (( ((i_u * i_cos + i_v * i_sin - i_x) >> i_bpp) \
-                       * i_sat) >> i_bpp) + I_MID( i_bpp ); \
-    *p_out_v++ = (( ((i_v * i_cos - i_u * i_sin - i_y) >> i_bpp) \
-                       * i_sat) >> i_bpp) + I_MID( i_bpp )
+    *p_out++ = ((( (((i_u * i_cos + i_v * i_sin - i_x) + I_MID( i_bpp )) >> 
i_bpp) \
+                       * i_sat) + I_MID( i_bpp )) >> i_bpp) + I_MID( i_bpp ); \
+    *p_out_v++ = ((( (((i_v * i_cos - i_u * i_sin - i_y) + I_MID( i_bpp )) >> 
i_bpp) \
+                       * i_sat) + I_MID( i_bpp )) >> i_bpp) + I_MID( i_bpp )
 
 #define PACKED_WRITE_UV_CLIP() \
     i_u = *p_in; p_in += 4; i_v = *p_in_v; p_in_v += 4; \
-    *p_out = clip_uint8_vlc( (( ((i_u * i_cos + i_v * i_sin - i_x) >> 8) \
-                           * i_sat) >> 8) + 128); \
+    *p_out = clip_uint8_vlc( ((( (((i_u * i_cos + i_v * i_sin - i_x) + I_MID( 
8 )) >> 8) \
+                           * i_sat) + I_MID( 8 )) >> 8) + 128); \
     p_out += 4; \
-    *p_out_v = clip_uint8_vlc( (( ((i_v * i_cos - i_u * i_sin - i_y) >> 8) \
-                           * i_sat) >> 8) + 128); \
+    *p_out_v = clip_uint8_vlc( ((( (((i_v * i_cos - i_u * i_sin - i_y) + 
I_MID( 8 )) >> 8) \
+                           * i_sat) + I_MID( 8 )) >> 8) + 128); \
     p_out_v += 4
 
 #define PACKED_WRITE_UV() \
     i_u = *p_in; p_in += 4; i_v = *p_in_v; p_in_v += 4; \
-    *p_out = (( ((i_u * i_cos + i_v * i_sin - i_x) >> 8) \
-                       * i_sat) >> 8) + 128; \
+    *p_out = ((( (((i_u * i_cos + i_v * i_sin - i_x) + I_MID( 8 )) >> 8) \
+                       * i_sat) + I_MID( 8 )) >> 8) + 128; \
     p_out += 4; \
-    *p_out_v = (( ((i_v * i_cos - i_u * i_sin - i_y) >> 8) \
-                       * i_sat) >> 8) + 128; \
+    *p_out_v = ((( (((i_v * i_cos - i_u * i_sin - i_y) + I_MID( 8 )) >> 8) \
+                       * i_sat) + I_MID( 8 )) >> 8) + 128; \
     p_out_v += 4
 
 #define ADJUST_8_TIMES(x) x; x; x; x; x; x; x; x

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to