2 * Copyright (c) 2001-2003 The ffmpeg Project
4 * This file is part of Libav.
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "bytestream.h"
25 #include "adpcm_data.h"
30 * First version by Francois Revol (revol@free.fr)
31 * Fringe ADPCM codecs (e.g., DK3, DK4, Westwood)
32 * by Mike Melanson (melanson@pcisys.net)
33 * CD-ROM XA ADPCM codec by BERO
34 * EA ADPCM decoder by Robin Kay (komadori@myrealbox.com)
35 * EA ADPCM R1/R2/R3 decoder by Peter Ross (pross@xvid.org)
36 * EA IMA EACS decoder by Peter Ross (pross@xvid.org)
37 * EA IMA SEAD decoder by Peter Ross (pross@xvid.org)
38 * EA ADPCM XAS decoder by Peter Ross (pross@xvid.org)
39 * MAXIS EA ADPCM decoder by Robert Marston (rmarston@gmail.com)
40 * THP ADPCM decoder by Marco Gerards (mgerards@xs4all.nl)
42 * Features and limitations:
44 * Reference documents:
45 * http://wiki.multimedia.cx/index.php?title=Category:ADPCM_Audio_Codecs
46 * http://www.pcisys.net/~melanson/codecs/simpleaudio.html [dead]
47 * http://www.geocities.com/SiliconValley/8682/aud3.txt [dead]
48 * http://openquicktime.sourceforge.net/
49 * XAnim sources (xa_codec.c) http://xanim.polter.net/
50 * http://www.cs.ucla.edu/~leec/mediabench/applications.html [dead]
51 * SoX source code http://sox.sourceforge.net/
54 * http://ku-www.ss.titech.ac.jp/~yatsushi/xaadpcm.html [dead]
55 * vagpack & depack http://homepages.compuserve.de/bITmASTER32/psx-index.html [dead]
56 * readstr http://www.geocities.co.jp/Playtown/2004/
59 /* These are for CD-ROM XA ADPCM */
60 static const int xa_adpcm_table[5][2] = {
68 static const int ea_adpcm_table[] = {
76 // padded to zero where table size is less then 16
77 static const int swf_index_tables[4][16] = {
79 /*3*/ { -1, -1, 2, 4 },
80 /*4*/ { -1, -1, -1, -1, 2, 4, 6, 8 },
81 /*5*/ { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }
86 typedef struct ADPCMDecodeContext {
88 ADPCMChannelStatus status[6];
89 int vqa_version; /**< VQA version. Used for ADPCM_IMA_WS */
92 static av_cold int adpcm_decode_init(AVCodecContext * avctx)
94 ADPCMDecodeContext *c = avctx->priv_data;
95 unsigned int min_channels = 1;
96 unsigned int max_channels = 2;
98 switch(avctx->codec->id) {
99 case CODEC_ID_ADPCM_EA:
102 case CODEC_ID_ADPCM_EA_R1:
103 case CODEC_ID_ADPCM_EA_R2:
104 case CODEC_ID_ADPCM_EA_R3:
105 case CODEC_ID_ADPCM_EA_XAS:
109 if (avctx->channels < min_channels || avctx->channels > max_channels) {
110 av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
111 return AVERROR(EINVAL);
114 switch(avctx->codec->id) {
115 case CODEC_ID_ADPCM_CT:
116 c->status[0].step = c->status[1].step = 511;
118 case CODEC_ID_ADPCM_IMA_WAV:
119 if (avctx->bits_per_coded_sample != 4) {
120 av_log(avctx, AV_LOG_ERROR, "Only 4-bit ADPCM IMA WAV files are supported\n");
124 case CODEC_ID_ADPCM_IMA_APC:
125 if (avctx->extradata && avctx->extradata_size >= 8) {
126 c->status[0].predictor = AV_RL32(avctx->extradata);
127 c->status[1].predictor = AV_RL32(avctx->extradata + 4);
130 case CODEC_ID_ADPCM_IMA_WS:
131 if (avctx->extradata && avctx->extradata_size >= 42)
132 c->vqa_version = AV_RL16(avctx->extradata);
137 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
139 avcodec_get_frame_defaults(&c->frame);
140 avctx->coded_frame = &c->frame;
145 static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble, int shift)
149 int sign, delta, diff, step;
151 step = ff_adpcm_step_table[c->step_index];
152 step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
153 step_index = av_clip(step_index, 0, 88);
157 /* perform direct multiplication instead of series of jumps proposed by
158 * the reference ADPCM implementation since modern CPUs can do the mults
160 diff = ((2 * delta + 1) * step) >> shift;
161 predictor = c->predictor;
162 if (sign) predictor -= diff;
163 else predictor += diff;
165 c->predictor = av_clip_int16(predictor);
166 c->step_index = step_index;
168 return (short)c->predictor;
171 static inline int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble, int shift)
177 step = ff_adpcm_step_table[c->step_index];
178 step_index = c->step_index + ff_adpcm_index_table[nibble];
179 step_index = av_clip(step_index, 0, 88);
182 if (nibble & 4) diff += step;
183 if (nibble & 2) diff += step >> 1;
184 if (nibble & 1) diff += step >> 2;
187 predictor = c->predictor - diff;
189 predictor = c->predictor + diff;
191 c->predictor = av_clip_int16(predictor);
192 c->step_index = step_index;
197 static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble)
201 predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 64;
202 predictor += ((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;
204 c->sample2 = c->sample1;
205 c->sample1 = av_clip_int16(predictor);
206 c->idelta = (ff_adpcm_AdaptationTable[(int)nibble] * c->idelta) >> 8;
207 if (c->idelta < 16) c->idelta = 16;
212 static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
214 int sign, delta, diff;
219 /* perform direct multiplication instead of series of jumps proposed by
220 * the reference ADPCM implementation since modern CPUs can do the mults
222 diff = ((2 * delta + 1) * c->step) >> 3;
223 /* predictor update is not so trivial: predictor is multiplied on 254/256 before updating */
224 c->predictor = ((c->predictor * 254) >> 8) + (sign ? -diff : diff);
225 c->predictor = av_clip_int16(c->predictor);
226 /* calculate new step and clamp it to range 511..32767 */
227 new_step = (ff_adpcm_AdaptationTable[nibble & 7] * c->step) >> 8;
228 c->step = av_clip(new_step, 511, 32767);
230 return (short)c->predictor;
233 static inline short adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, char nibble, int size, int shift)
235 int sign, delta, diff;
237 sign = nibble & (1<<(size-1));
238 delta = nibble & ((1<<(size-1))-1);
239 diff = delta << (7 + c->step + shift);
242 c->predictor = av_clip(c->predictor + (sign ? -diff : diff), -16384,16256);
244 /* calculate new step */
245 if (delta >= (2*size - 3) && c->step < 3)
247 else if (delta == 0 && c->step > 0)
250 return (short) c->predictor;
253 static inline short adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, unsigned char nibble)
260 c->predictor += (c->step * ff_adpcm_yamaha_difflookup[nibble]) / 8;
261 c->predictor = av_clip_int16(c->predictor);
262 c->step = (c->step * ff_adpcm_yamaha_indexscale[nibble]) >> 8;
263 c->step = av_clip(c->step, 127, 24567);
267 static int xa_decode(AVCodecContext *avctx,
268 short *out, const unsigned char *in,
269 ADPCMChannelStatus *left, ADPCMChannelStatus *right, int inc)
272 int shift,filter,f0,f1;
278 shift = 12 - (in[4+i*2] & 15);
279 filter = in[4+i*2] >> 4;
281 av_log(avctx, AV_LOG_ERROR,
282 "Invalid XA-ADPCM filter %d (max. allowed is 4)\n",
284 return AVERROR_INVALIDDATA;
286 f0 = xa_adpcm_table[filter][0];
287 f1 = xa_adpcm_table[filter][1];
295 t = sign_extend(d, 4);
296 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
298 s_1 = av_clip_int16(s);
303 if (inc==2) { /* stereo */
306 s_1 = right->sample1;
307 s_2 = right->sample2;
308 out = out + 1 - 28*2;
311 shift = 12 - (in[5+i*2] & 15);
312 filter = in[5+i*2] >> 4;
314 av_log(avctx, AV_LOG_ERROR,
315 "Invalid XA-ADPCM filter %d (max. allowed is 4)\n",
317 return AVERROR_INVALIDDATA;
319 f0 = xa_adpcm_table[filter][0];
320 f1 = xa_adpcm_table[filter][1];
325 t = sign_extend(d >> 4, 4);
326 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
328 s_1 = av_clip_int16(s);
333 if (inc==2) { /* stereo */
334 right->sample1 = s_1;
335 right->sample2 = s_2;
347 * Get the number of samples that will be decoded from the packet.
348 * In one case, this is actually the maximum number of samples possible to
349 * decode with the given buf_size.
351 * @param[out] coded_samples set to the number of samples as coded in the
352 * packet, or 0 if the codec does not encode the
353 * number of samples in each frame.
355 static int get_nb_samples(AVCodecContext *avctx, const uint8_t *buf,
357 int buf_size, int *coded_samples)
359 ADPCMDecodeContext *s = avctx->priv_data;
361 int ch = avctx->channels;
362 int has_coded_samples = 0;
367 switch (avctx->codec->id) {
368 /* constant, only check buf_size */
369 case CODEC_ID_ADPCM_EA_XAS:
370 if (buf_size < 76 * ch)
374 case CODEC_ID_ADPCM_IMA_QT:
375 if (buf_size < 34 * ch)
379 /* simple 4-bit adpcm */
380 case CODEC_ID_ADPCM_CT:
381 case CODEC_ID_ADPCM_IMA_APC:
382 case CODEC_ID_ADPCM_IMA_EA_SEAD:
383 case CODEC_ID_ADPCM_IMA_WS:
384 case CODEC_ID_ADPCM_YAMAHA:
385 nb_samples = buf_size * 2 / ch;
391 /* simple 4-bit adpcm, with header */
393 switch (avctx->codec->id) {
394 case CODEC_ID_ADPCM_4XM:
395 case CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break;
396 case CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break;
397 case CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4; break;
400 return (buf_size - header_size) * 2 / ch;
402 /* more complex formats */
403 switch (avctx->codec->id) {
404 case CODEC_ID_ADPCM_EA:
405 has_coded_samples = 1;
406 *coded_samples = bytestream2_get_le32(gb);
407 *coded_samples -= *coded_samples % 28;
408 nb_samples = (buf_size - 12) / 30 * 28;
410 case CODEC_ID_ADPCM_IMA_EA_EACS:
411 has_coded_samples = 1;
412 *coded_samples = bytestream2_get_le32(gb);
413 nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
415 case CODEC_ID_ADPCM_EA_MAXIS_XA:
416 nb_samples = (buf_size - ch) / ch * 2;
418 case CODEC_ID_ADPCM_EA_R1:
419 case CODEC_ID_ADPCM_EA_R2:
420 case CODEC_ID_ADPCM_EA_R3:
421 /* maximum number of samples */
422 /* has internal offsets and a per-frame switch to signal raw 16-bit */
423 has_coded_samples = 1;
424 switch (avctx->codec->id) {
425 case CODEC_ID_ADPCM_EA_R1:
426 header_size = 4 + 9 * ch;
427 *coded_samples = bytestream2_get_le32(gb);
429 case CODEC_ID_ADPCM_EA_R2:
430 header_size = 4 + 5 * ch;
431 *coded_samples = bytestream2_get_le32(gb);
433 case CODEC_ID_ADPCM_EA_R3:
434 header_size = 4 + 5 * ch;
435 *coded_samples = bytestream2_get_be32(gb);
438 *coded_samples -= *coded_samples % 28;
439 nb_samples = (buf_size - header_size) * 2 / ch;
440 nb_samples -= nb_samples % 28;
442 case CODEC_ID_ADPCM_IMA_DK3:
443 if (avctx->block_align > 0)
444 buf_size = FFMIN(buf_size, avctx->block_align);
445 nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
447 case CODEC_ID_ADPCM_IMA_DK4:
448 if (avctx->block_align > 0)
449 buf_size = FFMIN(buf_size, avctx->block_align);
450 nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
452 case CODEC_ID_ADPCM_IMA_WAV:
453 if (avctx->block_align > 0)
454 buf_size = FFMIN(buf_size, avctx->block_align);
455 nb_samples = 1 + (buf_size - 4 * ch) / (4 * ch) * 8;
457 case CODEC_ID_ADPCM_MS:
458 if (avctx->block_align > 0)
459 buf_size = FFMIN(buf_size, avctx->block_align);
460 nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;
462 case CODEC_ID_ADPCM_SBPRO_2:
463 case CODEC_ID_ADPCM_SBPRO_3:
464 case CODEC_ID_ADPCM_SBPRO_4:
466 int samples_per_byte;
467 switch (avctx->codec->id) {
468 case CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break;
469 case CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break;
470 case CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;
472 if (!s->status[0].step_index) {
476 nb_samples += buf_size * samples_per_byte / ch;
479 case CODEC_ID_ADPCM_SWF:
481 int buf_bits = buf_size * 8 - 2;
482 int nbits = (buf[0] >> 6) + 2;
483 int block_hdr_size = 22 * ch;
484 int block_size = block_hdr_size + nbits * ch * 4095;
485 int nblocks = buf_bits / block_size;
486 int bits_left = buf_bits - nblocks * block_size;
487 nb_samples = nblocks * 4096;
488 if (bits_left >= block_hdr_size)
489 nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
492 case CODEC_ID_ADPCM_THP:
493 has_coded_samples = 1;
496 *coded_samples = AV_RB32(&buf[4]);
497 *coded_samples -= *coded_samples % 14;
498 nb_samples = (buf_size - 80) / (8 * ch) * 14;
500 case CODEC_ID_ADPCM_XA:
501 nb_samples = (buf_size / 128) * 224 / ch;
505 /* validate coded sample count */
506 if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
507 return AVERROR_INVALIDDATA;
512 static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
513 int *got_frame_ptr, AVPacket *avpkt)
515 const uint8_t *buf = avpkt->data;
516 int buf_size = avpkt->size;
517 ADPCMDecodeContext *c = avctx->priv_data;
518 ADPCMChannelStatus *cs;
519 int n, m, channel, i;
524 int nb_samples, coded_samples, ret;
527 bytestream2_init(&gb, buf, buf_size);
528 nb_samples = get_nb_samples(avctx, buf, &gb, buf_size, &coded_samples);
529 if (nb_samples <= 0) {
530 av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
531 return AVERROR_INVALIDDATA;
534 /* get output buffer */
535 c->frame.nb_samples = nb_samples;
536 if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
537 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
540 samples = (short *)c->frame.data[0];
542 /* use coded_samples when applicable */
543 /* it is always <= nb_samples, so the output buffer will be large enough */
545 if (coded_samples != nb_samples)
546 av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
547 c->frame.nb_samples = nb_samples = coded_samples;
552 st = avctx->channels == 2 ? 1 : 0;
554 switch(avctx->codec->id) {
555 case CODEC_ID_ADPCM_IMA_QT:
556 /* In QuickTime, IMA is encoded by chunks of 34 bytes (=64 samples).
557 Channel data is interleaved per-chunk. */
558 for (channel = 0; channel < avctx->channels; channel++) {
561 cs = &(c->status[channel]);
562 /* (pppppp) (piiiiiii) */
564 /* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */
565 predictor = sign_extend(bytestream2_get_be16u(&gb), 16);
566 step_index = predictor & 0x7F;
569 if (cs->step_index == step_index) {
570 int diff = predictor - cs->predictor;
577 cs->step_index = step_index;
578 cs->predictor = predictor;
581 if (cs->step_index > 88u){
582 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
583 channel, cs->step_index);
584 return AVERROR_INVALIDDATA;
587 samples = (short *)c->frame.data[0] + channel;
589 for (m = 0; m < 32; m++) {
590 int byte = bytestream2_get_byteu(&gb);
591 *samples = adpcm_ima_qt_expand_nibble(cs, byte & 0x0F, 3);
592 samples += avctx->channels;
593 *samples = adpcm_ima_qt_expand_nibble(cs, byte >> 4 , 3);
594 samples += avctx->channels;
598 case CODEC_ID_ADPCM_IMA_WAV:
599 for(i=0; i<avctx->channels; i++){
600 cs = &(c->status[i]);
601 cs->predictor = *samples++ = sign_extend(bytestream2_get_le16u(&gb), 16);
603 cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
604 if (cs->step_index > 88u){
605 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
607 return AVERROR_INVALIDDATA;
611 for (n = (nb_samples - 1) / 8; n > 0; n--) {
612 for (i = 0; i < avctx->channels; i++) {
614 for (m = 0; m < 4; m++) {
615 int v = bytestream2_get_byteu(&gb);
616 *samples = adpcm_ima_expand_nibble(cs, v & 0x0F, 3);
617 samples += avctx->channels;
618 *samples = adpcm_ima_expand_nibble(cs, v >> 4 , 3);
619 samples += avctx->channels;
621 samples -= 8 * avctx->channels - 1;
623 samples += 7 * avctx->channels;
626 case CODEC_ID_ADPCM_4XM:
627 for (i = 0; i < avctx->channels; i++)
628 c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
630 for (i = 0; i < avctx->channels; i++) {
631 c->status[i].step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
632 if (c->status[i].step_index > 88u) {
633 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
634 i, c->status[i].step_index);
635 return AVERROR_INVALIDDATA;
639 for (i = 0; i < avctx->channels; i++) {
640 samples = (short *)c->frame.data[0] + i;
642 for (n = nb_samples >> 1; n > 0; n--) {
643 int v = bytestream2_get_byteu(&gb);
644 *samples = adpcm_ima_expand_nibble(cs, v & 0x0F, 4);
645 samples += avctx->channels;
646 *samples = adpcm_ima_expand_nibble(cs, v >> 4 , 4);
647 samples += avctx->channels;
651 case CODEC_ID_ADPCM_MS:
655 block_predictor = bytestream2_get_byteu(&gb);
656 if (block_predictor > 6) {
657 av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[0] = %d\n",
659 return AVERROR_INVALIDDATA;
661 c->status[0].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
662 c->status[0].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
664 block_predictor = bytestream2_get_byteu(&gb);
665 if (block_predictor > 6) {
666 av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[1] = %d\n",
668 return AVERROR_INVALIDDATA;
670 c->status[1].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
671 c->status[1].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
673 c->status[0].idelta = sign_extend(bytestream2_get_le16u(&gb), 16);
675 c->status[1].idelta = sign_extend(bytestream2_get_le16u(&gb), 16);
678 c->status[0].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16);
679 if (st) c->status[1].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16);
680 c->status[0].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16);
681 if (st) c->status[1].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16);
683 *samples++ = c->status[0].sample2;
684 if (st) *samples++ = c->status[1].sample2;
685 *samples++ = c->status[0].sample1;
686 if (st) *samples++ = c->status[1].sample1;
687 for(n = (nb_samples - 2) >> (1 - st); n > 0; n--) {
688 int byte = bytestream2_get_byteu(&gb);
689 *samples++ = adpcm_ms_expand_nibble(&c->status[0 ], byte >> 4 );
690 *samples++ = adpcm_ms_expand_nibble(&c->status[st], byte & 0x0F);
694 case CODEC_ID_ADPCM_IMA_DK4:
695 for (channel = 0; channel < avctx->channels; channel++) {
696 cs = &c->status[channel];
697 cs->predictor = *samples++ = sign_extend(bytestream2_get_le16u(&gb), 16);
698 cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
699 if (cs->step_index > 88u){
700 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
701 channel, cs->step_index);
702 return AVERROR_INVALIDDATA;
705 for (n = nb_samples >> (1 - st); n > 0; n--) {
706 int v = bytestream2_get_byteu(&gb);
707 *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v >> 4 , 3);
708 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
711 case CODEC_ID_ADPCM_IMA_DK3:
715 int decode_top_nibble_next = 0;
717 const int16_t *samples_end = samples + avctx->channels * nb_samples;
719 bytestream2_skipu(&gb, 10);
720 c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
721 c->status[1].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
722 c->status[0].step_index = bytestream2_get_byteu(&gb);
723 c->status[1].step_index = bytestream2_get_byteu(&gb);
724 if (c->status[0].step_index > 88u || c->status[1].step_index > 88u){
725 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i/%i\n",
726 c->status[0].step_index, c->status[1].step_index);
727 return AVERROR_INVALIDDATA;
729 /* sign extend the predictors */
730 diff_channel = c->status[1].predictor;
732 /* DK3 ADPCM support macro */
733 #define DK3_GET_NEXT_NIBBLE() \
734 if (decode_top_nibble_next) { \
735 nibble = last_byte >> 4; \
736 decode_top_nibble_next = 0; \
738 last_byte = bytestream2_get_byteu(&gb); \
739 nibble = last_byte & 0x0F; \
740 decode_top_nibble_next = 1; \
743 while (samples < samples_end) {
745 /* for this algorithm, c->status[0] is the sum channel and
746 * c->status[1] is the diff channel */
748 /* process the first predictor of the sum channel */
749 DK3_GET_NEXT_NIBBLE();
750 adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
752 /* process the diff channel predictor */
753 DK3_GET_NEXT_NIBBLE();
754 adpcm_ima_expand_nibble(&c->status[1], nibble, 3);
756 /* process the first pair of stereo PCM samples */
757 diff_channel = (diff_channel + c->status[1].predictor) / 2;
758 *samples++ = c->status[0].predictor + c->status[1].predictor;
759 *samples++ = c->status[0].predictor - c->status[1].predictor;
761 /* process the second predictor of the sum channel */
762 DK3_GET_NEXT_NIBBLE();
763 adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
765 /* process the second pair of stereo PCM samples */
766 diff_channel = (diff_channel + c->status[1].predictor) / 2;
767 *samples++ = c->status[0].predictor + c->status[1].predictor;
768 *samples++ = c->status[0].predictor - c->status[1].predictor;
772 case CODEC_ID_ADPCM_IMA_ISS:
773 for (channel = 0; channel < avctx->channels; channel++) {
774 cs = &c->status[channel];
775 cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
776 cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
777 if (cs->step_index > 88u){
778 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
779 channel, cs->step_index);
780 return AVERROR_INVALIDDATA;
784 for (n = nb_samples >> (1 - st); n > 0; n--) {
786 int v = bytestream2_get_byteu(&gb);
787 /* nibbles are swapped for mono */
795 *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v1, 3);
796 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3);
799 case CODEC_ID_ADPCM_IMA_APC:
800 while (bytestream2_get_bytes_left(&gb) > 0) {
801 int v = bytestream2_get_byteu(&gb);
802 *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4 , 3);
803 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
806 case CODEC_ID_ADPCM_IMA_WS:
807 if (c->vqa_version == 3) {
808 for (channel = 0; channel < avctx->channels; channel++) {
809 int16_t *smp = samples + channel;
811 for (n = nb_samples / 2; n > 0; n--) {
812 int v = bytestream2_get_byteu(&gb);
813 *smp = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3);
814 smp += avctx->channels;
815 *smp = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3);
816 smp += avctx->channels;
820 for (n = nb_samples / 2; n > 0; n--) {
821 for (channel = 0; channel < avctx->channels; channel++) {
822 int v = bytestream2_get_byteu(&gb);
823 *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3);
824 samples[st] = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3);
826 samples += avctx->channels;
829 bytestream2_seek(&gb, 0, SEEK_END);
831 case CODEC_ID_ADPCM_XA:
832 while (bytestream2_get_bytes_left(&gb) >= 128) {
833 if ((ret = xa_decode(avctx, samples, buf + bytestream2_tell(&gb), &c->status[0],
834 &c->status[1], avctx->channels)) < 0)
836 bytestream2_skipu(&gb, 128);
840 case CODEC_ID_ADPCM_IMA_EA_EACS:
841 for (i=0; i<=st; i++) {
842 c->status[i].step_index = bytestream2_get_le32u(&gb);
843 if (c->status[i].step_index > 88u) {
844 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
845 i, c->status[i].step_index);
846 return AVERROR_INVALIDDATA;
849 for (i=0; i<=st; i++)
850 c->status[i].predictor = bytestream2_get_le32u(&gb);
852 for (n = nb_samples >> (1 - st); n > 0; n--) {
853 int byte = bytestream2_get_byteu(&gb);
854 *samples++ = adpcm_ima_expand_nibble(&c->status[0], byte >> 4, 3);
855 *samples++ = adpcm_ima_expand_nibble(&c->status[st], byte & 0x0F, 3);
858 case CODEC_ID_ADPCM_IMA_EA_SEAD:
859 for (n = nb_samples >> (1 - st); n > 0; n--) {
860 int byte = bytestream2_get_byteu(&gb);
861 *samples++ = adpcm_ima_expand_nibble(&c->status[0], byte >> 4, 6);
862 *samples++ = adpcm_ima_expand_nibble(&c->status[st], byte & 0x0F, 6);
865 case CODEC_ID_ADPCM_EA:
867 int previous_left_sample, previous_right_sample;
868 int current_left_sample, current_right_sample;
869 int next_left_sample, next_right_sample;
870 int coeff1l, coeff2l, coeff1r, coeff2r;
871 int shift_left, shift_right;
873 /* Each EA ADPCM frame has a 12-byte header followed by 30-byte pieces,
874 each coding 28 stereo samples. */
876 current_left_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
877 previous_left_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
878 current_right_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
879 previous_right_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
881 for (count1 = 0; count1 < nb_samples / 28; count1++) {
882 int byte = bytestream2_get_byteu(&gb);
883 coeff1l = ea_adpcm_table[ byte >> 4 ];
884 coeff2l = ea_adpcm_table[(byte >> 4 ) + 4];
885 coeff1r = ea_adpcm_table[ byte & 0x0F];
886 coeff2r = ea_adpcm_table[(byte & 0x0F) + 4];
888 byte = bytestream2_get_byteu(&gb);
889 shift_left = 20 - (byte >> 4);
890 shift_right = 20 - (byte & 0x0F);
892 for (count2 = 0; count2 < 28; count2++) {
893 byte = bytestream2_get_byteu(&gb);
894 next_left_sample = sign_extend(byte >> 4, 4) << shift_left;
895 next_right_sample = sign_extend(byte, 4) << shift_right;
897 next_left_sample = (next_left_sample +
898 (current_left_sample * coeff1l) +
899 (previous_left_sample * coeff2l) + 0x80) >> 8;
900 next_right_sample = (next_right_sample +
901 (current_right_sample * coeff1r) +
902 (previous_right_sample * coeff2r) + 0x80) >> 8;
904 previous_left_sample = current_left_sample;
905 current_left_sample = av_clip_int16(next_left_sample);
906 previous_right_sample = current_right_sample;
907 current_right_sample = av_clip_int16(next_right_sample);
908 *samples++ = current_left_sample;
909 *samples++ = current_right_sample;
913 bytestream2_skip(&gb, 2); // Skip terminating 0x0000
917 case CODEC_ID_ADPCM_EA_MAXIS_XA:
919 int coeff[2][2], shift[2];
921 for(channel = 0; channel < avctx->channels; channel++) {
922 int byte = bytestream2_get_byteu(&gb);
924 coeff[channel][i] = ea_adpcm_table[(byte >> 4) + 4*i];
925 shift[channel] = 20 - (byte & 0x0F);
927 for (count1 = 0; count1 < nb_samples / 2; count1++) {
930 byte[0] = bytestream2_get_byteu(&gb);
931 if (st) byte[1] = bytestream2_get_byteu(&gb);
932 for(i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */
933 for(channel = 0; channel < avctx->channels; channel++) {
934 int sample = sign_extend(byte[channel] >> i, 4) << shift[channel];
936 c->status[channel].sample1 * coeff[channel][0] +
937 c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8;
938 c->status[channel].sample2 = c->status[channel].sample1;
939 c->status[channel].sample1 = av_clip_int16(sample);
940 *samples++ = c->status[channel].sample1;
944 bytestream2_seek(&gb, 0, SEEK_END);
947 case CODEC_ID_ADPCM_EA_R1:
948 case CODEC_ID_ADPCM_EA_R2:
949 case CODEC_ID_ADPCM_EA_R3: {
952 4chan: 0=fl, 1=rl, 2=fr, 3=rr
953 6chan: 0=fl, 1=c, 2=fr, 3=rl, 4=rr, 5=sub */
954 const int big_endian = avctx->codec->id == CODEC_ID_ADPCM_EA_R3;
955 int previous_sample, current_sample, next_sample;
958 unsigned int channel;
963 for (channel=0; channel<avctx->channels; channel++)
964 offsets[channel] = (big_endian ? bytestream2_get_be32(&gb) :
965 bytestream2_get_le32(&gb)) +
966 (avctx->channels + 1) * 4;
968 for (channel=0; channel<avctx->channels; channel++) {
969 bytestream2_seek(&gb, offsets[channel], SEEK_SET);
970 samplesC = samples + channel;
972 if (avctx->codec->id == CODEC_ID_ADPCM_EA_R1) {
973 current_sample = sign_extend(bytestream2_get_le16(&gb), 16);
974 previous_sample = sign_extend(bytestream2_get_le16(&gb), 16);
976 current_sample = c->status[channel].predictor;
977 previous_sample = c->status[channel].prev_sample;
980 for (count1 = 0; count1 < nb_samples / 28; count1++) {
981 int byte = bytestream2_get_byte(&gb);
982 if (byte == 0xEE) { /* only seen in R2 and R3 */
983 current_sample = sign_extend(bytestream2_get_be16(&gb), 16);
984 previous_sample = sign_extend(bytestream2_get_be16(&gb), 16);
986 for (count2=0; count2<28; count2++) {
987 *samplesC = sign_extend(bytestream2_get_be16(&gb), 16);
988 samplesC += avctx->channels;
991 coeff1 = ea_adpcm_table[ byte >> 4 ];
992 coeff2 = ea_adpcm_table[(byte >> 4) + 4];
993 shift = 20 - (byte & 0x0F);
995 for (count2=0; count2<28; count2++) {
997 next_sample = sign_extend(byte, 4) << shift;
999 byte = bytestream2_get_byte(&gb);
1000 next_sample = sign_extend(byte >> 4, 4) << shift;
1003 next_sample += (current_sample * coeff1) +
1004 (previous_sample * coeff2);
1005 next_sample = av_clip_int16(next_sample >> 8);
1007 previous_sample = current_sample;
1008 current_sample = next_sample;
1009 *samplesC = current_sample;
1010 samplesC += avctx->channels;
1016 } else if (count != count1) {
1017 av_log(avctx, AV_LOG_WARNING, "per-channel sample count mismatch\n");
1018 count = FFMAX(count, count1);
1021 if (avctx->codec->id != CODEC_ID_ADPCM_EA_R1) {
1022 c->status[channel].predictor = current_sample;
1023 c->status[channel].prev_sample = previous_sample;
1027 c->frame.nb_samples = count * 28;
1028 bytestream2_seek(&gb, 0, SEEK_END);
1031 case CODEC_ID_ADPCM_EA_XAS:
1032 for (channel=0; channel<avctx->channels; channel++) {
1033 int coeff[2][4], shift[4];
1034 short *s2, *s = &samples[channel];
1035 for (n=0; n<4; n++, s+=32*avctx->channels) {
1036 int val = sign_extend(bytestream2_get_le16u(&gb), 16);
1038 coeff[i][n] = ea_adpcm_table[(val&0x0F)+4*i];
1041 val = sign_extend(bytestream2_get_le16u(&gb), 16);
1042 shift[n] = 20 - (val & 0x0F);
1043 s[avctx->channels] = val & ~0x0F;
1046 for (m=2; m<32; m+=2) {
1047 s = &samples[m*avctx->channels + channel];
1048 for (n=0; n<4; n++, s+=32*avctx->channels) {
1049 int byte = bytestream2_get_byteu(&gb);
1050 for (s2=s, i=0; i<8; i+=4, s2+=avctx->channels) {
1051 int level = sign_extend(byte >> (4 - i), 4) << shift[n];
1052 int pred = s2[-1*avctx->channels] * coeff[0][n]
1053 + s2[-2*avctx->channels] * coeff[1][n];
1054 s2[0] = av_clip_int16((level + pred + 0x80) >> 8);
1060 case CODEC_ID_ADPCM_IMA_AMV:
1061 case CODEC_ID_ADPCM_IMA_SMJPEG:
1062 if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) {
1063 c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
1064 c->status[0].step_index = bytestream2_get_le16u(&gb);
1065 bytestream2_skipu(&gb, 4);
1067 c->status[0].predictor = sign_extend(bytestream2_get_be16u(&gb), 16);
1068 c->status[0].step_index = bytestream2_get_byteu(&gb);
1069 bytestream2_skipu(&gb, 1);
1071 if (c->status[0].step_index > 88u) {
1072 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n",
1073 c->status[0].step_index);
1074 return AVERROR_INVALIDDATA;
1077 for (n = nb_samples >> (1 - st); n > 0; n--) {
1078 int hi, lo, v = bytestream2_get_byteu(&gb);
1080 if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) {
1088 *samples++ = adpcm_ima_expand_nibble(&c->status[0], lo, 3);
1089 *samples++ = adpcm_ima_expand_nibble(&c->status[0], hi, 3);
1092 case CODEC_ID_ADPCM_CT:
1093 for (n = nb_samples >> (1 - st); n > 0; n--) {
1094 int v = bytestream2_get_byteu(&gb);
1095 *samples++ = adpcm_ct_expand_nibble(&c->status[0 ], v >> 4 );
1096 *samples++ = adpcm_ct_expand_nibble(&c->status[st], v & 0x0F);
1099 case CODEC_ID_ADPCM_SBPRO_4:
1100 case CODEC_ID_ADPCM_SBPRO_3:
1101 case CODEC_ID_ADPCM_SBPRO_2:
1102 if (!c->status[0].step_index) {
1103 /* the first byte is a raw sample */
1104 *samples++ = 128 * (*src++ - 0x80);
1106 *samples++ = 128 * (*src++ - 0x80);
1107 c->status[0].step_index = 1;
1110 if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_4) {
1111 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
1112 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1114 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
1115 src[0] & 0x0F, 4, 0);
1117 } else if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_3) {
1118 for (n = nb_samples / 3; n > 0; n--, src++) {
1119 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1120 src[0] >> 5 , 3, 0);
1121 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1122 (src[0] >> 2) & 0x07, 3, 0);
1123 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1124 src[0] & 0x03, 2, 0);
1127 for (n = nb_samples >> (2 - st); n > 0; n--, src++) {
1128 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1129 src[0] >> 6 , 2, 2);
1130 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
1131 (src[0] >> 4) & 0x03, 2, 2);
1132 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1133 (src[0] >> 2) & 0x03, 2, 2);
1134 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
1135 src[0] & 0x03, 2, 2);
1139 case CODEC_ID_ADPCM_SWF:
1143 int k0, signmask, nb_bits, count;
1144 int size = buf_size*8;
1146 init_get_bits(&gb, buf, size);
1148 //read bits & initial values
1149 nb_bits = get_bits(&gb, 2)+2;
1150 //av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", nb_bits);
1151 table = swf_index_tables[nb_bits-2];
1152 k0 = 1 << (nb_bits-2);
1153 signmask = 1 << (nb_bits-1);
1155 while (get_bits_count(&gb) <= size - 22*avctx->channels) {
1156 for (i = 0; i < avctx->channels; i++) {
1157 *samples++ = c->status[i].predictor = get_sbits(&gb, 16);
1158 c->status[i].step_index = get_bits(&gb, 6);
1161 for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) {
1164 for (i = 0; i < avctx->channels; i++) {
1165 // similar to IMA adpcm
1166 int delta = get_bits(&gb, nb_bits);
1167 int step = ff_adpcm_step_table[c->status[i].step_index];
1168 long vpdiff = 0; // vpdiff = (delta+0.5)*step/4
1179 if (delta & signmask)
1180 c->status[i].predictor -= vpdiff;
1182 c->status[i].predictor += vpdiff;
1184 c->status[i].step_index += table[delta & (~signmask)];
1186 c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
1187 c->status[i].predictor = av_clip_int16(c->status[i].predictor);
1189 *samples++ = c->status[i].predictor;
1196 case CODEC_ID_ADPCM_YAMAHA:
1197 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
1199 *samples++ = adpcm_yamaha_expand_nibble(&c->status[0 ], v & 0x0F);
1200 *samples++ = adpcm_yamaha_expand_nibble(&c->status[st], v >> 4 );
1203 case CODEC_ID_ADPCM_THP:
1209 src += 4; // skip channel size
1210 src += 4; // skip number of samples (already read)
1212 for (i = 0; i < 32; i++)
1213 table[0][i] = (int16_t)bytestream_get_be16(&src);
1215 /* Initialize the previous sample. */
1216 for (i = 0; i < 4; i++)
1217 prev[0][i] = (int16_t)bytestream_get_be16(&src);
1219 for (ch = 0; ch <= st; ch++) {
1220 samples = (short *)c->frame.data[0] + ch;
1222 /* Read in every sample for this channel. */
1223 for (i = 0; i < nb_samples / 14; i++) {
1224 int index = (*src >> 4) & 7;
1225 unsigned int exp = *src++ & 15;
1226 int factor1 = table[ch][index * 2];
1227 int factor2 = table[ch][index * 2 + 1];
1229 /* Decode 14 samples. */
1230 for (n = 0; n < 14; n++) {
1232 if(n&1) sampledat = sign_extend(*src++, 4);
1233 else sampledat = sign_extend(*src >> 4, 4);
1235 sampledat = ((prev[ch][0]*factor1
1236 + prev[ch][1]*factor2) >> 11) + (sampledat << exp);
1237 *samples = av_clip_int16(sampledat);
1238 prev[ch][1] = prev[ch][0];
1239 prev[ch][0] = *samples++;
1241 /* In case of stereo, skip one sample, this sample
1242 is for the other channel. */
1255 *(AVFrame *)data = c->frame;
1257 return src == buf ? bytestream2_tell(&gb) : src - buf;
1261 #define ADPCM_DECODER(id_, name_, long_name_) \
1262 AVCodec ff_ ## name_ ## _decoder = { \
1264 .type = AVMEDIA_TYPE_AUDIO, \
1266 .priv_data_size = sizeof(ADPCMDecodeContext), \
1267 .init = adpcm_decode_init, \
1268 .decode = adpcm_decode_frame, \
1269 .capabilities = CODEC_CAP_DR1, \
1270 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
1273 /* Note: Do not forget to add new entries to the Makefile as well. */
1274 ADPCM_DECODER(CODEC_ID_ADPCM_4XM, adpcm_4xm, "ADPCM 4X Movie");
1275 ADPCM_DECODER(CODEC_ID_ADPCM_CT, adpcm_ct, "ADPCM Creative Technology");
1276 ADPCM_DECODER(CODEC_ID_ADPCM_EA, adpcm_ea, "ADPCM Electronic Arts");
1277 ADPCM_DECODER(CODEC_ID_ADPCM_EA_MAXIS_XA, adpcm_ea_maxis_xa, "ADPCM Electronic Arts Maxis CDROM XA");
1278 ADPCM_DECODER(CODEC_ID_ADPCM_EA_R1, adpcm_ea_r1, "ADPCM Electronic Arts R1");
1279 ADPCM_DECODER(CODEC_ID_ADPCM_EA_R2, adpcm_ea_r2, "ADPCM Electronic Arts R2");
1280 ADPCM_DECODER(CODEC_ID_ADPCM_EA_R3, adpcm_ea_r3, "ADPCM Electronic Arts R3");
1281 ADPCM_DECODER(CODEC_ID_ADPCM_EA_XAS, adpcm_ea_xas, "ADPCM Electronic Arts XAS");
1282 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_AMV, adpcm_ima_amv, "ADPCM IMA AMV");
1283 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_APC, adpcm_ima_apc, "ADPCM IMA CRYO APC");
1284 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3, "ADPCM IMA Duck DK3");
1285 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4, "ADPCM IMA Duck DK4");
1286 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS");
1287 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead, "ADPCM IMA Electronic Arts SEAD");
1288 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_ISS, adpcm_ima_iss, "ADPCM IMA Funcom ISS");
1289 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt, "ADPCM IMA QuickTime");
1290 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg, "ADPCM IMA Loki SDL MJPEG");
1291 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav, "ADPCM IMA WAV");
1292 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws, "ADPCM IMA Westwood");
1293 ADPCM_DECODER(CODEC_ID_ADPCM_MS, adpcm_ms, "ADPCM Microsoft");
1294 ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2, "ADPCM Sound Blaster Pro 2-bit");
1295 ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3, "ADPCM Sound Blaster Pro 2.6-bit");
1296 ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4, "ADPCM Sound Blaster Pro 4-bit");
1297 ADPCM_DECODER(CODEC_ID_ADPCM_SWF, adpcm_swf, "ADPCM Shockwave Flash");
1298 ADPCM_DECODER(CODEC_ID_ADPCM_THP, adpcm_thp, "ADPCM Nintendo Gamecube THP");
1299 ADPCM_DECODER(CODEC_ID_ADPCM_XA, adpcm_xa, "ADPCM CDROM XA");
1300 ADPCM_DECODER(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha, "ADPCM Yamaha");