diff options
author | Peter Ross <pross@xvid.org> | 2008-08-04 07:49:50 +0000 |
---|---|---|
committer | Peter Ross <pross@xvid.org> | 2008-08-04 07:49:50 +0000 |
commit | cc0b61292af652bab0b7870b6293bf827bf42e7a (patch) | |
tree | 1857180265797496eedf84b4c55ba8a812e6190e /libavcodec/pcm.c | |
parent | 0fd7e57e7d284176839bff612cd1af3cadc3fe86 (diff) | |
download | ffmpeg-cc0b61292af652bab0b7870b6293bf827bf42e7a.tar.gz |
Simplify PCM codec; replace switch() statements with av_get_bits_per_sample().
Originally committed as revision 14534 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/pcm.c')
-rw-r--r-- | libavcodec/pcm.c | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index e86532437c..d8b013bcb0 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -121,37 +121,7 @@ static av_cold int pcm_encode_init(AVCodecContext *avctx) break; } - switch(avctx->codec->id) { - case CODEC_ID_PCM_S32LE: - case CODEC_ID_PCM_S32BE: - case CODEC_ID_PCM_U32LE: - case CODEC_ID_PCM_U32BE: - case CODEC_ID_PCM_F32BE: - avctx->block_align = 4 * avctx->channels; - break; - case CODEC_ID_PCM_S24LE: - case CODEC_ID_PCM_S24BE: - case CODEC_ID_PCM_U24LE: - case CODEC_ID_PCM_U24BE: - case CODEC_ID_PCM_S24DAUD: - avctx->block_align = 3 * avctx->channels; - break; - case CODEC_ID_PCM_S16LE: - case CODEC_ID_PCM_S16BE: - case CODEC_ID_PCM_U16LE: - case CODEC_ID_PCM_U16BE: - avctx->block_align = 2 * avctx->channels; - break; - case CODEC_ID_PCM_S8: - case CODEC_ID_PCM_U8: - case CODEC_ID_PCM_MULAW: - case CODEC_ID_PCM_ALAW: - avctx->block_align = avctx->channels; - break; - default: - break; - } - + avctx->block_align = avctx->channels * av_get_bits_per_sample(avctx->codec->id)/8; avctx->coded_frame= avcodec_alloc_frame(); avctx->coded_frame->key_frame= 1; @@ -197,31 +167,7 @@ static int pcm_encode_frame(AVCodecContext *avctx, short *samples; unsigned char *dst; - switch(avctx->codec->id) { - case CODEC_ID_PCM_S32LE: - case CODEC_ID_PCM_S32BE: - case CODEC_ID_PCM_U32LE: - case CODEC_ID_PCM_U32BE: - case CODEC_ID_PCM_F32BE: - sample_size = 4; - break; - case CODEC_ID_PCM_S24LE: - case CODEC_ID_PCM_S24BE: - case CODEC_ID_PCM_U24LE: - case CODEC_ID_PCM_U24BE: - case CODEC_ID_PCM_S24DAUD: - sample_size = 3; - break; - case CODEC_ID_PCM_S16LE: - case CODEC_ID_PCM_S16BE: - case CODEC_ID_PCM_U16LE: - case CODEC_ID_PCM_U16BE: - sample_size = 2; - break; - default: - sample_size = 1; - break; - } + sample_size = av_get_bits_per_sample(avctx->codec->id)/8; n = buf_size / sample_size; samples = data; dst = frame; |