aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Härdin <tomas.hardin@codemill.se>2010-10-01 11:08:19 +0000
committerTomas Härdin <tomas.hardin@codemill.se>2010-10-01 11:08:19 +0000
commitfbeabfca2f648bd83fa1969c3346d288a158d857 (patch)
tree1f172f3dcdb3ef5441f64f3a5ea91d3a0f11e952
parentc619572a7b70220e470a22165d83bda223eedc7a (diff)
downloadffmpeg-fbeabfca2f648bd83fa1969c3346d288a158d857.tar.gz
Add pcm_lxf, a decoder for the 20-bit planar PCM format used in LXF
Originally committed as revision 25280 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/allcodecs.c1
-rw-r--r--libavcodec/avcodec.h5
-rw-r--r--libavcodec/pcm.c26
3 files changed, 29 insertions, 3 deletions
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d499f25fd6..89614ab7d7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -283,6 +283,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (PCM_F32LE, pcm_f32le);
REGISTER_ENCDEC (PCM_F64BE, pcm_f64be);
REGISTER_ENCDEC (PCM_F64LE, pcm_f64le);
+ REGISTER_DECODER (PCM_LXF, pcm_lxf);
REGISTER_ENCDEC (PCM_MULAW, pcm_mulaw);
REGISTER_ENCDEC (PCM_S8, pcm_s8);
REGISTER_ENCDEC (PCM_S16BE, pcm_s16be);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 2ab5ed966b..eee56351f5 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -31,8 +31,8 @@
#include "libavutil/cpu.h"
#define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR 91
-#define LIBAVCODEC_VERSION_MICRO 1
+#define LIBAVCODEC_VERSION_MINOR 92
+#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
@@ -276,6 +276,7 @@ enum CodecID {
CODEC_ID_PCM_F64BE,
CODEC_ID_PCM_F64LE,
CODEC_ID_PCM_BLURAY,
+ CODEC_ID_PCM_LXF,
/* various ADPCM codecs */
CODEC_ID_ADPCM_IMA_QT= 0x11000,
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index e51b5f9dfa..51dbfd6abd 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -259,7 +259,7 @@ static int pcm_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
PCMDecode *s = avctx->priv_data;
- int sample_size, c, n;
+ int sample_size, c, n, i;
short *samples;
const uint8_t *src, *src8, *src2[MAX_CHANNELS];
uint8_t *dstu8;
@@ -288,6 +288,9 @@ static int pcm_decode_frame(AVCodecContext *avctx,
if (CODEC_ID_PCM_DVD == avctx->codec_id)
/* 2 samples are interleaved per block in PCM_DVD */
sample_size = avctx->bits_per_coded_sample * 2 / 8;
+ else if (avctx->codec_id == CODEC_ID_PCM_LXF)
+ /* we process 40-bit blocks per channel for LXF */
+ sample_size = 5;
n = avctx->channels * sample_size;
@@ -436,6 +439,26 @@ static int pcm_decode_frame(AVCodecContext *avctx,
}
samples = (short *) dst_int32_t;
break;
+ case CODEC_ID_PCM_LXF:
+ dst_int32_t = data;
+ n /= avctx->channels;
+ //unpack and de-planerize
+ for (i = 0; i < n; i++) {
+ for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) {
+ //extract low 20 bits and expand to 32 bits
+ *dst_int32_t++ = (src8[2] << 28) | (src8[1] << 20) | (src8[0] << 12) |
+ ((src8[2] & 0xF) << 8) | src8[1];
+ }
+
+ for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) {
+ //extract high 20 bits and expand to 32 bits
+ *dst_int32_t++ = (src8[4] << 24) | (src8[3] << 16) |
+ ((src8[2] & 0xF0) << 8) | (src8[4] << 4) | (src8[3] >> 4);
+ }
+ }
+ src += n * avctx->channels * 5;
+ samples = (short *) dst_int32_t;
+ break;
default:
return -1;
}
@@ -485,6 +508,7 @@ PCM_CODEC (CODEC_ID_PCM_F32BE, SAMPLE_FMT_FLT, pcm_f32be, "PCM 32-bit floating
PCM_CODEC (CODEC_ID_PCM_F32LE, SAMPLE_FMT_FLT, pcm_f32le, "PCM 32-bit floating point little-endian");
PCM_CODEC (CODEC_ID_PCM_F64BE, SAMPLE_FMT_DBL, pcm_f64be, "PCM 64-bit floating point big-endian");
PCM_CODEC (CODEC_ID_PCM_F64LE, SAMPLE_FMT_DBL, pcm_f64le, "PCM 64-bit floating point little-endian");
+PCM_DECODER(CODEC_ID_PCM_LXF, SAMPLE_FMT_S32, pcm_lxf, "PCM signed 20-bit little-endian planar");
PCM_CODEC (CODEC_ID_PCM_MULAW, SAMPLE_FMT_S16, pcm_mulaw, "PCM mu-law");
PCM_CODEC (CODEC_ID_PCM_S8, SAMPLE_FMT_U8, pcm_s8, "PCM signed 8-bit");
PCM_CODEC (CODEC_ID_PCM_S16BE, SAMPLE_FMT_S16, pcm_s16be, "PCM signed 16-bit big-endian");