54#define BACKSTEP_SIZE 512
56#define LAST_BUF_SIZE 2 * BACKSTEP_SIZE + EXTRABYTES
114#define SCALE_GEN(v) \
115{ FIXR_OLD(1.0 * (v)), FIXR_OLD(0.7937005259 * (v)), FIXR_OLD(0.6299605249 * (v)) }
130 g->region_size[2] = 576 / 2;
131 for (
i = 0;
i < 3;
i++) {
132 k =
FFMIN(
g->region_size[
i],
g->big_values);
133 g->region_size[
i] = k - j;
140 if (
g->block_type == 2) {
141 if (
s->sample_rate_index != 8)
142 g->region_size[0] = (36 / 2);
144 g->region_size[0] = (72 / 2);
146 if (
s->sample_rate_index <= 2)
147 g->region_size[0] = (36 / 2);
148 else if (
s->sample_rate_index != 8)
149 g->region_size[0] = (54 / 2);
151 g->region_size[0] = (108 / 2);
153 g->region_size[1] = (576 / 2);
162 l =
FFMIN(ra1 + ra2 + 2, 22);
168 if (
g->block_type == 2) {
169 if (
g->switch_point) {
170 if(
s->sample_rate_index == 8)
175 if (
s->sample_rate_index <= 2)
193static inline int l1_unscale(
int n,
int mant,
int scale_factor)
237 m = (m + ((1U << e) >> 1)) >> e;
247 for (
i = 0;
i < 15;
i++) {
250 norm = ((INT64_C(1) << n) *
FRAC_ONE) / ((1 << n) - 1);
254 ff_dlog(
NULL,
"%d: norm=%x s=%"PRIx32
" %"PRIx32
" %"PRIx32
"\n",
i,
265 for (
i = 0;
i < 16;
i++) {
269 for (j = 0; j < 2; j++) {
270 e = -(j + 1) * ((
i + 1) >> 1);
323#define C3 FIXHR(0.86602540378443864676/2)
324#define C4 FIXHR(0.70710678118654752439/2)
325#define C5 FIXHR(0.51763809020504152469/2)
326#define C6 FIXHR(1.93185165257813657349/4)
332 SUINTFLOAT in0, in1, in2, in3, in4, in5, t1, t2;
335 in1 = in[1*3] + in[0*3];
336 in2 = in[2*3] + in[1*3];
337 in3 = in[3*3] + in[2*3];
338 in4 = in[4*3] + in[3*3];
339 in5 = in[5*3] + in[4*3];
375 int sec_byte_len = sec_len >> 3;
376 int sec_rem_bits = sec_len & 7;
379 uint32_t crc_val =
av_crc(crc_tab, UINT16_MAX, &buf[2], 2);
380 crc_val =
av_crc(crc_tab, crc_val, &buf[6], sec_byte_len);
383 ((buf[6 + sec_byte_len] & (0xFF00U >> sec_rem_bits)) << 24) +
384 ((
s->crc << 16) >> sec_rem_bits));
386 crc_val =
av_crc(crc_tab, crc_val, tmp_buf, 3);
400 int bound,
i, v, n, ch, j, mant;
405 ret =
handle_crc(
s, (
s->nb_channels == 1) ? 8*16 : 8*32);
410 bound = (
s->mode_ext + 1) * 4;
416 for (ch = 0; ch <
s->nb_channels; ch++) {
425 for (ch = 0; ch <
s->nb_channels; ch++) {
426 if (allocation[ch][
i])
431 if (allocation[0][
i]) {
438 for (j = 0; j < 12; j++) {
440 for (ch = 0; ch <
s->nb_channels; ch++) {
441 n = allocation[ch][
i];
448 s->sb_samples[ch][j][
i] = v;
452 n = allocation[0][
i];
456 s->sb_samples[0][j][
i] = v;
458 s->sb_samples[1][j][
i] = v;
460 s->sb_samples[0][j][
i] = 0;
461 s->sb_samples[1][j][
i] = 0;
481 s->sample_rate,
s->lsf);
486 bound = (
s->mode_ext + 1) * 4;
500 for (ch = 0; ch <
s->nb_channels; ch++)
502 j += 1 << bit_alloc_bits;
509 j += 1 << bit_alloc_bits;
513 for (
i = 0;
i < sblimit;
i++) {
514 for (ch = 0; ch <
s->nb_channels; ch++) {
525 for (
i = 0;
i < sblimit;
i++) {
526 for (ch = 0; ch <
s->nb_channels; ch++) {
529 switch (scale_code[ch][
i]) {
557 for (k = 0; k < 3; k++) {
558 for (l = 0; l < 12; l += 3) {
562 for (ch = 0; ch <
s->nb_channels; ch++) {
575 s->sb_samples[ch][k * 12 + l + 0][
i] =
577 s->sb_samples[ch][k * 12 + l + 1][
i] =
579 s->sb_samples[ch][k * 12 + l + 2][
i] =
582 for (m = 0; m < 3; m++) {
585 s->sb_samples[ch][k * 12 + l + m][
i] = v;
589 s->sb_samples[ch][k * 12 + l + 0][
i] = 0;
590 s->sb_samples[ch][k * 12 + l + 1][
i] = 0;
591 s->sb_samples[ch][k * 12 + l + 2][
i] = 0;
595 j += 1 << bit_alloc_bits;
602 int mant, scale0, scale1;
613 s->sb_samples[0][k * 12 + l + 0][
i] =
615 s->sb_samples[1][k * 12 + l + 0][
i] =
619 s->sb_samples[0][k * 12 + l + 1][
i] =
621 s->sb_samples[1][k * 12 + l + 1][
i] =
623 s->sb_samples[0][k * 12 + l + 2][
i] =
625 s->sb_samples[1][k * 12 + l + 2][
i] =
628 for (m = 0; m < 3; m++) {
630 s->sb_samples[0][k * 12 + l + m][
i] =
632 s->sb_samples[1][k * 12 + l + m][
i] =
637 s->sb_samples[0][k * 12 + l + 0][
i] = 0;
638 s->sb_samples[0][k * 12 + l + 1][
i] = 0;
639 s->sb_samples[0][k * 12 + l + 2][
i] = 0;
640 s->sb_samples[1][k * 12 + l + 0][
i] = 0;
641 s->sb_samples[1][k * 12 + l + 1][
i] = 0;
642 s->sb_samples[1][k * 12 + l + 2][
i] = 0;
645 j += 1 << bit_alloc_bits;
649 for (ch = 0; ch <
s->nb_channels; ch++) {
650 s->sb_samples[ch][k * 12 + l + 0][
i] = 0;
651 s->sb_samples[ch][k * 12 + l + 1][
i] = 0;
652 s->sb_samples[ch][k * 12 + l + 2][
i] = 0;
660#define SPLIT(dst,sf,n) \
662 int m = (sf * 171) >> 9; \
665 } else if (n == 4) { \
668 } else if (n == 5) { \
669 int m = (sf * 205) >> 10; \
672 } else if (n == 6) { \
673 int m = (sf * 171) >> 10; \
683 SPLIT(slen[3], sf, n3)
684 SPLIT(slen[2], sf, n2)
685 SPLIT(slen[1], sf, n1)
692 const uint8_t *bstab, *pretab;
693 int len,
i, j, k, l, v0,
shift, gain, gains[3];
697 gain =
g->global_gain - 210;
698 shift =
g->scalefac_scale + 1;
702 for (
i = 0;
i <
g->long_end;
i++) {
703 v0 = gain - ((
g->scale_factors[
i] + pretab[
i]) <<
shift) + 400;
705 for (j =
len; j > 0; j--)
709 if (
g->short_start < 13) {
711 gains[0] = gain - (
g->subblock_gain[0] << 3);
712 gains[1] = gain - (
g->subblock_gain[1] << 3);
713 gains[2] = gain - (
g->subblock_gain[2] << 3);
715 for (
i =
g->short_start;
i < 13;
i++) {
717 for (l = 0; l < 3; l++) {
718 v0 = gains[l] - (
g->scale_factors[k++] <<
shift) + 400;
719 for (j =
len; j > 0; j--)
729 if (
s->in_gb.buffer && *
pos >=
s->gb.size_in_bits -
s->extrasize * 8) {
731 s->in_gb.buffer =
NULL;
748#define READ_FLIP_SIGN(dst,src) \
749 v = AV_RN32A(src) ^ (get_bits1(&s->gb) << 31); \
752#define READ_FLIP_SIGN(dst,src) \
753 v = -get_bits1(&s->gb); \
754 *(dst) = (*(src) ^ v) - v;
758 int16_t *exponents,
int end_pos2)
764 int end_pos =
FFMIN(end_pos2,
s->gb.size_in_bits -
s->extrasize * 8);
768 for (
i = 0;
i < 3;
i++) {
770 int j, k, l, linbits;
771 j =
g->region_size[
i];
775 k =
g->table_select[
i];
780 memset(&
g->sb_hybrid[s_index], 0,
sizeof(*
g->sb_hybrid) * 2 * j);
800 g->sb_hybrid[s_index ] =
801 g->sb_hybrid[s_index + 1] = 0;
806 exponent= exponents[s_index];
808 ff_dlog(
s->avctx,
"region=%d n=%d y=%d exp=%d\n",
809 i,
g->region_size[
i] - j, y, exponent);
820 g->sb_hybrid[s_index] = v;
829 g->sb_hybrid[s_index + 1] = v;
842 g->sb_hybrid[s_index+!!y] = v;
844 g->sb_hybrid[s_index + !y] = 0;
853 while (s_index <= 572) {
856 if (
pos >= end_pos) {
857 if (
pos > end_pos2 && last_pos) {
874 ff_dlog(
s->avctx,
"t=%d code=%d\n",
g->count1table_select,
code);
875 g->sb_hybrid[s_index + 0] =
876 g->sb_hybrid[s_index + 1] =
877 g->sb_hybrid[s_index + 2] =
878 g->sb_hybrid[s_index + 3] = 0;
880 static const int idxtab[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 };
882 int pos = s_index + idxtab[
code];
897 memset(&
g->sb_hybrid[s_index], 0,
sizeof(*
g->sb_hybrid) * (576 - s_index));
915 if (
g->block_type != 2)
918 if (
g->switch_point) {
919 if (
s->sample_rate_index != 8)
920 ptr =
g->sb_hybrid + 36;
922 ptr =
g->sb_hybrid + 72;
927 for (
i =
g->short_start;
i < 13;
i++) {
931 for (j =
len; j > 0; j--) {
938 memcpy(ptr1,
tmp,
len * 3 *
sizeof(*ptr1));
942#define ISQRT2 FIXR(0.70710678118654752440)
947 int sf_max, sf,
len, non_zero_found;
951 int non_zero_found_short[3];
966 non_zero_found_short[0] = 0;
967 non_zero_found_short[1] = 0;
968 non_zero_found_short[2] = 0;
975 for (l = 2; l >= 0; l--) {
978 if (!non_zero_found_short[l]) {
980 for (j = 0; j <
len; j++) {
982 non_zero_found_short[l] = 1;
992 for (j = 0; j <
len; j++) {
1002 for (j = 0; j <
len; j++) {
1013 non_zero_found = non_zero_found_short[0] |
1014 non_zero_found_short[1] |
1015 non_zero_found_short[2];
1022 if (!non_zero_found) {
1023 for (j = 0; j <
len; j++) {
1030 k = (
i == 21) ? 20 :
i;
1036 for (j = 0; j <
len; j++) {
1046 for (j = 0; j <
len; j++) {
1064 for (
i = 0;
i < 576;
i++) {
1067 tab0[
i] = tmp0 + tmp1;
1068 tab1[
i] = tmp0 - tmp1;
1084#ifndef compute_antialias
1087 float tmp0 = ptr[-1-j]; \
1088 float tmp1 = ptr[ j]; \
1089 ptr[-1-j] = tmp0 * csa_table[j][0] - tmp1 * csa_table[j][1]; \
1090 ptr[ j] = tmp0 * csa_table[j][1] + tmp1 * csa_table[j][0]; \
1094 SUINT tmp0 = ptr[-1-j]; \
1095 SUINT tmp1 = ptr[ j]; \
1096 SUINT tmp2 = MULH(tmp0 + tmp1, csa_table[j][0]); \
1097 ptr[-1-j] = 4 * (tmp2 - MULH(tmp1, csa_table[j][2])); \
1098 ptr[ j] = 4 * (tmp2 + MULH(tmp0, csa_table[j][3])); \
1108 if (
g->block_type == 2) {
1109 if (!
g->switch_point)
1117 ptr =
g->sb_hybrid + 18;
1118 for (
i = n;
i > 0;
i--) {
1138 int i, j, mdct_long_end, sblimit;
1141 ptr =
g->sb_hybrid + 576;
1142 ptr1 =
g->sb_hybrid + 2 * 18;
1143 while (ptr >= ptr1) {
1147 if (p[0] | p[1] | p[2] | p[3] | p[4] | p[5])
1150 sblimit = ((ptr -
g->sb_hybrid) / 18) + 1;
1152 if (
g->block_type == 2) {
1154 if (
g->switch_point)
1159 mdct_long_end = sblimit;
1162 s->mpadsp.RENAME(imdct36_blocks)(sb_samples, mdct_buf,
g->sb_hybrid,
1163 mdct_long_end,
g->switch_point,
1166 buf = mdct_buf + 4*18*(mdct_long_end >> 2) + (mdct_long_end & 3);
1167 ptr =
g->sb_hybrid + 18 * mdct_long_end;
1169 for (j = mdct_long_end; j < sblimit; j++) {
1171 win =
RENAME(ff_mdct_win)[2 + (4 & -(j & 1))];
1172 out_ptr = sb_samples + j;
1174 for (
i = 0;
i < 6;
i++) {
1175 *out_ptr = buf[4*
i];
1179 for (
i = 0;
i < 6;
i++) {
1180 *out_ptr =
MULH3(out2[
i ],
win[
i ], 1) + buf[4*(
i + 6*1)];
1181 buf[4*(
i + 6*2)] =
MULH3(out2[
i + 6],
win[
i + 6], 1);
1185 for (
i = 0;
i < 6;
i++) {
1186 *out_ptr =
MULH3(out2[
i ],
win[
i ], 1) + buf[4*(
i + 6*2)];
1187 buf[4*(
i + 6*0)] =
MULH3(out2[
i + 6],
win[
i + 6], 1);
1191 for (
i = 0;
i < 6;
i++) {
1192 buf[4*(
i + 6*0)] =
MULH3(out2[
i ],
win[
i ], 1) + buf[4*(
i + 6*0)];
1193 buf[4*(
i + 6*1)] =
MULH3(out2[
i + 6],
win[
i + 6], 1);
1194 buf[4*(
i + 6*2)] = 0;
1197 buf += (j&3) != 3 ? 1 : (4*18-3);
1200 for (j = sblimit; j <
SBLIMIT; j++) {
1202 out_ptr = sb_samples + j;
1203 for (
i = 0;
i < 18;
i++) {
1204 *out_ptr = buf[4*
i];
1208 buf += (j&3) != 3 ? 1 : (4*18-3);
1215 int nb_granules, main_data_begin;
1216 int gr, ch, blocksplit_flag,
i, j, k, n, bits_pos;
1218 int16_t exponents[576];
1223 ret =
handle_crc(
s, ((
s->nb_channels == 1) ? 8*9 : 8*17));
1228 ret =
handle_crc(
s, ((
s->nb_channels == 1) ? 8*17 : 8*32));
1230 if (
s->nb_channels == 2)
1235 for (ch = 0; ch <
s->nb_channels; ch++) {
1236 s->granules[ch][0].scfsi = 0;
1237 s->granules[ch][1].scfsi =
get_bits(&
s->gb, 4);
1243 for (gr = 0; gr < nb_granules; gr++) {
1244 for (ch = 0; ch <
s->nb_channels; ch++) {
1245 ff_dlog(
s->avctx,
"gr=%d ch=%d: side_info\n", gr, ch);
1246 g = &
s->granules[ch][gr];
1249 if (
g->big_values > 288) {
1259 g->global_gain -= 2;
1265 if (blocksplit_flag) {
1267 if (
g->block_type == 0) {
1272 for (
i = 0;
i < 2;
i++)
1274 for (
i = 0;
i < 3;
i++)
1278 int region_address1, region_address2;
1280 g->switch_point = 0;
1281 for (
i = 0;
i < 3;
i++)
1286 ff_dlog(
s->avctx,
"region1=%d region2=%d\n",
1287 region_address1, region_address2);
1298 ff_dlog(
s->avctx,
"block_type=%d switch_point=%d\n",
1299 g->block_type,
g->switch_point);
1310 ff_dlog(
s->avctx,
"seekback:%d, lastbuf:%d\n",
1311 main_data_begin,
s->last_buf_size);
1313 memcpy(
s->last_buf +
s->last_buf_size, ptr,
s->extrasize);
1316 s->last_buf_size <<= 3;
1317 for (gr = 0; gr < nb_granules && (
s->last_buf_size >> 3) < main_data_begin; gr++) {
1318 for (ch = 0; ch <
s->nb_channels; ch++) {
1319 g = &
s->granules[ch][gr];
1320 s->last_buf_size +=
g->part2_3_length;
1321 memset(
g->sb_hybrid, 0,
sizeof(
g->sb_hybrid));
1325 skip =
s->last_buf_size - 8 * main_data_begin;
1326 if (
skip >=
s->gb.size_in_bits -
s->extrasize * 8 &&
s->in_gb.buffer) {
1329 s->in_gb.buffer =
NULL;
1339 for (; gr < nb_granules; gr++) {
1340 for (ch = 0; ch <
s->nb_channels; ch++) {
1341 g = &
s->granules[ch][gr];
1346 int slen, slen1, slen2;
1351 ff_dlog(
s->avctx,
"slen1=%d slen2=%d\n", slen1, slen2);
1352 if (
g->block_type == 2) {
1353 n =
g->switch_point ? 17 : 18;
1356 for (
i = 0;
i < n;
i++)
1357 g->scale_factors[j++] =
get_bits(&
s->gb, slen1);
1359 for (
i = 0;
i < n;
i++)
1360 g->scale_factors[j++] = 0;
1363 for (
i = 0;
i < 18;
i++)
1364 g->scale_factors[j++] =
get_bits(&
s->gb, slen2);
1365 for (
i = 0;
i < 3;
i++)
1366 g->scale_factors[j++] = 0;
1368 for (
i = 0;
i < 21;
i++)
1369 g->scale_factors[j++] = 0;
1372 sc =
s->granules[ch][0].scale_factors;
1374 for (k = 0; k < 4; k++) {
1376 if ((
g->scfsi & (0x8 >> k)) == 0) {
1377 slen = (k < 2) ? slen1 : slen2;
1379 for (
i = 0;
i < n;
i++)
1380 g->scale_factors[j++] =
get_bits(&
s->gb, slen);
1382 for (
i = 0;
i < n;
i++)
1383 g->scale_factors[j++] = 0;
1387 for (
i = 0;
i < n;
i++) {
1388 g->scale_factors[j] = sc[j];
1393 g->scale_factors[j++] = 0;
1396 int tindex, tindex2, slen[4], sl, sf;
1399 if (
g->block_type == 2)
1400 tindex =
g->switch_point ? 2 : 1;
1404 sf =
g->scalefac_compress;
1411 }
else if (sf < 244) {
1423 }
else if (sf < 500) {
1434 for (k = 0; k < 4; k++) {
1438 for (
i = 0;
i < n;
i++)
1439 g->scale_factors[j++] =
get_bits(&
s->gb, sl);
1441 for (
i = 0;
i < n;
i++)
1442 g->scale_factors[j++] = 0;
1447 g->scale_factors[j] = 0;
1459 for (ch = 0; ch <
s->nb_channels; ch++) {
1460 g = &
s->granules[ch][gr];
1469 return nb_granules * 18;
1473 const uint8_t *buf,
int buf_size)
1475 int i, nb_frames, ch, ret;
1479 if (
s->error_protection)
1484 s->avctx->frame_size = 384;
1488 s->avctx->frame_size = 1152;
1492 s->avctx->frame_size =
s->lsf ? 576 : 1152;
1498 if (
s->in_gb.buffer) {
1507 s->in_gb.buffer =
NULL;
1520 memcpy(
s->last_buf +
s->last_buf_size,
s->gb.buffer + buf_size -
HEADER_SIZE -
i,
i);
1521 s->last_buf_size +=
i;
1530 s->frame->nb_samples =
s->avctx->frame_size;
1533 samples = (
OUT_INT **)
s->frame->extended_data;
1537 for (ch = 0; ch <
s->nb_channels; ch++) {
1540 samples_ptr = samples[ch];
1543 samples_ptr = samples[0] + ch;
1544 sample_stride =
s->nb_channels;
1546 for (
i = 0;
i < nb_frames;
i++) {
1548 &(
s->synth_buf_offset[ch]),
1549 RENAME(ff_mpa_synth_window),
1550 &
s->dither_state, samples_ptr,
1551 sample_stride,
s->sb_samples[ch][
i]);
1552 samples_ptr += 32 * sample_stride;
1556 return nb_frames * 32 *
sizeof(
OUT_INT) *
s->nb_channels;
1560 int *got_frame_ptr,
AVPacket *avpkt)
1562 const uint8_t *buf = avpkt->
data;
1563 int buf_size = avpkt->
size;
1569 while(buf_size && !*buf){
1581 return buf_size + skipped;
1587 }
else if (ret == 1) {
1599 if (
s->frame_size <= 0) {
1602 }
else if (
s->frame_size < buf_size) {
1604 buf_size=
s->frame_size;
1628 return buf_size + skipped;
1633 memset(
ctx->synth_buf, 0,
sizeof(
ctx->synth_buf));
1634 memset(
ctx->mdct_buf, 0,
sizeof(
ctx->mdct_buf));
1635 ctx->last_buf_size = 0;
1636 ctx->dither_state = 0;
1644#if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER
1646 int *got_frame_ptr,
AVPacket *avpkt)
1648 const uint8_t *buf = avpkt->
data;
1649 int buf_size = avpkt->
size;
1682 s->frame_size =
len;
1698#if CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER
1703typedef struct MP3On4DecodeContext {
1706 const uint8_t *coff;
1707 MPADecodeContext *mp3decctx[5];
1708} MP3On4DecodeContext;
1715static const uint8_t mp3Frames[8] = { 0, 1, 1, 2, 3, 3, 4, 5 };
1718static const uint8_t chan_offset[8][5] = {
1730static const int16_t chan_layout[8] = {
1764 if (!
cfg.chan_config ||
cfg.chan_config > 7) {
1768 s->frames = mp3Frames[
cfg.chan_config];
1769 s->coff = chan_offset[
cfg.chan_config];
1773 if (
cfg.sample_rate < 16000)
1774 s->syncword = 0xffe00000;
1776 s->syncword = 0xfff00000;
1782 s->mp3decctx[0] =
av_calloc(
s->frames,
sizeof(*
s->mp3decctx[0]));
1783 if (!
s->mp3decctx[0])
1788 s->mp3decctx[0]->adu_mode = 1;
1793 for (
i = 1;
i <
s->frames;
i++) {
1794 s->mp3decctx[
i] =
s->mp3decctx[0] +
i;
1795 s->mp3decctx[
i]->adu_mode = 1;
1796 s->mp3decctx[
i]->avctx = avctx;
1797 s->mp3decctx[
i]->mpadsp =
s->mp3decctx[0]->mpadsp;
1799 s->mp3decctx[
i]->butterflies_float =
s->mp3decctx[0]->butterflies_float;
1812 for (
i = 0;
i <
s->frames;
i++)
1818 int *got_frame_ptr,
AVPacket *avpkt)
1820 const uint8_t *buf = avpkt->
data;
1821 int buf_size = avpkt->
size;
1843 for (fr = 0; fr <
s->frames; fr++) {
1846 m =
s->mp3decctx[fr];
1867 ch += m->nb_channels;
1869 outptr[0] = out_samples[
s->coff[fr]];
1870 if (m->nb_channels > 1)
1871 outptr[1] = out_samples[
s->coff[fr] + 1];
1876 if (m->nb_channels > 1)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int bit_alloc(AC3EncodeContext *s, int snr_offset)
Run the bit allocation with a given SNR offset.
static double val(void *priv, double ch)
static double bound(const double threshold, const double val)
static float win(SuperEqualizerContext *s, float n, int N)
static AVFormatContext * ctx
static int64_t fsize(FILE *f)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
Reference: libavcodec/mpegaudiodec.c.
Reference: libavcodec/mpegaudiodec.c.
Public header for CRC hash function implementation.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_EF_BITSTREAM
detect bitstream specification deviations
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define AV_EF_BUFFER
detect improper bitstream length
#define AV_EF_AGGRESSIVE
consider things that a sane encoder/muxer should not do as an error
void(* flush)(AVBSFContext *ctx)
static CheckasmConfig cfg
static const uint8_t bits[8]
bitstream reader API header.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static const uint8_t * align_get_bits(GetBitContext *s)
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AV_CH_LAYOUT_4POINT0
#define AV_CH_LAYOUT_5POINT0
#define AV_CH_LAYOUT_7POINT1
#define AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_SURROUND
#define AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_5POINT1
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_MONO
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_calloc(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
static av_cold void decode_init_static(void)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static const float scale_factors[25]
scale factor for each decoded exponent: 2^-exp
static int shift(int a, int b)
Macro definitions for various function/variable attributes.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
static int ff_thread_once(char *control, void(*routine)(void))
Memory handling functions.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
static const int16_t steps[16]
static int mp_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
int avpriv_mpeg4audio_get_config2(MPEG4AudioConfig *c, const uint8_t *buf, int size, int sync_extension, void *logctx)
Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
int ff_mpa_l2_select_table(int bitrate, int nb_channels, int freq, int lsf)
mpeg audio declarations for both encoder and decoder.
#define MPA_MAX_CODED_FRAME_SIZE
static av_cold void mpegaudio_tableinit(void)
const int ff_mpa_quant_bits[17]
const unsigned char *const ff_mpa_alloc_tables[5]
const int ff_mpa_sblimit_table[5]
const int ff_mpa_quant_steps[17]
mpeg audio layer common tables.
#define MODE_EXT_MS_STEREO
uint16_t ff_scale_factor_modshift[64]
const uint8_t ff_band_size_long[9][22]
const uint8_t ff_mpa_huff_data[32][2]
uint16_t ff_band_index_long[9][23]
const uint8_t ff_lsf_nsf_table[6][3][4]
uint32_t ff_table_4_3_value[TABLE_4_3_SIZE]
const uint8_t ff_slen_table[2][16]
const VLCElem * ff_huff_vlc[16]
const uint8_t ff_mpa_pretab[2][22]
#define MODE_EXT_I_STEREO
int8_t ff_table_4_3_exp[TABLE_4_3_SIZE]
int16_t *const ff_division_tabs[4]
void ff_mpegaudiodec_common_init_static(void)
const uint8_t ff_band_size_short[9][13]
static const int32_t is_table[2][16]
static int huffman_decode(MPADecodeContext *s, GranuleDef *g, int16_t *exponents, int end_pos2)
static INTFLOAT is_table_lsf[2][2][16]
static void exponents_from_scale_factors(MPADecodeContext *s, GranuleDef *g, int16_t *exponents)
static av_cold void decode_init_static(void)
static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2)
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
static av_always_inline void lsf_sf_expand(int *slen, int sf, int n1, int n2, int n3)
static void compute_stereo(MPADecodeContext *s, GranuleDef *g0, GranuleDef *g1)
static void init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2)
static void compute_band_indexes(MPADecodeContext *s, GranuleDef *g)
static int l2_unscale_group(int steps, int mant, int scale_factor)
static void region_offset2size(GranuleDef *g)
Convert region offsets to region sizes and truncate size to big_values.
static av_cold int decode_init(AVCodecContext *avctx)
static int handle_crc(MPADecodeContext *s, int sec_len)
static int mp_decode_layer2(MPADecodeContext *s)
static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples, const uint8_t *buf, int buf_size)
static av_cold void mp_flush(MPADecodeContext *ctx)
#define SPLIT(dst, sf, n)
static int32_t scale_factor_mult[15][3]
static int l3_unscale(int value, int exponent)
static int mp_decode_layer3(MPADecodeContext *s)
static int mp_decode_layer1(MPADecodeContext *s)
static void imdct12(INTFLOAT *out, SUINTFLOAT *in)
static void init_short_region(MPADecodeContext *s, GranuleDef *g)
static av_cold int decode_ctx_init(AVCodecContext *avctx, MPADecodeContext *s)
#define READ_FLIP_SIGN(dst, src)
static void reorder_block(MPADecodeContext *s, GranuleDef *g)
static int l1_unscale(int n, int mant, int scale_factor)
static const int32_t scale_factor_mult2[3][3]
static void compute_imdct(MPADecodeContext *s, GranuleDef *g, INTFLOAT *sb_samples, INTFLOAT *mdct_buf)
static void compute_antialias(MPADecodeContext *s, GranuleDef *g)
av_cold void ff_mpadsp_init(MPADSPContext *s)
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, ptrdiff_t incr, MPA_INT *sb_samples)
av_cold void RENAME ff_mpa_synth_init(void)
static const uint16_t table[]
static const uint8_t header[24]
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int64_t bit_rate
the average bitrate
enum AVSampleFormat request_sample_fmt
desired sample format
int sample_rate
samples per second
int flags
AV_CODEC_FLAG_*.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
int frame_size
Number of samples per channel in an audio frame.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
void(* butterflies_float)(float *restrict v1, float *restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
uint8_t scale_factors[40]
INTFLOAT sb_hybrid[SBLIMIT *18]
uint8_t count1table_select
int adu_mode
0 for standard mp3, 1 for adu formatted mp3
INTFLOAT sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]
uint32_t free_format_next_header
INTFLOAT mdct_buf[MPA_MAX_CHANNELS][SBLIMIT *18]
int synth_buf_offset[MPA_MAX_CHANNELS]
MPA_INT synth_buf[MPA_MAX_CHANNELS][512 *2]
MPA_DECODE_HEADER uint8_t last_buf[LAST_BUF_SIZE]
GranuleDef granules[2][2]
void(* butterflies_float)(float *restrict v1, float *restrict v2, int len)
#define avpriv_request_sample(...)
static int mod(int a, int b)
Modulo operation with only positive remainders.
static int alloc_table(VLC *vlc, int size, int use_static)