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 }
94 unsigned int min_channels = 1;
95 unsigned int max_channels = 2;
171 step_index = av_clip(step_index, 0, 88);
178 diff = ((2 * delta + 1) * step) >>
shift;
180 if (sign) predictor -=
diff;
181 else predictor +=
diff;
197 step_index = av_clip(step_index, 0, 88);
199 sign = nibble & (1 <<
shift);
200 delta = av_mod_uintp2(nibble, shift);
201 diff = ((2 * delta + 1) * step) >>
shift;
203 if (sign) predictor -=
diff;
204 else predictor +=
diff;
220 step_index = av_clip(step_index, 0, 88);
223 if (nibble & 4) diff += step;
224 if (nibble & 2) diff += step >> 1;
225 if (nibble & 1) diff += step >> 2;
243 predictor += ((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->
idelta;
246 c->
sample1 = av_clip_int16(predictor);
249 if (c->
idelta > INT_MAX/768) {
263 step_index = av_clip(step_index, 0, 48);
267 diff = ((2 * delta + 1) * step) >> 3;
269 if (sign) predictor -=
diff;
270 else predictor +=
diff;
272 c->
predictor = av_clip_intp2(predictor, 11);
288 diff = ((2 * delta + 1) * c->
step) >> 3;
294 c->
step = av_clip(new_step, 511, 32767);
303 sign = nibble & (1<<(size-1));
304 delta = nibble & ((1<<(size-1))-1);
311 if (delta >= (2*size - 3) && c->
step < 3)
313 else if (delta == 0 && c->
step > 0)
329 c->
step = av_clip(c->
step, 127, 24567);
342 out0 += sample_offset;
346 out1 += sample_offset;
349 shift = 12 - (in[4+i*2] & 15);
350 filter = in[4+i*2] >> 4;
365 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
367 s_1 = av_clip_int16(s);
378 shift = 12 - (in[5+i*2] & 15);
379 filter = in[5+i*2] >> 4;
392 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
394 s_1 = av_clip_int16(s);
406 out0 += 28 * (3 - channels);
407 out1 += 28 * (3 - channels);
418 int k0, signmask, nb_bits,
count;
419 int size = buf_size*8;
427 k0 = 1 << (nb_bits-2);
428 signmask = 1 << (nb_bits-1);
431 for (i = 0; i < avctx->
channels; i++) {
439 for (i = 0; i < avctx->
channels; i++) {
454 if (delta & signmask)
482 int buf_size,
int *coded_samples,
int *approx_nb_samples)
487 int has_coded_samples = 0;
491 *approx_nb_samples = 0;
499 if (buf_size < 76 * ch)
504 if (buf_size < 34 * ch)
515 nb_samples = buf_size * 2 / ch;
530 return (buf_size - header_size) * 2 / ch;
535 has_coded_samples = 1;
536 *coded_samples = bytestream2_get_le32(gb);
537 *coded_samples -= *coded_samples % 28;
538 nb_samples = (buf_size - 12) / 30 * 28;
541 has_coded_samples = 1;
542 *coded_samples = bytestream2_get_le32(gb);
543 nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
546 nb_samples = (buf_size - ch) / ch * 2;
553 has_coded_samples = 1;
556 header_size = 4 + 9 * ch;
557 *coded_samples = bytestream2_get_le32(gb);
560 header_size = 4 + 5 * ch;
561 *coded_samples = bytestream2_get_le32(gb);
564 header_size = 4 + 5 * ch;
565 *coded_samples = bytestream2_get_be32(gb);
568 *coded_samples -= *coded_samples % 28;
569 nb_samples = (buf_size - header_size) * 2 / ch;
570 nb_samples -= nb_samples % 28;
571 *approx_nb_samples = 1;
576 nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
581 if (buf_size < 4 * ch)
583 nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
588 nb_samples = (buf_size - 4 * ch) * 2 / ch;
596 if (buf_size < 4 * ch)
598 nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
604 nb_samples = (buf_size - 6 * ch) * 2 / ch;
610 int samples_per_byte;
622 nb_samples += buf_size * samples_per_byte / ch;
627 int buf_bits = buf_size * 8 - 2;
628 int nbits = (bytestream2_get_byte(gb) >> 6) + 2;
629 int block_hdr_size = 22 * ch;
630 int block_size = block_hdr_size + nbits * ch * 4095;
631 int nblocks = buf_bits / block_size;
632 int bits_left = buf_bits - nblocks * block_size;
633 nb_samples = nblocks * 4096;
634 if (bits_left >= block_hdr_size)
635 nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
640 nb_samples = buf_size / (8 * ch) * 14;
643 has_coded_samples = 1;
645 *coded_samples = bytestream2_get_be32(gb);
646 *coded_samples -= *coded_samples % 14;
647 nb_samples = (buf_size - (8 + 36 * ch)) / (8 * ch) * 14;
650 nb_samples = buf_size / (9 * ch) * 16;
653 nb_samples = (buf_size / 128) * 224 / ch;
656 nb_samples = buf_size / (16 * ch) * 28;
661 if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
668 int *got_frame_ptr,
AVPacket *avpkt)
672 int buf_size = avpkt->
size;
675 int n,
m, channel, i;
680 int nb_samples, coded_samples, approx_nb_samples,
ret;
684 nb_samples =
get_nb_samples(avctx, &gb, buf_size, &coded_samples, &approx_nb_samples);
685 if (nb_samples <= 0) {
694 samples = (
short *)frame->
data[0];
700 if (!approx_nb_samples && coded_samples != nb_samples)
702 frame->
nb_samples = nb_samples = coded_samples;
711 for (channel = 0; channel < avctx->
channels; channel++) {
714 cs = &(c->
status[channel]);
718 predictor =
sign_extend(bytestream2_get_be16u(&gb), 16);
719 step_index = predictor & 0x7F;
740 samples = samples_p[channel];
742 for (m = 0; m < 64; m += 2) {
743 int byte = bytestream2_get_byteu(&gb);
767 for (n = 0; n < (nb_samples - 1) / samples_per_block; n++) {
768 for (i = 0; i < avctx->
channels; i++) {
770 samples = &samples_p[i][1 + n * samples_per_block];
771 for (m = 0; m < samples_per_block; m++) {
779 for (n = 0; n < (nb_samples - 1) / 8; n++) {
780 for (i = 0; i < avctx->
channels; i++) {
782 samples = &samples_p[i][1 + n * 8];
783 for (m = 0; m < 8; m += 2) {
784 int v = bytestream2_get_byteu(&gb);
793 for (i = 0; i < avctx->
channels; i++)
796 for (i = 0; i < avctx->
channels; i++) {
805 for (i = 0; i < avctx->
channels; i++) {
806 samples = (int16_t *)frame->
data[i];
808 for (n = nb_samples >> 1; n > 0; n--) {
809 int v = bytestream2_get_byteu(&gb);
819 block_predictor = bytestream2_get_byteu(&gb);
820 if (block_predictor > 6) {
828 block_predictor = bytestream2_get_byteu(&gb);
829 if (block_predictor > 6) {
851 for(n = (nb_samples - 2) >> (1 - st); n > 0; n--) {
852 int byte = bytestream2_get_byteu(&gb);
859 for (channel = 0; channel < avctx->
channels; channel++) {
869 for (n = (nb_samples - 1) >> (1 - st); n > 0; n--) {
870 int v = bytestream2_get_byteu(&gb);
879 int decode_top_nibble_next = 0;
881 const int16_t *samples_end = samples + avctx->
channels * nb_samples;
897 #define DK3_GET_NEXT_NIBBLE() \
898 if (decode_top_nibble_next) { \
899 nibble = last_byte >> 4; \
900 decode_top_nibble_next = 0; \
902 last_byte = bytestream2_get_byteu(&gb); \
903 nibble = last_byte & 0x0F; \
904 decode_top_nibble_next = 1; \
907 while (samples < samples_end) {
940 for (channel = 0; channel < avctx->
channels; channel++) {
951 for (n = nb_samples >> (1 - st); n > 0; n--) {
953 int v = bytestream2_get_byteu(&gb);
968 int v = bytestream2_get_byteu(&gb);
975 int v = bytestream2_get_byteu(&gb);
981 for (channel = 0; channel < avctx->
channels; channel++) {
991 for (n = 0; n < nb_samples / 2; n++) {
994 byte[0] = bytestream2_get_byteu(&gb);
996 byte[1] = bytestream2_get_byteu(&gb);
997 for(channel = 0; channel < avctx->
channels; channel++) {
1000 for(channel = 0; channel < avctx->
channels; channel++) {
1007 for (channel = 0; channel < avctx->
channels; channel++) {
1008 int16_t *smp = samples_p[channel];
1010 for (n = nb_samples / 2; n > 0; n--) {
1011 int v = bytestream2_get_byteu(&gb);
1017 for (n = nb_samples / 2; n > 0; n--) {
1018 for (channel = 0; channel < avctx->
channels; channel++) {
1019 int v = bytestream2_get_byteu(&gb);
1030 int16_t *out0 = samples_p[0];
1031 int16_t *out1 = samples_p[1];
1032 int samples_per_block = 28 * (3 - avctx->
channels) * 4;
1033 int sample_offset = 0;
1037 avctx->
channels, sample_offset)) < 0)
1040 sample_offset += samples_per_block;
1045 for (i=0; i<=st; i++) {
1053 for (i=0; i<=st; i++)
1056 for (n = nb_samples >> (1 - st); n > 0; n--) {
1057 int byte = bytestream2_get_byteu(&gb);
1063 for (n = nb_samples >> (1 - st); n > 0; n--) {
1064 int byte = bytestream2_get_byteu(&gb);
1071 int previous_left_sample, previous_right_sample;
1072 int current_left_sample, current_right_sample;
1073 int next_left_sample, next_right_sample;
1074 int coeff1l, coeff2l, coeff1r, coeff2r;
1075 int shift_left, shift_right;
1083 current_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1084 previous_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1085 current_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1086 previous_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1088 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1089 int byte = bytestream2_get_byteu(&gb);
1095 byte = bytestream2_get_byteu(&gb);
1096 shift_left = 20 - (byte >> 4);
1097 shift_right = 20 - (byte & 0x0F);
1099 for (count2 = 0; count2 < 28; count2++) {
1100 byte = bytestream2_get_byteu(&gb);
1101 next_left_sample =
sign_extend(byte >> 4, 4) << shift_left;
1102 next_right_sample =
sign_extend(byte, 4) << shift_right;
1104 next_left_sample = (next_left_sample +
1105 (current_left_sample * coeff1l) +
1106 (previous_left_sample * coeff2l) + 0x80) >> 8;
1107 next_right_sample = (next_right_sample +
1108 (current_right_sample * coeff1r) +
1109 (previous_right_sample * coeff2r) + 0x80) >> 8;
1111 previous_left_sample = current_left_sample;
1112 current_left_sample = av_clip_int16(next_left_sample);
1113 previous_right_sample = current_right_sample;
1114 current_right_sample = av_clip_int16(next_right_sample);
1115 *samples++ = current_left_sample;
1116 *samples++ = current_right_sample;
1128 for(channel = 0; channel < avctx->
channels; channel++) {
1129 int byte = bytestream2_get_byteu(&gb);
1132 shift[channel] = 20 - (byte & 0x0F);
1134 for (count1 = 0; count1 < nb_samples / 2; count1++) {
1137 byte[0] = bytestream2_get_byteu(&gb);
1138 if (st) byte[1] = bytestream2_get_byteu(&gb);
1139 for(i = 4; i >= 0; i-=4) {
1140 for(channel = 0; channel < avctx->
channels; channel++) {
1144 c->
status[channel].
sample2 * coeff[channel][1] + 0x80) >> 8;
1162 int previous_sample, current_sample, next_sample;
1165 unsigned int channel;
1170 for (channel=0; channel<avctx->
channels; channel++)
1171 offsets[channel] = (big_endian ? bytestream2_get_be32(&gb) :
1172 bytestream2_get_le32(&gb)) +
1175 for (channel=0; channel<avctx->
channels; channel++) {
1177 samplesC = samples_p[channel];
1180 current_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1181 previous_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1187 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1188 int byte = bytestream2_get_byte(&gb);
1190 current_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1191 previous_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1193 for (count2=0; count2<28; count2++)
1194 *samplesC++ =
sign_extend(bytestream2_get_be16(&gb), 16);
1198 shift = 20 - (byte & 0x0F);
1200 for (count2=0; count2<28; count2++) {
1204 byte = bytestream2_get_byte(&gb);
1208 next_sample += (current_sample * coeff1) +
1209 (previous_sample * coeff2);
1210 next_sample = av_clip_int16(next_sample >> 8);
1212 previous_sample = current_sample;
1213 current_sample = next_sample;
1214 *samplesC++ = current_sample;
1220 }
else if (count != count1) {
1222 count =
FFMAX(count, count1);
1236 for (channel=0; channel<avctx->
channels; channel++) {
1238 int16_t *
s = samples_p[channel];
1239 for (n = 0; n < 4; n++, s += 32) {
1245 val =
sign_extend(bytestream2_get_le16u(&gb), 16);
1246 shift[
n] = 20 - (val & 0x0F);
1250 for (m=2; m<32; m+=2) {
1251 s = &samples_p[channel][
m];
1252 for (n = 0; n < 4; n++, s += 32) {
1254 int byte = bytestream2_get_byteu(&gb);
1257 pred = s[-1] * coeff[0][
n] + s[-2] * coeff[1][
n];
1258 s[0] = av_clip_int16((level + pred + 0x80) >> 8);
1261 pred = s[0] * coeff[0][
n] + s[-1] * coeff[1][
n];
1262 s[1] = av_clip_int16((level + pred + 0x80) >> 8);
1277 for (n = nb_samples >> (1 - st); n > 0; n--) {
1278 int v = bytestream2_get_byteu(&gb);
1285 for (i = 0; i < avctx->
channels; i++) {
1296 for (n = nb_samples >> (1 - st); n > 0; n--) {
1297 int v = bytestream2_get_byteu(&gb);
1304 for (n = nb_samples >> (1 - st); n > 0; n--) {
1305 int v = bytestream2_get_byteu(&gb);
1315 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1317 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1322 for (n = nb_samples >> (1 - st); n > 0; n--) {
1323 int byte = bytestream2_get_byteu(&gb);
1330 for (n = (nb_samples<<st) / 3; n > 0; n--) {
1331 int byte = bytestream2_get_byteu(&gb);
1335 (byte >> 2) & 0x07, 3, 0);
1340 for (n = nb_samples >> (2 - st); n > 0; n--) {
1341 int byte = bytestream2_get_byteu(&gb);
1345 (byte >> 4) & 0x03, 2, 2);
1347 (byte >> 2) & 0x03, 2, 2);
1358 for (n = nb_samples >> (1 - st); n > 0; n--) {
1359 int v = bytestream2_get_byteu(&gb);
1366 int samples_per_block;
1370 samples_per_block = avctx->
extradata[0] / 16;
1371 blocks = nb_samples / avctx->
extradata[0];
1373 samples_per_block = nb_samples / 16;
1377 for (m = 0; m < blocks; m++) {
1378 for (channel = 0; channel < avctx->
channels; channel++) {
1382 samples = samples_p[channel] + m * 16;
1384 for (i = 0; i < samples_per_block; i++) {
1385 int byte = bytestream2_get_byteu(&gb);
1386 int scale = 1 << (byte >> 4);
1387 int index = byte & 0xf;
1392 for (n = 0; n < 16; n++) {
1398 byte = bytestream2_get_byteu(&gb);
1402 sampledat = ((prev1 * factor1 + prev2 * factor2) +
1403 ((sampledat * scale) << 11)) >> 11;
1404 *samples = av_clip_int16(sampledat);
1430 for (i = 0; i < avctx->
channels; i++)
1431 for (n = 0; n < 16; n++)
1432 table[i][n] =
sign_extend(bytestream2_get_be16u(&tb), 16);
1434 for (i = 0; i < avctx->
channels; i++)
1435 for (n = 0; n < 16; n++)
1436 table[i][n] =
sign_extend(bytestream2_get_be16u(&gb), 16);
1439 for (i = 0; i < avctx->
channels; i++) {
1445 for (ch = 0; ch < avctx->
channels; ch++) {
1446 samples = samples_p[ch];
1449 for (i = 0; i < nb_samples / 14; i++) {
1450 int byte = bytestream2_get_byteu(&gb);
1451 int index = (byte >> 4) & 7;
1452 unsigned int exp = byte & 0x0F;
1453 int factor1 = table[ch][index * 2];
1454 int factor2 = table[ch][index * 2 + 1];
1457 for (n = 0; n < 14; n++) {
1463 byte = bytestream2_get_byteu(&gb);
1468 + c->
status[ch].
sample2 * factor2) >> 11) + (sampledat << exp);
1469 *samples = av_clip_int16(sampledat);
1478 for (channel = 0; channel < avctx->
channels; channel++) {
1479 samples = samples_p[channel];
1482 for (i = 0; i < nb_samples / 28; i++) {
1486 header = bytestream2_get_byteu(&gb);
1490 for (n = 0; n < 28; n++) {
1493 switch (header >> 4) {
1507 prev = av_clip_intp2((prev + 0x20) >> 6, 21);
1509 byte = bytestream2_get_byteu(&gb);
1515 sampledat = (((sampledat << 12) >> (header & 0xf)) << 6) + prev;
1516 *samples++ = av_clip_int16(sampledat >> 6);
1554 #define ADPCM_DECODER(id_, sample_fmts_, name_, long_name_) \
1555 AVCodec ff_ ## name_ ## _decoder = { \
1557 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
1558 .type = AVMEDIA_TYPE_AUDIO, \
1560 .priv_data_size = sizeof(ADPCMDecodeContext), \
1561 .init = adpcm_decode_init, \
1562 .decode = adpcm_decode_frame, \
1563 .capabilities = CODEC_CAP_DR1, \
1564 .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[]
#define FF_ARRAY_ELEMS(a)
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_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)
ADPCMChannelStatus status[6]
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]
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.
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)
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.
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_)