[FFmpeg-devel] [PATCH 1/2] PCM signed 24-bit as found in Ensoniq Paris Audio Files

Paul B Mahol onemda at gmail.com
Wed Nov 28 03:09:01 CET 2012


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavcodec/Makefile     |  1 +
 libavcodec/allcodecs.c  |  1 +
 libavcodec/avcodec.h    |  1 +
 libavcodec/codec_desc.c |  7 +++++++
 libavcodec/pcm.c        | 22 ++++++++++++++++++++++
 libavcodec/utils.c      |  2 ++
 6 files changed, 34 insertions(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d805711..96436bf 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -541,6 +541,7 @@ OBJS-$(CONFIG_PCM_S24LE_DECODER)          += pcm.o
 OBJS-$(CONFIG_PCM_S24LE_ENCODER)          += pcm.o
 OBJS-$(CONFIG_PCM_S24LE_PLANAR_DECODER)   += pcm.o
 OBJS-$(CONFIG_PCM_S24LE_PLANAR_ENCODER)   += pcm.o
+OBJS-$(CONFIG_PCM_S24PARIS_DECODER)       += pcm.o
 OBJS-$(CONFIG_PCM_S32BE_DECODER)          += pcm.o
 OBJS-$(CONFIG_PCM_S32BE_ENCODER)          += pcm.o
 OBJS-$(CONFIG_PCM_S32LE_DECODER)          += pcm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4743bb1..b81691e 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -366,6 +366,7 @@ void avcodec_register_all(void)
     REGISTER_ENCDEC  (PCM_S24DAUD, pcm_s24daud);
     REGISTER_ENCDEC  (PCM_S24LE, pcm_s24le);
     REGISTER_ENCDEC  (PCM_S24LE_PLANAR, pcm_s24le_planar);
+    REGISTER_DECODER (PCM_S24PARIS, pcm_s24paris);
     REGISTER_ENCDEC  (PCM_S32BE, pcm_s32be);
     REGISTER_ENCDEC  (PCM_S32LE, pcm_s32le);
     REGISTER_ENCDEC  (PCM_S32LE_PLANAR, pcm_s32le_planar);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index b6a4b0e..854d2b4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -319,6 +319,7 @@ enum AVCodecID {
     AV_CODEC_ID_PCM_S24LE_PLANAR = MKBETAG(24,'P','S','P'),
     AV_CODEC_ID_PCM_S32LE_PLANAR = MKBETAG(32,'P','S','P'),
     AV_CODEC_ID_PCM_S16BE_PLANAR = MKBETAG('P','S','P',16),
+    AV_CODEC_ID_PCM_S24PARIS     = MKBETAG('E','P','A','F'),
 
     /* various ADPCM codecs */
     AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 5e4f357..e902756 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1546,6 +1546,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
         .long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"),
         .props     = AV_CODEC_PROP_LOSSLESS,
     },
+    {
+        .id        = AV_CODEC_ID_PCM_S24PARIS,
+        .type      = AVMEDIA_TYPE_AUDIO,
+        .name      = "pcm_s24paris",
+        .long_name = NULL_IF_CONFIG_SMALL("PCM Paris signed 24-bit"),
+        .props     = AV_CODEC_PROP_LOSSLESS,
+    },
 
     /* various ADPCM codecs */
     {
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 5ed603e..91fbdc8 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -326,6 +326,9 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
         /* we process 40-bit blocks per channel for LXF */
         samples_per_block = 2;
         sample_size       = 5;
+    } else if (avctx->codec_id == AV_CODEC_ID_PCM_S24PARIS) {
+        samples_per_block = 10;
+        sample_size       = 32;
     }
 
     if (sample_size == 0) {
@@ -535,6 +538,24 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
         }
         break;
     }
+    case AV_CODEC_ID_PCM_S24PARIS:
+    {
+        int i, j;
+        n /= avctx->channels;
+        for (i = 0; i < n; i++) {
+            for (c = 0; c < avctx->channels; c++) {
+                dst_int32_t = (int32_t *)s->frame.extended_data[c] + 10 * i;
+                for (j = 0; j < 10; j++) {
+                    *dst_int32_t++ = (src[2] << 24) |
+                                     (src[1] << 16) |
+                                     (src[0] <<  8);
+                    src += 3;
+                }
+                src += 2;
+            }
+        }
+        break;
+    }
     default:
         return -1;
     }
@@ -611,6 +632,7 @@ PCM_CODEC  (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_S24PARIS,     AV_SAMPLE_FMT_S32P,pcm_s24paris,     "PCM Paris signed 24-bit");
 PCM_CODEC  (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");
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 32bda51..b51b3eb 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2515,6 +2515,8 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
                     return blocks * (1 + (ba - 4 * ch) * 2 / ch);
                 case AV_CODEC_ID_ADPCM_MS:
                     return blocks * (2 + (ba - 7 * ch) * 2 / ch);
+                case AV_CODEC_ID_PCM_S24PARIS:
+                    return blocks * 10;
                 }
             }
 
-- 
1.7.11.4



More information about the ffmpeg-devel mailing list