comparison libaf/af_volume.c @ 36395:2b9bc3c2933d

Remove some macros and switch to libavutil equivalents.
author reimar
date Sat, 26 Oct 2013 09:36:23 +0000
parents 2f815fdd521c
children 49587a84cb91
comparison
equal deleted inserted replaced
36394:2f815fdd521c 36395:2b9bc3c2933d
40 40
41 #include <inttypes.h> 41 #include <inttypes.h>
42 #include <math.h> 42 #include <math.h>
43 #include <limits.h> 43 #include <limits.h>
44 44
45 #include "libavutil/common.h"
45 #include "mp_msg.h" 46 #include "mp_msg.h"
46 #include "af.h" 47 #include "af.h"
47 48
48 // Data for specific instances of this filter 49 // Data for specific instances of this filter
49 typedef struct af_volume_s 50 typedef struct af_volume_s
119 case AF_CONTROL_PRE_DESTROY:{ 120 case AF_CONTROL_PRE_DESTROY:{
120 float m = 0.0; 121 float m = 0.0;
121 int i; 122 int i;
122 if(!s->fast){ 123 if(!s->fast){
123 for(i=0;i<AF_NCH;i++) 124 for(i=0;i<AF_NCH;i++)
124 m=max(m,s->max[i]); 125 m=FFMAX(m,s->max[i]);
125 af_to_dB(1, &m, &m, 10.0); 126 af_to_dB(1, &m, &m, 10.0);
126 mp_msg(MSGT_AFILTER, MSGL_INFO, "[volume] The maximum volume was %0.2fdB \n", m); 127 mp_msg(MSGT_AFILTER, MSGL_INFO, "[volume] The maximum volume was %0.2fdB \n", m);
127 } 128 }
128 return AF_OK; 129 return AF_OK;
129 } 130 }
154 for(ch = 0; ch < nch ; ch++){ 155 for(ch = 0; ch < nch ; ch++){
155 if(s->enable[ch]){ 156 if(s->enable[ch]){
156 register int vol = (int)(255.0 * s->level[ch]); 157 register int vol = (int)(255.0 * s->level[ch]);
157 for(i=ch;i<len;i+=nch){ 158 for(i=ch;i<len;i+=nch){
158 register int x = (a[i] * vol) >> 8; 159 register int x = (a[i] * vol) >> 8;
159 a[i]=clamp(x,SHRT_MIN,SHRT_MAX); 160 a[i]=av_clip_int16(x);
160 } 161 }
161 } 162 }
162 } 163 }
163 } 164 }
164 // Machine is fast and data is floating point 165 // Machine is fast and data is floating point
187 post to Musicdsp.org */ 188 post to Musicdsp.org */
188 if(s->soft) 189 if(s->soft)
189 x=af_softclip(x); 190 x=af_softclip(x);
190 // Hard clipping 191 // Hard clipping
191 else 192 else
192 x=clamp(x,-1.0,1.0); 193 x=av_clipf(x,-1.0,1.0);
193 a[i] = x; 194 a[i] = x;
194 } 195 }
195 } 196 }
196 } 197 }
197 } 198 }