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;
370 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
372 s_1 = av_clip_int16(s);
383 shift = 12 - (in[5+i*2] & 15);
384 filter = in[5+i*2] >> 4;
397 s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
399 s_1 = av_clip_int16(s);
411 out0 += 28 * (3 - channels);
412 out1 += 28 * (3 - channels);
423 int k0, signmask, nb_bits,
count;
424 int size = buf_size*8;
432 k0 = 1 << (nb_bits-2);
433 signmask = 1 << (nb_bits-1);
436 for (i = 0; i < avctx->
channels; i++) {
444 for (i = 0; i < avctx->
channels; i++) {
459 if (delta & signmask)
487 int buf_size,
int *coded_samples,
int *approx_nb_samples)
492 int has_coded_samples = 0;
496 *approx_nb_samples = 0;
504 if (buf_size < 76 * ch)
509 if (buf_size < 34 * ch)
520 nb_samples = buf_size * 2 / ch;
535 return (buf_size - header_size) * 2 / ch;
540 has_coded_samples = 1;
541 *coded_samples = bytestream2_get_le32(gb);
542 *coded_samples -= *coded_samples % 28;
543 nb_samples = (buf_size - 12) / 30 * 28;
546 has_coded_samples = 1;
547 *coded_samples = bytestream2_get_le32(gb);
548 nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
551 nb_samples = (buf_size - ch) / ch * 2;
558 has_coded_samples = 1;
561 header_size = 4 + 9 * ch;
562 *coded_samples = bytestream2_get_le32(gb);
565 header_size = 4 + 5 * ch;
566 *coded_samples = bytestream2_get_le32(gb);
569 header_size = 4 + 5 * ch;
570 *coded_samples = bytestream2_get_be32(gb);
573 *coded_samples -= *coded_samples % 28;
574 nb_samples = (buf_size - header_size) * 2 / ch;
575 nb_samples -= nb_samples % 28;
576 *approx_nb_samples = 1;
581 nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
586 if (buf_size < 4 * ch)
588 nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
593 nb_samples = (buf_size - 4 * ch) * 2 / ch;
601 if (buf_size < 4 * ch)
603 nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
609 nb_samples = (buf_size - 6 * ch) * 2 / ch;
615 int samples_per_byte;
627 nb_samples += buf_size * samples_per_byte / ch;
632 int buf_bits = buf_size * 8 - 2;
633 int nbits = (bytestream2_get_byte(gb) >> 6) + 2;
634 int block_hdr_size = 22 * ch;
635 int block_size = block_hdr_size + nbits * ch * 4095;
636 int nblocks = buf_bits / block_size;
637 int bits_left = buf_bits - nblocks * block_size;
638 nb_samples = nblocks * 4096;
639 if (bits_left >= block_hdr_size)
640 nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
646 nb_samples = buf_size * 14 / (8 * ch);
649 has_coded_samples = 1;
652 bytestream2_get_le32(gb) :
653 bytestream2_get_be32(gb);
654 buf_size -= 8 + 36 * ch;
656 nb_samples = buf_size / 8 * 14;
657 if (buf_size % 8 > 1)
658 nb_samples += (buf_size % 8 - 1) * 2;
659 *approx_nb_samples = 1;
662 nb_samples = buf_size / (9 * ch) * 16;
665 nb_samples = (buf_size / 128) * 224 / ch;
668 nb_samples = buf_size / (16 * ch) * 28;
673 if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
680 int *got_frame_ptr,
AVPacket *avpkt)
684 int buf_size = avpkt->
size;
687 int n,
m, channel, i;
692 int nb_samples, coded_samples, approx_nb_samples, ret;
696 nb_samples =
get_nb_samples(avctx, &gb, buf_size, &coded_samples, &approx_nb_samples);
697 if (nb_samples <= 0) {
706 samples = (
short *)frame->
data[0];
712 if (!approx_nb_samples && coded_samples != nb_samples)
714 frame->
nb_samples = nb_samples = coded_samples;
723 for (channel = 0; channel < avctx->
channels; channel++) {
726 cs = &(c->
status[channel]);
730 predictor =
sign_extend(bytestream2_get_be16u(&gb), 16);
731 step_index = predictor & 0x7F;
752 samples = samples_p[channel];
754 for (m = 0; m < 64; m += 2) {
755 int byte = bytestream2_get_byteu(&gb);
781 for (n = 0; n < (nb_samples - 1) / samples_per_block; n++) {
782 for (i = 0; i < avctx->
channels; i++) {
784 samples = &samples_p[i][1 + n * samples_per_block];
785 for (m = 0; m < samples_per_block; m++) {
793 for (n = 0; n < (nb_samples - 1) / 8; n++) {
794 for (i = 0; i < avctx->
channels; i++) {
796 samples = &samples_p[i][1 + n * 8];
797 for (m = 0; m < 8; m += 2) {
798 int v = bytestream2_get_byteu(&gb);
807 for (i = 0; i < avctx->
channels; i++)
810 for (i = 0; i < avctx->
channels; i++) {
819 for (i = 0; i < avctx->
channels; i++) {
820 samples = (int16_t *)frame->
data[i];
822 for (n = nb_samples >> 1; n > 0; n--) {
823 int v = bytestream2_get_byteu(&gb);
833 block_predictor = bytestream2_get_byteu(&gb);
834 if (block_predictor > 6) {
842 block_predictor = bytestream2_get_byteu(&gb);
843 if (block_predictor > 6) {
865 for(n = (nb_samples - 2) >> (1 - st); n > 0; n--) {
866 int byte = bytestream2_get_byteu(&gb);
873 for (channel = 0; channel < avctx->
channels; channel++) {
883 for (n = (nb_samples - 1) >> (1 - st); n > 0; n--) {
884 int v = bytestream2_get_byteu(&gb);
893 int decode_top_nibble_next = 0;
895 const int16_t *samples_end = samples + avctx->
channels * nb_samples;
911 #define DK3_GET_NEXT_NIBBLE() \
912 if (decode_top_nibble_next) { \
913 nibble = last_byte >> 4; \
914 decode_top_nibble_next = 0; \
916 last_byte = bytestream2_get_byteu(&gb); \
917 nibble = last_byte & 0x0F; \
918 decode_top_nibble_next = 1; \
921 while (samples < samples_end) {
954 for (channel = 0; channel < avctx->
channels; channel++) {
965 for (n = nb_samples >> (1 - st); n > 0; n--) {
967 int v = bytestream2_get_byteu(&gb);
982 int v = bytestream2_get_byteu(&gb);
989 int v = bytestream2_get_byteu(&gb);
995 for (channel = 0; channel < avctx->
channels; channel++) {
1005 for (n = 0; n < nb_samples / 2; n++) {
1008 byte[0] = bytestream2_get_byteu(&gb);
1010 byte[1] = bytestream2_get_byteu(&gb);
1011 for(channel = 0; channel < avctx->
channels; channel++) {
1014 for(channel = 0; channel < avctx->
channels; channel++) {
1021 for (channel = 0; channel < avctx->
channels; channel++) {
1022 int16_t *smp = samples_p[channel];
1024 for (n = nb_samples / 2; n > 0; n--) {
1025 int v = bytestream2_get_byteu(&gb);
1031 for (n = nb_samples / 2; n > 0; n--) {
1032 for (channel = 0; channel < avctx->
channels; channel++) {
1033 int v = bytestream2_get_byteu(&gb);
1044 int16_t *out0 = samples_p[0];
1045 int16_t *out1 = samples_p[1];
1046 int samples_per_block = 28 * (3 - avctx->
channels) * 4;
1047 int sample_offset = 0;
1051 avctx->
channels, sample_offset)) < 0)
1054 sample_offset += samples_per_block;
1059 for (i=0; i<=st; i++) {
1067 for (i=0; i<=st; i++)
1070 for (n = nb_samples >> (1 - st); n > 0; n--) {
1071 int byte = bytestream2_get_byteu(&gb);
1077 for (n = nb_samples >> (1 - st); n > 0; n--) {
1078 int byte = bytestream2_get_byteu(&gb);
1085 int previous_left_sample, previous_right_sample;
1086 int current_left_sample, current_right_sample;
1087 int next_left_sample, next_right_sample;
1088 int coeff1l, coeff2l, coeff1r, coeff2r;
1089 int shift_left, shift_right;
1097 current_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1098 previous_left_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1099 current_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1100 previous_right_sample =
sign_extend(bytestream2_get_le16u(&gb), 16);
1102 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1103 int byte = bytestream2_get_byteu(&gb);
1109 byte = bytestream2_get_byteu(&gb);
1110 shift_left = 20 - (byte >> 4);
1111 shift_right = 20 - (byte & 0x0F);
1113 for (count2 = 0; count2 < 28; count2++) {
1114 byte = bytestream2_get_byteu(&gb);
1115 next_left_sample =
sign_extend(byte >> 4, 4) << shift_left;
1116 next_right_sample =
sign_extend(byte, 4) << shift_right;
1118 next_left_sample = (next_left_sample +
1119 (current_left_sample * coeff1l) +
1120 (previous_left_sample * coeff2l) + 0x80) >> 8;
1121 next_right_sample = (next_right_sample +
1122 (current_right_sample * coeff1r) +
1123 (previous_right_sample * coeff2r) + 0x80) >> 8;
1125 previous_left_sample = current_left_sample;
1126 current_left_sample = av_clip_int16(next_left_sample);
1127 previous_right_sample = current_right_sample;
1128 current_right_sample = av_clip_int16(next_right_sample);
1129 *samples++ = current_left_sample;
1130 *samples++ = current_right_sample;
1142 for(channel = 0; channel < avctx->
channels; channel++) {
1143 int byte = bytestream2_get_byteu(&gb);
1146 shift[channel] = 20 - (byte & 0x0F);
1148 for (count1 = 0; count1 < nb_samples / 2; count1++) {
1151 byte[0] = bytestream2_get_byteu(&gb);
1152 if (st) byte[1] = bytestream2_get_byteu(&gb);
1153 for(i = 4; i >= 0; i-=4) {
1154 for(channel = 0; channel < avctx->
channels; channel++) {
1158 c->
status[channel].
sample2 * coeff[channel][1] + 0x80) >> 8;
1176 int previous_sample, current_sample, next_sample;
1179 unsigned int channel;
1184 for (channel=0; channel<avctx->
channels; channel++)
1185 offsets[channel] = (big_endian ? bytestream2_get_be32(&gb) :
1186 bytestream2_get_le32(&gb)) +
1189 for (channel=0; channel<avctx->
channels; channel++) {
1191 samplesC = samples_p[channel];
1194 current_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1195 previous_sample =
sign_extend(bytestream2_get_le16(&gb), 16);
1201 for (count1 = 0; count1 < nb_samples / 28; count1++) {
1202 int byte = bytestream2_get_byte(&gb);
1204 current_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1205 previous_sample =
sign_extend(bytestream2_get_be16(&gb), 16);
1207 for (count2=0; count2<28; count2++)
1208 *samplesC++ =
sign_extend(bytestream2_get_be16(&gb), 16);
1212 shift = 20 - (byte & 0x0F);
1214 for (count2=0; count2<28; count2++) {
1218 byte = bytestream2_get_byte(&gb);
1222 next_sample += (current_sample * coeff1) +
1223 (previous_sample * coeff2);
1224 next_sample = av_clip_int16(next_sample >> 8);
1226 previous_sample = current_sample;
1227 current_sample = next_sample;
1228 *samplesC++ = current_sample;
1234 }
else if (count != count1) {
1236 count =
FFMAX(count, count1);
1250 for (channel=0; channel<avctx->
channels; channel++) {
1252 int16_t *
s = samples_p[channel];
1253 for (n = 0; n < 4; n++, s += 32) {
1259 val =
sign_extend(bytestream2_get_le16u(&gb), 16);
1260 shift[
n] = 20 - (val & 0x0F);
1264 for (m=2; m<32; m+=2) {
1265 s = &samples_p[channel][
m];
1266 for (n = 0; n < 4; n++, s += 32) {
1268 int byte = bytestream2_get_byteu(&gb);
1271 pred = s[-1] * coeff[0][
n] + s[-2] * coeff[1][
n];
1272 s[0] = av_clip_int16((level + pred + 0x80) >> 8);
1275 pred = s[0] * coeff[0][
n] + s[-1] * coeff[1][
n];
1276 s[1] = av_clip_int16((level + pred + 0x80) >> 8);
1291 for (n = nb_samples >> (1 - st); n > 0; n--) {
1292 int v = bytestream2_get_byteu(&gb);
1299 for (i = 0; i < avctx->
channels; i++) {
1310 for (n = nb_samples >> (1 - st); n > 0; n--) {
1311 int v = bytestream2_get_byteu(&gb);
1318 for (n = nb_samples >> (1 - st); n > 0; n--) {
1319 int v = bytestream2_get_byteu(&gb);
1329 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1331 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
1336 for (n = nb_samples >> (1 - st); n > 0; n--) {
1337 int byte = bytestream2_get_byteu(&gb);
1344 for (n = (nb_samples<<st) / 3; n > 0; n--) {
1345 int byte = bytestream2_get_byteu(&gb);
1349 (byte >> 2) & 0x07, 3, 0);
1354 for (n = nb_samples >> (2 - st); n > 0; n--) {
1355 int byte = bytestream2_get_byteu(&gb);
1359 (byte >> 4) & 0x03, 2, 2);
1361 (byte >> 2) & 0x03, 2, 2);
1372 for (n = nb_samples >> (1 - st); n > 0; n--) {
1373 int v = bytestream2_get_byteu(&gb);
1380 int samples_per_block;
1384 samples_per_block = avctx->
extradata[0] / 16;
1385 blocks = nb_samples / avctx->
extradata[0];
1387 samples_per_block = nb_samples / 16;
1391 for (m = 0; m < blocks; m++) {
1392 for (channel = 0; channel < avctx->
channels; channel++) {
1396 samples = samples_p[channel] + m * 16;
1398 for (i = 0; i < samples_per_block; i++) {
1399 int byte = bytestream2_get_byteu(&gb);
1400 int scale = 1 << (byte >> 4);
1401 int index = byte & 0xf;
1406 for (n = 0; n < 16; n++) {
1412 byte = bytestream2_get_byteu(&gb);
1416 sampledat = ((prev1 * factor1 + prev2 * factor2) +
1417 ((sampledat * scale) << 11)) >> 11;
1418 *samples = av_clip_int16(sampledat);
1437 #define THP_GET16(g) \
1439 avctx->codec->id == AV_CODEC_ID_ADPCM_THP_LE ? \
1440 bytestream2_get_le16u(&(g)) : \
1441 bytestream2_get_be16u(&(g)), 16)
1451 for (i = 0; i < avctx->
channels; i++)
1452 for (n = 0; n < 16; n++)
1455 for (i = 0; i < avctx->
channels; i++)
1456 for (n = 0; n < 16; n++)
1461 for (i = 0; i < avctx->
channels; i++) {
1471 for (ch = 0; ch < avctx->
channels; ch++) {
1472 samples = samples_p[ch];
1475 for (i = 0; i < (nb_samples + 13) / 14; i++) {
1476 int byte = bytestream2_get_byteu(&gb);
1477 int index = (byte >> 4) & 7;
1478 unsigned int exp = byte & 0x0F;
1479 int factor1 = table[ch][index * 2];
1480 int factor2 = table[ch][index * 2 + 1];
1483 for (n = 0; n < 14 && (i * 14 + n < nb_samples); n++) {
1489 byte = bytestream2_get_byteu(&gb);
1494 + c->
status[ch].
sample2 * factor2) >> 11) + (sampledat << exp);
1495 *samples = av_clip_int16(sampledat);
1504 for (channel = 0; channel < avctx->
channels; channel++) {
1505 samples = samples_p[channel];
1508 for (i = 0; i < nb_samples / 28; i++) {
1512 header = bytestream2_get_byteu(&gb);
1516 for (n = 0; n < 28; n++) {
1519 switch (header >> 4) {
1533 prev = av_clip_intp2((prev + 0x20) >> 6, 21);
1535 byte = bytestream2_get_byteu(&gb);
1541 sampledat = (((sampledat << 12) >> (header & 0xf)) << 6) + prev;
1542 *samples++ = av_clip_int16(sampledat >> 6);
1586 #define ADPCM_DECODER(id_, sample_fmts_, name_, long_name_) \
1587 AVCodec ff_ ## name_ ## _decoder = { \
1589 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
1590 .type = AVMEDIA_TYPE_AUDIO, \
1592 .priv_data_size = sizeof(ADPCMDecodeContext), \
1593 .init = adpcm_decode_init, \
1594 .decode = adpcm_decode_frame, \
1595 .flush = adpcm_flush, \
1596 .capabilities = AV_CODEC_CAP_DR1, \
1597 .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.
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 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[]
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.
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_)