diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2005-09-02 19:16:48 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2005-09-02 19:16:48 +0000 |
commit | b461b3bc4a14fe86aba4ed8e9adf30ab262896a2 (patch) | |
tree | 6ebc879c0917029608f33b2a224cb9a85c7ed3b4 /libavformat | |
parent | 16beae15f3b610dfaa1d39d1effa25816c4185ae (diff) |
Support de-/encoding of 24 and 32 bit PCM (from and to internal 16 bit).
Originally committed as revision 4548 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/utils.c | 17 | ||||
-rw-r--r-- | libavformat/wav.c | 12 |
2 files changed, 29 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index eb19eea527..7dede05b49 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -643,6 +643,23 @@ static int get_audio_frame_size(AVCodecContext *enc, int size) /* 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: diff --git a/libavformat/wav.c b/libavformat/wav.c index 6557c0a962..e566f5ee6b 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -25,6 +25,8 @@ const CodecTag codec_wav_tags[] = { { 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 @@ int put_wav_header(ByteIOContext *pb, AVCodecContext *enc) 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 @@ int put_wav_header(ByteIOContext *pb, AVCodecContext *enc) } 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 @@ int wav_codec_get_id(unsigned int tag, int bps) /* 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; } |