Go to the documentation of this file.
27 #include "config_components.h"
52 #define BACKSTEP_SIZE 512
54 #define LAST_BUF_SIZE 2 * BACKSTEP_SIZE + EXTRABYTES
100 #define HEADER_SIZE 4
112 #define SCALE_GEN(v) \
113 { FIXR_OLD(1.0 * (v)), FIXR_OLD(0.7937005259 * (v)), FIXR_OLD(0.6299605249 * (v)) }
128 g->region_size[2] = 576 / 2;
129 for (
i = 0;
i < 3;
i++) {
130 k =
FFMIN(
g->region_size[
i],
g->big_values);
131 g->region_size[
i] = k - j;
138 if (
g->block_type == 2) {
139 if (
s->sample_rate_index != 8)
140 g->region_size[0] = (36 / 2);
142 g->region_size[0] = (72 / 2);
144 if (
s->sample_rate_index <= 2)
145 g->region_size[0] = (36 / 2);
146 else if (
s->sample_rate_index != 8)
147 g->region_size[0] = (54 / 2);
149 g->region_size[0] = (108 / 2);
151 g->region_size[1] = (576 / 2);
160 l =
FFMIN(ra1 + ra2 + 2, 22);
166 if (
g->block_type == 2) {
167 if (
g->switch_point) {
168 if(
s->sample_rate_index == 8)
173 if (
s->sample_rate_index <= 2)
191 static inline int l1_unscale(
int n,
int mant,
int scale_factor)
235 m = (m + ((1U << e) >> 1)) >> e;
245 for (
i = 0;
i < 15;
i++) {
248 norm = ((INT64_C(1) << n) *
FRAC_ONE) / ((1 << n) - 1);
252 ff_dlog(
NULL,
"%d: norm=%x s=%"PRIx32
" %"PRIx32
" %"PRIx32
"\n",
i,
263 for (
i = 0;
i < 16;
i++) {
267 for (j = 0; j < 2; j++) {
268 e = -(j + 1) * ((
i + 1) >> 1);
278 RENAME(ff_mpa_synth_init)();
317 #define C3 FIXHR(0.86602540378443864676/2)
318 #define C4 FIXHR(0.70710678118654752439/2) //0.5 / cos(pi*(9)/36)
319 #define C5 FIXHR(0.51763809020504152469/2) //0.5 / cos(pi*(5)/36)
320 #define C6 FIXHR(1.93185165257813657349/4) //0.5 / cos(pi*(15)/36)
329 in1 = in[1*3] + in[0*3];
330 in2 = in[2*3] + in[1*3];
331 in3 = in[3*3] + in[2*3];
332 in4 = in[4*3] + in[3*3];
333 in5 = in[5*3] + in[4*3];
369 int sec_byte_len = sec_len >> 3;
370 int sec_rem_bits = sec_len & 7;
373 uint32_t crc_val =
av_crc(crc_tab, UINT16_MAX, &buf[2], 2);
374 crc_val =
av_crc(crc_tab, crc_val, &buf[6], sec_byte_len);
377 ((buf[6 + sec_byte_len] & (0xFF00U >> sec_rem_bits)) << 24) +
378 ((
s->crc << 16) >> sec_rem_bits));
380 crc_val =
av_crc(crc_tab, crc_val, tmp_buf, 3);
394 int bound,
i, v, n, ch, j, mant;
404 bound = (
s->mode_ext + 1) * 4;
410 for (ch = 0; ch <
s->nb_channels; ch++) {
419 for (ch = 0; ch <
s->nb_channels; ch++) {
420 if (allocation[ch][
i])
425 if (allocation[0][
i]) {
432 for (j = 0; j < 12; j++) {
434 for (ch = 0; ch <
s->nb_channels; ch++) {
435 n = allocation[ch][
i];
442 s->sb_samples[ch][j][
i] = v;
446 n = allocation[0][
i];
450 s->sb_samples[0][j][
i] = v;
452 s->sb_samples[1][j][
i] = v;
454 s->sb_samples[0][j][
i] = 0;
455 s->sb_samples[1][j][
i] = 0;
475 s->sample_rate,
s->lsf);
480 bound = (
s->mode_ext + 1) * 4;
494 for (ch = 0; ch <
s->nb_channels; ch++)
496 j += 1 << bit_alloc_bits;
503 j += 1 << bit_alloc_bits;
507 for (
i = 0;
i < sblimit;
i++) {
508 for (ch = 0; ch <
s->nb_channels; ch++) {
519 for (
i = 0;
i < sblimit;
i++) {
520 for (ch = 0; ch <
s->nb_channels; ch++) {
522 sf = scale_factors[ch][
i];
523 switch (scale_code[ch][
i]) {
551 for (k = 0; k < 3; k++) {
552 for (l = 0; l < 12; l += 3) {
556 for (ch = 0; ch <
s->nb_channels; ch++) {
559 scale = scale_factors[ch][
i][k];
569 s->sb_samples[ch][k * 12 + l + 0][
i] =
571 s->sb_samples[ch][k * 12 + l + 1][
i] =
573 s->sb_samples[ch][k * 12 + l + 2][
i] =
576 for (m = 0; m < 3; m++) {
579 s->sb_samples[ch][k * 12 + l + m][
i] = v;
583 s->sb_samples[ch][k * 12 + l + 0][
i] = 0;
584 s->sb_samples[ch][k * 12 + l + 1][
i] = 0;
585 s->sb_samples[ch][k * 12 + l + 2][
i] = 0;
589 j += 1 << bit_alloc_bits;
596 int mant, scale0, scale1;
597 scale0 = scale_factors[0][
i][k];
598 scale1 = scale_factors[1][
i][k];
607 s->sb_samples[0][k * 12 + l + 0][
i] =
609 s->sb_samples[1][k * 12 + l + 0][
i] =
613 s->sb_samples[0][k * 12 + l + 1][
i] =
615 s->sb_samples[1][k * 12 + l + 1][
i] =
617 s->sb_samples[0][k * 12 + l + 2][
i] =
619 s->sb_samples[1][k * 12 + l + 2][
i] =
622 for (m = 0; m < 3; m++) {
624 s->sb_samples[0][k * 12 + l + m][
i] =
626 s->sb_samples[1][k * 12 + l + m][
i] =
631 s->sb_samples[0][k * 12 + l + 0][
i] = 0;
632 s->sb_samples[0][k * 12 + l + 1][
i] = 0;
633 s->sb_samples[0][k * 12 + l + 2][
i] = 0;
634 s->sb_samples[1][k * 12 + l + 0][
i] = 0;
635 s->sb_samples[1][k * 12 + l + 1][
i] = 0;
636 s->sb_samples[1][k * 12 + l + 2][
i] = 0;
639 j += 1 << bit_alloc_bits;
643 for (ch = 0; ch <
s->nb_channels; ch++) {
644 s->sb_samples[ch][k * 12 + l + 0][
i] = 0;
645 s->sb_samples[ch][k * 12 + l + 1][
i] = 0;
646 s->sb_samples[ch][k * 12 + l + 2][
i] = 0;
654 #define SPLIT(dst,sf,n) \
656 int m = (sf * 171) >> 9; \
659 } else if (n == 4) { \
662 } else if (n == 5) { \
663 int m = (sf * 205) >> 10; \
666 } else if (n == 6) { \
667 int m = (sf * 171) >> 10; \
677 SPLIT(slen[3], sf, n3)
678 SPLIT(slen[2], sf, n2)
679 SPLIT(slen[1], sf, n1)
686 const uint8_t *bstab, *pretab;
691 gain =
g->global_gain - 210;
692 shift =
g->scalefac_scale + 1;
696 for (
i = 0;
i <
g->long_end;
i++) {
697 v0 = gain - ((
g->scale_factors[
i] + pretab[
i]) <<
shift) + 400;
699 for (j =
len; j > 0; j--)
703 if (
g->short_start < 13) {
705 gains[0] = gain - (
g->subblock_gain[0] << 3);
706 gains[1] = gain - (
g->subblock_gain[1] << 3);
707 gains[2] = gain - (
g->subblock_gain[2] << 3);
709 for (
i =
g->short_start;
i < 13;
i++) {
711 for (l = 0; l < 3; l++) {
712 v0 = gains[l] - (
g->scale_factors[k++] <<
shift) + 400;
713 for (j =
len; j > 0; j--)
723 if (
s->in_gb.buffer && *
pos >=
s->gb.size_in_bits -
s->extrasize * 8) {
725 s->in_gb.buffer =
NULL;
742 #define READ_FLIP_SIGN(dst,src) \
743 v = AV_RN32A(src) ^ (get_bits1(&s->gb) << 31); \
746 #define READ_FLIP_SIGN(dst,src) \
747 v = -get_bits1(&s->gb); \
748 *(dst) = (*(src) ^ v) - v;
752 int16_t *exponents,
int end_pos2)
758 int end_pos =
FFMIN(end_pos2,
s->gb.size_in_bits -
s->extrasize * 8);
762 for (
i = 0;
i < 3;
i++) {
764 int j, k, l, linbits;
765 j =
g->region_size[
i];
769 k =
g->table_select[
i];
774 memset(&
g->sb_hybrid[s_index], 0,
sizeof(*
g->sb_hybrid) * 2 * j);
794 g->sb_hybrid[s_index ] =
795 g->sb_hybrid[s_index + 1] = 0;
800 exponent= exponents[s_index];
802 ff_dlog(
s->avctx,
"region=%d n=%d y=%d exp=%d\n",
803 i,
g->region_size[
i] - j, y, exponent);
814 g->sb_hybrid[s_index] = v;
823 g->sb_hybrid[s_index + 1] = v;
836 g->sb_hybrid[s_index+!!y] = v;
838 g->sb_hybrid[s_index + !y] = 0;
847 while (s_index <= 572) {
850 if (
pos >= end_pos) {
851 if (
pos > end_pos2 && last_pos) {
868 ff_dlog(
s->avctx,
"t=%d code=%d\n",
g->count1table_select,
code);
869 g->sb_hybrid[s_index + 0] =
870 g->sb_hybrid[s_index + 1] =
871 g->sb_hybrid[s_index + 2] =
872 g->sb_hybrid[s_index + 3] = 0;
874 static const int idxtab[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 };
876 int pos = s_index + idxtab[
code];
891 memset(&
g->sb_hybrid[s_index], 0,
sizeof(*
g->sb_hybrid) * (576 - s_index));
909 if (
g->block_type != 2)
912 if (
g->switch_point) {
913 if (
s->sample_rate_index != 8)
914 ptr =
g->sb_hybrid + 36;
916 ptr =
g->sb_hybrid + 72;
921 for (
i =
g->short_start;
i < 13;
i++) {
925 for (j =
len; j > 0; j--) {
932 memcpy(ptr1,
tmp,
len * 3 *
sizeof(*ptr1));
936 #define ISQRT2 FIXR(0.70710678118654752440)
941 int sf_max, sf,
len, non_zero_found;
945 int non_zero_found_short[3];
960 non_zero_found_short[0] = 0;
961 non_zero_found_short[1] = 0;
962 non_zero_found_short[2] = 0;
969 for (l = 2; l >= 0; l--) {
972 if (!non_zero_found_short[l]) {
974 for (j = 0; j <
len; j++) {
976 non_zero_found_short[l] = 1;
986 for (j = 0; j <
len; j++) {
996 for (j = 0; j <
len; j++) {
1007 non_zero_found = non_zero_found_short[0] |
1008 non_zero_found_short[1] |
1009 non_zero_found_short[2];
1016 if (!non_zero_found) {
1017 for (j = 0; j <
len; j++) {
1024 k = (
i == 21) ? 20 :
i;
1030 for (j = 0; j <
len; j++) {
1040 for (j = 0; j <
len; j++) {
1058 for (
i = 0;
i < 576;
i++) {
1061 tab0[
i] = tmp0 + tmp1;
1062 tab1[
i] = tmp0 - tmp1;
1078 #ifndef compute_antialias
1080 #define AA(j) do { \
1081 float tmp0 = ptr[-1-j]; \
1082 float tmp1 = ptr[ j]; \
1083 ptr[-1-j] = tmp0 * csa_table[j][0] - tmp1 * csa_table[j][1]; \
1084 ptr[ j] = tmp0 * csa_table[j][1] + tmp1 * csa_table[j][0]; \
1087 #define AA(j) do { \
1088 SUINT tmp0 = ptr[-1-j]; \
1089 SUINT tmp1 = ptr[ j]; \
1090 SUINT tmp2 = MULH(tmp0 + tmp1, csa_table[j][0]); \
1091 ptr[-1-j] = 4 * (tmp2 - MULH(tmp1, csa_table[j][2])); \
1092 ptr[ j] = 4 * (tmp2 + MULH(tmp0, csa_table[j][3])); \
1102 if (
g->block_type == 2) {
1103 if (!
g->switch_point)
1111 ptr =
g->sb_hybrid + 18;
1112 for (
i = n;
i > 0;
i--) {
1132 int i, j, mdct_long_end, sblimit;
1135 ptr =
g->sb_hybrid + 576;
1136 ptr1 =
g->sb_hybrid + 2 * 18;
1137 while (ptr >= ptr1) {
1141 if (p[0] | p[1] | p[2] | p[3] | p[4] | p[5])
1144 sblimit = ((ptr -
g->sb_hybrid) / 18) + 1;
1146 if (
g->block_type == 2) {
1148 if (
g->switch_point)
1153 mdct_long_end = sblimit;
1156 s->mpadsp.RENAME(imdct36_blocks)(sb_samples, mdct_buf,
g->sb_hybrid,
1157 mdct_long_end,
g->switch_point,
1160 buf = mdct_buf + 4*18*(mdct_long_end >> 2) + (mdct_long_end & 3);
1161 ptr =
g->sb_hybrid + 18 * mdct_long_end;
1163 for (j = mdct_long_end; j < sblimit; j++) {
1165 win =
RENAME(ff_mdct_win)[2 + (4 & -(j & 1))];
1166 out_ptr = sb_samples + j;
1168 for (
i = 0;
i < 6;
i++) {
1169 *out_ptr = buf[4*
i];
1173 for (
i = 0;
i < 6;
i++) {
1174 *out_ptr =
MULH3(out2[
i ],
win[
i ], 1) + buf[4*(
i + 6*1)];
1175 buf[4*(
i + 6*2)] =
MULH3(out2[
i + 6],
win[
i + 6], 1);
1179 for (
i = 0;
i < 6;
i++) {
1180 *out_ptr =
MULH3(out2[
i ],
win[
i ], 1) + buf[4*(
i + 6*2)];
1181 buf[4*(
i + 6*0)] =
MULH3(out2[
i + 6],
win[
i + 6], 1);
1185 for (
i = 0;
i < 6;
i++) {
1186 buf[4*(
i + 6*0)] =
MULH3(out2[
i ],
win[
i ], 1) + buf[4*(
i + 6*0)];
1187 buf[4*(
i + 6*1)] =
MULH3(out2[
i + 6],
win[
i + 6], 1);
1188 buf[4*(
i + 6*2)] = 0;
1191 buf += (j&3) != 3 ? 1 : (4*18-3);
1194 for (j = sblimit; j <
SBLIMIT; j++) {
1196 out_ptr = sb_samples + j;
1197 for (
i = 0;
i < 18;
i++) {
1198 *out_ptr = buf[4*
i];
1202 buf += (j&3) != 3 ? 1 : (4*18-3);
1209 int nb_granules, main_data_begin;
1210 int gr, ch, blocksplit_flag,
i, j, k, n, bits_pos;
1212 int16_t exponents[576];
1224 if (
s->nb_channels == 2)
1229 for (ch = 0; ch <
s->nb_channels; ch++) {
1230 s->granules[ch][0].scfsi = 0;
1231 s->granules[ch][1].scfsi =
get_bits(&
s->gb, 4);
1237 for (gr = 0; gr < nb_granules; gr++) {
1238 for (ch = 0; ch <
s->nb_channels; ch++) {
1239 ff_dlog(
s->avctx,
"gr=%d ch=%d: side_info\n", gr, ch);
1240 g = &
s->granules[ch][gr];
1243 if (
g->big_values > 288) {
1253 g->global_gain -= 2;
1259 if (blocksplit_flag) {
1261 if (
g->block_type == 0) {
1266 for (
i = 0;
i < 2;
i++)
1268 for (
i = 0;
i < 3;
i++)
1272 int region_address1, region_address2;
1274 g->switch_point = 0;
1275 for (
i = 0;
i < 3;
i++)
1280 ff_dlog(
s->avctx,
"region1=%d region2=%d\n",
1281 region_address1, region_address2);
1292 ff_dlog(
s->avctx,
"block_type=%d switch_point=%d\n",
1293 g->block_type,
g->switch_point);
1304 ff_dlog(
s->avctx,
"seekback:%d, lastbuf:%d\n",
1305 main_data_begin,
s->last_buf_size);
1307 memcpy(
s->last_buf +
s->last_buf_size, ptr,
s->extrasize);
1310 s->last_buf_size <<= 3;
1311 for (gr = 0; gr < nb_granules && (
s->last_buf_size >> 3) < main_data_begin; gr++) {
1312 for (ch = 0; ch <
s->nb_channels; ch++) {
1313 g = &
s->granules[ch][gr];
1314 s->last_buf_size +=
g->part2_3_length;
1315 memset(
g->sb_hybrid, 0,
sizeof(
g->sb_hybrid));
1319 skip =
s->last_buf_size - 8 * main_data_begin;
1320 if (
skip >=
s->gb.size_in_bits -
s->extrasize * 8 &&
s->in_gb.buffer) {
1323 s->in_gb.buffer =
NULL;
1333 for (; gr < nb_granules; gr++) {
1334 for (ch = 0; ch <
s->nb_channels; ch++) {
1335 g = &
s->granules[ch][gr];
1340 int slen, slen1, slen2;
1345 ff_dlog(
s->avctx,
"slen1=%d slen2=%d\n", slen1, slen2);
1346 if (
g->block_type == 2) {
1347 n =
g->switch_point ? 17 : 18;
1350 for (
i = 0;
i < n;
i++)
1351 g->scale_factors[j++] =
get_bits(&
s->gb, slen1);
1353 for (
i = 0;
i < n;
i++)
1354 g->scale_factors[j++] = 0;
1357 for (
i = 0;
i < 18;
i++)
1358 g->scale_factors[j++] =
get_bits(&
s->gb, slen2);
1359 for (
i = 0;
i < 3;
i++)
1360 g->scale_factors[j++] = 0;
1362 for (
i = 0;
i < 21;
i++)
1363 g->scale_factors[j++] = 0;
1366 sc =
s->granules[ch][0].scale_factors;
1368 for (k = 0; k < 4; k++) {
1370 if ((
g->scfsi & (0x8 >> k)) == 0) {
1371 slen = (k < 2) ? slen1 : slen2;
1373 for (
i = 0;
i < n;
i++)
1374 g->scale_factors[j++] =
get_bits(&
s->gb, slen);
1376 for (
i = 0;
i < n;
i++)
1377 g->scale_factors[j++] = 0;
1381 for (
i = 0;
i < n;
i++) {
1382 g->scale_factors[j] = sc[j];
1387 g->scale_factors[j++] = 0;
1390 int tindex, tindex2, slen[4], sl, sf;
1393 if (
g->block_type == 2)
1394 tindex =
g->switch_point ? 2 : 1;
1398 sf =
g->scalefac_compress;
1405 }
else if (sf < 244) {
1417 }
else if (sf < 500) {
1428 for (k = 0; k < 4; k++) {
1432 for (
i = 0;
i < n;
i++)
1433 g->scale_factors[j++] =
get_bits(&
s->gb, sl);
1435 for (
i = 0;
i < n;
i++)
1436 g->scale_factors[j++] = 0;
1441 g->scale_factors[j] = 0;
1453 for (ch = 0; ch <
s->nb_channels; ch++) {
1454 g = &
s->granules[ch][gr];
1463 return nb_granules * 18;
1467 const uint8_t *buf,
int buf_size)
1469 int i, nb_frames, ch,
ret;
1473 if (
s->error_protection)
1478 s->avctx->frame_size = 384;
1482 s->avctx->frame_size = 1152;
1486 s->avctx->frame_size =
s->lsf ? 576 : 1152;
1491 if (
s->in_gb.buffer) {
1500 s->in_gb.buffer =
NULL;
1512 av_assert1(i <= buf_size - HEADER_SIZE && i >= 0);
1513 memcpy(
s->last_buf +
s->last_buf_size,
s->gb.buffer + buf_size -
HEADER_SIZE -
i,
i);
1514 s->last_buf_size +=
i;
1523 s->frame->nb_samples =
s->avctx->frame_size;
1530 for (ch = 0; ch <
s->nb_channels; ch++) {
1536 samples_ptr =
samples[0] + ch;
1537 sample_stride =
s->nb_channels;
1539 for (
i = 0;
i < nb_frames;
i++) {
1540 RENAME(ff_mpa_synth_filter)(&
s->mpadsp,
s->synth_buf[ch],
1541 &(
s->synth_buf_offset[ch]),
1542 RENAME(ff_mpa_synth_window),
1543 &
s->dither_state, samples_ptr,
1544 sample_stride,
s->sb_samples[ch][
i]);
1545 samples_ptr += 32 * sample_stride;
1549 return nb_frames * 32 *
sizeof(
OUT_INT) *
s->nb_channels;
1553 int *got_frame_ptr,
AVPacket *avpkt)
1555 const uint8_t *buf = avpkt->
data;
1556 int buf_size = avpkt->
size;
1562 while(buf_size && !*buf){
1574 return buf_size + skipped;
1580 }
else if (
ret == 1) {
1592 if (
s->frame_size <= 0) {
1595 }
else if (
s->frame_size < buf_size) {
1597 buf_size=
s->frame_size;
1620 return buf_size + skipped;
1625 memset(
ctx->synth_buf, 0,
sizeof(
ctx->synth_buf));
1626 memset(
ctx->mdct_buf, 0,
sizeof(
ctx->mdct_buf));
1627 ctx->last_buf_size = 0;
1628 ctx->dither_state = 0;
1636 #if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER
1638 int *got_frame_ptr,
AVPacket *avpkt)
1640 const uint8_t *buf = avpkt->
data;
1641 int buf_size = avpkt->
size;
1674 s->frame_size =
len;
1690 #if CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER
1695 typedef struct MP3On4DecodeContext {
1698 const uint8_t *coff;
1700 } MP3On4DecodeContext;
1707 static const uint8_t mp3Frames[8] = { 0, 1, 1, 2, 3, 3, 4, 5 };
1710 static const uint8_t chan_offset[8][5] = {
1722 static const int16_t chan_layout[8] = {
1738 for (
i = 0;
i <
s->frames;
i++)
1768 s->syncword = 0xffe00000;
1770 s->syncword = 0xfff00000;
1779 if (!
s->mp3decctx[0])
1788 s->mp3decctx[0]->adu_mode = 1;
1793 for (
i = 1;
i <
s->frames;
i++) {
1795 if (!
s->mp3decctx[
i])
1797 s->mp3decctx[
i]->adu_mode = 1;
1798 s->mp3decctx[
i]->avctx = avctx;
1799 s->mp3decctx[
i]->mpadsp =
s->mp3decctx[0]->mpadsp;
1800 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)
int frame_size
Number of samples per channel in an audio frame.
uint8_t scale_factors[40]
MPA_DECODE_HEADER uint8_t last_buf[LAST_BUF_SIZE]
static void compute_band_indexes(MPADecodeContext *s, GranuleDef *g)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int l3_unscale(int value, int exponent)
static void init_short_region(MPADecodeContext *s, GranuleDef *g)
#define AV_EF_EXPLODE
abort decoding on minor error detection
int ff_mpa_l2_select_table(int bitrate, int nb_channels, int freq, int lsf)
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame 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. Frame references ownership and permissions
void(* butterflies_float)(float *restrict v1, float *restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
#define AV_CHANNEL_LAYOUT_STEREO
int sample_rate
samples per second
GranuleDef granules[2][2]
static int l1_unscale(int n, int mant, int scale_factor)
#define AV_CH_LAYOUT_MONO
static void mp_flush(MPADecodeContext *ctx)
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static int get_bits_count(const GetBitContext *s)
av_cold void ff_mpadsp_init(MPADSPContext *s)
This structure describes decoded (raw) audio or video data.
int adu_mode
0 for standard mp3, 1 for adu formatted mp3
void(* butterflies_float)(float *restrict v1, float *restrict v2, int len)
static const uint16_t table[]
static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples, const uint8_t *buf, int buf_size)
static void compute_antialias(MPADecodeContext *s, GranuleDef *g)
static INTFLOAT is_table_lsf[2][2][16]
const int ff_mpa_quant_bits[17]
int nb_channels
Number of channels in this layout.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static float win(SuperEqualizerContext *s, float n, int N)
static av_cold void mpegaudio_tableinit(void)
static void skip_bits(GetBitContext *s, int n)
int8_t ff_table_4_3_exp[TABLE_4_3_SIZE]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void exponents_from_scale_factors(MPADecodeContext *s, GranuleDef *g, int16_t *exponents)
static void reorder_block(MPADecodeContext *s, GranuleDef *g)
static int mp_decode_layer3(MPADecodeContext *s)
AVChannelLayout ch_layout
Audio channel layout.
if it could not because there are no more frames
#define AV_EF_BITSTREAM
detect bitstream specification deviations
int flags
AV_CODEC_FLAG_*.
static double val(void *priv, double ch)
#define AV_CH_LAYOUT_STEREO
const uint8_t ff_slen_table[2][16]
static int bit_alloc(AC3EncodeContext *s, int snr_offset)
Run the bit allocation with a given SNR offset.
static int ff_thread_once(char *control, void(*routine)(void))
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const int ff_mpa_quant_steps[17]
static void compute_imdct(MPADecodeContext *s, GranuleDef *g, INTFLOAT *sb_samples, INTFLOAT *mdct_buf)
static void imdct12(INTFLOAT *out, SUINTFLOAT *in)
#define MODE_EXT_MS_STEREO
const uint8_t ff_mpa_huff_data[32][2]
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.
void ff_mpegaudiodec_common_init_static(void)
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.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int64_t fsize(FILE *f)
const unsigned char *const ff_mpa_alloc_tables[5]
#define SPLIT(dst, sf, n)
static void compute_stereo(MPADecodeContext *s, GranuleDef *g0, GranuleDef *g1)
static int huffman_decode(MPADecodeContext *s, GranuleDef *g, int16_t *exponents, int end_pos2)
int64_t bit_rate
the average bitrate
int sb_hybrid[SBLIMIT *18]
static unsigned int get_bits1(GetBitContext *s)
static int mp_decode_layer1(MPADecodeContext *s)
#define AV_CH_LAYOUT_5POINT1
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
An AVChannelLayout holds information about the channel layout of audio data.
#define DECLARE_ALIGNED(n, t, v)
static int shift(int a, int b)
static av_always_inline void lsf_sf_expand(int *slen, int sf, int n1, int n2, int n3)
int16_t *const ff_division_tabs[4]
enum AVSampleFormat sample_fmt
audio sample format
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_RB32
#define READ_FLIP_SIGN(dst, src)
static const uint8_t header[24]
uint32_t free_format_next_header
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
enum AVSampleFormat request_sample_fmt
desired sample format
static av_cold void decode_init_static(void)
static int handle_crc(MPADecodeContext *s, int sec_len)
#define AV_LOG_INFO
Standard information.
static int32_t scale_factor_mult[15][3]
#define AV_CH_LAYOUT_5POINT0
static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
const int ff_mpa_sblimit_table[5]
uint8_t ** extended_data
pointers to the data planes/channels.
static const int32_t is_table[2][16]
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define AV_CH_LAYOUT_7POINT1
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
MPA_INT synth_buf[MPA_MAX_CHANNELS][512 *2]
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
uint16_t ff_band_index_long[9][23]
static int mod(int a, int b)
Modulo operation with only positive remainders.
static double bound(const double threshold, const double val)
#define AV_EF_AGGRESSIVE
consider things that a sane encoder/muxer should not do as an error
#define AV_CH_LAYOUT_SURROUND
static const uint8_t * align_get_bits(GetBitContext *s)
uint32_t ff_table_4_3_value[TABLE_4_3_SIZE]
static const int16_t steps[16]
main external API structure.
int synth_buf_offset[MPA_MAX_CHANNELS]
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
const uint8_t ff_mpa_pretab[2][22]
static void region_offset2size(GranuleDef *g)
Convert region offsets to region sizes and truncate size to big_values.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
static void init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2)
#define MODE_EXT_I_STEREO
static int alloc_table(VLC *vlc, int size, int use_static)
const VLCElem * ff_huff_vlc[16]
static void flush(AVCodecContext *avctx)
Filter the word “frame” indicates either a video frame or a group of audio samples
static int l2_unscale_group(int steps, int mant, int scale_factor)
int sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]
uint8_t count1table_select
const uint8_t ff_band_size_long[9][22]
uint16_t ff_scale_factor_modshift[64]
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
#define AV_EF_BUFFER
detect improper bitstream length
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define avpriv_request_sample(...)
#define AV_CHANNEL_LAYOUT_MONO
This structure stores compressed data.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
const uint8_t ff_lsf_nsf_table[6][3][4]
static av_cold int decode_init(AVCodecContext *avctx)
#define AV_CH_LAYOUT_4POINT0
static const int32_t scale_factor_mult2[3][3]
const uint8_t ff_band_size_short[9][13]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
INTFLOAT mdct_buf[MPA_MAX_CHANNELS][SBLIMIT *18]
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
#define MPA_MAX_CODED_FRAME_SIZE
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
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_RB16
static int mp_decode_layer2(MPADecodeContext *s)