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;
154 c->status[0].step =
c->status[1].step = 511;
245 if ((nibble & 8) == 0)
255 c->step =
av_clip(
c->step * 2, 127, 24576);
286 step_index =
av_clip(step_index, 0, 88);
299 c->step_index = step_index;
301 return (int16_t)
c->predictor;
312 step_index =
av_clip(step_index, 0, 88);
322 c->step_index = step_index;
324 return (int16_t)
c->predictor;
333 delta = step * (2 * nibble - 15);
338 c->step_index =
av_clip(step_index, 0, 88);
340 return (int16_t)
c->predictor;
353 step_index =
av_clip(step_index, 0, 60);
358 c->step_index = step_index;
371 step_index =
av_clip(step_index, 0, 88);
373 sign = nibble & (1 <<
shift);
381 c->step_index = step_index;
383 return (int16_t)
c->predictor;
394 step_index =
av_clip(step_index, 0, 88);
397 if (nibble & 4)
diff += step;
398 if (nibble & 2)
diff += step >> 1;
399 if (nibble & 1)
diff += step >> 2;
407 c->step_index = step_index;
416 predictor = (((
c->sample1) * (
c->coeff1)) + ((
c->sample2) * (
c->coeff2))) / 64;
417 predictor += ((nibble & 0x08)?(nibble - 0x10):(nibble)) *
c->idelta;
419 c->sample2 =
c->sample1;
422 if (
c->idelta < 16)
c->idelta = 16;
423 if (
c->idelta > INT_MAX/768) {
425 c->idelta = INT_MAX/768;
437 step_index =
av_clip(step_index, 0, 48);
447 c->step_index = step_index;
449 return c->predictor * 16;
464 c->predictor = ((
c->predictor * 254) >> 8) + (sign ? -
diff :
diff);
468 c->step =
av_clip(new_step, 511, 32767);
470 return (int16_t)
c->predictor;
477 sign = nibble & (1<<(
size-1));
487 else if (
delta == 0 &&
c->step > 0)
490 return (int16_t)
c->predictor;
518 int16_t
index =
c->step_index;
525 sample += lookup_sample >> 1;
527 sample += lookup_sample >> 2;
529 sample += lookup_sample >> 3;
531 sample += lookup_sample >> 4;
533 sample += lookup_sample >> 5;
535 sample += lookup_sample >> 6;
560 out0 += sample_offset;
564 out1 += sample_offset;
587 s = t*(1<<
shift) + ((s_1*f0 + s_2*f1+32)>>6);
618 s = t*(1<<
shift) + ((s_1*f0 + s_2*f1+32)>>6);
644 int k0, signmask, nb_bits, count;
645 int size = buf_size*8;
653 k0 = 1 << (nb_bits-2);
654 signmask = 1 << (nb_bits-1);
658 *samples++ =
c->status[
i].predictor =
get_sbits(&gb, 16);
680 if (
delta & signmask)
681 c->status[
i].predictor -= vpdiff;
683 c->status[
i].predictor += vpdiff;
687 c->status[
i].step_index =
av_clip(
c->status[
i].step_index, 0, 88);
690 *samples++ =
c->status[
i].predictor;
725 int buf_size,
int *coded_samples,
int *approx_nb_samples)
730 int has_coded_samples = 0;
734 *approx_nb_samples = 0;
738 if (buf_size > INT_MAX / 2)
744 if (buf_size < 76 * ch)
749 if (buf_size < 34 * ch)
766 nb_samples = buf_size * 2 / ch;
783 return (buf_size - header_size) * 2 / ch;
789 has_coded_samples = 1;
790 *coded_samples = bytestream2_get_le32u(gb);
791 nb_samples =
FFMIN((buf_size - 8) * 2, *coded_samples);
795 has_coded_samples = 1;
796 *coded_samples = bytestream2_get_le32(gb);
797 *coded_samples -= *coded_samples % 28;
798 nb_samples = (buf_size - 12) / 30 * 28;
801 has_coded_samples = 1;
802 *coded_samples = bytestream2_get_le32(gb);
803 nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
806 nb_samples = (buf_size - ch) / ch * 2;
813 has_coded_samples = 1;
816 header_size = 4 + 9 * ch;
817 *coded_samples = bytestream2_get_le32(gb);
820 header_size = 4 + 5 * ch;
821 *coded_samples = bytestream2_get_le32(gb);
824 header_size = 4 + 5 * ch;
825 *coded_samples = bytestream2_get_be32(gb);
828 *coded_samples -= *coded_samples % 28;
829 nb_samples = (buf_size - header_size) * 2 / ch;
830 nb_samples -= nb_samples % 28;
831 *approx_nb_samples = 1;
836 nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
841 if (buf_size < 4 * ch)
843 nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
848 nb_samples = (buf_size - 4 * ch) * 2 / ch;
856 if (buf_size < 4 * ch)
858 nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
864 nb_samples = (buf_size - 6 * ch) * 2 / ch;
869 nb_samples = (buf_size - 16 * (ch / 2)) * 2 / ch;
875 int samples_per_byte;
881 if (!
s->status[0].step_index) {
887 nb_samples += buf_size * samples_per_byte / ch;
892 int buf_bits = buf_size * 8 - 2;
893 int nbits = (bytestream2_get_byte(gb) >> 6) + 2;
894 int block_hdr_size = 22 * ch;
895 int block_size = block_hdr_size + nbits * ch * 4095;
896 int nblocks = buf_bits / block_size;
897 int bits_left = buf_bits - nblocks * block_size;
898 nb_samples = nblocks * 4096;
899 if (bits_left >= block_hdr_size)
900 nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
906 nb_samples = buf_size * 14 / (8 * ch);
909 has_coded_samples = 1;
912 bytestream2_get_le32(gb) :
913 bytestream2_get_be32(gb);
914 buf_size -= 8 + 36 * ch;
916 nb_samples = buf_size / 8 * 14;
917 if (buf_size % 8 > 1)
918 nb_samples += (buf_size % 8 - 1) * 2;
919 *approx_nb_samples = 1;
922 nb_samples = buf_size / (9 * ch) * 16;
925 nb_samples = (buf_size / 128) * 224 / ch;
929 nb_samples = buf_size / (16 * ch) * 28;
935 nb_samples = buf_size / ch;
940 if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
947 int *got_frame_ptr,
AVPacket *avpkt)
951 int buf_size = avpkt->
size;
959 int nb_samples, coded_samples, approx_nb_samples, ret;
963 nb_samples =
get_nb_samples(avctx, &gb, buf_size, &coded_samples, &approx_nb_samples);
964 if (nb_samples <= 0) {
979 if (!approx_nb_samples && coded_samples != nb_samples)
1021 for (m = 0; m < 64; m += 2) {
1022 int byte = bytestream2_get_byteu(&gb);
1030 cs = &(
c->status[
i]);
1047 for (n = 0; n < (nb_samples - 1) / samples_per_block; n++) {
1052 samples = &samples_p[
i][1 + n * samples_per_block];
1053 for (j = 0; j < block_size; j++) {
1055 (j % 4) + (j / 4) * (avctx->
channels * 4) +
i * 4];
1060 for (m = 0; m < samples_per_block; m++) {
1068 for (n = 0; n < (nb_samples - 1) / 8; n++) {
1071 samples = &samples_p[
i][1 + n * 8];
1072 for (m = 0; m < 8; m += 2) {
1073 int v = bytestream2_get_byteu(&gb);
1083 c->status[
i].predictor =
sign_extend(bytestream2_get_le16u(&gb), 16);
1086 c->status[
i].step_index =
sign_extend(bytestream2_get_le16u(&gb), 16);
1087 if (
c->status[
i].step_index > 88u) {
1089 i,
c->status[
i].step_index);
1097 for (n = nb_samples >> 1; n > 0; n--) {
1098 int v = bytestream2_get_byteu(&gb);
1106 c->status[
i].predictor =
sign_extend(bytestream2_get_le16u(&gb), 16);
1108 c->status[
i].step =
sign_extend(bytestream2_get_le16u(&gb), 16);
1110 for (n = 0; n < nb_samples >> (1 - st); n++) {
1111 int v = bytestream2_get_byteu(&gb);
1118 int block_predictor;
1123 block_predictor = bytestream2_get_byteu(&gb);
1124 if (block_predictor > 6) {
1134 *samples++ =
c->status[
channel].sample2;
1135 *samples++ =
c->status[
channel].sample1;
1136 for(n = (nb_samples - 2) >> 1; n > 0; n--) {
1137 int byte = bytestream2_get_byteu(&gb);
1143 block_predictor = bytestream2_get_byteu(&gb);
1144 if (block_predictor > 6) {
1152 block_predictor = bytestream2_get_byteu(&gb);
1153 if (block_predictor > 6) {
1161 c->status[0].idelta =
sign_extend(bytestream2_get_le16u(&gb), 16);
1163 c->status[1].idelta =
sign_extend(bytestream2_get_le16u(&gb), 16);
1166 c->status[0].sample1 =
sign_extend(bytestream2_get_le16u(&gb), 16);
1167 if (st)
c->status[1].sample1 =
sign_extend(bytestream2_get_le16u(&gb), 16);
1168 c->status[0].sample2 =
sign_extend(bytestream2_get_le16u(&gb), 16);
1169 if (st)
c->status[1].sample2 =
sign_extend(bytestream2_get_le16u(&gb), 16);
1171 *samples++ =
c->status[0].sample2;
1172 if (st) *samples++ =
c->status[1].sample2;
1173 *samples++ =
c->status[0].sample1;
1174 if (st) *samples++ =
c->status[1].sample1;
1175 for(n = (nb_samples - 2) >> (1 - st); n > 0; n--) {
1176 int byte = bytestream2_get_byteu(&gb);
1186 c->status[
channel ].step = bytestream2_get_le16u(&gb) & 0x1f;
1187 c->status[
channel + 1].step = bytestream2_get_le16u(&gb) & 0x1f;
1192 for (n = 0; n < nb_samples; n+=2) {
1193 int v = bytestream2_get_byteu(&gb);
1197 for (n = 0; n < nb_samples; n+=2) {
1198 int v = bytestream2_get_byteu(&gb);
1215 for (n = (nb_samples - 1) >> (1 - st); n > 0; n--) {
1216 int v = bytestream2_get_byteu(&gb);
1225 int decode_top_nibble_next = 0;
1227 const int16_t *samples_end = samples + avctx->
channels * nb_samples;
1230 c->status[0].predictor =
sign_extend(bytestream2_get_le16u(&gb), 16);
1231 c->status[1].predictor =
sign_extend(bytestream2_get_le16u(&gb), 16);
1232 c->status[0].step_index = bytestream2_get_byteu(&gb);
1233 c->status[1].step_index = bytestream2_get_byteu(&gb);
1234 if (
c->status[0].step_index > 88u ||
c->status[1].step_index > 88u){
1236 c->status[0].step_index,
c->status[1].step_index);
1240 diff_channel =
c->status[1].predictor;
1243 #define DK3_GET_NEXT_NIBBLE() \
1244 if (decode_top_nibble_next) { \
1245 nibble = last_byte >> 4; \
1246 decode_top_nibble_next = 0; \
1248 last_byte = bytestream2_get_byteu(&gb); \
1249 nibble = last_byte & 0x0F; \
1250 decode_top_nibble_next = 1; \
1253 while (samples < samples_end) {
1267 diff_channel = (diff_channel +
c->status[1].predictor) / 2;
1268 *samples++ =
c->status[0].predictor +
c->status[1].predictor;
1269 *samples++ =
c->status[0].predictor -
c->status[1].predictor;
1276 diff_channel = (diff_channel +
c->status[1].predictor) / 2;
1277 *samples++ =
c->status[0].predictor +
c->status[1].predictor;
1278 *samples++ =
c->status[0].predictor -
c->status[1].predictor;
1297 for (n = nb_samples >> (1 - st); n > 0; n--) {
1299 int v = bytestream2_get_byteu(&gb);
1324 for (
int subframe = 0; subframe < nb_samples / 256; subframe++) {
1326 samples = samples_p[
channel] + 256 * subframe;
1327 for (n = 0; n < 256; n += 2) {
1328 int v = bytestream2_get_byteu(&gb);
1340 for (n = 0; n < nb_samples; n += 2) {
1341 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 (n = nb_samples >> (1 - st); n > 0; n--) {
1356 int v = bytestream2_get_byteu(&gb);
1362 for (n = nb_samples / 2; n > 0; n--) {
1364 int v = bytestream2_get_byteu(&gb);
1372 for (n = nb_samples / 2; n > 0; n--) {
1374 int v = bytestream2_get_byteu(&gb);
1383 int16_t *smp = samples_p[
channel];
1384 for (n = 0; n < nb_samples / 2; n++) {
1385 int v = bytestream2_get_byteu(&gb);
1392 for (n = nb_samples >> (1 - st); n > 0; n--) {
1393 int v = bytestream2_get_byteu(&gb);
1409 for (n = 0; n < nb_samples / 2; n++) {
1412 byte[0] = bytestream2_get_byteu(&gb);
1414 byte[1] = bytestream2_get_byteu(&gb);
1424 if (
c->vqa_version == 3) {
1426 int16_t *smp = samples_p[
channel];
1428 for (n = nb_samples / 2; n > 0; n--) {
1429 int v = bytestream2_get_byteu(&gb);
1435 for (n = nb_samples / 2; n > 0; n--) {
1437 int v = bytestream2_get_byteu(&gb);
1448 int16_t *out0 = samples_p[0];
1449 int16_t *out1 = samples_p[1];
1450 int samples_per_block = 28 * (3 - avctx->
channels) * 4;
1451 int sample_offset = 0;
1452 int bytes_remaining;
1455 &
c->status[0], &
c->status[1],
1456 avctx->
channels, sample_offset)) < 0)
1459 sample_offset += samples_per_block;
1464 if (bytes_remaining > 0) {
1470 for (
i=0;
i<=st;
i++) {
1471 c->status[
i].step_index = bytestream2_get_le32u(&gb);
1472 if (
c->status[
i].step_index > 88u) {
1474 i,
c->status[
i].step_index);
1478 for (
i=0;
i<=st;
i++) {
1479 c->status[
i].predictor = bytestream2_get_le32u(&gb);
1484 for (n = nb_samples >> (1 - st); n > 0; n--) {
1485 int byte = bytestream2_get_byteu(&gb);
1491 for (n = nb_samples >> (1 - st); n > 0; n--) {
1492 int byte = bytestream2_get_byteu(&gb);
1499 int previous_left_sample, previous_right_sample;
1500 int current_left_sample, current_right_sample;
1501 int next_left_sample, next_right_sample;
1502 int coeff1l, coeff2l, coeff1r, coeff2r;
1503 int shift_left, shift_right;
1511 current_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1512 previous_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1513 current_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1514 previous_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1516 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1517 int byte = bytestream2_get_byteu(&gb);
1523 byte = bytestream2_get_byteu(&gb);
1524 shift_left = 20 - (
byte >> 4);
1525 shift_right = 20 - (
byte & 0x0F);
1527 for (count2 = 0; count2 < 28; count2++) {
1528 byte = bytestream2_get_byteu(&gb);
1529 next_left_sample =
sign_extend(
byte >> 4, 4) * (1 << shift_left);
1530 next_right_sample =
sign_extend(
byte, 4) * (1 << shift_right);
1532 next_left_sample = (next_left_sample +
1533 (current_left_sample * coeff1l) +
1534 (previous_left_sample * coeff2l) + 0x80) >> 8;
1535 next_right_sample = (next_right_sample +
1536 (current_right_sample * coeff1r) +
1537 (previous_right_sample * coeff2r) + 0x80) >> 8;
1539 previous_left_sample = current_left_sample;
1541 previous_right_sample = current_right_sample;
1543 *samples++ = current_left_sample;
1544 *samples++ = current_right_sample;
1557 int byte = bytestream2_get_byteu(&gb);
1562 for (count1 = 0; count1 < nb_samples / 2; count1++) {
1565 byte[0] = bytestream2_get_byteu(&gb);
1566 if (st)
byte[1] = bytestream2_get_byteu(&gb);
1567 for(
i = 4;
i >= 0;
i-=4) {
1575 *samples++ =
c->status[
channel].sample1;
1590 int previous_sample, current_sample, next_sample;
1600 bytestream2_get_le32(&gb)) +
1605 samplesC = samples_p[
channel];
1608 current_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1609 previous_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1611 current_sample =
c->status[
channel].predictor;
1612 previous_sample =
c->status[
channel].prev_sample;
1615 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1616 int byte = bytestream2_get_byte(&gb);
1618 current_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1619 previous_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1621 for (count2=0; count2<28; count2++)
1622 *samplesC++ =
sign_extend(bytestream2_get_be16(&gb), 16);
1626 shift = 20 - (
byte & 0x0F);
1628 for (count2=0; count2<28; count2++) {
1632 byte = bytestream2_get_byte(&gb);
1636 next_sample += (current_sample * coeff1) +
1637 (previous_sample * coeff2);
1640 previous_sample = current_sample;
1641 current_sample = next_sample;
1642 *samplesC++ = current_sample;
1648 }
else if (count != count1) {
1650 count =
FFMAX(count, count1);
1654 c->status[
channel].predictor = current_sample;
1655 c->status[
channel].prev_sample = previous_sample;
1667 for (n = 0; n < 4; n++,
s += 32) {
1678 for (m=2; m<32; m+=2) {
1680 for (n = 0; n < 4; n++,
s += 32) {
1682 int byte = bytestream2_get_byteu(&gb);
1708 c->status[0].predictor =
sign_extend(bytestream2_get_le16u(&gb), 16);
1709 c->status[0].step_index = bytestream2_get_byteu(&gb);
1711 if (
c->status[0].step_index > 88u) {
1713 c->status[0].step_index);
1717 for (n = nb_samples >> 1; n > 0; n--) {
1718 int v = bytestream2_get_byteu(&gb);
1724 if (nb_samples & 1) {
1725 int v = bytestream2_get_byteu(&gb);
1737 c->status[
i].predictor =
sign_extend(bytestream2_get_be16u(&gb), 16);
1738 c->status[
i].step_index = bytestream2_get_byteu(&gb);
1740 if (
c->status[
i].step_index > 88u) {
1742 c->status[
i].step_index);
1747 for (n = nb_samples >> (1 - st); n > 0; n--) {
1748 int v = bytestream2_get_byteu(&gb);
1755 for (n = nb_samples >> (1 - st); n > 0; n--) {
1756 int v = bytestream2_get_byteu(&gb);
1764 if (!
c->status[0].step_index) {
1766 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1768 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1769 c->status[0].step_index = 1;
1773 for (n = nb_samples >> (1 - st); n > 0; n--) {
1774 int byte = bytestream2_get_byteu(&gb);
1781 for (n = (nb_samples<<st) / 3; n > 0; n--) {
1782 int byte = bytestream2_get_byteu(&gb);
1786 (
byte >> 2) & 0x07, 3, 0);
1791 for (n = nb_samples >> (2 - st); n > 0; n--) {
1792 int byte = bytestream2_get_byteu(&gb);
1796 (
byte >> 4) & 0x03, 2, 2);
1798 (
byte >> 2) & 0x03, 2, 2);
1809 for (n = nb_samples >> (1 - st); n > 0; n--) {
1810 int v = bytestream2_get_byteu(&gb);
1818 for (n = nb_samples >> 1; n > 0; n--) {
1819 int v = bytestream2_get_byteu(&gb);
1827 int samples_per_block;
1831 samples_per_block = avctx->
extradata[0] / 16;
1832 blocks = nb_samples / avctx->
extradata[0];
1834 samples_per_block = nb_samples / 16;
1838 for (m = 0; m < blocks; m++) {
1840 int prev1 =
c->status[
channel].sample1;
1841 int prev2 =
c->status[
channel].sample2;
1843 samples = samples_p[
channel] + m * 16;
1845 for (
i = 0;
i < samples_per_block;
i++) {
1846 int byte = bytestream2_get_byteu(&gb);
1847 int scale = 1 << (
byte >> 4);
1848 int index =
byte & 0xf;
1853 for (n = 0; n < 16; n++) {
1859 byte = bytestream2_get_byteu(&gb);
1863 sampledat = ((prev1 * factor1 + prev2 * factor2) >> 11) +
1871 c->status[
channel].sample1 = prev1;
1872 c->status[
channel].sample2 = prev2;
1884 #define THP_GET16(g) \
1886 avctx->codec->id == AV_CODEC_ID_ADPCM_THP_LE ? \
1887 bytestream2_get_le16u(&(g)) : \
1888 bytestream2_get_be16u(&(g)), 16)
1899 for (n = 0; n < 16; n++)
1903 for (n = 0; n < 16; n++)
1906 if (!
c->has_status) {
1918 for (ch = 0; ch < avctx->
channels; ch++) {
1919 samples = samples_p[ch];
1922 for (
i = 0;
i < (nb_samples + 13) / 14;
i++) {
1923 int byte = bytestream2_get_byteu(&gb);
1924 int index = (
byte >> 4) & 7;
1925 unsigned int exp =
byte & 0x0F;
1930 for (n = 0; n < 14 && (
i * 14 + n < nb_samples); n++) {
1936 byte = bytestream2_get_byteu(&gb);
1940 sampledat = ((
c->status[ch].sample1 * factor1
1941 +
c->status[ch].sample2 * factor2) >> 11) + sampledat * (1 <<
exp);
1943 c->status[ch].sample2 =
c->status[ch].sample1;
1944 c->status[ch].sample1 = *samples++;
1955 for (
i = 0;
i < nb_samples / 28;
i++) {
1959 header = bytestream2_get_byteu(&gb);
1963 for (n = 0; n < 28; n++) {
1968 prev = (
c->status[
channel].sample1 * 0x3c);
1971 prev = (
c->status[
channel].sample1 * 0x73) - (
c->status[
channel].sample2 * 0x34);
1974 prev = (
c->status[
channel].sample1 * 0x62) - (
c->status[
channel].sample2 * 0x37);
1982 byte = bytestream2_get_byteu(&gb);
1988 sampledat = ((sampledat * (1 << 12)) >> (
header & 0xf)) * (1 << 6) + prev;
1991 c->status[
channel].sample1 = sampledat;
2002 samples = samples_p[
channel] +
block * nb_samples_per_block;
2006 for (
i = 0;
i < nb_samples_per_block / 28;
i++) {
2009 filter = bytestream2_get_byteu(&gb);
2014 flag = bytestream2_get_byteu(&gb);
2017 for (n = 0; n < 28; n++) {
2024 byte = bytestream2_get_byteu(&gb);
2028 scale = scale * (1 << 12);
2065 control = bytestream2_get_byteu(&gb);
2066 shift = (control >> 4) + 2;
2068 for (n = 0; n < 16; n++) {
2069 int sample = bytestream2_get_byteu(&gb);
2077 for (n = 0; n < nb_samples * avctx->
channels; n++) {
2078 int v = bytestream2_get_byteu(&gb);
2083 for (n = nb_samples / 2; n > 0; n--) {
2085 int v = bytestream2_get_byteu(&gb);
2156 #define ADPCM_DECODER(id_, sample_fmts_, name_, long_name_) \
2157 AVCodec ff_ ## name_ ## _decoder = { \
2159 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
2160 .type = AVMEDIA_TYPE_AUDIO, \
2162 .priv_data_size = sizeof(ADPCMDecodeContext), \
2163 .init = adpcm_decode_init, \
2164 .decode = adpcm_decode_frame, \
2165 .flush = adpcm_flush, \
2166 .capabilities = AV_CODEC_CAP_DR1, \
2167 .sample_fmts = sample_fmts_, \
2168 .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, \
int16_t ff_adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int shift, int flag)
static const int8_t swf_index_tables[4][16]
static enum AVSampleFormat sample_fmts_s16[]
static int16_t adpcm_ima_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int shift)
static int16_t adpcm_mtaf_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
static int16_t adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nibble)
static int16_t adpcm_ima_mtf_expand_nibble(ADPCMChannelStatus *c, int nibble)
static int adpcm_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
#define DK3_GET_NEXT_NIBBLE()
static int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps)
static int16_t adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int size, int shift)
static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int16_t *samples)
static const int8_t xa_adpcm_table[5][2]
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 int16_t adpcm_agm_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)
static int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int shift)
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)
static const int16_t ea_adpcm_table[]
static int16_t adpcm_zork_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
static enum AVSampleFormat sample_fmts_s16p[]
static int16_t adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
static const int8_t zork_index_table[8]
static int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble)
static int16_t adpcm_ima_cunning_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)
static int16_t adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble)
static const int8_t mtf_index_table[16]
static int16_t adpcm_ct_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)
static av_cold int adpcm_decode_init(AVCodecContext *avctx)
static void adpcm_flush(AVCodecContext *avctx)
static enum AVSampleFormat sample_fmts_both[]
#define ADPCM_DECODER(id_, sample_fmts_, name_, long_name_)
ADPCM encoder/decoder common header.
const int8_t ff_adpcm_AdaptCoeff2[]
Divided by 4 to fit in 8-bit integers.
const int8_t ff_adpcm_index_table[16]
const int16_t ff_adpcm_mtaf_stepsize[32][16]
const int8_t ff_adpcm_ima_cunning_index_table[9]
const int8_t ff_adpcm_yamaha_difflookup[]
const int16_t ff_adpcm_step_table[89]
This is the step table.
const int16_t ff_adpcm_ima_cunning_step_table[61]
const uint8_t ff_adpcm_AdaptCoeff1[]
Divided by 4 to fit in 8-bit integers.
const int16_t ff_adpcm_yamaha_indexscale[]
const uint16_t ff_adpcm_afc_coeffs[2][16]
const int16_t ff_adpcm_AdaptationTable[]
const int8_t *const ff_adpcm_index_tables[4]
const int16_t ff_adpcm_oki_step_table[49]
static const uint8_t ff_adpcm_ima_block_sizes[4]
static const uint8_t ff_adpcm_ima_block_samples[4]
static double val(void *priv, double ch)
static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, int is_silence, int current_sample, int64_t nb_samples_notify, AVRational time_base)
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)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
static av_always_inline int bytestream2_tell(GetByteContext *g)
static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int len, int clip)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static float add(float src0, float src1)
channel
Use these values when setting the channel map with ebur128_set_channel().
static void predictor(uint8_t *src, ptrdiff_t size)
bitstream reader API header.
static unsigned int get_bits_le(GetBitContext *s, int n)
static int get_sbits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
@ AV_CODEC_ID_ADPCM_IMA_WS
@ AV_CODEC_ID_ADPCM_EA_R1
@ AV_CODEC_ID_ADPCM_IMA_OKI
@ AV_CODEC_ID_ADPCM_IMA_EA_EACS
@ AV_CODEC_ID_ADPCM_SBPRO_2
@ AV_CODEC_ID_ADPCM_IMA_EA_SEAD
@ AV_CODEC_ID_ADPCM_YAMAHA
@ AV_CODEC_ID_ADPCM_SBPRO_3
@ AV_CODEC_ID_ADPCM_EA_R2
@ AV_CODEC_ID_ADPCM_IMA_ISS
@ AV_CODEC_ID_ADPCM_SBPRO_4
@ AV_CODEC_ID_ADPCM_EA_MAXIS_XA
@ AV_CODEC_ID_ADPCM_IMA_APC
@ AV_CODEC_ID_ADPCM_IMA_AMV
@ AV_CODEC_ID_ADPCM_EA_XAS
@ AV_CODEC_ID_ADPCM_IMA_CUNNING
@ AV_CODEC_ID_ADPCM_IMA_DK4
@ AV_CODEC_ID_ADPCM_IMA_DK3
@ AV_CODEC_ID_ADPCM_IMA_DAT4
@ AV_CODEC_ID_ADPCM_IMA_QT
@ AV_CODEC_ID_ADPCM_IMA_SMJPEG
@ AV_CODEC_ID_ADPCM_IMA_MTF
@ AV_CODEC_ID_ADPCM_IMA_APM
@ AV_CODEC_ID_ADPCM_IMA_WAV
@ AV_CODEC_ID_ADPCM_THP_LE
@ AV_CODEC_ID_ADPCM_IMA_ALP
@ AV_CODEC_ID_ADPCM_EA_R3
@ AV_CODEC_ID_ADPCM_IMA_RAD
@ AV_CODEC_ID_ADPCM_IMA_SSI
@ AV_CODEC_ID_ADPCM_IMA_MOFLEX
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_S16
signed 16 bits
static const int offsets[]
common internal API header
static av_const int sign_extend(int val, unsigned bits)
static const uint16_t table[]
static const uint8_t header[24]
#define FF_ARRAY_ELEMS(a)
static const float pred[4]
static int shift(int a, int b)
int vqa_version
VQA version.
ADPCMChannelStatus status[14]
int has_status
Status flag.
main external API structure.
enum AVSampleFormat sample_fmt
audio sample format
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
const struct AVCodec * codec
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int channels
number of audio channels
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
uint8_t ** extended_data
pointers to the data planes/channels.
This structure stores compressed data.
#define avpriv_request_sample(...)
static const double coeff[2][5]
static av_always_inline int diff(const uint32_t a, const uint32_t b)