]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/adpcm.c
LPCM 24 bits support, patch by Lars Täuber, lars.taeuber gmx net
[ffmpeg] / libavcodec / adpcm.c
index 89977801582f52246f6a61fb7f3a06610865d72b..d7f76e80a9b883cc926db3211f7a565bed6742a1 100644 (file)
@@ -34,6 +34,7 @@
  * EA IMA EACS decoder by Peter Ross (pross@xvid.org)
  * EA IMA SEAD decoder by Peter Ross (pross@xvid.org)
  * EA ADPCM XAS decoder by Peter Ross (pross@xvid.org)
+ * MAXIS EA ADPCM decoder by Robert Marston (rmarston@gmail.com)
  * THP ADPCM decoder by Marco Gerards (mgerards@xs4all.nl)
  *
  * Features and limitations:
@@ -147,7 +148,6 @@ typedef struct ADPCMChannelStatus {
 } ADPCMChannelStatus;
 
 typedef struct ADPCMContext {
-    int channel; /* for stereo MOVs, decode left, then decode right, then tell it's decoded */
     ADPCMChannelStatus status[6];
 } ADPCMContext;
 
@@ -165,6 +165,10 @@ static int adpcm_encode_init(AVCodecContext *avctx)
         avctx->block_align = BLKSIZE;
         /* seems frame_size isn't taken into account... have to buffer the samples :-( */
         break;
+    case CODEC_ID_ADPCM_IMA_QT:
+        avctx->frame_size = 64;
+        avctx->block_align = 34 * avctx->channels;
+        break;
     case CODEC_ID_ADPCM_MS:
         avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / avctx->channels + 2; /* each 16 bits sample gives one nibble */
                                                              /* and we have 7 bytes per channel overhead */
@@ -295,7 +299,7 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
     nodes[0]->step = c->step_index;
     nodes[0]->sample1 = c->sample1;
     nodes[0]->sample2 = c->sample2;
-    if((version == CODEC_ID_ADPCM_IMA_WAV) || (version == CODEC_ID_ADPCM_SWF))
+    if((version == CODEC_ID_ADPCM_IMA_WAV) || (version == CODEC_ID_ADPCM_IMA_QT) || (version == CODEC_ID_ADPCM_SWF))
         nodes[0]->sample1 = c->prev_sample;
     if(version == CODEC_ID_ADPCM_MS)
         nodes[0]->step = c->idelta;
@@ -366,7 +370,7 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
                     next_##NAME:;
                     STORE_NODE(ms, FFMAX(16, (AdaptationTable[nibble] * step) >> 8));
                 }
-            } else if((version == CODEC_ID_ADPCM_IMA_WAV)|| (version == CODEC_ID_ADPCM_SWF)) {
+            } else if((version == CODEC_ID_ADPCM_IMA_WAV)|| (version == CODEC_ID_ADPCM_IMA_QT)|| (version == CODEC_ID_ADPCM_SWF)) {
 #define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)\
                 const int predictor = nodes[j]->sample1;\
                 const int div = (sample - predictor) * 4 / STEP_TABLE;\
@@ -451,7 +455,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
             *dst++ = 0; /* unknown */
             samples++;
             if (avctx->channels == 2) {
-                c->status[1].prev_sample = (signed short)samples[1];
+                c->status[1].prev_sample = (signed short)samples[0];
 /*                c->status[1].step_index = 0; */
                 bytestream_put_le16(&dst, c->status[1].prev_sample);
                 *dst++ = (unsigned char)c->status[1].step_index;
@@ -509,6 +513,36 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
                 samples += 8 * avctx->channels;
             }
         break;
+    case CODEC_ID_ADPCM_IMA_QT:
+    {
+        int ch, i;
+        PutBitContext pb;
+        init_put_bits(&pb, dst, buf_size*8);
+
+        for(ch=0; ch<avctx->channels; ch++){
+            put_bits(&pb, 9, (c->status[ch].prev_sample + 0x10000) >> 7);
+            put_bits(&pb, 7, c->status[ch].step_index);
+            if(avctx->trellis > 0) {
+                uint8_t buf[64];
+                adpcm_compress_trellis(avctx, samples+ch, buf, &c->status[ch], 64);
+                for(i=0; i<64; i++)
+                    put_bits(&pb, 4, buf[i^1]);
+                c->status[ch].prev_sample = c->status[ch].predictor & ~0x7F;
+            } else {
+                for (i=0; i<64; i+=2){
+                    int t1, t2;
+                    t1 = adpcm_ima_compress_sample(&c->status[ch], samples[avctx->channels*(i+0)+ch]);
+                    t2 = adpcm_ima_compress_sample(&c->status[ch], samples[avctx->channels*(i+1)+ch]);
+                    put_bits(&pb, 4, t2);
+                    put_bits(&pb, 4, t1);
+                }
+                c->status[ch].prev_sample &= ~0x7F;
+            }
+        }
+
+        dst += put_bits_count(&pb)>>3;
+        break;
+    }
     case CODEC_ID_ADPCM_SWF:
     {
         int i;
@@ -629,7 +663,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
 }
 #endif //CONFIG_ENCODERS
 
-static int adpcm_decode_init(AVCodecContext * avctx)
+static av_cold int adpcm_decode_init(AVCodecContext * avctx)
 {
     ADPCMContext *c = avctx->priv_data;
     unsigned int max_channels = 2;
@@ -828,7 +862,7 @@ static void xa_decode(short *out, const unsigned char *in,
 #define DK3_GET_NEXT_NIBBLE() \
     if (decode_top_nibble_next) \
     { \
-        nibble = (last_byte >> 4) & 0x0F; \
+        nibble = last_byte >> 4; \
         decode_top_nibble_next = 0; \
     } \
     else \
@@ -841,7 +875,7 @@ static void xa_decode(short *out, const unsigned char *in,
 
 static int adpcm_decode_frame(AVCodecContext *avctx,
                             void *data, int *data_size,
-                            uint8_t *buf, int buf_size)
+                            const uint8_t *buf, int buf_size)
 {
     ADPCMContext *c = avctx->priv_data;
     ADPCMChannelStatus *cs;
@@ -849,7 +883,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
     int block_predictor[2];
     short *samples;
     short *samples_end;
-    uint8_t *src;
+    const uint8_t *src;
     int st; /* stereo */
 
     /* DK3 ADPCM accounting variables */
@@ -866,6 +900,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
     int32_t coeff1l, coeff2l, coeff1r, coeff2r;
     uint8_t shift_left, shift_right;
     int count1, count2;
+    int coeff[2][2], shift[2];//used in EA MAXIS ADPCM
 
     if (!buf_size)
         return 0;
@@ -885,48 +920,43 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
 
     switch(avctx->codec->id) {
     case CODEC_ID_ADPCM_IMA_QT:
-        n = (buf_size - 2);/* >> 2*avctx->channels;*/
-        channel = c->channel;
-        cs = &(c->status[channel]);
-        /* (pppppp) (piiiiiii) */
+        n = buf_size - 2*avctx->channels;
+        for (channel = 0; channel < avctx->channels; channel++) {
+            cs = &(c->status[channel]);
+            /* (pppppp) (piiiiiii) */
 
-        /* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */
-        cs->predictor = (*src++) << 8;
-        cs->predictor |= (*src & 0x80);
-        cs->predictor &= 0xFF80;
+            /* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */
+            cs->predictor = (*src++) << 8;
+            cs->predictor |= (*src & 0x80);
+            cs->predictor &= 0xFF80;
 
-        /* sign extension */
-        if(cs->predictor & 0x8000)
-            cs->predictor -= 0x10000;
+            /* sign extension */
+            if(cs->predictor & 0x8000)
+                cs->predictor -= 0x10000;
 
-        cs->predictor = av_clip_int16(cs->predictor);
+            cs->predictor = av_clip_int16(cs->predictor);
 
-        cs->step_index = (*src++) & 0x7F;
+            cs->step_index = (*src++) & 0x7F;
 
-        if (cs->step_index > 88){
-            av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
-            cs->step_index = 88;
-        }
-
-        cs->step = step_table[cs->step_index];
+            if (cs->step_index > 88){
+                av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
+                cs->step_index = 88;
+            }
 
-        if (st && channel)
-            samples++;
+            cs->step = step_table[cs->step_index];
 
-        for(m=32; n>0 && m>0; n--, m--) { /* in QuickTime, IMA is encoded by chuncks of 34 bytes (=64 samples) */
-            *samples = adpcm_ima_expand_nibble(cs, src[0] & 0x0F, 3);
-            samples += avctx->channels;
-            *samples = adpcm_ima_expand_nibble(cs, (src[0] >> 4) & 0x0F, 3);
-            samples += avctx->channels;
-            src ++;
-        }
+            samples = (short*)data + channel;
 
-        if(st) { /* handle stereo interlacing */
-            c->channel = (channel + 1) % 2; /* we get one packet for left, then one for right data */
-            if(channel == 1) { /* wait for the other packet before outputing anything */
-                return src - buf;
+            for(m=32; n>0 && m>0; n--, m--) { /* in QuickTime, IMA is encoded by chuncks of 34 bytes (=64 samples) */
+                *samples = adpcm_ima_expand_nibble(cs, src[0] & 0x0F, 3);
+                samples += avctx->channels;
+                *samples = adpcm_ima_expand_nibble(cs, src[0] >> 4  , 3);
+                samples += avctx->channels;
+                src ++;
             }
         }
+        if (st)
+            samples--;
         break;
     case CODEC_ID_ADPCM_IMA_WAV:
         if (avctx->block_align != 0 && buf_size > avctx->block_align)
@@ -936,11 +966,9 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
 
         for(i=0; i<avctx->channels; i++){
             cs = &(c->status[i]);
-            cs->predictor = (int16_t)(src[0] + (src[1]<<8));
+            cs->predictor = *samples++ = (int16_t)(src[0] + (src[1]<<8));
             src+=2;
 
-        // XXX: is this correct ??: *samples++ = cs->predictor;
-
             cs->step_index = *src++;
             if (cs->step_index > 88){
                 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
@@ -1021,7 +1049,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
         *samples++ = c->status[0].sample2;
         if (st) *samples++ = c->status[1].sample2;
         for(;n>0;n--) {
-            *samples++ = adpcm_ms_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F);
+            *samples++ = adpcm_ms_expand_nibble(&c->status[0 ], src[0] >> 4  );
             *samples++ = adpcm_ms_expand_nibble(&c->status[st], src[0] & 0x0F);
             src ++;
         }
@@ -1044,7 +1072,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
 
             /* take care of the top nibble (always left or mono channel) */
             *samples++ = adpcm_ima_expand_nibble(&c->status[0],
-                (src[0] >> 4) & 0x0F, 3);
+                src[0] >> 4, 3);
 
             /* take care of the bottom nibble, which is right sample for
              * stereo, or another mono sample */
@@ -1109,12 +1137,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
 
             if (st) {
                 *samples++ = adpcm_ima_expand_nibble(&c->status[0],
-                    (src[0] >> 4) & 0x0F, 3);
+                    src[0] >> 4  , 3);
                 *samples++ = adpcm_ima_expand_nibble(&c->status[1],
                     src[0] & 0x0F, 3);
             } else {
                 *samples++ = adpcm_ima_expand_nibble(&c->status[0],
-                    (src[0] >> 4) & 0x0F, 3);
+                    src[0] >> 4  , 3);
                 *samples++ = adpcm_ima_expand_nibble(&c->status[0],
                     src[0] & 0x0F, 3);
             }
@@ -1123,8 +1151,6 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
         }
         break;
     case CODEC_ID_ADPCM_XA:
-        c->status[0].sample1 = c->status[0].sample2 =
-        c->status[1].sample1 = c->status[1].sample2 = 0;
         while (buf_size >= 128) {
             xa_decode(samples, src, &c->status[0], &c->status[1],
                 avctx->channels);
@@ -1174,19 +1200,19 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
         src += 2;
 
         for (count1 = 0; count1 < samples_in_chunk/28;count1++) {
-            coeff1l = ea_adpcm_table[(*src >> 4) & 0x0F];
-            coeff2l = ea_adpcm_table[((*src >> 4) & 0x0F) + 4];
+            coeff1l = ea_adpcm_table[ *src >> 4       ];
+            coeff2l = ea_adpcm_table[(*src >> 4  ) + 4];
             coeff1r = ea_adpcm_table[*src & 0x0F];
             coeff2r = ea_adpcm_table[(*src & 0x0F) + 4];
             src++;
 
-            shift_left = ((*src >> 4) & 0x0F) + 8;
+            shift_left  = (*src >> 4  ) + 8;
             shift_right = (*src & 0x0F) + 8;
             src++;
 
             for (count2 = 0; count2 < 28; count2++) {
-                next_left_sample = (((*src & 0xF0) << 24) >> shift_left);
-                next_right_sample = (((*src & 0x0F) << 28) >> shift_right);
+                next_left_sample  = (int32_t)((*src & 0xF0) << 24) >> shift_left;
+                next_right_sample = (int32_t)((*src & 0x0F) << 28) >> shift_right;
                 src++;
 
                 next_left_sample = (next_left_sample +
@@ -1205,6 +1231,28 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
             }
         }
         break;
+    case CODEC_ID_ADPCM_EA_MAXIS_XA:
+        for(channel = 0; channel < avctx->channels; channel++) {
+            for (i=0; i<2; i++)
+                coeff[channel][i] = ea_adpcm_table[(*src >> 4) + 4*i];
+            shift[channel] = (*src & 0x0F) + 8;
+            src++;
+        }
+        for (count1 = 0; count1 < (buf_size - avctx->channels) / avctx->channels; count1++) {
+            for(i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */
+                for(channel = 0; channel < avctx->channels; channel++) {
+                    int32_t sample = (int32_t)(((*(src+channel) >> i) & 0x0F) << 0x1C) >> shift[channel];
+                    sample = (sample +
+                             c->status[channel].sample1 * coeff[channel][0] +
+                             c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8;
+                    c->status[channel].sample2 = c->status[channel].sample1;
+                    c->status[channel].sample1 = av_clip_int16(sample);
+                    *samples++ = c->status[channel].sample1;
+                }
+            }
+            src+=avctx->channels;
+        }
+        break;
     case CODEC_ID_ADPCM_EA_R1:
     case CODEC_ID_ADPCM_EA_R2:
     case CODEC_ID_ADPCM_EA_R3: {
@@ -1218,7 +1266,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
         uint8_t shift;
         unsigned int channel;
         uint16_t *samplesC;
-        uint8_t *srcC;
+        const uint8_t *srcC;
 
         samples_in_chunk = (big_endian ? bytestream_get_be32(&src)
                                        : bytestream_get_le32(&src)) / 28;
@@ -1253,15 +1301,15 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
                         samplesC += avctx->channels;
                     }
                 } else {
-                    coeff1 = ea_adpcm_table[ (*srcC>>4) & 0x0F     ];
-                    coeff2 = ea_adpcm_table[((*srcC>>4) & 0x0F) + 4];
+                    coeff1 = ea_adpcm_table[ *srcC>>4     ];
+                    coeff2 = ea_adpcm_table[(*srcC>>4) + 4];
                     shift = (*srcC++ & 0x0F) + 8;
 
                     for (count2=0; count2<28; count2++) {
                         if (count2 & 1)
-                            next_sample = ((*srcC++ & 0x0F) << 28) >> shift;
+                            next_sample = (int32_t)((*srcC++ & 0x0F) << 28) >> shift;
                         else
-                            next_sample = ((*srcC   & 0xF0) << 24) >> shift;
+                            next_sample = (int32_t)((*srcC   & 0xF0) << 24) >> shift;
 
                         next_sample += (current_sample  * coeff1) +
                                        (previous_sample * coeff2);
@@ -1306,7 +1354,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
                 s = &samples[m*avctx->channels + channel];
                 for (n=0; n<4; n++, src++, s+=32*avctx->channels) {
                     for (s2=s, i=0; i<8; i+=4, s2+=avctx->channels) {
-                        int level = ((*src & (0xF0>>i)) << (24+i)) >> shift[n];
+                        int level = (int32_t)((*src & (0xF0>>i)) << (24+i)) >> shift[n];
                         int pred  = s2[-1*avctx->channels] * coeff[0][n]
                                   + s2[-2*avctx->channels] * coeff[1][n];
                         s2[0] = av_clip_int16((level + pred + 0x80) >> 8);
@@ -1327,7 +1375,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
         while (src < buf + buf_size) {
             char hi, lo;
             lo = *src & 0x0F;
-            hi = (*src >> 4) & 0x0F;
+            hi = *src >> 4;
 
             if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV)
                 FFSWAP(char, hi, lo);
@@ -1343,12 +1391,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
         while (src < buf + buf_size) {
             if (st) {
                 *samples++ = adpcm_ct_expand_nibble(&c->status[0],
-                    (src[0] >> 4) & 0x0F);
+                    src[0] >> 4);
                 *samples++ = adpcm_ct_expand_nibble(&c->status[1],
                     src[0] & 0x0F);
             } else {
                 *samples++ = adpcm_ct_expand_nibble(&c->status[0],
-                    (src[0] >> 4) & 0x0F);
+                    src[0] >> 4);
                 *samples++ = adpcm_ct_expand_nibble(&c->status[0],
                     src[0] & 0x0F);
             }
@@ -1368,7 +1416,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
         if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_4) {
             while (src < buf + buf_size) {
                 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
-                    (src[0] >> 4) & 0x0F, 4, 0);
+                    src[0] >> 4, 4, 0);
                 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
                     src[0] & 0x0F, 4, 0);
                 src++;
@@ -1376,7 +1424,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
         } else if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_3) {
             while (src < buf + buf_size && samples + 2 < samples_end) {
                 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
-                    (src[0] >> 5) & 0x07, 3, 0);
+                     src[0] >> 5        , 3, 0);
                 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
                     (src[0] >> 2) & 0x07, 3, 0);
                 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
@@ -1386,7 +1434,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
         } else {
             while (src < buf + buf_size && samples + 3 < samples_end) {
                 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
-                    (src[0] >> 6) & 0x03, 2, 2);
+                     src[0] >> 6        , 2, 2);
                 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
                     (src[0] >> 4) & 0x03, 2, 2);
                 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
@@ -1464,12 +1512,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
                 *samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
                         src[0] & 0x0F);
                 *samples++ = adpcm_yamaha_expand_nibble(&c->status[1],
-                        (src[0] >> 4) & 0x0F);
+                        src[0] >> 4  );
             } else {
                 *samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
                         src[0] & 0x0F);
                 *samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
-                        (src[0] >> 4) & 0x0F);
+                        src[0] >> 4  );
             }
             src++;
         }
@@ -1546,7 +1594,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
 
 
 #ifdef CONFIG_ENCODERS
-#define ADPCM_ENCODER(id,name)                  \
+#define ADPCM_ENCODER(id,name,long_name_)       \
 AVCodec name ## _encoder = {                    \
     #name,                                      \
     CODEC_TYPE_AUDIO,                           \
@@ -1556,13 +1604,14 @@ AVCodec name ## _encoder = {                    \
     adpcm_encode_frame,                         \
     adpcm_encode_close,                         \
     NULL,                                       \
+    .long_name = long_name_,                    \
 };
 #else
-#define ADPCM_ENCODER(id,name)
+#define ADPCM_ENCODER(id,name,long_name_)
 #endif
 
 #ifdef CONFIG_DECODERS
-#define ADPCM_DECODER(id,name)                  \
+#define ADPCM_DECODER(id,name,long_name_)       \
 AVCodec name ## _decoder = {                    \
     #name,                                      \
     CODEC_TYPE_AUDIO,                           \
@@ -1572,35 +1621,37 @@ AVCodec name ## _decoder = {                    \
     NULL,                                       \
     NULL,                                       \
     adpcm_decode_frame,                         \
+    .long_name = long_name_,                    \
 };
 #else
-#define ADPCM_DECODER(id,name)
+#define ADPCM_DECODER(id,name,long_name_)
 #endif
 
-#define ADPCM_CODEC(id, name)                   \
-ADPCM_ENCODER(id,name) ADPCM_DECODER(id,name)
-
-ADPCM_DECODER(CODEC_ID_ADPCM_4XM, adpcm_4xm);
-ADPCM_DECODER(CODEC_ID_ADPCM_CT, adpcm_ct);
-ADPCM_DECODER(CODEC_ID_ADPCM_EA, adpcm_ea);
-ADPCM_DECODER(CODEC_ID_ADPCM_EA_R1, adpcm_ea_r1);
-ADPCM_DECODER(CODEC_ID_ADPCM_EA_R2, adpcm_ea_r2);
-ADPCM_DECODER(CODEC_ID_ADPCM_EA_R3, adpcm_ea_r3);
-ADPCM_DECODER(CODEC_ID_ADPCM_EA_XAS, adpcm_ea_xas);
-ADPCM_DECODER(CODEC_ID_ADPCM_IMA_AMV, adpcm_ima_amv);
-ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
-ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
-ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs);
-ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead);
-ADPCM_DECODER(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
-ADPCM_DECODER(CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg);
-ADPCM_CODEC  (CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
-ADPCM_DECODER(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
-ADPCM_CODEC  (CODEC_ID_ADPCM_MS, adpcm_ms);
-ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4);
-ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3);
-ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2);
-ADPCM_CODEC  (CODEC_ID_ADPCM_SWF, adpcm_swf);
-ADPCM_DECODER(CODEC_ID_ADPCM_THP, adpcm_thp);
-ADPCM_DECODER(CODEC_ID_ADPCM_XA, adpcm_xa);
-ADPCM_CODEC  (CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
+#define ADPCM_CODEC(id,name,long_name_)         \
+    ADPCM_ENCODER(id,name,long_name_) ADPCM_DECODER(id,name,long_name_)
+
+ADPCM_DECODER(CODEC_ID_ADPCM_4XM, adpcm_4xm, "4X Movie ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_CT, adpcm_ct, "Creative Technology ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_EA, adpcm_ea, "Electronic Arts ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_EA_MAXIS_XA, adpcm_ea_maxis_xa, "Electronic Arts Maxis CDROM XA ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_EA_R1, adpcm_ea_r1, "Electronic Arts R1 ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_EA_R2, adpcm_ea_r2, "Electronic Arts R2 ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_EA_R3, adpcm_ea_r3, "Electronic Arts R3 ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_EA_XAS, adpcm_ea_xas, "Electronic Arts XAS ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_IMA_AMV, adpcm_ima_amv, "IMA AMV ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3, "IMA Duck DK3 ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4, "IMA Duck DK4 ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs, "IMA Electronic Arts EACS ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead, "IMA Electronic Arts SEAD ADPCM");
+ADPCM_CODEC  (CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt, "IMA QuickTime ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg, "IMA Loki SDL MJPEG ADPCM");
+ADPCM_CODEC  (CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav, "IMA Wav ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws, "IMA Westwood ADPCM");
+ADPCM_CODEC  (CODEC_ID_ADPCM_MS, adpcm_ms, "Microsoft ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2, "Sound Blaster Pro 2-bit ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3, "Sound Blaster Pro 2.6-bit ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4, "Sound Blaster Pro 4-bit ADPCM");
+ADPCM_CODEC  (CODEC_ID_ADPCM_SWF, adpcm_swf, "Shockwave Flash ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_THP, adpcm_thp, "Nintendo Gamecube THP ADPCM");
+ADPCM_DECODER(CODEC_ID_ADPCM_XA, adpcm_xa, "CDROM XA ADPCM");
+ADPCM_CODEC  (CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha, "Yamaha ADPCM");