summaryrefslogtreecommitdiff
path: root/libavcodec/pcm.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2012-11-16 16:00:04 +0000
committerPaul B Mahol <onemda@gmail.com>2012-11-17 19:09:43 +0000
commit467dfd5dfae7cc435a2b2e7cf012a0de2fea5848 (patch)
treeaa7581531324f864a14f2f8fd4df1a64b9004913 /libavcodec/pcm.c
parentee2d6fbc92e6d55dda319fa56234c5be9a476728 (diff)
PCM signed 24-bit/32-bit little-endian planar decoder
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/pcm.c')
-rw-r--r--libavcodec/pcm.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 70fa63823e..f024775aa9 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -252,6 +252,19 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
dst += size / 8; \
}
+#define DECODE_PLANAR(size, endian, src, dst, n, shift, offset) { \
+ int i; \
+ n /= avctx->channels; \
+ for (c = 0; c < avctx->channels; c++) { \
+ dst = s->frame.extended_data[c]; \
+ for (i = n; i > 0; i--) { \
+ uint ## size ## _t v = bytestream_get_ ## endian(&src); \
+ AV_WN ## size ## A(dst, (v - offset) << shift); \
+ dst += size / 8; \
+ } \
+ } \
+}
+
static int pcm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
@@ -344,18 +357,14 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
}
break;
case AV_CODEC_ID_PCM_S16LE_PLANAR:
- {
- int i;
- n /= avctx->channels;
- for (c = 0; c < avctx->channels; c++) {
- samples = s->frame.extended_data[c];
- for (i = n; i > 0; i--) {
- AV_WN16A(samples, bytestream_get_le16(&src));
- samples += 2;
- }
- }
+ DECODE_PLANAR(16, le16, src, samples, n, 0, 0);
+ break;
+ case AV_CODEC_ID_PCM_S24LE_PLANAR:
+ DECODE_PLANAR(32, le24, src, samples, n, 8, 0);
+ break;
+ case AV_CODEC_ID_PCM_S32LE_PLANAR:
+ DECODE_PLANAR(32, le32, src, samples, n, 0, 0);
break;
- }
case AV_CODEC_ID_PCM_U16LE:
DECODE(16, le16, src, samples, n, 0, 0x8000)
break;
@@ -544,8 +553,10 @@ PCM_DECODER(PCM_S16LE_PLANAR, AV_SAMPLE_FMT_S16P,pcm_s16le_planar, "PCM signed 1
PCM_CODEC (PCM_S24BE, AV_SAMPLE_FMT_S32, pcm_s24be, "PCM signed 24-bit big-endian");
PCM_CODEC (PCM_S24DAUD, AV_SAMPLE_FMT_S16, pcm_s24daud, "PCM D-Cinema audio signed 24-bit");
PCM_CODEC (PCM_S24LE, AV_SAMPLE_FMT_S32, pcm_s24le, "PCM signed 24-bit little-endian");
+PCM_DECODER(PCM_S24LE_PLANAR, AV_SAMPLE_FMT_S32P,pcm_s24le_planar, "PCM signed 24-bit little-endian planar");
PCM_CODEC (PCM_S32BE, AV_SAMPLE_FMT_S32, pcm_s32be, "PCM signed 32-bit big-endian");
PCM_CODEC (PCM_S32LE, AV_SAMPLE_FMT_S32, pcm_s32le, "PCM signed 32-bit little-endian");
+PCM_DECODER(PCM_S32LE_PLANAR, AV_SAMPLE_FMT_S32P,pcm_s32le_planar, "PCM signed 32-bit little-endian planar");
PCM_CODEC (PCM_U8, AV_SAMPLE_FMT_U8, pcm_u8, "PCM unsigned 8-bit");
PCM_CODEC (PCM_U16BE, AV_SAMPLE_FMT_S16, pcm_u16be, "PCM unsigned 16-bit big-endian");
PCM_CODEC (PCM_U16LE, AV_SAMPLE_FMT_S16, pcm_u16le, "PCM unsigned 16-bit little-endian");