[MPlayer-cvslog] CVS: main/libaf af_equalizer.c,1.7,1.8
Reynaldo H. Verdejo CVS
syncmail at mplayerhq.hu
Sat Mar 11 22:17:03 CET 2006
CVS change done by Reynaldo H. Verdejo CVS
Update of /cvsroot/mplayer/main/libaf
In directory mail:/var2/tmp/cvs-serv12683
Modified Files:
af_equalizer.c
Log Message:
added dinamically calculated gain factor at output stage to avoid clipping on sane ranges
Index: af_equalizer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_equalizer.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- af_equalizer.c 8 Mar 2006 13:00:51 -0000 1.7
+++ af_equalizer.c 11 Mar 2006 21:16:59 -0000 1.8
@@ -58,6 +58,7 @@
float g[AF_NCH][KM]; // Gain factor for each channel and band
int K; // Number of used eq bands
int channels; // Number of channels
+ float gain_factor; // applied at output to avoid clipping
} af_equalizer_t;
// 2nd order Band-pass Filter design
@@ -79,9 +80,11 @@
switch(cmd){
case AF_CONTROL_REINIT:{
- int k =0;
+ int k =0, i =0;
float F[KM] = CF;
+ s->gain_factor=0.0;
+
// Sanity check
if(!arg) return AF_ERROR;
@@ -105,7 +108,25 @@
// Calculate how much this plugin adds to the overall time delay
af->delay += 2000.0/((float)af->data->rate);
+
+ // Calculate gain factor to prevent clipping at output
+ for(k=0;k<AF_NCH;k++)
+ {
+ for(i=0;i<KM;i++)
+ {
+ if(s->gain_factor < s->g[k][i]) s->gain_factor=s->g[k][i];
+ }
+ }
+ s->gain_factor=log10(s->gain_factor + 1.0) * 20.0;
+
+ if(s->gain_factor > 0.0)
+ {
+ s->gain_factor=0.1+(s->gain_factor/12.0);
+ }else{
+ s->gain_factor=1;
+ }
+
return af_test_output(af,arg);
}
case AF_CONTROL_COMMAND_LINE:{
@@ -190,7 +211,7 @@
wq[0] = w;
}
// Calculate output
- *out=yt;
+ *out=yt*s->gain_factor;
out+=nch;
}
}
More information about the MPlayer-cvslog
mailing list