64bea6a5daefda215d813dbeafe67369e528b98e
[libav.git] / libavcodec / adpcm.c
1 /*
2 * Copyright (c) 2001-2003 The ffmpeg Project
3 *
4 * This file is part of Libav.
5 *
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.
10 *
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.
15 *
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
19 */
20 #include "avcodec.h"
21 #include "get_bits.h"
22 #include "put_bits.h"
23 #include "bytestream.h"
24 #include "adpcm.h"
25 #include "adpcm_data.h"
26
27 /**
28 * @file
29 * ADPCM decoders
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)
41 *
42 * Features and limitations:
43 *
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/
52 *
53 * CD-ROM XA:
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/
57 */
58
59 /* These are for CD-ROM XA ADPCM */
60 static const int xa_adpcm_table[5][2] = {
61 { 0, 0 },
62 { 60, 0 },
63 { 115, -52 },
64 { 98, -55 },
65 { 122, -60 }
66 };
67
68 static const int ea_adpcm_table[] = {
69 0, 240, 460, 392,
70 0, 0, -208, -220,
71 0, 1, 3, 4,
72 7, 8, 10, 11,
73 0, -1, -3, -4
74 };
75
76 // padded to zero where table size is less then 16
77 static const int swf_index_tables[4][16] = {
78 /*2*/ { -1, 2 },
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 }
82 };
83
84 /* end of tables */
85
86 typedef struct ADPCMDecodeContext {
87 AVFrame frame;
88 ADPCMChannelStatus status[6];
89 } ADPCMDecodeContext;
90
91 static av_cold int adpcm_decode_init(AVCodecContext * avctx)
92 {
93 ADPCMDecodeContext *c = avctx->priv_data;
94 unsigned int min_channels = 1;
95 unsigned int max_channels = 2;
96
97 switch(avctx->codec->id) {
98 case CODEC_ID_ADPCM_EA:
99 min_channels = 2;
100 break;
101 case CODEC_ID_ADPCM_EA_R1:
102 case CODEC_ID_ADPCM_EA_R2:
103 case CODEC_ID_ADPCM_EA_R3:
104 case CODEC_ID_ADPCM_EA_XAS:
105 max_channels = 6;
106 break;
107 }
108 if (avctx->channels < min_channels || avctx->channels > max_channels) {
109 av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
110 return AVERROR(EINVAL);
111 }
112
113 switch(avctx->codec->id) {
114 case CODEC_ID_ADPCM_CT:
115 c->status[0].step = c->status[1].step = 511;
116 break;
117 case CODEC_ID_ADPCM_IMA_WAV:
118 if (avctx->bits_per_coded_sample != 4) {
119 av_log(avctx, AV_LOG_ERROR, "Only 4-bit ADPCM IMA WAV files are supported\n");
120 return -1;
121 }
122 break;
123 case CODEC_ID_ADPCM_IMA_APC:
124 if (avctx->extradata && avctx->extradata_size >= 8) {
125 c->status[0].predictor = AV_RL32(avctx->extradata);
126 c->status[1].predictor = AV_RL32(avctx->extradata + 4);
127 }
128 break;
129 default:
130 break;
131 }
132 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
133
134 avcodec_get_frame_defaults(&c->frame);
135 avctx->coded_frame = &c->frame;
136
137 return 0;
138 }
139
140 static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble, int shift)
141 {
142 int step_index;
143 int predictor;
144 int sign, delta, diff, step;
145
146 step = ff_adpcm_step_table[c->step_index];
147 step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
148 if (step_index < 0) step_index = 0;
149 else if (step_index > 88) step_index = 88;
150
151 sign = nibble & 8;
152 delta = nibble & 7;
153 /* perform direct multiplication instead of series of jumps proposed by
154 * the reference ADPCM implementation since modern CPUs can do the mults
155 * quickly enough */
156 diff = ((2 * delta + 1) * step) >> shift;
157 predictor = c->predictor;
158 if (sign) predictor -= diff;
159 else predictor += diff;
160
161 c->predictor = av_clip_int16(predictor);
162 c->step_index = step_index;
163
164 return (short)c->predictor;
165 }
166
167 static inline int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble, int shift)
168 {
169 int step_index;
170 int predictor;
171 int diff, step;
172
173 step = ff_adpcm_step_table[c->step_index];
174 step_index = c->step_index + ff_adpcm_index_table[nibble];
175 step_index = av_clip(step_index, 0, 88);
176
177 diff = step >> 3;
178 if (nibble & 4) diff += step;
179 if (nibble & 2) diff += step >> 1;
180 if (nibble & 1) diff += step >> 2;
181
182 if (nibble & 8)
183 predictor = c->predictor - diff;
184 else
185 predictor = c->predictor + diff;
186
187 c->predictor = av_clip_int16(predictor);
188 c->step_index = step_index;
189
190 return c->predictor;
191 }
192
193 static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, char nibble)
194 {
195 int predictor;
196
197 predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 64;
198 predictor += (signed)((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;
199
200 c->sample2 = c->sample1;
201 c->sample1 = av_clip_int16(predictor);
202 c->idelta = (ff_adpcm_AdaptationTable[(int)nibble] * c->idelta) >> 8;
203 if (c->idelta < 16) c->idelta = 16;
204
205 return c->sample1;
206 }
207
208 static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
209 {
210 int sign, delta, diff;
211 int new_step;
212
213 sign = nibble & 8;
214 delta = nibble & 7;
215 /* perform direct multiplication instead of series of jumps proposed by
216 * the reference ADPCM implementation since modern CPUs can do the mults
217 * quickly enough */
218 diff = ((2 * delta + 1) * c->step) >> 3;
219 /* predictor update is not so trivial: predictor is multiplied on 254/256 before updating */
220 c->predictor = ((c->predictor * 254) >> 8) + (sign ? -diff : diff);
221 c->predictor = av_clip_int16(c->predictor);
222 /* calculate new step and clamp it to range 511..32767 */
223 new_step = (ff_adpcm_AdaptationTable[nibble & 7] * c->step) >> 8;
224 c->step = av_clip(new_step, 511, 32767);
225
226 return (short)c->predictor;
227 }
228
229 static inline short adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, char nibble, int size, int shift)
230 {
231 int sign, delta, diff;
232
233 sign = nibble & (1<<(size-1));
234 delta = nibble & ((1<<(size-1))-1);
235 diff = delta << (7 + c->step + shift);
236
237 /* clamp result */
238 c->predictor = av_clip(c->predictor + (sign ? -diff : diff), -16384,16256);
239
240 /* calculate new step */
241 if (delta >= (2*size - 3) && c->step < 3)
242 c->step++;
243 else if (delta == 0 && c->step > 0)
244 c->step--;
245
246 return (short) c->predictor;
247 }
248
249 static inline short adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, unsigned char nibble)
250 {
251 if(!c->step) {
252 c->predictor = 0;
253 c->step = 127;
254 }
255
256 c->predictor += (c->step * ff_adpcm_yamaha_difflookup[nibble]) / 8;
257 c->predictor = av_clip_int16(c->predictor);
258 c->step = (c->step * ff_adpcm_yamaha_indexscale[nibble]) >> 8;
259 c->step = av_clip(c->step, 127, 24567);
260 return c->predictor;
261 }
262
263 static void xa_decode(short *out, const unsigned char *in,
264 ADPCMChannelStatus *left, ADPCMChannelStatus *right, int inc)
265 {
266 int i, j;
267 int shift,filter,f0,f1;
268 int s_1,s_2;
269 int d,s,t;
270
271 for(i=0;i<4;i++) {
272
273 shift = 12 - (in[4+i*2] & 15);
274 filter = in[4+i*2] >> 4;
275 f0 = xa_adpcm_table[filter][0];
276 f1 = xa_adpcm_table[filter][1];
277
278 s_1 = left->sample1;
279 s_2 = left->sample2;
280
281 for(j=0;j<28;j++) {
282 d = in[16+i+j*4];
283
284 t = (signed char)(d<<4)>>4;
285 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
286 s_2 = s_1;
287 s_1 = av_clip_int16(s);
288 *out = s_1;
289 out += inc;
290 }
291
292 if (inc==2) { /* stereo */
293 left->sample1 = s_1;
294 left->sample2 = s_2;
295 s_1 = right->sample1;
296 s_2 = right->sample2;
297 out = out + 1 - 28*2;
298 }
299
300 shift = 12 - (in[5+i*2] & 15);
301 filter = in[5+i*2] >> 4;
302
303 f0 = xa_adpcm_table[filter][0];
304 f1 = xa_adpcm_table[filter][1];
305
306 for(j=0;j<28;j++) {
307 d = in[16+i+j*4];
308
309 t = (signed char)d >> 4;
310 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
311 s_2 = s_1;
312 s_1 = av_clip_int16(s);
313 *out = s_1;
314 out += inc;
315 }
316
317 if (inc==2) { /* stereo */
318 right->sample1 = s_1;
319 right->sample2 = s_2;
320 out -= 1;
321 } else {
322 left->sample1 = s_1;
323 left->sample2 = s_2;
324 }
325 }
326 }
327
328 /**
329 * Get the number of samples that will be decoded from the packet.
330 * In one case, this is actually the maximum number of samples possible to
331 * decode with the given buf_size.
332 *
333 * @param[out] coded_samples set to the number of samples as coded in the
334 * packet, or 0 if the codec does not encode the
335 * number of samples in each frame.
336 */
337 static int get_nb_samples(AVCodecContext *avctx, const uint8_t *buf,
338 int buf_size, int *coded_samples)
339 {
340 ADPCMDecodeContext *s = avctx->priv_data;
341 int nb_samples = 0;
342 int ch = avctx->channels;
343 int has_coded_samples = 0;
344 int header_size;
345
346 *coded_samples = 0;
347
348 switch (avctx->codec->id) {
349 /* constant, only check buf_size */
350 case CODEC_ID_ADPCM_EA_XAS:
351 if (buf_size < 76 * ch)
352 return 0;
353 nb_samples = 128;
354 break;
355 case CODEC_ID_ADPCM_IMA_QT:
356 if (buf_size < 34 * ch)
357 return 0;
358 nb_samples = 64;
359 break;
360 /* simple 4-bit adpcm */
361 case CODEC_ID_ADPCM_CT:
362 case CODEC_ID_ADPCM_IMA_APC:
363 case CODEC_ID_ADPCM_IMA_EA_SEAD:
364 case CODEC_ID_ADPCM_IMA_WS:
365 case CODEC_ID_ADPCM_YAMAHA:
366 nb_samples = buf_size * 2 / ch;
367 break;
368 }
369 if (nb_samples)
370 return nb_samples;
371
372 /* simple 4-bit adpcm, with header */
373 header_size = 0;
374 switch (avctx->codec->id) {
375 case CODEC_ID_ADPCM_4XM:
376 case CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break;
377 case CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break;
378 case CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4; break;
379 }
380 if (header_size > 0)
381 return (buf_size - header_size) * 2 / ch;
382
383 /* more complex formats */
384 switch (avctx->codec->id) {
385 case CODEC_ID_ADPCM_EA:
386 has_coded_samples = 1;
387 if (buf_size < 4)
388 return 0;
389 *coded_samples = AV_RL32(buf);
390 *coded_samples -= *coded_samples % 28;
391 nb_samples = (buf_size - 12) / 30 * 28;
392 break;
393 case CODEC_ID_ADPCM_IMA_EA_EACS:
394 has_coded_samples = 1;
395 if (buf_size < 4)
396 return 0;
397 *coded_samples = AV_RL32(buf);
398 nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
399 break;
400 case CODEC_ID_ADPCM_EA_MAXIS_XA:
401 nb_samples = ((buf_size - ch) / (2 * ch)) * 2 * ch;
402 break;
403 case CODEC_ID_ADPCM_EA_R1:
404 case CODEC_ID_ADPCM_EA_R2:
405 case CODEC_ID_ADPCM_EA_R3:
406 /* maximum number of samples */
407 /* has internal offsets and a per-frame switch to signal raw 16-bit */
408 has_coded_samples = 1;
409 if (buf_size < 4)
410 return 0;
411 switch (avctx->codec->id) {
412 case CODEC_ID_ADPCM_EA_R1:
413 header_size = 4 + 9 * ch;
414 *coded_samples = AV_RL32(buf);
415 break;
416 case CODEC_ID_ADPCM_EA_R2:
417 header_size = 4 + 5 * ch;
418 *coded_samples = AV_RL32(buf);
419 break;
420 case CODEC_ID_ADPCM_EA_R3:
421 header_size = 4 + 5 * ch;
422 *coded_samples = AV_RB32(buf);
423 break;
424 }
425 *coded_samples -= *coded_samples % 28;
426 nb_samples = (buf_size - header_size) * 2 / ch;
427 nb_samples -= nb_samples % 28;
428 break;
429 case CODEC_ID_ADPCM_IMA_DK3:
430 if (avctx->block_align > 0)
431 buf_size = FFMIN(buf_size, avctx->block_align);
432 nb_samples = ((buf_size - 16) * 8 / 3) / ch;
433 break;
434 case CODEC_ID_ADPCM_IMA_DK4:
435 nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
436 break;
437 case CODEC_ID_ADPCM_IMA_WAV:
438 if (avctx->block_align > 0)
439 buf_size = FFMIN(buf_size, avctx->block_align);
440 nb_samples = 1 + (buf_size - 4 * ch) / (4 * ch) * 8;
441 break;
442 case CODEC_ID_ADPCM_MS:
443 if (avctx->block_align > 0)
444 buf_size = FFMIN(buf_size, avctx->block_align);
445 nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;
446 break;
447 case CODEC_ID_ADPCM_SBPRO_2:
448 case CODEC_ID_ADPCM_SBPRO_3:
449 case CODEC_ID_ADPCM_SBPRO_4:
450 {
451 int samples_per_byte;
452 switch (avctx->codec->id) {
453 case CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break;
454 case CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break;
455 case CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;
456 }
457 if (!s->status[0].step_index) {
458 nb_samples++;
459 buf_size -= ch;
460 }
461 nb_samples += buf_size * samples_per_byte / ch;
462 break;
463 }
464 case CODEC_ID_ADPCM_SWF:
465 {
466 int buf_bits = buf_size * 8 - 2;
467 int nbits = (buf[0] >> 6) + 2;
468 int block_hdr_size = 22 * ch;
469 int block_size = block_hdr_size + nbits * ch * 4095;
470 int nblocks = buf_bits / block_size;
471 int bits_left = buf_bits - nblocks * block_size;
472 nb_samples = nblocks * 4096;
473 if (bits_left >= block_hdr_size)
474 nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
475 break;
476 }
477 case CODEC_ID_ADPCM_THP:
478 has_coded_samples = 1;
479 if (buf_size < 8)
480 return 0;
481 *coded_samples = AV_RB32(&buf[4]);
482 *coded_samples -= *coded_samples % 14;
483 nb_samples = (buf_size - 80) / (8 * ch) * 14;
484 break;
485 case CODEC_ID_ADPCM_XA:
486 nb_samples = (buf_size / 128) * 224 / ch;
487 break;
488 }
489
490 /* validate coded sample count */
491 if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
492 return AVERROR_INVALIDDATA;
493
494 return nb_samples;
495 }
496
497 /* DK3 ADPCM support macro */
498 #define DK3_GET_NEXT_NIBBLE() \
499 if (decode_top_nibble_next) \
500 { \
501 nibble = last_byte >> 4; \
502 decode_top_nibble_next = 0; \
503 } \
504 else \
505 { \
506 if (end_of_packet) \
507 break; \
508 last_byte = *src++; \
509 if (src >= buf + buf_size) \
510 end_of_packet = 1; \
511 nibble = last_byte & 0x0F; \
512 decode_top_nibble_next = 1; \
513 }
514
515 static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
516 int *got_frame_ptr, AVPacket *avpkt)
517 {
518 const uint8_t *buf = avpkt->data;
519 int buf_size = avpkt->size;
520 ADPCMDecodeContext *c = avctx->priv_data;
521 ADPCMChannelStatus *cs;
522 int n, m, channel, i;
523 short *samples;
524 const uint8_t *src;
525 int st; /* stereo */
526 int count1, count2;
527 int nb_samples, coded_samples, ret;
528
529 nb_samples = get_nb_samples(avctx, buf, buf_size, &coded_samples);
530 if (nb_samples <= 0) {
531 av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
532 return AVERROR_INVALIDDATA;
533 }
534
535 /* get output buffer */
536 c->frame.nb_samples = nb_samples;
537 if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
538 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
539 return ret;
540 }
541 samples = (short *)c->frame.data[0];
542
543 /* use coded_samples when applicable */
544 /* it is always <= nb_samples, so the output buffer will be large enough */
545 if (coded_samples) {
546 if (coded_samples != nb_samples)
547 av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
548 c->frame.nb_samples = nb_samples = coded_samples;
549 }
550
551 src = buf;
552
553 st = avctx->channels == 2 ? 1 : 0;
554
555 switch(avctx->codec->id) {
556 case CODEC_ID_ADPCM_IMA_QT:
557 /* In QuickTime, IMA is encoded by chunks of 34 bytes (=64 samples).
558 Channel data is interleaved per-chunk. */
559 for (channel = 0; channel < avctx->channels; channel++) {
560 int16_t predictor;
561 int step_index;
562 cs = &(c->status[channel]);
563 /* (pppppp) (piiiiiii) */
564
565 /* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */
566 predictor = AV_RB16(src);
567 step_index = predictor & 0x7F;
568 predictor &= 0xFF80;
569
570 src += 2;
571
572 if (cs->step_index == step_index) {
573 int diff = (int)predictor - cs->predictor;
574 if (diff < 0)
575 diff = - diff;
576 if (diff > 0x7f)
577 goto update;
578 } else {
579 update:
580 cs->step_index = step_index;
581 cs->predictor = predictor;
582 }
583
584 if (cs->step_index > 88){
585 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
586 cs->step_index = 88;
587 }
588
589 samples = (short *)c->frame.data[0] + channel;
590
591 for (m = 0; m < 32; m++) {
592 *samples = adpcm_ima_qt_expand_nibble(cs, src[0] & 0x0F, 3);
593 samples += avctx->channels;
594 *samples = adpcm_ima_qt_expand_nibble(cs, src[0] >> 4 , 3);
595 samples += avctx->channels;
596 src ++;
597 }
598 }
599 break;
600 case CODEC_ID_ADPCM_IMA_WAV:
601 if (avctx->block_align != 0 && buf_size > avctx->block_align)
602 buf_size = avctx->block_align;
603
604 for(i=0; i<avctx->channels; i++){
605 cs = &(c->status[i]);
606 cs->predictor = *samples++ = (int16_t)bytestream_get_le16(&src);
607
608 cs->step_index = *src++;
609 if (cs->step_index > 88){
610 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
611 cs->step_index = 88;
612 }
613 if (*src++) av_log(avctx, AV_LOG_ERROR, "unused byte should be null but is %d!!\n", src[-1]); /* unused */
614 }
615
616 for (n = (nb_samples - 1) / 8; n > 0; n--) {
617 for (i = 0; i < avctx->channels; i++) {
618 cs = &c->status[i];
619 for (m = 0; m < 4; m++) {
620 uint8_t v = *src++;
621 *samples = adpcm_ima_expand_nibble(cs, v & 0x0F, 3);
622 samples += avctx->channels;
623 *samples = adpcm_ima_expand_nibble(cs, v >> 4 , 3);
624 samples += avctx->channels;
625 }
626 samples -= 8 * avctx->channels - 1;
627 }
628 samples += 7 * avctx->channels;
629 }
630 break;
631 case CODEC_ID_ADPCM_4XM:
632 for (i = 0; i < avctx->channels; i++)
633 c->status[i].predictor= (int16_t)bytestream_get_le16(&src);
634
635 for (i = 0; i < avctx->channels; i++) {
636 c->status[i].step_index= (int16_t)bytestream_get_le16(&src);
637 c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
638 }
639
640 for (i = 0; i < avctx->channels; i++) {
641 samples = (short *)c->frame.data[0] + i;
642 cs = &c->status[i];
643 for (n = nb_samples >> 1; n > 0; n--, src++) {
644 uint8_t v = *src;
645 *samples = adpcm_ima_expand_nibble(cs, v & 0x0F, 4);
646 samples += avctx->channels;
647 *samples = adpcm_ima_expand_nibble(cs, v >> 4 , 4);
648 samples += avctx->channels;
649 }
650 }
651 break;
652 case CODEC_ID_ADPCM_MS:
653 {
654 int block_predictor;
655
656 if (avctx->block_align != 0 && buf_size > avctx->block_align)
657 buf_size = avctx->block_align;
658
659 block_predictor = av_clip(*src++, 0, 6);
660 c->status[0].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
661 c->status[0].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
662 if (st) {
663 block_predictor = av_clip(*src++, 0, 6);
664 c->status[1].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
665 c->status[1].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
666 }
667 c->status[0].idelta = (int16_t)bytestream_get_le16(&src);
668 if (st){
669 c->status[1].idelta = (int16_t)bytestream_get_le16(&src);
670 }
671
672 c->status[0].sample1 = bytestream_get_le16(&src);
673 if (st) c->status[1].sample1 = bytestream_get_le16(&src);
674 c->status[0].sample2 = bytestream_get_le16(&src);
675 if (st) c->status[1].sample2 = bytestream_get_le16(&src);
676
677 *samples++ = c->status[0].sample2;
678 if (st) *samples++ = c->status[1].sample2;
679 *samples++ = c->status[0].sample1;
680 if (st) *samples++ = c->status[1].sample1;
681 for(n = (nb_samples - 2) >> (1 - st); n > 0; n--, src++) {
682 *samples++ = adpcm_ms_expand_nibble(&c->status[0 ], src[0] >> 4 );
683 *samples++ = adpcm_ms_expand_nibble(&c->status[st], src[0] & 0x0F);
684 }
685 break;
686 }
687 case CODEC_ID_ADPCM_IMA_DK4:
688 if (avctx->block_align != 0 && buf_size > avctx->block_align)
689 buf_size = avctx->block_align;
690
691 for (channel = 0; channel < avctx->channels; channel++) {
692 cs = &c->status[channel];
693 cs->predictor = (int16_t)bytestream_get_le16(&src);
694 cs->step_index = *src++;
695 src++;
696 *samples++ = cs->predictor;
697 }
698 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
699 uint8_t v = *src;
700 *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v >> 4 , 3);
701 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
702 }
703 break;
704 case CODEC_ID_ADPCM_IMA_DK3:
705 {
706 unsigned char last_byte = 0;
707 unsigned char nibble;
708 int decode_top_nibble_next = 0;
709 int end_of_packet = 0;
710 int diff_channel;
711
712 if (avctx->block_align != 0 && buf_size > avctx->block_align)
713 buf_size = avctx->block_align;
714
715 c->status[0].predictor = (int16_t)AV_RL16(src + 10);
716 c->status[1].predictor = (int16_t)AV_RL16(src + 12);
717 c->status[0].step_index = src[14];
718 c->status[1].step_index = src[15];
719 /* sign extend the predictors */
720 src += 16;
721 diff_channel = c->status[1].predictor;
722
723 /* the DK3_GET_NEXT_NIBBLE macro issues the break statement when
724 * the buffer is consumed */
725 while (1) {
726
727 /* for this algorithm, c->status[0] is the sum channel and
728 * c->status[1] is the diff channel */
729
730 /* process the first predictor of the sum channel */
731 DK3_GET_NEXT_NIBBLE();
732 adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
733
734 /* process the diff channel predictor */
735 DK3_GET_NEXT_NIBBLE();
736 adpcm_ima_expand_nibble(&c->status[1], nibble, 3);
737
738 /* process the first pair of stereo PCM samples */
739 diff_channel = (diff_channel + c->status[1].predictor) / 2;
740 *samples++ = c->status[0].predictor + c->status[1].predictor;
741 *samples++ = c->status[0].predictor - c->status[1].predictor;
742
743 /* process the second predictor of the sum channel */
744 DK3_GET_NEXT_NIBBLE();
745 adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
746
747 /* process the second pair of stereo PCM samples */
748 diff_channel = (diff_channel + c->status[1].predictor) / 2;
749 *samples++ = c->status[0].predictor + c->status[1].predictor;
750 *samples++ = c->status[0].predictor - c->status[1].predictor;
751 }
752 break;
753 }
754 case CODEC_ID_ADPCM_IMA_ISS:
755 for (channel = 0; channel < avctx->channels; channel++) {
756 cs = &c->status[channel];
757 cs->predictor = (int16_t)bytestream_get_le16(&src);
758 cs->step_index = *src++;
759 src++;
760 }
761
762 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
763 uint8_t v1, v2;
764 uint8_t v = *src;
765 /* nibbles are swapped for mono */
766 if (st) {
767 v1 = v >> 4;
768 v2 = v & 0x0F;
769 } else {
770 v2 = v >> 4;
771 v1 = v & 0x0F;
772 }
773 *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v1, 3);
774 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3);
775 }
776 break;
777 case CODEC_ID_ADPCM_IMA_WS:
778 case CODEC_ID_ADPCM_IMA_APC:
779 while (src < buf + buf_size) {
780 uint8_t v = *src++;
781 *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4 , 3);
782 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
783 }
784 break;
785 case CODEC_ID_ADPCM_XA:
786 while (buf_size >= 128) {
787 xa_decode(samples, src, &c->status[0], &c->status[1],
788 avctx->channels);
789 src += 128;
790 samples += 28 * 8;
791 buf_size -= 128;
792 }
793 break;
794 case CODEC_ID_ADPCM_IMA_EA_EACS:
795 src += 4; // skip sample count (already read)
796
797 for (i=0; i<=st; i++)
798 c->status[i].step_index = bytestream_get_le32(&src);
799 for (i=0; i<=st; i++)
800 c->status[i].predictor = bytestream_get_le32(&src);
801
802 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
803 *samples++ = adpcm_ima_expand_nibble(&c->status[0], *src>>4, 3);
804 *samples++ = adpcm_ima_expand_nibble(&c->status[st], *src&0x0F, 3);
805 }
806 break;
807 case CODEC_ID_ADPCM_IMA_EA_SEAD:
808 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
809 *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] >> 4, 6);
810 *samples++ = adpcm_ima_expand_nibble(&c->status[st],src[0]&0x0F, 6);
811 }
812 break;
813 case CODEC_ID_ADPCM_EA:
814 {
815 int32_t previous_left_sample, previous_right_sample;
816 int32_t current_left_sample, current_right_sample;
817 int32_t next_left_sample, next_right_sample;
818 int32_t coeff1l, coeff2l, coeff1r, coeff2r;
819 uint8_t shift_left, shift_right;
820
821 /* Each EA ADPCM frame has a 12-byte header followed by 30-byte pieces,
822 each coding 28 stereo samples. */
823
824 src += 4; // skip sample count (already read)
825
826 current_left_sample = (int16_t)bytestream_get_le16(&src);
827 previous_left_sample = (int16_t)bytestream_get_le16(&src);
828 current_right_sample = (int16_t)bytestream_get_le16(&src);
829 previous_right_sample = (int16_t)bytestream_get_le16(&src);
830
831 for (count1 = 0; count1 < nb_samples / 28; count1++) {
832 coeff1l = ea_adpcm_table[ *src >> 4 ];
833 coeff2l = ea_adpcm_table[(*src >> 4 ) + 4];
834 coeff1r = ea_adpcm_table[*src & 0x0F];
835 coeff2r = ea_adpcm_table[(*src & 0x0F) + 4];
836 src++;
837
838 shift_left = 20 - (*src >> 4);
839 shift_right = 20 - (*src & 0x0F);
840 src++;
841
842 for (count2 = 0; count2 < 28; count2++) {
843 next_left_sample = sign_extend(*src >> 4, 4) << shift_left;
844 next_right_sample = sign_extend(*src, 4) << shift_right;
845 src++;
846
847 next_left_sample = (next_left_sample +
848 (current_left_sample * coeff1l) +
849 (previous_left_sample * coeff2l) + 0x80) >> 8;
850 next_right_sample = (next_right_sample +
851 (current_right_sample * coeff1r) +
852 (previous_right_sample * coeff2r) + 0x80) >> 8;
853
854 previous_left_sample = current_left_sample;
855 current_left_sample = av_clip_int16(next_left_sample);
856 previous_right_sample = current_right_sample;
857 current_right_sample = av_clip_int16(next_right_sample);
858 *samples++ = (unsigned short)current_left_sample;
859 *samples++ = (unsigned short)current_right_sample;
860 }
861 }
862
863 if (src - buf == buf_size - 2)
864 src += 2; // Skip terminating 0x0000
865
866 break;
867 }
868 case CODEC_ID_ADPCM_EA_MAXIS_XA:
869 {
870 int coeff[2][2], shift[2];
871
872 for(channel = 0; channel < avctx->channels; channel++) {
873 for (i=0; i<2; i++)
874 coeff[channel][i] = ea_adpcm_table[(*src >> 4) + 4*i];
875 shift[channel] = 20 - (*src & 0x0F);
876 src++;
877 }
878 for (count1 = 0; count1 < nb_samples / 2; count1++) {
879 for(i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */
880 for(channel = 0; channel < avctx->channels; channel++) {
881 int32_t sample = sign_extend(src[channel] >> i, 4) << shift[channel];
882 sample = (sample +
883 c->status[channel].sample1 * coeff[channel][0] +
884 c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8;
885 c->status[channel].sample2 = c->status[channel].sample1;
886 c->status[channel].sample1 = av_clip_int16(sample);
887 *samples++ = c->status[channel].sample1;
888 }
889 }
890 src+=avctx->channels;
891 }
892 /* consume whole packet */
893 src = buf + buf_size;
894 break;
895 }
896 case CODEC_ID_ADPCM_EA_R1:
897 case CODEC_ID_ADPCM_EA_R2:
898 case CODEC_ID_ADPCM_EA_R3: {
899 /* channel numbering
900 2chan: 0=fl, 1=fr
901 4chan: 0=fl, 1=rl, 2=fr, 3=rr
902 6chan: 0=fl, 1=c, 2=fr, 3=rl, 4=rr, 5=sub */
903 const int big_endian = avctx->codec->id == CODEC_ID_ADPCM_EA_R3;
904 int32_t previous_sample, current_sample, next_sample;
905 int32_t coeff1, coeff2;
906 uint8_t shift;
907 unsigned int channel;
908 uint16_t *samplesC;
909 const uint8_t *srcC;
910 const uint8_t *src_end = buf + buf_size;
911 int count = 0;
912
913 src += 4; // skip sample count (already read)
914
915 for (channel=0; channel<avctx->channels; channel++) {
916 int32_t offset = (big_endian ? bytestream_get_be32(&src)
917 : bytestream_get_le32(&src))
918 + (avctx->channels-channel-1) * 4;
919
920 if ((offset < 0) || (offset >= src_end - src - 4)) break;
921 srcC = src + offset;
922 samplesC = samples + channel;
923
924 if (avctx->codec->id == CODEC_ID_ADPCM_EA_R1) {
925 current_sample = (int16_t)bytestream_get_le16(&srcC);
926 previous_sample = (int16_t)bytestream_get_le16(&srcC);
927 } else {
928 current_sample = c->status[channel].predictor;
929 previous_sample = c->status[channel].prev_sample;
930 }
931
932 for (count1 = 0; count1 < nb_samples / 28; count1++) {
933 if (*srcC == 0xEE) { /* only seen in R2 and R3 */
934 srcC++;
935 if (srcC > src_end - 30*2) break;
936 current_sample = (int16_t)bytestream_get_be16(&srcC);
937 previous_sample = (int16_t)bytestream_get_be16(&srcC);
938
939 for (count2=0; count2<28; count2++) {
940 *samplesC = (int16_t)bytestream_get_be16(&srcC);
941 samplesC += avctx->channels;
942 }
943 } else {
944 coeff1 = ea_adpcm_table[ *srcC>>4 ];
945 coeff2 = ea_adpcm_table[(*srcC>>4) + 4];
946 shift = 20 - (*srcC++ & 0x0F);
947
948 if (srcC > src_end - 14) break;
949 for (count2=0; count2<28; count2++) {
950 if (count2 & 1)
951 next_sample = sign_extend(*srcC++, 4) << shift;
952 else
953 next_sample = sign_extend(*srcC >> 4, 4) << shift;
954
955 next_sample += (current_sample * coeff1) +
956 (previous_sample * coeff2);
957 next_sample = av_clip_int16(next_sample >> 8);
958
959 previous_sample = current_sample;
960 current_sample = next_sample;
961 *samplesC = current_sample;
962 samplesC += avctx->channels;
963 }
964 }
965 }
966 if (!count) {
967 count = count1;
968 } else if (count != count1) {
969 av_log(avctx, AV_LOG_WARNING, "per-channel sample count mismatch\n");
970 count = FFMAX(count, count1);
971 }
972
973 if (avctx->codec->id != CODEC_ID_ADPCM_EA_R1) {
974 c->status[channel].predictor = current_sample;
975 c->status[channel].prev_sample = previous_sample;
976 }
977 }
978
979 c->frame.nb_samples = count * 28;
980 src = src_end;
981 break;
982 }
983 case CODEC_ID_ADPCM_EA_XAS:
984 for (channel=0; channel<avctx->channels; channel++) {
985 int coeff[2][4], shift[4];
986 short *s2, *s = &samples[channel];
987 for (n=0; n<4; n++, s+=32*avctx->channels) {
988 for (i=0; i<2; i++)
989 coeff[i][n] = ea_adpcm_table[(src[0]&0x0F)+4*i];
990 shift[n] = 20 - (src[2] & 0x0F);
991 for (s2=s, i=0; i<2; i++, src+=2, s2+=avctx->channels)
992 s2[0] = (src[0]&0xF0) + (src[1]<<8);
993 }
994
995 for (m=2; m<32; m+=2) {
996 s = &samples[m*avctx->channels + channel];
997 for (n=0; n<4; n++, src++, s+=32*avctx->channels) {
998 for (s2=s, i=0; i<8; i+=4, s2+=avctx->channels) {
999 int level = sign_extend(*src >> (4 - i), 4) << shift[n];
1000 int pred = s2[-1*avctx->channels] * coeff[0][n]
1001 + s2[-2*avctx->channels] * coeff[1][n];
1002 s2[0] = av_clip_int16((level + pred + 0x80) >> 8);
1003 }
1004 }
1005 }
1006 }
1007 break;
1008 case CODEC_ID_ADPCM_IMA_AMV:
1009 case CODEC_ID_ADPCM_IMA_SMJPEG:
1010 if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) {
1011 c->status[0].predictor = sign_extend(bytestream_get_le16(&src), 16);
1012 c->status[0].step_index = bytestream_get_le16(&src);
1013 src += 4;
1014 } else {
1015 c->status[0].predictor = sign_extend(bytestream_get_be16(&src), 16);
1016 c->status[0].step_index = bytestream_get_byte(&src);
1017 src += 1;
1018 }
1019
1020 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
1021 char hi, lo;
1022 lo = *src & 0x0F;
1023 hi = *src >> 4;
1024
1025 if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV)
1026 FFSWAP(char, hi, lo);
1027
1028 *samples++ = adpcm_ima_expand_nibble(&c->status[0],
1029 lo, 3);
1030 *samples++ = adpcm_ima_expand_nibble(&c->status[0],
1031 hi, 3);
1032 }
1033 break;
1034 case CODEC_ID_ADPCM_CT:
1035 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
1036 uint8_t v = *src;
1037 *samples++ = adpcm_ct_expand_nibble(&c->status[0 ], v >> 4 );
1038 *samples++ = adpcm_ct_expand_nibble(&c->status[st], v & 0x0F);
1039 }
1040 break;
1041 case CODEC_ID_ADPCM_SBPRO_4:
1042 case CODEC_ID_ADPCM_SBPRO_3:
1043 case CODEC_ID_ADPCM_SBPRO_2:
1044 if (!c->status[0].step_index) {
1045 /* the first byte is a raw sample */
1046 *samples++ = 128 * (*src++ - 0x80);
1047 if (st)
1048 *samples++ = 128 * (*src++ - 0x80);
1049 c->status[0].step_index = 1;
1050 nb_samples--;
1051 }
1052 if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_4) {
1053 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
1054 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1055 src[0] >> 4, 4, 0);
1056 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
1057 src[0] & 0x0F, 4, 0);
1058 }
1059 } else if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_3) {
1060 for (n = nb_samples / 3; n > 0; n--, src++) {
1061 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1062 src[0] >> 5 , 3, 0);
1063 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1064 (src[0] >> 2) & 0x07, 3, 0);
1065 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1066 src[0] & 0x03, 2, 0);
1067 }
1068 } else {
1069 for (n = nb_samples >> (2 - st); n > 0; n--, src++) {
1070 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1071 src[0] >> 6 , 2, 2);
1072 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
1073 (src[0] >> 4) & 0x03, 2, 2);
1074 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
1075 (src[0] >> 2) & 0x03, 2, 2);
1076 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
1077 src[0] & 0x03, 2, 2);
1078 }
1079 }
1080 break;
1081 case CODEC_ID_ADPCM_SWF:
1082 {
1083 GetBitContext gb;
1084 const int *table;
1085 int k0, signmask, nb_bits, count;
1086 int size = buf_size*8;
1087
1088 init_get_bits(&gb, buf, size);
1089
1090 //read bits & initial values
1091 nb_bits = get_bits(&gb, 2)+2;
1092 //av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", nb_bits);
1093 table = swf_index_tables[nb_bits-2];
1094 k0 = 1 << (nb_bits-2);
1095 signmask = 1 << (nb_bits-1);
1096
1097 while (get_bits_count(&gb) <= size - 22*avctx->channels) {
1098 for (i = 0; i < avctx->channels; i++) {
1099 *samples++ = c->status[i].predictor = get_sbits(&gb, 16);
1100 c->status[i].step_index = get_bits(&gb, 6);
1101 }
1102
1103 for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) {
1104 int i;
1105
1106 for (i = 0; i < avctx->channels; i++) {
1107 // similar to IMA adpcm
1108 int delta = get_bits(&gb, nb_bits);
1109 int step = ff_adpcm_step_table[c->status[i].step_index];
1110 long vpdiff = 0; // vpdiff = (delta+0.5)*step/4
1111 int k = k0;
1112
1113 do {
1114 if (delta & k)
1115 vpdiff += step;
1116 step >>= 1;
1117 k >>= 1;
1118 } while(k);
1119 vpdiff += step;
1120
1121 if (delta & signmask)
1122 c->status[i].predictor -= vpdiff;
1123 else
1124 c->status[i].predictor += vpdiff;
1125
1126 c->status[i].step_index += table[delta & (~signmask)];
1127
1128 c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
1129 c->status[i].predictor = av_clip_int16(c->status[i].predictor);
1130
1131 *samples++ = c->status[i].predictor;
1132 }
1133 }
1134 }
1135 src += buf_size;
1136 break;
1137 }
1138 case CODEC_ID_ADPCM_YAMAHA:
1139 for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
1140 uint8_t v = *src;
1141 *samples++ = adpcm_yamaha_expand_nibble(&c->status[0 ], v & 0x0F);
1142 *samples++ = adpcm_yamaha_expand_nibble(&c->status[st], v >> 4 );
1143 }
1144 break;
1145 case CODEC_ID_ADPCM_THP:
1146 {
1147 int table[2][16];
1148 int prev[2][2];
1149 int ch;
1150
1151 src += 4; // skip channel size
1152 src += 4; // skip number of samples (already read)
1153
1154 for (i = 0; i < 32; i++)
1155 table[0][i] = (int16_t)bytestream_get_be16(&src);
1156
1157 /* Initialize the previous sample. */
1158 for (i = 0; i < 4; i++)
1159 prev[0][i] = (int16_t)bytestream_get_be16(&src);
1160
1161 for (ch = 0; ch <= st; ch++) {
1162 samples = (short *)c->frame.data[0] + ch;
1163
1164 /* Read in every sample for this channel. */
1165 for (i = 0; i < nb_samples / 14; i++) {
1166 int index = (*src >> 4) & 7;
1167 unsigned int exp = *src++ & 15;
1168 int factor1 = table[ch][index * 2];
1169 int factor2 = table[ch][index * 2 + 1];
1170
1171 /* Decode 14 samples. */
1172 for (n = 0; n < 14; n++) {
1173 int32_t sampledat;
1174 if(n&1) sampledat = sign_extend(*src++, 4);
1175 else sampledat = sign_extend(*src >> 4, 4);
1176
1177 sampledat = ((prev[ch][0]*factor1
1178 + prev[ch][1]*factor2) >> 11) + (sampledat << exp);
1179 *samples = av_clip_int16(sampledat);
1180 prev[ch][1] = prev[ch][0];
1181 prev[ch][0] = *samples++;
1182
1183 /* In case of stereo, skip one sample, this sample
1184 is for the other channel. */
1185 samples += st;
1186 }
1187 }
1188 }
1189 break;
1190 }
1191
1192 default:
1193 return -1;
1194 }
1195
1196 *got_frame_ptr = 1;
1197 *(AVFrame *)data = c->frame;
1198
1199 return src - buf;
1200 }
1201
1202
1203 #define ADPCM_DECODER(id_, name_, long_name_) \
1204 AVCodec ff_ ## name_ ## _decoder = { \
1205 .name = #name_, \
1206 .type = AVMEDIA_TYPE_AUDIO, \
1207 .id = id_, \
1208 .priv_data_size = sizeof(ADPCMDecodeContext), \
1209 .init = adpcm_decode_init, \
1210 .decode = adpcm_decode_frame, \
1211 .capabilities = CODEC_CAP_DR1, \
1212 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
1213 }
1214
1215 /* Note: Do not forget to add new entries to the Makefile as well. */
1216 ADPCM_DECODER(CODEC_ID_ADPCM_4XM, adpcm_4xm, "ADPCM 4X Movie");
1217 ADPCM_DECODER(CODEC_ID_ADPCM_CT, adpcm_ct, "ADPCM Creative Technology");
1218 ADPCM_DECODER(CODEC_ID_ADPCM_EA, adpcm_ea, "ADPCM Electronic Arts");
1219 ADPCM_DECODER(CODEC_ID_ADPCM_EA_MAXIS_XA, adpcm_ea_maxis_xa, "ADPCM Electronic Arts Maxis CDROM XA");
1220 ADPCM_DECODER(CODEC_ID_ADPCM_EA_R1, adpcm_ea_r1, "ADPCM Electronic Arts R1");
1221 ADPCM_DECODER(CODEC_ID_ADPCM_EA_R2, adpcm_ea_r2, "ADPCM Electronic Arts R2");
1222 ADPCM_DECODER(CODEC_ID_ADPCM_EA_R3, adpcm_ea_r3, "ADPCM Electronic Arts R3");
1223 ADPCM_DECODER(CODEC_ID_ADPCM_EA_XAS, adpcm_ea_xas, "ADPCM Electronic Arts XAS");
1224 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_AMV, adpcm_ima_amv, "ADPCM IMA AMV");
1225 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_APC, adpcm_ima_apc, "ADPCM IMA CRYO APC");
1226 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3, "ADPCM IMA Duck DK3");
1227 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4, "ADPCM IMA Duck DK4");
1228 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS");
1229 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead, "ADPCM IMA Electronic Arts SEAD");
1230 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_ISS, adpcm_ima_iss, "ADPCM IMA Funcom ISS");
1231 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt, "ADPCM IMA QuickTime");
1232 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg, "ADPCM IMA Loki SDL MJPEG");
1233 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav, "ADPCM IMA WAV");
1234 ADPCM_DECODER(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws, "ADPCM IMA Westwood");
1235 ADPCM_DECODER(CODEC_ID_ADPCM_MS, adpcm_ms, "ADPCM Microsoft");
1236 ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2, "ADPCM Sound Blaster Pro 2-bit");
1237 ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3, "ADPCM Sound Blaster Pro 2.6-bit");
1238 ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4, "ADPCM Sound Blaster Pro 4-bit");
1239 ADPCM_DECODER(CODEC_ID_ADPCM_SWF, adpcm_swf, "ADPCM Shockwave Flash");
1240 ADPCM_DECODER(CODEC_ID_ADPCM_THP, adpcm_thp, "ADPCM Nintendo Gamecube THP");
1241 ADPCM_DECODER(CODEC_ID_ADPCM_XA, adpcm_xa, "ADPCM CDROM XA");
1242 ADPCM_DECODER(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha, "ADPCM Yamaha");