1 /*____________________________________________________________________________
2 
3 	FreeAmp - The Free MP3 Player
4 
5         MP3 Decoder originally Copyright (C) 1996-1997 Xing Technology
6         Corp.  http://www.xingtech.com
7 
8 	Portions Copyright (C) 1998-1999 Emusic.com
9 
10 	This program is free software; you can redistribute it and/or modify
11 	it under the terms of the GNU General Public License as published by
12 	the Free Software Foundation; either version 2 of the License, or
13 	(at your option) any later version.
14 
15 	This program is distributed in the hope that it will be useful,
16 	but WITHOUT ANY WARRANTY; without even the implied warranty of
17 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 	GNU General Public License for more details.
19 
20 	You should have received a copy of the GNU General Public License
21 	along with this program; if not, write to the Free Software
22 	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 
24 	$Id: L3.h,v 1.10 2000/10/13 14:29:02 ijr Exp $
25 ____________________________________________________________________________*/
26 
27 #ifndef _L3_H_
28 #define _L3_H_
29 
30 /****  L3.h  ***************************************************
31 
32   Layer III structures
33 
34   *** Layer III is 32 bit only          ***
35   *** Layer III code assumes 32 bit int ***
36 
37 ******************************************************************/
38 
39 #define GLOBAL_GAIN_SCALE (4*15)
40 /* #define GLOBAL_GAIN_SCALE 0 */
41 
42 #include <sys/types.h>
43 
44 #ifdef BYTE_ORDER
45 #if BYTE_ORDER == LITTLE_ENDIAN
46 #define L_ENDIAN 1
47 #else
48 #define L_ENDIAN 0
49 #endif
50 #else
51 
52 #ifdef i386
53 #define L_ENDIAN 1
54 #endif
55 
56 #ifdef _M_IX86
57 #define L_ENDIAN 1
58 #endif
59 
60 #ifdef _M_ALPHA
61 #define L_ENDIAN 1
62 #endif
63 
64 #ifdef sparc
65 #define L_ENDIAN 0
66 #endif
67 
68 #endif
69 
70 #ifndef L_ENDIAN
71 #error Layer III L_ENDIAN must be defined 0 or 1
72 #endif
73 
74 /*-----------------------------------------------------------*/
75 /*---- huffman lookup tables ---*/
76 /* endian dependent !!! */
77 #if L_ENDIAN
78 typedef union
79 {
80    int ptr;
81    struct
82    {
83       unsigned char signbits;
84       unsigned char x;
85       unsigned char y;
86       unsigned char purgebits;	// 0 = esc
87 
88    }
89    b;
90 }
91 HUFF_ELEMENT;
92 
93 #else /* big endian machines */
94 typedef union
95 {
96    int ptr;			/* int must be 32 bits or more */
97    struct
98    {
99       unsigned char purgebits;	// 0 = esc
100 
101       unsigned char y;
102       unsigned char x;
103       unsigned char signbits;
104    }
105    b;
106 }
107 HUFF_ELEMENT;
108 
109 #endif
110 /*--------------------------------------------------------------*/
111 typedef struct
112 {
113    unsigned int bitbuf;
114    int bits;
115    unsigned char *bs_ptr;
116    unsigned char *bs_ptr0;
117    unsigned char *bs_ptr_end;	// optional for overrun test
118 
119 }
120 BITDAT;
121 
122 /*-- side info ---*/
123 typedef struct
124 {
125    int part2_3_length;
126    int big_values;
127    int global_gain;
128    int scalefac_compress;
129    int window_switching_flag;
130    int block_type;
131    int mixed_block_flag;
132    int table_select[3];
133    int subblock_gain[3];
134    int region0_count;
135    int region1_count;
136    int preflag;
137    int scalefac_scale;
138    int count1table_select;
139 }
140 GR;
141 typedef struct
142 {
143    int mode;
144    int mode_ext;
145 /*---------------*/
146    int main_data_begin;		/* beginning, not end, my spec wrong */
147    int private_bits;
148 /*---------------*/
149    int scfsi[2];		/* 4 bit flags [ch] */
150    GR gr[2][2];			/* [gran][ch] */
151 }
152 SIDE_INFO;
153 
154 /*-----------------------------------------------------------*/
155 /*-- scale factors ---*/
156 // check dimensions - need 21 long, 3*12 short
157 // plus extra for implicit sf=0 above highest cb
158 typedef struct
159 {
160    int l[23];			/* [cb] */
161    int s[3][13];		/* [window][cb] */
162 }
163 SCALEFACT;
164 
165 /*-----------------------------------------------------------*/
166 typedef struct
167 {
168    int cbtype;			/* long=0 short=1 */
169    int cbmax;			/* max crit band */
170 //   int lb_type;			/* long block type 0 1 3 */
171    int cbs0;			/* short band start index 0 3 12 (12=no shorts */
172    int ncbl;			/* number long cb's 0 8 21 */
173    int cbmax_s[3];		/* cbmax by individual short blocks */
174 }
175 CB_INFO;
176 
177 /*-----------------------------------------------------------*/
178 /* scale factor infor for MPEG2 intensity stereo  */
179 typedef struct
180 {
181    int nr[3];
182    int slen[3];
183    int intensity_scale;
184 }
185 IS_SF_INFO;
186 
187 /*-----------------------------------------------------------*/
188 typedef union
189 {
190    int s;
191    float x;
192 }
193 SAMPLE;
194 
195 /*-----------------------------------------------------------*/
196 
197 #endif
198