[vlc-devel] commit: Added s32l/b to float conversion support (close #1872). ( Laurent Aimar )

git version control git at videolan.org
Tue Aug 19 21:10:36 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Aug 19 20:54:41 2008 +0200| [10e4032179794aa614cf029de90dd3d4b66f15f8] | committer: Laurent Aimar 

Added s32l/b to float conversion support (close #1872).

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

 modules/audio_filter/converter/float.c |   70 +++++++++++++++++++++++++++++---
 1 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/modules/audio_filter/converter/float.c b/modules/audio_filter/converter/float.c
index c388831..7d9c022 100644
--- a/modules/audio_filter/converter/float.c
+++ b/modules/audio_filter/converter/float.c
@@ -76,12 +76,16 @@ static void Do_S16ToFL32( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
                            aout_buffer_t * );
 static void Do_S24ToFL32( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
                            aout_buffer_t * );
+static void Do_S32ToFL32( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
+                           aout_buffer_t * );
 
 static int  Create_S16ToFL32_SW( vlc_object_t * );
 static void Do_S16ToFL32_SW( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
                            aout_buffer_t * );
 static void Do_S24ToFL32_SW( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
                            aout_buffer_t * );
+static void Do_S32ToFL32_SW( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
+                           aout_buffer_t * );
 
 static int  Create_S8ToFL32( vlc_object_t * );
 static void Do_S8ToFL32( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
@@ -393,7 +397,8 @@ static int Create_S16ToFL32( vlc_object_t *p_this )
     aout_filter_t * p_filter = (aout_filter_t *)p_this;
 
     if ( ( p_filter->input.i_format != AOUT_FMT_S16_NE &&
-           p_filter->input.i_format != AOUT_FMT_S24_NE )
+           p_filter->input.i_format != AOUT_FMT_S24_NE &&
+           p_filter->input.i_format != AOUT_FMT_S32_NE )
           || p_filter->output.i_format != VLC_FOURCC('f','l','3','2') )
     {
         return -1;
@@ -404,7 +409,9 @@ static int Create_S16ToFL32( vlc_object_t *p_this )
         return -1;
     }
 
-    if( p_filter->input.i_format == AOUT_FMT_S24_NE )
+    if( p_filter->input.i_format == AOUT_FMT_S32_NE )
+        p_filter->pf_do_work = Do_S32ToFL32;
+    else if( p_filter->input.i_format == AOUT_FMT_S24_NE )
         p_filter->pf_do_work = Do_S24ToFL32;
     else
         p_filter->pf_do_work = Do_S16ToFL32;
@@ -442,7 +449,7 @@ static void Do_S16ToFL32( aout_instance_t * p_aout, aout_filter_t * p_filter,
     }
 
     p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
-    p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 2;
+    p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 4 / 2;
 }
 
 static void Do_S24ToFL32( aout_instance_t * p_aout, aout_filter_t * p_filter,
@@ -471,6 +478,25 @@ static void Do_S24ToFL32( aout_instance_t * p_aout, aout_filter_t * p_filter,
     p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 4 / 3;
 }
 
+static void Do_S32ToFL32( aout_instance_t * p_aout, aout_filter_t * p_filter,
+                          aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
+{
+    VLC_UNUSED(p_aout);
+    int i = p_in_buf->i_nb_samples * aout_FormatNbChannels( &p_filter->input );
+
+    /* We start from the end because b_in_place is true */
+    int32_t * p_in = (int32_t *)p_in_buf->p_buffer + i - 1;
+    float * p_out = (float *)p_out_buf->p_buffer + i - 1;
+
+    while( i-- )
+    {
+        *p_out-- = (float)*p_in-- / 2147483648.0;
+    }
+
+    p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
+    p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 4 / 4;
+}
+
 /*****************************************************************************
  * S16 To Float32 with endianness conversion
  *****************************************************************************/
@@ -504,11 +530,23 @@ static int Create_S16ToFL32_SW( vlc_object_t *p_this )
 
         return 0;
     }
+
+    if ( (p_filter->input.i_format == VLC_FOURCC('s','3','2','l') ||
+         p_filter->input.i_format == VLC_FOURCC('s','3','2','b'))
+         && p_filter->output.i_format == VLC_FOURCC('f','l','3','2')
+         && p_filter->input.i_format != AOUT_FMT_S32_NE )
+    {
+        p_filter->pf_do_work = Do_S32ToFL32_SW;
+        p_filter->b_in_place = true;
+
+        return 0;
+    }
+
     return -1;
 }
 
 static void Do_S16ToFL32_SW( aout_instance_t * p_aout, aout_filter_t * p_filter,
-                          aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
+                             aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
 {
     VLC_UNUSED(p_aout);
     int i = p_in_buf->i_nb_samples * aout_FormatNbChannels( &p_filter->input );
@@ -551,11 +589,11 @@ static void Do_S16ToFL32_SW( aout_instance_t * p_aout, aout_filter_t * p_filter,
 #endif
 
     p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
-    p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 2;
+    p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 4 / 2;
 }
 
 static void Do_S24ToFL32_SW( aout_instance_t * p_aout, aout_filter_t * p_filter,
-                           aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
+                             aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
 {
     VLC_UNUSED(p_aout);
     int i = p_in_buf->i_nb_samples * aout_FormatNbChannels( &p_filter->input );
@@ -586,6 +624,26 @@ static void Do_S24ToFL32_SW( aout_instance_t * p_aout, aout_filter_t * p_filter,
     p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 4 / 3;
 }
 
+static void Do_S32ToFL32_SW( aout_instance_t * p_aout, aout_filter_t * p_filter,
+                             aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
+{
+    VLC_UNUSED(p_aout);
+    int i = p_in_buf->i_nb_samples * aout_FormatNbChannels( &p_filter->input );
+
+    /* We start from the end because b_in_place is true */
+    int32_t * p_in = (int32_t *)p_in_buf->p_buffer + i - 1;
+    float * p_out = (float *)p_out_buf->p_buffer + i - 1;
+
+    while( i-- )
+    {
+        *p_out-- = (float)*p_in-- / 2147483648.0;
+    }
+
+    p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
+    p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 4 / 4;
+}
+
+
 /*****************************************************************************
  * S8 To FL32
  *****************************************************************************/




More information about the vlc-devel mailing list