XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
minimp3.cpp File Reference
#include "libc.h"
#include "minimp3.h"
Include dependency graph for minimp3.cpp:

Classes

struct  _bitstream
 
struct  _vlc
 
struct  _mp3_context
 
struct  _granule
 
struct  _huff_table
 

Macros

#define MP3_FRAME_SIZE   1152
 
#define MP3_MAX_CODED_FRAME_SIZE   1792
 
#define MP3_MAX_CHANNELS   2
 
#define SBLIMIT   32
 
#define MP3_STEREO   0
 
#define MP3_JSTEREO   1
 
#define MP3_DUAL   2
 
#define MP3_MONO   3
 
#define SAME_HEADER_MASK    (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19))
 
#define FRAC_BITS   15
 
#define WFRAC_BITS   14
 
#define OUT_MAX   (32767)
 
#define OUT_MIN   (-32768)
 
#define OUT_SHIFT   (WFRAC_BITS + FRAC_BITS - 15)
 
#define MODE_EXT_MS_STEREO   2
 
#define MODE_EXT_I_STEREO   1
 
#define FRAC_ONE   (1 << FRAC_BITS)
 
#define FIX(a)   ((int)((a) * FRAC_ONE))
 
#define FIXR(a)   ((int)((a) * FRAC_ONE + 0.5))
 
#define FRAC_RND(a)   (((a) + (FRAC_ONE/2)) >> FRAC_BITS)
 
#define FIXHR(a)   ((int)((a) * (1LL<<32) + 0.5))
 
#define MULL(a, b)   (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS)
 
#define MULH(a, b)   (((int64_t)(a) * (int64_t)(b)) >> 32)
 
#define MULS(ra, rb)   ((ra) * (rb))
 
#define ISQRT2   FIXR(0.70710678118654752440)
 
#define HEADER_SIZE   4
 
#define BACKSTEP_SIZE   512
 
#define EXTRABYTES   24
 
#define VLC_TYPE   int16_t
 
#define TABLE_4_3_SIZE   (8191 + 16)*4
 
#define C1   FIXHR(0.98480775301220805936/2)
 
#define C2   FIXHR(0.93969262078590838405/2)
 
#define C3   FIXHR(0.86602540378443864676/2)
 
#define C4   FIXHR(0.76604444311897803520/2)
 
#define C5   FIXHR(0.64278760968653932632/2)
 
#define C6   FIXHR(0.5/2)
 
#define C7   FIXHR(0.34202014332566873304/2)
 
#define C8   FIXHR(0.17364817766693034885/2)
 
#define MIN_CACHE_BITS   25
 
#define NEG_SSR32(a, s)   ((( int32_t)(a))>>(32-(s)))
 
#define NEG_USR32(a, s)   (((uint32_t)(a))>>(32-(s)))
 
#define OPEN_READER(name, gb)
 
#define CLOSE_READER(name, gb)    (gb)->index = name##_index; \
 
#define UPDATE_CACHE(name, gb)    name##_cache = unaligned32_be(&((gb)->buffer[name##_index >> 3])) << (name##_index & 0x07); \
 
#define SKIP_CACHE(name, gb, num)    name##_cache <<= (num);
 
#define SKIP_COUNTER(name, gb, num)    name##_index += (num); \
 
#define SKIP_BITS(name, gb, num)
 
#define LAST_SKIP_BITS(name, gb, num)   SKIP_COUNTER(name, gb, num)
 
#define LAST_SKIP_CACHE(name, gb, num)   ;
 
#define SHOW_UBITS(name, gb, num)    NEG_USR32(name##_cache, num)
 
#define SHOW_SBITS(name, gb, num)    NEG_SSR32(name##_cache, num)
 
#define GET_CACHE(name, gb)    ((uint32_t)name##_cache)
 
#define skip_bits   skip_bits_long
 
#define GET_DATA(v, table, i, wrap, size)
 
#define GET_VLC(code, name, gb, table, bits, max_depth)
 
#define INT_AA(j)
 
#define SUM8(sum, op, w, p)
 
#define SUM8P2(sum1, op1, sum2, op2, w1, w2, p)
 
#define COS0_0   FIXHR(0.50060299823519630134/2)
 
#define COS0_1   FIXHR(0.50547095989754365998/2)
 
#define COS0_2   FIXHR(0.51544730992262454697/2)
 
#define COS0_3   FIXHR(0.53104259108978417447/2)
 
#define COS0_4   FIXHR(0.55310389603444452782/2)
 
#define COS0_5   FIXHR(0.58293496820613387367/2)
 
#define COS0_6   FIXHR(0.62250412303566481615/2)
 
#define COS0_7   FIXHR(0.67480834145500574602/2)
 
#define COS0_8   FIXHR(0.74453627100229844977/2)
 
#define COS0_9   FIXHR(0.83934964541552703873/2)
 
#define COS0_10   FIXHR(0.97256823786196069369/2)
 
#define COS0_11   FIXHR(1.16943993343288495515/4)
 
#define COS0_12   FIXHR(1.48416461631416627724/4)
 
#define COS0_13   FIXHR(2.05778100995341155085/8)
 
#define COS0_14   FIXHR(3.40760841846871878570/8)
 
#define COS0_15   FIXHR(10.19000812354805681150/32)
 
#define COS1_0   FIXHR(0.50241928618815570551/2)
 
#define COS1_1   FIXHR(0.52249861493968888062/2)
 
#define COS1_2   FIXHR(0.56694403481635770368/2)
 
#define COS1_3   FIXHR(0.64682178335999012954/2)
 
#define COS1_4   FIXHR(0.78815462345125022473/2)
 
#define COS1_5   FIXHR(1.06067768599034747134/4)
 
#define COS1_6   FIXHR(1.72244709823833392782/4)
 
#define COS1_7   FIXHR(5.10114861868916385802/16)
 
#define COS2_0   FIXHR(0.50979557910415916894/2)
 
#define COS2_1   FIXHR(0.60134488693504528054/2)
 
#define COS2_2   FIXHR(0.89997622313641570463/2)
 
#define COS2_3   FIXHR(2.56291544774150617881/8)
 
#define COS3_0   FIXHR(0.54119610014619698439/2)
 
#define COS3_1   FIXHR(1.30656296487637652785/4)
 
#define COS4_0   FIXHR(0.70710678118654752439/2)
 
#define BF(a, b, c, s)
 
#define BF1(a, b, c, d)
 
#define BF2(a, b, c, d)
 
#define ADD(a, b)   tab[a] += tab[b]
 

Typedefs

typedef struct _bitstream bitstream_t
 
typedef struct _vlc vlc_t
 
typedef struct _mp3_context mp3_context_t
 
typedef struct _granule granule_t
 
typedef struct _huff_table huff_table_t
 

Functions

mp3_decoder_t mp3_create (void)
 
void mp3_done (mp3_decoder_t *dec)
 
int mp3_decode (mp3_decoder_t dec, void *buf, int bytes, signed short *out, mp3_info_t *info)
 

Macro Definition Documentation

◆ ADD

#define ADD (   a,
 
)    tab[a] += tab[b]

◆ BACKSTEP_SIZE

#define BACKSTEP_SIZE   512

◆ BF

#define BF (   a,
  b,
  c,
 
)
Value:
{\
tmp0 = tab[a] + tab[b]; \
tmp1 = tab[a] - tab[b]; \
tab[a] = tmp0; \
tab[b] = MULH(tmp1 << (s), c); \
}
#define MULH(a, b)
Definition minimp3.cpp:58

◆ BF1

#define BF1 (   a,
  b,
  c,
 
)
Value:
{\
BF(a, b, COS4_0, 1); \
BF(c, d, -COS4_0, 1); \
tab[c] += tab[d]; \
}
#define COS4_0
Definition minimp3.cpp:1826

◆ BF2

#define BF2 (   a,
  b,
  c,
 
)
Value:
{\
BF(a, b, COS4_0, 1); \
BF(c, d, -COS4_0, 1); \
tab[c] += tab[d]; \
tab[a] += tab[c]; \
tab[c] += tab[b]; \
tab[b] += tab[d]; \
}

◆ C1

#define C1   FIXHR(0.98480775301220805936/2)

◆ C2

#define C2   FIXHR(0.93969262078590838405/2)

◆ C3

#define C3   FIXHR(0.86602540378443864676/2)

◆ C4

#define C4   FIXHR(0.76604444311897803520/2)

◆ C5

#define C5   FIXHR(0.64278760968653932632/2)

◆ C6

#define C6   FIXHR(0.5/2)

◆ C7

#define C7   FIXHR(0.34202014332566873304/2)

◆ C8

#define C8   FIXHR(0.17364817766693034885/2)

◆ CLOSE_READER

#define CLOSE_READER (   name,
  gb 
)     (gb)->index = name##_index; \

◆ COS0_0

#define COS0_0   FIXHR(0.50060299823519630134/2)

◆ COS0_1

#define COS0_1   FIXHR(0.50547095989754365998/2)

◆ COS0_10

#define COS0_10   FIXHR(0.97256823786196069369/2)

◆ COS0_11

#define COS0_11   FIXHR(1.16943993343288495515/4)

◆ COS0_12

#define COS0_12   FIXHR(1.48416461631416627724/4)

◆ COS0_13

#define COS0_13   FIXHR(2.05778100995341155085/8)

◆ COS0_14

#define COS0_14   FIXHR(3.40760841846871878570/8)

◆ COS0_15

#define COS0_15   FIXHR(10.19000812354805681150/32)

◆ COS0_2

#define COS0_2   FIXHR(0.51544730992262454697/2)

◆ COS0_3

#define COS0_3   FIXHR(0.53104259108978417447/2)

◆ COS0_4

#define COS0_4   FIXHR(0.55310389603444452782/2)

◆ COS0_5

#define COS0_5   FIXHR(0.58293496820613387367/2)

◆ COS0_6

#define COS0_6   FIXHR(0.62250412303566481615/2)

◆ COS0_7

#define COS0_7   FIXHR(0.67480834145500574602/2)

◆ COS0_8

#define COS0_8   FIXHR(0.74453627100229844977/2)

◆ COS0_9

#define COS0_9   FIXHR(0.83934964541552703873/2)

◆ COS1_0

#define COS1_0   FIXHR(0.50241928618815570551/2)

◆ COS1_1

#define COS1_1   FIXHR(0.52249861493968888062/2)

◆ COS1_2

#define COS1_2   FIXHR(0.56694403481635770368/2)

◆ COS1_3

#define COS1_3   FIXHR(0.64682178335999012954/2)

◆ COS1_4

#define COS1_4   FIXHR(0.78815462345125022473/2)

◆ COS1_5

#define COS1_5   FIXHR(1.06067768599034747134/4)

◆ COS1_6

#define COS1_6   FIXHR(1.72244709823833392782/4)

◆ COS1_7

#define COS1_7   FIXHR(5.10114861868916385802/16)

◆ COS2_0

#define COS2_0   FIXHR(0.50979557910415916894/2)

◆ COS2_1

#define COS2_1   FIXHR(0.60134488693504528054/2)

◆ COS2_2

#define COS2_2   FIXHR(0.89997622313641570463/2)

◆ COS2_3

#define COS2_3   FIXHR(2.56291544774150617881/8)

◆ COS3_0

#define COS3_0   FIXHR(0.54119610014619698439/2)

◆ COS3_1

#define COS3_1   FIXHR(1.30656296487637652785/4)

◆ COS4_0

#define COS4_0   FIXHR(0.70710678118654752439/2)

◆ EXTRABYTES

#define EXTRABYTES   24

◆ FIX

#define FIX (   a)    ((int)((a) * FRAC_ONE))

◆ FIXHR

#define FIXHR (   a)    ((int)((a) * (1LL<<32) + 0.5))

◆ FIXR

#define FIXR (   a)    ((int)((a) * FRAC_ONE + 0.5))

◆ FRAC_BITS

#define FRAC_BITS   15

◆ FRAC_ONE

#define FRAC_ONE   (1 << FRAC_BITS)

◆ FRAC_RND

#define FRAC_RND (   a)    (((a) + (FRAC_ONE/2)) >> FRAC_BITS)

◆ GET_CACHE

#define GET_CACHE (   name,
  gb 
)     ((uint32_t)name##_cache)

◆ GET_DATA

#define GET_DATA (   v,
  table,
  i,
  wrap,
  size 
)
Value:
{\
const uint8_t *ptr = (const uint8_t *)table + i * wrap; \
switch (size) {\
case 1:\
v = *(const uint8_t *)ptr; \
break; \
case 2:\
v = *(const uint16_t *)ptr; \
break; \
default:\
v = *(const uint32_t *)ptr; \
break; \
}\
}
unsigned int uint32_t
Definition acefiex.h:163
unsigned char uint8_t
Definition acefiex.h:161
unsigned short int uint16_t
Definition acefiex.h:162

◆ GET_VLC

#define GET_VLC (   code,
  name,
  gb,
  table,
  bits,
  max_depth 
)

◆ HEADER_SIZE

#define HEADER_SIZE   4

◆ INT_AA

#define INT_AA (   j)
Value:
tmp0 = ptr[-1 - j]; \
tmp1 = ptr[j]; \
tmp2 = MULH(tmp0 + tmp1, csa[0 + 4 * j]); \
ptr[-1 - j] = 4 * (tmp2 - MULH(tmp1, csa[2 + 4 * j])); \
ptr[j] = 4 * (tmp2 + MULH(tmp0, csa[3 + 4 * j]));

◆ ISQRT2

#define ISQRT2   FIXR(0.70710678118654752440)

◆ LAST_SKIP_BITS

#define LAST_SKIP_BITS (   name,
  gb,
  num 
)    SKIP_COUNTER(name, gb, num)

◆ LAST_SKIP_CACHE

#define LAST_SKIP_CACHE (   name,
  gb,
  num 
)    ;

◆ MIN_CACHE_BITS

#define MIN_CACHE_BITS   25

◆ MODE_EXT_I_STEREO

#define MODE_EXT_I_STEREO   1

◆ MODE_EXT_MS_STEREO

#define MODE_EXT_MS_STEREO   2

◆ MP3_DUAL

#define MP3_DUAL   2

◆ MP3_FRAME_SIZE

#define MP3_FRAME_SIZE   1152

◆ MP3_JSTEREO

#define MP3_JSTEREO   1

◆ MP3_MAX_CHANNELS

#define MP3_MAX_CHANNELS   2

◆ MP3_MAX_CODED_FRAME_SIZE

#define MP3_MAX_CODED_FRAME_SIZE   1792

◆ MP3_MONO

#define MP3_MONO   3

◆ MP3_STEREO

#define MP3_STEREO   0

◆ MULH

#define MULH (   a,
 
)    (((int64_t)(a) * (int64_t)(b)) >> 32)

◆ MULL

#define MULL (   a,
 
)    (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS)

◆ MULS

#define MULS (   ra,
  rb 
)    ((ra) * (rb))

◆ NEG_SSR32

#define NEG_SSR32 (   a,
 
)    ((( int32_t)(a))>>(32-(s)))

◆ NEG_USR32

#define NEG_USR32 (   a,
 
)    (((uint32_t)(a))>>(32-(s)))

◆ OPEN_READER

#define OPEN_READER (   name,
  gb 
)
Value:
int name##_index = (gb)->index; \
int name##_cache = 0; \
#define index(str, chr)
Definition string.h:66

◆ OUT_MAX

#define OUT_MAX   (32767)

◆ OUT_MIN

#define OUT_MIN   (-32768)

◆ OUT_SHIFT

#define OUT_SHIFT   (WFRAC_BITS + FRAC_BITS - 15)

◆ SAME_HEADER_MASK

#define SAME_HEADER_MASK    (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19))

◆ SBLIMIT

#define SBLIMIT   32

◆ SHOW_SBITS

#define SHOW_SBITS (   name,
  gb,
  num 
)     NEG_SSR32(name##_cache, num)

◆ SHOW_UBITS

#define SHOW_UBITS (   name,
  gb,
  num 
)     NEG_USR32(name##_cache, num)

◆ SKIP_BITS

#define SKIP_BITS (   name,
  gb,
  num 
)
Value:
{\
SKIP_CACHE(name, gb, num)\
SKIP_COUNTER(name, gb, num)\
}\

◆ skip_bits

#define skip_bits   skip_bits_long

◆ SKIP_CACHE

#define SKIP_CACHE (   name,
  gb,
  num 
)     name##_cache <<= (num);

◆ SKIP_COUNTER

#define SKIP_COUNTER (   name,
  gb,
  num 
)     name##_index += (num); \

◆ SUM8

#define SUM8 (   sum,
  op,
  w,
 
)
Value:
{ \
sum op MULS((w)[0 * 64], p[0 * 64]); \
sum op MULS((w)[1 * 64], p[1 * 64]); \
sum op MULS((w)[2 * 64], p[2 * 64]); \
sum op MULS((w)[3 * 64], p[3 * 64]); \
sum op MULS((w)[4 * 64], p[4 * 64]); \
sum op MULS((w)[5 * 64], p[5 * 64]); \
sum op MULS((w)[6 * 64], p[6 * 64]); \
sum op MULS((w)[7 * 64], p[7 * 64]); \
}
#define MULS(ra, rb)
Definition minimp3.cpp:82

◆ SUM8P2

#define SUM8P2 (   sum1,
  op1,
  sum2,
  op2,
  w1,
  w2,
 
)
Value:
{ \
int tmp; \
tmp = p[0 * 64]; \
sum1 op1 MULS((w1)[0 * 64], tmp); \
sum2 op2 MULS((w2)[0 * 64], tmp); \
tmp = p[1 * 64]; \
sum1 op1 MULS((w1)[1 * 64], tmp); \
sum2 op2 MULS((w2)[1 * 64], tmp); \
tmp = p[2 * 64]; \
sum1 op1 MULS((w1)[2 * 64], tmp); \
sum2 op2 MULS((w2)[2 * 64], tmp); \
tmp = p[3 * 64]; \
sum1 op1 MULS((w1)[3 * 64], tmp); \
sum2 op2 MULS((w2)[3 * 64], tmp); \
tmp = p[4 * 64]; \
sum1 op1 MULS((w1)[4 * 64], tmp); \
sum2 op2 MULS((w2)[4 * 64], tmp); \
tmp = p[5 * 64]; \
sum1 op1 MULS((w1)[5 * 64], tmp); \
sum2 op2 MULS((w2)[5 * 64], tmp); \
tmp = p[6 * 64]; \
sum1 op1 MULS((w1)[6 * 64], tmp); \
sum2 op2 MULS((w2)[6 * 64], tmp); \
tmp = p[7 * 64]; \
sum1 op1 MULS((w1)[7 * 64], tmp); \
sum2 op2 MULS((w2)[7 * 64], tmp); \
}

◆ TABLE_4_3_SIZE

#define TABLE_4_3_SIZE   (8191 + 16)*4

◆ UPDATE_CACHE

#define UPDATE_CACHE (   name,
  gb 
)     name##_cache = unaligned32_be(&((gb)->buffer[name##_index >> 3])) << (name##_index & 0x07); \

◆ VLC_TYPE

#define VLC_TYPE   int16_t

◆ WFRAC_BITS

#define WFRAC_BITS   14

Typedef Documentation

◆ bitstream_t

typedef struct _bitstream bitstream_t

◆ granule_t

typedef struct _granule granule_t

◆ huff_table_t

typedef struct _huff_table huff_table_t

◆ mp3_context_t

typedef struct _mp3_context mp3_context_t

◆ vlc_t

typedef struct _vlc vlc_t

Function Documentation

◆ mp3_create()

mp3_decoder_t mp3_create ( void  )

◆ mp3_decode()

int mp3_decode ( mp3_decoder_t  dec,
void *  buf,
int  bytes,
signed short *  out,
mp3_info_t info 
)

◆ mp3_done()

void mp3_done ( mp3_decoder_t dec)