[vlc-devel] commit: Added a small vlc_fourcc_GetCodecAudio helper. (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:46:02 2009 +0200| [4de16278bbc64316f786cbed5fa1321b91c731f0] | committer: Laurent Aimar 

Added a small vlc_fourcc_GetCodecAudio helper.

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

 include/vlc_fourcc.h |    9 ++++++
 src/libvlccore.sym   |    1 +
 src/misc/fourcc.c    |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/include/vlc_fourcc.h b/include/vlc_fourcc.h
index 3a1e8a6..0fe0c2d 100644
--- a/include/vlc_fourcc.h
+++ b/include/vlc_fourcc.h
@@ -334,6 +334,15 @@ VLC_EXPORT( vlc_fourcc_t, vlc_fourcc_GetCodec, ( int i_cat, vlc_fourcc_t i_fourc
 VLC_EXPORT( vlc_fourcc_t, vlc_fourcc_GetCodecFromString, ( int i_cat, const char * ) );
 
 /**
+ * It convert the gives fourcc to an audio codec when possible.
+ *
+ * The fourcc converted are aflt, araw/pcm , twos, sowt. When an incompatible i_bits
+ * is detected, 0 is returned.
+ * The other fourcc goes through vlc_fourcc_GetCodec and i_bits is not checked.
+ */
+VLC_EXPORT( vlc_fourcc_t, vlc_fourcc_GetCodecAudio, ( vlc_fourcc_t i_fourcc, int i_bits ) );
+
+/**
  * It returns the description of the given fourcc or NULL if not found.
  *
  * You may use UNKNOWN_ES for the ES category if you don't have the information.
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 8adf4fb..e2216fc 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -453,6 +453,7 @@ vlc_event_send
 __vlc_execve
 vlc_fastmem_register
 vlc_fourcc_GetCodec
+vlc_fourcc_GetCodecAudio
 vlc_fourcc_GetCodecFromString
 vlc_fourcc_GetDescription
 vlc_freeaddrinfo
diff --git a/src/misc/fourcc.c b/src/misc/fourcc.c
index 2690bc8..8a6121b 100644
--- a/src/misc/fourcc.c
+++ b/src/misc/fourcc.c
@@ -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 )
 {




More information about the vlc-devel mailing list