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
283 REGISTER_ENCDEC (PCM_F32LE, pcm_f32le);283 REGISTER_ENCDEC (PCM_F32LE, pcm_f32le);
284 REGISTER_ENCDEC (PCM_F64BE, pcm_f64be);284 REGISTER_ENCDEC (PCM_F64BE, pcm_f64be);
285 REGISTER_ENCDEC (PCM_F64LE, pcm_f64le);285 REGISTER_ENCDEC (PCM_F64LE, pcm_f64le);
286 REGISTER_DECODER (PCM_LXF, pcm_lxf);
286 REGISTER_ENCDEC (PCM_MULAW, pcm_mulaw);287 REGISTER_ENCDEC (PCM_MULAW, pcm_mulaw);
287 REGISTER_ENCDEC (PCM_S8, pcm_s8);288 REGISTER_ENCDEC (PCM_S8, pcm_s8);
288 REGISTER_ENCDEC (PCM_S16BE, pcm_s16be);289 REGISTER_ENCDEC (PCM_S16BE, pcm_s16be);
libavcodec/avcodec.h+3−2
@@ -31,8 +31,8 @@ · 30 unmodified lines
31#include "libavutil/cpu.h"31#include "libavutil/cpu.h"
32 32
33#define LIBAVCODEC_VERSION_MAJOR 5233#define LIBAVCODEC_VERSION_MAJOR 52
34#define LIBAVCODEC_VERSION_MINOR 9134#define LIBAVCODEC_VERSION_MINOR 92
35#define LIBAVCODEC_VERSION_MICRO 135#define LIBAVCODEC_VERSION_MICRO 0
36 36
37#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \37#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
38 LIBAVCODEC_VERSION_MINOR, \38 LIBAVCODEC_VERSION_MINOR, \
@@ -276,6 +276,7 @@ enum CodecID { · 237 unmodified lines
276 CODEC_ID_PCM_F64BE,276 CODEC_ID_PCM_F64BE,
277 CODEC_ID_PCM_F64LE,277 CODEC_ID_PCM_F64LE,
278 CODEC_ID_PCM_BLURAY,278 CODEC_ID_PCM_BLURAY,
279 CODEC_ID_PCM_LXF,
279 280
280 /* various ADPCM codecs */281 /* various ADPCM codecs */
281 CODEC_ID_ADPCM_IMA_QT= 0x11000,282 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
259 const uint8_t *buf = avpkt->data;259 const uint8_t *buf = avpkt->data;
260 int buf_size = avpkt->size;260 int buf_size = avpkt->size;
261 PCMDecode *s = avctx->priv_data;261 PCMDecode *s = avctx->priv_data;
262 int sample_size, c, n;262 int sample_size, c, n, i;
263 short *samples;263 short *samples;
264 const uint8_t *src, *src8, *src2[MAX_CHANNELS];264 const uint8_t *src, *src8, *src2[MAX_CHANNELS];
265 uint8_t *dstu8;265 uint8_t *dstu8;
@@ -288,6 +288,9 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 22 unmodified lines
288 if (CODEC_ID_PCM_DVD == avctx->codec_id)288 if (CODEC_ID_PCM_DVD == avctx->codec_id)
289 /* 2 samples are interleaved per block in PCM_DVD */289 /* 2 samples are interleaved per block in PCM_DVD */
290 sample_size = avctx->bits_per_coded_sample * 2 / 8;290 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;
291 294
292 n = avctx->channels * sample_size;295 n = avctx->channels * sample_size;
293 296
@@ -436,6 +439,26 @@ static int pcm_decode_frame(AVCodecContext *avctx, · 142 unmodified lines
436 }439 }
437 samples = (short *) dst_int32_t;440 samples = (short *) dst_int32_t;
438 break;441 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;
439 default:462 default:
440 return -1;463 return -1;
441 }464 }
@@ -485,6 +508,7 @@ PCM_CODEC (CODEC_ID_PCM_F32BE, SAMPLE_FMT_FLT, pcm_f32be, "PCM 32-bit floating · 43 unmodified lines
485PCM_CODEC (CODEC_ID_PCM_F32LE, SAMPLE_FMT_FLT, pcm_f32le, "PCM 32-bit floating point little-endian");508PCM_CODEC (CODEC_ID_PCM_F32LE, SAMPLE_FMT_FLT, pcm_f32le, "PCM 32-bit floating point little-endian");
486PCM_CODEC (CODEC_ID_PCM_F64BE, SAMPLE_FMT_DBL, pcm_f64be, "PCM 64-bit floating point big-endian");509PCM_CODEC (CODEC_ID_PCM_F64BE, SAMPLE_FMT_DBL, pcm_f64be, "PCM 64-bit floating point big-endian");
487PCM_CODEC (CODEC_ID_PCM_F64LE, SAMPLE_FMT_DBL, pcm_f64le, "PCM 64-bit floating point little-endian");510PCM_CODEC (CODEC_ID_PCM_F64LE, SAMPLE_FMT_DBL, pcm_f64le, "PCM 64-bit floating point little-endian");
511PCM_DECODER(CODEC_ID_PCM_LXF, SAMPLE_FMT_S32, pcm_lxf, "PCM signed 20-bit little-endian planar");
488PCM_CODEC (CODEC_ID_PCM_MULAW, SAMPLE_FMT_S16, pcm_mulaw, "PCM mu-law");512PCM_CODEC (CODEC_ID_PCM_MULAW, SAMPLE_FMT_S16, pcm_mulaw, "PCM mu-law");
489PCM_CODEC (CODEC_ID_PCM_S8, SAMPLE_FMT_U8, pcm_s8, "PCM signed 8-bit");513PCM_CODEC (CODEC_ID_PCM_S8, SAMPLE_FMT_U8, pcm_s8, "PCM signed 8-bit");
490PCM_CODEC (CODEC_ID_PCM_S16BE, SAMPLE_FMT_S16, pcm_s16be, "PCM signed 16-bit big-endian");514PCM_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