45 #define BACKSTEP_SIZE 512 47 #define LAST_BUF_SIZE 2 * BACKSTEP_SIZE + EXTRABYTES 92 # define SHR(a,b) ((a)*(1.0f/(1<<(b)))) 93 # define FIXR_OLD(a) ((int)((a) * FRAC_ONE + 0.5)) 94 # define FIXR(x) ((float)(x)) 95 # define FIXHR(x) ((float)(x)) 96 # define MULH3(x, y, s) ((s)*(y)*(x)) 97 # define MULLx(x, y, s) ((y)*(x)) 98 # define RENAME(a) a ## _float 99 # define OUT_FMT AV_SAMPLE_FMT_FLT 100 # define OUT_FMT_P AV_SAMPLE_FMT_FLTP 102 # define SHR(a,b) ((a)>>(b)) 104 # define FIXR_OLD(a) ((int)((a) * FRAC_ONE + 0.5)) 105 # define FIXR(a) ((int)((a) * FRAC_ONE + 0.5)) 106 # define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) 107 # define MULH3(x, y, s) MULH((s)*(x), y) 108 # define MULLx(x, y, s) MULL(x,y,s) 109 # define RENAME(a) a ## _fixed 110 # define OUT_FMT AV_SAMPLE_FMT_S16 111 # define OUT_FMT_P AV_SAMPLE_FMT_S16P 116 #define HEADER_SIZE 4 124 0 + 128 + 128 + 128 + 130 + 128 + 154 + 166 +
125 142 + 204 + 190 + 170 + 542 + 460 + 662 + 414
128 0, 128, 128, 128, 130, 128, 154, 166,
129 142, 204, 190, 170, 542, 460, 662, 414
156 #define SCALE_GEN(v) \ 157 { FIXR_OLD(1.0 * (v)), FIXR_OLD(0.7937005259 * (v)), FIXR_OLD(0.6299605249 * (v)) } 173 for (i = 0; i < 3; i++) {
183 if (s->sample_rate_index != 8)
188 if (s->sample_rate_index <= 2)
190 else if (s->sample_rate_index != 8)
203 l =
FFMIN(ra1 + ra2 + 2, 22);
211 if(s->sample_rate_index == 8)
216 if (s->sample_rate_index <= 2)
245 return (
int)((val + (1LL << (shift - 1))) >> shift);
259 val = (val + (1 << (shift - 1))) >> shift;
278 m = (m + (1 << (e - 1))) >> e;
289 for (i = 0; i < 64; i++) {
298 for (i = 0; i < 15; i++) {
301 norm = ((INT64_C(1) <<
n) *
FRAC_ONE) / ((1 <<
n) - 1);
315 for (i = 1; i < 16; i++) {
318 uint8_t tmp_bits [512] = { 0 };
319 uint16_t tmp_codes[512] = { 0 };
324 for (x = 0; x < xsize; x++) {
325 for (y = 0; y < xsize; y++) {
326 tmp_bits [(x << 5) | y | ((x&&y)<<4)]= h->
bits [j ];
327 tmp_codes[(x << 5) | y | ((x&&
y)<<4)]= h->
codes[j++];
335 tmp_bits, 1, 1, tmp_codes, 2, 2,
342 for (i = 0; i < 2; i++) {
345 init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16,
352 for (i = 0; i < 9; i++) {
354 for (j = 0; j < 22; j++) {
365 for (i = 0; i < 4; i++) {
368 int val1, val2, val3, steps;
381 for (i = 0; i < 7; i++) {
385 f = tan((
double)i *
M_PI / 12.0);
386 v =
FIXR(f / (1.0 + f));
394 for (i = 7; i < 16; i++)
397 for (i = 0; i < 16; i++) {
401 for (j = 0; j < 2; j++) {
402 e = -(j + 1) * ((i + 1) >> 1);
413 for (i = 0; i < 8; i++) {
416 cs = 1.0 /
sqrt(1.0 + ci * ci);
434 static int initialized_tables = 0;
437 if (!initialized_tables) {
439 initialized_tables = 1;
460 #define C3 FIXHR(0.86602540378443864676/2) 461 #define C4 FIXHR(0.70710678118654752439/2) //0.5 / cos(pi*(9)/36) 462 #define C5 FIXHR(0.51763809020504152469/2) //0.5 / cos(pi*(5)/36) 463 #define C6 FIXHR(1.93185165257813657349/4) //0.5 / cos(pi*(15)/36) 472 in1 = in[1*3] + in[0*3];
473 in2 = in[2*3] + in[1*3];
474 in3 = in[3*3] + in[2*3];
475 in4 = in[4*3] + in[3*3];
476 in5 = in[5*3] + in[4*3];
511 int bound,
i,
v,
n, ch, j, mant;
516 bound = (s->mode_ext + 1) * 4;
521 for (i = 0; i < bound; i++) {
522 for (ch = 0; ch < s->nb_channels; ch++) {
526 for (i = bound; i <
SBLIMIT; i++)
530 for (i = 0; i < bound; i++) {
531 for (ch = 0; ch < s->nb_channels; ch++) {
532 if (allocation[ch][i])
536 for (i = bound; i <
SBLIMIT; i++) {
537 if (allocation[0][i]) {
544 for (j = 0; j < 12; j++) {
545 for (i = 0; i < bound; i++) {
546 for (ch = 0; ch < s->nb_channels; ch++) {
547 n = allocation[ch][
i];
550 v =
l1_unscale(n, mant, scale_factors[ch][i]);
554 s->sb_samples[ch][j][
i] =
v;
557 for (i = bound; i <
SBLIMIT; i++) {
558 n = allocation[0][
i];
562 s->sb_samples[0][j][
i] =
v;
564 s->sb_samples[1][j][
i] =
v;
566 s->sb_samples[0][j][
i] = 0;
567 s->sb_samples[1][j][
i] = 0;
578 int table, bit_alloc_bits,
i, j, ch, bound,
v;
586 s->sample_rate, s->lsf);
591 bound = (s->mode_ext + 1) * 4;
595 av_dlog(s->avctx,
"bound=%d sblimit=%d\n", bound, sblimit);
603 for (i = 0; i < bound; i++) {
604 bit_alloc_bits = alloc_table[j];
605 for (ch = 0; ch < s->nb_channels; ch++)
606 bit_alloc[ch][i] =
get_bits(&s->
gb, bit_alloc_bits);
607 j += 1 << bit_alloc_bits;
609 for (i = bound; i < sblimit; i++) {
610 bit_alloc_bits = alloc_table[j];
614 j += 1 << bit_alloc_bits;
618 for (i = 0; i < sblimit; i++) {
619 for (ch = 0; ch < s->nb_channels; ch++) {
620 if (bit_alloc[ch][i])
626 for (i = 0; i < sblimit; i++) {
627 for (ch = 0; ch < s->nb_channels; ch++) {
628 if (bit_alloc[ch][i]) {
629 sf = scale_factors[ch][
i];
630 switch (scale_code[ch][i]) {
658 for (k = 0; k < 3; k++) {
659 for (l = 0; l < 12; l += 3) {
661 for (i = 0; i < bound; i++) {
662 bit_alloc_bits = alloc_table[j];
663 for (ch = 0; ch < s->nb_channels; ch++) {
664 b = bit_alloc[ch][
i];
666 scale = scale_factors[ch][
i][
k];
667 qindex = alloc_table[j+
b];
676 s->sb_samples[ch][k * 12 + l + 0][
i] =
678 s->sb_samples[ch][k * 12 + l + 1][
i] =
680 s->sb_samples[ch][k * 12 + l + 2][
i] =
683 for (m = 0; m < 3; m++) {
686 s->sb_samples[ch][k * 12 + l +
m][
i] =
v;
690 s->sb_samples[ch][k * 12 + l + 0][
i] = 0;
691 s->sb_samples[ch][k * 12 + l + 1][
i] = 0;
692 s->sb_samples[ch][k * 12 + l + 2][
i] = 0;
696 j += 1 << bit_alloc_bits;
699 for (i = bound; i < sblimit; i++) {
700 bit_alloc_bits = alloc_table[j];
703 int mant, scale0, scale1;
704 scale0 = scale_factors[0][
i][
k];
705 scale1 = scale_factors[1][
i][
k];
706 qindex = alloc_table[j+
b];
714 s->sb_samples[0][k * 12 + l + 0][
i] =
716 s->sb_samples[1][k * 12 + l + 0][
i] =
720 s->sb_samples[0][k * 12 + l + 1][
i] =
722 s->sb_samples[1][k * 12 + l + 1][
i] =
724 s->sb_samples[0][k * 12 + l + 2][
i] =
726 s->sb_samples[1][k * 12 + l + 2][
i] =
729 for (m = 0; m < 3; m++) {
731 s->sb_samples[0][k * 12 + l +
m][
i] =
733 s->sb_samples[1][k * 12 + l +
m][
i] =
738 s->sb_samples[0][k * 12 + l + 0][
i] = 0;
739 s->sb_samples[0][k * 12 + l + 1][
i] = 0;
740 s->sb_samples[0][k * 12 + l + 2][
i] = 0;
741 s->sb_samples[1][k * 12 + l + 0][
i] = 0;
742 s->sb_samples[1][k * 12 + l + 1][
i] = 0;
743 s->sb_samples[1][k * 12 + l + 2][
i] = 0;
746 j += 1 << bit_alloc_bits;
749 for (i = sblimit; i <
SBLIMIT; i++) {
750 for (ch = 0; ch < s->nb_channels; ch++) {
751 s->sb_samples[ch][k * 12 + l + 0][
i] = 0;
752 s->sb_samples[ch][k * 12 + l + 1][
i] = 0;
753 s->sb_samples[ch][k * 12 + l + 2][
i] = 0;
761 #define SPLIT(dst,sf,n) \ 763 int m = (sf * 171) >> 9; \ 766 } else if (n == 4) { \ 769 } else if (n == 5) { \ 770 int m = (sf * 205) >> 10; \ 773 } else if (n == 6) { \ 774 int m = (sf * 171) >> 10; \ 784 SPLIT(slen[3], sf, n3)
785 SPLIT(slen[2], sf, n2)
786 SPLIT(slen[1], sf, n1)
806 for (j = len; j > 0; j--)
818 for (l = 0; l < 3; l++) {
820 for (j = len; j > 0; j--)
855 #define READ_FLIP_SIGN(dst,src) \ 856 v = AV_RN32A(src) ^ (get_bits1(&s->gb) << 31); \ 859 #define READ_FLIP_SIGN(dst,src) \ 860 v = -get_bits1(&s->gb); \ 861 *(dst) = (*(src) ^ v) - v; 865 int16_t *exponents,
int end_pos2)
869 int last_pos, bits_left;
875 for (i = 0; i < 3; i++) {
876 int j,
k, l, linbits;
887 memset(&g->sb_hybrid[s_index], 0,
sizeof(*g->sb_hybrid) * 2 * j);
906 g->sb_hybrid[s_index ] =
907 g->sb_hybrid[s_index+1] = 0;
912 exponent= exponents[s_index];
914 av_dlog(s->avctx,
"region=%d n=%d x=%d y=%d exp=%d\n",
926 g->sb_hybrid[s_index] =
v;
935 g->sb_hybrid[s_index+1] =
v;
948 g->sb_hybrid[s_index+!!
y] =
v;
950 g->sb_hybrid[s_index + !
y] = 0;
959 while (s_index <= 572) {
962 if (pos >= end_pos) {
963 if (pos > end_pos2 && last_pos) {
968 av_log(s->avctx,
AV_LOG_INFO,
"overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos);
981 g->sb_hybrid[s_index+0] =
982 g->sb_hybrid[s_index+1] =
983 g->sb_hybrid[s_index+2] =
984 g->sb_hybrid[s_index+3] = 0;
986 static const int idxtab[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 };
988 int pos = s_index + idxtab[
code];
989 code ^= 8 >> idxtab[
code];
1003 memset(&g->sb_hybrid[s_index], 0,
sizeof(*g->sb_hybrid) * (576 - s_index));
1025 if (s->sample_rate_index != 8)
1026 ptr = g->sb_hybrid + 36;
1028 ptr = g->sb_hybrid + 72;
1037 for (j = len; j > 0; j--) {
1038 *dst++ = ptr[0*
len];
1039 *dst++ = ptr[1*
len];
1040 *dst++ = ptr[2*
len];
1044 memcpy(ptr1, tmp, len * 3 *
sizeof(*ptr1));
1048 #define ISQRT2 FIXR(0.70710678118654752440) 1053 int sf_max, sf,
len, non_zero_found;
1054 INTFLOAT (*is_tab)[16], *tab0, *
tab1, tmp0, tmp1, v1, v2;
1055 int non_zero_found_short[3];
1067 tab0 = g0->sb_hybrid + 576;
1068 tab1 = g1->sb_hybrid + 576;
1070 non_zero_found_short[0] = 0;
1071 non_zero_found_short[1] = 0;
1072 non_zero_found_short[2] = 0;
1079 for (l = 2; l >= 0; l--) {
1082 if (!non_zero_found_short[l]) {
1084 for (j = 0; j <
len; j++) {
1086 non_zero_found_short[l] = 1;
1096 for (j = 0; j <
len; j++) {
1106 for (j = 0; j <
len; j++) {
1117 non_zero_found = non_zero_found_short[0] |
1118 non_zero_found_short[1] |
1119 non_zero_found_short[2];
1121 for (i = g1->
long_end - 1;i >= 0;i--) {
1126 if (!non_zero_found) {
1127 for (j = 0; j <
len; j++) {
1134 k = (i == 21) ? 20 : i;
1140 for (j = 0; j <
len; j++) {
1150 for (j = 0; j <
len; j++) {
1164 s->fdsp.butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576);
1166 tab0 = g0->sb_hybrid;
1167 tab1 = g1->sb_hybrid;
1168 for (i = 0; i < 576; i++) {
1171 tab0[
i] = tmp0 + tmp1;
1172 tab1[
i] = tmp0 - tmp1;
1188 #ifndef compute_antialias 1190 #define AA(j) do { \ 1191 float tmp0 = ptr[-1-j]; \ 1192 float tmp1 = ptr[ j]; \ 1193 ptr[-1-j] = tmp0 * csa_table[j][0] - tmp1 * csa_table[j][1]; \ 1194 ptr[ j] = tmp0 * csa_table[j][1] + tmp1 * csa_table[j][0]; \ 1197 #define AA(j) do { \ 1198 int tmp0 = ptr[-1-j]; \ 1199 int tmp1 = ptr[ j]; \ 1200 int tmp2 = MULH(tmp0 + tmp1, csa_table[j][0]); \ 1201 ptr[-1-j] = 4 * (tmp2 - MULH(tmp1, csa_table[j][2])); \ 1202 ptr[ j] = 4 * (tmp2 + MULH(tmp0, csa_table[j][3])); \ 1221 ptr = g->sb_hybrid + 18;
1222 for (i = n; i > 0; i--) {
1242 int i, j, mdct_long_end, sblimit;
1245 ptr = g->sb_hybrid + 576;
1246 ptr1 = g->sb_hybrid + 2 * 18;
1247 while (ptr >= ptr1) {
1251 if (p[0] | p[1] | p[2] | p[3] | p[4] | p[5])
1254 sblimit = ((ptr - g->sb_hybrid) / 18) + 1;
1263 mdct_long_end = sblimit;
1266 s->mpadsp.RENAME(imdct36_blocks)(sb_samples, mdct_buf, g->sb_hybrid,
1270 buf = mdct_buf + 4*18*(mdct_long_end >> 2) + (mdct_long_end & 3);
1271 ptr = g->sb_hybrid + 18 * mdct_long_end;
1273 for (j = mdct_long_end; j < sblimit; j++) {
1275 win =
RENAME(ff_mdct_win)[2 + (4 & -(j & 1))];
1276 out_ptr = sb_samples + j;
1278 for (i = 0; i < 6; i++) {
1279 *out_ptr = buf[4*
i];
1283 for (i = 0; i < 6; i++) {
1284 *out_ptr =
MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*1)];
1285 buf[4*(i + 6*2)] =
MULH3(out2[i + 6], win[i + 6], 1);
1289 for (i = 0; i < 6; i++) {
1290 *out_ptr =
MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*2)];
1291 buf[4*(i + 6*0)] =
MULH3(out2[i + 6], win[i + 6], 1);
1295 for (i = 0; i < 6; i++) {
1296 buf[4*(i + 6*0)] =
MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*0)];
1297 buf[4*(i + 6*1)] =
MULH3(out2[i + 6], win[i + 6], 1);
1298 buf[4*(i + 6*2)] = 0;
1301 buf += (j&3) != 3 ? 1 : (4*18-3);
1304 for (j = sblimit; j <
SBLIMIT; j++) {
1306 out_ptr = sb_samples + j;
1307 for (i = 0; i < 18; i++) {
1308 *out_ptr = buf[4*
i];
1312 buf += (j&3) != 3 ? 1 : (4*18-3);
1319 int nb_granules, main_data_begin;
1320 int gr, ch, blocksplit_flag,
i, j,
k,
n, bits_pos;
1322 int16_t exponents[576];
1331 if (s->nb_channels == 2)
1336 for (ch = 0; ch < s->nb_channels; ch++) {
1337 s->granules[ch][0].scfsi = 0;
1338 s->granules[ch][1].scfsi =
get_bits(&s->
gb, 4);
1342 for (gr = 0; gr < nb_granules; gr++) {
1343 for (ch = 0; ch < s->nb_channels; ch++) {
1344 av_dlog(s->avctx,
"gr=%d ch=%d: side_info\n", gr, ch);
1345 g = &s->granules[ch][gr];
1364 if (blocksplit_flag) {
1371 for (i = 0; i < 2; i++)
1373 for (i = 0; i < 3; i++)
1377 int region_address1, region_address2;
1380 for (i = 0; i < 3; i++)
1385 av_dlog(s->avctx,
"region1=%d region2=%d\n",
1386 region_address1, region_address2);
1397 av_dlog(s->avctx,
"block_type=%d switch_point=%d\n",
1408 av_dlog(s->avctx,
"seekback:%d, lastbuf:%d\n",
1414 #if !UNCHECKED_BITSTREAM_READER 1418 for (gr = 0; gr < nb_granules && (s->
last_buf_size >> 3) < main_data_begin; gr++) {
1419 for (ch = 0; ch < s->nb_channels; ch++) {
1420 g = &s->granules[ch][gr];
1422 memset(g->sb_hybrid, 0,
sizeof(g->sb_hybrid));
1423 compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]);
1438 for (; gr < nb_granules; gr++) {
1439 for (ch = 0; ch < s->nb_channels; ch++) {
1440 g = &s->granules[ch][gr];
1445 int slen, slen1, slen2;
1450 av_dlog(s->avctx,
"slen1=%d slen2=%d\n", slen1, slen2);
1455 for (i = 0; i <
n; i++)
1458 for (i = 0; i <
n; i++)
1462 for (i = 0; i < 18; i++)
1464 for (i = 0; i < 3; i++)
1467 for (i = 0; i < 21; i++)
1471 sc = s->granules[ch][0].scale_factors;
1473 for (k = 0; k < 4; k++) {
1475 if ((g->
scfsi & (0x8 >> k)) == 0) {
1476 slen = (k < 2) ? slen1 : slen2;
1478 for (i = 0; i <
n; i++)
1481 for (i = 0; i <
n; i++)
1486 for (i = 0; i <
n; i++) {
1495 int tindex, tindex2, slen[4], sl, sf;
1510 }
else if (sf < 244) {
1522 }
else if (sf < 500) {
1533 for (k = 0; k < 4; k++) {
1537 for (i = 0; i <
n; i++)
1540 for (i = 0; i <
n; i++)
1558 for (ch = 0; ch < s->nb_channels; ch++) {
1559 g = &s->granules[ch][gr];
1563 compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]);
1568 return nb_granules * 18;
1574 int i, nb_frames, ch,
ret;
1580 if (s->error_protection)
1585 s->avctx->frame_size = 384;
1589 s->avctx->frame_size = 1152;
1593 s->avctx->frame_size = s->lsf ? 576 : 1152;
1619 av_assert1(i <= buf_size - HEADER_SIZE && i >= 0);
1630 s->frame->nb_samples = s->avctx->frame_size;
1633 samples = (
OUT_INT **)s->frame->extended_data;
1637 for (ch = 0; ch < s->nb_channels; ch++) {
1639 if (s->avctx->sample_fmt ==
OUT_FMT_P) {
1640 samples_ptr = samples[ch];
1643 samples_ptr = samples[0] + ch;
1644 sample_stride = s->nb_channels;
1646 for (i = 0; i < nb_frames; i++) {
1648 &(s->synth_buf_offset[ch]),
1649 RENAME(ff_mpa_synth_window),
1650 &s->dither_state, samples_ptr,
1651 sample_stride, s->sb_samples[ch][
i]);
1652 samples_ptr += 32 * sample_stride;
1656 return nb_frames * 32 *
sizeof(
OUT_INT) * s->nb_channels;
1663 int buf_size = avpkt->
size;
1668 while(buf_size && !*buf){
1677 if (header>>8 ==
AV_RB32(
"TAG")>>8) {
1697 if (s->frame_size <= 0 || s->frame_size > buf_size) {
1700 }
else if (s->frame_size < buf_size) {
1702 buf_size= s->frame_size;
1730 memset(ctx->synth_buf, 0,
sizeof(ctx->synth_buf));
1739 #if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER 1741 int *got_frame_ptr,
AVPacket *avpkt)
1744 int buf_size = avpkt->
size;
1763 header =
AV_RB32(buf) | 0xffe00000;
1777 s->frame_size =
len;
1793 #if CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER 1798 typedef struct MP3On4DecodeContext {
1803 } MP3On4DecodeContext;
1810 static const uint8_t mp3Frames[8] = { 0, 1, 1, 2, 3, 3, 4, 5 };
1813 static const uint8_t chan_offset[8][5] = {
1825 static const int16_t chan_layout[8] = {
1841 for (i = 0; i < s->frames; i++)
1871 s->syncword = 0xffe00000;
1873 s->syncword = 0xfff00000;
1882 if (!s->mp3decctx[0])
1889 s->mp3decctx[0]->adu_mode = 1;
1894 for (i = 1; i < s->frames; i++) {
1896 if (!s->mp3decctx[i])
1898 s->mp3decctx[
i]->adu_mode = 1;
1899 s->mp3decctx[
i]->avctx = avctx;
1900 s->mp3decctx[
i]->mpadsp = s->mp3decctx[0]->mpadsp;
1905 decode_close_mp3on4(avctx);
1915 for (i = 0; i < s->frames; i++)
1921 int *got_frame_ptr,
AVPacket *avpkt)
1925 int buf_size = avpkt->
size;
1928 int fsize,
len = buf_size, out_size = 0;
1947 for (fr = 0; fr < s->frames; fr++) {
1950 m = s->mp3decctx[fr];
1957 header = (
AV_RB32(buf) & 0x000fffff) | s->syncword;
1964 if (ch + m->nb_channels > avctx->
channels || s->coff[fr] + m->nb_channels > avctx->
channels) {
1969 ch += m->nb_channels;
1971 outptr[0] = out_samples[s->coff[fr]];
1972 if (m->nb_channels > 1)
1973 outptr[1] = out_samples[s->coff[fr] + 1];
1986 avctx->
sample_rate = s->mp3decctx[0]->sample_rate;
1996 #if CONFIG_MP1_DECODER 2012 #if CONFIG_MP2_DECODER 2028 #if CONFIG_MP3_DECODER 2044 #if CONFIG_MP3ADU_DECODER 2051 .
decode = decode_frame_adu,
2060 #if CONFIG_MP3ON4_DECODER 2065 .priv_data_size =
sizeof(MP3On4DecodeContext),
2066 .
init = decode_init_mp3on4,
2067 .
close = decode_close_mp3on4,
2068 .
decode = decode_frame_mp3on4,
2070 .
flush = flush_mp3on4,
#define MPA_MAX_CODED_FRAME_SIZE
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#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]
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
static int l1_unscale(int n, int mant, int scale_factor)
Reference: libavcodec/mpegaudiodec.c.
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 av_cold int init(AVCodecContext *avctx)
#define READ_FLIP_SIGN(dst, src)
static int8_t table_4_3_exp[TABLE_4_3_SIZE]
#define AV_LOG_WARNING
Something somehow does not look correct.
static void compute_stereo(MPADecodeContext *s, GranuleDef *g0, GranuleDef *g1)
struct MPADecodeContext MPADecodeContext
About Git write you should know how to use GIT properly Luckily Git comes with excellent documentation git help man git shows you the available git< command > help man git< command > shows information about the subcommand< command > The most comprehensive manual is the website Git Reference visit they are quite exhaustive You do not need a special username or password All you need is to provide a ssh public key to the Git server admin What follows now is a basic introduction to Git and some FFmpeg specific guidelines Read it at least if you are granted commit privileges to the FFmpeg project you are expected to be familiar with these rules I if not You can get git from etc no matter how small Every one of them has been saved from looking like a fool by this many times It s very easy for stray debug output or cosmetic modifications to slip in
#define DECLARE_ALIGNED(n, t, v)
const int ff_mpa_quant_bits[17]
static const uint8_t mpa_pretab[2][22]
#define AV_CH_LAYOUT_4POINT0
#define FF_ARRAY_ELEMS(a)
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_cold void decode_init_static(void)
uint8_t scale_factors[40]
#define AV_CH_LAYOUT_5POINT0
mpeg audio layer common tables.
static const int huff_vlc_tables_sizes[16]
static const uint8_t slen_table[2][16]
static av_always_inline void lsf_sf_expand(int *slen, int sf, int n1, int n2, int n3)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int16_t division_tab5[1<< 8]
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
enum AVSampleFormat sample_fmt
audio sample format
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static av_cold int decode_init(AVCodecContext *avctx)
static int mp_decode_layer2(MPADecodeContext *s)
static int32_t scale_factor_mult[15][3]
av_cold void RENAME() ff_mpa_synth_init(MPA_INT *window)
const int ff_mpa_quant_steps[17]
static void mpegaudio_tableinit(void)
const unsigned char *const ff_mpa_alloc_tables[5]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static const uint8_t mpa_huff_data[32][2]
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
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 int bit_alloc(AC3EncodeContext *s, int snr_offset)
Run the bit allocation with a given SNR offset.
static int16_t division_tab3[1<< 6]
#define AV_CH_LAYOUT_5POINT1
static int get_bits_left(GetBitContext *gb)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static INTFLOAT csa_table[8][4]
#define MODE_EXT_MS_STEREO
static VLC_TYPE huff_quad_vlc_tables[128+16][2]
enum AVSampleFormat request_sample_fmt
desired sample format
static const struct endianess table[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
preferred ID for decoding MPEG audio layer 1, 2 or 3
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static int mp_decode_layer1(MPADecodeContext *s)
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static const uint8_t offset[127][2]
static const int32_t scale_factor_mult2[3][3]
uint64_t channel_layout
Audio channel layout.
void ff_mpadsp_init(MPADSPContext *s)
static int huffman_decode(MPADecodeContext *s, GranuleDef *g, int16_t *exponents, int end_pos2)
int bit_rate
the average bitrate
audio channel layout utility functions
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2)
static int mp_decode_layer3(MPADecodeContext *s)
static int16_t division_tab9[1<< 11]
uint32_t free_format_next_header
Reference: libavcodec/mpegaudiodec.c.
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static int16_t *const division_tabs[4]
if it could not because there are no more frames
static int l2_unscale_group(int steps, int mant, int scale_factor)
static int l3_unscale(int value, int exponent)
#define INIT_VLC_USE_NEW_STATIC
static const uint8_t mpa_quad_bits[2][16]
static uint16_t band_index_long[9][23]
int frame_size
Number of samples per channel in an audio frame.
or the Software in violation of any applicable export control laws in any jurisdiction Except as provided by mandatorily applicable UPF has no obligation to provide you with source code to the Software In the event Software contains any source code
static const int huff_quad_vlc_tables_sizes[2]
static INTFLOAT is_table_lsf[2][2][16]
int sample_rate
samples per second
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
Replacements for frequently missing libm functions.
static unsigned int get_bits1(GetBitContext *s)
uint8_t count1table_select
static void skip_bits(GetBitContext *s, int n)
static void ff_region_offset2size(GranuleDef *g)
Convert region offsets to region sizes and truncate size to big_values.
static void compute_imdct(MPADecodeContext *s, GranuleDef *g, INTFLOAT *sb_samples, INTFLOAT *mdct_buf)
static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples, const uint8_t *buf, int buf_size)
#define MODE_EXT_I_STEREO
synthesis window for stochastic i
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static void exponents_from_scale_factors(MPADecodeContext *s, GranuleDef *g, int16_t *exponents)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Buffer references ownership and permissions
static const uint8_t band_size_long[9][22]
static void compute_antialias(MPADecodeContext *s, GranuleDef *g)
#define SPLIT(dst, sf, n)
static VLC huff_quad_vlc[2]
common internal api header.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static uint16_t scale_factor_modshift[64]
static void ff_init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2)
static INTFLOAT is_table[2][16]
AVSampleFormat
Audio Sample Formats.
static void ff_compute_band_indexes(MPADecodeContext *s, GranuleDef *g)
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.
static void imdct12(INTFLOAT *out, INTFLOAT *in)
static void reorder_block(MPADecodeContext *s, GranuleDef *g)
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.
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]
else dst[i][x+y *dst_stride[i]]
MPA_DECODE_HEADER uint8_t last_buf[LAST_BUF_SIZE]
VLC_TYPE(* table)[2]
code, bits
static VLC_TYPE huff_vlc_tables[0+128+128+128+130+128+154+166+142+204+190+170+542+460+662+414][2]
struct GranuleDef GranuleDef
static const uint8_t * align_get_bits(GetBitContext *s)
Filter the word “frame” indicates either a video frame or a group of audio samples
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;}return ac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> out
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int get_bitsz(GetBitContext *s, int n)
mpeg audio layer decoder tables.
void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
Initialize a float DSP context.
static const HuffTable mpa_huff_tables[16]
static void flush(AVCodecContext *avctx)
static const float ci_table[8]
uint8_t ** extended_data
pointers to the data planes/channels.
#define AV_CH_LAYOUT_MONO
static void ff_init_short_region(MPADecodeContext *s, GranuleDef *g)
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
static int alloc_table(VLC *vlc, int size, int use_static)
static const uint8_t band_size_short[9][13]
static void mp_flush(MPADecodeContext *ctx)