Used vlc_fourcc_GetCodecAudio when applicable.
authorLaurent Aimar <fenrir@videolan.org>
Thu, 14 May 2009 20:54:50 +0000 (22:54 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Fri, 15 May 2009 20:05:37 +0000 (22:05 +0200)
modules/codec/araw.c
modules/packetizer/copy.c

index d59b417..4196a9c 100644 (file)
@@ -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;
index e2379ab..8207b60 100644 (file)
@@ -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) );