00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "avcodec.h"
00021 #include "get_bits.h"
00022 #include "put_bits.h"
00023 #include "bytestream.h"
00024 #include "adpcm.h"
00025 #include "adpcm_data.h"
00026
00059
00060 static const int xa_adpcm_table[5][2] = {
00061 { 0, 0 },
00062 { 60, 0 },
00063 { 115, -52 },
00064 { 98, -55 },
00065 { 122, -60 }
00066 };
00067
00068 static const int ea_adpcm_table[] = {
00069 0, 240, 460, 392,
00070 0, 0, -208, -220,
00071 0, 1, 3, 4,
00072 7, 8, 10, 11,
00073 0, -1, -3, -4
00074 };
00075
00076
00077 static const int swf_index_tables[4][16] = {
00078 { -1, 2 },
00079 { -1, -1, 2, 4 },
00080 { -1, -1, -1, -1, 2, 4, 6, 8 },
00081 { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }
00082 };
00083
00084
00085
00086 typedef struct ADPCMDecodeContext {
00087 AVFrame frame;
00088 ADPCMChannelStatus status[6];
00089 } ADPCMDecodeContext;
00090
00091 static av_cold int adpcm_decode_init(AVCodecContext * avctx)
00092 {
00093 ADPCMDecodeContext *c = avctx->priv_data;
00094 unsigned int max_channels = 2;
00095
00096 switch(avctx->codec->id) {
00097 case CODEC_ID_ADPCM_EA_R1:
00098 case CODEC_ID_ADPCM_EA_R2:
00099 case CODEC_ID_ADPCM_EA_R3:
00100 case CODEC_ID_ADPCM_EA_XAS:
00101 max_channels = 6;
00102 break;
00103 }
00104 if (avctx->channels <= 0 || avctx->channels > max_channels) {
00105 av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
00106 return AVERROR(EINVAL);
00107 }
00108
00109 switch(avctx->codec->id) {
00110 case CODEC_ID_ADPCM_CT:
00111 c->status[0].step = c->status[1].step = 511;
00112 break;
00113 case CODEC_ID_ADPCM_IMA_WAV:
00114 if (avctx->bits_per_coded_sample != 4) {
00115 av_log(avctx, AV_LOG_ERROR, "Only 4-bit ADPCM IMA WAV files are supported\n");
00116 return -1;
00117 }
00118 break;
00119 case CODEC_ID_ADPCM_IMA_WS:
00120 if (avctx->extradata && avctx->extradata_size == 2 * 4) {
00121 c->status[0].predictor = AV_RL32(avctx->extradata);
00122 c->status[1].predictor = AV_RL32(avctx->extradata + 4);
00123 }
00124 break;
00125 default:
00126 break;
00127 }
00128 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
00129
00130 avcodec_get_frame_defaults(&c->frame);
00131 avctx->coded_frame = &c->frame;
00132
00133 return 0;
00134 }
00135
00136 static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble, int shift)
00137 {
00138 int step_index;
00139 int predictor;
00140 int sign, delta, diff, step;
00141
00142 step = ff_adpcm_step_table[c->step_index];
00143 step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
00144 if (step_index < 0) step_index = 0;
00145 else if (step_index > 88) step_index = 88;
00146
00147 sign = nibble & 8;
00148 delta = nibble & 7;
00149
00150
00151
00152 diff = ((2 * delta + 1) * step) >> shift;
00153 predictor = c->predictor;
00154 if (sign) predictor -= diff;
00155 else predictor += diff;
00156
00157 c->predictor = av_clip_int16(predictor);
00158 c->step_index = step_index;
00159
00160 return (short)c->predictor;
00161 }
00162
00163 static inline int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble, int shift)
00164 {
00165 int step_index;
00166 int predictor;
00167 int diff, step;
00168
00169 step = ff_adpcm_step_table[c->step_index];
00170 step_index = c->step_index + ff_adpcm_index_table[nibble];
00171 step_index = av_clip(step_index, 0, 88);
00172
00173 diff = step >> 3;
00174 if (nibble & 4) diff += step;
00175 if (nibble & 2) diff += step >> 1;
00176 if (nibble & 1) diff += step >> 2;
00177
00178 if (nibble & 8)
00179 predictor = c->predictor - diff;
00180 else
00181 predictor = c->predictor + diff;
00182
00183 c->predictor = av_clip_int16(predictor);
00184 c->step_index = step_index;
00185
00186 return c->predictor;
00187 }
00188
00189 static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, char nibble)
00190 {
00191 int predictor;
00192
00193 predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 64;
00194 predictor += (signed)((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;
00195
00196 c->sample2 = c->sample1;
00197 c->sample1 = av_clip_int16(predictor);
00198 c->idelta = (ff_adpcm_AdaptationTable[(int)nibble] * c->idelta) >> 8;
00199 if (c->idelta < 16) c->idelta = 16;
00200
00201 return c->sample1;
00202 }
00203
00204 static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
00205 {
00206 int sign, delta, diff;
00207 int new_step;
00208
00209 sign = nibble & 8;
00210 delta = nibble & 7;
00211
00212
00213
00214 diff = ((2 * delta + 1) * c->step) >> 3;
00215
00216 c->predictor = ((c->predictor * 254) >> 8) + (sign ? -diff : diff);
00217 c->predictor = av_clip_int16(c->predictor);
00218
00219 new_step = (ff_adpcm_AdaptationTable[nibble & 7] * c->step) >> 8;
00220 c->step = av_clip(new_step, 511, 32767);
00221
00222 return (short)c->predictor;
00223 }
00224
00225 static inline short adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, char nibble, int size, int shift)
00226 {
00227 int sign, delta, diff;
00228
00229 sign = nibble & (1<<(size-1));
00230 delta = nibble & ((1<<(size-1))-1);
00231 diff = delta << (7 + c->step + shift);
00232
00233
00234 c->predictor = av_clip(c->predictor + (sign ? -diff : diff), -16384,16256);
00235
00236
00237 if (delta >= (2*size - 3) && c->step < 3)
00238 c->step++;
00239 else if (delta == 0 && c->step > 0)
00240 c->step--;
00241
00242 return (short) c->predictor;
00243 }
00244
00245 static inline short adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, unsigned char nibble)
00246 {
00247 if(!c->step) {
00248 c->predictor = 0;
00249 c->step = 127;
00250 }
00251
00252 c->predictor += (c->step * ff_adpcm_yamaha_difflookup[nibble]) / 8;
00253 c->predictor = av_clip_int16(c->predictor);
00254 c->step = (c->step * ff_adpcm_yamaha_indexscale[nibble]) >> 8;
00255 c->step = av_clip(c->step, 127, 24567);
00256 return c->predictor;
00257 }
00258
00259 static void xa_decode(short *out, const unsigned char *in,
00260 ADPCMChannelStatus *left, ADPCMChannelStatus *right, int inc)
00261 {
00262 int i, j;
00263 int shift,filter,f0,f1;
00264 int s_1,s_2;
00265 int d,s,t;
00266
00267 for(i=0;i<4;i++) {
00268
00269 shift = 12 - (in[4+i*2] & 15);
00270 filter = in[4+i*2] >> 4;
00271 f0 = xa_adpcm_table[filter][0];
00272 f1 = xa_adpcm_table[filter][1];
00273
00274 s_1 = left->sample1;
00275 s_2 = left->sample2;
00276
00277 for(j=0;j<28;j++) {
00278 d = in[16+i+j*4];
00279
00280 t = (signed char)(d<<4)>>4;
00281 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
00282 s_2 = s_1;
00283 s_1 = av_clip_int16(s);
00284 *out = s_1;
00285 out += inc;
00286 }
00287
00288 if (inc==2) {
00289 left->sample1 = s_1;
00290 left->sample2 = s_2;
00291 s_1 = right->sample1;
00292 s_2 = right->sample2;
00293 out = out + 1 - 28*2;
00294 }
00295
00296 shift = 12 - (in[5+i*2] & 15);
00297 filter = in[5+i*2] >> 4;
00298
00299 f0 = xa_adpcm_table[filter][0];
00300 f1 = xa_adpcm_table[filter][1];
00301
00302 for(j=0;j<28;j++) {
00303 d = in[16+i+j*4];
00304
00305 t = (signed char)d >> 4;
00306 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
00307 s_2 = s_1;
00308 s_1 = av_clip_int16(s);
00309 *out = s_1;
00310 out += inc;
00311 }
00312
00313 if (inc==2) {
00314 right->sample1 = s_1;
00315 right->sample2 = s_2;
00316 out -= 1;
00317 } else {
00318 left->sample1 = s_1;
00319 left->sample2 = s_2;
00320 }
00321 }
00322 }
00323
00333 static int get_nb_samples(AVCodecContext *avctx, const uint8_t *buf,
00334 int buf_size, int *coded_samples)
00335 {
00336 ADPCMDecodeContext *s = avctx->priv_data;
00337 int nb_samples = 0;
00338 int ch = avctx->channels;
00339 int has_coded_samples = 0;
00340 int header_size;
00341
00342 *coded_samples = 0;
00343
00344 if(ch <= 0)
00345 return 0;
00346
00347 switch (avctx->codec->id) {
00348
00349 case CODEC_ID_ADPCM_EA_XAS:
00350 if (buf_size < 76 * ch)
00351 return 0;
00352 nb_samples = 128;
00353 break;
00354 case CODEC_ID_ADPCM_IMA_QT:
00355 if (buf_size < 34 * ch)
00356 return 0;
00357 nb_samples = 64;
00358 break;
00359
00360 case CODEC_ID_ADPCM_CT:
00361 case CODEC_ID_ADPCM_IMA_EA_SEAD:
00362 case CODEC_ID_ADPCM_IMA_WS:
00363 case CODEC_ID_ADPCM_YAMAHA:
00364 nb_samples = buf_size * 2 / ch;
00365 break;
00366 }
00367 if (nb_samples)
00368 return nb_samples;
00369
00370
00371 header_size = 0;
00372 switch (avctx->codec->id) {
00373 case CODEC_ID_ADPCM_4XM:
00374 case CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break;
00375 case CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break;
00376 case CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4; break;
00377 }
00378 if (header_size > 0)
00379 return (buf_size - header_size) * 2 / ch;
00380
00381
00382 switch (avctx->codec->id) {
00383 case CODEC_ID_ADPCM_EA:
00384 has_coded_samples = 1;
00385 if (buf_size < 4)
00386 return 0;
00387 *coded_samples = AV_RL32(buf);
00388 *coded_samples -= *coded_samples % 28;
00389 nb_samples = (buf_size - 12) / 30 * 28;
00390 break;
00391 case CODEC_ID_ADPCM_IMA_EA_EACS:
00392 has_coded_samples = 1;
00393 if (buf_size < 4)
00394 return 0;
00395 *coded_samples = AV_RL32(buf);
00396 nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
00397 break;
00398 case CODEC_ID_ADPCM_EA_MAXIS_XA:
00399 nb_samples = ((buf_size - ch) / (2 * ch)) * 2 * ch;
00400 break;
00401 case CODEC_ID_ADPCM_EA_R1:
00402 case CODEC_ID_ADPCM_EA_R2:
00403 case CODEC_ID_ADPCM_EA_R3:
00404
00405
00406 has_coded_samples = 1;
00407 if (buf_size < 4)
00408 return 0;
00409 switch (avctx->codec->id) {
00410 case CODEC_ID_ADPCM_EA_R1:
00411 header_size = 4 + 9 * ch;
00412 *coded_samples = AV_RL32(buf);
00413 break;
00414 case CODEC_ID_ADPCM_EA_R2:
00415 header_size = 4 + 5 * ch;
00416 *coded_samples = AV_RL32(buf);
00417 break;
00418 case CODEC_ID_ADPCM_EA_R3:
00419 header_size = 4 + 5 * ch;
00420 *coded_samples = AV_RB32(buf);
00421 break;
00422 }
00423 *coded_samples -= *coded_samples % 28;
00424 nb_samples = (buf_size - header_size) * 2 / ch;
00425 nb_samples -= nb_samples % 28;
00426 break;
00427 case CODEC_ID_ADPCM_IMA_DK3:
00428 if (avctx->block_align > 0)
00429 buf_size = FFMIN(buf_size, avctx->block_align);
00430 nb_samples = ((buf_size - 16) * 8 / 3) / ch;
00431 break;
00432 case CODEC_ID_ADPCM_IMA_DK4:
00433 nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
00434 break;
00435 case CODEC_ID_ADPCM_IMA_WAV:
00436 if (avctx->block_align > 0)
00437 buf_size = FFMIN(buf_size, avctx->block_align);
00438 nb_samples = 1 + (buf_size - 4 * ch) / (4 * ch) * 8;
00439 break;
00440 case CODEC_ID_ADPCM_MS:
00441 if (avctx->block_align > 0)
00442 buf_size = FFMIN(buf_size, avctx->block_align);
00443 nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;
00444 break;
00445 case CODEC_ID_ADPCM_SBPRO_2:
00446 case CODEC_ID_ADPCM_SBPRO_3:
00447 case CODEC_ID_ADPCM_SBPRO_4:
00448 {
00449 int samples_per_byte;
00450 switch (avctx->codec->id) {
00451 case CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break;
00452 case CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break;
00453 case CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;
00454 }
00455 if (!s->status[0].step_index) {
00456 nb_samples++;
00457 buf_size -= ch;
00458 }
00459 nb_samples += buf_size * samples_per_byte / ch;
00460 break;
00461 }
00462 case CODEC_ID_ADPCM_SWF:
00463 {
00464 int buf_bits = buf_size * 8 - 2;
00465 int nbits = (buf[0] >> 6) + 2;
00466 int block_hdr_size = 22 * ch;
00467 int block_size = block_hdr_size + nbits * ch * 4095;
00468 int nblocks = buf_bits / block_size;
00469 int bits_left = buf_bits - nblocks * block_size;
00470 nb_samples = nblocks * 4096;
00471 if (bits_left >= block_hdr_size)
00472 nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
00473 break;
00474 }
00475 case CODEC_ID_ADPCM_THP:
00476 has_coded_samples = 1;
00477 if (buf_size < 8)
00478 return 0;
00479 *coded_samples = AV_RB32(&buf[4]);
00480 *coded_samples -= *coded_samples % 14;
00481 nb_samples = (buf_size - 80) / (8 * ch) * 14;
00482 break;
00483 case CODEC_ID_ADPCM_XA:
00484 nb_samples = (buf_size / 128) * 224 / ch;
00485 break;
00486 }
00487
00488
00489 if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
00490 return AVERROR_INVALIDDATA;
00491
00492 return nb_samples;
00493 }
00494
00495
00496 #define DK3_GET_NEXT_NIBBLE() \
00497 if (decode_top_nibble_next) \
00498 { \
00499 nibble = last_byte >> 4; \
00500 decode_top_nibble_next = 0; \
00501 } \
00502 else \
00503 { \
00504 if (end_of_packet) \
00505 break; \
00506 last_byte = *src++; \
00507 if (src >= buf + buf_size) \
00508 end_of_packet = 1; \
00509 nibble = last_byte & 0x0F; \
00510 decode_top_nibble_next = 1; \
00511 }
00512
00513 static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
00514 int *got_frame_ptr, AVPacket *avpkt)
00515 {
00516 const uint8_t *buf = avpkt->data;
00517 int buf_size = avpkt->size;
00518 ADPCMDecodeContext *c = avctx->priv_data;
00519 ADPCMChannelStatus *cs;
00520 int n, m, channel, i;
00521 short *samples;
00522 const uint8_t *src;
00523 int st;
00524 int count1, count2;
00525 int nb_samples, coded_samples, ret;
00526
00527 nb_samples = get_nb_samples(avctx, buf, buf_size, &coded_samples);
00528 if (nb_samples <= 0) {
00529 av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
00530 return AVERROR_INVALIDDATA;
00531 }
00532
00533
00534 c->frame.nb_samples = nb_samples;
00535 if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
00536 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
00537 return ret;
00538 }
00539 samples = (short *)c->frame.data[0];
00540
00541
00542
00543 if (coded_samples) {
00544 if (coded_samples != nb_samples)
00545 av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
00546 c->frame.nb_samples = nb_samples = coded_samples;
00547 }
00548
00549 src = buf;
00550
00551 st = avctx->channels == 2 ? 1 : 0;
00552
00553 switch(avctx->codec->id) {
00554 case CODEC_ID_ADPCM_IMA_QT:
00555
00556
00557 for (channel = 0; channel < avctx->channels; channel++) {
00558 int16_t predictor;
00559 int step_index;
00560 cs = &(c->status[channel]);
00561
00562
00563
00564 predictor = AV_RB16(src);
00565 step_index = predictor & 0x7F;
00566 predictor &= 0xFF80;
00567
00568 src += 2;
00569
00570 if (cs->step_index == step_index) {
00571 int diff = (int)predictor - cs->predictor;
00572 if (diff < 0)
00573 diff = - diff;
00574 if (diff > 0x7f)
00575 goto update;
00576 } else {
00577 update:
00578 cs->step_index = step_index;
00579 cs->predictor = predictor;
00580 }
00581
00582 if (cs->step_index > 88){
00583 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
00584 cs->step_index = 88;
00585 }
00586
00587 samples = (short *)c->frame.data[0] + channel;
00588
00589 for (m = 0; m < 32; m++) {
00590 *samples = adpcm_ima_qt_expand_nibble(cs, src[0] & 0x0F, 3);
00591 samples += avctx->channels;
00592 *samples = adpcm_ima_qt_expand_nibble(cs, src[0] >> 4 , 3);
00593 samples += avctx->channels;
00594 src ++;
00595 }
00596 }
00597 break;
00598 case CODEC_ID_ADPCM_IMA_WAV:
00599 if (avctx->block_align != 0 && buf_size > avctx->block_align)
00600 buf_size = avctx->block_align;
00601
00602 for(i=0; i<avctx->channels; i++){
00603 cs = &(c->status[i]);
00604 cs->predictor = *samples++ = (int16_t)bytestream_get_le16(&src);
00605
00606 cs->step_index = *src++;
00607 if (cs->step_index > 88){
00608 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
00609 cs->step_index = 88;
00610 }
00611 if (*src++) av_log(avctx, AV_LOG_ERROR, "unused byte should be null but is %d!!\n", src[-1]);
00612 }
00613
00614 for (n = (nb_samples - 1) / 8; n > 0; n--) {
00615 for (i = 0; i < avctx->channels; i++) {
00616 cs = &c->status[i];
00617 for (m = 0; m < 4; m++) {
00618 uint8_t v = *src++;
00619 *samples = adpcm_ima_expand_nibble(cs, v & 0x0F, 3);
00620 samples += avctx->channels;
00621 *samples = adpcm_ima_expand_nibble(cs, v >> 4 , 3);
00622 samples += avctx->channels;
00623 }
00624 samples -= 8 * avctx->channels - 1;
00625 }
00626 samples += 7 * avctx->channels;
00627 }
00628 break;
00629 case CODEC_ID_ADPCM_4XM:
00630 for (i = 0; i < avctx->channels; i++)
00631 c->status[i].predictor= (int16_t)bytestream_get_le16(&src);
00632
00633 for (i = 0; i < avctx->channels; i++) {
00634 c->status[i].step_index= (int16_t)bytestream_get_le16(&src);
00635 c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
00636 }
00637
00638 for (i = 0; i < avctx->channels; i++) {
00639 samples = (short *)c->frame.data[0] + i;
00640 cs = &c->status[i];
00641 for (n = nb_samples >> 1; n > 0; n--, src++) {
00642 uint8_t v = *src;
00643 *samples = adpcm_ima_expand_nibble(cs, v & 0x0F, 4);
00644 samples += avctx->channels;
00645 *samples = adpcm_ima_expand_nibble(cs, v >> 4 , 4);
00646 samples += avctx->channels;
00647 }
00648 }
00649 break;
00650 case CODEC_ID_ADPCM_MS:
00651 {
00652 int block_predictor;
00653
00654 if (avctx->block_align != 0 && buf_size > avctx->block_align)
00655 buf_size = avctx->block_align;
00656
00657 block_predictor = av_clip(*src++, 0, 6);
00658 c->status[0].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
00659 c->status[0].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
00660 if (st) {
00661 block_predictor = av_clip(*src++, 0, 6);
00662 c->status[1].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
00663 c->status[1].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
00664 }
00665 c->status[0].idelta = (int16_t)bytestream_get_le16(&src);
00666 if (st){
00667 c->status[1].idelta = (int16_t)bytestream_get_le16(&src);
00668 }
00669
00670 c->status[0].sample1 = bytestream_get_le16(&src);
00671 if (st) c->status[1].sample1 = bytestream_get_le16(&src);
00672 c->status[0].sample2 = bytestream_get_le16(&src);
00673 if (st) c->status[1].sample2 = bytestream_get_le16(&src);
00674
00675 *samples++ = c->status[0].sample2;
00676 if (st) *samples++ = c->status[1].sample2;
00677 *samples++ = c->status[0].sample1;
00678 if (st) *samples++ = c->status[1].sample1;
00679 for(n = (nb_samples - 2) >> (1 - st); n > 0; n--, src++) {
00680 *samples++ = adpcm_ms_expand_nibble(&c->status[0 ], src[0] >> 4 );
00681 *samples++ = adpcm_ms_expand_nibble(&c->status[st], src[0] & 0x0F);
00682 }
00683 break;
00684 }
00685 case CODEC_ID_ADPCM_IMA_DK4:
00686 if (avctx->block_align != 0 && buf_size > avctx->block_align)
00687 buf_size = avctx->block_align;
00688
00689 for (channel = 0; channel < avctx->channels; channel++) {
00690 cs = &c->status[channel];
00691 cs->predictor = (int16_t)bytestream_get_le16(&src);
00692 cs->step_index = *src++;
00693 src++;
00694 *samples++ = cs->predictor;
00695 }
00696 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
00697 uint8_t v = *src;
00698 *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v >> 4 , 3);
00699 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
00700 }
00701 break;
00702 case CODEC_ID_ADPCM_IMA_DK3:
00703 {
00704 unsigned char last_byte = 0;
00705 unsigned char nibble;
00706 int decode_top_nibble_next = 0;
00707 int end_of_packet = 0;
00708 int diff_channel;
00709
00710 if (avctx->block_align != 0 && buf_size > avctx->block_align)
00711 buf_size = avctx->block_align;
00712
00713 c->status[0].predictor = (int16_t)AV_RL16(src + 10);
00714 c->status[1].predictor = (int16_t)AV_RL16(src + 12);
00715 c->status[0].step_index = src[14];
00716 c->status[1].step_index = src[15];
00717
00718 src += 16;
00719 diff_channel = c->status[1].predictor;
00720
00721
00722
00723 while (1) {
00724
00725
00726
00727
00728
00729 DK3_GET_NEXT_NIBBLE();
00730 adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
00731
00732
00733 DK3_GET_NEXT_NIBBLE();
00734 adpcm_ima_expand_nibble(&c->status[1], nibble, 3);
00735
00736
00737 diff_channel = (diff_channel + c->status[1].predictor) / 2;
00738 *samples++ = c->status[0].predictor + c->status[1].predictor;
00739 *samples++ = c->status[0].predictor - c->status[1].predictor;
00740
00741
00742 DK3_GET_NEXT_NIBBLE();
00743 adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
00744
00745
00746 diff_channel = (diff_channel + c->status[1].predictor) / 2;
00747 *samples++ = c->status[0].predictor + c->status[1].predictor;
00748 *samples++ = c->status[0].predictor - c->status[1].predictor;
00749 }
00750 break;
00751 }
00752 case CODEC_ID_ADPCM_IMA_ISS:
00753 for (channel = 0; channel < avctx->channels; channel++) {
00754 cs = &c->status[channel];
00755 cs->predictor = (int16_t)bytestream_get_le16(&src);
00756 cs->step_index = *src++;
00757 src++;
00758 }
00759
00760 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
00761 uint8_t v1, v2;
00762 uint8_t v = *src;
00763
00764 if (st) {
00765 v1 = v >> 4;
00766 v2 = v & 0x0F;
00767 } else {
00768 v2 = v >> 4;
00769 v1 = v & 0x0F;
00770 }
00771 *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v1, 3);
00772 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3);
00773 }
00774 break;
00775 case CODEC_ID_ADPCM_IMA_WS:
00776 while (src < buf + buf_size) {
00777 uint8_t v = *src++;
00778 *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4 , 3);
00779 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
00780 }
00781 break;
00782 case CODEC_ID_ADPCM_XA:
00783 while (buf_size >= 128) {
00784 xa_decode(samples, src, &c->status[0], &c->status[1],
00785 avctx->channels);
00786 src += 128;
00787 samples += 28 * 8;
00788 buf_size -= 128;
00789 }
00790 break;
00791 case CODEC_ID_ADPCM_IMA_EA_EACS:
00792 src += 4;
00793
00794 for (i=0; i<=st; i++)
00795 c->status[i].step_index = bytestream_get_le32(&src);
00796 for (i=0; i<=st; i++)
00797 c->status[i].predictor = bytestream_get_le32(&src);
00798
00799 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
00800 *samples++ = adpcm_ima_expand_nibble(&c->status[0], *src>>4, 3);
00801 *samples++ = adpcm_ima_expand_nibble(&c->status[st], *src&0x0F, 3);
00802 }
00803 break;
00804 case CODEC_ID_ADPCM_IMA_EA_SEAD:
00805 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
00806 *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] >> 4, 6);
00807 *samples++ = adpcm_ima_expand_nibble(&c->status[st],src[0]&0x0F, 6);
00808 }
00809 break;
00810 case CODEC_ID_ADPCM_EA:
00811 {
00812 int32_t previous_left_sample, previous_right_sample;
00813 int32_t current_left_sample, current_right_sample;
00814 int32_t next_left_sample, next_right_sample;
00815 int32_t coeff1l, coeff2l, coeff1r, coeff2r;
00816 uint8_t shift_left, shift_right;
00817
00818
00819
00820
00821 if(avctx->channels != 2)
00822 return AVERROR_INVALIDDATA;
00823
00824 src += 4;
00825
00826 current_left_sample = (int16_t)bytestream_get_le16(&src);
00827 previous_left_sample = (int16_t)bytestream_get_le16(&src);
00828 current_right_sample = (int16_t)bytestream_get_le16(&src);
00829 previous_right_sample = (int16_t)bytestream_get_le16(&src);
00830
00831 for (count1 = 0; count1 < nb_samples / 28; count1++) {
00832 coeff1l = ea_adpcm_table[ *src >> 4 ];
00833 coeff2l = ea_adpcm_table[(*src >> 4 ) + 4];
00834 coeff1r = ea_adpcm_table[*src & 0x0F];
00835 coeff2r = ea_adpcm_table[(*src & 0x0F) + 4];
00836 src++;
00837
00838 shift_left = 20 - (*src >> 4);
00839 shift_right = 20 - (*src & 0x0F);
00840 src++;
00841
00842 for (count2 = 0; count2 < 28; count2++) {
00843 next_left_sample = sign_extend(*src >> 4, 4) << shift_left;
00844 next_right_sample = sign_extend(*src, 4) << shift_right;
00845 src++;
00846
00847 next_left_sample = (next_left_sample +
00848 (current_left_sample * coeff1l) +
00849 (previous_left_sample * coeff2l) + 0x80) >> 8;
00850 next_right_sample = (next_right_sample +
00851 (current_right_sample * coeff1r) +
00852 (previous_right_sample * coeff2r) + 0x80) >> 8;
00853
00854 previous_left_sample = current_left_sample;
00855 current_left_sample = av_clip_int16(next_left_sample);
00856 previous_right_sample = current_right_sample;
00857 current_right_sample = av_clip_int16(next_right_sample);
00858 *samples++ = (unsigned short)current_left_sample;
00859 *samples++ = (unsigned short)current_right_sample;
00860 }
00861 }
00862
00863 if (src - buf == buf_size - 2)
00864 src += 2;
00865
00866 break;
00867 }
00868 case CODEC_ID_ADPCM_EA_MAXIS_XA:
00869 {
00870 int coeff[2][2], shift[2];
00871
00872 for(channel = 0; channel < avctx->channels; channel++) {
00873 for (i=0; i<2; i++)
00874 coeff[channel][i] = ea_adpcm_table[(*src >> 4) + 4*i];
00875 shift[channel] = 20 - (*src & 0x0F);
00876 src++;
00877 }
00878 for (count1 = 0; count1 < nb_samples / 2; count1++) {
00879 for(i = 4; i >= 0; i-=4) {
00880 for(channel = 0; channel < avctx->channels; channel++) {
00881 int32_t sample = sign_extend(src[channel] >> i, 4) << shift[channel];
00882 sample = (sample +
00883 c->status[channel].sample1 * coeff[channel][0] +
00884 c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8;
00885 c->status[channel].sample2 = c->status[channel].sample1;
00886 c->status[channel].sample1 = av_clip_int16(sample);
00887 *samples++ = c->status[channel].sample1;
00888 }
00889 }
00890 src+=avctx->channels;
00891 }
00892
00893 src = buf + buf_size;
00894 break;
00895 }
00896 case CODEC_ID_ADPCM_EA_R1:
00897 case CODEC_ID_ADPCM_EA_R2:
00898 case CODEC_ID_ADPCM_EA_R3: {
00899
00900
00901
00902
00903 const int big_endian = avctx->codec->id == CODEC_ID_ADPCM_EA_R3;
00904 int32_t previous_sample, current_sample, next_sample;
00905 int32_t coeff1, coeff2;
00906 uint8_t shift;
00907 unsigned int channel;
00908 uint16_t *samplesC;
00909 const uint8_t *srcC;
00910 const uint8_t *src_end = buf + buf_size;
00911 int count = 0;
00912
00913 src += 4;
00914
00915 for (channel=0; channel<avctx->channels; channel++) {
00916 int32_t offset = (big_endian ? bytestream_get_be32(&src)
00917 : bytestream_get_le32(&src))
00918 + (avctx->channels-channel-1) * 4;
00919
00920 if ((offset < 0) || (offset >= src_end - src - 4)) break;
00921 srcC = src + offset;
00922 samplesC = samples + channel;
00923
00924 if (avctx->codec->id == CODEC_ID_ADPCM_EA_R1) {
00925 current_sample = (int16_t)bytestream_get_le16(&srcC);
00926 previous_sample = (int16_t)bytestream_get_le16(&srcC);
00927 } else {
00928 current_sample = c->status[channel].predictor;
00929 previous_sample = c->status[channel].prev_sample;
00930 }
00931
00932 for (count1 = 0; count1 < nb_samples / 28; count1++) {
00933 if (*srcC == 0xEE) {
00934 srcC++;
00935 if (srcC > src_end - 30*2) break;
00936 current_sample = (int16_t)bytestream_get_be16(&srcC);
00937 previous_sample = (int16_t)bytestream_get_be16(&srcC);
00938
00939 for (count2=0; count2<28; count2++) {
00940 *samplesC = (int16_t)bytestream_get_be16(&srcC);
00941 samplesC += avctx->channels;
00942 }
00943 } else {
00944 coeff1 = ea_adpcm_table[ *srcC>>4 ];
00945 coeff2 = ea_adpcm_table[(*srcC>>4) + 4];
00946 shift = 20 - (*srcC++ & 0x0F);
00947
00948 if (srcC > src_end - 14) break;
00949 for (count2=0; count2<28; count2++) {
00950 if (count2 & 1)
00951 next_sample = sign_extend(*srcC++, 4) << shift;
00952 else
00953 next_sample = sign_extend(*srcC >> 4, 4) << shift;
00954
00955 next_sample += (current_sample * coeff1) +
00956 (previous_sample * coeff2);
00957 next_sample = av_clip_int16(next_sample >> 8);
00958
00959 previous_sample = current_sample;
00960 current_sample = next_sample;
00961 *samplesC = current_sample;
00962 samplesC += avctx->channels;
00963 }
00964 }
00965 }
00966 if (!count) {
00967 count = count1;
00968 } else if (count != count1) {
00969 av_log(avctx, AV_LOG_WARNING, "per-channel sample count mismatch\n");
00970 count = FFMAX(count, count1);
00971 }
00972
00973 if (avctx->codec->id != CODEC_ID_ADPCM_EA_R1) {
00974 c->status[channel].predictor = current_sample;
00975 c->status[channel].prev_sample = previous_sample;
00976 }
00977 }
00978
00979 c->frame.nb_samples = count * 28;
00980 src = src_end;
00981 break;
00982 }
00983 case CODEC_ID_ADPCM_EA_XAS:
00984 for (channel=0; channel<avctx->channels; channel++) {
00985 int coeff[2][4], shift[4];
00986 short *s2, *s = &samples[channel];
00987 for (n=0; n<4; n++, s+=32*avctx->channels) {
00988 for (i=0; i<2; i++)
00989 coeff[i][n] = ea_adpcm_table[(src[0]&0x0F)+4*i];
00990 shift[n] = 20 - (src[2] & 0x0F);
00991 for (s2=s, i=0; i<2; i++, src+=2, s2+=avctx->channels)
00992 s2[0] = (src[0]&0xF0) + (src[1]<<8);
00993 }
00994
00995 for (m=2; m<32; m+=2) {
00996 s = &samples[m*avctx->channels + channel];
00997 for (n=0; n<4; n++, src++, s+=32*avctx->channels) {
00998 for (s2=s, i=0; i<8; i+=4, s2+=avctx->channels) {
00999 int level = sign_extend(*src >> (4 - i), 4) << shift[n];
01000 int pred = s2[-1*avctx->channels] * coeff[0][n]
01001 + s2[-2*avctx->channels] * coeff[1][n];
01002 s2[0] = av_clip_int16((level + pred + 0x80) >> 8);
01003 }
01004 }
01005 }
01006 }
01007 break;
01008 case CODEC_ID_ADPCM_IMA_AMV:
01009 case CODEC_ID_ADPCM_IMA_SMJPEG:
01010 if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) {
01011 c->status[0].predictor = sign_extend(bytestream_get_le16(&src), 16);
01012 c->status[0].step_index = bytestream_get_le16(&src);
01013 src += 4;
01014 } else {
01015 c->status[0].predictor = sign_extend(bytestream_get_be16(&src), 16);
01016 c->status[0].step_index = bytestream_get_byte(&src);
01017 src += 1;
01018 }
01019
01020 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
01021 char hi, lo;
01022 lo = *src & 0x0F;
01023 hi = *src >> 4;
01024
01025 if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV)
01026 FFSWAP(char, hi, lo);
01027
01028 *samples++ = adpcm_ima_expand_nibble(&c->status[0],
01029 lo, 3);
01030 *samples++ = adpcm_ima_expand_nibble(&c->status[0],
01031 hi, 3);
01032 }
01033 break;
01034 case CODEC_ID_ADPCM_CT:
01035 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
01036 uint8_t v = *src;
01037 *samples++ = adpcm_ct_expand_nibble(&c->status[0 ], v >> 4 );
01038 *samples++ = adpcm_ct_expand_nibble(&c->status[st], v & 0x0F);
01039 }
01040 break;
01041 case CODEC_ID_ADPCM_SBPRO_4:
01042 case CODEC_ID_ADPCM_SBPRO_3:
01043 case CODEC_ID_ADPCM_SBPRO_2:
01044 if (!c->status[0].step_index) {
01045
01046 *samples++ = 128 * (*src++ - 0x80);
01047 if (st)
01048 *samples++ = 128 * (*src++ - 0x80);
01049 c->status[0].step_index = 1;
01050 nb_samples--;
01051 }
01052 if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_4) {
01053 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
01054 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
01055 src[0] >> 4, 4, 0);
01056 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
01057 src[0] & 0x0F, 4, 0);
01058 }
01059 } else if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_3) {
01060 for (n = nb_samples / 3; n > 0; n--, src++) {
01061 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
01062 src[0] >> 5 , 3, 0);
01063 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
01064 (src[0] >> 2) & 0x07, 3, 0);
01065 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
01066 src[0] & 0x03, 2, 0);
01067 }
01068 } else {
01069 for (n = nb_samples >> (2 - st); n > 0; n--, src++) {
01070 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
01071 src[0] >> 6 , 2, 2);
01072 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
01073 (src[0] >> 4) & 0x03, 2, 2);
01074 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
01075 (src[0] >> 2) & 0x03, 2, 2);
01076 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
01077 src[0] & 0x03, 2, 2);
01078 }
01079 }
01080 break;
01081 case CODEC_ID_ADPCM_SWF:
01082 {
01083 GetBitContext gb;
01084 const int *table;
01085 int k0, signmask, nb_bits, count;
01086 int size = buf_size*8;
01087
01088 init_get_bits(&gb, buf, size);
01089
01090
01091 nb_bits = get_bits(&gb, 2)+2;
01092
01093 table = swf_index_tables[nb_bits-2];
01094 k0 = 1 << (nb_bits-2);
01095 signmask = 1 << (nb_bits-1);
01096
01097 while (get_bits_count(&gb) <= size - 22*avctx->channels) {
01098 for (i = 0; i < avctx->channels; i++) {
01099 *samples++ = c->status[i].predictor = get_sbits(&gb, 16);
01100 c->status[i].step_index = get_bits(&gb, 6);
01101 }
01102
01103 for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) {
01104 int i;
01105
01106 for (i = 0; i < avctx->channels; i++) {
01107
01108 int delta = get_bits(&gb, nb_bits);
01109 int step = ff_adpcm_step_table[c->status[i].step_index];
01110 long vpdiff = 0;
01111 int k = k0;
01112
01113 do {
01114 if (delta & k)
01115 vpdiff += step;
01116 step >>= 1;
01117 k >>= 1;
01118 } while(k);
01119 vpdiff += step;
01120
01121 if (delta & signmask)
01122 c->status[i].predictor -= vpdiff;
01123 else
01124 c->status[i].predictor += vpdiff;
01125
01126 c->status[i].step_index += table[delta & (~signmask)];
01127
01128 c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
01129 c->status[i].predictor = av_clip_int16(c->status[i].predictor);
01130
01131 *samples++ = c->status[i].predictor;
01132 }
01133 }
01134 }
01135 src += buf_size;
01136 break;
01137 }
01138 case CODEC_ID_ADPCM_YAMAHA:
01139 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
01140 uint8_t v = *src;
01141 *samples++ = adpcm_yamaha_expand_nibble(&c->status[0 ], v & 0x0F);
01142 *samples++ = adpcm_yamaha_expand_nibble(&c->status[st], v >> 4 );
01143 }
01144 break;
01145 case CODEC_ID_ADPCM_THP:
01146 {
01147 int table[2][16];
01148 int prev[2][2];
01149 int ch;
01150
01151 src += 4;
01152 src += 4;
01153
01154 for (i = 0; i < 32; i++)
01155 table[0][i] = (int16_t)bytestream_get_be16(&src);
01156
01157
01158 for (i = 0; i < 4; i++)
01159 prev[0][i] = (int16_t)bytestream_get_be16(&src);
01160
01161 for (ch = 0; ch <= st; ch++) {
01162 samples = (short *)c->frame.data[0] + ch;
01163
01164
01165 for (i = 0; i < nb_samples / 14; i++) {
01166 int index = (*src >> 4) & 7;
01167 unsigned int exp = *src++ & 15;
01168 int factor1 = table[ch][index * 2];
01169 int factor2 = table[ch][index * 2 + 1];
01170
01171
01172 for (n = 0; n < 14; n++) {
01173 int32_t sampledat;
01174 if(n&1) sampledat = sign_extend(*src++, 4);
01175 else sampledat = sign_extend(*src >> 4, 4);
01176
01177 sampledat = ((prev[ch][0]*factor1
01178 + prev[ch][1]*factor2) >> 11) + (sampledat << exp);
01179 *samples = av_clip_int16(sampledat);
01180 prev[ch][1] = prev[ch][0];
01181 prev[ch][0] = *samples++;
01182
01183
01184
01185 samples += st;
01186 }
01187 }
01188 }
01189 break;
01190 }
01191
01192 default:
01193 return -1;
01194 }
01195
01196 *got_frame_ptr = 1;
01197 *(AVFrame *)data = c->frame;
01198
01199 return src - buf;
01200 }
01201
01202
01203 #define ADPCM_DECODER(id_, name_, long_name_) \
01204 AVCodec ff_ ## name_ ## _decoder = { \
01205 .name = #name_, \
01206 .type = AVMEDIA_TYPE_AUDIO, \
01207 .id = id_, \
01208 .priv_data_size = sizeof(ADPCMDecodeContext), \
01209 .init = adpcm_decode_init, \
01210 .decode = adpcm_decode_frame, \
01211 .capabilities = CODEC_CAP_DR1, \
01212 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
01213 }
01214
01215
01216 ADPCM_DECODER(CODEC_ID_ADPCM_4XM, adpcm_4xm, "ADPCM 4X Movie");
01217 ADPCM_DECODER(CODEC_ID_ADPCM_CT, adpcm_ct, "ADPCM Creative Technology");
01218 ADPCM_DECODER(CODEC_ID_ADPCM_EA, adpcm_ea, "ADPCM Electronic Arts");
01219 ADPCM_DECODER(CODEC_ID_ADPCM_EA_MAXIS_XA, adpcm_ea_maxis_xa, "ADPCM Electronic Arts Maxis CDROM XA");
01220 ADPCM_DECODER(CODEC_ID_ADPCM_EA_R1, adpcm_ea_r1, "ADPCM Electronic Arts R1");
01221 ADPCM_DECODER(CODEC_ID_ADPCM_EA_R2, adpcm_ea_r2, "ADPCM Electronic Arts R2");
01222 ADPCM_DECODER(CODEC_ID_ADPCM_EA_R3, adpcm_ea_r3, "ADPCM Electronic Arts R3");
01223 ADPCM_DECODER(CODEC_ID_ADPCM_EA_XAS, adpcm_ea_xas, "ADPCM Electronic Arts XAS");
01224 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_AMV, adpcm_ima_amv, "ADPCM IMA AMV");
01225 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3, "ADPCM IMA Duck DK3");
01226 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4, "ADPCM IMA Duck DK4");
01227 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS");
01228 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead, "ADPCM IMA Electronic Arts SEAD");
01229 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_ISS, adpcm_ima_iss, "ADPCM IMA Funcom ISS");
01230 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt, "ADPCM IMA QuickTime");
01231 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg, "ADPCM IMA Loki SDL MJPEG");
01232 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav, "ADPCM IMA WAV");
01233 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws, "ADPCM IMA Westwood");
01234 ADPCM_DECODER(CODEC_ID_ADPCM_MS, adpcm_ms, "ADPCM Microsoft");
01235 ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2, "ADPCM Sound Blaster Pro 2-bit");
01236 ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3, "ADPCM Sound Blaster Pro 2.6-bit");
01237 ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4, "ADPCM Sound Blaster Pro 4-bit");
01238 ADPCM_DECODER(CODEC_ID_ADPCM_SWF, adpcm_swf, "ADPCM Shockwave Flash");
01239 ADPCM_DECODER(CODEC_ID_ADPCM_THP, adpcm_thp, "ADPCM Nintendo Gamecube THP");
01240 ADPCM_DECODER(CODEC_ID_ADPCM_XA, adpcm_xa, "ADPCM CDROM XA");
01241 ADPCM_DECODER(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha, "ADPCM Yamaha");