aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pcm.c
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2007-11-25 16:32:47 +0000
committerAurelien Jacobs <aurel@gnuage.org>2007-11-25 16:32:47 +0000
commit725d86bfd52fdecb4d24fc6c62201064071f4c82 (patch)
treedb396edbc420ae29b15b217489af047727d7bc3c /libavcodec/pcm.c
parent4d4f59d750b5b65cb37bc2242355ea3e41d7667c (diff)
downloadffmpeg-725d86bfd52fdecb4d24fc6c62201064071f4c82.tar.gz
add pcm_s16le_planar support for electronicarts files
Originally committed as revision 11092 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/pcm.c')
-rw-r--r--libavcodec/pcm.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index d070628a04..88c39208f7 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -28,6 +28,8 @@
#include "bitstream.h" // for ff_reverse
#include "bytestream.h"
+#define MAX_CHANNELS 64
+
/* from g711.c by SUN microsystems (unrestricted use) */
#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
@@ -374,15 +376,15 @@ static int pcm_decode_frame(AVCodecContext *avctx,
uint8_t *buf, int buf_size)
{
PCMDecode *s = avctx->priv_data;
- int n;
+ int c, n;
short *samples;
- uint8_t *src;
+ uint8_t *src, *src2[MAX_CHANNELS];
samples = data;
src = buf;
n= av_get_bits_per_sample(avctx->codec_id)/8;
- if(n && buf_size % n){
+ if((n && buf_size % n) || avctx->channels > MAX_CHANNELS){
av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n");
return -1;
}
@@ -390,6 +392,10 @@ static int pcm_decode_frame(AVCodecContext *avctx,
buf_size= FFMIN(buf_size, *data_size/2);
*data_size=0;
+ n = buf_size/avctx->channels;
+ for(c=0;c<avctx->channels;c++)
+ src2[c] = &src[c*n];
+
switch(avctx->codec->id) {
case CODEC_ID_PCM_S32LE:
decode_to16(4, 1, 0, &src, &samples, buf_size);
@@ -430,6 +436,12 @@ static int pcm_decode_frame(AVCodecContext *avctx,
*samples++ = bytestream_get_le16(&src);
}
break;
+ case CODEC_ID_PCM_S16LE_PLANAR:
+ for(n>>=1;n>0;n--)
+ for(c=0;c<avctx->channels;c++)
+ *samples++ = bytestream_get_le16(&src2[c]);
+ src = src2[avctx->channels-1];
+ break;
case CODEC_ID_PCM_S16BE:
n = buf_size >> 1;
for(;n>0;n--) {
@@ -528,6 +540,7 @@ PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud);
PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
+PCM_DECODER(CODEC_ID_PCM_S16LE_PLANAR, pcm_s16le_planar);
PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);