summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-11-27 14:52:38 -0500
committerJustin Ruggles <justin.ruggles@gmail.com>2012-11-28 11:18:50 -0500
commit261e9348ef377efc8672c6f8ade974cee7db8e49 (patch)
treeff98f739e44a47e958e029c54026725b0f610cb5 /libavformat/utils.c
parentbfe5454cd238b16e7977085f880205229103eccb (diff)
lavf: add a common function for selecting a pcm codec from parameters
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index fc8b770a85..481760b5ad 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2135,6 +2135,36 @@ enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
return AV_CODEC_ID_NONE;
}
+enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags)
+{
+ if (flt) {
+ switch (bps) {
+ case 32: return be ? AV_CODEC_ID_PCM_F32BE : AV_CODEC_ID_PCM_F32LE;
+ case 64: return be ? AV_CODEC_ID_PCM_F64BE : AV_CODEC_ID_PCM_F64LE;
+ default: return AV_CODEC_ID_NONE;
+ }
+ } else {
+ bps >>= 3;
+ if (sflags & (1 << (bps - 1))) {
+ switch (bps) {
+ case 1: return AV_CODEC_ID_PCM_S8;
+ case 2: return be ? AV_CODEC_ID_PCM_S16BE : AV_CODEC_ID_PCM_S16LE;
+ case 3: return be ? AV_CODEC_ID_PCM_S24BE : AV_CODEC_ID_PCM_S24LE;
+ case 4: return be ? AV_CODEC_ID_PCM_S32BE : AV_CODEC_ID_PCM_S32LE;
+ default: return AV_CODEC_ID_NONE;
+ }
+ } else {
+ switch (bps) {
+ case 1: return AV_CODEC_ID_PCM_U8;
+ case 2: return be ? AV_CODEC_ID_PCM_U16BE : AV_CODEC_ID_PCM_U16LE;
+ case 3: return be ? AV_CODEC_ID_PCM_U24BE : AV_CODEC_ID_PCM_U24LE;
+ case 4: return be ? AV_CODEC_ID_PCM_U32BE : AV_CODEC_ID_PCM_U32LE;
+ default: return AV_CODEC_ID_NONE;
+ }
+ }
+ }
+}
+
unsigned int av_codec_get_tag(const AVCodecTag * const *tags, enum AVCodecID id)
{
int i;