History

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

Tomas Härdin committed 16 years ago

Commit fbeabfc1 parent c6195723 files · +29 −3Browse files

Unified · Split

3 files
  1. libavcodec/allcodecs.c +1 −0
  2. libavcodec/avcodec.h +3 −2
  3. libavcodec/pcm.c +25 −1
libavcodec/allcodecs.c+1−0
@@ -283,6 +283,7 @@ void avcodec_register_all(void) · 282 unmodified lines
283283 REGISTER_ENCDEC (PCM_F32LE, pcm_f32le);
284284 REGISTER_ENCDEC (PCM_F64BE, pcm_f64be);
285285 REGISTER_ENCDEC (PCM_F64LE, pcm_f64le);
286+ REGISTER_DECODER (PCM_LXF, pcm_lxf);
286287 REGISTER_ENCDEC (PCM_MULAW, pcm_mulaw);
287288 REGISTER_ENCDEC (PCM_S8, pcm_s8);
288289 REGISTER_ENCDEC (PCM_S16BE, pcm_s16be);
libavcodec/avcodec.h+3−2
@@ -31,8 +31,8 @@ · 30 unmodified lines
3131 #include "libavutil/cpu.h"
3232
3333 #define LIBAVCODEC_VERSION_MAJOR 52
34−#define LIBAVCODEC_VERSION_MINOR 91
35−#define LIBAVCODEC_VERSION_MICRO 1
34+#define LIBAVCODEC_VERSION_MINOR 92
35+#define LIBAVCODEC_VERSION_MICRO 0
3636
3737 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3838 LIBAVCODEC_VERSION_MINOR, \
@@ -276,6 +276,7 @@ enum CodecID { · 237 unmodified lines
276276 CODEC_ID_PCM_F64BE,
277277 CODEC_ID_PCM_F64LE,
278278 CODEC_ID_PCM_BLURAY,
279+ CODEC_ID_PCM_LXF,
279280
280281 /* various ADPCM codecs */
281282 CODEC_ID_ADPCM_IMA_QT= 0x11000,
libavcodec/pcm.c+25−1
@@ -259,7 +259,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 258 unmodified lines
259259 const uint8_t *buf = avpkt->data;
260260 int buf_size = avpkt->size;
261261 PCMDecode *s = avctx->priv_data;
262− int sample_size, c, n;
262+ int sample_size, c, n, i;
263263 short *samples;
264264 const uint8_t *src, *src8, *src2[MAX_CHANNELS];
265265 uint8_t *dstu8;
@@ -288,6 +288,9 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 22 unmodified lines
288288 if (CODEC_ID_PCM_DVD == avctx->codec_id)
289289 /* 2 samples are interleaved per block in PCM_DVD */
290290 sample_size = avctx->bits_per_coded_sample * 2 / 8;
291+ else if (avctx->codec_id == CODEC_ID_PCM_LXF)
292+ /* we process 40-bit blocks per channel for LXF */
293+ sample_size = 5;
291294
292295 n = avctx->channels * sample_size;
293296
@@ -436,6 +439,26 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 142 unmodified lines
436439 }
437440 samples = (short *) dst_int32_t;
438441 break;
442+ case CODEC_ID_PCM_LXF:
443+ dst_int32_t = data;
444+ n /= avctx->channels;
445+ //unpack and de-planerize
446+ for (i = 0; i < n; i++) {
447+ for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) {
448+ //extract low 20 bits and expand to 32 bits
449+ *dst_int32_t++ = (src8[2] << 28) | (src8[1] << 20) | (src8[0] << 12) |
450+ ((src8[2] & 0xF) << 8) | src8[1];
451+ }
452+
453+ for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) {
454+ //extract high 20 bits and expand to 32 bits
455+ *dst_int32_t++ = (src8[4] << 24) | (src8[3] << 16) |
456+ ((src8[2] & 0xF0) << 8) | (src8[4] << 4) | (src8[3] >> 4);
457+ }
458+ }
459+ src += n * avctx->channels * 5;
460+ samples = (short *) dst_int32_t;
461+ break;
439462 default:
440463 return -1;
441464 }
@@ -485,6 +508,7 @@ PCM_CODEC (CODEC_ID_PCM_F32BE, SAMPLE_FMT_FLT, pcm_f32be, "PCM 32-bit floating · 43 unmodified lines
485508 PCM_CODEC (CODEC_ID_PCM_F32LE, SAMPLE_FMT_FLT, pcm_f32le, "PCM 32-bit floating point little-endian");
486509 PCM_CODEC (CODEC_ID_PCM_F64BE, SAMPLE_FMT_DBL, pcm_f64be, "PCM 64-bit floating point big-endian");
487510 PCM_CODEC (CODEC_ID_PCM_F64LE, SAMPLE_FMT_DBL, pcm_f64le, "PCM 64-bit floating point little-endian");
511+PCM_DECODER(CODEC_ID_PCM_LXF, SAMPLE_FMT_S32, pcm_lxf, "PCM signed 20-bit little-endian planar");
488512 PCM_CODEC (CODEC_ID_PCM_MULAW, SAMPLE_FMT_S16, pcm_mulaw, "PCM mu-law");
489513 PCM_CODEC (CODEC_ID_PCM_S8, SAMPLE_FMT_U8, pcm_s8, "PCM signed 8-bit");
490514 PCM_CODEC (CODEC_ID_PCM_S16BE, SAMPLE_FMT_S16, pcm_s16be, "PCM signed 16-bit big-endian");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t