changeset 16195:cb08f47d3a79

Removed in-filter int to float conversion. af_ladspa now demands floats as that's what LADSPA filters use internally too. conversion from int, if needed, is done by af_format as it's supposed to.
author ivo
date Wed, 10 Aug 2005 23:27:39 +0000
parents 167342641f0b
children d90f867b870d
files libaf/af_ladspa.c
diffstat 1 files changed, 9 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_ladspa.c	Wed Aug 10 22:48:32 2005 +0000
+++ b/libaf/af_ladspa.c	Wed Aug 10 23:27:39 2005 +0000
@@ -24,6 +24,7 @@
  * Changelog
  *
  * 2005-06-21   Replaced erroneous use of mp_msg by af_msg
+ * 2005-05-30   Removed int16 to float conversion; leave that to af_format
  * 2004-12-23   Added to CVS
  * 2004-12-22   Cleaned up cosmetics
  *              Made conversion loops in play() more cache-friendly
@@ -535,12 +536,12 @@
 
         if (!arg) return AF_ERROR;
 
-        /* for now, only accept 16 bit signed int */
+        /* accept FLOAT, let af_format do conversion */
 
         af->data->rate   = ((af_data_t*)arg)->rate;
         af->data->nch    = ((af_data_t*)arg)->nch;
-        af->data->format = AF_FORMAT_S16_NE;
-        af->data->bps    = 2;
+        af->data->format = AF_FORMAT_FLOAT_NE;
+        af->data->bps    = 4;
 
         /* arg->len is not set here yet, so init of buffers and connecting the
          * filter, has to be done in play() :-/
@@ -768,12 +769,11 @@
 static af_data_t* play(struct af_instance_s *af, af_data_t *data) {
     af_ladspa_t *setup = af->setup;
     const LADSPA_Descriptor *pdes = setup->plugin_descriptor;
-    int16_t *audio = (int16_t*)data->audio;
-    int nsamples = data->len/2; /* /2 because it's int16_t */
+    float *audio = (float*)data->audio;
+    int nsamples = data->len/4; /* /4 because it's 32-bit float */
     int nch = data->nch;
     int rate = data->rate;
     int i, p; 
-    float v;
 
     if (setup->status !=AF_OK)
         return data;
@@ -911,7 +911,7 @@
 
     for (p=0; p<setup->bufsize; p++) {
         for (i=0; i<nch; i++) {
-            setup->inbufs[i][p] = ( (float) audio[p*nch + i] ) / 32768.0f;
+            setup->inbufs[i][p] = audio[p*nch + i];
         }
     }
 
@@ -923,15 +923,11 @@
             i++;
     }
 
-    /* Extract outbufs, hard clipping in case the filter exceeded [-1.0,1.0] */
+    /* Extract outbufs */
 
     for (p=0; p<setup->bufsize; p++) {
         for (i=0; i<nch; i++) {
-            v = setup->outbufs[i][p];
-            v *= 32768.0f;
-            v = (v > 32767.0f ? 32767.0f : v);
-            v = (v < -32768.0f ? -32768.0f : v);
-            audio[p*nch + i] = (int16_t) v;
+            audio[p*nch + i] = setup->outbufs[i][p];
         }
     }