27 #include "libavutil/attributes.h"
28 #include "libavutil/avassert.h"
29 #include "libavutil/channel_layout.h"
45 #define BACKSTEP_SIZE 512
47 #define LAST_BUF_SIZE 2 * BACKSTEP_SIZE + EXTRABYTES
99 0 + 128 + 128 + 128 + 130 + 128 + 154 + 166 +
100 142 + 204 + 190 + 170 + 542 + 460 + 662 + 414
103 0, 128, 128, 128, 130, 128, 154, 166,
104 142, 204, 190, 170, 542, 460, 662, 414
131 #define SCALE_GEN(v) \
132 { FIXR_OLD(1.0 * (v)), FIXR_OLD(0.7937005259 * (v)), FIXR_OLD(0.6299605249 * (v)) }
148 for (i = 0; i < 3; i++) {
158 if (s->sample_rate_index != 8)
163 if (s->sample_rate_index <= 2)
165 else if (s->sample_rate_index != 8)
179 l =
FFMIN(ra1 + ra2 + 2, 22);
190 if (s->sample_rate_index <= 2)
208 static inline int l1_unscale(
int n,
int mant,
int scale_factor)
219 return (
int)((val + (1LL << (shift - 1))) >> shift);
233 val = (val + (1 << (shift - 1))) >> shift;
249 m = (m + (1 << (e - 1))) >> e;
260 for (i = 0; i < 64; i++) {
269 for (i = 0; i < 15; i++) {
272 norm = ((INT64_C(1) << n) *
FRAC_ONE) / ((1 << n) - 1);
286 for (i = 1; i < 16; i++) {
289 uint8_t tmp_bits [512] = { 0 };
290 uint16_t tmp_codes[512] = { 0 };
295 for (x = 0; x < xsize; x++) {
296 for (y = 0; y < xsize; y++) {
297 tmp_bits [(x << 5) | y | ((x&&y)<<4)]= h->
bits [j ];
298 tmp_codes[(x << 5) | y | ((x&&y)<<4)]= h->
codes[j++];
306 tmp_bits, 1, 1, tmp_codes, 2, 2,
313 for (i = 0; i < 2; i++) {
316 init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16,
323 for (i = 0; i < 9; i++) {
325 for (j = 0; j < 22; j++) {
336 for (i = 0; i < 4; i++) {
339 int val1, val2, val3, steps;
352 for (i = 0; i < 7; i++) {
356 f = tan((
double)i * M_PI / 12.0);
357 v =
FIXR(f / (1.0 + f));
365 for (i = 7; i < 16; i++)
368 for (i = 0; i < 16; i++) {
372 for (j = 0; j < 2; j++) {
373 e = -(j + 1) * ((i + 1) >> 1);
374 f = pow(2.0, e / 4.0);
384 for (i = 0; i < 8; i++) {
387 cs = 1.0 / sqrt(1.0 + ci * ci);
405 static int initialized_tables = 0;
408 if (!initialized_tables) {
410 initialized_tables = 1;
431 #define C3 FIXHR(0.86602540378443864676/2)
432 #define C4 FIXHR(0.70710678118654752439/2) //0.5 / cos(pi*(9)/36)
433 #define C5 FIXHR(0.51763809020504152469/2) //0.5 / cos(pi*(5)/36)
434 #define C6 FIXHR(1.93185165257813657349/4) //0.5 / cos(pi*(15)/36)
440 INTFLOAT in0, in1, in2, in3, in4, in5, t1, t2;
443 in1 = in[1*3] + in[0*3];
444 in2 = in[2*3] + in[1*3];
445 in3 = in[3*3] + in[2*3];
446 in4 = in[4*3] + in[3*3];
447 in5 = in[5*3] + in[4*3];
482 int bound, i, v, n, ch, j, mant;
487 bound = (s->mode_ext + 1) * 4;
492 for (i = 0; i < bound; i++) {
493 for (ch = 0; ch < s->nb_channels; ch++) {
497 for (i = bound; i <
SBLIMIT; i++)
501 for (i = 0; i < bound; i++) {
502 for (ch = 0; ch < s->nb_channels; ch++) {
503 if (allocation[ch][i])
507 for (i = bound; i <
SBLIMIT; i++) {
508 if (allocation[0][i]) {
515 for (j = 0; j < 12; j++) {
516 for (i = 0; i < bound; i++) {
517 for (ch = 0; ch < s->nb_channels; ch++) {
518 n = allocation[ch][i];
521 v =
l1_unscale(n, mant, scale_factors[ch][i]);
528 for (i = bound; i <
SBLIMIT; i++) {
529 n = allocation[0][i];
549 int table, bit_alloc_bits, i, j, ch, bound, v;
553 int scale, qindex,
bits, steps, k, l, m,
b;
557 s->sample_rate, s->lsf);
562 bound = (s->mode_ext + 1) * 4;
566 av_dlog(s->
avctx,
"bound=%d sblimit=%d\n", bound, sblimit);
574 for (i = 0; i < bound; i++) {
575 bit_alloc_bits = alloc_table[j];
576 for (ch = 0; ch < s->nb_channels; ch++)
577 bit_alloc[ch][i] =
get_bits(&s->
gb, bit_alloc_bits);
578 j += 1 << bit_alloc_bits;
580 for (i = bound; i < sblimit; i++) {
581 bit_alloc_bits = alloc_table[j];
585 j += 1 << bit_alloc_bits;
589 for (i = 0; i < sblimit; i++) {
590 for (ch = 0; ch < s->nb_channels; ch++) {
591 if (bit_alloc[ch][i])
597 for (i = 0; i < sblimit; i++) {
598 for (ch = 0; ch < s->nb_channels; ch++) {
599 if (bit_alloc[ch][i]) {
600 sf = scale_factors[ch][i];
601 switch (scale_code[ch][i]) {
629 for (k = 0; k < 3; k++) {
630 for (l = 0; l < 12; l += 3) {
632 for (i = 0; i < bound; i++) {
633 bit_alloc_bits = alloc_table[j];
634 for (ch = 0; ch < s->nb_channels; ch++) {
635 b = bit_alloc[ch][i];
637 scale = scale_factors[ch][i][k];
638 qindex = alloc_table[j+
b];
654 for (m = 0; m < 3; m++) {
667 j += 1 << bit_alloc_bits;
670 for (i = bound; i < sblimit; i++) {
671 bit_alloc_bits = alloc_table[j];
674 int mant, scale0, scale1;
675 scale0 = scale_factors[0][i][k];
676 scale1 = scale_factors[1][i][k];
677 qindex = alloc_table[j+
b];
700 for (m = 0; m < 3; m++) {
717 j += 1 << bit_alloc_bits;
720 for (i = sblimit; i <
SBLIMIT; i++) {
721 for (ch = 0; ch < s->nb_channels; ch++) {
732 #define SPLIT(dst,sf,n) \
734 int m = (sf * 171) >> 9; \
737 } else if (n == 4) { \
740 } else if (n == 5) { \
741 int m = (sf * 205) >> 10; \
744 } else if (n == 6) { \
745 int m = (sf * 171) >> 10; \
755 SPLIT(slen[3], sf, n3)
756 SPLIT(slen[2], sf, n2)
757 SPLIT(slen[1], sf, n1)
765 int len, i, j, k, l, v0, shift, gain, gains[3];
775 v0 = gain - ((g->
scale_factors[i] + pretab[i]) << shift) + 400;
777 for (j = len; j > 0; j--)
789 for (l = 0; l < 3; l++) {
791 for (j = len; j > 0; j--)
826 #define READ_FLIP_SIGN(dst,src) \
827 v = AV_RN32A(src) ^ (get_bits1(&s->gb) << 31); \
830 #define READ_FLIP_SIGN(dst,src) \
831 v = -get_bits1(&s->gb); \
832 *(dst) = (*(src) ^ v) - v;
836 int16_t *exponents,
int end_pos2)
840 int last_pos, bits_left;
846 for (i = 0; i < 3; i++) {
847 int j, k, l, linbits;
883 exponent= exponents[s_index];
930 while (s_index <= 572) {
933 if (pos >= end_pos) {
934 if (pos > end_pos2 && last_pos) {
939 av_log(s->
avctx,
AV_LOG_INFO,
"overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos);
957 static const int idxtab[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 };
959 int pos = s_index + idxtab[code];
960 code ^= 8 >> idxtab[code];
996 if (s->sample_rate_index != 8)
1008 for (j = len; j > 0; j--) {
1009 *dst++ = ptr[0*
len];
1010 *dst++ = ptr[1*
len];
1011 *dst++ = ptr[2*
len];
1015 memcpy(ptr1, tmp, len * 3 *
sizeof(*ptr1));
1019 #define ISQRT2 FIXR(0.70710678118654752440)
1024 int sf_max, sf,
len, non_zero_found;
1025 INTFLOAT (*is_tab)[16], *tab0, *
tab1, tmp0, tmp1, v1, v2;
1026 int non_zero_found_short[3];
1041 non_zero_found_short[0] = 0;
1042 non_zero_found_short[1] = 0;
1043 non_zero_found_short[2] = 0;
1050 for (l = 2; l >= 0; l--) {
1053 if (!non_zero_found_short[l]) {
1055 for (j = 0; j <
len; j++) {
1057 non_zero_found_short[l] = 1;
1067 for (j = 0; j <
len; j++) {
1077 for (j = 0; j <
len; j++) {
1088 non_zero_found = non_zero_found_short[0] |
1089 non_zero_found_short[1] |
1090 non_zero_found_short[2];
1092 for (i = g1->
long_end - 1;i >= 0;i--) {
1097 if (!non_zero_found) {
1098 for (j = 0; j <
len; j++) {
1105 k = (i == 21) ? 20 : i;
1111 for (j = 0; j <
len; j++) {
1121 for (j = 0; j <
len; j++) {
1139 for (i = 0; i < 576; i++) {
1142 tab0[i] = tmp0 + tmp1;
1143 tab1[i] = tmp0 - tmp1;
1150 #define AA(j) do { \
1151 float tmp0 = ptr[-1-j]; \
1152 float tmp1 = ptr[ j]; \
1153 ptr[-1-j] = tmp0 * csa_table[j][0] - tmp1 * csa_table[j][1]; \
1154 ptr[ j] = tmp0 * csa_table[j][1] + tmp1 * csa_table[j][0]; \
1157 #define AA(j) do { \
1158 int tmp0 = ptr[-1-j]; \
1159 int tmp1 = ptr[ j]; \
1160 int tmp2 = MULH(tmp0 + tmp1, csa_table[j][0]); \
1161 ptr[-1-j] = 4 * (tmp2 - MULH(tmp1, csa_table[j][2])); \
1162 ptr[ j] = 4 * (tmp2 + MULH(tmp0, csa_table[j][3])); \
1182 for (i = n; i > 0; i--) {
1199 INTFLOAT *win, *out_ptr, *ptr, *buf, *ptr1;
1201 int i, j, mdct_long_end, sblimit;
1206 while (ptr >= ptr1) {
1210 if (p[0] | p[1] | p[2] | p[3] | p[4] | p[5])
1213 sblimit = ((ptr - g->
sb_hybrid) / 18) + 1;
1222 mdct_long_end = sblimit;
1229 buf = mdct_buf + 4*18*(mdct_long_end >> 2) + (mdct_long_end & 3);
1230 ptr = g->
sb_hybrid + 18 * mdct_long_end;
1232 for (j = mdct_long_end; j < sblimit; j++) {
1234 win =
RENAME(ff_mdct_win)[2 + (4 & -(j & 1))];
1235 out_ptr = sb_samples + j;
1237 for (i = 0; i < 6; i++) {
1238 *out_ptr = buf[4*i];
1242 for (i = 0; i < 6; i++) {
1243 *out_ptr =
MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*1)];
1244 buf[4*(i + 6*2)] =
MULH3(out2[i + 6], win[i + 6], 1);
1248 for (i = 0; i < 6; i++) {
1249 *out_ptr =
MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*2)];
1250 buf[4*(i + 6*0)] =
MULH3(out2[i + 6], win[i + 6], 1);
1254 for (i = 0; i < 6; i++) {
1255 buf[4*(i + 6*0)] =
MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*0)];
1256 buf[4*(i + 6*1)] =
MULH3(out2[i + 6], win[i + 6], 1);
1257 buf[4*(i + 6*2)] = 0;
1260 buf += (j&3) != 3 ? 1 : (4*18-3);
1263 for (j = sblimit; j <
SBLIMIT; j++) {
1265 out_ptr = sb_samples + j;
1266 for (i = 0; i < 18; i++) {
1267 *out_ptr = buf[4*i];
1271 buf += (j&3) != 3 ? 1 : (4*18-3);
1278 int nb_granules, main_data_begin;
1279 int gr, ch, blocksplit_flag, i, j, k, n, bits_pos;
1281 int16_t exponents[576];
1290 if (s->nb_channels == 2)
1295 for (ch = 0; ch < s->nb_channels; ch++) {
1301 for (gr = 0; gr < nb_granules; gr++) {
1302 for (ch = 0; ch < s->nb_channels; ch++) {
1323 if (blocksplit_flag) {
1330 for (i = 0; i < 2; i++)
1332 for (i = 0; i < 3; i++)
1336 int region_address1, region_address2;
1339 for (i = 0; i < 3; i++)
1345 region_address1, region_address2);
1374 #if !UNCHECKED_BITSTREAM_READER
1375 s->
gb.size_in_bits_plus8 += extrasize * 8;
1378 for (gr = 0; gr < nb_granules && (s->
last_buf_size >> 3) < main_data_begin; gr++) {
1379 for (ch = 0; ch < s->nb_channels; ch++) {
1398 for (; gr < nb_granules; gr++) {
1399 for (ch = 0; ch < s->nb_channels; ch++) {
1405 int slen, slen1, slen2;
1410 av_dlog(s->
avctx,
"slen1=%d slen2=%d\n", slen1, slen2);
1415 for (i = 0; i < n; i++)
1418 for (i = 0; i < n; i++)
1422 for (i = 0; i < 18; i++)
1424 for (i = 0; i < 3; i++)
1427 for (i = 0; i < 21; i++)
1433 for (k = 0; k < 4; k++) {
1435 if ((g->
scfsi & (0x8 >> k)) == 0) {
1436 slen = (k < 2) ? slen1 : slen2;
1438 for (i = 0; i < n; i++)
1441 for (i = 0; i < n; i++)
1446 for (i = 0; i < n; i++) {
1455 int tindex, tindex2, slen[4], sl, sf;
1470 }
else if (sf < 244) {
1482 }
else if (sf < 500) {
1493 for (k = 0; k < 4; k++) {
1497 for (i = 0; i < n; i++)
1500 for (i = 0; i < n; i++)
1518 for (ch = 0; ch < s->nb_channels; ch++) {
1528 return nb_granules * 18;
1532 const uint8_t *buf,
int buf_size)
1534 int i, nb_frames, ch, ret;
1540 if (s->error_protection)
1582 assert(i <= buf_size - HEADER_SIZE && i >= 0);
1599 for (ch = 0; ch < s->nb_channels; ch++) {
1602 samples_ptr = samples[ch];
1605 samples_ptr = samples[0] + ch;
1606 sample_stride = s->nb_channels;
1608 for (i = 0; i < nb_frames; i++) {
1611 RENAME(ff_mpa_synth_window),
1614 samples_ptr += 32 * sample_stride;
1618 return nb_frames * 32 *
sizeof(
OUT_INT) * s->nb_channels;
1625 int buf_size = avpkt->
size;
1650 if (s->frame_size <= 0 || s->frame_size > buf_size) {
1653 }
else if (s->frame_size < buf_size) {
1654 buf_size= s->frame_size;
1691 #if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER
1693 int *got_frame_ptr,
AVPacket *avpkt)
1696 int buf_size = avpkt->
size;
1714 header =
AV_RB32(buf) | 0xffe00000;
1729 s->frame_size =
len;
1745 #if CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER
1750 typedef struct MP3On4DecodeContext {
1755 } MP3On4DecodeContext;
1762 static const uint8_t mp3Frames[8] = { 0, 1, 1, 2, 3, 3, 4, 5 };
1765 static const uint8_t chan_offset[8][5] = {
1777 static const int16_t chan_layout[8] = {
1790 MP3On4DecodeContext *s = avctx->
priv_data;
1793 for (i = 0; i < s->frames; i++)
1802 MP3On4DecodeContext *s = avctx->
priv_data;
1823 s->syncword = 0xffe00000;
1825 s->syncword = 0xfff00000;
1834 if (!s->mp3decctx[0])
1841 s->mp3decctx[0]->adu_mode = 1;
1846 for (i = 1; i < s->frames; i++) {
1848 if (!s->mp3decctx[i])
1850 s->mp3decctx[i]->adu_mode = 1;
1851 s->mp3decctx[i]->avctx = avctx;
1852 s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;
1857 decode_close_mp3on4(avctx);
1865 MP3On4DecodeContext *s = avctx->
priv_data;
1867 for (i = 0; i < s->frames; i++)
1872 static int decode_frame_mp3on4(
AVCodecContext *avctx,
void *data,
1873 int *got_frame_ptr,
AVPacket *avpkt)
1877 int buf_size = avpkt->
size;
1878 MP3On4DecodeContext *s = avctx->
priv_data;
1880 int fsize, len = buf_size, out_size = 0;
1901 for (fr = 0; fr < s->frames; fr++) {
1904 m = s->mp3decctx[fr];
1911 header = (
AV_RB32(buf) & 0x000fffff) | s->syncword;
1918 if (ch + m->nb_channels > avctx->
channels ||
1919 s->coff[fr] + m->nb_channels > avctx->
channels) {
1924 ch += m->nb_channels;
1926 outptr[0] = out_samples[s->coff[fr]];
1927 if (m->nb_channels > 1)
1928 outptr[1] = out_samples[s->coff[fr] + 1];
1941 avctx->
sample_rate = s->mp3decctx[0]->sample_rate;
static av_cold void decode_init_static(void)
#define MPA_MAX_CODED_FRAME_SIZE
static int32_t scale_factor_mult[15][3]
static int16_t division_tab9[1<< 11]
#define AV_CH_LAYOUT_7POINT1
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static uint32_t table_4_3_value[TABLE_4_3_SIZE]
static const uint8_t lsf_nsf_table[6][3][4]
This structure describes decoded (raw) audio or video data.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CH_LAYOUT_SURROUND
static void skip_bits_long(GetBitContext *s, int n)
static void exponents_from_scale_factors(MPADecodeContext *s, GranuleDef *g, int16_t *exponents)
static int8_t table_4_3_exp[TABLE_4_3_SIZE]
uint8_t ** extended_data
pointers to the data planes/channels.
#define DECLARE_ALIGNED(n, t, v)
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_dlog(ac->avr,"%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
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
const int ff_mpa_quant_bits[17]
static const uint8_t mpa_pretab[2][22]
#define AV_CH_LAYOUT_4POINT0
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
#define AV_CH_LAYOUT_STEREO
static av_always_inline void lsf_sf_expand(int *slen, int sf, int n1, int n2, int n3)
uint8_t scale_factors[40]
static void imdct12(INTFLOAT *out, INTFLOAT *in)
#define AV_CH_LAYOUT_5POINT0
mpeg audio layer common tables.
static const uint8_t slen_table[2][16]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
enum AVSampleFormat sample_fmt
audio sample format
av_cold void RENAME() ff_mpa_synth_init(MPA_INT *window)
const int ff_mpa_quant_steps[17]
static int l2_unscale_group(int steps, int mant, int scale_factor)
static void mpegaudio_tableinit(void)
const unsigned char *const ff_mpa_alloc_tables[5]
static const uint8_t mpa_huff_data[32][2]
#define SPLIT(dst, sf, n)
static INTFLOAT csa_table[8][4]
static int l3_unscale(int value, int exponent)
static const uint8_t mpa_quad_codes[2][16]
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2)
static int bit_alloc(AC3EncodeContext *s, int snr_offset)
Run the bit allocation with a given SNR offset.
#define AV_CH_LAYOUT_5POINT1
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define MODE_EXT_MS_STEREO
enum AVSampleFormat request_sample_fmt
Used to request a sample format from the decoder.
static void init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2)
static uint16_t band_index_long[9][23]
static av_cold int decode_init(AVCodecContext *avctx)
static VLC_TYPE huff_quad_vlc_tables[128+16][2]
Libavcodec external API header.
static VLC_TYPE huff_vlc_tables[0+128+128+128+130+128+154+166+142+204+190+170+542+460+662+414][2]
uint64_t channel_layout
Audio channel layout.
static const int32_t scale_factor_mult2[3][3]
#define READ_FLIP_SIGN(dst, src)
int bit_rate
the average bitrate
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static void compute_band_indexes(MPADecodeContext *s, GranuleDef *g)
uint32_t free_format_next_header
#define FF_ARRAY_ELEMS(a)
static int mp_decode_layer2(MPADecodeContext *s)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
#define INIT_VLC_USE_NEW_STATIC
if(ac->has_optimized_func)
static const uint8_t mpa_quad_bits[2][16]
int frame_size
Number of samples per channel in an audio frame.
#define AV_LOG_INFO
Standard information.
int sb_hybrid[SBLIMIT *18]
static const int huff_vlc_tables_sizes[16]
int sample_rate
samples per second
MPA_INT synth_buf[MPA_MAX_CHANNELS][512 *2]
static int mp_decode_layer3(MPADecodeContext *s)
static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples, const uint8_t *buf, int buf_size)
main external API structure.
static void compute_antialias(MPADecodeContext *s, GranuleDef *g)
static INTFLOAT is_table[2][16]
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
static void mp_flush(MPADecodeContext *ctx)
static void reorder_block(MPADecodeContext *s, GranuleDef *g)
static unsigned int get_bits1(GetBitContext *s)
uint8_t count1table_select
static void skip_bits(GetBitContext *s, int n)
#define MODE_EXT_I_STEREO
static int get_bitsz(GetBitContext *s, int n)
static const int huff_quad_vlc_tables_sizes[2]
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static uint16_t scale_factor_modshift[64]
static INTFLOAT is_table_lsf[2][2][16]
static int16_t division_tab5[1<< 8]
static void init_short_region(MPADecodeContext *s, GranuleDef *g)
static const uint8_t band_size_long[9][22]
av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
Initialize a float DSP context.
static void compute_stereo(MPADecodeContext *s, GranuleDef *g0, GranuleDef *g1)
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_dlog(ac->avr,"%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-> out
static int16_t *const division_tabs[4]
static void compute_imdct(MPADecodeContext *s, GranuleDef *g, INTFLOAT *sb_samples, INTFLOAT *mdct_buf)
common internal api header.
void RENAME() ff_mpa_synth_filter(MPADSPContext *s, MPA_INT *synth_buf_ptr, int *synth_buf_offset, MPA_INT *window, int *dither_state, OUT_INT *samples, int incr, MPA_INT *sb_samples)
mpeg audio declarations for both encoder and decoder.
const int ff_mpa_sblimit_table[5]
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int bit_size, int sync_extension)
Parse MPEG-4 systems extradata to retrieve audio configuration.
static int mp_decode_layer1(MPADecodeContext *s)
INTFLOAT mdct_buf[MPA_MAX_CHANNELS][SBLIMIT *18]
int ff_mpa_l2_select_table(int bitrate, int nb_channels, int freq, int lsf)
int channels
number of audio channels
const uint8_t ff_mpeg4audio_channels[8]
MPA_DECODE_HEADER uint8_t last_buf[LAST_BUF_SIZE]
VLC_TYPE(* table)[2]
code, bits
int synth_buf_offset[MPA_MAX_CHANNELS]
static const uint8_t * align_get_bits(GetBitContext *s)
static VLC huff_quad_vlc[2]
void(* butterflies_float)(float *restrict v1, float *restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int huffman_decode(MPADecodeContext *s, GranuleDef *g, int16_t *exponents, int end_pos2)
mpeg audio layer decoder tables.
static int l1_unscale(int n, int mant, int scale_factor)
int sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]
static const HuffTable mpa_huff_tables[16]
static const float ci_table[8]
#define AV_CH_LAYOUT_MONO
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static void region_offset2size(GranuleDef *g)
Convert region offsets to region sizes and truncate size to big_values.
This structure stores compressed data.
av_cold void ff_mpadsp_init(MPADSPContext *s)
int nb_samples
number of audio samples (per channel) described by this frame
static void flush(AVCodecContext *avctx)
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int alloc_table(VLC *vlc, int size, int use_static)
static const uint8_t band_size_short[9][13]
int adu_mode
0 for standard mp3, 1 for adu formatted mp3
static int16_t division_tab3[1<< 6]
GranuleDef granules[2][2]