[vlc-devel] commit: Used vlc_fourcc_GetCodecAudio when applicable. (Laurent Aimar )

git version control git at videolan.org
Fri May 15 22:07:14 CEST 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Thu May 14 22:54:50 2009 +0200| [138f098d36b5d976cf1ea596b2c533b4cce0dd0b] | committer: Laurent Aimar 

Used vlc_fourcc_GetCodecAudio when applicable.

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

 modules/codec/araw.c      |   91 +++++---------------------------------------
 modules/packetizer/copy.c |   73 ++++-------------------------------
 2 files changed, 20 insertions(+), 144 deletions(-)

diff --git a/modules/codec/araw.c b/modules/codec/araw.c
index d59b417..4196a9c 100644
--- a/modules/codec/araw.c
+++ b/modules/codec/araw.c
@@ -266,85 +266,6 @@ static int DecoderOpen( vlc_object_t *p_this )
         p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;
         p_dec->fmt_in.audio.i_bitspersample = 8;
     }
-    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'a', 'f', 'l', 't' ) )
-    {
-        switch( ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8 )
-        {
-        case 4:
-            p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
-            break;
-        case 8:
-            p_dec->fmt_out.i_codec = VLC_CODEC_FL64;
-            break;
-        default:
-            msg_Err( p_dec, "bad parameters(bits/sample)" );
-            return VLC_EGENERIC;
-        }
-    }
-    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'a', 'r', 'a', 'w' ) ||
-             p_dec->fmt_in.i_codec == VLC_FOURCC( 'p', 'c', 'm', ' ' ) )
-    {
-        switch( ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8 )
-        {
-        case 1:
-            p_dec->fmt_out.i_codec = VLC_CODEC_U8;
-            break;
-        case 2:
-            p_dec->fmt_out.i_codec = VLC_CODEC_S16L;
-            break;
-        case 3:
-            p_dec->fmt_out.i_codec = VLC_CODEC_S24L;
-            break;
-        case 4:
-            p_dec->fmt_out.i_codec = VLC_CODEC_S32L;
-            break;
-        default:
-            msg_Err( p_dec, "bad parameters(bits/sample)" );
-            return VLC_EGENERIC;
-        }
-    }
-    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 't', 'w', 'o', 's' ) )
-    {
-        switch( ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8 )
-        {
-        case 1:
-            p_dec->fmt_out.i_codec = VLC_CODEC_S8;
-            break;
-        case 2:
-            p_dec->fmt_out.i_codec = VLC_CODEC_S16B;
-            break;
-        case 3:
-            p_dec->fmt_out.i_codec = VLC_CODEC_S24B;
-            break;
-        case 4:
-            p_dec->fmt_out.i_codec = VLC_CODEC_S32B;
-            break;
-        default:
-            msg_Err( p_dec, "bad parameters(bits/sample)" );
-            return VLC_EGENERIC;
-        }
-    }
-    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 's', 'o', 'w', 't' ) )
-    {
-        switch( ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8 )
-        {
-        case 1:
-            p_dec->fmt_out.i_codec = VLC_CODEC_S8;
-            break;
-        case 2:
-            p_dec->fmt_out.i_codec = VLC_CODEC_S16L;
-            break;
-        case 3:
-            p_dec->fmt_out.i_codec = VLC_CODEC_S24L;
-            break;
-        case 4:
-            p_dec->fmt_out.i_codec = VLC_CODEC_S32L;
-            break;
-        default:
-            msg_Err( p_dec, "bad parameters(bits/sample)" );
-            return VLC_EGENERIC;
-        }
-    }
     else if( p_dec->fmt_in.i_codec == VLC_CODEC_ALAW )
     {
         p_dec->fmt_out.i_codec = VLC_CODEC_S16N;
@@ -357,7 +278,17 @@ static int DecoderOpen( vlc_object_t *p_this )
         p_sys->p_logtos16  = ulawtos16;
         p_dec->fmt_in.audio.i_bitspersample = 8;
     }
-    else return VLC_EGENERIC;
+    else
+    {
+        p_dec->fmt_out.i_codec =
+            vlc_fourcc_GetCodecAudio( p_dec->fmt_in.i_codec,
+                                      p_dec->fmt_in.audio.i_bitspersample );
+        if( !p_dec->fmt_out.i_codec )
+        {
+            msg_Err( p_dec, "bad parameters(bits/sample)" );
+            return VLC_EGENERIC;
+        }
+    }
 
     /* Set output properties */
     p_dec->fmt_out.i_cat = AUDIO_ES;
diff --git a/modules/packetizer/copy.c b/modules/packetizer/copy.c
index e2379ab..8207b60 100644
--- a/modules/packetizer/copy.c
+++ b/modules/packetizer/copy.c
@@ -87,71 +87,16 @@ static int Open( vlc_object_t *p_this )
     /* Create the output format */
     es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
 
-    /* Fix the value of the fourcc */
-    switch( p_dec->fmt_in.i_codec )
+    /* Fix the value of the fourcc for audio */
+    if( p_dec->fmt_in.i_cat == AUDIO_ES )
     {
-        case VLC_FOURCC( 'a', 'r', 'a', 'w' ):
-            switch( ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8 )
-            {
-                case 1:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_U8;
-                    break;
-                case 2:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_S16L;
-                    break;
-                case 3:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_S24L;
-                    break;
-                case 4:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_S32L;
-                    break;
-                default:
-                    msg_Err( p_dec, "unknown raw audio sample size" );
-                    return VLC_EGENERIC;
-            }
-            break;
-
-        case VLC_FOURCC( 't', 'w', 'o', 's' ):
-            switch( ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8 )
-            {
-                case 1:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_S8;
-                    break;
-                case 2:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_S16B;
-                    break;
-                case 3:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_S24B;
-                    break;
-                case 4:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_S32B;
-                    break;
-                default:
-                    msg_Err( p_dec, "unknown raw audio sample size" );
-                    return VLC_EGENERIC;
-            }
-            break;
-
-        case VLC_FOURCC( 's', 'o', 'w', 't' ):
-            switch( ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8 )
-            {
-                case 1:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_S8;
-                    break;
-                case 2:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_S16L;
-                    break;
-                case 3:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_S24L;
-                    break;
-                case 4:
-                    p_dec->fmt_out.i_codec = VLC_CODEC_S32L;
-                    break;
-                default:
-                    msg_Err( p_dec, "unknown raw audio sample size" );
-                    return VLC_EGENERIC;
-            }
-            break;
+        p_dec->fmt_out.i_codec = vlc_fourcc_GetCodecAudio( p_dec->fmt_in.i_codec,
+                                                           p_dec->fmt_in.audio.i_bitspersample );
+        if( !p_dec->fmt_out.i_codec )
+        {
+            msg_Err( p_dec, "unknown raw audio sample size" );
+            return VLC_EGENERIC;
+        }
     }
 
     p_dec->p_sys = p_sys = malloc( sizeof(*p_sys) );




More information about the vlc-devel mailing list