Mercurial > libavformat.hg
changeset 846:fd1c2109505e libavformat
Support de-/encoding of 24 and 32 bit PCM (from and to internal 16 bit).
author | reimar |
---|---|
date | Fri, 02 Sep 2005 19:16:48 +0000 |
parents | e4e8c395d8e9 |
children | f5a33919749a |
files | utils.c wav.c |
diffstat | 2 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/utils.c Fri Sep 02 08:30:26 2005 +0000 +++ b/utils.c Fri Sep 02 19:16:48 2005 +0000 @@ -643,6 +643,23 @@ /* 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: + 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:
--- a/wav.c Fri Sep 02 08:30:26 2005 +0000 +++ b/wav.c Fri Sep 02 19:16:48 2005 +0000 @@ -25,6 +25,8 @@ { CODEC_ID_AC3, 0x2000 }, { CODEC_ID_PCM_S16LE, 0x01 }, { CODEC_ID_PCM_U8, 0x01 }, /* must come after s16le in this list */ + { CODEC_ID_PCM_S24LE, 0x01 }, + { CODEC_ID_PCM_S32LE, 0x01 }, { CODEC_ID_PCM_ALAW, 0x06 }, { CODEC_ID_PCM_MULAW, 0x07 }, { CODEC_ID_ADPCM_MS, 0x02 }, @@ -68,6 +70,10 @@ bps = 0; } else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV || enc->codec_id == CODEC_ID_ADPCM_MS || enc->codec_id == CODEC_ID_ADPCM_G726 || enc->codec_id == CODEC_ID_ADPCM_YAMAHA) { // bps = 4; + } else if (enc->codec_id == CODEC_ID_PCM_S24LE) { + bps = 24; + } else if (enc->codec_id == CODEC_ID_PCM_S32LE) { + bps = 32; } else { bps = 16; } @@ -82,6 +88,8 @@ } else blkalign = enc->channels*bps >> 3; if (enc->codec_id == CODEC_ID_PCM_U8 || + enc->codec_id == CODEC_ID_PCM_S24LE || + enc->codec_id == CODEC_ID_PCM_S32LE || enc->codec_id == CODEC_ID_PCM_S16LE) { bytespersec = enc->sample_rate * blkalign; } else { @@ -179,6 +187,10 @@ /* handle specific u8 codec */ if (id == CODEC_ID_PCM_S16LE && bps == 8) id = CODEC_ID_PCM_U8; + if (id == CODEC_ID_PCM_S16LE && bps == 24) + id = CODEC_ID_PCM_S24LE; + if (id == CODEC_ID_PCM_S16LE && bps == 32) + id = CODEC_ID_PCM_S32LE; return id; }