[vlc-devel] commit: fixed: add S32N, rewrite FL32 ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Jan 30 13:40:39 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jan 30 14:40:13 2010 +0200| [ff9fe43d8e9e185a1abc598427f5b9629016faa3] | committer: Rémi Denis-Courmont 

fixed: add S32N, rewrite FL32

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ff9fe43d8e9e185a1abc598427f5b9629016faa3
---

 modules/audio_filter/converter/fixed.c |   38 +++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/modules/audio_filter/converter/fixed.c b/modules/audio_filter/converter/fixed.c
index f994fda..c090a9e 100644
--- a/modules/audio_filter/converter/fixed.c
+++ b/modules/audio_filter/converter/fixed.c
@@ -76,6 +76,13 @@ static int CreateFrom( vlc_object_t *p_this )
     return VLC_SUCCESS;;
 }
 
+union dw
+{
+    float    f;
+    int32_t  s;
+    uint32_t u;
+};
+
 /*****************************************************************************
  * F32 to S16
  *****************************************************************************/
@@ -139,6 +146,7 @@ static block_t *Do_F32ToS16( filter_t * p_filter, block_t * p_in_buf )
 
 /*** Conversions from decoders to FI32 */
 static block_t *Do_FL32ToF32( filter_t *, block_t * );
+static block_t *Do_S32ToF32( filter_t *, block_t * );
 static block_t *Do_S16ToF32( filter_t *, block_t * );
 static block_t *Do_U8ToF32( filter_t *, block_t * );
 
@@ -157,6 +165,10 @@ static int CreateTo( vlc_object_t *p_this )
             p_filter->pf_audio_filter = Do_FL32ToF32;
             break;
 
+        case VLC_CODEC_S32N:
+            p_filter->pf_audio_filter = Do_S32ToF32;
+            break;
+
         case VLC_CODEC_S16N:
             p_filter->pf_audio_filter = Do_S16ToF32;
             break;
@@ -231,13 +243,29 @@ out:
 
 static block_t *Do_FL32ToF32( filter_t * p_filter, block_t * p_in_buf )
 {
-    const float * p_in = (float *)p_in_buf->p_buffer;
-    vlc_fixed_t * p_out = (vlc_fixed_t *)p_in_buf->p_buffer;
+    unsigned count = p_in_buf->i_nb_samples
+                   * aout_FormatNbChannels( &p_filter->fmt_in.audio );
+    union dw *restrict p = (union dw *)p_in_buf->p_buffer, *end = p + count;
+    const float one = FIXED32_ONE;
 
-    for ( unsigned i = p_in_buf->i_nb_samples
-               * aout_FormatNbChannels( &p_filter->fmt_in.audio ) ; i-- ; )
+    while (p < end)
+    {
+        p->s = (one * p->f);
+        p++;
+    }
+    return p_in_buf;
+}
+
+static block_t *Do_S32ToF32( filter_t * p_filter, block_t * p_in_buf )
+{
+    unsigned count = p_in_buf->i_nb_samples
+                   * aout_FormatNbChannels( &p_filter->fmt_in.audio );
+    int32_t *restrict p = (int32_t *)p_in_buf->p_buffer, *end = p + count;
+
+    while (p < end)
     {
-        *p_out++ = (vlc_fixed_t)( *p_in++ * (float)FIXED32_ONE );
+        *p = *p >> 3;
+        p++;
     }
     return p_in_buf;
 }




More information about the vlc-devel mailing list