aboutsummaryrefslogtreecommitdiffstats
path: root/codecs/mp3/include/L3.h
blob: e920afd94d3e20347ea7fc3a3a18f0f06ba78a82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*____________________________________________________________________________
	
	FreeAmp - The Free MP3 Player

        MP3 Decoder originally Copyright (C) 1996-1997 Xing Technology
        Corp.  http://www.xingtech.com

	Portions Copyright (C) 1998-1999 Emusic.com

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
	
	$Id$
____________________________________________________________________________*/

/****  L3.h  ***************************************************

  Layer III structures

  *** Layer III is 32 bit only          ***
  *** Layer III code assumes 32 bit int ***

******************************************************************/

#define GLOBAL_GAIN_SCALE (4*15)
/* #define GLOBAL_GAIN_SCALE 0 */


#ifdef _M_IX86
#define LITTLE_ENDIAN 1
#endif

#ifdef _M_ALPHA
#define LITTLE_ENDIAN 1
#endif

#ifdef sparc
#define LITTLE_ENDIAN 0
#endif

#ifndef LITTLE_ENDIAN
#error Layer III LITTLE_ENDIAN must be defined 0 or 1
#endif

/*-----------------------------------------------------------*/
/*---- huffman lookup tables ---*/
/* endian dependent !!! */
#if LITTLE_ENDIAN
typedef union
{
   int ptr;
   struct
   {
      unsigned char signbits;
      unsigned char x;
      unsigned char y;
      unsigned char purgebits;	// 0 = esc

   }
   b;
}
HUFF_ELEMENT;

#else /* big endian machines */
typedef union
{
   int ptr;			/* int must be 32 bits or more */
   struct
   {
      unsigned char purgebits;	// 0 = esc

      unsigned char y;
      unsigned char x;
      unsigned char signbits;
   }
   b;
}
HUFF_ELEMENT;

#endif
/*--------------------------------------------------------------*/
typedef struct
{
   unsigned int bitbuf;
   int bits;
   unsigned char *bs_ptr;
   unsigned char *bs_ptr0;
   unsigned char *bs_ptr_end;	// optional for overrun test

}
BITDAT;

/*-- side info ---*/
typedef struct
{
   int part2_3_length;
   int big_values;
   int global_gain;
   int scalefac_compress;
   int window_switching_flag;
   int block_type;
   int mixed_block_flag;
   int table_select[3];
   int subblock_gain[3];
   int region0_count;
   int region1_count;
   int preflag;
   int scalefac_scale;
   int count1table_select;
}
GR;
typedef struct
{
   int mode;
   int mode_ext;
/*---------------*/
   int main_data_begin;		/* beginning, not end, my spec wrong */
   int private_bits;
/*---------------*/
   int scfsi[2];		/* 4 bit flags [ch] */
   GR gr[2][2];			/* [gran][ch] */
}
SIDE_INFO;

/*-----------------------------------------------------------*/
/*-- scale factors ---*/
// check dimensions - need 21 long, 3*12 short
// plus extra for implicit sf=0 above highest cb
typedef struct
{
   int l[23];			/* [cb] */
   int s[3][13];		/* [window][cb] */
}
SCALEFACT;

/*-----------------------------------------------------------*/
typedef struct
{
   int cbtype;			/* long=0 short=1 */
   int cbmax;			/* max crit band */
//   int lb_type;			/* long block type 0 1 3 */
   int cbs0;			/* short band start index 0 3 12 (12=no shorts */
   int ncbl;			/* number long cb's 0 8 21 */
   int cbmax_s[3];		/* cbmax by individual short blocks */
}
CB_INFO;

/*-----------------------------------------------------------*/
/* scale factor infor for MPEG2 intensity stereo  */
typedef struct
{
   int nr[3];
   int slen[3];
   int intensity_scale;
}
IS_SF_INFO;

/*-----------------------------------------------------------*/
typedef union
{
   int s;
   float x;
}
SAMPLE;

/*-----------------------------------------------------------*/