80 { -1, -1, -1, -1, 2, 4, 6, 8 },
81 { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }
95 unsigned int min_channels = 1;
96 unsigned int max_channels = 2;
181 step_index = av_clip(step_index, 0, 88);
188 diff = ((2 * delta + 1) * step) >>
shift;
190 if (sign) predictor -=
diff;
191 else predictor +=
diff;
207 step_index = av_clip(step_index, 0, 88);
209 sign = nibble & (1 <<
shift);
210 delta = av_mod_uintp2(nibble, shift);
211 diff = ((2 * delta + 1) * step) >>
shift;
213 if (sign) predictor -=
diff;
214 else predictor +=
diff;
230 step_index = av_clip(step_index, 0, 88);
233 if (nibble & 4) diff += step;
234 if (nibble & 2) diff += step >> 1;
235 if (nibble & 1) diff += step >> 2;
253 predictor += ((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->
idelta;
256 c->
sample1 = av_clip_int16(predictor);
259 if (c->
idelta > INT_MAX/768) {
273 step_index = av_clip(step_index, 0, 48);
277 diff = ((2 * delta + 1) * step) >> 3;
279 if (sign) predictor -=
diff;
280 else predictor +=
diff;
282 c->
predictor = av_clip_intp2(predictor, 11);
298 diff = ((2 * delta + 1) * c->
step) >> 3;
304 c->
step = av_clip(new_step, 511, 32767);
313 sign = nibble & (1<<(size-1));
314 delta = nibble & ((1<<(size-1))-1);
321 if (delta >= (2*size - 3) && c->
step < 3)
323 else if (delta == 0 && c->
step > 0)
339 c->
step = av_clip(c->
step, 127, 24567);
352 out0 += sample_offset;
356 out1 += sample_offset;
359 shift = 12 - (in[4+i*2] & 15);
360 filter = in[4+i*2] >> 4;
375 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
377 s_1 = av_clip_int16(s);
388 shift = 12 - (in[5+i*2] & 15);
389 filter = in[5+i*2] >> 4;
402 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
404 s_1 = av_clip_int16(s);
416 out0 += 28 * (3 - channels);
417 out1 += 28 * (3 - channels);
428 int k0, signmask, nb_bits,
count;
429 int size = buf_size*8;
437 k0 = 1 << (nb_bits-2);
438 signmask = 1 << (nb_bits-1);
441 for (i = 0; i < avctx->
channels; i++) {
449 for (i = 0; i < avctx->
channels; i++) {
464 if (delta & signmask)
492 int buf_size,
int *coded_samples,
int *approx_nb_samples)
497 int has_coded_samples = 0;
501 *approx_nb_samples = 0;
509 if (buf_size < 76 * ch)
514 if (buf_size < 34 * ch)
526 nb_samples = buf_size * 2 / ch;
541 return (buf_size - header_size) * 2 / ch;
546 has_coded_samples = 1;
547 *coded_samples = bytestream2_get_le32(gb);
548 *coded_samples -= *coded_samples % 28;
549 nb_samples = (buf_size - 12) / 30 * 28;
552 has_coded_samples = 1;
553 *coded_samples = bytestream2_get_le32(gb);
554 nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
557 nb_samples = (buf_size - ch) / ch * 2;
564 has_coded_samples = 1;
567 header_size = 4 + 9 * ch;
568 *coded_samples = bytestream2_get_le32(gb);
571 header_size = 4 + 5 * ch;
572 *coded_samples = bytestream2_get_le32(gb);
575 header_size = 4 + 5 * ch;
576 *coded_samples = bytestream2_get_be32(gb);
579 *coded_samples -= *coded_samples % 28;
580 nb_samples = (buf_size - header_size) * 2 / ch;
581 nb_samples -= nb_samples % 28;
582 *approx_nb_samples = 1;
587 nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
592 if (buf_size < 4 * ch)
594 nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
599 nb_samples = (buf_size - 4 * ch) * 2 / ch;
607 if (buf_size < 4 * ch)
609 nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
615 nb_samples = (buf_size - 6 * ch) * 2 / ch;
621 int samples_per_byte;
633 nb_samples += buf_size * samples_per_byte / ch;
638 int buf_bits = buf_size * 8 - 2;
639 int nbits = (bytestream2_get_byte(gb) >> 6) + 2;
640 int block_hdr_size = 22 * ch;
641 int block_size = block_hdr_size + nbits * ch * 4095;
642 int nblocks = buf_bits / block_size;
643 int bits_left = buf_bits - nblocks * block_size;
644 nb_samples = nblocks * 4096;
645 if (bits_left >= block_hdr_size)
646 nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
652 nb_samples = buf_size * 14 / (8 * ch);
655 has_coded_samples = 1;
658 bytestream2_get_le32(gb) :
659 bytestream2_get_be32(gb);
660 buf_size -= 8 + 36 * ch;
662 nb_samples = buf_size / 8 * 14;
663 if (buf_size % 8 > 1)
664 nb_samples += (buf_size % 8 - 1) * 2;
665 *approx_nb_samples = 1;
668 nb_samples = buf_size / (9 * ch) * 16;
671 nb_samples = (buf_size / 128) * 224 / ch;
675 nb_samples = buf_size / (16 * ch) * 28;
680 if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
687 int *got_frame_ptr,
AVPacket *avpkt)
691 int buf_size = avpkt->
size;
694 int n,
m, channel, i;
699 int nb_samples, coded_samples, approx_nb_samples, ret;
703 nb_samples =
get_nb_samples(avctx, &gb, buf_size, &coded_samples, &approx_nb_samples);
704 if (nb_samples <= 0) {
713 samples = (
short *)frame->
data[0];
719 if (!approx_nb_samples && coded_samples != nb_samples)
721 frame->
nb_samples = nb_samples = coded_samples;
730 for (channel = 0; channel < avctx->
channels; channel++) {
733 cs = &(c->
status[channel]);
737 predictor =
sign_extend(bytestream2_get_be16u(&gb), 16);
738 step_index = predictor & 0x7F;
759 samples = samples_p[channel];
761 for (m = 0; m < 64; m += 2) {
762 int byte = bytestream2_get_byteu(&gb);
788 for (n = 0; n < (nb_samples - 1) / samples_per_block; n++) {
789 for (i = 0; i < avctx->
channels; i++) {
791 samples = &samples_p[i][1 + n * samples_per_block];
792 for (m = 0; m < samples_per_block; m++) {
800 for (n = 0; n < (nb_samples - 1) / 8; n++) {
801 for (i = 0; i < avctx->
channels; i++) {
803 samples = &samples_p[i][1 + n * 8];
804 for (m = 0; m < 8; m += 2) {
805 int v = bytestream2_get_byteu(&gb);
814 for (i = 0; i < avctx->
channels; i++)
817 for (i = 0; i < avctx->
channels; i++) {
826 for (i = 0; i < avctx->
channels; i++) {
827 samples = (int16_t *)frame->
data[i];
829 for (n = nb_samples >> 1; n > 0; n--) {
830 int v = bytestream2_get_byteu(&gb);
840 block_predictor = bytestream2_get_byteu(&gb);
841 if (block_predictor > 6) {
849 block_predictor = bytestream2_get_byteu(&gb);
850 if (block_predictor > 6) {
872 for(n = (nb_samples - 2) >> (1 - st); n > 0; n--) {
873 int byte = bytestream2_get_byteu(&gb);
880 for (channel = 0; channel < avctx->
channels; channel++) {
890 for (n = (nb_samples - 1) >> (1 - st); n > 0; n--) {
891 int v = bytestream2_get_byteu(&gb);
900 int decode_top_nibble_next = 0;
902 const int16_t *samples_end = samples + avctx->
channels * nb_samples;
918 #define DK3_GET_NEXT_NIBBLE() \
919 if (decode_top_nibble_next) { \
920 nibble = last_byte >> 4; \
921 decode_top_nibble_next = 0; \
923 last_byte = bytestream2_get_byteu(&gb); \
924 nibble = last_byte & 0x0F; \
925 decode_top_nibble_next = 1; \
928 while (samples < samples_end) {
961 for (channel = 0; channel < avctx->
channels; channel++) {
972 for (n = nb_samples >> (1 - st); n > 0; n--) {
974 int v = bytestream2_get_byteu(&gb);
989 int v = bytestream2_get_byteu(&gb);
996 int v = bytestream2_get_byteu(&gb);
1002 for (channel = 0; channel < avctx->
channels; channel++) {
1003 cs = &c->
status[channel];
1012 for (n = 0; n < nb_samples / 2; n++) {
1015 byte[0] = bytestream2_get_byteu(&gb);
1017 byte[1] = bytestream2_get_byteu(&gb);
1018 for(channel = 0; channel < avctx->
channels; channel++) {
1021 for(channel = 0; channel < avctx->
channels; channel++) {
1028 for (channel = 0; channel < avctx->
channels; channel++) {
1029 int16_t *smp = samples_p[channel];
1031 for (n = nb_samples / 2; n > 0; n--) {
1032 int v = bytestream2_get_byteu(&gb);
1038 for (n = nb_samples / 2; n > 0; n--) {
1039 for (channel = 0; channel < avctx->
channels; channel++) {
1040 int v = bytestream2_get_byteu(&gb);
1051 int16_t *out0 = samples_p[0];
1052 int16_t *out1 = samples_p[1];
1053 int samples_per_block = 28 * (3 - avctx->
channels) * 4;
1054 int sample_offset = 0;
1058 avctx->
channels, sample_offset)) < 0)
1061 sample_offset += samples_per_block;
1066 for (i=0; i<=st; i++) {
1074 for (i=0; i<=st; i++)
1077 for (n = nb_samples >> (1 - st); n > 0; n--) {
1078 int byte = bytestream2_get_byteu(&gb);
1084 for (n = nb_samples >> (1 - st); n > 0; n--) {
1085 int byte = bytestream2_get_byteu(&gb);
1092 int previous_left_sample, previous_right_sample;
1093 int current_left_sample, current_right_sample;
1094 int next_left_sample, next_right_sample;
1095 int coeff1l, coeff2l, coeff1r, coeff2r;
1096 int shift_left, shift_right;
1104 current_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1105 previous_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1106 current_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1107 previous_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1109 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1110 int byte = bytestream2_get_byteu(&gb);
1116 byte = bytestream2_get_byteu(&gb);
1117 shift_left = 20 - (byte >> 4);
1118 shift_right = 20 - (byte & 0x0F);
1120 for (count2 = 0; count2 < 28; count2++) {
1121 byte = bytestream2_get_byteu(&gb);
1122 next_left_sample =
sign_extend(byte >> 4, 4) << shift_left;
1123 next_right_sample =
sign_extend(byte, 4) << shift_right;
1125 next_left_sample = (next_left_sample +
1126 (current_left_sample * coeff1l) +
1127 (previous_left_sample * coeff2l) + 0x80) >> 8;
1128 next_right_sample = (next_right_sample +
1129 (current_right_sample * coeff1r) +
1130 (previous_right_sample * coeff2r) + 0x80) >> 8;
1132 previous_left_sample = current_left_sample;
1133 current_left_sample = av_clip_int16(next_left_sample);
1134 previous_right_sample = current_right_sample;
1135 current_right_sample = av_clip_int16(next_right_sample);
1136 *samples++ = current_left_sample;
1137 *samples++ = current_right_sample;
1149 for(channel = 0; channel < avctx->
channels; channel++) {
1150 int byte = bytestream2_get_byteu(&gb);
1153 shift[channel] = 20 - (byte & 0x0F);
1155 for (count1 = 0; count1 < nb_samples / 2; count1++) {
1158 byte[0] = bytestream2_get_byteu(&gb);
1159 if (st) byte[1] = bytestream2_get_byteu(&gb);
1160 for(i = 4; i >= 0; i-=4) {
1161 for(channel = 0; channel < avctx->
channels; channel++) {
1165 c->
status[channel].
sample2 * coeff[channel][1] + 0x80) >> 8;
1183 int previous_sample, current_sample, next_sample;
1186 unsigned int channel;
1191 for (channel=0; channel<avctx->
channels; channel++)
1192 offsets[channel] = (big_endian ? bytestream2_get_be32(&gb) :
1193 bytestream2_get_le32(&gb)) +
1196 for (channel=0; channel<avctx->
channels; channel++) {
1198 samplesC = samples_p[channel];
1201 current_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1202 previous_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1208 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1209 int byte = bytestream2_get_byte(&gb);
1211 current_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1212 previous_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1214 for (count2=0; count2<28; count2++)
1215 *samplesC++ =
sign_extend(bytestream2_get_be16(&gb), 16);
1219 shift = 20 - (byte & 0x0F);
1221 for (count2=0; count2<28; count2++) {
1225 byte = bytestream2_get_byte(&gb);
1229 next_sample += (current_sample * coeff1) +
1230 (previous_sample * coeff2);
1231 next_sample = av_clip_int16(next_sample >> 8);
1233 previous_sample = current_sample;
1234 current_sample = next_sample;
1235 *samplesC++ = current_sample;
1241 }
else if (count != count1) {
1243 count =
FFMAX(count, count1);
1257 for (channel=0; channel<avctx->
channels; channel++) {
1259 int16_t *
s = samples_p[channel];
1260 for (n = 0; n < 4; n++, s += 32) {
1266 val =
sign_extend(bytestream2_get_le16u(&gb), 16);
1267 shift[
n] = 20 - (val & 0x0F);
1271 for (m=2; m<32; m+=2) {
1272 s = &samples_p[channel][
m];
1273 for (n = 0; n < 4; n++, s += 32) {
1275 int byte = bytestream2_get_byteu(&gb);
1278 pred = s[-1] * coeff[0][
n] + s[-2] * coeff[1][
n];
1279 s[0] = av_clip_int16((level + pred + 0x80) >> 8);
1282 pred = s[0] * coeff[0][
n] + s[-1] * coeff[1][
n];
1283 s[1] = av_clip_int16((level + pred + 0x80) >> 8);
1298 for (n = nb_samples >> (1 - st); n > 0; n--) {
1299 int v = bytestream2_get_byteu(&gb);
1306 for (i = 0; i < avctx->
channels; i++) {
1317 for (n = nb_samples >> (1 - st); n > 0; n--) {
1318 int v = bytestream2_get_byteu(&gb);
1325 for (n = nb_samples >> (1 - st); n > 0; n--) {
1326 int v = bytestream2_get_byteu(&gb);
1336 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1338 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1343 for (n = nb_samples >> (1 - st); n > 0; n--) {
1344 int byte = bytestream2_get_byteu(&gb);
1351 for (n = (nb_samples<<st) / 3; n > 0; n--) {
1352 int byte = bytestream2_get_byteu(&gb);
1356 (byte >> 2) & 0x07, 3, 0);
1361 for (n = nb_samples >> (2 - st); n > 0; n--) {
1362 int byte = bytestream2_get_byteu(&gb);
1366 (byte >> 4) & 0x03, 2, 2);
1368 (byte >> 2) & 0x03, 2, 2);
1379 for (n = nb_samples >> (1 - st); n > 0; n--) {
1380 int v = bytestream2_get_byteu(&gb);
1387 for (channel = 0; channel < avctx->
channels; channel++)
1391 for (channel = 0; channel < avctx->
channels; channel++) {
1392 samples = samples_p[channel];
1393 for (n = nb_samples >> 1; n > 0; n--) {
1394 int v = bytestream2_get_byteu(&gb);
1402 int samples_per_block;
1406 samples_per_block = avctx->
extradata[0] / 16;
1407 blocks = nb_samples / avctx->
extradata[0];
1409 samples_per_block = nb_samples / 16;
1413 for (m = 0; m < blocks; m++) {
1414 for (channel = 0; channel < avctx->
channels; channel++) {
1418 samples = samples_p[channel] + m * 16;
1420 for (i = 0; i < samples_per_block; i++) {
1421 int byte = bytestream2_get_byteu(&gb);
1422 int scale = 1 << (byte >> 4);
1423 int index = byte & 0xf;
1428 for (n = 0; n < 16; n++) {
1434 byte = bytestream2_get_byteu(&gb);
1438 sampledat = ((prev1 * factor1 + prev2 * factor2) +
1439 ((sampledat * scale) << 11)) >> 11;
1440 *samples = av_clip_int16(sampledat);
1459 #define THP_GET16(g) \
1461 avctx->codec->id == AV_CODEC_ID_ADPCM_THP_LE ? \
1462 bytestream2_get_le16u(&(g)) : \
1463 bytestream2_get_be16u(&(g)), 16)
1473 for (i = 0; i < avctx->
channels; i++)
1474 for (n = 0; n < 16; n++)
1477 for (i = 0; i < avctx->
channels; i++)
1478 for (n = 0; n < 16; n++)
1483 for (i = 0; i < avctx->
channels; i++) {
1493 for (ch = 0; ch < avctx->
channels; ch++) {
1494 samples = samples_p[ch];
1497 for (i = 0; i < (nb_samples + 13) / 14; i++) {
1498 int byte = bytestream2_get_byteu(&gb);
1499 int index = (byte >> 4) & 7;
1500 unsigned int exp = byte & 0x0F;
1501 int factor1 = table[ch][index * 2];
1502 int factor2 = table[ch][index * 2 + 1];
1505 for (n = 0; n < 14 && (i * 14 + n < nb_samples); n++) {
1511 byte = bytestream2_get_byteu(&gb);
1517 *samples = av_clip_int16(sampledat);
1526 for (channel = 0; channel < avctx->
channels; channel++) {
1527 samples = samples_p[channel];
1530 for (i = 0; i < nb_samples / 28; i++) {
1534 header = bytestream2_get_byteu(&gb);
1538 for (n = 0; n < 28; n++) {
1541 switch (header >> 4) {
1555 prev = av_clip_intp2((prev + 0x20) >> 6, 21);
1557 byte = bytestream2_get_byteu(&gb);
1563 sampledat = (((sampledat << 12) >> (header & 0xf)) << 6) + prev;
1564 *samples++ = av_clip_int16(sampledat >> 6);
1574 for (channel = 0; channel < avctx->
channels; channel++) {
1575 samples = samples_p[channel];
1578 for (i = 0; i < nb_samples / 28; i++) {
1581 filter = bytestream2_get_byteu(&gb);
1582 shift = filter & 0xf;
1583 filter = filter >> 4;
1586 flag = bytestream2_get_byteu(&gb);
1589 for (n = 0; n < 28; n++) {
1596 byte = bytestream2_get_byteu(&gb);
1600 scale = scale << 12;
1603 *samples++ = av_clip_int16(sample);
1645 #define ADPCM_DECODER(id_, sample_fmts_, name_, long_name_) \
1646 AVCodec ff_ ## name_ ## _decoder = { \
1648 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
1649 .type = AVMEDIA_TYPE_AUDIO, \
1651 .priv_data_size = sizeof(ADPCMDecodeContext), \
1652 .init = adpcm_decode_init, \
1653 .decode = adpcm_decode_frame, \
1654 .flush = adpcm_flush, \
1655 .capabilities = AV_CODEC_CAP_DR1, \
1656 .sample_fmts = sample_fmts_, \
const struct AVCodec * codec
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static short adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, char nibble, int size, int shift)
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
const int16_t ff_adpcm_afc_coeffs[2][16]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static enum AVSampleFormat sample_fmts_s16[]
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
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)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
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.
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, uint8_t clip)
static const int xa_adpcm_table[5][2]
static int get_bits_count(const GetBitContext *s)
static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, int buf_size, int *coded_samples, int *approx_nb_samples)
Get the number of samples that will be decoded from the packet.
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
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 void predictor(uint8_t *src, int size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
ADPCM encoder/decoder common header.
static short adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, unsigned char nibble)
static const int ea_adpcm_table[]
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
const int8_t *const ff_adpcm_index_tables[4]
static const struct endianess table[]
const int16_t ff_adpcm_step_table[89]
This is the step table.
static int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble, int shift)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
static int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps)
const int8_t ff_adpcm_index_table[16]
static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, int is_silence, int64_t nb_samples_notify, AVRational time_base)
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 const uint8_t ff_adpcm_ima_block_sizes[4]
static enum AVSampleFormat sample_fmts_s16p[]
const int16_t ff_adpcm_oki_step_table[49]
#define FF_ARRAY_ELEMS(a)
static short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble, int shift)
static const float pred[4]
static const int swf_index_tables[4][16]
static const uint8_t ff_adpcm_ima_block_samples[4]
static av_always_inline int bytestream2_tell(GetByteContext *g)
const int16_t ff_adpcm_AdaptationTable[]
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL byte
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble)
main external API structure.
#define DK3_GET_NEXT_NIBBLE()
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static short adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nibble)
ADPCMChannelStatus status[14]
static av_const int sign_extend(int val, unsigned bits)
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_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)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
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 enum AVSampleFormat sample_fmts_both[]
uint8_t ** extended_data
pointers to the data planes/channels.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
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_)