FFmpeg
Data Structures | Macros | Functions | Variables
mpegaudiodec_template.c File Reference
#include "config_components.h"
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/crc.h"
#include "libavutil/float_dsp.h"
#include "libavutil/libm.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "decode.h"
#include "get_bits.h"
#include "mathops.h"
#include "mpegaudiodsp.h"
#include "mpegaudio.h"
#include "mpegaudiodecheader.h"
#include "mpegaudiodata.h"
#include "mpegaudio_tablegen.h"

Go to the source code of this file.

Data Structures

struct  GranuleDef
 
struct  MPADecodeContext
 

Macros

#define BACKSTEP_SIZE   512
 
#define EXTRABYTES   24
 
#define LAST_BUF_SIZE   2 * BACKSTEP_SIZE + EXTRABYTES
 
#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)
 

Functions

static void region_offset2size (GranuleDef *g)
 Convert region offsets to region sizes and truncate size to big_values. More...
 
static void init_short_region (MPADecodeContext *s, GranuleDef *g)
 
static void init_long_region (MPADecodeContext *s, GranuleDef *g, int ra1, int ra2)
 
static void 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, SUINTFLOAT *in)
 
static int handle_crc (MPADecodeContext *s, int sec_len)
 
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 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, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
 
static void mp_flush (MPADecodeContext *ctx)
 
static void flush (AVCodecContext *avctx)
 

Variables

static INTFLOAT is_table_lsf [2][2][16]
 
static int32_t scale_factor_mult [15][3]
 
static const int32_t scale_factor_mult2 [3][3]
 

Detailed Description

MPEG Audio decoder

Definition in file mpegaudiodec_template.c.

Macro Definition Documentation

◆ BACKSTEP_SIZE

#define BACKSTEP_SIZE   512

Definition at line 53 of file mpegaudiodec_template.c.

◆ EXTRABYTES

#define EXTRABYTES   24

Definition at line 54 of file mpegaudiodec_template.c.

◆ LAST_BUF_SIZE

#define LAST_BUF_SIZE   2 * BACKSTEP_SIZE + EXTRABYTES

Definition at line 55 of file mpegaudiodec_template.c.

◆ HEADER_SIZE

#define HEADER_SIZE   4

Definition at line 101 of file mpegaudiodec_template.c.

◆ SCALE_GEN

#define SCALE_GEN (   v)    { FIXR_OLD(1.0 * (v)), FIXR_OLD(0.7937005259 * (v)), FIXR_OLD(0.6299605249 * (v)) }

Definition at line 113 of file mpegaudiodec_template.c.

◆ C3

#define C3   FIXHR(0.86602540378443864676/2)

Definition at line 318 of file mpegaudiodec_template.c.

◆ C4

#define C4   FIXHR(0.70710678118654752439/2)

Definition at line 319 of file mpegaudiodec_template.c.

◆ C5

#define C5   FIXHR(0.51763809020504152469/2)

Definition at line 320 of file mpegaudiodec_template.c.

◆ C6

#define C6   FIXHR(1.93185165257813657349/4)

Definition at line 321 of file mpegaudiodec_template.c.

◆ SPLIT

#define SPLIT (   dst,
  sf,
 
)
Value:
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 655 of file mpegaudiodec_template.c.

◆ READ_FLIP_SIGN

#define READ_FLIP_SIGN (   dst,
  src 
)
Value:
v = -get_bits1(&s->gb); \
*(dst) = (*(src) ^ v) - v;

Definition at line 747 of file mpegaudiodec_template.c.

◆ ISQRT2

#define ISQRT2   FIXR(0.70710678118654752440)

Definition at line 937 of file mpegaudiodec_template.c.

◆ AA

#define AA (   j)
Value:
do { \
SUINT tmp0 = ptr[-1-j]; \
SUINT tmp1 = ptr[ j]; \
SUINT 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 1088 of file mpegaudiodec_template.c.

Function Documentation

◆ region_offset2size()

static void region_offset2size ( GranuleDef g)
static

Convert region offsets to region sizes and truncate size to big_values.

Definition at line 126 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer3().

◆ init_short_region()

static void init_short_region ( MPADecodeContext s,
GranuleDef g 
)
static

Definition at line 137 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer3().

◆ init_long_region()

static void init_long_region ( MPADecodeContext s,
GranuleDef g,
int  ra1,
int  ra2 
)
static

Definition at line 155 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer3().

◆ compute_band_indexes()

static void compute_band_indexes ( MPADecodeContext s,
GranuleDef g 
)
static

Definition at line 165 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer3().

◆ l1_unscale()

static int l1_unscale ( int  n,
int  mant,
int  scale_factor 
)
inlinestatic

Definition at line 192 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer1(), and mp_decode_layer2().

◆ l2_unscale_group()

static int l2_unscale_group ( int  steps,
int  mant,
int  scale_factor 
)
inlinestatic

Definition at line 206 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer2().

◆ l3_unscale()

static int l3_unscale ( int  value,
int  exponent 
)
inlinestatic

Definition at line 222 of file mpegaudiodec_template.c.

Referenced by huffman_decode().

◆ decode_init_static()

static av_cold void decode_init_static ( void  )
static

Definition at line 241 of file mpegaudiodec_template.c.

Referenced by decode_init().

◆ decode_init()

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 283 of file mpegaudiodec_template.c.

◆ imdct12()

static void imdct12 ( INTFLOAT out,
SUINTFLOAT in 
)
static

Definition at line 325 of file mpegaudiodec_template.c.

Referenced by compute_imdct().

◆ handle_crc()

static int handle_crc ( MPADecodeContext s,
int  sec_len 
)
static

Definition at line 366 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer1(), mp_decode_layer2(), and mp_decode_layer3().

◆ mp_decode_layer1()

static int mp_decode_layer1 ( MPADecodeContext s)
static

Definition at line 393 of file mpegaudiodec_template.c.

Referenced by mp_decode_frame().

◆ mp_decode_layer2()

static int mp_decode_layer2 ( MPADecodeContext s)
static

Definition at line 463 of file mpegaudiodec_template.c.

Referenced by mp_decode_frame().

◆ lsf_sf_expand()

static av_always_inline void lsf_sf_expand ( int slen,
int  sf,
int  n1,
int  n2,
int  n3 
)
static

Definition at line 675 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer3().

◆ exponents_from_scale_factors()

static void exponents_from_scale_factors ( MPADecodeContext s,
GranuleDef g,
int16_t *  exponents 
)
static

Definition at line 684 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer3().

◆ switch_buffer()

static void switch_buffer ( MPADecodeContext s,
int pos,
int end_pos,
int end_pos2 
)
static

Definition at line 721 of file mpegaudiodec_template.c.

Referenced by huffman_decode().

◆ huffman_decode()

static int huffman_decode ( MPADecodeContext s,
GranuleDef g,
int16_t *  exponents,
int  end_pos2 
)
static

Definition at line 752 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer3().

◆ reorder_block()

static void reorder_block ( MPADecodeContext s,
GranuleDef g 
)
static

Definition at line 904 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer3().

◆ compute_stereo()

static void compute_stereo ( MPADecodeContext s,
GranuleDef g0,
GranuleDef g1 
)
static

Definition at line 939 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer3().

◆ compute_antialias()

static void compute_antialias ( MPADecodeContext s,
GranuleDef g 
)
static

Definition at line 1097 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer3().

◆ compute_imdct()

static void compute_imdct ( MPADecodeContext s,
GranuleDef g,
INTFLOAT sb_samples,
INTFLOAT mdct_buf 
)
static

Definition at line 1128 of file mpegaudiodec_template.c.

Referenced by mp_decode_layer3().

◆ mp_decode_layer3()

static int mp_decode_layer3 ( MPADecodeContext s)
static

Definition at line 1208 of file mpegaudiodec_template.c.

Referenced by mp_decode_frame().

◆ mp_decode_frame()

static int mp_decode_frame ( MPADecodeContext s,
OUT_INT **  samples,
const uint8_t *  buf,
int  buf_size 
)
static

Definition at line 1467 of file mpegaudiodec_template.c.

Referenced by decode_frame().

◆ decode_frame()

static int decode_frame ( AVCodecContext avctx,
AVFrame frame,
int got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 1553 of file mpegaudiodec_template.c.

◆ mp_flush()

static void mp_flush ( MPADecodeContext ctx)
static

Definition at line 1624 of file mpegaudiodec_template.c.

Referenced by flush().

◆ flush()

static void flush ( AVCodecContext avctx)
static

Definition at line 1632 of file mpegaudiodec_template.c.

Variable Documentation

◆ is_table_lsf

INTFLOAT is_table_lsf[2][2][16]
static

Definition at line 107 of file mpegaudiodec_template.c.

Referenced by compute_stereo(), and decode_init_static().

◆ scale_factor_mult

int32_t scale_factor_mult[15][3]
static

Definition at line 110 of file mpegaudiodec_template.c.

Referenced by decode_init_static(), and l1_unscale().

◆ scale_factor_mult2

const int32_t scale_factor_mult2[3][3]
static
Initial value:
= {
SCALE_GEN(4.0 / 3.0),
SCALE_GEN(4.0 / 5.0),
SCALE_GEN(4.0 / 9.0),
}

Definition at line 116 of file mpegaudiodec_template.c.

Referenced by l2_unscale_group().

SCALE_GEN
#define SCALE_GEN(v)
Definition: mpegaudiodec_template.c:113
MULH
#define MULH
Definition: mathops.h:42
s
#define s(width, name)
Definition: cbs_vp9.c:198
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:388
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
csa_table
static const int32_t csa_table[8][4]
Definition: mpegaudiodec_fixed.c:50