diff options
author | wm4 <wm4@nowhere> | 2014-04-13 18:00:51 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-04-13 18:03:01 +0200 |
commit | 78128bddda4bcea1f256fc13cc33fa2652ed277c (patch) | |
tree | 35bf6596cb8e2d7927618845833c3ee36534f890 /audio/filter/af_equalizer.c | |
parent | 44f382cf98564c0fe08bdc78579c284362cd6f3c (diff) | |
download | mpv-78128bddda4bcea1f256fc13cc33fa2652ed277c.tar.bz2 mpv-78128bddda4bcea1f256fc13cc33fa2652ed277c.tar.xz |
Kill all tabs
I hate tabs.
This replaces all tabs in all source files with spaces. The only
exception is old-makefile. The replacement was made by running the
GNU coreutils "expand" command on every file. Since the replacement was
automatic, it's possible that some formatting was destroyed (but perhaps
only if it was assuming that the end of a tab does not correspond to
aligning the end to multiples of 8 spaces).
Diffstat (limited to 'audio/filter/af_equalizer.c')
-rw-r--r-- | audio/filter/af_equalizer.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/audio/filter/af_equalizer.c b/audio/filter/af_equalizer.c index 4f5a29706e..83fa80f2b3 100644 --- a/audio/filter/af_equalizer.c +++ b/audio/filter/af_equalizer.c @@ -32,41 +32,41 @@ #include "common/common.h" #include "af.h" -#define L 2 // Storage for filter taps -#define KM 10 // Max number of bands +#define L 2 // Storage for filter taps +#define KM 10 // Max number of bands #define Q 1.2247449 /* Q value for band-pass filters 1.2247=(3/2)^(1/2) - gives 4dB suppression @ Fc*2 and Fc/2 */ + gives 4dB suppression @ Fc*2 and Fc/2 */ /* Center frequencies for band-pass filters The different frequency bands are: - nr. center frequency - 0 31.25 Hz - 1 62.50 Hz - 2 125.0 Hz - 3 250.0 Hz - 4 500.0 Hz - 5 1.000 kHz - 6 2.000 kHz - 7 4.000 kHz - 8 8.000 kHz - 9 16.00 kHz + nr. center frequency + 0 31.25 Hz + 1 62.50 Hz + 2 125.0 Hz + 3 250.0 Hz + 4 500.0 Hz + 5 1.000 kHz + 6 2.000 kHz + 7 4.000 kHz + 8 8.000 kHz + 9 16.00 kHz */ -#define CF {31.25,62.5,125,250,500,1000,2000,4000,8000,16000} +#define CF {31.25,62.5,125,250,500,1000,2000,4000,8000,16000} // Maximum and minimum gain for the bands -#define G_MAX +12.0 -#define G_MIN -12.0 +#define G_MAX +12.0 +#define G_MIN -12.0 // Data for specific instances of this filter typedef struct af_equalizer_s { - float a[KM][L]; // A weights - float b[KM][L]; // B weights - float wq[AF_NCH][KM][L]; // Circular buffer for W data - 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 a[KM][L]; // A weights + float b[KM][L]; // B weights + float wq[AF_NCH][KM][L]; // Circular buffer for W data + 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 double p[KM]; } af_equalizer_t; @@ -108,7 +108,7 @@ static int control(struct af_instance* af, int cmd, void* arg) if(s->K != KM) MP_INFO(af, "Limiting the number of filters to" - " %i due to low sample rate.\n",s->K); + " %i due to low sample rate.\n",s->K); // Generate filter taps for(k=0;k<s->K;k++) @@ -144,33 +144,33 @@ static int control(struct af_instance* af, int cmd, void* arg) // Filter data through filter static int filter(struct af_instance* af, struct mp_audio* data, int flags) { - struct mp_audio* c = data; // Current working data - af_equalizer_t* s = (af_equalizer_t*)af->priv; // Setup - uint32_t ci = af->data->nch; // Index for channels - uint32_t nch = af->data->nch; // Number of channels + struct mp_audio* c = data; // Current working data + af_equalizer_t* s = (af_equalizer_t*)af->priv; // Setup + uint32_t ci = af->data->nch; // Index for channels + uint32_t nch = af->data->nch; // Number of channels while(ci--){ - float* g = s->g[ci]; // Gain factor - float* in = ((float*)c->planes[0])+ci; - float* out = ((float*)c->planes[0])+ci; - float* end = in + c->samples*c->nch; // Block loop end + float* g = s->g[ci]; // Gain factor + float* in = ((float*)c->planes[0])+ci; + float* out = ((float*)c->planes[0])+ci; + float* end = in + c->samples*c->nch; // Block loop end while(in < end){ - register int k = 0; // Frequency band index - register float yt = *in; // Current input sample + register int k = 0; // Frequency band index + register float yt = *in; // Current input sample in+=nch; // Run the filters for(;k<s->K;k++){ - // Pointer to circular buffer wq - register float* wq = s->wq[ci][k]; - // Calculate output from AR part of current filter - register float w=yt*s->b[k][0] + wq[0]*s->a[k][0] + wq[1]*s->a[k][1]; - // Calculate output form MA part of current filter - yt+=(w + wq[1]*s->b[k][1])*g[k]; - // Update circular buffer - wq[1] = wq[0]; - wq[0] = w; + // Pointer to circular buffer wq + register float* wq = s->wq[ci][k]; + // Calculate output from AR part of current filter + register float w=yt*s->b[k][0] + wq[0]*s->a[k][0] + wq[1]*s->a[k][1]; + // Calculate output form MA part of current filter + yt+=(w + wq[1]*s->b[k][1])*g[k]; + // Update circular buffer + wq[1] = wq[0]; + wq[0] = w; } // Calculate output *out=yt*s->gain_factor; |