# HG changeset patch # User bcoudurier # Date 1152294609 0 # Node ID e1906b2f1daf14ca39b43aaf01c3b1a9414a1e1f # Parent ab49baf4adadee23a72485c79a2240acc8656e1f av_get_bits_per_sample and due simplifications diff -r ab49baf4adad -r e1906b2f1daf avcodec.h --- 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 { diff -r ab49baf4adad -r e1906b2f1daf utils.c --- 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;