[MPlayer-cvslog] r36491 - in trunk/libaf: af.h af_center.c af_channels.c af_comp.c af_delay.c af_equalizer.c af_extrastereo.c af_lavcresample.c af_pan.c af_resample.c af_sub.c af_tools.c af_volnorm.c af_volume.c

reimar subversion at mplayerhq.hu
Sat Oct 26 11:36:24 CEST 2013


Author: reimar
Date: Sat Oct 26 11:36:23 2013
New Revision: 36491

Log:
Remove some macros and switch to libavutil equivalents.

Modified:
   trunk/libaf/af.h
   trunk/libaf/af_center.c
   trunk/libaf/af_channels.c
   trunk/libaf/af_comp.c
   trunk/libaf/af_delay.c
   trunk/libaf/af_equalizer.c
   trunk/libaf/af_extrastereo.c
   trunk/libaf/af_lavcresample.c
   trunk/libaf/af_pan.c
   trunk/libaf/af_resample.c
   trunk/libaf/af_sub.c
   trunk/libaf/af_tools.c
   trunk/libaf/af_volnorm.c
   trunk/libaf/af_volume.c

Modified: trunk/libaf/af.h
==============================================================================
--- trunk/libaf/af.h	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af.h	Sat Oct 26 11:36:23 2013	(r36491)
@@ -325,25 +325,4 @@ void af_fix_parameters(af_data_t *data);
 #define RESIZE_LOCAL_BUFFER(a,d)\
 ((a->data->len < af_lencalc(a->mul,d))?af_resize_local_buffer(a,d):AF_OK)
 
-/* Some other useful macro definitions*/
-#ifndef min
-#define min(a,b)(((a)>(b))?(b):(a))
-#endif
-
-#ifndef max
-#define max(a,b)(((a)>(b))?(a):(b))
-#endif
-
-#ifndef clamp
-#define clamp(a,min,max) (((a)>(max))?(max):(((a)<(min))?(min):(a)))
-#endif
-
-#ifndef sign
-#define sign(a) (((a)>0)?(1):(-1))
-#endif
-
-#ifndef lrnd
-#define lrnd(a,b) ((b)((a)>=0.0?(a)+0.5:(a)-0.5))
-#endif
-
 #endif /* MPLAYER_AF_H */

Modified: trunk/libaf/af_center.c
==============================================================================
--- trunk/libaf/af_center.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_center.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "libavutil/common.h"
 #include "mp_msg.h"
 #include "af.h"
 
@@ -49,7 +50,7 @@ static int control(struct af_instance_s*
     if(!arg) return AF_ERROR;
 
     af->data->rate   = ((af_data_t*)arg)->rate;
-    af->data->nch    = max(s->ch+1,((af_data_t*)arg)->nch);
+    af->data->nch    = FFMAX(s->ch+1,((af_data_t*)arg)->nch);
     af->data->format = AF_FORMAT_FLOAT_NE;
     af->data->bps    = 4;
 

Modified: trunk/libaf/af_channels.c
==============================================================================
--- trunk/libaf/af_channels.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_channels.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <inttypes.h>
 
+#include "libavutil/common.h"
 #include "mp_msg.h"
 #include "af.h"
 
@@ -149,14 +150,14 @@ static int control(struct af_instance_s*
 
       // If mono: fake stereo
       if(((af_data_t*)arg)->nch == 1){
-	s->nr = min(af->data->nch,2);
+	s->nr = FFMIN(af->data->nch,2);
 	for(i=0;i<s->nr;i++){
 	  s->route[i][FR] = 0;
 	  s->route[i][TO] = i;
 	}
       }
       else{
-	s->nr = min(af->data->nch, ((af_data_t*)arg)->nch);
+	s->nr = FFMIN(af->data->nch, ((af_data_t*)arg)->nch);
 	for(i=0;i<s->nr;i++){
 	  s->route[i][FR] = i;
 	  s->route[i][TO] = i;

Modified: trunk/libaf/af_comp.c
==============================================================================
--- trunk/libaf/af_comp.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_comp.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -26,6 +26,7 @@
 #include <math.h>
 #include <limits.h>
 
+#include "libavutil/common.h"
 #include "af.h"
 
 // Data for specific instances of this filter
@@ -94,7 +95,7 @@ static int control(struct af_instance_s*
     return af_to_ms(AF_NCH,s->release,(float*)arg,af->data->rate);
   case AF_CONTROL_COMP_RATIO | AF_CONTROL_SET:
     for(i=0;i<AF_NCH;i++)
-      s->ratio[i] = clamp(((float*)arg)[i],1.0,10.0);
+      s->ratio[i] = av_clipf(((float*)arg)[i],1.0,10.0);
     return AF_OK;
   case AF_CONTROL_COMP_RATIO | AF_CONTROL_GET:
     for(i=0;i<AF_NCH;i++)

Modified: trunk/libaf/af_delay.c
==============================================================================
--- trunk/libaf/af_delay.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_delay.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <inttypes.h>
 
+#include "libavutil/common.h"
 #include "mp_msg.h"
 #include "af.h"
 
@@ -87,7 +88,7 @@ static int control(struct af_instance_s*
     s->ri = 0;
     for(i=0;i<AF_NCH;i++){
       mp_msg(MSGT_AFILTER, MSGL_DBG2, "[delay] Channel %i delayed by %0.3fms\n",
-	     i,clamp(s->d[i],0.0,1000.0));
+	     i,av_clipf(s->d[i],0.0,1000.0));
       mp_msg(MSGT_AFILTER, MSGL_DBG3, "[delay] Channel %i delayed by %i samples\n",
 	     i,s->wi[i]);
     }

Modified: trunk/libaf/af_equalizer.c
==============================================================================
--- trunk/libaf/af_equalizer.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_equalizer.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -29,6 +29,7 @@
 #include <inttypes.h>
 #include <math.h>
 
+#include "libavutil/common.h"
 #include "mp_msg.h"
 #include "af.h"
 
@@ -146,7 +147,7 @@ static int control(struct af_instance_s*
     for(i=0;i<AF_NCH;i++){
       for(j=0;j<KM;j++){
 	((af_equalizer_t*)af->setup)->g[i][j] =
-	  pow(10.0,clamp(g[j],G_MIN,G_MAX)/20.0)-1.0;
+	  pow(10.0,av_clipf(g[j],G_MIN,G_MAX)/20.0)-1.0;
       }
     }
     return AF_OK;
@@ -159,7 +160,7 @@ static int control(struct af_instance_s*
       return AF_ERROR;
 
     for(k = 0 ; k<KM ; k++)
-      s->g[ch][k] = pow(10.0,clamp(gain[k],G_MIN,G_MAX)/20.0)-1.0;
+      s->g[ch][k] = pow(10.0,av_clipf(gain[k],G_MIN,G_MAX)/20.0)-1.0;
 
     return AF_OK;
   }

Modified: trunk/libaf/af_extrastereo.c
==============================================================================
--- trunk/libaf/af_extrastereo.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_extrastereo.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -26,6 +26,7 @@
 #include <math.h>
 #include <limits.h>
 
+#include "libavutil/common.h"
 #include "af.h"
 
 // Data for specific instances of this filter
@@ -102,8 +103,8 @@ static af_data_t* play_s16(struct af_ins
     l = avg + (int)(s->mul * (a[i] - avg));
     r = avg + (int)(s->mul * (a[i + 1] - avg));
 
-    a[i] = clamp(l, SHRT_MIN, SHRT_MAX);
-    a[i + 1] = clamp(r, SHRT_MIN, SHRT_MAX);
+    a[i] = av_clip_int16(l);
+    a[i + 1] = av_clip_int16(r);
   }
 
   return data;

Modified: trunk/libaf/af_lavcresample.c
==============================================================================
--- trunk/libaf/af_lavcresample.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_lavcresample.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -66,7 +66,7 @@ static int control(struct af_instance_s*
     af->data->format = AF_FORMAT_S16_NE;
     af->data->bps    = 2;
     af->mul = (double)af->data->rate / data->rate;
-    af->delay = af->data->nch * s->filter_length / min(af->mul, 1); // *bps*.5
+    af->delay = af->data->nch * s->filter_length / FFMIN(af->mul, 1); // *bps*.5
 
     if (s->ctx_out_rate != af->data->rate || s->ctx_in_rate != data->rate || s->ctx_filter_size != s->filter_length ||
         s->ctx_phase_shift != s->phase_shift || s->ctx_linear != s->linear || s->ctx_cutoff != s->cutoff) {
@@ -89,7 +89,7 @@ static int control(struct af_instance_s*
   case AF_CONTROL_COMMAND_LINE:{
     s->cutoff= 0.0;
     sscanf((char*)arg,"%d:%d:%d:%d:%lf", &af->data->rate, &s->filter_length, &s->linear, &s->phase_shift, &s->cutoff);
-    if(s->cutoff <= 0.0) s->cutoff= max(1.0 - 6.5/(s->filter_length+8), 0.80);
+    if(s->cutoff <= 0.0) s->cutoff= FFMAX(1.0 - 6.5/(s->filter_length+8), 0.80);
     return AF_OK;
   }
   case AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET:
@@ -132,7 +132,7 @@ static af_data_t* play(struct af_instanc
 
   out= (int16_t*)af->data->audio;
 
-  out_len= min(out_len, af->data->len/(2*chans));
+  out_len= FFMIN(out_len, af->data->len/(2*chans));
 
   if(s->in_alloc < in_len + s->index){
       s->in_alloc= in_len + s->index;
@@ -196,7 +196,7 @@ static int af_open(af_instance_t* af){
   af->mul=1;
   af->data=calloc(1,sizeof(af_data_t));
   s->filter_length= 16;
-  s->cutoff= max(1.0 - 6.5/(s->filter_length+8), 0.80);
+  s->cutoff= FFMAX(1.0 - 6.5/(s->filter_length+8), 0.80);
   s->phase_shift= 10;
 //  s->setup = RSMP_INT | FREQ_SLOPPY;
   af->setup=s;

Modified: trunk/libaf/af_pan.c
==============================================================================
--- trunk/libaf/af_pan.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_pan.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -25,6 +25,7 @@
 #include <math.h>
 #include <limits.h>
 
+#include "libavutil/common.h"
 #include "mp_msg.h"
 #include "af.h"
 
@@ -123,10 +124,10 @@ static int control(struct af_instance_s*
     if (s->nch)
       return AF_ERROR;
     if (af->data->nch >= 2) {
-      s->level[0][0] = min(1.f, 1.f - val);
-      s->level[0][1] = max(0.f, val);
-      s->level[1][0] = max(0.f, -val);
-      s->level[1][1] = min(1.f, 1.f + val);
+      s->level[0][0] = FFMIN(1.f, 1.f - val);
+      s->level[0][1] = FFMAX(0.f, val);
+      s->level[1][0] = FFMAX(0.f, -val);
+      s->level[1][1] = FFMIN(1.f, 1.f + val);
     }
     return AF_OK;
   }

Modified: trunk/libaf/af_resample.c
==============================================================================
--- trunk/libaf/af_resample.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_resample.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -234,7 +234,7 @@ static int control(struct af_instance_s*
       s->i = 0;
 
       // Calculate cutoff frequency for filter
-      fc = 1/(float)(max(s->up,s->dn));
+      fc = 1/(float)(FFMAX(s->up,s->dn));
       // Allocate space for polyphase filter bank and prototype filter
       w = malloc(sizeof(float) * s->up *L);
       free(s->w);
@@ -277,7 +277,7 @@ static int control(struct af_instance_s*
     int sloppy=1;
     sscanf((char*)arg,"%i:%i:%i", &rate, &sloppy, &type);
     s->setup = (sloppy?FREQ_SLOPPY:FREQ_EXACT) |
-      (clamp(type,RSMP_LIN,RSMP_FLOAT));
+      (av_clip(type,RSMP_LIN,RSMP_FLOAT));
     return af->control(af,AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET, &rate);
   }
   case AF_CONTROL_POST_CREATE:

Modified: trunk/libaf/af_sub.c
==============================================================================
--- trunk/libaf/af_sub.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_sub.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -32,6 +32,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "libavutil/common.h"
 #include "mp_msg.h"
 #include "af.h"
 #include "dsp.h"
@@ -71,7 +72,7 @@ static int control(struct af_instance_s*
     if(!arg) return AF_ERROR;
 
     af->data->rate   = ((af_data_t*)arg)->rate;
-    af->data->nch    = max(s->ch+1,((af_data_t*)arg)->nch);
+    af->data->nch    = FFMAX(s->ch+1,((af_data_t*)arg)->nch);
     af->data->format = AF_FORMAT_FLOAT_NE;
     af->data->bps    = 4;
 

Modified: trunk/libaf/af_tools.c
==============================================================================
--- trunk/libaf/af_tools.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_tools.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -18,6 +18,7 @@
 
 #include <math.h>
 #include <string.h>
+#include "libavutil/common.h"
 #include "af.h"
 
 /* Convert to gain value from dB. Returns AF_OK if of and AF_ERROR if
@@ -33,7 +34,7 @@ int af_from_dB(int n, float* in, float* 
     if(in[i]<=-200)
       out[i]=0.0;
     else
-      out[i]=pow(10.0,clamp(in[i],mi,ma)/k);
+      out[i]=pow(10.0,av_clipf(in[i],mi,ma)/k);
   }
   return AF_OK;
 }
@@ -65,7 +66,7 @@ int af_from_ms(int n, float* in, int* ou
     return AF_ERROR;
 
   for(i=0;i<n;i++)
-    out[i]=(int)((float)rate * clamp(in[i],mi,ma)/1000.0);
+    out[i]=(int)((float)rate * av_clipf(in[i],mi,ma)/1000.0);
 
   return AF_OK;
 }

Modified: trunk/libaf/af_volnorm.c
==============================================================================
--- trunk/libaf/af_volnorm.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_volnorm.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -26,6 +26,7 @@
 #include <math.h>
 #include <limits.h>
 
+#include "libavutil/common.h"
 #include "af.h"
 
 // Methods:
@@ -144,14 +145,14 @@ static void method1_int16(af_volnorm_t *
     s->mul = (1.0 - SMOOTH_MUL) * s->mul + SMOOTH_MUL * neededmul;
 
     // clamp the mul coefficient
-    s->mul = clamp(s->mul, MUL_MIN, MUL_MAX);
+    s->mul = av_clipf(s->mul, MUL_MIN, MUL_MAX);
   }
 
   // Scale & clamp the samples
   for (i = 0; i < len; i++)
   {
     tmp = s->mul * data[i];
-    tmp = clamp(tmp, SHRT_MIN, SHRT_MAX);
+    tmp = av_clip_int16(tmp);
     data[i] = tmp;
   }
 
@@ -185,7 +186,7 @@ static void method1_float(af_volnorm_t *
     s->mul = (1.0 - SMOOTH_MUL) * s->mul + SMOOTH_MUL * neededmul;
 
     // clamp the mul coefficient
-    s->mul = clamp(s->mul, MUL_MIN, MUL_MAX);
+    s->mul = av_clipf(s->mul, MUL_MIN, MUL_MAX);
   }
 
   // Scale & clamp the samples
@@ -228,7 +229,7 @@ static void method2_int16(af_volnorm_t *
     if (avg >= SIL_S16)
     {
 	s->mul = s->mid_s16 / avg;
-	s->mul = clamp(s->mul, MUL_MIN, MUL_MAX);
+	s->mul = av_clipf(s->mul, MUL_MIN, MUL_MAX);
     }
   }
 
@@ -236,7 +237,7 @@ static void method2_int16(af_volnorm_t *
   for (i = 0; i < len; i++)
   {
     tmp = s->mul * data[i];
-    tmp = clamp(tmp, SHRT_MIN, SHRT_MAX);
+    tmp = av_clip_int16(tmp);
     data[i] = tmp;
   }
 
@@ -278,7 +279,7 @@ static void method2_float(af_volnorm_t *
     if (avg >= SIL_FLOAT)
     {
 	s->mul = s->mid_float / avg;
-	s->mul = clamp(s->mul, MUL_MIN, MUL_MAX);
+	s->mul = av_clipf(s->mul, MUL_MIN, MUL_MAX);
     }
   }
 

Modified: trunk/libaf/af_volume.c
==============================================================================
--- trunk/libaf/af_volume.c	Sat Oct 26 11:36:21 2013	(r36490)
+++ trunk/libaf/af_volume.c	Sat Oct 26 11:36:23 2013	(r36491)
@@ -42,6 +42,7 @@
 #include <math.h>
 #include <limits.h>
 
+#include "libavutil/common.h"
 #include "mp_msg.h"
 #include "af.h"
 
@@ -121,7 +122,7 @@ static int control(struct af_instance_s*
     int i;
     if(!s->fast){
       for(i=0;i<AF_NCH;i++)
-	m=max(m,s->max[i]);
+	m=FFMAX(m,s->max[i]);
 	af_to_dB(1, &m, &m, 10.0);
 	mp_msg(MSGT_AFILTER, MSGL_INFO, "[volume] The maximum volume was %0.2fdB \n", m);
     }
@@ -156,7 +157,7 @@ static af_data_t* play(struct af_instanc
 	register int vol = (int)(255.0 * s->level[ch]);
 	for(i=ch;i<len;i+=nch){
 	  register int x = (a[i] * vol) >> 8;
-	  a[i]=clamp(x,SHRT_MIN,SHRT_MAX);
+	  a[i]=av_clip_int16(x);
 	}
       }
     }
@@ -189,7 +190,7 @@ static af_data_t* play(struct af_instanc
 	    x=af_softclip(x);
 	  // Hard clipping
 	  else
-	    x=clamp(x,-1.0,1.0);
+	    x=av_clipf(x,-1.0,1.0);
 	  a[i] = x;
 	}
       }


More information about the MPlayer-cvslog mailing list