summaryrefslogtreecommitdiffstats
path: root/libaf
diff options
context:
space:
mode:
authoranders <anders@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-12-31 05:42:20 +0000
committeranders <anders@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-12-31 05:42:20 +0000
commitec6de0f24a4854e25c2ea9466561c93ec90937c0 (patch)
tree04df109bf6bf94d0abbdf5ff2a83a314c4d35813 /libaf
parent630d1fcf9446e32a159502d56beae4acec8d7a3c (diff)
downloadmpv-ec6de0f24a4854e25c2ea9466561c93ec90937c0.tar.bz2
mpv-ec6de0f24a4854e25c2ea9466561c93ec90937c0.tar.xz
10l memory leak + bug fixes in ms to sample time conversion
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8675 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libaf')
-rw-r--r--libaf/af.h4
-rw-r--r--libaf/af_comp.c4
-rw-r--r--libaf/af_gate.c4
-rw-r--r--libaf/af_pan.c2
-rw-r--r--libaf/af_tools.c18
5 files changed, 17 insertions, 15 deletions
diff --git a/libaf/af.h b/libaf/af.h
index 48dfbc5b17..79a14a7c13 100644
--- a/libaf/af.h
+++ b/libaf/af.h
@@ -187,9 +187,9 @@ int af_from_dB(int n, float* in, float* out, float k, float mi, float ma);
AF_OK if of and AF_ERROR if fail */
int af_to_dB(int n, float* in, float* out, float k);
/* Helper function used to convert from ms to sample time*/
-int af_from_ms(int n, float* in, float* out, int rate, float mi, float ma);
+int af_from_ms(int n, float* in, int* out, int rate, float mi, float ma);
/* Helper function used to convert from sample time to ms */
-int af_to_ms(int n, float* in, float* out, int rate);
+int af_to_ms(int n, int* in, float* out, int rate);
/* Helper function for testing the output format */
int af_test_output(struct af_instance_s* af, af_data_t* out);
diff --git a/libaf/af_comp.c b/libaf/af_comp.c
index 616b1e2159..13a73d5e57 100644
--- a/libaf/af_comp.c
+++ b/libaf/af_comp.c
@@ -26,8 +26,8 @@ typedef struct af_comp_s
float time[AF_NCH]; // Forgetting factor for power estimate
float pow[AF_NCH]; // Estimated power level [dB]
float tresh[AF_NCH]; // Threshold [dB]
- float attack[AF_NCH]; // Attack time [ms]
- float release[AF_NCH]; // Release time [ms]
+ int attack[AF_NCH]; // Attack time [ms]
+ int release[AF_NCH]; // Release time [ms]
float ratio[AF_NCH]; // Compression ratio
}af_comp_t;
diff --git a/libaf/af_gate.c b/libaf/af_gate.c
index e6df778db0..3813424783 100644
--- a/libaf/af_gate.c
+++ b/libaf/af_gate.c
@@ -26,8 +26,8 @@ typedef struct af_gate_s
float time[AF_NCH]; // Forgetting factor for power estimate
float pow[AF_NCH]; // Estimated power level [dB]
float tresh[AF_NCH]; // Threshold [dB]
- float attack[AF_NCH]; // Attack time [ms]
- float release[AF_NCH]; // Release time [ms]
+ int attack[AF_NCH]; // Attack time [ms]
+ int release[AF_NCH]; // Release time [ms]
float range[AF_NCH]; // Range level [dB]
}af_gate_t;
diff --git a/libaf/af_pan.c b/libaf/af_pan.c
index 49e9e4cb2e..8398e169cf 100644
--- a/libaf/af_pan.c
+++ b/libaf/af_pan.c
@@ -113,6 +113,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
// Deallocate memory
static void uninit(struct af_instance_s* af)
{
+ if(af->data->audio)
+ free(af->data->audio);
if(af->data)
free(af->data);
if(af->setup)
diff --git a/libaf/af_tools.c b/libaf/af_tools.c
index d9f8bc9498..11eea2b49e 100644
--- a/libaf/af_tools.c
+++ b/libaf/af_tools.c
@@ -29,7 +29,7 @@ inline int af_to_dB(int n, float* in, float* out, float k)
if(!in || !out)
return AF_ERROR;
- for(i=0;i<AF_NCH;i++){
+ for(i=0;i<n;i++){
if(in[i] == 0.0)
out[i]=-200.0;
else
@@ -38,30 +38,30 @@ inline int af_to_dB(int n, float* in, float* out, float k)
return AF_OK;
}
-/* Convert from ms to sample time*/
-inline int af_from_ms(int n, float* in, float* out, int rate, float mi, float ma)
+/* Convert from ms to sample time */
+inline int af_from_ms(int n, float* in, int* out, int rate, float mi, float ma)
{
int i = 0;
// Sanity check
if(!in || !out)
return AF_ERROR;
- for(i=0;i<AF_NCH;i++)
- out[i]=clamp(in[i],ma,mi);
+ for(i=0;i<n;i++)
+ out[i]=(int)((float)rate * clamp(in[i],mi,ma)/1000.0);
return AF_OK;
}
/* Convert from sample time to ms */
-inline int af_to_ms(int n, float* in, float* out, int rate)
+inline int af_to_ms(int n, int* in, float* out, int rate)
{
int i = 0;
// Sanity check
- if(!in || !out)
+ if(!in || !out || !rate)
return AF_ERROR;
- for(i=0;i<AF_NCH;i++)
- out[i]=in[i];
+ for(i=0;i<n;i++)
+ out[i]=1000.0 * (float)in[i]/((float)rate);
return AF_OK;
}