2 * Copyright (c) 2001-2003 The ffmpeg Project
4 * This file is part of FFmpeg.
6 * FFmpeg 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 * FFmpeg 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 FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "bytestream.h"
26 #include "adpcm_data.h"
31 * First version by Francois Revol (revol@free.fr)
32 * Fringe ADPCM codecs (e.g., DK3, DK4, Westwood)
33 * by Mike Melanson (melanson@pcisys.net)
35 * See ADPCM decoder reference documents for codec information.
38 typedef struct TrellisPath {
43 typedef struct TrellisNode {
51 typedef struct ADPCMEncodeContext {
52 ADPCMChannelStatus status[6];
54 TrellisNode *node_buf;
55 TrellisNode **nodep_buf;
56 uint8_t *trellis_hash;
59 #define FREEZE_INTERVAL 128
61 static av_cold int adpcm_encode_init(AVCodecContext *avctx)
63 ADPCMEncodeContext *s = avctx->priv_data;
66 if (avctx->channels > 2)
67 return -1; /* only stereo or mono =) */
69 if (avctx->trellis && (unsigned)avctx->trellis > 16U) {
70 av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
75 int frontier = 1 << avctx->trellis;
76 int max_paths = frontier * FREEZE_INTERVAL;
77 FF_ALLOC_OR_GOTO(avctx, s->paths,
78 max_paths * sizeof(*s->paths), error);
79 FF_ALLOC_OR_GOTO(avctx, s->node_buf,
80 2 * frontier * sizeof(*s->node_buf), error);
81 FF_ALLOC_OR_GOTO(avctx, s->nodep_buf,
82 2 * frontier * sizeof(*s->nodep_buf), error);
83 FF_ALLOC_OR_GOTO(avctx, s->trellis_hash,
84 65536 * sizeof(*s->trellis_hash), error);
87 avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
89 switch (avctx->codec->id) {
90 case CODEC_ID_ADPCM_IMA_WAV:
91 /* each 16 bits sample gives one nibble
92 and we have 4 bytes per channel overhead */
93 avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 /
94 (4 * avctx->channels) + 1;
95 /* seems frame_size isn't taken into account...
96 have to buffer the samples :-( */
97 avctx->block_align = BLKSIZE;
98 avctx->bits_per_coded_sample = 4;
100 case CODEC_ID_ADPCM_IMA_QT:
101 avctx->frame_size = 64;
102 avctx->block_align = 34 * avctx->channels;
104 case CODEC_ID_ADPCM_MS:
105 /* each 16 bits sample gives one nibble
106 and we have 7 bytes per channel overhead */
107 avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / avctx->channels + 2;
108 avctx->block_align = BLKSIZE;
109 avctx->bits_per_coded_sample = 4;
110 avctx->extradata_size = 32;
111 extradata = avctx->extradata = av_malloc(avctx->extradata_size);
113 return AVERROR(ENOMEM);
114 bytestream_put_le16(&extradata, avctx->frame_size);
115 bytestream_put_le16(&extradata, 7); /* wNumCoef */
116 for (i = 0; i < 7; i++) {
117 bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff1[i] * 4);
118 bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff2[i] * 4);
121 case CODEC_ID_ADPCM_YAMAHA:
122 avctx->frame_size = BLKSIZE * avctx->channels;
123 avctx->block_align = BLKSIZE;
125 case CODEC_ID_ADPCM_SWF:
126 if (avctx->sample_rate != 11025 &&
127 avctx->sample_rate != 22050 &&
128 avctx->sample_rate != 44100) {
129 av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, "
133 avctx->frame_size = 512 * (avctx->sample_rate / 11025);
139 avctx->coded_frame = avcodec_alloc_frame();
140 avctx->coded_frame->key_frame= 1;
145 av_freep(&s->node_buf);
146 av_freep(&s->nodep_buf);
147 av_freep(&s->trellis_hash);
151 static av_cold int adpcm_encode_close(AVCodecContext *avctx)
153 ADPCMEncodeContext *s = avctx->priv_data;
154 av_freep(&avctx->coded_frame);
156 av_freep(&s->node_buf);
157 av_freep(&s->nodep_buf);
158 av_freep(&s->trellis_hash);
164 static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c,
167 int delta = sample - c->prev_sample;
168 int nibble = FFMIN(7, abs(delta) * 4 /
169 ff_adpcm_step_table[c->step_index]) + (delta < 0) * 8;
170 c->prev_sample += ((ff_adpcm_step_table[c->step_index] *
171 ff_adpcm_yamaha_difflookup[nibble]) / 8);
172 c->prev_sample = av_clip_int16(c->prev_sample);
173 c->step_index = av_clip(c->step_index + ff_adpcm_index_table[nibble], 0, 88);
177 static inline unsigned char adpcm_ima_qt_compress_sample(ADPCMChannelStatus *c,
180 int delta = sample - c->prev_sample;
181 int diff, step = ff_adpcm_step_table[c->step_index];
182 int nibble = 8*(delta < 0);
185 diff = delta + (step >> 3);
204 c->prev_sample -= diff;
206 c->prev_sample += diff;
208 c->prev_sample = av_clip_int16(c->prev_sample);
209 c->step_index = av_clip(c->step_index + ff_adpcm_index_table[nibble], 0, 88);
214 static inline unsigned char adpcm_ms_compress_sample(ADPCMChannelStatus *c,
217 int predictor, nibble, bias;
219 predictor = (((c->sample1) * (c->coeff1)) +
220 (( c->sample2) * (c->coeff2))) / 64;
222 nibble = sample - predictor;
224 bias = c->idelta / 2;
226 bias = -c->idelta / 2;
228 nibble = (nibble + bias) / c->idelta;
229 nibble = av_clip(nibble, -8, 7) & 0x0F;
231 predictor += (signed)((nibble & 0x08) ? (nibble - 0x10) : nibble) * c->idelta;
233 c->sample2 = c->sample1;
234 c->sample1 = av_clip_int16(predictor);
236 c->idelta = (ff_adpcm_AdaptationTable[(int)nibble] * c->idelta) >> 8;
243 static inline unsigned char adpcm_yamaha_compress_sample(ADPCMChannelStatus *c,
253 delta = sample - c->predictor;
255 nibble = FFMIN(7, abs(delta) * 4 / c->step) + (delta < 0) * 8;
257 c->predictor += ((c->step * ff_adpcm_yamaha_difflookup[nibble]) / 8);
258 c->predictor = av_clip_int16(c->predictor);
259 c->step = (c->step * ff_adpcm_yamaha_indexscale[nibble]) >> 8;
260 c->step = av_clip(c->step, 127, 24567);
265 static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
266 uint8_t *dst, ADPCMChannelStatus *c, int n)
268 //FIXME 6% faster if frontier is a compile-time constant
269 ADPCMEncodeContext *s = avctx->priv_data;
270 const int frontier = 1 << avctx->trellis;
271 const int stride = avctx->channels;
272 const int version = avctx->codec->id;
273 TrellisPath *paths = s->paths, *p;
274 TrellisNode *node_buf = s->node_buf;
275 TrellisNode **nodep_buf = s->nodep_buf;
276 TrellisNode **nodes = nodep_buf; // nodes[] is always sorted by .ssd
277 TrellisNode **nodes_next = nodep_buf + frontier;
278 int pathn = 0, froze = -1, i, j, k, generation = 0;
279 uint8_t *hash = s->trellis_hash;
280 memset(hash, 0xff, 65536 * sizeof(*hash));
282 memset(nodep_buf, 0, 2 * frontier * sizeof(*nodep_buf));
283 nodes[0] = node_buf + frontier;
286 nodes[0]->step = c->step_index;
287 nodes[0]->sample1 = c->sample1;
288 nodes[0]->sample2 = c->sample2;
289 if (version == CODEC_ID_ADPCM_IMA_WAV ||
290 version == CODEC_ID_ADPCM_IMA_QT ||
291 version == CODEC_ID_ADPCM_SWF)
292 nodes[0]->sample1 = c->prev_sample;
293 if (version == CODEC_ID_ADPCM_MS)
294 nodes[0]->step = c->idelta;
295 if (version == CODEC_ID_ADPCM_YAMAHA) {
297 nodes[0]->step = 127;
298 nodes[0]->sample1 = 0;
300 nodes[0]->step = c->step;
301 nodes[0]->sample1 = c->predictor;
305 for (i = 0; i < n; i++) {
306 TrellisNode *t = node_buf + frontier*(i&1);
308 int sample = samples[i * stride];
310 memset(nodes_next, 0, frontier * sizeof(TrellisNode*));
311 for (j = 0; j < frontier && nodes[j]; j++) {
312 // higher j have higher ssd already, so they're likely
313 // to yield a suboptimal next sample too
314 const int range = (j < frontier / 2) ? 1 : 0;
315 const int step = nodes[j]->step;
317 if (version == CODEC_ID_ADPCM_MS) {
318 const int predictor = ((nodes[j]->sample1 * c->coeff1) +
319 (nodes[j]->sample2 * c->coeff2)) / 64;
320 const int div = (sample - predictor) / step;
321 const int nmin = av_clip(div-range, -8, 6);
322 const int nmax = av_clip(div+range, -7, 7);
323 for (nidx = nmin; nidx <= nmax; nidx++) {
324 const int nibble = nidx & 0xf;
325 int dec_sample = predictor + nidx * step;
326 #define STORE_NODE(NAME, STEP_INDEX)\
332 dec_sample = av_clip_int16(dec_sample);\
333 d = sample - dec_sample;\
334 ssd = nodes[j]->ssd + d*d;\
335 /* Check for wraparound, skip such samples completely. \
336 * Note, changing ssd to a 64 bit variable would be \
337 * simpler, avoiding this check, but it's slower on \
338 * x86 32 bit at the moment. */\
339 if (ssd < nodes[j]->ssd)\
341 /* Collapse any two states with the same previous sample value. \
342 * One could also distinguish states by step and by 2nd to last
343 * sample, but the effects of that are negligible.
344 * Since nodes in the previous generation are iterated
345 * through a heap, they're roughly ordered from better to
346 * worse, but not strictly ordered. Therefore, an earlier
347 * node with the same sample value is better in most cases
348 * (and thus the current is skipped), but not strictly
349 * in all cases. Only skipping samples where ssd >=
350 * ssd of the earlier node with the same sample gives
351 * slightly worse quality, though, for some reason. */ \
352 h = &hash[(uint16_t) dec_sample];\
353 if (*h == generation)\
355 if (heap_pos < frontier) {\
358 /* Try to replace one of the leaf nodes with the new \
359 * one, but try a different slot each time. */\
360 pos = (frontier >> 1) +\
361 (heap_pos & ((frontier >> 1) - 1));\
362 if (ssd > nodes_next[pos]->ssd)\
367 u = nodes_next[pos];\
369 assert(pathn < FREEZE_INTERVAL << avctx->trellis);\
371 nodes_next[pos] = u;\
375 u->step = STEP_INDEX;\
376 u->sample2 = nodes[j]->sample1;\
377 u->sample1 = dec_sample;\
378 paths[u->path].nibble = nibble;\
379 paths[u->path].prev = nodes[j]->path;\
380 /* Sift the newly inserted node up in the heap to \
381 * restore the heap property. */\
383 int parent = (pos - 1) >> 1;\
384 if (nodes_next[parent]->ssd <= ssd)\
386 FFSWAP(TrellisNode*, nodes_next[parent], nodes_next[pos]);\
390 STORE_NODE(ms, FFMAX(16,
391 (ff_adpcm_AdaptationTable[nibble] * step) >> 8));
393 } else if (version == CODEC_ID_ADPCM_IMA_WAV ||
394 version == CODEC_ID_ADPCM_IMA_QT ||
395 version == CODEC_ID_ADPCM_SWF) {
396 #define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)\
397 const int predictor = nodes[j]->sample1;\
398 const int div = (sample - predictor) * 4 / STEP_TABLE;\
399 int nmin = av_clip(div - range, -7, 6);\
400 int nmax = av_clip(div + range, -6, 7);\
402 nmin--; /* distinguish -0 from +0 */\
405 for (nidx = nmin; nidx <= nmax; nidx++) {\
406 const int nibble = nidx < 0 ? 7 - nidx : nidx;\
407 int dec_sample = predictor +\
409 ff_adpcm_yamaha_difflookup[nibble]) / 8;\
410 STORE_NODE(NAME, STEP_INDEX);\
412 LOOP_NODES(ima, ff_adpcm_step_table[step],
413 av_clip(step + ff_adpcm_index_table[nibble], 0, 88));
414 } else { //CODEC_ID_ADPCM_YAMAHA
415 LOOP_NODES(yamaha, step,
416 av_clip((step * ff_adpcm_yamaha_indexscale[nibble]) >> 8,
428 if (generation == 255) {
429 memset(hash, 0xff, 65536 * sizeof(*hash));
434 if (nodes[0]->ssd > (1 << 28)) {
435 for (j = 1; j < frontier && nodes[j]; j++)
436 nodes[j]->ssd -= nodes[0]->ssd;
440 // merge old paths to save memory
441 if (i == froze + FREEZE_INTERVAL) {
442 p = &paths[nodes[0]->path];
443 for (k = i; k > froze; k--) {
449 // other nodes might use paths that don't coincide with the frozen one.
450 // checking which nodes do so is too slow, so just kill them all.
451 // this also slightly improves quality, but I don't know why.
452 memset(nodes + 1, 0, (frontier - 1) * sizeof(TrellisNode*));
456 p = &paths[nodes[0]->path];
457 for (i = n - 1; i > froze; i--) {
462 c->predictor = nodes[0]->sample1;
463 c->sample1 = nodes[0]->sample1;
464 c->sample2 = nodes[0]->sample2;
465 c->step_index = nodes[0]->step;
466 c->step = nodes[0]->step;
467 c->idelta = nodes[0]->step;
470 static int adpcm_encode_frame(AVCodecContext *avctx,
471 unsigned char *frame, int buf_size, void *data)
476 ADPCMEncodeContext *c = avctx->priv_data;
480 samples = (short *)data;
481 st = avctx->channels == 2;
482 /* n = (BLKSIZE - 4 * avctx->channels) / (2 * 8 * avctx->channels); */
484 switch(avctx->codec->id) {
485 case CODEC_ID_ADPCM_IMA_WAV:
486 n = avctx->frame_size / 8;
487 c->status[0].prev_sample = (signed short)samples[0]; /* XXX */
488 /* c->status[0].step_index = 0;
489 XXX: not sure how to init the state machine */
490 bytestream_put_le16(&dst, c->status[0].prev_sample);
491 *dst++ = (unsigned char)c->status[0].step_index;
492 *dst++ = 0; /* unknown */
494 if (avctx->channels == 2) {
495 c->status[1].prev_sample = (signed short)samples[0];
496 /* c->status[1].step_index = 0; */
497 bytestream_put_le16(&dst, c->status[1].prev_sample);
498 *dst++ = (unsigned char)c->status[1].step_index;
503 /* stereo: 4 bytes (8 samples) for left,
504 4 bytes for right, 4 bytes left, ... */
505 if (avctx->trellis > 0) {
506 FF_ALLOC_OR_GOTO(avctx, buf, 2 * n * 8, error);
507 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n * 8);
508 if (avctx->channels == 2)
509 adpcm_compress_trellis(avctx, samples + 1, buf + n * 8,
510 &c->status[1], n * 8);
511 for (i = 0; i < n; i++) {
512 *dst++ = buf[8 * i + 0] | (buf[8 * i + 1] << 4);
513 *dst++ = buf[8 * i + 2] | (buf[8 * i + 3] << 4);
514 *dst++ = buf[8 * i + 4] | (buf[8 * i + 5] << 4);
515 *dst++ = buf[8 * i + 6] | (buf[8 * i + 7] << 4);
516 if (avctx->channels == 2) {
517 uint8_t *buf1 = buf + n * 8;
518 *dst++ = buf1[8 * i + 0] | (buf1[8 * i + 1] << 4);
519 *dst++ = buf1[8 * i + 2] | (buf1[8 * i + 3] << 4);
520 *dst++ = buf1[8 * i + 4] | (buf1[8 * i + 5] << 4);
521 *dst++ = buf1[8 * i + 6] | (buf1[8 * i + 7] << 4);
527 *dst = adpcm_ima_compress_sample(&c->status[0], samples[0]);
528 *dst++ |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels ]) << 4;
529 *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 2]);
530 *dst++ |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 3]) << 4;
531 *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 4]);
532 *dst++ |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 5]) << 4;
533 *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 6]);
534 *dst++ |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 7]) << 4;
536 if (avctx->channels == 2) {
537 *dst = adpcm_ima_compress_sample(&c->status[1], samples[1 ]);
538 *dst++ |= adpcm_ima_compress_sample(&c->status[1], samples[3 ]) << 4;
539 *dst = adpcm_ima_compress_sample(&c->status[1], samples[5 ]);
540 *dst++ |= adpcm_ima_compress_sample(&c->status[1], samples[7 ]) << 4;
541 *dst = adpcm_ima_compress_sample(&c->status[1], samples[9 ]);
542 *dst++ |= adpcm_ima_compress_sample(&c->status[1], samples[11]) << 4;
543 *dst = adpcm_ima_compress_sample(&c->status[1], samples[13]);
544 *dst++ |= adpcm_ima_compress_sample(&c->status[1], samples[15]) << 4;
546 samples += 8 * avctx->channels;
550 case CODEC_ID_ADPCM_IMA_QT:
554 init_put_bits(&pb, dst, buf_size * 8);
556 for (ch = 0; ch < avctx->channels; ch++) {
557 put_bits(&pb, 9, (c->status[ch].prev_sample + 0x10000) >> 7);
558 put_bits(&pb, 7, c->status[ch].step_index);
559 if (avctx->trellis > 0) {
561 adpcm_compress_trellis(avctx, samples+ch, buf, &c->status[ch], 64);
562 for (i = 0; i < 64; i++)
563 put_bits(&pb, 4, buf[i ^ 1]);
565 for (i = 0; i < 64; i += 2) {
567 t1 = adpcm_ima_qt_compress_sample(&c->status[ch],
568 samples[avctx->channels * (i + 0) + ch]);
569 t2 = adpcm_ima_qt_compress_sample(&c->status[ch],
570 samples[avctx->channels * (i + 1) + ch]);
571 put_bits(&pb, 4, t2);
572 put_bits(&pb, 4, t1);
578 dst += put_bits_count(&pb) >> 3;
581 case CODEC_ID_ADPCM_SWF:
585 init_put_bits(&pb, dst, buf_size * 8);
587 n = avctx->frame_size - 1;
589 // store AdpcmCodeSize
590 put_bits(&pb, 2, 2); // set 4-bit flash adpcm format
592 // init the encoder state
593 for (i = 0; i < avctx->channels; i++) {
594 // clip step so it fits 6 bits
595 c->status[i].step_index = av_clip(c->status[i].step_index, 0, 63);
596 put_sbits(&pb, 16, samples[i]);
597 put_bits(&pb, 6, c->status[i].step_index);
598 c->status[i].prev_sample = (signed short)samples[i];
601 if (avctx->trellis > 0) {
602 FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
603 adpcm_compress_trellis(avctx, samples + 2, buf, &c->status[0], n);
604 if (avctx->channels == 2)
605 adpcm_compress_trellis(avctx, samples + 3, buf + n,
607 for (i = 0; i < n; i++) {
608 put_bits(&pb, 4, buf[i]);
609 if (avctx->channels == 2)
610 put_bits(&pb, 4, buf[n + i]);
614 for (i = 1; i < avctx->frame_size; i++) {
615 put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0],
616 samples[avctx->channels * i]));
617 if (avctx->channels == 2)
618 put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1],
619 samples[2 * i + 1]));
623 dst += put_bits_count(&pb) >> 3;
626 case CODEC_ID_ADPCM_MS:
627 for (i = 0; i < avctx->channels; i++) {
630 c->status[i].coeff1 = ff_adpcm_AdaptCoeff1[predictor];
631 c->status[i].coeff2 = ff_adpcm_AdaptCoeff2[predictor];
633 for (i = 0; i < avctx->channels; i++) {
634 if (c->status[i].idelta < 16)
635 c->status[i].idelta = 16;
636 bytestream_put_le16(&dst, c->status[i].idelta);
638 for (i = 0; i < avctx->channels; i++)
639 c->status[i].sample2= *samples++;
640 for (i = 0; i < avctx->channels; i++) {
641 c->status[i].sample1 = *samples++;
642 bytestream_put_le16(&dst, c->status[i].sample1);
644 for (i = 0; i < avctx->channels; i++)
645 bytestream_put_le16(&dst, c->status[i].sample2);
647 if (avctx->trellis > 0) {
648 int n = avctx->block_align - 7 * avctx->channels;
649 FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
650 if (avctx->channels == 1) {
651 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n);
652 for (i = 0; i < n; i += 2)
653 *dst++ = (buf[i] << 4) | buf[i + 1];
655 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n);
656 adpcm_compress_trellis(avctx, samples + 1, buf + n, &c->status[1], n);
657 for (i = 0; i < n; i++)
658 *dst++ = (buf[i] << 4) | buf[n + i];
662 for (i = 7 * avctx->channels; i < avctx->block_align; i++) {
664 nibble = adpcm_ms_compress_sample(&c->status[ 0], *samples++) << 4;
665 nibble |= adpcm_ms_compress_sample(&c->status[st], *samples++);
670 case CODEC_ID_ADPCM_YAMAHA:
671 n = avctx->frame_size / 2;
672 if (avctx->trellis > 0) {
673 FF_ALLOC_OR_GOTO(avctx, buf, 2 * n * 2, error);
675 if (avctx->channels == 1) {
676 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n);
677 for (i = 0; i < n; i += 2)
678 *dst++ = buf[i] | (buf[i + 1] << 4);
680 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n);
681 adpcm_compress_trellis(avctx, samples + 1, buf + n, &c->status[1], n);
682 for (i = 0; i < n; i++)
683 *dst++ = buf[i] | (buf[n + i] << 4);
687 for (n *= avctx->channels; n > 0; n--) {
689 nibble = adpcm_yamaha_compress_sample(&c->status[ 0], *samples++);
690 nibble |= adpcm_yamaha_compress_sample(&c->status[st], *samples++) << 4;
702 #define ADPCM_ENCODER(id_, name_, long_name_) \
703 AVCodec ff_ ## name_ ## _encoder = { \
705 .type = AVMEDIA_TYPE_AUDIO, \
707 .priv_data_size = sizeof(ADPCMEncodeContext), \
708 .init = adpcm_encode_init, \
709 .encode = adpcm_encode_frame, \
710 .close = adpcm_encode_close, \
711 .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, \
712 AV_SAMPLE_FMT_NONE}, \
713 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
716 ADPCM_ENCODER(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt, "ADPCM IMA QuickTime");
717 ADPCM_ENCODER(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav, "ADPCM IMA WAV");
718 ADPCM_ENCODER(CODEC_ID_ADPCM_MS, adpcm_ms, "ADPCM Microsoft");
719 ADPCM_ENCODER(CODEC_ID_ADPCM_SWF, adpcm_swf, "ADPCM Shockwave Flash");
720 ADPCM_ENCODER(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha, "ADPCM Yamaha");