summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
Diffstat (limited to 'audio')
-rw-r--r--audio/filter/af_center.c12
-rw-r--r--audio/filter/af_channels.c34
-rw-r--r--audio/filter/af_delay.c46
-rw-r--r--audio/filter/af_drc.c36
-rw-r--r--audio/filter/af_dummy.c2
-rw-r--r--audio/filter/af_equalizer.c86
-rw-r--r--audio/filter/af_export.c44
-rw-r--r--audio/filter/af_extrastereo.c12
-rw-r--r--audio/filter/af_hrtf.c452
-rw-r--r--audio/filter/af_hrtf.h50
-rw-r--r--audio/filter/af_karaoke.c56
-rw-r--r--audio/filter/af_pan.c20
-rw-r--r--audio/filter/af_sinesuppress.c16
-rw-r--r--audio/filter/af_sub.c30
-rw-r--r--audio/filter/af_surround.c36
-rw-r--r--audio/filter/dsp.h4
-rw-r--r--audio/filter/equalizer.h26
-rw-r--r--audio/filter/filter.c72
-rw-r--r--audio/filter/filter.h2
-rw-r--r--audio/filter/tools.c6
-rw-r--r--audio/filter/window.c6
21 files changed, 524 insertions, 524 deletions
diff --git a/audio/filter/af_center.c b/audio/filter/af_center.c
index 2e626bffb6..106e08412e 100644
--- a/audio/filter/af_center.c
+++ b/audio/filter/af_center.c
@@ -35,7 +35,7 @@
// Data for specific instances of this filter
typedef struct af_center_s
{
- int ch; // Channel number which to insert the filtered data
+ int ch; // Channel number which to insert the filtered data
}af_center_t;
// Initialization and runtime control
@@ -61,12 +61,12 @@ 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
+ struct mp_audio* c = data; // Current working data
af_center_t* s = af->priv; // Setup for this instance
- float* a = c->planes[0]; // Audio data
- int nch = c->nch; // Number of channels
- int len = c->samples*c->nch; // Number of samples in current audio block
- int ch = s->ch; // Channel in which to insert the center audio
+ float* a = c->planes[0]; // Audio data
+ int nch = c->nch; // Number of channels
+ int len = c->samples*c->nch; // Number of samples in current audio block
+ int ch = s->ch; // Channel in which to insert the center audio
register int i;
// Run filter
diff --git a/audio/filter/af_channels.c b/audio/filter/af_channels.c
index 6db44ba024..118607b66f 100644
--- a/audio/filter/af_channels.c
+++ b/audio/filter/af_channels.c
@@ -114,7 +114,7 @@ static void copy(struct af_instance *af, void* in, void* out,
}
default:
MP_ERR(af, "Unsupported number of bytes/sample: %i"
- " please report this error on the MPlayer mailing list. \n",bps);
+ " please report this error on the MPlayer mailing list. \n",bps);
}
}
@@ -125,7 +125,7 @@ static int check_routes(struct af_instance *af, int nin, int nout)
int i;
if((s->nr < 1) || (s->nr > AF_NCH)){
MP_ERR(af, "The number of routing pairs must be"
- " between 1 and %i. Current value is %i\n",AF_NCH,s->nr);
+ " between 1 and %i. Current value is %i\n",AF_NCH,s->nr);
return AF_ERROR;
}
@@ -154,22 +154,22 @@ static int control(struct af_instance* af, int cmd, void* arg)
int i;
// Make sure this filter isn't redundant
if(af->data->nch == ((struct mp_audio*)arg)->nch)
- return AF_DETACH;
+ return AF_DETACH;
// If mono: fake stereo
if(((struct mp_audio*)arg)->nch == 1){
- s->nr = MPMIN(af->data->nch,2);
- for(i=0;i<s->nr;i++){
- s->route[i][FR] = 0;
- s->route[i][TO] = i;
- }
+ s->nr = MPMIN(af->data->nch,2);
+ for(i=0;i<s->nr;i++){
+ s->route[i][FR] = 0;
+ s->route[i][TO] = i;
+ }
}
else{
- s->nr = MPMIN(af->data->nch, ((struct mp_audio*)arg)->nch);
- for(i=0;i<s->nr;i++){
- s->route[i][FR] = i;
- s->route[i][TO] = i;
- }
+ s->nr = MPMIN(af->data->nch, ((struct mp_audio*)arg)->nch);
+ for(i=0;i<s->nr;i++){
+ s->route[i][FR] = i;
+ s->route[i][TO] = i;
+ }
}
}
@@ -184,10 +184,10 @@ 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
- struct mp_audio* l = af->data; // Local data
+ struct mp_audio* c = data; // Current working data
+ struct mp_audio* l = af->data; // Local data
af_channels_t* s = af->priv;
- int i;
+ int i;
mp_audio_realloc_min(af->data, data->samples);
@@ -197,7 +197,7 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
if(AF_OK == check_routes(af,c->nch,l->nch))
for(i=0;i<s->nr;i++)
copy(af, c->planes[0],l->planes[0],c->nch,s->route[i][FR],
- l->nch,s->route[i][TO],mp_audio_psize(c),c->bps);
+ l->nch,s->route[i][TO],mp_audio_psize(c),c->bps);
// Set output data
c->planes[0] = l->planes[0];
diff --git a/audio/filter/af_delay.c b/audio/filter/af_delay.c
index a8cd79f117..b16cdc1f63 100644
--- a/audio/filter/af_delay.c
+++ b/audio/filter/af_delay.c
@@ -37,10 +37,10 @@
// Data for specific instances of this filter
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]
+ 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]
char *delaystr;
}af_delay_t;
@@ -69,7 +69,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
for(i=0;i<af->data->nch;i++){
s->q[i] = calloc(L,af->data->bps);
if(NULL == s->q[i])
- MP_FATAL(af, "Out of memory\n");
+ MP_FATAL(af, "Out of memory\n");
}
if(AF_OK != af_from_ms(AF_NCH, s->d, s->wi, af->data->rate, 0.0, 1000.0))
@@ -99,12 +99,12 @@ static void uninit(struct af_instance* af)
// 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_delay_t* s = af->priv; // Setup for this instance
- int nch = c->nch; // Number of channels
- int len = mp_audio_psize(c)/c->bps; // Number of sample in data chunk
- int ri = 0;
- int ch,i;
+ struct mp_audio* c = data; // Current working data
+ af_delay_t* s = af->priv; // Setup for this instance
+ int nch = c->nch; // Number of channels
+ int len = mp_audio_psize(c)/c->bps; // Number of sample in data chunk
+ int ri = 0;
+ int ch,i;
for(ch=0;ch<nch;ch++){
switch(c->bps){
case 1:{
@@ -113,10 +113,10 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
int wi = s->wi[ch];
ri = s->ri;
for(i=ch;i<len;i+=nch){
- q[wi] = a[i];
- a[i] = q[ri];
- UPDATEQI(wi);
- UPDATEQI(ri);
+ q[wi] = a[i];
+ a[i] = q[ri];
+ UPDATEQI(wi);
+ UPDATEQI(ri);
}
s->wi[ch] = wi;
break;
@@ -127,10 +127,10 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
int wi = s->wi[ch];
ri = s->ri;
for(i=ch;i<len;i+=nch){
- q[wi] = a[i];
- a[i] = q[ri];
- UPDATEQI(wi);
- UPDATEQI(ri);
+ q[wi] = a[i];
+ a[i] = q[ri];
+ UPDATEQI(wi);
+ UPDATEQI(ri);
}
s->wi[ch] = wi;
break;
@@ -141,10 +141,10 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
int wi = s->wi[ch];
ri = s->ri;
for(i=ch;i<len;i+=nch){
- q[wi] = a[i];
- a[i] = q[ri];
- UPDATEQI(wi);
- UPDATEQI(ri);
+ q[wi] = a[i];
+ a[i] = q[ri];
+ UPDATEQI(wi);
+ UPDATEQI(ri);
}
s->wi[ch] = wi;
break;
diff --git a/audio/filter/af_drc.c b/audio/filter/af_drc.c
index fad34ba500..3bcd368d4d 100644
--- a/audio/filter/af_drc.c
+++ b/audio/filter/af_drc.c
@@ -70,8 +70,8 @@ typedef struct af_volume_s
// method 2
int idx;
struct {
- float avg; // average level of the sample
- int len; // sample size (weight)
+ float avg; // average level of the sample
+ int len; // sample size (weight)
} mem[NSAMPLES];
// "Ideal" level
float mid_s16;
@@ -100,8 +100,8 @@ static int control(struct af_instance* af, int cmd, void* arg)
static void method1_int16(af_drc_t *s, struct mp_audio *c)
{
register int i = 0;
- int16_t *data = (int16_t*)c->planes[0]; // Audio data
- int len = c->samples*c->nch; // Number of samples
+ int16_t *data = (int16_t*)c->planes[0]; // Audio data
+ int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, neededmul;
int tmp;
@@ -142,8 +142,8 @@ static void method1_int16(af_drc_t *s, struct mp_audio *c)
static void method1_float(af_drc_t *s, struct mp_audio *c)
{
register int i = 0;
- float *data = (float*)c->planes[0]; // Audio data
- int len = c->samples*c->nch; // Number of samples
+ float *data = (float*)c->planes[0]; // Audio data
+ int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, neededmul, tmp;
for (i = 0; i < len; i++)
@@ -179,8 +179,8 @@ static void method1_float(af_drc_t *s, struct mp_audio *c)
static void method2_int16(af_drc_t *s, struct mp_audio *c)
{
register int i = 0;
- int16_t *data = (int16_t*)c->planes[0]; // Audio data
- int len = c->samples*c->nch; // Number of samples
+ int16_t *data = (int16_t*)c->planes[0]; // Audio data
+ int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, avg = 0.0;
int tmp, totallen = 0;
@@ -204,8 +204,8 @@ static void method2_int16(af_drc_t *s, struct mp_audio *c)
avg /= (float)totallen;
if (avg >= SIL_S16)
{
- s->mul = s->mid_s16 / avg;
- s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX);
+ s->mul = s->mid_s16 / avg;
+ s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX);
}
}
@@ -229,8 +229,8 @@ static void method2_int16(af_drc_t *s, struct mp_audio *c)
static void method2_float(af_drc_t *s, struct mp_audio *c)
{
register int i = 0;
- float *data = (float*)c->planes[0]; // Audio data
- int len = c->samples*c->nch; // Number of samples
+ float *data = (float*)c->planes[0]; // Audio data
+ int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, avg = 0.0, tmp;
int totallen = 0;
@@ -254,8 +254,8 @@ static void method2_float(af_drc_t *s, struct mp_audio *c)
avg /= (float)totallen;
if (avg >= SIL_FLOAT)
{
- s->mul = s->mid_float / avg;
- s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX);
+ s->mul = s->mid_float / avg;
+ s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX);
}
}
@@ -279,16 +279,16 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
if(af->data->format == (AF_FORMAT_S16))
{
if (s->method == 2)
- method2_int16(s, data);
+ method2_int16(s, data);
else
- method1_int16(s, data);
+ method1_int16(s, data);
}
else if(af->data->format == (AF_FORMAT_FLOAT))
{
if (s->method == 2)
- method2_float(s, data);
+ method2_float(s, data);
else
- method1_float(s, data);
+ method1_float(s, data);
}
return 0;
}
diff --git a/audio/filter/af_dummy.c b/audio/filter/af_dummy.c
index c13c32b968..d920480e01 100644
--- a/audio/filter/af_dummy.c
+++ b/audio/filter/af_dummy.c
@@ -34,7 +34,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
case AF_CONTROL_REINIT: ;
*af->data = *(struct mp_audio*)arg;
MP_VERBOSE(af, "Was reinitialized: %iHz/%ich/%s\n",
- af->data->rate,af->data->nch,af_fmt_to_str(af->data->format));
+ af->data->rate,af->data->nch,af_fmt_to_str(af->data->format));
return AF_OK;
}
return AF_UNKNOWN;
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;
diff --git a/audio/filter/af_export.c b/audio/filter/af_export.c
index 542b2a1f9f..faa09bf927 100644
--- a/audio/filter/af_export.c
+++ b/audio/filter/af_export.c
@@ -47,7 +47,7 @@
#define DEF_SZ 512 // default buffer size (in samples)
#define SHARED_FILE "mpv-af_export" /* default file name
- (relative to ~/.mpv/ */
+ (relative to ~/.mpv/ */
#define SIZE_HEADER (2 * sizeof(int) + sizeof(unsigned long long))
@@ -55,12 +55,12 @@
typedef struct af_export_s
{
unsigned long long count; // Used for sync
- void* buf[AF_NCH]; // Buffers for storing the data before it is exported
- int sz; // Size of buffer in samples
- int wi; // Write index
- int fd; // File descriptor to shared memory area
- char* filename; // File to export data
- uint8_t *mmap_area; // MMap shared area
+ void* buf[AF_NCH]; // Buffers for storing the data before it is exported
+ int sz; // Size of buffer in samples
+ int wi; // Write index
+ int fd; // File descriptor to shared memory area
+ char* filename; // File to export data
+ uint8_t *mmap_area; // MMap shared area
} af_export_t;
@@ -109,7 +109,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
MP_INFO(af, "Exporting to file: %s\n", s->filename);
if(s->fd < 0) {
MP_FATAL(af, "Could not open/create file: %s\n",
- s->filename);
+ s->filename);
return AF_ERROR;
}
@@ -127,7 +127,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
if(s->mmap_area == NULL)
MP_FATAL(af, "Could not mmap file %s\n", s->filename);
MP_INFO(af, "Memory mapped to file: %s (%p)\n",
- s->filename, s->mmap_area);
+ s->filename, s->mmap_area);
// Initialize header
*((int*)s->mmap_area) = af->data->nch;
@@ -164,27 +164,27 @@ static void uninit( struct af_instance* af )
*/
static int filter( struct af_instance* af, struct mp_audio* data, int flags)
{
- struct mp_audio* c = data; // Current working data
- af_export_t* s = af->priv; // Setup for this instance
- int16_t* a = c->planes[0]; // Incomming sound
- int nch = c->nch; // Number of channels
- int len = c->samples*c->nch; // Number of sample in data chunk
- int sz = s->sz; // buffer size (in samples)
- int flag = 0; // Set to 1 if buffer is filled
+ struct mp_audio* c = data; // Current working data
+ af_export_t* s = af->priv; // Setup for this instance
+ int16_t* a = c->planes[0]; // Incomming sound
+ int nch = c->nch; // Number of channels
+ int len = c->samples*c->nch; // Number of sample in data chunk
+ int sz = s->sz; // buffer size (in samples)
+ int flag = 0; // Set to 1 if buffer is filled
- int ch, i;
+ int ch, i;
// Fill all buffers
for(ch = 0; ch < nch; ch++){
- int wi = s->wi; // Reset write index
- int16_t* b = s->buf[ch]; // Current buffer
+ int wi = s->wi; // Reset write index
+ int16_t* b = s->buf[ch]; // Current buffer
// Copy data to export buffers
for(i = ch; i < len; i += nch){
b[wi++] = a[i];
if(wi >= sz){ // Don't write outside the end of the buffer
- flag = 1;
- break;
+ flag = 1;
+ break;
}
}
s->wi = wi % s->sz;
@@ -196,7 +196,7 @@ static int filter( struct af_instance* af, struct mp_audio* data, int flags)
memcpy(s->mmap_area + SIZE_HEADER, s->buf[0], sz * c->bps * nch);
s->count++; // increment counter (to sync)
memcpy(s->mmap_area + SIZE_HEADER - sizeof(s->count),
- &(s->count), sizeof(s->count));
+ &(s->count), sizeof(s->count));
}
return 0;
diff --git a/audio/filter/af_extrastereo.c b/audio/filter/af_extrastereo.c
index 1e814e8351..05a1ac8e36 100644
--- a/audio/filter/af_extrastereo.c
+++ b/audio/filter/af_extrastereo.c
@@ -51,11 +51,11 @@ static int control(struct af_instance* af, int cmd, void* arg)
mp_audio_set_num_channels(af->data, 2);
if (af->data->format == AF_FORMAT_FLOAT)
{
- af->filter = play_float;
+ af->filter = play_float;
}// else
{
mp_audio_set_format(af->data, AF_FORMAT_S16);
- af->filter = play_s16;
+ af->filter = play_s16;
}
return af_test_output(af,(struct mp_audio*)arg);
@@ -69,8 +69,8 @@ static int play_s16(struct af_instance* af, struct mp_audio* data, int f)
{
af_extrastereo_t *s = af->priv;
register int i = 0;
- int16_t *a = (int16_t*)data->planes[0]; // Audio data
- int len = data->samples*data->nch; // Number of samples
+ int16_t *a = (int16_t*)data->planes[0]; // Audio data
+ int len = data->samples*data->nch; // Number of samples
int avg, l, r;
for (i = 0; i < len; i+=2)
@@ -91,8 +91,8 @@ static int play_float(struct af_instance* af, struct mp_audio* data, int f)
{
af_extrastereo_t *s = af->priv;
register int i = 0;
- float *a = (float*)data->planes[0]; // Audio data
- int len = data->samples * data->nch; // Number of samples
+ float *a = (float*)data->planes[0]; // Audio data
+ int len = data->samples * data->nch; // Number of samples
float avg, l, r;
for (i = 0; i < len; i+=2)
diff --git a/audio/filter/af_hrtf.c b/audio/filter/af_hrtf.c
index e329b4e558..e8ab5fc72d 100644
--- a/audio/filter/af_hrtf.c
+++ b/audio/filter/af_hrtf.c
@@ -75,23 +75,23 @@ typedef struct af_hrtf_s {
} af_hrtf_t;
/* Convolution on a ring buffer
- * nx: length of the ring buffer
- * nk: length of the convolution kernel
- * sx: ring buffer
- * sk: convolution kernel
- * offset: offset on the ring buffer, can be
+ * nx: length of the ring buffer
+ * nk: length of the convolution kernel
+ * sx: ring buffer
+ * sk: convolution kernel
+ * offset: offset on the ring buffer, can be
*/
static float conv(const int nx, const int nk, const float *sx, const float *sk,
- const int offset)
+ const int offset)
{
/* k = reminder of offset / nx */
int k = offset >= 0 ? offset % nx : nx + (offset % nx);
if(nk + k <= nx)
- return af_filter_fir(nk, sx + k, sk);
+ return af_filter_fir(nk, sx + k, sk);
else
- return af_filter_fir(nk + k - nx, sx, sk + nx - k) +
- af_filter_fir(nx - k, sx + k, sk);
+ return af_filter_fir(nk + k - nx, sx, sk + nx - k) +
+ af_filter_fir(nx - k, sx + k, sk);
}
/* Detect when the impulse response starts (significantly) */
@@ -104,8 +104,8 @@ static int pulse_detect(const float *sx)
int i;
for(i = 0; i < nmax; i++)
- if(fabs(sx[i]) > thresh)
- return i;
+ if(fabs(sx[i]) > thresh)
+ return i;
return 0;
}
@@ -122,14 +122,14 @@ static inline float passive_lock(float x)
/* Unified active matrix decoder for 2 channel matrix encoded surround
sources */
static inline void matrix_decode(short *in, const int k, const int il,
- const int ir, const int decode_rear,
- const int dlbuflen,
- float l_fwr, float r_fwr,
- float lpr_fwr, float lmr_fwr,
- float *adapt_l_gain, float *adapt_r_gain,
- float *adapt_lpr_gain, float *adapt_lmr_gain,
- float *lf, float *rf, float *lr,
- float *rr, float *cf)
+ const int ir, const int decode_rear,
+ const int dlbuflen,
+ float l_fwr, float r_fwr,
+ float lpr_fwr, float lmr_fwr,
+ float *adapt_l_gain, float *adapt_r_gain,
+ float *adapt_lpr_gain, float *adapt_lmr_gain,
+ float *lf, float *rf, float *lr,
+ float *rr, float *cf)
{
const int kr = (k + MATREARDELAY) % dlbuflen;
float l_gain = (l_fwr + r_fwr) /
@@ -161,13 +161,13 @@ static inline void matrix_decode(short *in, const int k, const int il,
fp_out = fopen("af_hrtf.log", "w");
if(counter % 240 == 0)
fprintf(fp_out, "%g %g %g %g %g ", counter * (1.0 / 48000),
- l_gain, r_gain, lpr_gain, lmr_gain);
+ l_gain, r_gain, lpr_gain, lmr_gain);
#endif
/*** AXIS NO. 1: (Lt, Rt) -> (C, Ls, Rs) ***/
/* AGC adaption */
d_gain = (fabs(l_gain - *adapt_l_gain) +
- fabs(r_gain - *adapt_r_gain)) * 0.5;
+ fabs(r_gain - *adapt_r_gain)) * 0.5;
f = d_gain * (1.0 / MATAGCTRIG);
f = MATAGCDECAY - MATAGCDECAY / (1 + f * f);
*adapt_l_gain = (1 - f) * *adapt_l_gain + f * l_gain;
@@ -179,12 +179,12 @@ static inline void matrix_decode(short *in, const int k, const int il,
if(decode_rear) {
lr[kr] = rr[kr] = (l_agc - r_agc) * M_SQRT1_2;
/* Stereo rear channel is steered with the same AGC steering as
- the decoding matrix. Note this requires a fast updating AGC
- at the order of 20 ms (which is the case here). */
+ the decoding matrix. Note this requires a fast updating AGC
+ at the order of 20 ms (which is the case here). */
lr[kr] *= (l_fwr + l_fwr) /
- (1 + l_fwr + r_fwr);
+ (1 + l_fwr + r_fwr);
rr[kr] *= (r_fwr + r_fwr) /
- (1 + l_fwr + r_fwr);
+ (1 + l_fwr + r_fwr);
}
/*** AXIS NO. 2: (Lt + Rt, Lt - Rt) -> (L, R) ***/
@@ -221,9 +221,9 @@ static inline void matrix_decode(short *in, const int k, const int il,
#if 0
if(counter % 240 == 0)
fprintf(fp_out, "%g %g %g %g %g\n",
- *adapt_l_gain, *adapt_r_gain,
- *adapt_lpr_gain, *adapt_lmr_gain,
- c_gain);
+ *adapt_l_gain, *adapt_r_gain,
+ *adapt_lpr_gain, *adapt_lmr_gain,
+ c_gain);
counter++;
#endif
}
@@ -237,18 +237,18 @@ static inline void update_ch(af_hrtf_t *s, short *in, const int k)
s->l_fwr += abs(in[0]) - fabs(s->fwrbuf_l[fwr_pos]);
s->r_fwr += abs(in[1]) - fabs(s->fwrbuf_r[fwr_pos]);
s->lpr_fwr += abs(in[0] + in[1]) -
- fabs(s->fwrbuf_l[fwr_pos] + s->fwrbuf_r[fwr_pos]);
+ fabs(s->fwrbuf_l[fwr_pos] + s->fwrbuf_r[fwr_pos]);
s->lmr_fwr += abs(in[0] - in[1]) -
- fabs(s->fwrbuf_l[fwr_pos] - s->fwrbuf_r[fwr_pos]);
+ fabs(s->fwrbuf_l[fwr_pos] - s->fwrbuf_r[fwr_pos]);
}
/* Rear matrix decoder */
if(s->matrix_mode) {
s->lr_fwr += abs(in[2]) - fabs(s->fwrbuf_lr[fwr_pos]);
s->rr_fwr += abs(in[3]) - fabs(s->fwrbuf_rr[fwr_pos]);
s->lrprr_fwr += abs(in[2] + in[3]) -
- fabs(s->fwrbuf_lr[fwr_pos] + s->fwrbuf_rr[fwr_pos]);
+ fabs(s->fwrbuf_lr[fwr_pos] + s->fwrbuf_rr[fwr_pos]);
s->lrmrr_fwr += abs(in[2] - in[3]) -
- fabs(s->fwrbuf_lr[fwr_pos] - s->fwrbuf_rr[fwr_pos]);
+ fabs(s->fwrbuf_lr[fwr_pos] - s->fwrbuf_rr[fwr_pos]);
}
switch (s->decode_mode) {
@@ -265,11 +265,11 @@ static inline void update_ch(af_hrtf_t *s, short *in, const int k)
s->fwrbuf_l[k] = in[0];
s->fwrbuf_r[k] = in[1];
matrix_decode(in, k, 0, 1, 1, s->dlbuflen,
- s->l_fwr, s->r_fwr,
- s->lpr_fwr, s->lmr_fwr,
- &(s->adapt_l_gain), &(s->adapt_r_gain),
- &(s->adapt_lpr_gain), &(s->adapt_lmr_gain),
- s->lf, s->rf, s->lr, s->rr, s->cf);
+ s->l_fwr, s->r_fwr,
+ s->lpr_fwr, s->lmr_fwr,
+ &(s->adapt_l_gain), &(s->adapt_r_gain),
+ &(s->adapt_lpr_gain), &(s->adapt_lmr_gain),
+ s->lf, s->rf, s->lr, s->rr, s->cf);
break;
case HRTF_MIX_STEREO:
/* Stereo sources */
@@ -292,30 +292,30 @@ static int control(struct af_instance *af, int cmd, void* arg)
switch(cmd) {
case AF_CONTROL_REINIT:
- af->data->rate = ((struct mp_audio*)arg)->rate;
- if(af->data->rate != 48000) {
- // automatic samplerate adjustment in the filter chain
- // is not yet supported.
- MP_ERR(af, "ERROR: Sampling rate is not 48000 Hz (%d)!\n",
- af->data->rate);
- return AF_ERROR;
- }
- mp_audio_set_channels_old(af->data, ((struct mp_audio*)arg)->nch);
- if(af->data->nch == 2) {
- /* 2 channel input */
- if(s->decode_mode != HRTF_MIX_MATRIX2CH) {
- /* Default behavior is stereo mixing. */
- s->decode_mode = HRTF_MIX_STEREO;
- }
- }
- else if (af->data->nch < 5)
- mp_audio_set_channels_old(af->data, 5);
+ af->data->rate = ((struct mp_audio*)arg)->rate;
+ if(af->data->rate != 48000) {
+ // automatic samplerate adjustment in the filter chain
+ // is not yet supported.
+ MP_ERR(af, "ERROR: Sampling rate is not 48000 Hz (%d)!\n",
+ af->data->rate);
+ return AF_ERROR;
+ }
+ mp_audio_set_channels_old(af->data, ((struct mp_audio*)arg)->nch);
+ if(af->data->nch == 2) {
+ /* 2 channel input */
+ if(s->decode_mode != HRTF_MIX_MATRIX2CH) {
+ /* Default behavior is stereo mixing. */
+ s->decode_mode = HRTF_MIX_STEREO;
+ }
+ }
+ else if (af->data->nch < 5)
+ mp_audio_set_channels_old(af->data, 5);
mp_audio_set_format(af->data, AF_FORMAT_S16);
- test_output_res = af_test_output(af, (struct mp_audio*)arg);
- // after testing input set the real output format
+ test_output_res = af_test_output(af, (struct mp_audio*)arg);
+ // after testing input set the real output format
mp_audio_set_num_channels(af->data, 2);
- s->print_flag = 1;
- return test_output_res;
+ s->print_flag = 1;
+ return test_output_res;
}
return AF_UNKNOWN;
@@ -324,21 +324,21 @@ static int control(struct af_instance *af, int cmd, void* arg)
/* Deallocate memory */
static void uninit(struct af_instance *af)
{
- af_hrtf_t *s = af->priv;
-