[vlc-commits] mad: decode to FL32 (as in existing VLC releases)

Rémi Denis-Courmont git at videolan.org
Fri Dec 21 19:35:45 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Dec 21 20:23:14 2012 +0200| [69aa24b519f682bd43d628e1ab7ca9c960a6c7d9] | committer: Rémi Denis-Courmont

mad: decode to FL32 (as in existing VLC releases)

Apparently, mad generates sample values outside the [-1,+1] range, so
FL32 seems to be the most reasonable output format.

(On systems without hardware FPU, I would recommend disabling mad, and
using libavcodec for MPGA decoding.)

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

 modules/audio_filter/converter/mpgatofixed32.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/modules/audio_filter/converter/mpgatofixed32.c b/modules/audio_filter/converter/mpgatofixed32.c
index 3cd7180..6e6bece 100644
--- a/modules/audio_filter/converter/mpgatofixed32.c
+++ b/modules/audio_filter/converter/mpgatofixed32.c
@@ -87,7 +87,7 @@ static void DoWork( filter_t * p_filter,
     filter_sys_t *p_sys = p_filter->p_sys;
 
     p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
-    p_out_buf->i_buffer = p_in_buf->i_nb_samples * sizeof(vlc_fixed_t) *
+    p_out_buf->i_buffer = p_in_buf->i_nb_samples * sizeof(float) *
                                aout_FormatNbChannels( &p_filter->fmt_out.audio );
 
     /* Do the actual decoding now. */
@@ -118,7 +118,7 @@ static void DoWork( filter_t * p_filter,
     unsigned int i_samples = p_pcm->length;
     mad_fixed_t const * p_left = p_pcm->samples[0];
     mad_fixed_t const * p_right = p_pcm->samples[1];
-    mad_fixed_t * p_samples = (mad_fixed_t *)p_out_buf->p_buffer;
+    float *p_samples = (float *)p_out_buf->p_buffer;
 
     assert( i_samples == p_out_buf->i_nb_samples );
     /* Interleave and keep buffers in mad_fixed_t format */
@@ -126,14 +126,23 @@ static void DoWork( filter_t * p_filter,
     {
         while ( i_samples-- )
         {
-            *p_samples++ = *p_left++;
-            *p_samples++ = *p_right++;
+            //assert( *p_left < MAD_F_ONE );
+            //assert( *p_left >= -MAD_F_ONE );
+            //assert( *p_right < MAD_F_ONE );
+            //assert( *p_right >= -MAD_F_ONE );
+            *p_samples++ = (float)*p_left++ / (float)MAD_F_ONE;
+            *p_samples++ = (float)*p_right++ / (float)MAD_F_ONE;
         }
     }
     else
     {
         assert( p_pcm->channels == 1 );
-        memcpy( p_samples, p_left, i_samples * sizeof(mad_fixed_t) );
+        while ( i_samples-- )
+        {
+            //assert( *p_left < MAD_F_ONE );
+            //assert( *p_left >= -MAD_F_ONE );
+            *p_samples++ = (float)*p_left++ / (float)MAD_F_ONE;
+        }
     }
 }
 
@@ -149,7 +158,7 @@ static int OpenFilter( vlc_object_t *p_this )
         p_filter->fmt_in.audio.i_format != VLC_FOURCC('m','p','g','3') )
         return VLC_EGENERIC;
 
-    if( p_filter->fmt_out.audio.i_format != VLC_CODEC_FI32 )
+    if( p_filter->fmt_out.audio.i_format != VLC_CODEC_FL32 )
         return VLC_EGENERIC;
 
     if( !AOUT_FMTS_SIMILAR( &p_filter->fmt_in.audio, &p_filter->fmt_out.audio ) )



More information about the vlc-commits mailing list