Data Structures | |
| struct | sideinfo |
| struct | fixedfloat |
| table for requantization. More... | |
Defines | |
| #define | sfb_16000_long sfb_22050_long |
| #define | sfb_12000_long sfb_16000_long |
| MPEG 2.5 scalefactor band widths. | |
| #define | sfb_11025_long sfb_12000_long |
| #define | sfb_12000_short sfb_16000_short |
| #define | sfb_11025_short sfb_12000_short |
| #define | sfb_12000_mixed sfb_16000_mixed |
| #define | sfb_11025_mixed sfb_12000_mixed |
| #define | MASK(cache, sz, bits) (((cache) >> ((sz) - (bits))) & ((1 << (bits)) - 1)) |
| #define | MASK1BIT(cache, sz) ((cache) & (1 << ((sz) - 1))) |
Enumerations | |
| enum | { count1table_select = 0x01, scalefac_scale = 0x02, preflag = 0x04, mixed_block_flag = 0x08 } |
| enum | { I_STEREO = 0x1, MS_STEREO = 0x2 } |
Functions | |
| static enum mad_error | III_sideinfo (struct mad_bitptr *ptr, unsigned int nch, int lsf, struct sideinfo *si, unsigned int *data_bitlen, unsigned int *priv_bitlen) |
| decode frame side information from a bitstream. | |
| static unsigned int | III_scalefactors_lsf (struct mad_bitptr *ptr, struct channel *channel, struct channel *gr1ch, int mode_extension) |
| decode channel scalefactors for LSF from a bitstream. | |
| static unsigned int | III_scalefactors (struct mad_bitptr *ptr, struct channel *channel, struct channel const *gr0ch, unsigned int scfsi) |
| decode channel scalefactors of one granule from a bitstream. | |
| static void | III_exponents (struct channel const *channel, unsigned char const *sfbwidth, signed int exponents[39]) |
| The Layer III formula for requantization and scaling is defined by section 2.4.3.4.7.1 of ISO/IEC 11172-3, as follows:. | |
| static mad_fixed_t | III_requantize (unsigned int value, signed int exp) |
| requantize one (positive) value. | |
| static enum mad_error | III_huffdecode (struct mad_bitptr *ptr, mad_fixed_t xr[576], struct channel *channel, unsigned char const *sfbwidth, unsigned int part2_length) |
| decode Huffman code words of one channel of one granule. | |
| static void | III_reorder (mad_fixed_t xr[576], struct channel const *channel, unsigned char const sfbwidth[39]) |
| reorder frequency lines of a short block into subband order. | |
| static enum mad_error | III_stereo (mad_fixed_t xr[2][576], struct granule const *granule, struct mad_header *header, unsigned char const *sfbwidth) |
| perform joint stereo processing on a granule. | |
| static void | III_aliasreduce (mad_fixed_t xr[576], int lines) |
| perform frequency line alias reduction. | |
| static void | fastsdct (mad_fixed_t const x[9], mad_fixed_t y[18]) |
| static void | sdctII (mad_fixed_t const x[18], mad_fixed_t X[18]) |
| static void | dctIV (mad_fixed_t const y[18], mad_fixed_t X[18]) |
| static void | imdct36 (mad_fixed_t const x[18], mad_fixed_t y[36]) |
| perform X[18]->x[36] IMDCT using Szu-Wei Lee's fast algorithm. | |
| static void | III_imdct_l (mad_fixed_t const X[18], mad_fixed_t z[36], unsigned int block_type) |
| perform IMDCT and windowing for long blocks. | |
| static void | III_imdct_s (mad_fixed_t const X[18], mad_fixed_t z[36]) |
| perform IMDCT and windowing for short blocks. | |
| static void | III_overlap (mad_fixed_t const output[36], mad_fixed_t overlap[18], mad_fixed_t sample[18][32], unsigned int sb) |
| perform overlap-add of windowed IMDCT outputs. | |
| static void | III_overlap_z (mad_fixed_t overlap[18], mad_fixed_t sample[18][32], unsigned int sb) |
| perform "overlap-add" of zero IMDCT outputs. | |
| static void | III_freqinver (mad_fixed_t sample[18][32], unsigned int sb) |
| perform subband frequency inversion for odd sample lines. | |
| static enum mad_error | III_decode (struct mad_bitptr *ptr, struct mad_frame *frame, struct sideinfo *si, unsigned int nch) |
| decode frame main_data. | |
| int | mad_layer_III (struct mad_stream *stream, struct mad_frame *frame) |
| decode a single Layer III frame. | |
Variables | |
| struct { | |
| unsigned char slen1 | |
| unsigned char slen2 | |
| } | sflen_table [16] |
| static unsigned char const | nsfb_table [6][3][4] |
| number of LSF scalefactor band values. | |
| static unsigned char const | sfb_48000_long [] |
| MPEG-1 scalefactor band widths. | |
| static unsigned char const | sfb_44100_long [] |
| static unsigned char const | sfb_32000_long [] |
| static unsigned char const | sfb_48000_short [] |
| static unsigned char const | sfb_44100_short [] |
| static unsigned char const | sfb_32000_short [] |
| static unsigned char const | sfb_48000_mixed [] |
| static unsigned char const | sfb_44100_mixed [] |
| static unsigned char const | sfb_32000_mixed [] |
| static unsigned char const | sfb_24000_long [] |
| MPEG-2 scalefactor band widths. | |
| static unsigned char const | sfb_22050_long [] |
| static unsigned char const | sfb_24000_short [] |
| static unsigned char const | sfb_22050_short [] |
| static unsigned char const | sfb_16000_short [] |
| static unsigned char const | sfb_24000_mixed [] |
| static unsigned char const | sfb_22050_mixed [] |
| static unsigned char const | sfb_16000_mixed [] |
| static unsigned char const | sfb_8000_long [] |
| static unsigned char const | sfb_8000_short [] |
| static unsigned char const | sfb_8000_mixed [] |
| struct { | |
| unsigned char const * l | |
| unsigned char const * s | |
| unsigned char const * m | |
| } | sfbwidth_table [9] |
| static unsigned char const | pretab [22] |
| scalefactor band preemphasis (used only when preflag is set). | |
| static struct fixedfloat | rq_table [8207] |
| static mad_fixed_t const | root_table [7] |
| fractional powers of two. | |
| static mad_fixed_t const | cs [8] |
| coefficients for aliasing reduction. | |
| static mad_fixed_t const | ca [8] |
| static mad_fixed_t const | imdct_s [6][6] |
| IMDCT coefficients for short blocks. | |
| static mad_fixed_t const | window_l [36] |
| windowing coefficients for long blocks. | |
| static mad_fixed_t const | window_s [12] |
| windowing coefficients for short blocks. | |
| static mad_fixed_t const | is_table [7] |
| coefficients for intensity stereo processing. | |
| static mad_fixed_t const | is_lsf_table [2][15] |
| coefficients for LSF intensity stereo processing. | |
| #define MASK | ( | cache, | |||
| sz, | |||||
| bits | ) | (((cache) >> ((sz) - (bits))) & ((1 << (bits)) - 1)) |
| #define MASK1BIT | ( | cache, | |||
| sz | ) | ((cache) & (1 << ((sz) - 1))) |
| #define sfb_12000_long sfb_16000_long |
| #define sfb_12000_mixed sfb_16000_mixed |
| #define sfb_12000_short sfb_16000_short |
| #define sfb_16000_long sfb_22050_long |
| anonymous enum |
| static void dctIV | ( | mad_fixed_t const | y[18], | |
| mad_fixed_t | X[18] | |||
| ) | [inline, static] |
| static void fastsdct | ( | mad_fixed_t const | x[9], | |
| mad_fixed_t | y[18] | |||
| ) | [static] |
| static void III_aliasreduce | ( | mad_fixed_t | xr[576], | |
| int | lines | |||
| ) | [static] |
| static enum mad_error III_decode | ( | struct mad_bitptr * | ptr, | |
| struct mad_frame * | frame, | |||
| struct sideinfo * | si, | |||
| unsigned int | nch | |||
| ) | [static] |
decode frame main_data.
Definition at line 2341 of file layer3.c.
References sideinfo::granule::ch, error(), mad_header::flags, sideinfo::gr, mad_frame::header, III_aliasreduce(), III_freqinver(), III_huffdecode(), III_imdct_l(), III_imdct_s(), III_overlap(), III_overlap_z(), III_reorder(), III_scalefactors(), III_scalefactors_lsf(), III_stereo(), l, m, MAD_ERROR_NONE, MAD_FLAG_LSF_EXT, MAD_FLAG_MPEG_2_5_EXT, MAD_MODE_JOINT_STEREO, mixed_block_flag, mad_header::mode, mad_header::mode_extension, output(), mad_frame::overlap, s, mad_header::samplerate, sblimit, mad_frame::sbsample, sideinfo::scfsi, and sfbwidth_table.
Referenced by mad_layer_III().

| static void III_exponents | ( | struct channel const * | channel, | |
| unsigned char const * | sfbwidth, | |||
| signed int | exponents[39] | |||
| ) | [static] |
The Layer III formula for requantization and scaling is defined by section 2.4.3.4.7.1 of ISO/IEC 11172-3, as follows:.
xr[i] = sign(is[i]) * abs(is[i])^(4/3) *
2^((1/4) * (global_gain - 210 - 8 * subblock_gain[w])) *
2^-(scalefac_multiplier * scalefac_s[sfb][w])
The routines III_exponents() and III_requantize() facilitate this calculation. calculate scalefactor exponents.
Definition at line 816 of file layer3.c.
References l, mixed_block_flag, preflag, pretab, and scalefac_scale.
Referenced by III_huffdecode().
| static void III_freqinver | ( | mad_fixed_t | sample[18][32], | |
| unsigned int | sb | |||
| ) | [static] |
perform subband frequency inversion for odd sample lines.
Definition at line 2308 of file layer3.c.
Referenced by III_decode().
| static enum mad_error III_huffdecode | ( | struct mad_bitptr * | ptr, | |
| mad_fixed_t | xr[576], | |||
| struct channel * | channel, | |||
| unsigned char const * | sfbwidth, | |||
| unsigned int | part2_length | |||
| ) | [static] |
decode Huffman code words of one channel of one granule.
Definition at line 935 of file layer3.c.
References assert, huffquad::bits, huffpair::bits, CHAR_BIT, count1table_select, huffquad::final, huffpair::final, huffquad::hlen, huffpair::hlen, III_exponents(), III_requantize(), hufftable::linbits, mad_bit_bitsleft, mad_bit_read(), mad_bit_skip(), MAD_BUFFER_GUARD, MAD_ERROR_BADHUFFDATA, MAD_ERROR_BADHUFFTABLE, MAD_ERROR_BADPART3LEN, MAD_ERROR_NONE, mad_huff_pair_table, mad_huff_quad_table, MASK, MASK1BIT, huffquad::offset, huffpair::offset, huffquad::ptr, huffpair::ptr, hufftable::startbits, hufftable::table, huffquad::v, huffquad::value, huffpair::value, huffquad::w, huffquad::x, huffpair::x, huffquad::y, and huffpair::y.
Referenced by III_decode().

| static void III_imdct_l | ( | mad_fixed_t const | X[18], | |
| mad_fixed_t | z[36], | |||
| unsigned int | block_type | |||
| ) | [static] |
| static void III_imdct_s | ( | mad_fixed_t const | X[18], | |
| mad_fixed_t | z[36] | |||
| ) | [static] |
| static void III_overlap | ( | mad_fixed_t const | output[36], | |
| mad_fixed_t | overlap[18], | |||
| mad_fixed_t | sample[18][32], | |||
| unsigned int | sb | |||
| ) | [static] |
perform overlap-add of windowed IMDCT outputs.
Definition at line 2222 of file layer3.c.
Referenced by III_decode().
| static void III_overlap_z | ( | mad_fixed_t | overlap[18], | |
| mad_fixed_t | sample[18][32], | |||
| unsigned int | sb | |||
| ) | [inline, static] |
perform "overlap-add" of zero IMDCT outputs.
Definition at line 2269 of file layer3.c.
Referenced by III_decode().
| static void III_reorder | ( | mad_fixed_t | xr[576], | |
| struct channel const * | channel, | |||
| unsigned char const | sfbwidth[39] | |||
| ) | [static] |
reorder frequency lines of a short block into subband order.
Definition at line 1282 of file layer3.c.
References l, mixed_block_flag, and huffquad::w.
Referenced by III_decode().
| static mad_fixed_t III_requantize | ( | unsigned int | value, | |
| signed int | exp | |||
| ) | [static] |
requantize one (positive) value.
Definition at line 886 of file layer3.c.
References CHAR_BIT, fixedfloat::exponent, MAD_F_MAX, mad_f_mul, mad_f_todouble, fixedfloat::mantissa, root_table, and rq_table.
Referenced by III_huffdecode().
| static unsigned int III_scalefactors | ( | struct mad_bitptr * | ptr, | |
| struct channel * | channel, | |||
| struct channel const * | gr0ch, | |||
| unsigned int | scfsi | |||
| ) | [static] |
decode channel scalefactors of one granule from a bitstream.
Definition at line 716 of file layer3.c.
References mad_bit_length(), mad_bit_read(), mixed_block_flag, sflen_table, slen1, and slen2.
Referenced by III_decode().

| static unsigned int III_scalefactors_lsf | ( | struct mad_bitptr * | ptr, | |
| struct channel * | channel, | |||
| struct channel * | gr1ch, | |||
| int | mode_extension | |||
| ) | [static] |
decode channel scalefactors for LSF from a bitstream.
Definition at line 602 of file layer3.c.
References I_STEREO, mad_bit_length(), mad_bit_read(), mixed_block_flag, nsfb_table, and preflag.
Referenced by III_decode().

| static enum mad_error III_sideinfo | ( | struct mad_bitptr * | ptr, | |
| unsigned int | nch, | |||
| int | lsf, | |||
| struct sideinfo * | si, | |||
| unsigned int * | data_bitlen, | |||
| unsigned int * | priv_bitlen | |||
| ) | [static] |
decode frame side information from a bitstream.
Definition at line 512 of file layer3.c.
References sideinfo::granule::ch, sideinfo::gr, mad_bit_read(), MAD_ERROR_BADBIGVALUES, MAD_ERROR_BADBLOCKTYPE, MAD_ERROR_BADSCFSI, MAD_ERROR_NONE, sideinfo::main_data_begin, mixed_block_flag, sideinfo::granule::channel::part2_3_length, sideinfo::private_bits, and sideinfo::scfsi.
Referenced by mad_layer_III().

| static enum mad_error III_stereo | ( | mad_fixed_t | xr[2][576], | |
| struct granule const * | granule, | |||
| struct mad_header * | header, | |||
| unsigned char const * | sfbwidth | |||
| ) | [static] |
perform joint stereo processing on a granule.
Definition at line 1328 of file layer3.c.
References mad_header::flags, I_STEREO, is_lsf_table, is_table, l, m, MAD_ERROR_BADSTEREO, MAD_ERROR_NONE, mad_f_mul, MAD_FLAG_I_STEREO, MAD_FLAG_LSF_EXT, MAD_FLAG_MS_STEREO, mixed_block_flag, mad_header::mode_extension, MS_STEREO, root_table, and s.
Referenced by III_decode().
| static void imdct36 | ( | mad_fixed_t const | x[18], | |
| mad_fixed_t | y[36] | |||
| ) | [inline, static] |
perform X[18]->x[36] IMDCT using Szu-Wei Lee's fast algorithm.
Definition at line 1735 of file layer3.c.
References dctIV().
Referenced by III_imdct_l().

| int mad_layer_III | ( | struct mad_stream * | stream, | |
| struct mad_frame * | frame | |||
| ) |
decode a single Layer III frame.
Definition at line 2506 of file layer3.c.
References mad_stream::anc_bitlen, mad_stream::anc_ptr, assert, CHAR_BIT, mad_header::crc_check, mad_header::crc_target, mad_stream::error, error(), mad_header::flags, mad_frame::header, III_decode(), III_sideinfo(), mad_bit_crc(), mad_bit_finish, mad_bit_init(), mad_bit_nextbyte(), mad_bit_read(), mad_bit_skip(), MAD_BUFFER_MDLEN, MAD_ERROR_BADCRC, MAD_ERROR_BADDATAPTR, MAD_ERROR_BADFRAMELEN, MAD_ERROR_NOMEM, MAD_FLAG_LSF_EXT, MAD_FLAG_PROTECTION, MAD_NCHANNELS, MAD_OPTION_IGNORECRC, mad_stream::main_data, sideinfo::main_data_begin, mad_stream::md_len, mad_stream::next_frame, mad_frame::options, mad_frame::overlap, sideinfo::private_bits, mad_header::private_bits, and mad_stream::ptr.

| static void sdctII | ( | mad_fixed_t const | x[18], | |
| mad_fixed_t | X[18] | |||
| ) | [inline, static] |
mad_fixed_t const ca[8] [static] |
mad_fixed_t const cs[8] [static] |
Initial value:
{
+MAD_F(0x0db84a81) , +MAD_F(0x0e1b9d7f) ,
+MAD_F(0x0f31adcf) , +MAD_F(0x0fbba815) ,
+MAD_F(0x0feda417) , +MAD_F(0x0ffc8fc8) ,
+MAD_F(0x0fff964c) , +MAD_F(0x0ffff8d3)
}
derived from Table B.9 of ISO/IEC 11172-3
c[] = { -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037 } cs[i] = 1 / sqrt(1 + c[i]^2) ca[i] = c[i] / sqrt(1 + c[i]^2)
Definition at line 371 of file layer3.c.
Referenced by III_aliasreduce().
mad_fixed_t const imdct_s[6][6] [static] |
IMDCT coefficients for short blocks.
derived from section 2.4.3.4.10.2 of ISO/IEC 11172-3
imdct_s[i/even][k] = cos((PI / 24) * (2 * (i / 2) + 7) * (2 * k + 1)) imdct_s[i /odd][k] = cos((PI / 24) * (2 * (6 + (i-1)/2) + 7) * (2 * k + 1))
Definition at line 394 of file layer3.c.
Referenced by III_imdct_s().
mad_fixed_t const is_lsf_table[2][15] [static] |
coefficients for LSF intensity stereo processing.
derived from section 2.4.3.2 of ISO/IEC 13818-3
is_lsf_table[0][i] = (1 / sqrt(sqrt(2)))^(i + 1) is_lsf_table[1][i] = (1 / sqrt(2)) ^(i + 1)
Definition at line 472 of file layer3.c.
Referenced by III_stereo().
mad_fixed_t const is_table[7] [static] |
Initial value:
{
MAD_F(0x00000000) ,
MAD_F(0x0361962f) ,
MAD_F(0x05db3d74) ,
MAD_F(0x08000000) ,
MAD_F(0x0a24c28c) ,
MAD_F(0x0c9e69d1) ,
MAD_F(0x10000000)
}
derived from section 2.4.3.4.9.3 of ISO/IEC 11172-3
is_ratio[i] = tan(i * (PI / 12)) is_table[i] = is_ratio[i] / (1 + is_ratio[i])
Definition at line 454 of file layer3.c.
Referenced by III_stereo().
unsigned char const nsfb_table[6][3][4] [static] |
Initial value:
{
{ { 6, 5, 5, 5 },
{ 9, 9, 9, 9 },
{ 6, 9, 9, 9 } },
{ { 6, 5, 7, 3 },
{ 9, 9, 12, 6 },
{ 6, 9, 12, 6 } },
{ { 11, 10, 0, 0 },
{ 18, 18, 0, 0 },
{ 15, 18, 0, 0 } },
{ { 7, 7, 7, 0 },
{ 12, 12, 12, 0 },
{ 6, 15, 12, 0 } },
{ { 6, 6, 6, 3 },
{ 12, 9, 9, 6 },
{ 6, 12, 9, 6 } },
{ { 8, 8, 5, 0 },
{ 15, 12, 9, 0 },
{ 6, 18, 9, 0 } }
}
derived from section 2.4.3.2 of ISO/IEC 13818-3
Definition at line 114 of file layer3.c.
Referenced by III_scalefactors_lsf().
unsigned char const pretab[22] [static] |
Initial value:
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0
}
derived from Table B.6 of ISO/IEC 11172-3
Definition at line 328 of file layer3.c.
Referenced by III_exponents().
mad_fixed_t const root_table[7] [static] |
Initial value:
{
MAD_F(0x09837f05) ,
MAD_F(0x0b504f33) ,
MAD_F(0x0d744fcd) ,
MAD_F(0x10000000) ,
MAD_F(0x1306fe0a) ,
MAD_F(0x16a09e66) ,
MAD_F(0x1ae89f99)
}
used for requantization and joint stereo decoding
root_table[3 + x] = 2^(x/4)
Definition at line 352 of file layer3.c.
Referenced by III_requantize(), and III_stereo().
struct fixedfloat rq_table[8207] [static] |
Referenced by III_requantize().
unsigned char const sfb_16000_mixed[] [static] |
unsigned char const sfb_16000_short[] [static] |
unsigned char const sfb_22050_long[] [static] |
unsigned char const sfb_22050_mixed[] [static] |
unsigned char const sfb_22050_short[] [static] |
unsigned char const sfb_24000_long[] [static] |
unsigned char const sfb_24000_mixed[] [static] |
unsigned char const sfb_24000_short[] [static] |
unsigned char const sfb_32000_long[] [static] |
unsigned char const sfb_32000_mixed[] [static] |
unsigned char const sfb_32000_short[] [static] |
unsigned char const sfb_44100_long[] [static] |
unsigned char const sfb_44100_mixed[] [static] |
unsigned char const sfb_44100_short[] [static] |
unsigned char const sfb_48000_long[] [static] |
unsigned char const sfb_48000_mixed[] [static] |
unsigned char const sfb_48000_short[] [static] |
unsigned char const sfb_8000_long[] [static] |
unsigned char const sfb_8000_mixed[] [static] |
unsigned char const sfb_8000_short[] [static] |
struct { ... } sfbwidth_table[9] [static] |
Referenced by III_decode().
struct { ... } sflen_table[16] [static] |
Referenced by III_scalefactors().
mad_fixed_t const window_l[36] [static] |
Initial value:
{
MAD_F(0x00b2aa3e) , MAD_F(0x0216a2a2) ,
MAD_F(0x03768962) , MAD_F(0x04cfb0e2) ,
MAD_F(0x061f78aa) , MAD_F(0x07635284) ,
MAD_F(0x0898c779) , MAD_F(0x09bd7ca0) ,
MAD_F(0x0acf37ad) , MAD_F(0x0bcbe352) ,
MAD_F(0x0cb19346) , MAD_F(0x0d7e8807) ,
MAD_F(0x0e313245) , MAD_F(0x0ec835e8) ,
MAD_F(0x0f426cb5) , MAD_F(0x0f9ee890) ,
MAD_F(0x0fdcf549) , MAD_F(0x0ffc19fd) ,
MAD_F(0x0ffc19fd) , MAD_F(0x0fdcf549) ,
MAD_F(0x0f9ee890) , MAD_F(0x0f426cb5) ,
MAD_F(0x0ec835e8) , MAD_F(0x0e313245) ,
MAD_F(0x0d7e8807) , MAD_F(0x0cb19346) ,
MAD_F(0x0bcbe352) , MAD_F(0x0acf37ad) ,
MAD_F(0x09bd7ca0) , MAD_F(0x0898c779) ,
MAD_F(0x07635284) , MAD_F(0x061f78aa) ,
MAD_F(0x04cfb0e2) , MAD_F(0x03768962) ,
MAD_F(0x0216a2a2) , MAD_F(0x00b2aa3e) ,
}
derived from section 2.4.3.4.10.3 of ISO/IEC 11172-3
window_l[i] = sin((PI / 36) * (i + 1/2))
Definition at line 406 of file layer3.c.
Referenced by III_imdct_l().
mad_fixed_t const window_s[12] [static] |
Initial value:
{
MAD_F(0x0216a2a2) , MAD_F(0x061f78aa) ,
MAD_F(0x09bd7ca0) , MAD_F(0x0cb19346) ,
MAD_F(0x0ec835e8) , MAD_F(0x0fdcf549) ,
MAD_F(0x0fdcf549) , MAD_F(0x0ec835e8) ,
MAD_F(0x0cb19346) , MAD_F(0x09bd7ca0) ,
MAD_F(0x061f78aa) , MAD_F(0x0216a2a2) ,
}
derived from section 2.4.3.4.10.3 of ISO/IEC 11172-3
window_s[i] = sin((PI / 12) * (i + 1/2))
Definition at line 437 of file layer3.c.
Referenced by III_imdct_l(), and III_imdct_s().
1.5.5