changeset 3433:e1906b2f1daf libavcodec

av_get_bits_per_sample and due simplifications
author bcoudurier
date Fri, 07 Jul 2006 17:50:09 +0000
parents ab49baf4adad
children d42ab8824434
files avcodec.h utils.c
diffstat 2 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/avcodec.h	Fri Jul 07 11:08:58 2006 +0000
+++ b/avcodec.h	Fri Jul 07 17:50:09 2006 +0000
@@ -2499,6 +2499,10 @@
  */
 char av_get_pict_type_char(int pict_type);
 
+/**
+ * returns codec bits per sample
+ */
+int av_get_bits_per_sample(enum CodecID codec_id);
 
 /* frame parsing */
 typedef struct AVCodecParserContext {
--- a/utils.c	Fri Jul 07 11:08:58 2006 +0000
+++ b/utils.c	Fri Jul 07 17:50:09 2006 +0000
@@ -1304,6 +1304,34 @@
     }
 }
 
+int av_get_bits_per_sample(enum CodecID codec_id){
+    switch(codec_id){
+    case CODEC_ID_PCM_ALAW:
+    case CODEC_ID_PCM_MULAW:
+    case CODEC_ID_PCM_S8:
+    case CODEC_ID_PCM_U8:
+        return 8;
+    case CODEC_ID_PCM_S16BE:
+    case CODEC_ID_PCM_S16LE:
+    case CODEC_ID_PCM_U16BE:
+    case CODEC_ID_PCM_U16LE:
+        return 16;
+    case CODEC_ID_PCM_S24DAUD:
+    case CODEC_ID_PCM_S24BE:
+    case CODEC_ID_PCM_S24LE:
+    case CODEC_ID_PCM_U24BE:
+    case CODEC_ID_PCM_U24LE:
+        return 24;
+    case CODEC_ID_PCM_S32BE:
+    case CODEC_ID_PCM_S32LE:
+    case CODEC_ID_PCM_U32BE:
+    case CODEC_ID_PCM_U32LE:
+        return 32;
+    default:
+        return 0;
+    }
+}
+
 /* av_log API */
 
 static int av_log_level = AV_LOG_INFO;