MPEG Audio decoder. More...
#include "libavutil/audioconvert.h"
#include "avcodec.h"
#include "get_bits.h"
#include "mathops.h"
#include "mpegaudiodsp.h"
#include "mpegaudio.h"
#include "mpegaudiodecheader.h"
#include "mpegaudiodata.h"
#include "mpegaudiodectab.h"
#include "mpegaudio_tablegen.h"
#include "mpeg4audio.h"
Go to the source code of this file.
Data Structures | |
struct | GranuleDef |
struct | MPADecodeContext |
struct | MP3On4DecodeContext |
Context for MP3On4 decoder. More... | |
Defines | |
#define | BACKSTEP_SIZE 512 |
#define | EXTRABYTES 24 |
#define | LAST_BUF_SIZE 2 * BACKSTEP_SIZE + EXTRABYTES |
#define | SHR(a, b) ((a)>>(b)) |
#define | FIXR_OLD(a) ((int)((a) * FRAC_ONE + 0.5)) |
#define | FIXR(a) ((int)((a) * FRAC_ONE + 0.5)) |
#define | FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) |
#define | MULH3(x, y, s) MULH((s)*(x), y) |
#define | MULLx(x, y, s) MULL(x,y,s) |
#define | RENAME(a) a ## _fixed |
#define | OUT_FMT AV_SAMPLE_FMT_S16 |
#define | HEADER_SIZE 4 |
#define | SCALE_GEN(v) { FIXR_OLD(1.0 * (v)), FIXR_OLD(0.7937005259 * (v)), FIXR_OLD(0.6299605249 * (v)) } |
#define | C3 FIXHR(0.86602540378443864676/2) |
#define | C4 FIXHR(0.70710678118654752439/2) |
#define | C5 FIXHR(0.51763809020504152469/2) |
#define | C6 FIXHR(1.93185165257813657349/4) |
#define | SPLIT(dst, sf, n) |
#define | READ_FLIP_SIGN(dst, src) |
#define | ISQRT2 FIXR(0.70710678118654752440) |
#define | AA(j) |
Typedefs | |
typedef struct GranuleDef | GranuleDef |
typedef struct MPADecodeContext | MPADecodeContext |
typedef struct MP3On4DecodeContext | MP3On4DecodeContext |
Context for MP3On4 decoder. | |
Functions | |
static void | ff_region_offset2size (GranuleDef *g) |
Convert region offsets to region sizes and truncate size to big_values. | |
static void | ff_init_short_region (MPADecodeContext *s, GranuleDef *g) |
static void | ff_init_long_region (MPADecodeContext *s, GranuleDef *g, int ra1, int ra2) |
static void | ff_compute_band_indexes (MPADecodeContext *s, GranuleDef *g) |
static int | l1_unscale (int n, int mant, int scale_factor) |
static int | l2_unscale_group (int steps, int mant, int scale_factor) |
static int | l3_unscale (int value, int exponent) |
static av_cold void | decode_init_static (void) |
static av_cold int | decode_init (AVCodecContext *avctx) |
static void | imdct12 (INTFLOAT *out, INTFLOAT *in) |
static int | mp_decode_layer1 (MPADecodeContext *s) |
static int | mp_decode_layer2 (MPADecodeContext *s) |
static av_always_inline void | lsf_sf_expand (int *slen, int sf, int n1, int n2, int n3) |
static void | exponents_from_scale_factors (MPADecodeContext *s, GranuleDef *g, int16_t *exponents) |
static int | get_bitsz (GetBitContext *s, int n) |
static void | switch_buffer (MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2) |
static int | huffman_decode (MPADecodeContext *s, GranuleDef *g, int16_t *exponents, int end_pos2) |
static void | reorder_block (MPADecodeContext *s, GranuleDef *g) |
static void | compute_stereo (MPADecodeContext *s, GranuleDef *g0, GranuleDef *g1) |
static void | compute_antialias (MPADecodeContext *s, GranuleDef *g) |
static void | compute_imdct (MPADecodeContext *s, GranuleDef *g, INTFLOAT *sb_samples, INTFLOAT *mdct_buf) |
static int | mp_decode_layer3 (MPADecodeContext *s) |
static int | mp_decode_frame (MPADecodeContext *s, OUT_INT *samples, const uint8_t *buf, int buf_size) |
static int | decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) |
static void | flush (AVCodecContext *avctx) |
static int | decode_frame_adu (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) |
static av_cold int | decode_close_mp3on4 (AVCodecContext *avctx) |
static int | decode_init_mp3on4 (AVCodecContext *avctx) |
static void | flush_mp3on4 (AVCodecContext *avctx) |
static int | decode_frame_mp3on4 (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) |
Variables | |
static VLC | huff_vlc [16] |
static VLC_TYPE | huff_vlc_tables [0+128+128+128+130+128+154+166+142+204+190+170+542+460+662+414][2] |
static const int | huff_vlc_tables_sizes [16] |
static VLC | huff_quad_vlc [2] |
static VLC_TYPE | huff_quad_vlc_tables [128+16][2] |
static const int | huff_quad_vlc_tables_sizes [2] = { 128, 16 } |
static uint16_t | band_index_long [9][23] |
static INTFLOAT | is_table [2][16] |
static INTFLOAT | is_table_lsf [2][2][16] |
static INTFLOAT | csa_table [8][4] |
static int16_t | division_tab3 [1<< 6] |
static int16_t | division_tab5 [1<< 8] |
static int16_t | division_tab9 [1<< 11] |
static int16_t *const | division_tabs [4] |
static uint16_t | scale_factor_modshift [64] |
static int32_t | scale_factor_mult [15][3] |
static const int32_t | scale_factor_mult2 [3][3] |
static const uint8_t | mp3Frames [8] = { 0, 1, 1, 2, 3, 3, 4, 5 } |
static const uint8_t | chan_offset [8][5] |
static const int16_t | chan_layout [8] |
AVCodec | ff_mp1_decoder |
AVCodec | ff_mp2_decoder |
AVCodec | ff_mp3_decoder |
AVCodec | ff_mp3adu_decoder |
AVCodec | ff_mp3on4_decoder |
MPEG Audio decoder.
Definition in file mpegaudiodec.c.
#define AA | ( | j | ) |
do { \ int tmp0 = ptr[-1-j]; \ int tmp1 = ptr[ j]; \ int tmp2 = MULH(tmp0 + tmp1, csa_table[j][0]); \ ptr[-1-j] = 4 * (tmp2 - MULH(tmp1, csa_table[j][2])); \ ptr[ j] = 4 * (tmp2 + MULH(tmp0, csa_table[j][3])); \ } while (0)
Definition at line 1175 of file mpegaudiodec.c.
Referenced by compute_antialias().
#define BACKSTEP_SIZE 512 |
Definition at line 41 of file mpegaudiodec.c.
Referenced by mp_decode_frame().
#define C3 FIXHR(0.86602540378443864676/2) |
Definition at line 448 of file mpegaudiodec.c.
Referenced by imdct12().
#define C4 FIXHR(0.70710678118654752439/2) |
Definition at line 449 of file mpegaudiodec.c.
Referenced by imdct12().
#define C5 FIXHR(0.51763809020504152469/2) |
Definition at line 450 of file mpegaudiodec.c.
Referenced by imdct12().
#define C6 FIXHR(1.93185165257813657349/4) |
Definition at line 451 of file mpegaudiodec.c.
Referenced by imdct12().
#define EXTRABYTES 24 |
Definition at line 42 of file mpegaudiodec.c.
#define FIXHR | ( | a | ) | ((int)((a) * (1LL<<32) + 0.5)) |
Definition at line 100 of file mpegaudiodec.c.
Referenced by decode_init_static().
#define FIXR | ( | a | ) | ((int)((a) * FRAC_ONE + 0.5)) |
Definition at line 99 of file mpegaudiodec.c.
Referenced by decode_init_static().
#define FIXR_OLD | ( | a | ) | ((int)((a) * FRAC_ONE + 0.5)) |
Definition at line 98 of file mpegaudiodec.c.
#define HEADER_SIZE 4 |
Definition at line 109 of file mpegaudiodec.c.
Referenced by decode_frame(), decode_frame_adu(), decode_frame_mp3on4(), and mp_decode_frame().
#define ISQRT2 FIXR(0.70710678118654752440) |
Definition at line 1041 of file mpegaudiodec.c.
Referenced by compute_stereo().
#define LAST_BUF_SIZE 2 * BACKSTEP_SIZE + EXTRABYTES |
Definition at line 43 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
#define MULH3 | ( | x, | ||
y, | ||||
s | ||||
) | MULH((s)*(x), y) |
Definition at line 101 of file mpegaudiodec.c.
Referenced by compute_imdct(), and imdct12().
#define MULLx | ( | x, | ||
y, | ||||
s | ||||
) | MULL(x,y,s) |
Definition at line 102 of file mpegaudiodec.c.
Referenced by compute_stereo(), and decode_init_static().
#define OUT_FMT AV_SAMPLE_FMT_S16 |
Definition at line 104 of file mpegaudiodec.c.
#define READ_FLIP_SIGN | ( | dst, | ||
src | ||||
) |
Definition at line 847 of file mpegaudiodec.c.
Referenced by huffman_decode().
#define RENAME | ( | a | ) | a ## _fixed |
Definition at line 103 of file mpegaudiodec.c.
Referenced by bgr24ToUV_MMX(), compute_imdct(), decode_init_static(), huffman_decode(), mp_decode_frame(), postProcess_3DNow(), rgb24ToUV_MMX(), rgb2rgb_init_3DNOW(), sws_init_swScale_MMX(), uyvytoyuv420_3DNOW(), uyvytoyuv422_3DNOW(), yuv422ptouyvy_3DNOW(), yuv422ptoyuy2_3DNOW(), yuyvtoyuv420_3DNOW(), yuyvtoyuv422_3DNOW(), yv12touyvy_3DNOW(), and yv12toyuy2_3DNOW().
#define SCALE_GEN | ( | v | ) | { FIXR_OLD(1.0 * (v)), FIXR_OLD(0.7937005259 * (v)), FIXR_OLD(0.6299605249 * (v)) } |
Definition at line 149 of file mpegaudiodec.c.
#define SHR | ( | a, | ||
b | ||||
) | ((a)>>(b)) |
Definition at line 96 of file mpegaudiodec.c.
Referenced by imdct12().
#define SPLIT | ( | dst, | ||
sf, | ||||
n | ||||
) |
if (n == 3) { \ int m = (sf * 171) >> 9; \ dst = sf - 3 * m; \ sf = m; \ } else if (n == 4) { \ dst = sf & 3; \ sf >>= 2; \ } else if (n == 5) { \ int m = (sf * 205) >> 10; \ dst = sf - 5 * m; \ sf = m; \ } else if (n == 6) { \ int m = (sf * 171) >> 10; \ dst = sf - 6 * m; \ sf = m; \ } else { \ dst = 0; \ }
Definition at line 749 of file mpegaudiodec.c.
Referenced by avfilter_register_all(), and lsf_sf_expand().
typedef struct GranuleDef GranuleDef |
typedef struct MP3On4DecodeContext MP3On4DecodeContext |
Context for MP3On4 decoder.
typedef struct MPADecodeContext MPADecodeContext |
static void compute_antialias | ( | MPADecodeContext * | s, | |
GranuleDef * | g | |||
) | [static] |
Definition at line 1184 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
static void compute_imdct | ( | MPADecodeContext * | s, | |
GranuleDef * | g, | |||
INTFLOAT * | sb_samples, | |||
INTFLOAT * | mdct_buf | |||
) | [static] |
Definition at line 1214 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
static void compute_stereo | ( | MPADecodeContext * | s, | |
GranuleDef * | g0, | |||
GranuleDef * | g1 | |||
) | [static] |
Definition at line 1043 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
static av_cold int decode_close_mp3on4 | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 1800 of file mpegaudiodec.c.
Referenced by decode_init_mp3on4().
static int decode_frame | ( | AVCodecContext * | avctx, | |
void * | data, | |||
int * | got_frame_ptr, | |||
AVPacket * | avpkt | |||
) | [static] |
Definition at line 1631 of file mpegaudiodec.c.
static int decode_frame_adu | ( | AVCodecContext * | avctx, | |
void * | data, | |||
int * | got_frame_ptr, | |||
AVPacket * | avpkt | |||
) | [static] |
Definition at line 1698 of file mpegaudiodec.c.
static int decode_frame_mp3on4 | ( | AVCodecContext * | avctx, | |
void * | data, | |||
int * | got_frame_ptr, | |||
AVPacket * | avpkt | |||
) | [static] |
Definition at line 1898 of file mpegaudiodec.c.
static av_cold int decode_init | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 422 of file mpegaudiodec.c.
Referenced by decode_init_mp3on4().
static int decode_init_mp3on4 | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 1814 of file mpegaudiodec.c.
static av_cold void decode_init_static | ( | void | ) | [static] |
Definition at line 270 of file mpegaudiodec.c.
Referenced by decode_init().
static void exponents_from_scale_factors | ( | MPADecodeContext * | s, | |
GranuleDef * | g, | |||
int16_t * | exponents | |||
) | [static] |
Definition at line 778 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
static void ff_compute_band_indexes | ( | MPADecodeContext * | s, | |
GranuleDef * | g | |||
) | [static] |
Definition at line 197 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
static void ff_init_long_region | ( | MPADecodeContext * | s, | |
GranuleDef * | g, | |||
int | ra1, | |||
int | ra2 | |||
) | [static] |
Definition at line 188 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
static void ff_init_short_region | ( | MPADecodeContext * | s, | |
GranuleDef * | g | |||
) | [static] |
Definition at line 173 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
static void ff_region_offset2size | ( | GranuleDef * | g | ) | [static] |
Convert region offsets to region sizes and truncate size to big_values.
Definition at line 162 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
static void flush | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 1690 of file mpegaudiodec.c.
static void flush_mp3on4 | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 1885 of file mpegaudiodec.c.
static int get_bitsz | ( | GetBitContext * | s, | |
int | n | |||
) | [inline, static] |
Definition at line 816 of file mpegaudiodec.c.
Referenced by huffman_decode().
static int huffman_decode | ( | MPADecodeContext * | s, | |
GranuleDef * | g, | |||
int16_t * | exponents, | |||
int | end_pos2 | |||
) | [static] |
Definition at line 852 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
static void imdct12 | ( | INTFLOAT * | out, | |
INTFLOAT * | in | |||
) | [static] |
Definition at line 455 of file mpegaudiodec.c.
Referenced by compute_imdct().
static int l1_unscale | ( | int | n, | |
int | mant, | |||
int | scale_factor | |||
) | [inline, static] |
Definition at line 224 of file mpegaudiodec.c.
Referenced by mp_decode_layer1(), and mp_decode_layer2().
static int l2_unscale_group | ( | int | steps, | |
int | mant, | |||
int | scale_factor | |||
) | [inline, static] |
Definition at line 238 of file mpegaudiodec.c.
Referenced by mp_decode_layer2().
static int l3_unscale | ( | int | value, | |
int | exponent | |||
) | [inline, static] |
Definition at line 254 of file mpegaudiodec.c.
Referenced by huffman_decode().
static av_always_inline void lsf_sf_expand | ( | int * | slen, | |
int | sf, | |||
int | n1, | |||
int | n2, | |||
int | n3 | |||
) | [static] |
Definition at line 769 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
static int mp_decode_frame | ( | MPADecodeContext * | s, | |
OUT_INT * | samples, | |||
const uint8_t * | buf, | |||
int | buf_size | |||
) | [static] |
Definition at line 1548 of file mpegaudiodec.c.
Referenced by decode_frame(), decode_frame_adu(), and decode_frame_mp3on4().
static int mp_decode_layer1 | ( | MPADecodeContext * | s | ) | [static] |
Definition at line 497 of file mpegaudiodec.c.
Referenced by mp_decode_frame().
static int mp_decode_layer2 | ( | MPADecodeContext * | s | ) | [static] |
Definition at line 562 of file mpegaudiodec.c.
Referenced by mp_decode_frame().
static int mp_decode_layer3 | ( | MPADecodeContext * | s | ) | [static] |
Definition at line 1294 of file mpegaudiodec.c.
Referenced by mp_decode_frame().
static void reorder_block | ( | MPADecodeContext * | s, | |
GranuleDef * | g | |||
) | [static] |
Definition at line 1008 of file mpegaudiodec.c.
Referenced by mp_decode_layer3().
static void switch_buffer | ( | MPADecodeContext * | s, | |
int * | pos, | |||
int * | end_pos, | |||
int * | end_pos2 | |||
) | [static] |
Definition at line 822 of file mpegaudiodec.c.
Referenced by huffman_decode().
uint16_t band_index_long[9][23] [static] |
Definition at line 128 of file mpegaudiodec.c.
Referenced by decode_init_static(), and ff_init_long_region().
const int16_t chan_layout[8] [static] |
{ 0, AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_4POINT0, AV_CH_LAYOUT_5POINT0, AV_CH_LAYOUT_5POINT1, AV_CH_LAYOUT_7POINT1 }
Definition at line 1789 of file mpegaudiodec.c.
Referenced by decode_init_mp3on4().
const uint8_t chan_offset[8][5] [static] |
{ { 0 }, { 0 }, { 0 }, { 2, 0 }, { 2, 0, 3 }, { 2, 0, 3 }, { 2, 0, 4, 3 }, { 2, 0, 6, 4, 3 }, }
Definition at line 1777 of file mpegaudiodec.c.
Referenced by decode_init_mp3on4().
INTFLOAT csa_table[8][4] [static] |
Definition at line 133 of file mpegaudiodec.c.
Referenced by decode_init_static().
int16_t division_tab3[1<< 6] [static] |
Definition at line 135 of file mpegaudiodec.c.
int16_t division_tab5[1<< 8] [static] |
Definition at line 136 of file mpegaudiodec.c.
int16_t division_tab9[1<< 11] [static] |
Definition at line 137 of file mpegaudiodec.c.
int16_t* const division_tabs[4] [static] |
Definition at line 139 of file mpegaudiodec.c.
Referenced by decode_init_static(), and mp_decode_layer2().
{ .name = "mp1", .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP1, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1, .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), }
Definition at line 1993 of file mpegaudiodec.c.
{ .name = "mp2", .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP2, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1, .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), }
Definition at line 2010 of file mpegaudiodec.c.
{ .name = "mp3", .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP3, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1, .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), }
Definition at line 2027 of file mpegaudiodec.c.
{ .name = "mp3adu", .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP3ADU, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame_adu, .capabilities = CODEC_CAP_PARSE_ONLY | CODEC_CAP_DR1, .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), }
Definition at line 2044 of file mpegaudiodec.c.
{ .name = "mp3on4", .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP3ON4, .priv_data_size = sizeof(MP3On4DecodeContext), .init = decode_init_mp3on4, .close = decode_close_mp3on4, .decode = decode_frame_mp3on4, .capabilities = CODEC_CAP_DR1, .flush = flush_mp3on4, .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"), }
Definition at line 2061 of file mpegaudiodec.c.
VLC huff_quad_vlc[2] [static] |
Definition at line 124 of file mpegaudiodec.c.
VLC_TYPE huff_quad_vlc_tables[128+16][2] [static] |
Definition at line 125 of file mpegaudiodec.c.
Referenced by decode_init_static().
const int huff_quad_vlc_tables_sizes[2] = { 128, 16 } [static] |
Definition at line 126 of file mpegaudiodec.c.
Referenced by decode_init_static().
Definition at line 115 of file mpegaudiodec.c.
VLC_TYPE huff_vlc_tables[0+128+128+128+130+128+154+166+142+204+190+170+542+460+662+414][2] [static] |
Definition at line 119 of file mpegaudiodec.c.
Referenced by decode_init_static().
const int huff_vlc_tables_sizes[16] [static] |
{ 0, 128, 128, 128, 130, 128, 154, 166, 142, 204, 190, 170, 542, 460, 662, 414 }
Definition at line 120 of file mpegaudiodec.c.
Referenced by decode_init_static().
INTFLOAT is_table[2][16] [static] |
Definition at line 131 of file mpegaudiodec.c.
Referenced by compute_stereo(), and decode_init_static().
INTFLOAT is_table_lsf[2][2][16] [static] |
Definition at line 132 of file mpegaudiodec.c.
Referenced by compute_stereo(), and decode_init_static().
const uint8_t mp3Frames[8] = { 0, 1, 1, 2, 3, 3, 4, 5 } [static] |
Definition at line 1774 of file mpegaudiodec.c.
Referenced by decode_init_mp3on4().
uint16_t scale_factor_modshift[64] [static] |
Definition at line 144 of file mpegaudiodec.c.
Referenced by decode_init_static(), l1_unscale(), and l2_unscale_group().
int32_t scale_factor_mult[15][3] [static] |
Definition at line 146 of file mpegaudiodec.c.
Referenced by decode_init_static(), encode_frame(), l1_unscale(), and MPA_encode_init().
const int32_t scale_factor_mult2[3][3] [static] |
Definition at line 152 of file mpegaudiodec.c.
Referenced by l2_unscale_group().