changeset 7476:2321e0384521 libavcodec

Simplify PCM codec; use sample_fmts field to set the avctx->sample_fmt field.
author pross
date Mon, 04 Aug 2008 07:47:23 +0000
parents eaf0ebba81d7
children 2f6a2fd238fb
files pcm.c
diffstat 1 files changed, 6 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/pcm.c	Mon Aug 04 07:40:07 2008 +0000
+++ b/pcm.c	Mon Aug 04 07:47:23 2008 +0000
@@ -358,14 +358,7 @@
         break;
     }
 
-    switch(avctx->codec->id) {
-    case CODEC_ID_PCM_F32BE:
-        avctx->sample_fmt = SAMPLE_FMT_FLT;
-        break;
-    default:
-        avctx->sample_fmt = SAMPLE_FMT_S16;
-        break;
-    }
+    avctx->sample_fmt = avctx->codec->sample_fmts[0];
     return 0;
 }
 
@@ -571,7 +564,7 @@
 #endif
 
 #ifdef CONFIG_DECODERS
-#define PCM_DECODER(id,name,long_name_)         \
+#define PCM_DECODER(id,sample_fmt_,name,long_name_)         \
 AVCodec name ## _decoder = {                    \
     #name,                                      \
     CODEC_TYPE_AUDIO,                           \
@@ -581,14 +574,15 @@
     NULL,                                       \
     NULL,                                       \
     pcm_decode_frame,                           \
+    .sample_fmts = (enum SampleFormat[]){sample_fmt_,SAMPLE_FMT_NONE}, \
     .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
 };
 #else
-#define PCM_DECODER(id,name,long_name_)
+#define PCM_DECODER(id,sample_fmt_,name,long_name_)
 #endif
 
 #define PCM_CODEC(id, sample_fmt_, name, long_name_)         \
-    PCM_ENCODER(id,sample_fmt_,name,long_name_) PCM_DECODER(id,name,long_name_)
+    PCM_ENCODER(id,sample_fmt_,name,long_name_) PCM_DECODER(id,sample_fmt_,name,long_name_)
 
 /* Note: Do not forget to add new entries to the Makefile as well. */
 PCM_CODEC  (CODEC_ID_PCM_ALAW,  SAMPLE_FMT_S16, pcm_alaw, "A-law PCM");
@@ -598,7 +592,7 @@
 PCM_CODEC  (CODEC_ID_PCM_S8,    SAMPLE_FMT_S16, pcm_s8, "signed 8-bit PCM");
 PCM_CODEC  (CODEC_ID_PCM_S16BE, SAMPLE_FMT_S16, pcm_s16be, "signed 16-bit big-endian PCM");
 PCM_CODEC  (CODEC_ID_PCM_S16LE, SAMPLE_FMT_S16, pcm_s16le, "signed 16-bit little-endian PCM");
-PCM_DECODER(CODEC_ID_PCM_S16LE_PLANAR, pcm_s16le_planar, "16-bit little-endian planar PCM");
+PCM_DECODER(CODEC_ID_PCM_S16LE_PLANAR, SAMPLE_FMT_S16, pcm_s16le_planar, "16-bit little-endian planar PCM");
 PCM_CODEC  (CODEC_ID_PCM_S24BE, SAMPLE_FMT_S16, pcm_s24be, "signed 24-bit big-endian PCM");
 PCM_CODEC  (CODEC_ID_PCM_S24DAUD, SAMPLE_FMT_S16,  pcm_s24daud, "D-Cinema audio signed 24-bit PCM");
 PCM_CODEC  (CODEC_ID_PCM_S24LE, SAMPLE_FMT_S16, pcm_s24le, "signed 24-bit little-endian PCM");