diff options
author | Nicolas George <nicolas.george@normalesup.org> | 2012-02-16 14:59:55 +0100 |
---|---|---|
committer | Nicolas George <nicolas.george@normalesup.org> | 2012-02-22 11:37:32 +0100 |
commit | 9cbf17e9af80cb450042ebaf5e28692044b574cf (patch) | |
tree | e68e5a8380ef589db67b3502f598fef441fb7236 /libavcodec/utils.c | |
parent | 4217dfe87bde4fe676291e98f6cda79f9df3baf2 (diff) | |
download | ffmpeg-9cbf17e9af80cb450042ebaf5e28692044b574cf.tar.gz |
lavc: introduce av_get_pcm_codec.
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 755186d0b6..7a4e01c833 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1902,6 +1902,27 @@ int av_get_bits_per_sample(enum CodecID codec_id){ } } +enum CodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be) +{ + static const enum CodecID map[AV_SAMPLE_FMT_NB][2] = { + [AV_SAMPLE_FMT_U8 ] = { CODEC_ID_PCM_U8, CODEC_ID_PCM_U8 }, + [AV_SAMPLE_FMT_S16 ] = { CODEC_ID_PCM_S16LE, CODEC_ID_PCM_S16BE }, + [AV_SAMPLE_FMT_S32 ] = { CODEC_ID_PCM_S32LE, CODEC_ID_PCM_S32BE }, + [AV_SAMPLE_FMT_FLT ] = { CODEC_ID_PCM_F32LE, CODEC_ID_PCM_F32BE }, + [AV_SAMPLE_FMT_DBL ] = { CODEC_ID_PCM_F64LE, CODEC_ID_PCM_F64BE }, + [AV_SAMPLE_FMT_U8P ] = { CODEC_ID_PCM_U8, CODEC_ID_PCM_U8 }, + [AV_SAMPLE_FMT_S16P] = { CODEC_ID_PCM_S16LE, CODEC_ID_PCM_S16BE }, + [AV_SAMPLE_FMT_S32P] = { CODEC_ID_PCM_S32LE, CODEC_ID_PCM_S32BE }, + [AV_SAMPLE_FMT_FLTP] = { CODEC_ID_PCM_F32LE, CODEC_ID_PCM_F32BE }, + [AV_SAMPLE_FMT_DBLP] = { CODEC_ID_PCM_F64LE, CODEC_ID_PCM_F64BE }, + }; + if (fmt < 0 || fmt >= AV_SAMPLE_FMT_NB) + return CODEC_ID_NONE; + if (be < 0 || be > 1) + be = AV_NE(1, 0); + return map[fmt][be]; +} + #if !HAVE_THREADS int ff_thread_init(AVCodecContext *s){ return -1; |