Rev 228 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
228 | serge | 1 | /* |
2 | mpg123: main code of the program (not of the decoder...) |
||
3 | |||
4 | copyright 1995-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
||
5 | see COPYING and AUTHORS files in distribution or http://mpg123.de |
||
6 | initially written by Michael Hipp |
||
7 | |||
8 | mpg123 defines |
||
9 | used source: musicout.h from mpegaudio package |
||
10 | */ |
||
11 | |||
12 | #ifdef __cplusplus |
||
13 | extern "C" { |
||
14 | #endif |
||
15 | |||
16 | #include |
||
17 | #include |
||
18 | #ifndef _AUDIO_H_ |
||
19 | #define _AUDIO_H_ |
||
20 | |||
21 | typedef unsigned char byte; |
||
22 | #define off_t long |
||
23 | |||
24 | //#define I486_OPT 1 |
||
25 | |||
26 | #define SKIP_JUNK 1 |
||
27 | # define M_PI 3.14159265358979323846 |
||
28 | # define M_SQRT2 1.41421356237309504880 |
||
29 | # define REAL_IS_FLOAT |
||
30 | # define NEW_DCT9 |
||
31 | |||
32 | #ifdef REAL_IS_FLOAT |
||
33 | # define real float |
||
34 | # define REAL_SCANF "%f" |
||
35 | # define REAL_PRINTF "%f" |
||
36 | #else |
||
37 | # define real double |
||
38 | # define REAL_SCANF "%lf" |
||
39 | # define REAL_PRINTF "%f" |
||
40 | #endif |
||
41 | |||
42 | #ifndef DOUBLE_TO_REAL |
||
43 | # define DOUBLE_TO_REAL(x) (x) |
||
44 | #endif |
||
45 | #ifndef REAL_TO_SHORT |
||
46 | # define REAL_TO_SHORT(x) (x) |
||
47 | #endif |
||
48 | #ifndef REAL_PLUS_32767 |
||
49 | # define REAL_PLUS_32767 32767.0 |
||
50 | #endif |
||
51 | #ifndef REAL_MINUS_32768 |
||
52 | # define REAL_MINUS_32768 -32768.0 |
||
53 | #endif |
||
54 | #ifndef REAL_MUL |
||
55 | # define REAL_MUL(x, y) ((x) * (y)) |
||
56 | #endif |
||
57 | |||
58 | #define INLINE |
||
59 | /* AUDIOBUFSIZE = n*64 with n=1,2,3 ... */ |
||
60 | #define AUDIOBUFSIZE 16384 |
||
61 | |||
62 | #define FALSE 0 |
||
63 | #define TRUE 1 |
||
64 | |||
65 | #define MAX_NAME_SIZE 81 |
||
66 | #define SBLIMIT 32 |
||
67 | #define SCALE_BLOCK 12 |
||
68 | #define SSLIMIT 18 |
||
69 | |||
70 | #define MPG_MD_STEREO 0 |
||
71 | #define MPG_MD_JOINT_STEREO 1 |
||
72 | #define MPG_MD_DUAL_CHANNEL 2 |
||
73 | #define MPG_MD_MONO 3 |
||
74 | |||
75 | /* I suspect that 32767 would be a better idea here, but Michael put this in... */ |
||
76 | #define MAXOUTBURST 32768 |
||
77 | |||
78 | /* Pre Shift fo 16 to 8 bit converter table */ |
||
79 | #define AUSHIFT (3) |
||
80 | |||
81 | struct bitstream_info |
||
82 | { int bitindex; |
||
83 | unsigned char *wordpointer; |
||
84 | }; |
||
85 | extern struct bitstream_info bsi; |
||
86 | |||
87 | struct reader |
||
88 | { char *hFile; |
||
89 | unsigned char *buffer; |
||
90 | unsigned char *stream; |
||
91 | int strpos; |
||
92 | int strremain; |
||
93 | int filelen; |
||
94 | int filepos; |
||
95 | |||
96 | int (*head_read)(struct reader *,unsigned long *newhead); |
||
97 | int (*read_frame_body)(struct reader *,unsigned char *,int size); |
||
98 | }; |
||
99 | |||
100 | struct al_table |
||
101 | { short bits; |
||
102 | short d; |
||
103 | }; |
||
104 | |||
105 | struct frame { |
||
106 | struct al_table *alloc; |
||
107 | int (*synth)(real *,int,unsigned char *,int *); |
||
108 | int (*synth_mono)(real *,unsigned char *,int *); |
||
109 | int stereo; /* I _think_ 1 for mono and 2 for stereo */ |
||
110 | int jsbound; |
||
111 | int single; |
||
112 | int II_sblimit; |
||
113 | int down_sample_sblimit; |
||
114 | int lsf; /* 0: MPEG 1.0; 1: MPEG 2.0/2.5 -- both used as bool and array index! */ |
||
115 | int mpeg25; |
||
116 | int down_sample; |
||
117 | int header_change; |
||
118 | int lay; |
||
119 | int (*do_layer)(struct frame *fr,byte *pcm_out, int *pcm_size); |
||
120 | int error_protection; |
||
121 | int bitrate_index; |
||
122 | int sampling_frequency; |
||
123 | int padding; |
||
124 | int extension; |
||
125 | int mode; |
||
126 | int mode_ext; |
||
127 | int copyright; |
||
128 | int original; |
||
129 | int emphasis; |
||
130 | int framesize; /* computed framesize */ |
||
131 | int vbr; /* 1 if variable bitrate was detected */ |
||
132 | unsigned long num; /* the nth frame in some stream... */ |
||
133 | }; |
||
134 | |||
135 | #if 0 |
||
136 | struct parameter { |
||
137 | int aggressive; /* renice to max. priority */ |
||
138 | int shuffle; /* shuffle/random play */ |
||
139 | int remote; /* remote operation */ |
||
140 | int remote_err; /* remote operation to stderr */ |
||
141 | int outmode; /* where to out the decoded sampels */ |
||
142 | int quiet; /* shut up! */ |
||
143 | int xterm_title; /* Change xterm title to song names? */ |
||
144 | long usebuffer; /* second level buffer size */ |
||
145 | int tryresync; /* resync stream after error */ |
||
146 | int verbose; /* verbose level */ |
||
147 | int force_mono; |
||
148 | int force_stereo; |
||
149 | int force_8bit; |
||
150 | long force_rate; |
||
151 | int down_sample; |
||
152 | int checkrange; |
||
153 | long doublespeed; |
||
154 | long halfspeed; |
||
155 | int force_reopen; |
||
156 | long realtime; |
||
157 | char filename[256]; |
||
158 | long listentry; /* possibility to choose playback of one entry in playlist (0: off, > 0 : select, < 0; just show list*/ |
||
159 | int rva; /* (which) rva to do: <0: nothing, 0: radio/mix/track 1: album/audiophile */ |
||
160 | char* listname; /* name of playlist */ |
||
161 | int long_id3; |
||
162 | }; |
||
163 | #endif |
||
164 | |||
165 | #if 0 |
||
166 | struct reader { |
||
167 | int (*init)(struct reader *); |
||
168 | void (*close)(struct reader *); |
||
169 | int (*head_read)(struct reader *,unsigned long *newhead); |
||
170 | int (*head_shift)(struct reader *,unsigned long *head); |
||
171 | long (*skip_bytes)(struct reader *,off_t len); |
||
172 | int (*read_frame_body)(struct reader *,unsigned char *,int size); |
||
173 | int (*back_bytes)(struct reader *,off_t bytes); |
||
174 | int (*back_frame)(struct reader *,struct frame *,long num); |
||
175 | off_t (*tell)(struct reader *); |
||
176 | void (*rewind)(struct reader *); |
||
177 | off_t filelen; |
||
178 | off_t filepos; |
||
179 | int filept; |
||
180 | int flags; |
||
181 | unsigned char id3buf[128]; |
||
182 | }; |
||
183 | #endif |
||
184 | |||
185 | #define READER_FD_OPENED 0x1 |
||
186 | #define READER_ID3TAG 0x2 |
||
187 | #define READER_SEEKABLE 0x4 |
||
188 | |||
189 | //extern void audio_flush(int, struct audio_info_struct *); |
||
190 | |||
191 | //extern void print_header(struct frame *); |
||
192 | //extern void print_header_compact(struct frame *); |
||
193 | //extern void print_id3_tag(unsigned char *buf); |
||
194 | |||
195 | //extern int split_dir_file(const char *path, char **dname, char **fname); |
||
196 | |||
197 | extern unsigned int get1bit(void); |
||
198 | extern unsigned int getbits(int); |
||
199 | extern unsigned int getbits_fast(int); |
||
200 | //extern void backbits(int); |
||
201 | //extern int getbitoffset(void); |
||
202 | //extern int getbyte(void); |
||
203 | |||
204 | //extern void set_pointer(long); |
||
205 | |||
206 | //extern unsigned char *pcm_sample; |
||
207 | //extern int pcm_point; |
||
208 | //extern int audiobufsize; |
||
209 | |||
210 | //extern int OutputDescriptor; |
||
211 | |||
212 | #ifdef VARMODESUPPORT |
||
213 | extern int varmode; |
||
214 | extern int playlimit; |
||
215 | #endif |
||
216 | |||
217 | struct gr_info_s { |
||
218 | int scfsi; |
||
219 | unsigned part2_3_length; |
||
220 | unsigned big_values; |
||
221 | unsigned scalefac_compress; |
||
222 | unsigned block_type; |
||
223 | unsigned mixed_block_flag; |
||
224 | unsigned table_select[3]; |
||
225 | unsigned subblock_gain[3]; |
||
226 | unsigned maxband[3]; |
||
227 | unsigned maxbandl; |
||
228 | unsigned maxb; |
||
229 | unsigned region1start; |
||
230 | unsigned region2start; |
||
231 | unsigned preflag; |
||
232 | unsigned scalefac_scale; |
||
233 | unsigned count1table_select; |
||
234 | real *full_gain[3]; |
||
235 | real *pow2gain; |
||
236 | }; |
||
237 | |||
238 | struct III_sideinfo |
||
239 | { |
||
240 | unsigned main_data_begin; |
||
241 | unsigned private_bits; |
||
242 | struct { |
||
243 | struct gr_info_s gr[2]; |
||
244 | } ch[2]; |
||
245 | }; |
||
246 | |||
247 | extern int open_stream(char *,int fd); |
||
248 | extern void read_frame_init (struct frame* fr); |
||
249 | int read_frame(struct reader *rd, struct frame *fr); |
||
250 | |||
251 | |||
252 | /* why extern? */ |
||
253 | void prepare_audioinfo(struct frame *fr, struct audio_info_struct *nai); |
||
254 | int play_frame(int init,struct frame *fr); |
||
255 | int do_layer1(struct frame *fr,byte *pcm_sample, int *pcm_point); |
||
256 | int do_layer2(struct frame *fr,byte *pcm_sample, int *pcm_point); |
||
257 | int do_layer3(struct frame *fr,byte *pcm_sample, int *pcm_point); |
||
258 | extern void do_equalizer(real *bandPtr,int channel); |
||
259 | |||
260 | #ifdef PENTIUM_OPT |
||
261 | extern int synth_1to1_pent (real *,int,unsigned char *); |
||
262 | #endif |
||
263 | extern int synth_1to1 (real *,int,unsigned char *,int *); |
||
264 | extern int synth_1to1_8bit (real *,int,unsigned char *,int *); |
||
265 | extern int synth_1to1_mono (real *,unsigned char *,int *); |
||
266 | extern int synth_1to1_mono2stereo (real *,unsigned char *,int *); |
||
267 | extern int synth_1to1_8bit_mono (real *,unsigned char *,int *); |
||
268 | extern int synth_1to1_8bit_mono2stereo (real *,unsigned char *,int *); |
||
269 | |||
270 | extern int synth_2to1 (real *,int,unsigned char *,int *); |
||
271 | extern int synth_2to1_8bit (real *,int,unsigned char *,int *); |
||
272 | extern int synth_2to1_mono (real *,unsigned char *,int *); |
||
273 | extern int synth_2to1_mono2stereo (real *,unsigned char *,int *); |
||
274 | extern int synth_2to1_8bit_mono (real *,unsigned char *,int *); |
||
275 | extern int synth_2to1_8bit_mono2stereo (real *,unsigned char *,int *); |
||
276 | |||
277 | extern int synth_4to1 (real *,int,unsigned char *,int *); |
||
278 | extern int synth_4to1_8bit (real *,int,unsigned char *,int *); |
||
279 | extern int synth_4to1_mono (real *,unsigned char *,int *); |
||
280 | extern int synth_4to1_mono2stereo (real *,unsigned char *,int *); |
||
281 | extern int synth_4to1_8bit_mono (real *,unsigned char *,int *); |
||
282 | extern int synth_4to1_8bit_mono2stereo (real *,unsigned char *,int *); |
||
283 | |||
284 | extern int synth_ntom (real *,int,unsigned char *,int *); |
||
285 | extern int synth_ntom_8bit (real *,int,unsigned char *,int *); |
||
286 | extern int synth_ntom_mono (real *,unsigned char *,int *); |
||
287 | extern int synth_ntom_mono2stereo (real *,unsigned char *,int *); |
||
288 | extern int synth_ntom_8bit_mono (real *,unsigned char *,int *); |
||
289 | extern int synth_ntom_8bit_mono2stereo (real *,unsigned char *,int *); |
||
290 | |||
291 | extern void rewindNbits(int bits); |
||
292 | extern int hsstell(void); |
||
293 | extern void set_pointer(long); |
||
294 | extern void huffman_decoder(int ,int *); |
||
295 | extern void huffman_count1(int,int *); |
||
296 | extern void print_stat(struct frame *fr,unsigned long no,long buffsize,struct audio_info_struct *ai); |
||
297 | extern int get_songlen(struct frame *fr,int no); |
||
298 | |||
299 | extern void init_layer3(int); |
||
300 | extern void init_layer2(void); |
||
301 | extern void make_decode_tables(long scale); |
||
302 | extern int make_conv16to8_table(int); |
||
303 | extern void dct64(real *,real *,real *); |
||
304 | |||
305 | #ifdef USE_MMX |
||
306 | extern void dct64_MMX(short *a,short *b,real *c); |
||
307 | extern int synth_1to1_MMX(real *, int, short *, short *, int *); |
||
308 | #endif |
||
309 | |||
310 | extern int synth_ntom_set_step(long,long); |
||
311 | |||
312 | |||
313 | extern unsigned char *conv16to8; |
||
314 | extern long freqs[9]; |
||
315 | extern real muls[27][64]; |
||
316 | extern real decwin[512+32]; |
||
317 | #ifndef USE_MMX |
||
318 | extern real *pnts[5]; |
||
319 | #endif |
||
320 | |||
321 | extern real equalizer[2][32]; |
||
322 | extern real equalizer_sum[2][32]; |
||
323 | extern int equalizer_cnt; |
||
324 | |||
325 | extern struct audio_name audio_val2name[]; |
||
326 | |||
327 | //extern struct parameter param; |
||
328 | |||
329 | /* 486 optimizations */ |
||
330 | #define FIR_BUFFER_SIZE 128 |
||
331 | extern void dct64_486(int *a,int *b,real *c); |
||
332 | extern int synth_1to1_486(real *bandPtr,int channel,unsigned char *out,int nb_blocks); |
||
333 | |||
334 | /* 3DNow! optimizations */ |
||
335 | #ifdef USE_3DNOW |
||
336 | extern int getcpuflags(void); |
||
337 | extern void dct36(real *,real *,real *,real *,real *); |
||
338 | extern void dct36_3dnow(real *,real *,real *,real *,real *); |
||
339 | extern int synth_1to1_3dnow(real *,int,unsigned char *,int *); |
||
340 | #endif |
||
341 | |||
342 | /* avoid the SIGINT in terminal control */ |
||
343 | void next_track(void); |
||
344 | extern long outscale; |
||
345 | |||
346 | #endif |
||
347 | |||
348 | void set_pointer(long backstep); |
||
349 | int __stdcall create_reader(struct reader *rd,byte *buffer, int buffsize); |
||
350 | int __stdcall init_reader(struct reader *rd, char *file); |
||
351 | int __stdcall decode_header(struct frame *fr,unsigned long newhead); |
||
352 | int __stdcall set_reader(struct reader *rd, unsigned int filepos); |
||
353 | double pow_test(double, double); |
||
354 | void * __cdecl mem_cpy(void * dst,const void * src,size_t count); |
||
286 | serge | 355 | void init_dct(); |
356 | void reset_mpg(); |
||
228 | serge | 357 | #ifdef __cplusplus |
358 | } |
||
359 | #endif0:>> |