layer3.c File Reference

Implements MPEG Layer III method for mad_stream structure. More...

#include "global.h"
#include <stdlib.h>
#include <string.h>
#include "fixed.h"
#include "bit.h"
#include "stream.h"
#include "frame.h"
#include "huffman.h"
#include "layer3.h"
#include "rq_table.dat"
#include "imdct_s.dat"

Include dependency graph for layer3.c:

Go to the source code of this file.

Data Structures

struct  sideinfo
struct  sideinfo::granule
struct  sideinfo::granule::channel
struct  fixedfloat
 table for requantization. More...

Defines

#define CHAR_BIT   8
#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.


Detailed Description

Implements MPEG Layer III method for mad_stream structure.

Definition in file layer3.c.


Define Documentation

#define CHAR_BIT   8

Definition at line 41 of file layer3.c.


Variable Documentation

unsigned char const* l

Definition at line 308 of file layer3.c.

Referenced by III_decode(), III_exponents(), III_reorder(), and III_stereo().

unsigned char const* m

Definition at line 310 of file layer3.c.

Referenced by III_decode(), III_stereo(), and mad_timer_string().

unsigned char const* s

unsigned char slen1

Definition at line 100 of file layer3.c.

Referenced by III_scalefactors().

unsigned char slen2

Definition at line 101 of file layer3.c.

Referenced by III_scalefactors().


Generated on Tue Jun 10 12:14:18 2008 for libmad by  doxygen 1.5.5