85 { -1, -1, -1, -1, 2, 4, 6, 8 },
86 { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }
90 -1, -1, -1, 1, 4, 7, 10, 12,
94 8, 6, 4, 2, -1, -1, -1, -1,
95 -1, -1, -1, -1, 2, 4, 6, 8,
109 unsigned int min_channels = 1;
110 unsigned int max_channels = 2;
230 add = (delta * 2 + 1) * step;
234 if ((nibble & 8) == 0)
235 pred = av_clip(pred + (add >> 3), -32767, 32767);
237 pred = av_clip(pred - (add >> 3), -32767, 32767);
244 c->
step = av_clip(c->
step * 2, 127, 24576);
262 c->
step = av_clip(c->
step, 127, 24576);
275 step_index = av_clip(step_index, 0, 88);
282 diff = ((2 * delta + 1) * step) >>
shift;
284 if (sign) predictor -=
diff;
285 else predictor +=
diff;
301 step_index = av_clip(step_index, 0, 88);
305 diff = (delta * step) >> shift;
307 if (sign) predictor -=
diff;
308 else predictor +=
diff;
318 int step_index, step,
delta, predictor;
322 delta = step * (2 * nibble - 15);
326 c->
predictor = av_clip_int16(predictor >> 4);
342 step_index = av_clip(step_index, 0, 60);
344 predictor = c->
predictor + step * nibble;
354 int nibble, step_index, predictor, sign,
delta,
diff, step,
shift;
360 step_index = av_clip(step_index, 0, 88);
362 sign = nibble & (1 <<
shift);
363 delta = av_mod_uintp2(nibble, shift);
364 diff = ((2 * delta + 1) * step) >>
shift;
366 if (sign) predictor -=
diff;
367 else predictor +=
diff;
383 step_index = av_clip(step_index, 0, 88);
386 if (nibble & 4) diff += step;
387 if (nibble & 2) diff += step >> 1;
388 if (nibble & 1) diff += step >> 2;
406 predictor += ((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->
idelta;
409 c->
sample1 = av_clip_int16(predictor);
412 if (c->
idelta > INT_MAX/768) {
422 int step_index, predictor, sign,
delta,
diff, step;
426 step_index = av_clip(step_index, 0, 48);
430 diff = ((2 * delta + 1) * step) >> 3;
432 if (sign) predictor -=
diff;
433 else predictor +=
diff;
435 c->
predictor = av_clip_intp2(predictor, 11);
451 diff = ((2 * delta + 1) * c->
step) >> 3;
457 c->
step = av_clip(new_step, 511, 32767);
466 sign = nibble & (1<<(size-1));
467 delta = nibble & ((1<<(size-1))-1);
474 if (delta >= (2*size - 3) && c->
step < 3)
476 else if (delta == 0 && c->
step > 0)
492 c->
step = av_clip(c->
step, 127, 24576);
501 c->
step = av_clip_uintp2(c->
step, 5);
512 sample += lookup_sample;
514 sample += lookup_sample >> 1;
516 sample += lookup_sample >> 2;
518 sample += lookup_sample >> 3;
520 sample += lookup_sample >> 4;
522 sample += lookup_sample >> 5;
524 sample += lookup_sample >> 6;
529 sample = av_clip_int16(sample);
532 index = av_clip(index, 0, 88);
549 out0 += sample_offset;
553 out1 += sample_offset;
556 shift = 12 - (in[4+i*2] & 15);
557 filter = in[4+i*2] >> 4;
576 s = t*(1<<
shift) + ((s_1*f0 + s_2*f1+32)>>6);
578 s_1 = av_clip_int16(s);
589 shift = 12 - (in[5+i*2] & 15);
590 filter = in[5+i*2] >> 4;
607 s = t*(1<<
shift) + ((s_1*f0 + s_2*f1+32)>>6);
609 s_1 = av_clip_int16(s);
633 int k0, signmask, nb_bits, count;
634 int size = buf_size*8;
642 k0 = 1 << (nb_bits-2);
643 signmask = 1 << (nb_bits-1);
646 for (i = 0; i < avctx->
channels; i++) {
654 for (i = 0; i < avctx->
channels; i++) {
669 if (delta & signmask)
694 sample = av_clip_int16(sample >> 2);
714 int buf_size,
int *coded_samples,
int *approx_nb_samples)
719 int has_coded_samples = 0;
723 *approx_nb_samples = 0;
731 if (buf_size < 76 * ch)
736 if (buf_size < 34 * ch)
741 if (buf_size < 17 * ch)
758 nb_samples = buf_size * 2 / ch;
775 return (buf_size - header_size) * 2 / ch;
780 has_coded_samples = 1;
781 *coded_samples = bytestream2_get_le32(gb);
782 *coded_samples -= *coded_samples % 28;
783 nb_samples = (buf_size - 12) / 30 * 28;
786 has_coded_samples = 1;
787 *coded_samples = bytestream2_get_le32(gb);
788 nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
791 nb_samples = (buf_size - ch) / ch * 2;
798 has_coded_samples = 1;
801 header_size = 4 + 9 * ch;
802 *coded_samples = bytestream2_get_le32(gb);
805 header_size = 4 + 5 * ch;
806 *coded_samples = bytestream2_get_le32(gb);
809 header_size = 4 + 5 * ch;
810 *coded_samples = bytestream2_get_be32(gb);
813 *coded_samples -= *coded_samples % 28;
814 nb_samples = (buf_size - header_size) * 2 / ch;
815 nb_samples -= nb_samples % 28;
816 *approx_nb_samples = 1;
821 nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
826 if (buf_size < 4 * ch)
828 nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
833 nb_samples = (buf_size - 4 * ch) * 2 / ch;
841 if (buf_size < 4 * ch)
843 nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
849 nb_samples = (buf_size - 6 * ch) * 2 / ch;
854 nb_samples = (buf_size - 16 * (ch / 2)) * 2 / ch;
860 int samples_per_byte;
872 nb_samples += buf_size * samples_per_byte / ch;
877 int buf_bits = buf_size * 8 - 2;
878 int nbits = (bytestream2_get_byte(gb) >> 6) + 2;
879 int block_hdr_size = 22 * ch;
880 int block_size = block_hdr_size + nbits * ch * 4095;
881 int nblocks = buf_bits / block_size;
882 int bits_left = buf_bits - nblocks * block_size;
883 nb_samples = nblocks * 4096;
884 if (bits_left >= block_hdr_size)
885 nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
891 nb_samples = buf_size * 14 / (8 * ch);
894 has_coded_samples = 1;
897 bytestream2_get_le32(gb) :
898 bytestream2_get_be32(gb);
899 buf_size -= 8 + 36 * ch;
901 nb_samples = buf_size / 8 * 14;
902 if (buf_size % 8 > 1)
903 nb_samples += (buf_size % 8 - 1) * 2;
904 *approx_nb_samples = 1;
907 nb_samples = buf_size / (9 * ch) * 16;
910 nb_samples = (buf_size / 128) * 224 / ch;
914 nb_samples = buf_size / (16 * ch) * 28;
917 nb_samples = buf_size / ch;
922 if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
929 int *got_frame_ptr,
AVPacket *avpkt)
933 int buf_size = avpkt->
size;
941 int nb_samples, coded_samples, approx_nb_samples, ret;
945 nb_samples =
get_nb_samples(avctx, &gb, buf_size, &coded_samples, &approx_nb_samples);
946 if (nb_samples <= 0) {
955 samples = (int16_t *)frame->
data[0];
961 if (!approx_nb_samples && coded_samples != nb_samples)
963 frame->
nb_samples = nb_samples = coded_samples;
972 for (channel = 0; channel < avctx->
channels; channel++) {
979 predictor =
sign_extend(bytestream2_get_be16u(&gb), 16);
980 step_index = predictor & 0x7F;
1003 for (m = 0; m < 64; m += 2) {
1004 int byte = bytestream2_get_byteu(&gb);
1029 for (n = 0; n < (nb_samples - 1) / samples_per_block; n++) {
1030 for (i = 0; i < avctx->
channels; i++) {
1034 samples = &samples_p[
i][1 + n * samples_per_block];
1035 for (j = 0; j < block_size; j++) {
1037 (j % 4) + (j / 4) * (avctx->
channels * 4) + i * 4];
1042 for (m = 0; m < samples_per_block; m++) {
1050 for (n = 0; n < (nb_samples - 1) / 8; n++) {
1051 for (i = 0; i < avctx->
channels; i++) {
1053 samples = &samples_p[
i][1 + n * 8];
1054 for (m = 0; m < 8; m += 2) {
1055 int v = bytestream2_get_byteu(&gb);
1064 for (i = 0; i < avctx->
channels; i++)
1067 for (i = 0; i < avctx->
channels; i++) {
1076 for (i = 0; i < avctx->
channels; i++) {
1077 samples = (int16_t *)frame->
data[i];
1079 for (n = nb_samples >> 1; n > 0; n--) {
1080 int v = bytestream2_get_byteu(&gb);
1087 for (i = 0; i < avctx->
channels; i++)
1089 for (i = 0; i < avctx->
channels; i++)
1092 for (n = 0; n < nb_samples >> (1 - st); n++) {
1093 int v = bytestream2_get_byteu(&gb);
1100 int block_predictor;
1103 for (channel = 0; channel < avctx->
channels; channel++) {
1105 block_predictor = bytestream2_get_byteu(&gb);
1106 if (block_predictor > 6) {
1108 channel, block_predictor);
1118 for(n = (nb_samples - 2) >> 1; n > 0; n--) {
1119 int byte = bytestream2_get_byteu(&gb);
1125 block_predictor = bytestream2_get_byteu(&gb);
1126 if (block_predictor > 6) {
1134 block_predictor = bytestream2_get_byteu(&gb);
1135 if (block_predictor > 6) {
1157 for(n = (nb_samples - 2) >> (1 - st); n > 0; n--) {
1158 int byte = bytestream2_get_byteu(&gb);
1166 for (channel = 0; channel < avctx->
channels; channel+=2) {
1169 c->
status[channel + 1].
step = bytestream2_get_le16u(&gb) & 0x1f;
1174 for (n = 0; n < nb_samples; n+=2) {
1175 int v = bytestream2_get_byteu(&gb);
1179 for (n = 0; n < nb_samples; n+=2) {
1180 int v = bytestream2_get_byteu(&gb);
1187 for (channel = 0; channel < avctx->
channels; channel++) {
1197 for (n = (nb_samples - 1) >> (1 - st); n > 0; n--) {
1198 int v = bytestream2_get_byteu(&gb);
1207 int decode_top_nibble_next = 0;
1209 const int16_t *samples_end = samples + avctx->
channels * nb_samples;
1225 #define DK3_GET_NEXT_NIBBLE() \ 1226 if (decode_top_nibble_next) { \ 1227 nibble = last_byte >> 4; \ 1228 decode_top_nibble_next = 0; \ 1230 last_byte = bytestream2_get_byteu(&gb); \ 1231 nibble = last_byte & 0x0F; \ 1232 decode_top_nibble_next = 1; \ 1235 while (samples < samples_end) {
1268 for (channel = 0; channel < avctx->
channels; channel++) {
1279 for (n = nb_samples >> (1 - st); n > 0; n--) {
1281 int v = bytestream2_get_byteu(&gb);
1295 for (channel = 0; channel < avctx->
channels; channel++) {
1299 for (n = 0; n < nb_samples; n += 2) {
1300 int v = bytestream2_get_byteu(&gb);
1307 for (n = nb_samples >> (1 - st); n > 0; n--) {
1308 int v = bytestream2_get_byteu(&gb);
1314 for (n = nb_samples >> (1 - st); n > 0; n--) {
1315 int v = bytestream2_get_byteu(&gb);
1321 for (n = nb_samples / 2; n > 0; n--) {
1322 for (channel = 0; channel < avctx->
channels; channel++) {
1323 int v = bytestream2_get_byteu(&gb);
1331 for (n = nb_samples / 2; n > 0; n--) {
1332 for (channel = 0; channel < avctx->
channels; channel++) {
1333 int v = bytestream2_get_byteu(&gb);
1341 for (n = 0; n < nb_samples / 2; n++) {
1342 int v = bytestream2_get_byteu(&gb);
1348 for (n = nb_samples >> (1 - st); n > 0; n--) {
1349 int v = bytestream2_get_byteu(&gb);
1355 for (channel = 0; channel < avctx->
channels; channel++) {
1365 for (n = 0; n < nb_samples / 2; n++) {
1368 byte[0] = bytestream2_get_byteu(&gb);
1370 byte[1] = bytestream2_get_byteu(&gb);
1371 for(channel = 0; channel < avctx->
channels; channel++) {
1374 for(channel = 0; channel < avctx->
channels; channel++) {
1381 for (channel = 0; channel < avctx->
channels; channel++) {
1382 int16_t *smp = samples_p[
channel];
1384 for (n = nb_samples / 2; n > 0; n--) {
1385 int v = bytestream2_get_byteu(&gb);
1391 for (n = nb_samples / 2; n > 0; n--) {
1392 for (channel = 0; channel < avctx->
channels; channel++) {
1393 int v = bytestream2_get_byteu(&gb);
1404 int16_t *out0 = samples_p[0];
1405 int16_t *out1 = samples_p[1];
1406 int samples_per_block = 28 * (3 - avctx->
channels) * 4;
1407 int sample_offset = 0;
1408 int bytes_remaining;
1412 avctx->
channels, sample_offset)) < 0)
1415 sample_offset += samples_per_block;
1420 if (bytes_remaining > 0) {
1426 for (i=0; i<=st; i++) {
1434 for (i=0; i<=st; i++) {
1440 for (n = nb_samples >> (1 - st); n > 0; n--) {
1441 int byte = bytestream2_get_byteu(&gb);
1447 for (n = nb_samples >> (1 - st); n > 0; n--) {
1448 int byte = bytestream2_get_byteu(&gb);
1455 int previous_left_sample, previous_right_sample;
1456 int current_left_sample, current_right_sample;
1457 int next_left_sample, next_right_sample;
1458 int coeff1l, coeff2l, coeff1r, coeff2r;
1459 int shift_left, shift_right;
1467 current_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1468 previous_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1469 current_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1470 previous_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1472 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1473 int byte = bytestream2_get_byteu(&gb);
1479 byte = bytestream2_get_byteu(&gb);
1480 shift_left = 20 - (byte >> 4);
1481 shift_right = 20 - (byte & 0x0F);
1483 for (count2 = 0; count2 < 28; count2++) {
1484 byte = bytestream2_get_byteu(&gb);
1485 next_left_sample =
sign_extend(byte >> 4, 4) * (1 << shift_left);
1486 next_right_sample =
sign_extend(byte, 4) * (1 << shift_right);
1488 next_left_sample = (next_left_sample +
1489 (current_left_sample * coeff1l) +
1490 (previous_left_sample * coeff2l) + 0x80) >> 8;
1491 next_right_sample = (next_right_sample +
1492 (current_right_sample * coeff1r) +
1493 (previous_right_sample * coeff2r) + 0x80) >> 8;
1495 previous_left_sample = current_left_sample;
1496 current_left_sample = av_clip_int16(next_left_sample);
1497 previous_right_sample = current_right_sample;
1498 current_right_sample = av_clip_int16(next_right_sample);
1499 *samples++ = current_left_sample;
1500 *samples++ = current_right_sample;
1512 for(channel = 0; channel < avctx->
channels; channel++) {
1513 int byte = bytestream2_get_byteu(&gb);
1516 shift[
channel] = 20 - (byte & 0x0F);
1518 for (count1 = 0; count1 < nb_samples / 2; count1++) {
1521 byte[0] = bytestream2_get_byteu(&gb);
1522 if (st) byte[1] = bytestream2_get_byteu(&gb);
1523 for(i = 4; i >= 0; i-=4) {
1524 for(channel = 0; channel < avctx->
channels; channel++) {
1546 int previous_sample, current_sample, next_sample;
1554 for (channel=0; channel<avctx->
channels; channel++)
1555 offsets[channel] = (big_endian ? bytestream2_get_be32(&gb) :
1556 bytestream2_get_le32(&gb)) +
1559 for (channel=0; channel<avctx->
channels; channel++) {
1561 samplesC = samples_p[
channel];
1564 current_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1565 previous_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1571 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1572 int byte = bytestream2_get_byte(&gb);
1574 current_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1575 previous_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1577 for (count2=0; count2<28; count2++)
1578 *samplesC++ =
sign_extend(bytestream2_get_be16(&gb), 16);
1582 shift = 20 - (byte & 0x0F);
1584 for (count2=0; count2<28; count2++) {
1588 byte = bytestream2_get_byte(&gb);
1592 next_sample += (current_sample * coeff1) +
1593 (previous_sample * coeff2);
1594 next_sample = av_clip_int16(next_sample >> 8);
1596 previous_sample = current_sample;
1597 current_sample = next_sample;
1598 *samplesC++ = current_sample;
1604 }
else if (count != count1) {
1606 count =
FFMAX(count, count1);
1620 for (channel=0; channel<avctx->
channels; channel++) {
1623 for (n = 0; n < 4; n++, s += 32) {
1629 val =
sign_extend(bytestream2_get_le16u(&gb), 16);
1630 shift[n] = 20 - (val & 0x0F);
1634 for (m=2; m<32; m+=2) {
1636 for (n = 0; n < 4; n++, s += 32) {
1638 int byte = bytestream2_get_byteu(&gb);
1640 level =
sign_extend(byte >> 4, 4) * (1 << shift[n]);
1641 pred = s[-1] * coeff[0][n] + s[-2] * coeff[1][n];
1642 s[0] = av_clip_int16((level + pred + 0x80) >> 8);
1645 pred = s[0] * coeff[0][n] + s[-1] * coeff[1][n];
1646 s[1] = av_clip_int16((level + pred + 0x80) >> 8);
1661 for (n = nb_samples >> (1 - st); n > 0; n--) {
1662 int v = bytestream2_get_byteu(&gb);
1669 for (i = 0; i < avctx->
channels; i++) {
1680 for (n = nb_samples >> (1 - st); n > 0; n--) {
1681 int v = bytestream2_get_byteu(&gb);
1688 for (n = nb_samples >> (1 - st); n > 0; n--) {
1689 int v = bytestream2_get_byteu(&gb);
1699 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1701 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1706 for (n = nb_samples >> (1 - st); n > 0; n--) {
1707 int byte = bytestream2_get_byteu(&gb);
1714 for (n = (nb_samples<<st) / 3; n > 0; n--) {
1715 int byte = bytestream2_get_byteu(&gb);
1719 (byte >> 2) & 0x07, 3, 0);
1724 for (n = nb_samples >> (2 - st); n > 0; n--) {
1725 int byte = bytestream2_get_byteu(&gb);
1729 (byte >> 4) & 0x03, 2, 2);
1731 (byte >> 2) & 0x03, 2, 2);
1742 for (n = nb_samples >> (1 - st); n > 0; n--) {
1743 int v = bytestream2_get_byteu(&gb);
1750 for (channel = 0; channel < avctx->
channels; channel++)
1754 for (channel = 0; channel < avctx->
channels; channel++) {
1756 for (n = nb_samples >> 1; n > 0; n--) {
1757 int v = bytestream2_get_byteu(&gb);
1765 int samples_per_block;
1769 samples_per_block = avctx->
extradata[0] / 16;
1770 blocks = nb_samples / avctx->
extradata[0];
1772 samples_per_block = nb_samples / 16;
1776 for (m = 0; m < blocks; m++) {
1777 for (channel = 0; channel < avctx->
channels; channel++) {
1781 samples = samples_p[
channel] + m * 16;
1783 for (i = 0; i < samples_per_block; i++) {
1784 int byte = bytestream2_get_byteu(&gb);
1785 int scale = 1 << (byte >> 4);
1786 int index = byte & 0xf;
1791 for (n = 0; n < 16; n++) {
1797 byte = bytestream2_get_byteu(&gb);
1801 sampledat = ((prev1 * factor1 + prev2 * factor2) >> 11) +
1803 *samples = av_clip_int16(sampledat);
1822 #define THP_GET16(g) \ 1824 avctx->codec->id == AV_CODEC_ID_ADPCM_THP_LE ? \ 1825 bytestream2_get_le16u(&(g)) : \ 1826 bytestream2_get_be16u(&(g)), 16) 1836 for (i = 0; i < avctx->
channels; i++)
1837 for (n = 0; n < 16; n++)
1840 for (i = 0; i < avctx->
channels; i++)
1841 for (n = 0; n < 16; n++)
1846 for (i = 0; i < avctx->
channels; i++) {
1856 for (ch = 0; ch < avctx->
channels; ch++) {
1857 samples = samples_p[ch];
1860 for (i = 0; i < (nb_samples + 13) / 14; i++) {
1861 int byte = bytestream2_get_byteu(&gb);
1862 int index = (byte >> 4) & 7;
1863 unsigned int exp = byte & 0x0F;
1864 int64_t factor1 = table[ch][index * 2];
1865 int64_t factor2 = table[ch][index * 2 + 1];
1868 for (n = 0; n < 14 && (i * 14 + n < nb_samples); n++) {
1874 byte = bytestream2_get_byteu(&gb);
1880 *samples = av_clip_int16(sampledat);
1889 for (channel = 0; channel < avctx->
channels; channel++) {
1893 for (i = 0; i < nb_samples / 28; i++) {
1897 header = bytestream2_get_byteu(&gb);
1901 for (n = 0; n < 28; n++) {
1904 switch (header >> 4) {
1918 prev = av_clip_intp2((prev + 0x20) >> 6, 21);
1920 byte = bytestream2_get_byteu(&gb);
1926 sampledat = ((sampledat * (1 << 12)) >> (header & 0xf)) * (1 << 6) + prev;
1927 *samples++ = av_clip_int16(sampledat >> 6);
1937 for (channel = 0; channel < avctx->
channels; channel++) {
1941 for (i = 0; i < nb_samples / 28; i++) {
1944 filter = bytestream2_get_byteu(&gb);
1945 shift = filter & 0xf;
1946 filter = filter >> 4;
1949 flag = bytestream2_get_byteu(&gb);
1952 for (n = 0; n < 28; n++) {
1959 byte = bytestream2_get_byteu(&gb);
1963 scale = scale * (1 << 12);
1966 *samples++ = av_clip_int16(sample);
1991 for (channel = 0; channel < avctx->
channels; channel++) {
1998 control = bytestream2_get_byteu(&gb);
1999 shift = (control >> 4) + 2;
2001 for (n = 0; n < nb_samples / 2; n++) {
2002 int sample = bytestream2_get_byteu(&gb);
2010 for (channel = 0; channel < avctx->
channels; channel++) {
2016 for (n = 0; n < nb_samples * avctx->
channels; n++) {
2017 int v = bytestream2_get_byteu(&gb);
2022 for (n = nb_samples / 2; n > 0; n--) {
2023 for (channel = 0; channel < avctx->
channels; channel++) {
2024 int v = bytestream2_get_byteu(&gb);
2065 #define ADPCM_DECODER(id_, sample_fmts_, name_, long_name_) \ 2066 AVCodec ff_ ## name_ ## _decoder = { \ 2068 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ 2069 .type = AVMEDIA_TYPE_AUDIO, \ 2071 .priv_data_size = sizeof(ADPCMDecodeContext), \ 2072 .init = adpcm_decode_init, \ 2073 .decode = adpcm_decode_frame, \ 2074 .flush = adpcm_flush, \ 2075 .capabilities = AV_CODEC_CAP_DR1, \ 2076 .sample_fmts = sample_fmts_, \
const struct AVCodec * codec
static const int16_t ea_adpcm_table[]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
static int16_t adpcm_mtaf_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define avpriv_request_sample(...)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static enum AVSampleFormat sample_fmts_s16[]
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
static int get_sbits(GetBitContext *s, int n)
static int16_t adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, int clip)
const uint8_t ff_adpcm_AdaptCoeff1[]
Divided by 4 to fit in 8-bit integers.
enum AVSampleFormat sample_fmt
audio sample format
static av_cold int adpcm_decode_init(AVCodecContext *avctx)
static void adpcm_flush(AVCodecContext *avctx)
static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int16_t *samples)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define u(width, name, range_min, range_max)
static int get_bits_count(const GetBitContext *s)
static const int8_t mtf_index_table[16]
static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, int buf_size, int *coded_samples, int *approx_nb_samples)
Get the number of samples (per channel) that will be decoded from the packet.
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
static int16_t adpcm_zork_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
bitstream reader API header.
static const uint8_t header[24]
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static const uint16_t table[]
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static int16_t adpcm_ima_cunning_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)
#define i(width, name, range_min, range_max)
static const int8_t xa_adpcm_table[5][2]
const uint16_t ff_adpcm_afc_coeffs[2][16]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
ADPCM encoder/decoder common header.
static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, int is_silence, int current_sample, int64_t nb_samples_notify, AVRational time_base)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
const int8_t *const ff_adpcm_index_tables[4]
const int16_t ff_adpcm_step_table[89]
This is the step table.
static int16_t adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nibble)
static int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps)
static int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int shift)
const int8_t ff_adpcm_index_table[16]
static const int8_t swf_index_tables[4][16]
const int16_t ff_adpcm_mtaf_stepsize[32][16]
static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1, const uint8_t *in, ADPCMChannelStatus *left, ADPCMChannelStatus *right, int channels, int sample_offset)
const int8_t ff_adpcm_AdaptCoeff2[]
Divided by 4 to fit in 8-bit integers.
int vqa_version
VQA version.
static int16_t adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int control, int shift)
static const uint8_t ff_adpcm_ima_block_sizes[4]
static enum AVSampleFormat sample_fmts_s16p[]
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
const int16_t ff_adpcm_oki_step_table[49]
#define FF_ARRAY_ELEMS(a)
static const float pred[4]
static const uint8_t ff_adpcm_ima_block_samples[4]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static av_always_inline int bytestream2_tell(GetByteContext *g)
const int16_t ff_adpcm_AdaptationTable[]
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
const int16_t ff_adpcm_ima_cunning_step_table[61]
static int16_t adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
#define DK3_GET_NEXT_NIBBLE()
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static int16_t adpcm_ima_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int shift)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
static int16_t adpcm_ima_mtf_expand_nibble(ADPCMChannelStatus *c, int nibble)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static int16_t adpcm_agm_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)
static int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble)
ADPCMChannelStatus status[14]
static av_const int sign_extend(int val, unsigned bits)
static int16_t adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int size, int shift)
static unsigned int get_bits_le(GetBitContext *s, int n)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const int8_t ff_adpcm_ima_cunning_index_table[9]
const int8_t ff_adpcm_yamaha_difflookup[]
common internal api header.
const int16_t ff_adpcm_yamaha_indexscale[]
static int adpcm_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
channel
Use these values when setting the channel map with ebur128_set_channel().
static const int8_t zork_index_table[8]
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static av_always_inline int diff(const uint32_t a, const uint32_t b)
#define xf(width, name, var, range_min, range_max, subs,...)
int channels
number of audio channels
static const double coeff[2][5]
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
static int16_t adpcm_ct_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)
static enum AVSampleFormat sample_fmts_both[]
uint8_t ** extended_data
pointers to the data planes/channels.
static double val(void *priv, double ch)
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
#define ADPCM_DECODER(id_, sample_fmts_, name_, long_name_)