]> git.sesse.net Git - vlc/blobdiff - src/misc/fourcc.c
Added a small vlc_fourcc_GetCodecAudio helper.
[vlc] / src / misc / fourcc.c
index 2690bc871a7df4bdbbc17194256b47483dbac927..8a6121b5aadd9832b892a3edba55d27eda3b3e71 100644 (file)
@@ -1195,6 +1195,78 @@ vlc_fourcc_t vlc_fourcc_GetCodecFromString( int i_cat, const char *psz_fourcc )
                                             psz_fourcc[2], psz_fourcc[3] ) );
 }
 
+vlc_fourcc_t vlc_fourcc_GetCodecAudio( vlc_fourcc_t i_fourcc, int i_bits )
+{
+    const int i_bytes = ( i_bits + 7 ) / 8;
+
+    if( i_fourcc == VLC_FOURCC( 'a', 'f', 'l', 't' ) )
+    {
+        switch( i_bytes )
+        {
+        case 4:
+            return VLC_CODEC_FL32;
+        case 8:
+            return VLC_CODEC_FL64;
+        default:
+            return 0;
+        }
+    }
+    else if( i_fourcc == VLC_FOURCC( 'a', 'r', 'a', 'w' ) ||
+             i_fourcc == VLC_FOURCC( 'p', 'c', 'm', ' ' ) )
+    {
+        switch( i_bytes )
+        {
+        case 1:
+            return VLC_CODEC_U8;
+        case 2:
+            return VLC_CODEC_S16L;
+        case 3:
+            return VLC_CODEC_S24L;
+            break;
+        case 4:
+            return VLC_CODEC_S32L;
+        default:
+            return 0;
+        }
+    }
+    else if( i_fourcc == VLC_FOURCC( 't', 'w', 'o', 's' ) )
+    {
+        switch( i_bytes )
+        {
+        case 1:
+            return VLC_CODEC_S8;
+        case 2:
+            return VLC_CODEC_S16B;
+        case 3:
+            return VLC_CODEC_S24B;
+        case 4:
+            return VLC_CODEC_S32B;
+        default:
+            return 0;
+        }
+    }
+    else if( i_fourcc == VLC_FOURCC( 's', 'o', 'w', 't' ) )
+    {
+        switch( i_bytes )
+        {
+        case 1:
+            return VLC_CODEC_S8;
+        case 2:
+            return VLC_CODEC_S16L;
+        case 3:
+            return VLC_CODEC_S24L;
+        case 4:
+            return VLC_CODEC_S32L;
+        default:
+            return 0;
+        }
+    }
+    else
+    {
+        return vlc_fourcc_GetCodec( AUDIO_ES, i_fourcc );
+    }
+}
+
 /* */
 const char *vlc_fourcc_GetDescription( int i_cat, vlc_fourcc_t i_fourcc )
 {