[vlc-commits] Use standard abs() function where appropriate
Rémi Denis-Courmont
git at videolan.org
Tue Aug 21 23:14:40 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug 22 00:13:46 2012 +0300| [df4da384688af2d08921ecaca0cdd408b4f6ac32] | committer: Rémi Denis-Courmont
Use standard abs() function where appropriate
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=df4da384688af2d08921ecaca0cdd408b4f6ac32
---
modules/control/dbus/dbus.c | 2 +-
modules/control/dbus/dbus.h | 1 -
modules/demux/avi/avi.c | 8 +++-----
modules/video_filter/deinterlace/common.h | 1 -
modules/video_filter/deinterlace/yadif.h | 16 ++++++++--------
modules/video_filter/hqdn3d.h | 4 +---
6 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/modules/control/dbus/dbus.c b/modules/control/dbus/dbus.c
index 8841f78..84581a6 100644
--- a/modules/control/dbus/dbus.c
+++ b/modules/control/dbus/dbus.c
@@ -931,7 +931,7 @@ static int InputIntfEventCallback( intf_thread_t *p_intf,
p_intf->p_sys->i_last_input_pos_event = i_now;
p_intf->p_sys->i_last_input_pos = i_pos;
- if( ABS( i_pos - i_projected_pos ) < SEEK_THRESHOLD )
+ if( llabs( i_pos - i_projected_pos ) < SEEK_THRESHOLD )
break;
p_info->signal = SIGNAL_SEEK;
diff --git a/modules/control/dbus/dbus.h b/modules/control/dbus/dbus.h
index 12e66a1..cdafe5c 100644
--- a/modules/control/dbus/dbus.h
+++ b/modules/control/dbus/dbus.h
@@ -38,7 +38,6 @@ static const DBusObjectPathVTable dbus_mpris_vtable = {
NULL, NULL, NULL, NULL
};
-#define ABS(x) ( ( x ) > 0 ? ( x ) : ( -1 * ( x ) ) )
#define SEEK_THRESHOLD 1000 /* µsec */
#endif //dbus.h
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 5490296..16c542f 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -91,8 +91,6 @@ static int Seek ( demux_t *, mtime_t, int );
static int Demux_Seekable ( demux_t * );
static int Demux_UnSeekable( demux_t * );
-#define __ABS( x ) ( (x) < 0 ? (-(x)) : (x) )
-
static char *FromACP( const char *str )
{
return FromCharset(vlc_pgettext("GetACP", "CP1252"), str, strlen(str));
@@ -893,11 +891,11 @@ static int Demux_Seekable( demux_t *p_demux )
if( tk->i_samplesize )
{
- toread[i_track].i_toread = AVI_PTSToByte( tk, __ABS( i_dpts ) );
+ toread[i_track].i_toread = AVI_PTSToByte( tk, llabs( i_dpts ) );
}
else
{
- toread[i_track].i_toread = AVI_PTSToChunk( tk, __ABS( i_dpts ) );
+ toread[i_track].i_toread = AVI_PTSToChunk( tk, llabs( i_dpts ) );
}
if( i_dpts < 0 )
@@ -1248,7 +1246,7 @@ static int Demux_UnSeekable( demux_t *p_demux )
else
{
/* check for time */
- if( __ABS( AVI_GetPTS( p_stream ) -
+ if( llabs( AVI_GetPTS( p_stream ) -
AVI_GetPTS( p_stream_master ) )< 600*1000 )
{
/* load it and send to decoder */
diff --git a/modules/video_filter/deinterlace/common.h b/modules/video_filter/deinterlace/common.h
index f11eac7..e5835d5 100644
--- a/modules/video_filter/deinterlace/common.h
+++ b/modules/video_filter/deinterlace/common.h
@@ -30,7 +30,6 @@
*/
/* Needed for Yadif, but also some others. */
-#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
#define FFMAX(a,b) __MAX(a,b)
#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
#define FFMIN(a,b) __MIN(a,b)
diff --git a/modules/video_filter/deinterlace/yadif.h b/modules/video_filter/deinterlace/yadif.h
index a2fccac..135f18d 100644
--- a/modules/video_filter/deinterlace/yadif.h
+++ b/modules/video_filter/deinterlace/yadif.h
@@ -88,18 +88,18 @@ static void yadif_filter_line_c(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8
int c= cur[mrefs];
int d= (prev2[0] + next2[0])>>1;
int e= cur[prefs];
- int temporal_diff0= FFABS(prev2[0] - next2[0]);
- int temporal_diff1=( FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1;
- int temporal_diff2=( FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1;
+ int temporal_diff0= abs(prev2[0] - next2[0]);
+ int temporal_diff1=( abs(prev[mrefs] - c) + abs(prev[prefs] - e) )>>1;
+ int temporal_diff2=( abs(next[mrefs] - c) + abs(next[prefs] - e) )>>1;
int diff= FFMAX3(temporal_diff0>>1, temporal_diff1, temporal_diff2);
int spatial_pred= (c+e)>>1;
- int spatial_score= FFABS(cur[mrefs-1] - cur[prefs-1]) + FFABS(c-e)
- + FFABS(cur[mrefs+1] - cur[prefs+1]) - 1;
+ int spatial_score= abs(cur[mrefs-1] - cur[prefs-1]) + abs(c-e)
+ + abs(cur[mrefs+1] - cur[prefs+1]) - 1;
#define CHECK(j)\
- { int score= FFABS(cur[mrefs-1+j] - cur[prefs-1-j])\
- + FFABS(cur[mrefs +j] - cur[prefs -j])\
- + FFABS(cur[mrefs+1+j] - cur[prefs+1-j]);\
+ { int score= abs(cur[mrefs-1+j] - cur[prefs-1-j])\
+ + abs(cur[mrefs +j] - cur[prefs -j])\
+ + abs(cur[mrefs+1+j] - cur[prefs+1-j]);\
if(score < spatial_score){\
spatial_score= score;\
spatial_pred= (cur[mrefs +j] + cur[prefs -j])>>1;\
diff --git a/modules/video_filter/hqdn3d.h b/modules/video_filter/hqdn3d.h
index 6ee2f98..0036d07 100644
--- a/modules/video_filter/hqdn3d.h
+++ b/modules/video_filter/hqdn3d.h
@@ -182,8 +182,6 @@ static void deNoise(unsigned char *Frame, // mpi->planes[x]
//===========================================================================//
-#define ABS(A) ( (A) > 0 ? (A) : -(A) )
-
static void PrecalcCoefs(int *Ct, double Dist25)
{
int i;
@@ -193,7 +191,7 @@ static void PrecalcCoefs(int *Ct, double Dist25)
for (i = -255*16; i <= 255*16; i++)
{
- Simil = 1.0 - ABS(i) / (16*255.0);
+ Simil = 1.0 - abs(i) / (16*255.0);
C = pow(Simil, Gamma) * 65536.0 * (double)i / 16.0;
Ct[16*256+i] = (C<0) ? (C-0.5) : (C+0.5);
}
More information about the vlc-commits
mailing list