Mercurial > libavformat.hg
changeset 1158:51d3928ab00d libavformat
av_get_bits_per_sample and due simplifications
author | bcoudurier |
---|---|
date | Fri, 07 Jul 2006 17:50:09 +0000 |
parents | 257e22500af0 |
children | 712f2acca29a |
files | movenc.c utils.c |
diffstat | 2 files changed, 6 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/movenc.c Fri Jul 07 09:43:46 2006 +0000 +++ b/movenc.c Fri Jul 07 17:50:09 2006 +0000 @@ -1463,27 +1463,7 @@ }else if(st->codec->codec_type == CODEC_TYPE_AUDIO){ track->tag = mov_find_audio_codec_tag(s, track); av_set_pts_info(st, 64, 1, st->codec->sample_rate); - - switch (st->codec->codec_id) { - case CODEC_ID_PCM_MULAW: - case CODEC_ID_PCM_ALAW: - track->sampleSize = 1 * st->codec->channels; - break; - case CODEC_ID_PCM_S16BE: - case CODEC_ID_PCM_S16LE: - track->sampleSize = 2 * st->codec->channels; - break; - case CODEC_ID_PCM_S24BE: - case CODEC_ID_PCM_S24LE: - track->sampleSize = 3 * st->codec->channels; - break; - case CODEC_ID_PCM_S32BE: - case CODEC_ID_PCM_S32LE: - track->sampleSize = 4 * st->codec->channels; - break; - default: - track->sampleSize = 0; - } + track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels; } track->language = ff_mov_iso639_to_lang(st->language, mov->mode != MODE_MOV); track->mode = mov->mode;
--- a/utils.c Fri Jul 07 09:43:46 2006 +0000 +++ b/utils.c Fri Jul 07 17:50:09 2006 +0000 @@ -653,48 +653,17 @@ int frame_size; if (enc->frame_size <= 1) { - /* specific hack for pcm codecs because no frame size is - provided */ - switch(enc->codec_id) { - case CODEC_ID_PCM_S32LE: - case CODEC_ID_PCM_S32BE: - case CODEC_ID_PCM_U32LE: - case CODEC_ID_PCM_U32BE: - if (enc->channels == 0) - return -1; - frame_size = size / (4 * enc->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: + int bits_per_sample = av_get_bits_per_sample(enc->codec_id); + + if (bits_per_sample) { if (enc->channels == 0) return -1; - frame_size = size / (3 * enc->channels); - break; - case CODEC_ID_PCM_S16LE: - case CODEC_ID_PCM_S16BE: - case CODEC_ID_PCM_U16LE: - case CODEC_ID_PCM_U16BE: - if (enc->channels == 0) - return -1; - frame_size = size / (2 * enc->channels); - break; - case CODEC_ID_PCM_S8: - case CODEC_ID_PCM_U8: - case CODEC_ID_PCM_MULAW: - case CODEC_ID_PCM_ALAW: - if (enc->channels == 0) - return -1; - frame_size = size / (enc->channels); - break; - default: + frame_size = size / ((bits_per_sample >> 3) * enc->channels); + } else { /* used for example by ADPCM codecs */ if (enc->bit_rate == 0) return -1; frame_size = (size * 8 * enc->sample_rate) / enc->bit_rate; - break; } } else { frame_size = enc->frame_size;