Mercurial > libavformat.hg
changeset 1399:5a3003271ad8 libavformat
simplify pcm read seek, use av_get_bits_per_sample
author | bcoudurier |
---|---|
date | Wed, 18 Oct 2006 11:57:24 +0000 |
parents | 303e9fb547c7 |
children | cb3a850b9971 |
files | raw.c |
diffstat | 1 files changed, 5 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/raw.c Tue Oct 17 17:44:06 2006 +0000 +++ b/raw.c Wed Oct 18 11:57:24 2006 +0000 @@ -183,26 +183,11 @@ int64_t pos; st = s->streams[0]; - switch(st->codec->codec_id) { - case CODEC_ID_PCM_S16LE: - case CODEC_ID_PCM_S16BE: - case CODEC_ID_PCM_U16LE: - case CODEC_ID_PCM_U16BE: - block_align = 2 * st->codec->channels; - byte_rate = block_align * st->codec->sample_rate; - break; - case CODEC_ID_PCM_S8: - case CODEC_ID_PCM_U8: - case CODEC_ID_PCM_MULAW: - case CODEC_ID_PCM_ALAW: - block_align = st->codec->channels; - byte_rate = block_align * st->codec->sample_rate; - break; - default: - block_align = st->codec->block_align; - byte_rate = st->codec->bit_rate / 8; - break; - } + + block_align = st->codec->block_align ? st->codec->block_align : + (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3; + byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 : + block_align * st->codec->sample_rate; if (block_align <= 0 || byte_rate <= 0) return -1;