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;
176 step_index = av_clip(step_index, 0, 88);
183 diff = ((2 * delta + 1) * step) >>
shift;
185 if (sign) predictor -=
diff;
186 else predictor +=
diff;
202 step_index = av_clip(step_index, 0, 88);
204 sign = nibble & (1 <<
shift);
205 delta = av_mod_uintp2(nibble, shift);
206 diff = ((2 * delta + 1) * step) >>
shift;
208 if (sign) predictor -=
diff;
209 else predictor +=
diff;
225 step_index = av_clip(step_index, 0, 88);
228 if (nibble & 4) diff += step;
229 if (nibble & 2) diff += step >> 1;
230 if (nibble & 1) diff += step >> 2;
248 predictor += ((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->
idelta;
251 c->
sample1 = av_clip_int16(predictor);
254 if (c->
idelta > INT_MAX/768) {
268 step_index = av_clip(step_index, 0, 48);
272 diff = ((2 * delta + 1) * step) >> 3;
274 if (sign) predictor -=
diff;
275 else predictor +=
diff;
277 c->
predictor = av_clip_intp2(predictor, 11);
293 diff = ((2 * delta + 1) * c->
step) >> 3;
299 c->
step = av_clip(new_step, 511, 32767);
308 sign = nibble & (1<<(size-1));
309 delta = nibble & ((1<<(size-1))-1);
316 if (delta >= (2*size - 3) && c->
step < 3)
318 else if (delta == 0 && c->
step > 0)
334 c->
step = av_clip(c->
step, 127, 24567);
347 out0 += sample_offset;
351 out1 += sample_offset;
354 shift = 12 - (in[4+i*2] & 15);
355 filter = in[4+i*2] >> 4;
374 s = t*(1<<
shift) + ((s_1*f0 + s_2*f1+32)>>6);
376 s_1 = av_clip_int16(s);
387 shift = 12 - (in[5+i*2] & 15);
388 filter = in[5+i*2] >> 4;
405 s = t*(1<<
shift) + ((s_1*f0 + s_2*f1+32)>>6);
407 s_1 = av_clip_int16(s);
419 out0 += 28 * (3 - channels);
420 out1 += 28 * (3 - channels);
431 int k0, signmask, nb_bits,
count;
432 int size = buf_size*8;
440 k0 = 1 << (nb_bits-2);
441 signmask = 1 << (nb_bits-1);
444 for (i = 0; i < avctx->
channels; i++) {
452 for (i = 0; i < avctx->
channels; i++) {
467 if (delta & signmask)
495 int buf_size,
int *coded_samples,
int *approx_nb_samples)
500 int has_coded_samples = 0;
504 *approx_nb_samples = 0;
512 if (buf_size < 76 * ch)
517 if (buf_size < 34 * ch)
528 nb_samples = buf_size * 2 / ch;
543 return (buf_size - header_size) * 2 / ch;
548 has_coded_samples = 1;
549 *coded_samples = bytestream2_get_le32(gb);
550 *coded_samples -= *coded_samples % 28;
551 nb_samples = (buf_size - 12) / 30 * 28;
554 has_coded_samples = 1;
555 *coded_samples = bytestream2_get_le32(gb);
556 nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
559 nb_samples = (buf_size - ch) / ch * 2;
566 has_coded_samples = 1;
569 header_size = 4 + 9 * ch;
570 *coded_samples = bytestream2_get_le32(gb);
573 header_size = 4 + 5 * ch;
574 *coded_samples = bytestream2_get_le32(gb);
577 header_size = 4 + 5 * ch;
578 *coded_samples = bytestream2_get_be32(gb);
581 *coded_samples -= *coded_samples % 28;
582 nb_samples = (buf_size - header_size) * 2 / ch;
583 nb_samples -= nb_samples % 28;
584 *approx_nb_samples = 1;
589 nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
594 if (buf_size < 4 * ch)
596 nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
601 nb_samples = (buf_size - 4 * ch) * 2 / ch;
609 if (buf_size < 4 * ch)
611 nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
617 nb_samples = (buf_size - 6 * ch) * 2 / ch;
623 int samples_per_byte;
635 nb_samples += buf_size * samples_per_byte / ch;
640 int buf_bits = buf_size * 8 - 2;
641 int nbits = (bytestream2_get_byte(gb) >> 6) + 2;
642 int block_hdr_size = 22 * ch;
643 int block_size = block_hdr_size + nbits * ch * 4095;
644 int nblocks = buf_bits / block_size;
645 int bits_left = buf_bits - nblocks * block_size;
646 nb_samples = nblocks * 4096;
647 if (bits_left >= block_hdr_size)
648 nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
654 nb_samples = buf_size * 14 / (8 * ch);
657 has_coded_samples = 1;
660 bytestream2_get_le32(gb) :
661 bytestream2_get_be32(gb);
662 buf_size -= 8 + 36 * ch;
664 nb_samples = buf_size / 8 * 14;
665 if (buf_size % 8 > 1)
666 nb_samples += (buf_size % 8 - 1) * 2;
667 *approx_nb_samples = 1;
670 nb_samples = buf_size / (9 * ch) * 16;
673 nb_samples = (buf_size / 128) * 224 / ch;
676 nb_samples = buf_size / (16 * ch) * 28;
681 if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
688 int *got_frame_ptr,
AVPacket *avpkt)
692 int buf_size = avpkt->
size;
695 int n,
m, channel, i;
700 int nb_samples, coded_samples, approx_nb_samples, ret;
704 nb_samples =
get_nb_samples(avctx, &gb, buf_size, &coded_samples, &approx_nb_samples);
705 if (nb_samples <= 0) {
714 samples = (
short *)frame->
data[0];
720 if (!approx_nb_samples && coded_samples != nb_samples)
722 frame->
nb_samples = nb_samples = coded_samples;
731 for (channel = 0; channel < avctx->
channels; channel++) {
734 cs = &(c->
status[channel]);
738 predictor =
sign_extend(bytestream2_get_be16u(&gb), 16);
739 step_index = predictor & 0x7F;
760 samples = samples_p[channel];
762 for (m = 0; m < 64; m += 2) {
763 int byte = bytestream2_get_byteu(&gb);
789 for (n = 0; n < (nb_samples - 1) / samples_per_block; n++) {
790 for (i = 0; i < avctx->
channels; i++) {
792 samples = &samples_p[i][1 + n * samples_per_block];
793 for (m = 0; m < samples_per_block; m++) {
801 for (n = 0; n < (nb_samples - 1) / 8; n++) {
802 for (i = 0; i < avctx->
channels; i++) {
804 samples = &samples_p[i][1 + n * 8];
805 for (m = 0; m < 8; m += 2) {
806 int v = bytestream2_get_byteu(&gb);
815 for (i = 0; i < avctx->
channels; i++)
818 for (i = 0; i < avctx->
channels; i++) {
827 for (i = 0; i < avctx->
channels; i++) {
828 samples = (int16_t *)frame->
data[i];
830 for (n = nb_samples >> 1; n > 0; n--) {
831 int v = bytestream2_get_byteu(&gb);
841 block_predictor = bytestream2_get_byteu(&gb);
842 if (block_predictor > 6) {
850 block_predictor = bytestream2_get_byteu(&gb);
851 if (block_predictor > 6) {
873 for(n = (nb_samples - 2) >> (1 - st); n > 0; n--) {
874 int byte = bytestream2_get_byteu(&gb);
881 for (channel = 0; channel < avctx->
channels; channel++) {
891 for (n = (nb_samples - 1) >> (1 - st); n > 0; n--) {
892 int v = bytestream2_get_byteu(&gb);
901 int decode_top_nibble_next = 0;
903 const int16_t *samples_end = samples + avctx->
channels * nb_samples;
919 #define DK3_GET_NEXT_NIBBLE() \
920 if (decode_top_nibble_next) { \
921 nibble = last_byte >> 4; \
922 decode_top_nibble_next = 0; \
924 last_byte = bytestream2_get_byteu(&gb); \
925 nibble = last_byte & 0x0F; \
926 decode_top_nibble_next = 1; \
929 while (samples < samples_end) {
962 for (channel = 0; channel < avctx->
channels; channel++) {
973 for (n = nb_samples >> (1 - st); n > 0; n--) {
975 int v = bytestream2_get_byteu(&gb);
990 int v = bytestream2_get_byteu(&gb);
997 int v = bytestream2_get_byteu(&gb);
1003 for (channel = 0; channel < avctx->
channels; channel++) {
1004 cs = &c->
status[channel];
1013 for (n = 0; n < nb_samples / 2; n++) {
1016 byte[0] = bytestream2_get_byteu(&gb);
1018 byte[1] = bytestream2_get_byteu(&gb);
1019 for(channel = 0; channel < avctx->
channels; channel++) {
1022 for(channel = 0; channel < avctx->
channels; channel++) {
1029 for (channel = 0; channel < avctx->
channels; channel++) {
1030 int16_t *smp = samples_p[channel];
1032 for (n = nb_samples / 2; n > 0; n--) {
1033 int v = bytestream2_get_byteu(&gb);
1039 for (n = nb_samples / 2; n > 0; n--) {
1040 for (channel = 0; channel < avctx->
channels; channel++) {
1041 int v = bytestream2_get_byteu(&gb);
1052 int16_t *out0 = samples_p[0];
1053 int16_t *out1 = samples_p[1];
1054 int samples_per_block = 28 * (3 - avctx->
channels) * 4;
1055 int sample_offset = 0;
1059 avctx->
channels, sample_offset)) < 0)
1062 sample_offset += samples_per_block;
1067 for (i=0; i<=st; i++) {
1075 for (i=0; i<=st; i++) {
1081 for (n = nb_samples >> (1 - st); n > 0; n--) {
1082 int byte = bytestream2_get_byteu(&gb);
1088 for (n = nb_samples >> (1 - st); n > 0; n--) {
1089 int byte = bytestream2_get_byteu(&gb);
1096 int previous_left_sample, previous_right_sample;
1097 int current_left_sample, current_right_sample;
1098 int next_left_sample, next_right_sample;
1099 int coeff1l, coeff2l, coeff1r, coeff2r;
1100 int shift_left, shift_right;
1108 current_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1109 previous_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1110 current_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1111 previous_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1113 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1114 int byte = bytestream2_get_byteu(&gb);
1120 byte = bytestream2_get_byteu(&gb);
1121 shift_left = 20 - (byte >> 4);
1122 shift_right = 20 - (byte & 0x0F);
1124 for (count2 = 0; count2 < 28; count2++) {
1125 byte = bytestream2_get_byteu(&gb);
1126 next_left_sample =
sign_extend(byte >> 4, 4) << shift_left;
1127 next_right_sample =
sign_extend(byte, 4) << shift_right;
1129 next_left_sample = (next_left_sample +
1130 (current_left_sample * coeff1l) +
1131 (previous_left_sample * coeff2l) + 0x80) >> 8;
1132 next_right_sample = (next_right_sample +
1133 (current_right_sample * coeff1r) +
1134 (previous_right_sample * coeff2r) + 0x80) >> 8;
1136 previous_left_sample = current_left_sample;
1137 current_left_sample = av_clip_int16(next_left_sample);
1138 previous_right_sample = current_right_sample;
1139 current_right_sample = av_clip_int16(next_right_sample);
1140 *samples++ = current_left_sample;
1141 *samples++ = current_right_sample;
1153 for(channel = 0; channel < avctx->
channels; channel++) {
1154 int byte = bytestream2_get_byteu(&gb);
1157 shift[channel] = 20 - (byte & 0x0F);
1159 for (count1 = 0; count1 < nb_samples / 2; count1++) {
1162 byte[0] = bytestream2_get_byteu(&gb);
1163 if (st) byte[1] = bytestream2_get_byteu(&gb);
1164 for(i = 4; i >= 0; i-=4) {
1165 for(channel = 0; channel < avctx->
channels; channel++) {
1169 c->
status[channel].
sample2 * coeff[channel][1] + 0x80) >> 8;
1187 int previous_sample, current_sample, next_sample;
1190 unsigned int channel;
1195 for (channel=0; channel<avctx->
channels; channel++)
1196 offsets[channel] = (big_endian ? bytestream2_get_be32(&gb) :
1197 bytestream2_get_le32(&gb)) +
1200 for (channel=0; channel<avctx->
channels; channel++) {
1202 samplesC = samples_p[channel];
1205 current_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1206 previous_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1212 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1213 int byte = bytestream2_get_byte(&gb);
1215 current_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1216 previous_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1218 for (count2=0; count2<28; count2++)
1219 *samplesC++ =
sign_extend(bytestream2_get_be16(&gb), 16);
1223 shift = 20 - (byte & 0x0F);
1225 for (count2=0; count2<28; count2++) {
1229 byte = bytestream2_get_byte(&gb);
1233 next_sample += (current_sample * coeff1) +
1234 (previous_sample * coeff2);
1235 next_sample = av_clip_int16(next_sample >> 8);
1237 previous_sample = current_sample;
1238 current_sample = next_sample;
1239 *samplesC++ = current_sample;
1245 }
else if (count != count1) {
1247 count =
FFMAX(count, count1);
1261 for (channel=0; channel<avctx->
channels; channel++) {
1263 int16_t *
s = samples_p[channel];
1264 for (n = 0; n < 4; n++, s += 32) {
1270 val =
sign_extend(bytestream2_get_le16u(&gb), 16);
1271 shift[
n] = 20 - (val & 0x0F);
1275 for (m=2; m<32; m+=2) {
1276 s = &samples_p[channel][
m];
1277 for (n = 0; n < 4; n++, s += 32) {
1279 int byte = bytestream2_get_byteu(&gb);
1282 pred = s[-1] * coeff[0][
n] + s[-2] * coeff[1][
n];
1283 s[0] = av_clip_int16((level + pred + 0x80) >> 8);
1286 pred = s[0] * coeff[0][
n] + s[-1] * coeff[1][
n];
1287 s[1] = av_clip_int16((level + pred + 0x80) >> 8);
1302 for (n = nb_samples >> (1 - st); n > 0; n--) {
1303 int v = bytestream2_get_byteu(&gb);
1310 for (i = 0; i < avctx->
channels; i++) {
1321 for (n = nb_samples >> (1 - st); n > 0; n--) {
1322 int v = bytestream2_get_byteu(&gb);
1329 for (n = nb_samples >> (1 - st); n > 0; n--) {
1330 int v = bytestream2_get_byteu(&gb);
1340 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1342 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1347 for (n = nb_samples >> (1 - st); n > 0; n--) {
1348 int byte = bytestream2_get_byteu(&gb);
1355 for (n = (nb_samples<<st) / 3; n > 0; n--) {
1356 int byte = bytestream2_get_byteu(&gb);
1360 (byte >> 2) & 0x07, 3, 0);
1365 for (n = nb_samples >> (2 - st); n > 0; n--) {
1366 int byte = bytestream2_get_byteu(&gb);
1370 (byte >> 4) & 0x03, 2, 2);
1372 (byte >> 2) & 0x03, 2, 2);
1383 for (n = nb_samples >> (1 - st); n > 0; n--) {
1384 int v = bytestream2_get_byteu(&gb);
1391 int samples_per_block;
1395 samples_per_block = avctx->
extradata[0] / 16;
1396 blocks = nb_samples / avctx->
extradata[0];
1398 samples_per_block = nb_samples / 16;
1402 for (m = 0; m < blocks; m++) {
1403 for (channel = 0; channel < avctx->
channels; channel++) {
1407 samples = samples_p[channel] + m * 16;
1409 for (i = 0; i < samples_per_block; i++) {
1410 int byte = bytestream2_get_byteu(&gb);
1411 int scale = 1 << (byte >> 4);
1412 int index = byte & 0xf;
1417 for (n = 0; n < 16; n++) {
1423 byte = bytestream2_get_byteu(&gb);
1427 sampledat = ((prev1 * factor1 + prev2 * factor2) +
1428 ((sampledat * scale) << 11)) >> 11;
1429 *samples = av_clip_int16(sampledat);
1448 #define THP_GET16(g) \
1450 avctx->codec->id == AV_CODEC_ID_ADPCM_THP_LE ? \
1451 bytestream2_get_le16u(&(g)) : \
1452 bytestream2_get_be16u(&(g)), 16)
1462 for (i = 0; i < avctx->
channels; i++)
1463 for (n = 0; n < 16; n++)
1466 for (i = 0; i < avctx->
channels; i++)
1467 for (n = 0; n < 16; n++)
1472 for (i = 0; i < avctx->
channels; i++) {
1482 for (ch = 0; ch < avctx->
channels; ch++) {
1483 samples = samples_p[ch];
1486 for (i = 0; i < (nb_samples + 13) / 14; i++) {
1487 int byte = bytestream2_get_byteu(&gb);
1488 int index = (byte >> 4) & 7;
1489 unsigned int exp = byte & 0x0F;
1490 int64_t factor1 = table[ch][index * 2];
1491 int64_t factor2 = table[ch][index * 2 + 1];
1494 for (n = 0; n < 14 && (i * 14 + n < nb_samples); n++) {
1500 byte = bytestream2_get_byteu(&gb);
1505 + c->
status[ch].
sample2 * factor2) >> 11) + (sampledat << exp);
1506 *samples = av_clip_int16(sampledat);
1515 for (channel = 0; channel < avctx->
channels; channel++) {
1516 samples = samples_p[channel];
1519 for (i = 0; i < nb_samples / 28; i++) {
1523 header = bytestream2_get_byteu(&gb);
1527 for (n = 0; n < 28; n++) {
1530 switch (header >> 4) {
1544 prev = av_clip_intp2((prev + 0x20) >> 6, 21);
1546 byte = bytestream2_get_byteu(&gb);
1552 sampledat = ((sampledat * (1 << 12)) >> (header & 0xf)) * (1 << 6) + prev;
1553 *samples++ = av_clip_int16(sampledat >> 6);
1597 #define ADPCM_DECODER(id_, sample_fmts_, name_, long_name_) \
1598 AVCodec ff_ ## name_ ## _decoder = { \
1600 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
1601 .type = AVMEDIA_TYPE_AUDIO, \
1603 .priv_data_size = sizeof(ADPCMDecodeContext), \
1604 .init = adpcm_decode_init, \
1605 .decode = adpcm_decode_frame, \
1606 .flush = adpcm_flush, \
1607 .capabilities = AV_CODEC_CAP_DR1, \
1608 .sample_fmts = sample_fmts_, \
const struct AVCodec * codec
const char const char void * val
ADPCMChannelStatus status[10]
#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.
#define avpriv_request_sample(...)
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[]
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)
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 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)
Libavcodec external API header.
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[]
#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 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[]
AVSampleFormat
Audio sample formats.
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)
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.
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
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.
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_)