50 #define BACKSTEP_SIZE 512 52 #define LAST_BUF_SIZE 2 * BACKSTEP_SIZE + EXTRABYTES 93 void (*butterflies_float)(
float *av_restrict v1,
float *av_restrict v2,
int len);
110 #define SCALE_GEN(v) \ 111 { FIXR_OLD(1.0 * (v)), FIXR_OLD(0.7937005259 * (v)), FIXR_OLD(0.6299605249 * (v)) } 127 for (i = 0; i < 3; i++) {
137 if (s->sample_rate_index != 8)
142 if (s->sample_rate_index <= 2)
144 else if (s->sample_rate_index != 8)
158 l =
FFMIN(ra1 + ra2 + 2, 22);
166 if(s->sample_rate_index == 8)
171 if (s->sample_rate_index <= 2)
189 static inline int l1_unscale(
int n,
int mant,
int scale_factor)
200 return (
int)((val + (1LL << (shift - 1))) >> shift);
214 val = (val + (1 << (shift - 1))) >> shift;
233 m = (m + ((1U << e) >> 1)) >> e;
243 for (i = 0; i < 15; i++) {
246 norm = ((INT64_C(1) << n) *
FRAC_ONE) / ((1 << n) - 1);
250 ff_dlog(
NULL,
"%d: norm=%x s=%"PRIx32
" %"PRIx32
" %"PRIx32
"\n", i,
261 for (i = 0; i < 16; i++) {
265 for (j = 0; j < 2; j++) {
266 e = -(j + 1) * ((i + 1) >> 1);
276 RENAME(ff_mpa_synth_init)();
315 #define C3 FIXHR(0.86602540378443864676/2) 316 #define C4 FIXHR(0.70710678118654752439/2) //0.5 / cos(pi*(9)/36) 317 #define C5 FIXHR(0.51763809020504152469/2) //0.5 / cos(pi*(5)/36) 318 #define C6 FIXHR(1.93185165257813657349/4) //0.5 / cos(pi*(15)/36) 327 in1 = in[1*3] + in[0*3];
328 in2 = in[2*3] + in[1*3];
329 in3 = in[3*3] + in[2*3];
330 in4 = in[4*3] + in[3*3];
331 in5 = in[5*3] + in[4*3];
367 int sec_byte_len = sec_len >> 3;
368 int sec_rem_bits = sec_len & 7;
371 uint32_t crc_val =
av_crc(crc_tab, UINT16_MAX, &buf[2], 2);
372 crc_val =
av_crc(crc_tab, crc_val, &buf[6], sec_byte_len);
375 ((buf[6 + sec_byte_len] & (0xFF00 >> sec_rem_bits)) << 24) +
376 ((s->
crc << 16) >> sec_rem_bits));
378 crc_val =
av_crc(crc_tab, crc_val, tmp_buf, 3);
392 int bound,
i, v, n, ch, j, mant;
397 ret =
handle_crc(s, (s->nb_channels == 1) ? 8*16 : 8*32);
402 bound = (s->mode_ext + 1) * 4;
407 for (i = 0; i <
bound; i++) {
408 for (ch = 0; ch < s->nb_channels; ch++) {
412 for (i = bound; i <
SBLIMIT; i++)
416 for (i = 0; i <
bound; i++) {
417 for (ch = 0; ch < s->nb_channels; ch++) {
418 if (allocation[ch][i])
422 for (i = bound; i <
SBLIMIT; i++) {
423 if (allocation[0][i]) {
430 for (j = 0; j < 12; j++) {
431 for (i = 0; i <
bound; i++) {
432 for (ch = 0; ch < s->nb_channels; ch++) {
433 n = allocation[ch][
i];
436 v =
l1_unscale(n, mant, scale_factors[ch][i]);
443 for (i = bound; i <
SBLIMIT; i++) {
444 n = allocation[0][
i];
468 int scale, qindex,
bits, steps, k, l, m,
b;
473 s->sample_rate, s->lsf);
478 bound = (s->mode_ext + 1) * 4;
482 ff_dlog(s->
avctx,
"bound=%d sblimit=%d\n", bound, sblimit);
490 for (i = 0; i <
bound; i++) {
491 bit_alloc_bits = alloc_table[j];
492 for (ch = 0; ch < s->nb_channels; ch++)
493 bit_alloc[ch][i] =
get_bits(&s->
gb, bit_alloc_bits);
494 j += 1 << bit_alloc_bits;
496 for (i = bound; i < sblimit; i++) {
497 bit_alloc_bits = alloc_table[j];
501 j += 1 << bit_alloc_bits;
505 for (i = 0; i < sblimit; i++) {
506 for (ch = 0; ch < s->nb_channels; ch++) {
507 if (bit_alloc[ch][i])
517 for (i = 0; i < sblimit; i++) {
518 for (ch = 0; ch < s->nb_channels; ch++) {
519 if (bit_alloc[ch][i]) {
520 sf = scale_factors[ch][
i];
521 switch (scale_code[ch][i]) {
549 for (k = 0; k < 3; k++) {
550 for (l = 0; l < 12; l += 3) {
552 for (i = 0; i <
bound; i++) {
553 bit_alloc_bits = alloc_table[j];
554 for (ch = 0; ch < s->nb_channels; ch++) {
555 b = bit_alloc[ch][
i];
557 scale = scale_factors[ch][
i][k];
558 qindex = alloc_table[j+
b];
574 for (m = 0; m < 3; m++) {
587 j += 1 << bit_alloc_bits;
590 for (i = bound; i < sblimit; i++) {
591 bit_alloc_bits = alloc_table[j];
594 int mant, scale0, scale1;
595 scale0 = scale_factors[0][
i][k];
596 scale1 = scale_factors[1][
i][k];
597 qindex = alloc_table[j +
b];
620 for (m = 0; m < 3; m++) {
637 j += 1 << bit_alloc_bits;
640 for (i = sblimit; i <
SBLIMIT; i++) {
641 for (ch = 0; ch < s->nb_channels; ch++) {
652 #define SPLIT(dst,sf,n) \ 654 int m = (sf * 171) >> 9; \ 657 } else if (n == 4) { \ 660 } else if (n == 5) { \ 661 int m = (sf * 205) >> 10; \ 664 } else if (n == 6) { \ 665 int m = (sf * 171) >> 10; \ 675 SPLIT(slen[3], sf, n3)
676 SPLIT(slen[2], sf, n2)
677 SPLIT(slen[1], sf, n1)
697 for (j = len; j > 0; j--)
709 for (l = 0; l < 3; l++) {
711 for (j = len; j > 0; j--)
740 #define READ_FLIP_SIGN(dst,src) \ 741 v = AV_RN32A(src) ^ (get_bits1(&s->gb) << 31); \ 744 #define READ_FLIP_SIGN(dst,src) \ 745 v = -get_bits1(&s->gb); \ 746 *(dst) = (*(src) ^ v) - v; 750 int16_t *exponents,
int end_pos2)
754 int last_pos, bits_left;
760 for (i = 0; i < 3; i++) {
761 int j, k, l, linbits;
797 exponent= exponents[s_index];
844 while (s_index <= 572) {
847 if (pos >= end_pos) {
848 if (pos > end_pos2 && last_pos) {
853 av_log(s->
avctx,
AV_LOG_INFO,
"overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos);
871 static const int idxtab[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 };
873 int pos = s_index + idxtab[
code];
874 code ^= 8 >> idxtab[
code];
910 if (s->sample_rate_index != 8)
922 for (j = len; j > 0; j--) {
929 memcpy(ptr1, tmp, len * 3 *
sizeof(*ptr1));
933 #define ISQRT2 FIXR(0.70710678118654752440) 938 int sf_max, sf,
len, non_zero_found;
942 int non_zero_found_short[3];
957 non_zero_found_short[0] = 0;
958 non_zero_found_short[1] = 0;
959 non_zero_found_short[2] = 0;
966 for (l = 2; l >= 0; l--) {
969 if (!non_zero_found_short[l]) {
971 for (j = 0; j <
len; j++) {
973 non_zero_found_short[l] = 1;
983 for (j = 0; j <
len; j++) {
993 for (j = 0; j <
len; j++) {
1004 non_zero_found = non_zero_found_short[0] |
1005 non_zero_found_short[1] |
1006 non_zero_found_short[2];
1008 for (i = g1->
long_end - 1;i >= 0;i--) {
1013 if (!non_zero_found) {
1014 for (j = 0; j <
len; j++) {
1021 k = (i == 21) ? 20 : i;
1027 for (j = 0; j <
len; j++) {
1037 for (j = 0; j <
len; j++) {
1055 for (i = 0; i < 576; i++) {
1058 tab0[
i] = tmp0 + tmp1;
1059 tab1[
i] = tmp0 - tmp1;
1075 #ifndef compute_antialias 1077 #define AA(j) do { \ 1078 float tmp0 = ptr[-1-j]; \ 1079 float tmp1 = ptr[ j]; \ 1080 ptr[-1-j] = tmp0 * csa_table[j][0] - tmp1 * csa_table[j][1]; \ 1081 ptr[ j] = tmp0 * csa_table[j][1] + tmp1 * csa_table[j][0]; \ 1084 #define AA(j) do { \ 1085 SUINT tmp0 = ptr[-1-j]; \ 1086 SUINT tmp1 = ptr[ j]; \ 1087 SUINT tmp2 = MULH(tmp0 + tmp1, csa_table[j][0]); \ 1088 ptr[-1-j] = 4 * (tmp2 - MULH(tmp1, csa_table[j][2])); \ 1089 ptr[ j] = 4 * (tmp2 + MULH(tmp0, csa_table[j][3])); \ 1109 for (i = n; i > 0; i--) {
1129 int i, j, mdct_long_end, sblimit;
1134 while (ptr >= ptr1) {
1138 if (p[0] | p[1] | p[2] | p[3] | p[4] | p[5])
1141 sblimit = ((ptr - g->
sb_hybrid) / 18) + 1;
1150 mdct_long_end = sblimit;
1157 buf = mdct_buf + 4*18*(mdct_long_end >> 2) + (mdct_long_end & 3);
1158 ptr = g->
sb_hybrid + 18 * mdct_long_end;
1160 for (j = mdct_long_end; j < sblimit; j++) {
1162 win =
RENAME(ff_mdct_win)[2 + (4 & -(j & 1))];
1163 out_ptr = sb_samples + j;
1165 for (i = 0; i < 6; i++) {
1166 *out_ptr = buf[4*
i];
1170 for (i = 0; i < 6; i++) {
1171 *out_ptr =
MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*1)];
1172 buf[4*(i + 6*2)] =
MULH3(out2[i + 6], win[i + 6], 1);
1176 for (i = 0; i < 6; i++) {
1177 *out_ptr =
MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*2)];
1178 buf[4*(i + 6*0)] =
MULH3(out2[i + 6], win[i + 6], 1);
1182 for (i = 0; i < 6; i++) {
1183 buf[4*(i + 6*0)] =
MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*0)];
1184 buf[4*(i + 6*1)] =
MULH3(out2[i + 6], win[i + 6], 1);
1185 buf[4*(i + 6*2)] = 0;
1188 buf += (j&3) != 3 ? 1 : (4*18-3);
1191 for (j = sblimit; j <
SBLIMIT; j++) {
1193 out_ptr = sb_samples + j;
1194 for (i = 0; i < 18; i++) {
1195 *out_ptr = buf[4*
i];
1199 buf += (j&3) != 3 ? 1 : (4*18-3);
1206 int nb_granules, main_data_begin;
1207 int gr, ch, blocksplit_flag,
i, j, k, n, bits_pos;
1209 int16_t exponents[576];
1214 ret =
handle_crc(s, ((s->nb_channels == 1) ? 8*9 : 8*17));
1219 ret =
handle_crc(s, ((s->nb_channels == 1) ? 8*17 : 8*32));
1221 if (s->nb_channels == 2)
1226 for (ch = 0; ch < s->nb_channels; ch++) {
1234 for (gr = 0; gr < nb_granules; gr++) {
1235 for (ch = 0; ch < s->nb_channels; ch++) {
1256 if (blocksplit_flag) {
1263 for (i = 0; i < 2; i++)
1265 for (i = 0; i < 3; i++)
1269 int region_address1, region_address2;
1272 for (i = 0; i < 3; i++)
1278 region_address1, region_address2);
1308 for (gr = 0; gr < nb_granules && (s->
last_buf_size >> 3) < main_data_begin; gr++) {
1309 for (ch = 0; ch < s->nb_channels; ch++) {
1330 for (; gr < nb_granules; gr++) {
1331 for (ch = 0; ch < s->nb_channels; ch++) {
1337 int slen, slen1, slen2;
1342 ff_dlog(s->
avctx,
"slen1=%d slen2=%d\n", slen1, slen2);
1347 for (i = 0; i < n; i++)
1350 for (i = 0; i < n; i++)
1354 for (i = 0; i < 18; i++)
1356 for (i = 0; i < 3; i++)
1359 for (i = 0; i < 21; i++)
1365 for (k = 0; k < 4; k++) {
1367 if ((g->
scfsi & (0x8 >> k)) == 0) {
1368 slen = (k < 2) ? slen1 : slen2;
1370 for (i = 0; i < n; i++)
1373 for (i = 0; i < n; i++)
1378 for (i = 0; i < n; i++) {
1387 int tindex, tindex2, slen[4], sl, sf;
1402 }
else if (sf < 244) {
1414 }
else if (sf < 500) {
1425 for (k = 0; k < 4; k++) {
1429 for (i = 0; i < n; i++)
1432 for (i = 0; i < n; i++)
1450 for (ch = 0; ch < s->nb_channels; ch++) {
1460 return nb_granules * 18;
1464 const uint8_t *buf,
int buf_size)
1466 int i, nb_frames, ch,
ret;
1470 if (s->error_protection)
1509 av_assert1(i <= buf_size - HEADER_SIZE && i >= 0);
1527 for (ch = 0; ch < s->nb_channels; ch++) {
1530 samples_ptr = samples[ch];
1533 samples_ptr = samples[0] + ch;
1534 sample_stride = s->nb_channels;
1536 for (i = 0; i < nb_frames; i++) {
1539 RENAME(ff_mpa_synth_window),
1542 samples_ptr += 32 * sample_stride;
1546 return nb_frames * 32 *
sizeof(
OUT_INT) * s->nb_channels;
1553 int buf_size = avpkt->
size;
1559 while(buf_size && !*buf){
1569 if (header >> 8 ==
AV_RB32(
"TAG") >> 8) {
1571 return buf_size + skipped;
1577 }
else if (ret == 1) {
1588 if (s->frame_size <= 0) {
1591 }
else if (s->frame_size < buf_size) {
1593 buf_size= s->frame_size;
1616 return buf_size + skipped;
1632 #if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER 1634 int *got_frame_ptr,
AVPacket *avpkt)
1637 int buf_size = avpkt->
size;
1656 header =
AV_RB32(buf) | 0xffe00000;
1670 s->frame_size =
len;
1686 #if CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER 1691 typedef struct MP3On4DecodeContext {
1696 } MP3On4DecodeContext;
1703 static const uint8_t mp3Frames[8] = { 0, 1, 1, 2, 3, 3, 4, 5 };
1706 static const uint8_t chan_offset[8][5] = {
1718 static const int16_t chan_layout[8] = {
1734 for (i = 0; i < s->frames; i++)
1764 s->syncword = 0xffe00000;
1766 s->syncword = 0xfff00000;
1775 if (!s->mp3decctx[0])
1784 s->mp3decctx[0]->adu_mode = 1;
1789 for (i = 1; i < s->frames; i++) {
1791 if (!s->mp3decctx[i])
1793 s->mp3decctx[
i]->adu_mode = 1;
1794 s->mp3decctx[
i]->avctx = avctx;
1795 s->mp3decctx[
i]->mpadsp = s->mp3decctx[0]->mpadsp;
1796 s->mp3decctx[
i]->butterflies_float = s->mp3decctx[0]->butterflies_float;
1808 for (i = 0; i < s->frames; i++)
1814 int *got_frame_ptr,
AVPacket *avpkt)
1818 int buf_size = avpkt->
size;
1840 for (fr = 0; fr < s->frames; fr++) {
1843 m = s->mp3decctx[fr];
1850 header = (
AV_RB32(buf) & 0x000fffff) | s->syncword;
1858 if (ch + m->nb_channels > avctx->
channels ||
1859 s->coff[fr] + m->nb_channels > avctx->
channels) {
1864 ch += m->nb_channels;
1866 outptr[0] = out_samples[s->coff[fr]];
1867 if (m->nb_channels > 1)
1868 outptr[1] = out_samples[s->coff[fr] + 1];
1873 if (m->nb_channels > 1)
1890 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]
#define AV_EF_AGGRESSIVE
consider things that a sane encoder should not do as an error
static double bound(const double threshold, const double val)
#define AV_CH_LAYOUT_7POINT1
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
Reference: libavcodec/mpegaudiodec.c.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
#define AV_CH_LAYOUT_SURROUND
static float win(SuperEqualizerContext *s, float n, int N)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
const uint8_t ff_band_size_short[9][13]
static void exponents_from_scale_factors(MPADecodeContext *s, GranuleDef *g, int16_t *exponents)
#define avpriv_request_sample(...)
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
#define AV_EF_BUFFER
detect improper bitstream length
const int ff_mpa_quant_bits[17]
#define AV_CH_LAYOUT_4POINT0
#define AV_EF_BITSTREAM
detect bitstream specification deviations
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#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]
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
if it could not because there are no more frames
#define AV_CH_LAYOUT_5POINT0
mpeg audio layer common tables.
Macro definitions for various function/variable attributes.
void ff_mpegaudiodec_common_init_static(void)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
enum AVSampleFormat sample_fmt
audio sample format
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. ...
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
const uint8_t ff_mpeg4audio_channels[14]
const int ff_mpa_quant_steps[17]
static int l2_unscale_group(int steps, int mant, int scale_factor)
static av_cold void mpegaudio_tableinit(void)
GLsizei GLboolean const GLfloat * value
const unsigned char *const ff_mpa_alloc_tables[5]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int8_t ff_table_4_3_exp[TABLE_4_3_SIZE]
#define SPLIT(dst, sf, n)
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
Public header for CRC hash function implementation.
static int l3_unscale(int value, int exponent)
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2)
static const uint8_t header[24]
static int bit_alloc(AC3EncodeContext *s, int snr_offset)
Run the bit allocation with a given SNR offset.
static const uint16_t table[]
#define AV_CH_LAYOUT_5POINT1
const uint8_t ff_slen_table[2][16]
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define MODE_EXT_MS_STEREO
static int handle_crc(MPADecodeContext *s, int sec_len)
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
void(* butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len)
const uint8_t ff_mpa_huff_data[32][2]
enum AVSampleFormat request_sample_fmt
desired sample format
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static void init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2)
static av_cold int decode_init(AVCodecContext *avctx)
int flags
AV_CODEC_FLAG_*.
simple assert() macros that are a bit more flexible than ISO C assert().
uint64_t channel_layout
Audio channel layout.
static const int32_t scale_factor_mult2[3][3]
#define READ_FLIP_SIGN(dst, src)
audio channel layout utility functions
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
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 compute_band_indexes(MPADecodeContext *s, GranuleDef *g)
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
uint32_t free_format_next_header
Reference: libavcodec/mpegaudiodec.c.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
static int mp_decode_layer2(MPADecodeContext *s)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
#define AV_EF_EXPLODE
abort decoding on minor error detection
static const int32_t is_table[2][16]
int frame_size
Number of samples per channel in an audio frame.
#define AV_LOG_INFO
Standard information.
int16_t *const ff_division_tabs[4]
Libavcodec external API header.
int sb_hybrid[SBLIMIT *18]
int sample_rate
samples per second
MPA_INT synth_buf[MPA_MAX_CHANNELS][512 *2]
static int mp_decode_layer3(MPADecodeContext *s)
static int mod(int a, int b)
Modulo operation with only positive remainders.
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)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
void(* butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
static void mp_flush(MPADecodeContext *ctx)
Replacements for frequently missing libm functions.
uint16_t ff_band_index_long[9][23]
static void reorder_block(MPADecodeContext *s, GranuleDef *g)
static unsigned int get_bits1(GetBitContext *s)
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=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;}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_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);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_log(ac->avr, AV_LOG_TRACE,"%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-> in
uint8_t count1table_select
static void skip_bits(GetBitContext *s, int n)
#define MODE_EXT_I_STEREO
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data...
uint16_t ff_scale_factor_modshift[64]
static INTFLOAT is_table_lsf[2][2][16]
static void init_short_region(MPADecodeContext *s, GranuleDef *g)
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
static void compute_stereo(MPADecodeContext *s, GranuleDef *g0, GranuleDef *g1)
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
static void compute_imdct(MPADecodeContext *s, GranuleDef *g, INTFLOAT *sb_samples, INTFLOAT *mdct_buf)
common internal api header.
uint32_t ff_table_4_3_value[TABLE_4_3_SIZE]
static void imdct12(INTFLOAT *out, SUINTFLOAT *in)
mpeg audio declarations for both encoder and decoder.
const int ff_mpa_sblimit_table[5]
const uint8_t ff_mpa_pretab[2][22]
INTFLOAT mdct_buf[MPA_MAX_CHANNELS][SBLIMIT *18]
static int mp_decode_layer1(MPADecodeContext *s)
int ff_mpa_l2_select_table(int bitrate, int nb_channels, int freq, int lsf)
int channels
number of audio channels
static int ff_thread_once(char *control, void(*routine)(void))
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)
const uint8_t ff_band_size_long[9][22]
Filter the word “frame” indicates either a video frame or a group of audio samples
static int huffman_decode(MPADecodeContext *s, GranuleDef *g, int16_t *exponents, int end_pos2)
static int64_t fsize(FILE *f)
static int l1_unscale(int n, int mant, int scale_factor)
int sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]
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
uint8_t ** extended_data
pointers to the data planes/channels.
#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.
static double val(void *priv, double ch)
This structure stores compressed data.
av_cold void ff_mpadsp_init(MPADSPContext *s)
const uint8_t ff_lsf_nsf_table[6][3][4]
int nb_samples
number of audio samples (per channel) described by this frame
static void flush(AVCodecContext *avctx)
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
static int alloc_table(VLC *vlc, int size, int use_static)
int adu_mode
0 for standard mp3, 1 for adu formatted mp3
GranuleDef granules[2][2]