diff options
Diffstat (limited to 'libaf')
35 files changed, 1323 insertions, 1337 deletions
diff --git a/libaf/af.c b/libaf/af.c index 987b7e548f..86b00a3e09 100644 --- a/libaf/af.c +++ b/libaf/af.c @@ -51,7 +51,7 @@ extern af_info_t af_info_scaletempo; extern af_info_t af_info_stats; extern af_info_t af_info_bs2b; -static af_info_t* filter_list[]={ +static af_info_t* filter_list[]={ &af_info_dummy, &af_info_delay, &af_info_channels, @@ -88,7 +88,7 @@ static af_info_t* filter_list[]={ #ifdef CONFIG_LIBBS2B &af_info_bs2b, #endif - NULL + NULL }; // CPU speed @@ -106,13 +106,13 @@ static af_info_t* af_find(char*name) } mp_msg(MSGT_AFILTER, MSGL_ERR, "Couldn't find audio filter '%s'\n",name); return NULL; -} +} /* Find filter in the dynamic filter list using it's name This function is used for finding already initialized filters */ af_instance_t* af_get(af_stream_t* s, char* name) { - af_instance_t* af=s->first; + af_instance_t* af=s->first; // Find the filter while(af != NULL){ if(!strcmp(af->info->name,name)) @@ -134,7 +134,7 @@ static af_instance_t* af_create(af_stream_t* s, const char* name_with_cmd) if (!name || !new) { mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Could not allocate memory\n"); goto err_out; - } + } memset(new,0,sizeof(af_instance_t)); // Check for commandline parameters @@ -148,29 +148,29 @@ static af_instance_t* af_create(af_stream_t* s, const char* name_with_cmd) non-reentrant */ if(new->info->flags & AF_FLAGS_NOT_REENTRANT){ if(af_get(s,name)){ - mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] There can only be one instance of" - " the filter '%s' in each stream\n",name); + mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] There can only be one instance of" + " the filter '%s' in each stream\n",name); goto err_out; } } - + mp_msg(MSGT_AFILTER, MSGL_V, "[libaf] Adding filter %s \n",name); - + // Initialize the new filter - if(AF_OK == new->info->open(new) && + if(AF_OK == new->info->open(new) && AF_ERROR < new->control(new,AF_CONTROL_POST_CREATE,&s->cfg)){ if(cmdline){ if(AF_ERROR>=new->control(new,AF_CONTROL_COMMAND_LINE,cmdline)) goto err_out; } free(name); - return new; + return new; } - + err_out: free(new); mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Couldn't create or open audio filter '%s'\n", - name); + name); free(name); return NULL; } @@ -228,8 +228,8 @@ void af_remove(af_stream_t* s, af_instance_t* af) { if(!af) return; - // Print friendly message - mp_msg(MSGT_AFILTER, MSGL_V, "[libaf] Removing filter %s \n",af->info->name); + // Print friendly message + mp_msg(MSGT_AFILTER, MSGL_V, "[libaf] Removing filter %s \n",af->info->name); // Notify filter before changing anything af->control(af,AF_CONTROL_PRE_DESTROY,0); @@ -244,7 +244,7 @@ void af_remove(af_stream_t* s, af_instance_t* af) else s->last=af->prev; - // Uninitialize af and free memory + // Uninitialize af and free memory af->uninit(af); free(af); } @@ -260,21 +260,21 @@ static int af_reinit(af_stream_t* s, af_instance_t* af) // Check if there are any filters left in the list if(NULL == af){ - if(!(af=af_append(s,s->first,"dummy"))) - return AF_UNKNOWN; + if(!(af=af_append(s,s->first,"dummy"))) + return AF_UNKNOWN; else return AF_ERROR; } - // Check if this is the first filter - if(!af->prev) + // Check if this is the first filter + if(!af->prev) memcpy(&in,&(s->input),sizeof(af_data_t)); else memcpy(&in,af->prev->data,sizeof(af_data_t)); // Reset just in case... in.audio=NULL; in.len=0; - + rv = af->control(af,AF_CONTROL_REINIT,&in); switch(rv){ case AF_OK: @@ -293,7 +293,7 @@ static int af_reinit(af_stream_t* s, af_instance_t* af) if(AF_OK != (rv = new->control(new,AF_CONTROL_CHANNELS,&in.nch))) return rv; // Initialize channels filter - if(!new->prev) + if(!new->prev) memcpy(&in,&(s->input),sizeof(af_data_t)); else memcpy(&in,new->prev->data,sizeof(af_data_t)); @@ -310,7 +310,7 @@ static int af_reinit(af_stream_t* s, af_instance_t* af) if(AF_OK != (rv = new->control(new,AF_CONTROL_FORMAT_FMT,&in.format))) return rv; // Initialize format filter - if(!new->prev) + if(!new->prev) memcpy(&in,&(s->input),sizeof(af_data_t)); else memcpy(&in,new->prev->data,sizeof(af_data_t)); @@ -318,7 +318,7 @@ static int af_reinit(af_stream_t* s, af_instance_t* af) return rv; } if(!new){ // Should _never_ happen - mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Unable to correct audio format. " + mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Unable to correct audio format. " "This error should never uccur, please send bugreport.\n"); return AF_ERROR; } @@ -344,7 +344,7 @@ static int af_reinit(af_stream_t* s, af_instance_t* af) break; } default: - mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Reinitialization did not work, audio" + mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Reinitialization did not work, audio" " filter '%s' returned error code %i\n",af->info->name,rv); return AF_ERROR; } @@ -387,8 +387,8 @@ int af_init(af_stream_t* s) if(!s->first){ // Add all filters in the list (if there are any) if(!s->cfg.list){ // To make automatic format conversion work - if(!af_append(s,s->first,"dummy")) - return -1; + if(!af_append(s,s->first,"dummy")) + return -1; } else{ while(s->cfg.list[i]){ @@ -398,7 +398,7 @@ int af_init(af_stream_t* s) } } - // Init filters + // Init filters if(AF_OK != af_reinit(s,s->first)) return -1; @@ -426,7 +426,7 @@ int af_init(af_stream_t* s) af = af_append(s,s->first,resampler); else af = af_prepend(s,s->first,resampler); - } + } else{ if(!strcmp(s->last->info->name,"format")) af = af_prepend(s,s->last,resampler); @@ -452,8 +452,8 @@ int af_init(af_stream_t* s) } if(AF_OK != af_reinit(s,af)) return -1; - } - + } + // Check number of output channels fix if not OK // If needed always inserted last -> easy to screw up other filters if(s->output.nch && s->last->data->nch!=s->output.nch){ @@ -467,7 +467,7 @@ int af_init(af_stream_t* s) if(AF_OK != af_reinit(s,af)) return -1; } - + // Check output format fix if not OK if(s->output.format != AF_FORMAT_UNKNOWN && s->last->data->format != s->output.format){ @@ -491,11 +491,11 @@ int af_init(af_stream_t* s) s->output.format = s->last->data->format; if (!s->output.nch) s->output.nch = s->last->data->nch; if (!s->output.rate) s->output.rate = s->last->data->rate; - if((s->last->data->format != s->output.format) || - (s->last->data->nch != s->output.nch) || + if((s->last->data->format != s->output.format) || + (s->last->data->nch != s->output.nch) || (s->last->data->rate != s->output.rate)) { - // Something is stuffed audio out will not work - mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Unable to setup filter system can not" + // Something is stuffed audio out will not work + mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Unable to setup filter system can not" " meet sound-card demands, please send bugreport. \n"); af_uninit(s); return -1; @@ -532,8 +532,8 @@ af_instance_t* af_add(af_stream_t* s, char* name){ // Filter data chunk through the filters in the list af_data_t* af_play(af_stream_t* s, af_data_t* data) { - af_instance_t* af=s->first; - // Iterate through all filters + af_instance_t* af=s->first; + // Iterate through all filters do{ if (data->len <= 0) break; data=af->play(af,data); @@ -555,7 +555,7 @@ int af_lencalc(double mul, af_data_t* d) // Calculate average ratio of filter output size to input size double af_calc_filter_multiplier(af_stream_t* s) { - af_instance_t* af=s->first; + af_instance_t* af=s->first; double mul = 1; // Iterate through all filters and calculate total multiplication factor do{ @@ -569,9 +569,9 @@ double af_calc_filter_multiplier(af_stream_t* s) /* Calculate the total delay [bytes output] caused by the filters */ double af_calc_delay(af_stream_t* s) { - af_instance_t* af=s->first; + af_instance_t* af=s->first; register double delay = 0.0; - // Iterate through all filters + // Iterate through all filters while(af){ delay += af->delay; delay *= af->mul; @@ -586,10 +586,10 @@ int af_resize_local_buffer(af_instance_t* af, af_data_t* data) { // Calculate new length register int len = af_lencalc(af->mul,data); - mp_msg(MSGT_AFILTER, MSGL_V, "[libaf] Reallocating memory in module %s, " + mp_msg(MSGT_AFILTER, MSGL_V, "[libaf] Reallocating memory in module %s, " "old len = %i, new len = %i\n",af->info->name,af->data->len,len); // If there is a buffer free it - if(af->data->audio) + if(af->data->audio) free(af->data->audio); // Create new buffer and check that it is OK af->data->audio = malloc(len); diff --git a/libaf/af.h b/libaf/af.h index 487c635a97..de70fcf77c 100644 --- a/libaf/af.h +++ b/libaf/af.h @@ -33,7 +33,7 @@ #undef AF_INIT_TYPE #define AF_INIT_TYPE \ ((gCpuCaps.has3DNow || gCpuCaps.hasSSE)?AF_INIT_FAST:AF_INIT_SLOW) -#endif +#endif struct af_instance_s; @@ -59,8 +59,8 @@ typedef struct af_data_s #define AF_FLAGS_NOT_REENTRANT 0x00000001 /* Audio filter information not specific for current instance, but for - a specific filter */ -typedef struct af_info_s + a specific filter */ +typedef struct af_info_s { const char *info; const char *name; @@ -80,7 +80,7 @@ typedef struct af_instance_s void* setup; // setup data for this specific instance and filter af_data_t* data; // configuration for outgoing data stream struct af_instance_s* next; - struct af_instance_s* prev; + struct af_instance_s* prev; double delay; /* Delay caused by the filter, in units of bytes read without * corresponding output */ double mul; /* length multiplier: how much does this instance change @@ -100,7 +100,7 @@ extern int* af_cpu_speed; #define AF_INIT_FLOAT 0x00000004 #define AF_INIT_FORMAT_MASK 0x00000004 -// Default init type +// Default init type #ifndef AF_INIT_TYPE #if HAVE_SSE || HAVE_AMD3DNOW #define AF_INIT_TYPE (af_cpu_speed?*af_cpu_speed:AF_INIT_FAST) @@ -194,7 +194,7 @@ void af_remove(af_stream_t* s, af_instance_t* af); * \brief find filter in chain by name * \param name name of the filter to find * \return first filter with right name or NULL if not found - * + * * This function is used for finding already initialized filters */ af_instance_t* af_get(af_stream_t* s, char* name); @@ -288,7 +288,7 @@ int af_from_ms(int n, float* in, int* out, int rate, float mi, float ma); * \param rate sample rate * \return AF_ERROR on error, AF_OK otherwise */ -int af_to_ms(int n, int* in, float* out, int rate); +int af_to_ms(int n, int* in, float* out, int rate); /** * \brief test if output format matches @@ -317,7 +317,7 @@ void af_help(void); * \brief fill the missing parameters in the af_data_t structure * \param data structure to fill * \ingroup af_filter - * + * * Currently only sets bps based on format */ void af_fix_parameters(af_data_t *data); @@ -344,7 +344,7 @@ void af_fix_parameters(af_data_t *data); #endif #ifndef sign -#define sign(a) (((a)>0)?(1):(-1)) +#define sign(a) (((a)>0)?(1):(-1)) #endif #ifndef lrnd diff --git a/libaf/af_center.c b/libaf/af_center.c index 5023872447..d3c867c39e 100644 --- a/libaf/af_center.c +++ b/libaf/af_center.c @@ -27,7 +27,7 @@ #include <stdio.h> #include <stdlib.h> -#include <string.h> +#include <string.h> #include "af.h" @@ -40,7 +40,7 @@ typedef struct af_center_s // Initialization and runtime control static int control(struct af_instance_s* af, int cmd, void* arg) { - af_center_t* s = af->setup; + af_center_t* s = af->setup; switch(cmd){ case AF_CONTROL_REINIT:{ @@ -75,7 +75,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) return AF_UNKNOWN; } -// Deallocate memory +// Deallocate memory static void uninit(struct af_instance_s* af) { if(af->data) @@ -90,7 +90,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) af_data_t* c = data; // Current working data af_center_t* s = af->setup; // Setup for this instance float* a = c->audio; // Audio data - int len = c->len/4; // Number of samples in current audio block + int len = c->len/4; // Number of samples in current audio block int nch = c->nch; // Number of channels int ch = s->ch; // Channel in which to insert the center audio register int i; diff --git a/libaf/af_channels.c b/libaf/af_channels.c index ffed84bfb0..b42cde380a 100644 --- a/libaf/af_channels.c +++ b/libaf/af_channels.c @@ -108,7 +108,7 @@ static void copy(void* in, void* out, int ins, int inos,int outs, int outos, int break; } default: - mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] Unsupported number of bytes/sample: %i" + mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] Unsupported number of bytes/sample: %i" " please report this error on the MPlayer mailing list. \n",bps); } } @@ -118,11 +118,11 @@ static int check_routes(af_channels_t* s, int nin, int nout) { int i; if((s->nr < 1) || (s->nr > AF_NCH)){ - mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of routing pairs must be" + mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of routing pairs must be" " between 1 and %i. Current value is %i\n",AF_NCH,s->nr); return AF_ERROR; } - + for(i=0;i<s->nr;i++){ if((s->route[i][FR] >= nin) || (s->route[i][TO] >= nout)){ mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] Invalid routing in pair nr. %i.\n", i); @@ -142,7 +142,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) // Set default channel assignment if(!s->router){ int i; - // Make sure this filter isn't redundant + // Make sure this filter isn't redundant if(af->data->nch == ((af_data_t*)arg)->nch) return AF_DETACH; @@ -180,14 +180,14 @@ static int control(struct af_instance_s* af, int cmd, void* arg) int ch = 0; // Sanity check if((s->nr < 1) || (s->nr > AF_NCH)){ - mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of routing pairs must be" + mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of routing pairs must be" " between 1 and %i. Current value is %i\n",AF_NCH,s->nr); - } + } s->router = 1; // Scan for pairs on commandline while((*cp == ':') && (ch < s->nr)){ sscanf(cp, ":%i:%i%n" ,&s->route[ch][FR], &s->route[ch][TO], &n); - mp_msg(MSGT_AFILTER, MSGL_V, "[channels] Routing from channel %i to" + mp_msg(MSGT_AFILTER, MSGL_V, "[channels] Routing from channel %i to" " channel %i\n",s->route[ch][FR],s->route[ch][TO]); cp = &cp[n]; ch++; @@ -197,20 +197,20 @@ static int control(struct af_instance_s* af, int cmd, void* arg) if(AF_OK != af->control(af,AF_CONTROL_CHANNELS | AF_CONTROL_SET ,&nch)) return AF_ERROR; return AF_OK; - } - case AF_CONTROL_CHANNELS | AF_CONTROL_SET: + } + case AF_CONTROL_CHANNELS | AF_CONTROL_SET: // Reinit must be called after this function has been called - + // Sanity check if(((int*)arg)[0] <= 0 || ((int*)arg)[0] > AF_NCH){ - mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of output channels must be" + mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of output channels must be" " between 1 and %i. Current value is %i\n",AF_NCH,((int*)arg)[0]); return AF_ERROR; } - af->data->nch=((int*)arg)[0]; + af->data->nch=((int*)arg)[0]; if(!s->router) - mp_msg(MSGT_AFILTER, MSGL_V, "[channels] Changing number of channels" + mp_msg(MSGT_AFILTER, MSGL_V, "[channels] Changing number of channels" " to %i\n",af->data->nch); return AF_OK; case AF_CONTROL_CHANNELS | AF_CONTROL_GET: @@ -246,7 +246,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) return AF_UNKNOWN; } -// Deallocate memory +// Deallocate memory static void uninit(struct af_instance_s* af) { free(af->setup); @@ -262,18 +262,18 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) af_data_t* l = af->data; // Local data af_channels_t* s = af->setup; int i; - + if(AF_OK != RESIZE_LOCAL_BUFFER(af,data)) return NULL; // Reset unused channels memset(l->audio,0,c->len / c->nch * l->nch); - + if(AF_OK == check_routes(s,c->nch,l->nch)) for(i=0;i<s->nr;i++) copy(c->audio,l->audio,c->nch,s->route[i][FR], l->nch,s->route[i][TO],c->len,c->bps); - + // Set output data c->audio = l->audio; c->len = c->len / c->nch * l->nch; diff --git a/libaf/af_comp.c b/libaf/af_comp.c index 0eef76c2f4..4999612865 100644 --- a/libaf/af_comp.c +++ b/libaf/af_comp.c @@ -43,21 +43,21 @@ typedef struct af_comp_s // Initialization and runtime control static int control(struct af_instance_s* af, int cmd, void* arg) { - af_comp_t* s = (af_comp_t*)af->setup; + af_comp_t* s = (af_comp_t*)af->setup; int i; switch(cmd){ case AF_CONTROL_REINIT: // Sanity check if(!arg) return AF_ERROR; - + af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; // Time constant set to 0.1s - // s->alpha = (1.0/0.2)/(2.0*M_PI*(float)((af_data_t*)arg)->rate); + // s->alpha = (1.0/0.2)/(2.0*M_PI*(float)((af_data_t*)arg)->rate); return af_test_output(af,(af_data_t*)arg); case AF_CONTROL_COMMAND_LINE:{ /* float v=-10.0; */ @@ -76,10 +76,10 @@ static int control(struct af_instance_s* af, int cmd, void* arg) } case AF_CONTROL_COMP_ON_OFF | AF_CONTROL_SET: memcpy(s->enable,(int*)arg,AF_NCH*sizeof(int)); - return AF_OK; + return AF_OK; case AF_CONTROL_COMP_ON_OFF | AF_CONTROL_GET: memcpy((int*)arg,s->enable,AF_NCH*sizeof(int)); - return AF_OK; + return AF_OK; case AF_CONTROL_COMP_THRESH | AF_CONTROL_SET: return af_from_dB(AF_NCH,(float*)arg,s->tresh,20.0,-60.0,-1.0); case AF_CONTROL_COMP_THRESH | AF_CONTROL_GET: @@ -93,18 +93,18 @@ static int control(struct af_instance_s* af, int cmd, void* arg) case AF_CONTROL_COMP_RELEASE | AF_CONTROL_GET: 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++) + for(i=0;i<AF_NCH;i++) s->ratio[i] = clamp(((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++) + for(i=0;i<AF_NCH;i++) ((float*)arg)[i] = s->ratio[i]; - return AF_OK; + return AF_OK; } return AF_UNKNOWN; } -// Deallocate memory +// Deallocate memory static void uninit(struct af_instance_s* af) { if(af->data) @@ -121,7 +121,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) float* a = (float*)c->audio; // Audio data int len = c->len/4; // Number of samples int ch = 0; // Channel counter - register int nch = c->nch; // Number of channels + register int nch = c->nch; // Number of channels register int i = 0; // Compress/expand @@ -130,8 +130,8 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) float t = 1.0 - s->time[ch]; for(i=ch;i<len;i+=nch){ register float x = a[i]; - register float pow = x*x; - s->pow[ch] = t*s->pow[ch] + + register float pow = x*x; + s->pow[ch] = t*s->pow[ch] + pow*s->time[ch]; // LP filter if(pow < s->pow[ch]){ ; diff --git a/libaf/af_delay.c b/libaf/af_delay.c index 4b94e00066..84a76c470e 100644 --- a/libaf/af_delay.c +++ b/libaf/af_delay.c @@ -37,7 +37,7 @@ typedef struct af_delay_s void* q[AF_NCH]; // Circular queues used for delaying audio signal int wi[AF_NCH]; // Write index int ri; // Read index - float d[AF_NCH]; // Delay [ms] + float d[AF_NCH]; // Delay [ms] }af_delay_t; // Initialization and runtime control @@ -108,7 +108,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) return AF_UNKNOWN; } -// Deallocate memory +// Deallocate memory static void uninit(struct af_instance_s* af) { int i; @@ -134,7 +134,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) switch(c->bps){ case 1:{ int8_t* a = c->audio; - int8_t* q = s->q[ch]; + int8_t* q = s->q[ch]; int wi = s->wi[ch]; ri = s->ri; for(i=ch;i<len;i+=nch){ @@ -148,7 +148,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) } case 2:{ int16_t* a = c->audio; - int16_t* q = s->q[ch]; + int16_t* q = s->q[ch]; int wi = s->wi[ch]; ri = s->ri; for(i=ch;i<len;i+=nch){ @@ -162,7 +162,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) } case 4:{ int32_t* a = c->audio; - int32_t* q = s->q[ch]; + int32_t* q = s->q[ch]; int wi = s->wi[ch]; ri = s->ri; for(i=ch;i<len;i+=nch){ @@ -202,5 +202,3 @@ af_info_t af_info_delay = { AF_FLAGS_REENTRANT, af_open }; - - diff --git a/libaf/af_dummy.c b/libaf/af_dummy.c index 6e32116b99..2d375924e1 100644 --- a/libaf/af_dummy.c +++ b/libaf/af_dummy.c @@ -38,7 +38,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) return AF_UNKNOWN; } -// Deallocate memory +// Deallocate memory static void uninit(struct af_instance_s* af) { if(af->data) diff --git a/libaf/af_equalizer.c b/libaf/af_equalizer.c index 519d9aba4c..bd69fdec9d 100644 --- a/libaf/af_equalizer.c +++ b/libaf/af_equalizer.c @@ -32,13 +32,13 @@ #include "af.h" #define L 2 // Storage for filter taps -#define KM 10 // Max number of bands +#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 */ /* Center frequencies for band-pass filters - The different frequency bands are: + The different frequency bands are: nr. center frequency 0 31.25 Hz 1 62.50 Hz @@ -55,7 +55,7 @@ // Maximum and minimum gain for the bands #define G_MAX +12.0 -#define G_MIN -12.0 +#define G_MIN -12.0 // Data for specific instances of this filter typedef struct af_equalizer_s @@ -76,7 +76,7 @@ static void bp2(float* a, float* b, float fc, float q){ a[0] = (1.0 + C) * cos(th); a[1] = -1 * C; - + b[0] = (1.0 - C)/2.0; b[1] = -1.0050; } @@ -84,30 +84,30 @@ static void bp2(float* a, float* b, float fc, float q){ // Initialization and runtime control static int control(struct af_instance_s* af, int cmd, void* arg) { - af_equalizer_t* s = (af_equalizer_t*)af->setup; + af_equalizer_t* s = (af_equalizer_t*)af->setup; switch(cmd){ case AF_CONTROL_REINIT:{ int k =0, i =0; float F[KM] = CF; - + s->gain_factor=0.0; // Sanity check if(!arg) return AF_ERROR; - + af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; - + // Calculate number of active filters s->K=KM; while(F[s->K-1] > (float)af->data->rate/2.2) s->K--; - + if(s->K != KM) - mp_msg(MSGT_AFILTER, MSGL_INFO, "[equalizer] Limiting the number of filters to" + mp_msg(MSGT_AFILTER, MSGL_INFO, "[equalizer] Limiting the number of filters to" " %i due to low sample rate.\n",s->K); // Generate filter taps @@ -116,7 +116,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) // Calculate how much this plugin adds to the overall time delay af->delay = 2 * af->data->nch * af->data->bps; - + // Calculate gain factor to prevent clipping at output for(k=0;k<AF_NCH;k++) { @@ -127,24 +127,24 @@ static int control(struct af_instance_s* af, int cmd, void* arg) } 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:{ float g[10]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; int i,j; - sscanf((char*)arg,"%f:%f:%f:%f:%f:%f:%f:%f:%f:%f", &g[0], &g[1], + sscanf((char*)arg,"%f:%f:%f:%f:%f:%f:%f:%f:%f:%f", &g[0], &g[1], &g[2], &g[3], &g[4], &g[5], &g[6], &g[7], &g[8] ,&g[9]); for(i=0;i<AF_NCH;i++){ for(j=0;j<KM;j++){ - ((af_equalizer_t*)af->setup)->g[i][j] = + ((af_equalizer_t*)af->setup)->g[i][j] = pow(10.0,clamp(g[j],G_MIN,G_MAX)/20.0)-1.0; } } @@ -178,7 +178,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) return AF_UNKNOWN; } -// Deallocate memory +// Deallocate memory static void uninit(struct af_instance_s* af) { if(af->data) @@ -191,12 +191,12 @@ static void unini |