catori 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/VERSION +1 -0
  2. data/bin/catori +9 -0
  3. data/changelog.txt +3 -0
  4. data/construir +3 -0
  5. data/crear_vista.sql +8 -0
  6. data/ext/audiofile/MANIFEST +8 -0
  7. data/ext/audiofile/README +11 -0
  8. data/ext/audiofile/audiofile.c +833 -0
  9. data/ext/audiofile/audiofile.rd +265 -0
  10. data/ext/audiofile/depend +0 -0
  11. data/ext/audiofile/extconf.rb +8 -0
  12. data/ext/audiofile/fail.rb +22 -0
  13. data/ext/audiofile/mkmf.log +34 -0
  14. data/ext/audiofile/test.rb +229 -0
  15. data/ext/flac/extconf.rb +5 -0
  16. data/ext/flac/flac.c +75 -0
  17. data/ext/flac/mkmf.log +12 -0
  18. data/ext/flac/test.rb +3 -0
  19. data/ext/mahoro-0.1/INSTALL +9 -0
  20. data/ext/mahoro-0.1/extconf.rb +7 -0
  21. data/ext/mahoro-0.1/mahoro.c +187 -0
  22. data/ext/mahoro-0.1/mkmf.log +24 -0
  23. data/ext/mahoro-0.1/test.rb +41 -0
  24. data/ext/mpc/extconf.rb +5 -0
  25. data/ext/mpc/id3tag.c +245 -0
  26. data/ext/mpc/id3tag.h +5 -0
  27. data/ext/mpc/mkmf.log +12 -0
  28. data/ext/mpc/mpc.c +56 -0
  29. data/ext/mpc/mpp.h +194 -0
  30. data/ext/mpc/mppdec.h +1171 -0
  31. data/ext/mpc/test.rb +3 -0
  32. data/ext/rmac/extconf.rb +7 -0
  33. data/ext/rmac/mkmf.log +22 -0
  34. data/ext/rmac/rmac.cpp +162 -0
  35. data/ext/vorbisfile/ChangeLog +11 -0
  36. data/ext/vorbisfile/README +33 -0
  37. data/ext/vorbisfile/configure +2 -0
  38. data/ext/vorbisfile/extconf.rb +9 -0
  39. data/ext/vorbisfile/mkmf.log +68 -0
  40. data/ext/vorbisfile/test.rb +78 -0
  41. data/ext/vorbisfile/vorbisfile.c +482 -0
  42. data/instalar.txt +19 -0
  43. data/install.rb +11 -0
  44. data/lib/audioinfo.rb +321 -0
  45. data/lib/catori.rb +131 -0
  46. data/lib/catori/Catalogador.rb +71 -0
  47. data/lib/catori/Db.rb +81 -0
  48. data/lib/catori/Gui.rb +52 -0
  49. data/lib/catori/Installer.rb +16 -0
  50. data/lib/catori/Query.rb +82 -0
  51. data/lib/catori/XML.rb +42 -0
  52. data/lib/catori/catori_gui.glade +340 -0
  53. data/lib/catori/catori_gui.glade.bak +340 -0
  54. data/lib/catori/catori_gui.gladep +8 -0
  55. data/lib/catori/catori_gui.gladep.bak +8 -0
  56. data/lib/catori/taglib.rb +227 -0
  57. data/lib/pixmaps/album.png +0 -0
  58. data/lib/pixmaps/artist.png +0 -0
  59. data/lib/pixmaps/cdr.png +0 -0
  60. data/lib/pixmaps/song.png +0 -0
  61. data/lib/taglib.rb +230 -0
  62. data/sql/catori_mysql.sql +68 -0
  63. data/sql/catori_pg.sql +65 -0
  64. data/tests/saw.ape +0 -0
  65. data/tests/saw.flac +0 -0
  66. data/tests/saw.mp3 +0 -0
  67. data/tests/saw.mpc +0 -0
  68. data/tests/saw.ogg +0 -0
  69. data/tests/saw.wav +0 -0
  70. data/tests/test_audioinfo.rb +43 -0
  71. metadata +217 -0
@@ -0,0 +1,5 @@
1
+ #ifndef __ID3_TAG__
2
+ #define __ID3_TAG__
3
+ Int Read_ID3V1_Tags ( FILE_T fp, TagInfo_t* tip );
4
+ Int Read_APE_Tags ( FILE_T fp, TagInfo_t* tip );
5
+ #endif
@@ -0,0 +1,12 @@
1
+ have_library: checking for main() in -lmpcdec... -------------------- yes
2
+
3
+ "i686-pc-linux-gnu-gcc -o conftest -I. -I/usr/lib/ruby/1.8/i686-linux -I. -O2 -march=athlon-xp -m3dnow -msse -mfpmath=sse -mmmx -pipe -fno-strict-aliasing -fPIC -Wall conftest.c -L'.' -L'/usr/lib' -Wl,-R'/usr/lib' -L. -rdynamic -Wl,-export-dynamic -lruby18-static -lmpcdec -ldl -lcrypt -lm -lc"
4
+ checked program was:
5
+ /* begin */
6
+ 1: /*top*/
7
+ 2: int main() { return 0; }
8
+ 3: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
9
+ /* end */
10
+
11
+ --------------------
12
+
@@ -0,0 +1,56 @@
1
+ #include <stdio.h>
2
+ #include <ctype.h>
3
+ #include <string.h>
4
+ #include <mpcdec/mpcdec.h>
5
+ #include <ruby.h>
6
+ #include "mppdec.h"
7
+ #include "id3tag.h"
8
+
9
+ static VALUE mMpc;
10
+ static VALUE cInfo;
11
+ static VALUE rb_mpc_info(VALUE module, VALUE filename);
12
+
13
+ void
14
+ Init_mpc()
15
+ {
16
+ mMpc = rb_define_module("Mpc");
17
+ cInfo = rb_define_class_under(mMpc, "Info", rb_cObject);
18
+
19
+ int i = 0;
20
+ //#define NA 5
21
+ const char *attr2[] =
22
+ { "time", "bps","sample_rate", "channels", "bits_per_sample", "comments","tracknumber","year","title","artist","album","comment",NULL
23
+ };
24
+
25
+ for (i = 0; attr2[i]; i++) {
26
+ rb_define_attr(cInfo, attr2[i], 1, 0);
27
+ }
28
+
29
+ rb_define_module_function(mMpc, "info", rb_mpc_info, 1);
30
+ }
31
+
32
+ VALUE
33
+ rb_mpc_info(VALUE self, VALUE filename)
34
+ {
35
+ VALUE info = rb_class_new_instance(0, NULL, cInfo);
36
+ mpc_reader_file r;
37
+ mpc_streaminfo si;
38
+ TagInfo_t tags;
39
+ FILE *fp=fopen(STR2CSTR(filename),"r");
40
+ mpc_streaminfo_init(&si);
41
+ mpc_reader_setup_file_reader(&r,fp);
42
+ mpc_streaminfo_read(&si,&r.reader);
43
+ rb_iv_set(info,"@time",rb_float_new(mpc_streaminfo_get_length(&si)));
44
+ rb_iv_set(info,"@sample_rate",INT2FIX(si.sample_freq));
45
+ rb_iv_set(info,"@channels",INT2FIX(si.channels));
46
+ rb_iv_set(info,"@bps",rb_float_new(si.average_bitrate));
47
+ Read_APE_Tags(fp,&tags);
48
+ rb_iv_set(info,"@tracknumber",rb_str_new2(tags.Track));
49
+ rb_iv_set(info,"@year",rb_str_new2(tags.Year));
50
+ rb_iv_set(info,"@title",rb_str_new2(tags.Title));
51
+ rb_iv_set(info,"@artist",rb_str_new2(tags.Artist));
52
+ rb_iv_set(info,"@album",rb_str_new2(tags.Album));
53
+ rb_iv_set(info,"@comment",rb_str_new2(tags.Comment));
54
+ fclose(fp);
55
+ return info;
56
+ }
@@ -0,0 +1,194 @@
1
+ /*
2
+ * Musepack audio compression
3
+ * Copyright (C) 1999-2004 Buschmann/Klemm/Piecha/Wolf
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ */
19
+
20
+ /******************************************************
21
+ * *
22
+ * Source Compile configuration *
23
+ * *
24
+ ******************************************************/
25
+
26
+
27
+ #if !defined(__APPLE__)
28
+ // use optimized assembler routines for Pentium III/K6-2/Athlon (only 32 bit OS, Intel x86 and no MAKE_xxBITS)
29
+ // you need the NASM assembler on your system, the program becomes a little bit larger and decoding
30
+ // on AMD K6-2 (x3), AMD K6-III (x3), AMD Duron (x1.7), AMD Athlon (x1.7), Pentium III (x2) and Pentium 4 (x1.8) becomes faster
31
+ #define USE_ASM
32
+
33
+ // Open Sound System support (only Unix with OSS support)
34
+ // If your Operating System supports the Open Sound System, you can output to /dev/dsp* and
35
+ // instead of writing a file the program plays the file via this sound device.
36
+ // on some systems you also must link the libossaudio library, so maybe you also must edit the Makefile
37
+ #define USE_OSS_AUDIO
38
+
39
+ // Enlightenment Sound Daemon support (only Unix with ESD support)
40
+ // If your Operating System supports the Enlightenment Sound Daemon you can output to /dev/esd and
41
+ // instead of writing a file the program plays the file via this sound device.
42
+ // you also must link the libesd library, so maybe you also must edit the Makefile
43
+ #define USE_ESD_AUDIO
44
+
45
+ #endif
46
+
47
+ // native Sun Onboard-Audio support (only SunOS)
48
+ // If you have a Sun Workstation with Onboard-Audio, you can output to /dev/audio and
49
+ // instead of writing a file the program plays the file via this sound device.
50
+ // Some machines lacking librt.a so you are unable to link a static executable with realtime-support.
51
+ // Although you can still perfectly use the dynamic executable.
52
+ //#define USE_SUN_AUDIO
53
+
54
+ // Sound support for SGI Irix
55
+ // If you have a SGI Workstation running IRIX, you can output to /dev/audio and
56
+ // instead of writing a file the program plays the file via this sound device.
57
+ #define USE_IRIX_AUDIO
58
+
59
+ // Audio support for Windows (WAVE OUT) (only Windows)
60
+ // If you have a Windows based system and if you want also play files directly instead of only writing audio files,
61
+ // then define the next item
62
+ #define USE_WIN_AUDIO
63
+
64
+ // Buffersize for Windows Audio in 4.5 KByte units
65
+ // Only needed for Windows+USE_WIN_AUDIO
66
+ // Good values are 8...32 for fast machines and 128...512 for slow machines
67
+ // large values decrease average performance a little bit, increase memory
68
+ // consumption (1 Block = 4.5 KByte), but increase buffering, so it takes a
69
+ // longer time to get a drop out. Note that I don't have a 486/80...133, so
70
+ // I don't know anything about their performance.
71
+ // (Attention: 512 = additional 2.3 MByte of memory)
72
+ #define MAX_WAVEBLOCKS 40
73
+
74
+ // increase priority if destination is an audio device
75
+ // this increases the priority of the decoder when playing the file directly to a sound card to reduce/prevent
76
+ // drop outs during the playback due to CPU time shortage
77
+ #define USE_NICE
78
+
79
+ // use realtime scheduling if destination is an audio device
80
+ // This sets the program to real time priority when playing the file directly to a sound card.
81
+ // Now it should really difficult to get drop outs (file IO and other realtime programs are the remaining weak points)
82
+ #define USE_REALTIME
83
+
84
+ // use ANSI-Escape sequences to structure output
85
+ #define USE_ANSI_ESCAPE
86
+
87
+ // Use termios for reading values from keyboard without echo and ENTER
88
+ #define USE_TERMIOS
89
+
90
+ // if none of the next three macros MAKE_xxBIT is defined,
91
+ // normal non-dithered and non-shaped 16 bit PCM output is generated
92
+
93
+ // create 16 bit Output
94
+ // output is 16 bit wide, you can also dither and noise shape
95
+ //#define MAKE_16BIT
96
+
97
+ // create 24 bit Output
98
+ // output is 24 bit wide instead of 16 bit wide, you can also dither and noise shape
99
+ //#define MAKE_24BIT
100
+
101
+ // create 32 bit Output
102
+ // output is 32 bit wide instead of 16 bit wide, you can also dither and noise shape
103
+ //#define MAKE_32BIT
104
+ #define MPP_ENCODER 1
105
+ // Select subset of function used for file I/O:
106
+ // 1: ANSI via file pointer (FILE*)
107
+ // 2: POSIX via file handle (int or HANDLE)
108
+ // 3: POSIX like lowest level function of Turbo/Borland C
109
+ // 4: WinAMP 3: running inside WinAMP
110
+ // Try to use '2', if this doesn't work, try '1'. '3' is for Borland compilers.
111
+ #ifndef FILEIO
112
+ # if defined MPP_ENCODER
113
+ # define FILEIO 1 // mppenc still uses buffered ANSI-I/O
114
+ # elif defined MPP_DECODER
115
+ # define FILEIO 2
116
+ # else
117
+ # error Neigher MPP_DECODER nor MPP_ENCODER is defined. Abort.
118
+ # endif
119
+ #endif
120
+
121
+ // the POSIX function read() can return less bytes than requested not only at the end of the file.
122
+ // if this happens, the following macro must be defined:
123
+ #define HAVE_INCOMPLETE_READ
124
+
125
+ // use a shorter Huffman_t representation, may be faster
126
+ // use for performance tuning
127
+ #define USE_HUFF_PACK
128
+
129
+ // use shorter representation for SCF_Index[][] and Res[], may be faster
130
+ // use for performance tuning
131
+ #define USE_ARRAY_PACK
132
+
133
+ // use the System 5 timer for profiling
134
+ // otherwise a special piece of code for Turbo-C is used or the Timestamp Counter on Intel IA32/gcc systems.
135
+ // Both is highly non portable. This solution is more portable (you only need a SYS 5 compatible system,
136
+ // but also much much more inaccurate.
137
+ //#define USE_SYSV_TIMER
138
+
139
+ // do a memory shift every n subband samples, otherwise only increment pointer (6, 12, 18 and 36 are good values)
140
+ // use for performance tuning
141
+ #define VIRT_SHIFT 18
142
+
143
+ // selects InputBuff size, size is 4 * 2^IBUFLOG2 bytes (11...14 are good values)
144
+ // use for performance tuning
145
+ // can also be used to eliminate disk performance issue while tuning the program
146
+ // (set to a value, so the test cases are fully read before decoding
147
+ #define IBUFLOG2 14
148
+
149
+ // Dump contents of MPEGplus files (only for development), 0x00 no dump
150
+ // Bit 0: maxband, Bit 1: msbits, Bit 2: allocation/resolution, Bit 3: SCF
151
+ // Bit 4: Subsamples, Bit 5: Datenrate, Bit 6: Bitusage der Sektionen
152
+ //#define DUMPSELECT 0xFF
153
+
154
+ // 16 bit and 32 bit accesses must be aligned, otherwise a bus error occures.
155
+ // try this if you get bus errors
156
+ //#define MUST_ALIGNED
157
+
158
+ // Experimental: use http/ftp streaming
159
+ #define USE_HTTP
160
+
161
+ // _use setargv module
162
+ #define USE_ARGV
163
+
164
+
165
+ // Use IPv4 and IPv6
166
+ //#define USE_IPv4_6
167
+ // Use only IPv6
168
+ //#define USE_IPv6
169
+
170
+ // compile StreamVersion 8 decoding (always disable, no usabiltity)
171
+ // do not edit
172
+ //#define USE_SV8
173
+
174
+ // disables assert()
175
+ // assert() is for development only and decreases speed and increases the size of the program
176
+ #ifndef NDEBUG
177
+ # define NDEBUG
178
+ #endif
179
+
180
+ // Some other tracing (only for development)
181
+ // do not edit
182
+ //#define DEBUG
183
+
184
+ // Some tracings of popen()
185
+ // do not edit
186
+ //#define DEBUG2
187
+
188
+ // activate simple profiler
189
+ //#define PROFILE
190
+
191
+ // make debug output in tags.c stfu
192
+ #define STFU
193
+
194
+ /* end of mpp.h */
@@ -0,0 +1,1171 @@
1
+ /*
2
+ * Musepack audio compression
3
+ * Copyright (C) 1999-2004 Buschmann/Klemm/Piecha/Wolf
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ */
19
+
20
+ //// Macros typical for Compilers:
21
+ //
22
+ // __TURBOC__ Turbo-C, Borland-C
23
+ // __BORLANDC__ Borland-C
24
+ // __ZTC__ Zortech-C
25
+ // _MSC_VER Microsoft-C
26
+ // __EMX__ Eberhard Mattes EMX (GNU based)
27
+ // __GNUC__ GNU C based compiler (also Cygwin)
28
+ // __CYGWIN__ Cygnus Windows C-Compiler (GNU based)
29
+ // __APPLE_CC__ Apple GCC (GNU based)
30
+
31
+
32
+ //// Macros typical for Operating Systems
33
+ //
34
+ // __linux__ Linux
35
+ // __bsdi__ BSDi
36
+ // __FreeBSD__ FreeBSD
37
+ // __NetBSD__ NetBSD
38
+ // __OpenBSD__ OpenBSD
39
+ // __unix__ Unix ????????
40
+ // _WIN16 16 bit-Windows
41
+ // _WIN32 32 bit-Windows (WIN32 is wrong, not defined by not MSC) (also __GNUC__ + _WIN32 is possible)
42
+ // _HPUX_SOURCE HP-UX
43
+ // __BEOS__ BeOS
44
+ // __APPLE__ Apple Mac OS X (only when using Apple GCC)
45
+ // ??????? MS-DOS and relatives
46
+
47
+
48
+ //// Macros typical for special conformances
49
+ // System 5 Release 4 (SVr4)
50
+ // System 5 ID (SVID)
51
+ // POSIX 1.0
52
+ // POSIX 1.0b
53
+ // X/OPEN
54
+ // BSD 4.3
55
+ // BSD 4.4
56
+ // ANSI
57
+
58
+
59
+ // Macros to manipulate Sockets + Files in one, in (+0x4000)
60
+ // output times TIME/TIME_T/DTIME
61
+
62
+ #ifndef MPPDEC_MPPDEC_H
63
+ #define MPPDEC_MPPDEC_H
64
+
65
+ //// optimization/feature defines //////////////////////////////////
66
+ #ifndef NOT_INCLUDE_CONFIG_H
67
+ # include "config.h"
68
+ #endif
69
+ #include "./mpp.h"
70
+
71
+
72
+ //// portable system includes //////////////////////////////////////
73
+ #include <stdio.h>
74
+ #include <stdlib.h>
75
+ #include <stddef.h>
76
+ #include <stdarg.h>
77
+ #include <string.h>
78
+ #include <limits.h>
79
+ #include <assert.h>
80
+ #include <math.h>
81
+
82
+
83
+ //// system dependent system includes //////////////////////////////
84
+ // low level I/O, where are prototypes and constants?
85
+ #if defined _WIN32 || defined __TURBOC__ || defined __ZTC__ || defined _MSC_VER
86
+ # include <io.h>
87
+ # include <fcntl.h>
88
+ # include <time.h>
89
+ # include <sys/types.h>
90
+ # include <sys/stat.h>
91
+ #elif defined __unix__ || defined __linux__ || defined __APPLE__
92
+ # include <fcntl.h>
93
+ # include <unistd.h>
94
+ # include <sys/time.h>
95
+ # include <sys/ioctl.h>
96
+ # include <sys/types.h>
97
+ # include <sys/stat.h>
98
+ #else
99
+ // .... add Includes for new Operating System here (with prefix: #elif defined)
100
+ # include <fcntl.h>
101
+ # include <unistd.h>
102
+ # include <sys/ioctl.h>
103
+ # include <sys/stat.h>
104
+ #endif
105
+
106
+
107
+ #if defined __linux__
108
+ # include <fpu_control.h>
109
+ #elif defined __FreeBSD__
110
+ # include <machine/floatingpoint.h>
111
+ #elif defined _MSC_VER
112
+ # include <float.h>
113
+ #endif
114
+
115
+
116
+ #if defined _WIN32
117
+ # undef USE_OSS_AUDIO
118
+ # undef USE_ESD_AUDIO
119
+ # undef USE_SUN_AUDIO
120
+ #else
121
+ # undef USE_WIN_AUDIO
122
+ #endif
123
+
124
+ #if defined __APPLE__
125
+ # undef USE_OSS_AUDIO
126
+ # undef USE_SUN_AUDIO
127
+ # undef USE_WIN_AUDIO
128
+ # undef USE_NICE
129
+ # undef USE_REALTIME
130
+ # undef USE_ASM
131
+ # undef USE_ESD_AUDIO
132
+ # define NO_DEV_AUDIO
133
+ # undef ENDIAN
134
+ # define ENDIAN HAVE_BIG_ENDIAN
135
+ #endif
136
+
137
+ #if defined __TURBOC__
138
+ # undef USE_OSS_AUDIO
139
+ # undef USE_ESD_AUDIO
140
+ # undef USE_SUN_AUDIO
141
+ # undef USE_NICE
142
+ # undef USE_REALTIME
143
+ #endif
144
+
145
+ #if defined USE_DIET || defined MAKE_24BIT || defined MAKE_32BIT
146
+ # undef USE_ESD_AUDIO
147
+ #endif
148
+
149
+ #if defined MAKE_16BIT || defined MAKE_24BIT || defined MAKE_32BIT
150
+ # undef USE_ASM
151
+ #endif
152
+
153
+ #if INT_MAX < 2147483647L
154
+ # undef USE_ASM
155
+ #endif
156
+
157
+ // sound card
158
+ #if defined USE_OSS_AUDIO
159
+ # include <sys/ioctl.h>
160
+ # include <sys/time.h>
161
+ # if defined __linux__ // the standard is that this file is stored somewhere on the hard disk
162
+ # include <linux/soundcard.h>
163
+ # elif defined __bsdi__
164
+ # include <sys/soundcard.h>
165
+ # elif defined __FreeBSD__
166
+ # include <machine/soundcard.h>
167
+ # elif defined __NetBSD__ || defined __OpenBSD__
168
+ # include <soundcard.h>
169
+ # elif defined __APPLE__ && defined __MACH__
170
+ # include <pleasepatchheretherightpathofsoundcard.hforMacOSX/soundcard.h>
171
+ # else
172
+ # include <pleasepatchheretherightpathof/soundcard.h>
173
+ # endif
174
+ #endif /* USE_OSS_AUDIO */
175
+
176
+ #if defined USE_ESD_AUDIO
177
+ # include <esd.h>
178
+ #endif
179
+
180
+ #if defined USE_SUN_AUDIO
181
+ # include <sys/audioio.h>
182
+ #endif
183
+
184
+ #ifdef MPP_ENCODER
185
+ # undef USE_HTTP
186
+ #endif
187
+
188
+ #ifdef USE_HTTP
189
+ # ifdef _WIN32
190
+ # include <winsock2.h>
191
+ # else
192
+ # include <sys/socket.h>
193
+ # endif
194
+ #endif
195
+
196
+ #if defined USE_WIN_AUDIO
197
+ # include <windows.h>
198
+ # define WINAUDIO_FD ((FILE_T)-128)
199
+ #elif defined USE_IRIX_AUDIO
200
+ # define IRIXAUDIO_FD ((FILE_T)-127)
201
+ #endif
202
+ #define NULL_FD ((FILE_T)-126)
203
+
204
+ #if defined USE_NICE && !defined _WIN32
205
+ # include <sys/resource.h>
206
+ #endif
207
+
208
+ // scheduler stuff
209
+ #if defined USE_REALTIME && !defined _WIN32
210
+ # include <sched.h>
211
+ #endif
212
+
213
+ #ifndef O_BINARY
214
+ # ifdef _O_BINARY
215
+ # define O_BINARY _O_BINARY
216
+ # else
217
+ # define O_BINARY 0
218
+ # endif
219
+ #endif
220
+
221
+ #if defined _WIN32 || defined __TURBOC__
222
+ # define strncasecmp(__s1,__s2,__n) strnicmp ((__s1), (__s2), (__n))
223
+ # define strcasecmp(__s1,__s2) stricmp ((__s1), (__s2))
224
+ # define MKDIR(__dir,__attr) mkdir ((__dir))
225
+ #else
226
+ # define MKDIR(__dir,__attr) mkdir ((__dir), (__attr))
227
+ #endif
228
+
229
+ #if defined _WIN32
230
+ # include <direct.h>
231
+ # define snprintf _snprintf
232
+ # define getcwd(__buff,__len) _getcwd ((__buff), (__len))
233
+ # define sleep(__sec) Sleep ((__sec) * 1000)
234
+ #endif
235
+
236
+ #if defined _WIN32
237
+ # define TIME_T long
238
+ # define TIME(__x) time ( &(__x) )
239
+ # define DTIME(__x,__y) ( (double)(__y) - (__x) )
240
+ #else
241
+ # define TIME_T struct timeval
242
+ # define TIME(__x) gettimeofday ( &(__x), NULL )
243
+ # define DTIME(__x,__y) ( ((double)(__y).tv_sec - (__x).tv_sec) + 1.e-6 * ((double)(__y).tv_usec - (__x).tv_usec) )
244
+ #endif
245
+
246
+ #if defined __GNUC__
247
+ # define inline __inline__
248
+ # define restrict
249
+ #elif defined _WIN32
250
+ # define inline __inline
251
+ # define restrict
252
+ #else
253
+ # define inline
254
+ # define restrict
255
+ #endif
256
+
257
+
258
+ //// Binary/Low-Level-IO ///////////////////////////////////////////
259
+ //
260
+ // All file I/O is basicly handled via an ANSI file pointer (type: FILE*) in
261
+ // FILEIO-Mode 1 and via a POSIX file descriptor (type: int) in
262
+ // FILEIO-Mode 2 and 3.
263
+ //
264
+ // Some operation are only available via the POSIX interface (fcntl, setmode,
265
+ // ...) so we need a function to get the file descriptor from a file pointer.
266
+ // In FILEIO-Mode 2 and 3 this is a dummy function because we always working
267
+ // with this file descriptors.
268
+ //
269
+
270
+ #if FILEIO == 1
271
+ # if defined __BORLANDC__ || defined _WIN32
272
+ # define FILENO(__fp) _fileno ((__fp))
273
+ # elif defined __CYGWIN__ || defined __TURBOC__ || defined __unix__ || defined __EMX__ || defined _MSC_VER
274
+ # define FILENO(__fp) fileno ((__fp))
275
+ # else
276
+ # define FILENO(__fp) fileno ((__fp))
277
+ # endif
278
+ #else
279
+ # define FILENO(__fd) (__fd)
280
+ #endif
281
+
282
+
283
+ //
284
+ // If we have access to a file via file name, we can open the file with an
285
+ // additional "b" or a O_BINARY within the (f)open function to get a
286
+ // transparent untranslated data stream which is necessary for audio bitstream
287
+ // data and also for PCM data. If we are working with
288
+ // stdin/stdout/FILENO_STDIN/FILENO_STDOUT we can't open the file with this
289
+ // attributes, because the files are already open. So we need a non
290
+ // standardized sequence to switch to this mode (not necessary for Unix).
291
+ // Mostly the sequency is the same for incoming and outgoing streams, but only
292
+ // mostly so we need one for IN and one for OUT.
293
+ // Macros are called with the file pointer and you get back the untransalted file
294
+ // pointer which can be equal or different from the original.
295
+ //
296
+
297
+ #if defined __EMX__
298
+ # define SETBINARY_IN(__fp) (_fsetmode ( (__fp), "b" ), (__fp))
299
+ # define SETBINARY_OUT(__fp) (_fsetmode ( (__fp), "b" ), (__fp))
300
+ #elif defined __TURBOC__ || defined __BORLANDC__
301
+ # define SETBINARY_IN(__fp) (setmode ( FILENO ((__fp)), O_BINARY ), (__fp))
302
+ # define SETBINARY_OUT(__fp) (setmode ( FILENO ((__fp)), O_BINARY ), (__fp))
303
+ #elif defined __CYGWIN__
304
+ # define SETBINARY_IN(__fp) (setmode ( FILENO ((__fp)), _O_BINARY ), (__fp))
305
+ # define SETBINARY_OUT(__fp) (setmode ( FILENO ((__fp)), _O_BINARY ), (__fp))
306
+ #elif defined _WIN32
307
+ # define SETBINARY_IN(__fp) (_setmode ( FILENO ((__fp)), _O_BINARY ), (__fp))
308
+ # define SETBINARY_OUT(__fp) (_setmode ( FILENO ((__fp)), _O_BINARY ), (__fp))
309
+ #elif defined _MSC_VER
310
+ # define SETBINARY_IN(__fp) (setmode ( FILENO ((__fp)), O_BINARY ), (__fp))
311
+ # define SETBINARY_OUT(__fp) (setmode ( FILENO ((__fp)), O_BINARY ), (__fp))
312
+ #elif defined __unix__
313
+ # define SETBINARY_IN(__fp) (__fp)
314
+ # define SETBINARY_OUT(__fp) (__fp)
315
+ #elif 0
316
+ # define SETBINARY_IN(__fp) (freopen ( NULL, "rb", (__fp) ), (__fp))
317
+ # define SETBINARY_OUT(__fp) (freopen ( NULL, "wb", (__fp) ), (__fp))
318
+ #else
319
+ # define SETBINARY_IN(__fp) (__fp)
320
+ # define SETBINARY_OUT(__fp) (__fp)
321
+ #endif
322
+
323
+ // file I/O using ANSI buffered file I/O via file pointer FILE* (fopen, fread, fwrite, fclose)
324
+ #if FILEIO == 1
325
+ # define OFF_T signed long
326
+ # define FILE_T FILE*
327
+ # define OPEN(name) fopen (name, "rb" )
328
+ # define OPENRW(name) fopen (name, "r+b")
329
+ # define CREATE(name) fopen (name, "wb" )
330
+ # define INVALID_FILEDESC NULL
331
+ # define CLOSE(fp) fclose (fp) // CLOSE returns -1 on error, otherwise 0
332
+ # define READ(fp,ptr,len) fread (ptr, 1, len, fp) // READ returns -1 or 0 on error/EOF, otherwise > 0
333
+ # define READ1(fp,ptr) fread (ptr, 1, 1, fp) // READ returns -1 or 0 on error/EOF, otherwise > 0
334
+ # define WRITE(fp,ptr,len) fwrite (ptr, 1, len, fp) // WRITE returns -1 or 0 on error/EOF, otherwise > 0
335
+ # define SEEK(fp,offs,lbl) fseek (fp, offs, lbl) // SEEK returns -1 on error, otherwise >= 0
336
+ # define FILEPOS(fp) ftell (fp) // FILEPOS returns -1 on error, otherwise >= 0
337
+ # define STDIN stdin
338
+ # define STDOUT stdout
339
+ # define STDERR stderr
340
+ # define FDOPEN(fd,mode) fdopen (fd, mode)
341
+ # define UNBUFFER(fp) setvbuf(fp, NULL, _IONBF, 0 )
342
+ # define FLUSH(fp) fflush (fp)
343
+ #endif /* FILEIO==1 */
344
+
345
+ // file I/O using POSIX unbuffered file I/O via file descriptors (open, read, write, close)
346
+ #if FILEIO == 2
347
+ # ifdef WIN32
348
+ # define OFF_T _off_t
349
+ # else
350
+ # define OFF_T off_t
351
+ # endif
352
+ # define FILE_T int
353
+ # define OPEN(name) open (name, O_RDONLY|O_BINARY)
354
+ # define OPENRW(name) open (name, O_RDWR |O_BINARY)
355
+ # define CREATE(name) open (name, O_WRONLY|O_BINARY|O_TRUNC|O_CREAT, 0644)
356
+ # define INVALID_FILEDESC (-1)
357
+ # define CLOSE(fd) close (fd) // CLOSE returns -1 on error, otherwise 0
358
+ # if defined HAVE_INCOMPLETE_READ
359
+ # define READ(fd,ptr,len) complete_read (fd, ptr, len) // READ returns -1 or 0 on error/EOF, otherwise > 0
360
+ # else
361
+ # define READ(fd,ptr,len) (size_t)read (fd, ptr, len)// READ returns -1 or 0 on error/EOF, otherwise > 0
362
+ # endif
363
+ # define READ1(fd,ptr) (size_t)read (fd, ptr, 1) // READ returns -1 or 0 on error/EOF, otherwise > 0
364
+ # define WRITE(fd,ptr,len) (size_t)write (fd, ptr, len)// WRITE returns -1 or 0 on error/EOF, otherwise > 0
365
+ # define SEEK(fd,offs,lbl) lseek (fd, offs, lbl) // SEEK returns -1 on error, otherwise >= 0
366
+ # define FILEPOS(fd) lseek (fd, 0L, SEEK_CUR) // FILEPOS returns -1 on error, otherwise >= 0
367
+ # define STDIN 0
368
+ # define STDOUT 1
369
+ # define STDERR 2
370
+ # define FDOPEN(fd,mode) (fd)
371
+ # define UNBUFFER(fd) (void)(fd)
372
+ # define FLUSH(fd) (void)(fd)
373
+ #endif /* FILEIO==2 */
374
+
375
+ // file I/O using Turbo-C lowest level unbuffered file I/O via file descriptors (_open, _read, _write, _close)
376
+ #if FILEIO == 3
377
+ # define OFF_T signed long
378
+ # define FILE_T int
379
+ # define OPEN(name) _open (name, O_RDONLY)
380
+ # define OPENRW(name) _open (name, O_RDWR )
381
+ # define CREATE(name) _creat(name, 0)
382
+ # define INVALID_FILEDESC (-1)
383
+ # define CLOSE(fd) _close (fd) // CLOSE returns -1 on error, otherwise 0
384
+ # define READ(fd,ptr,len) (size_t)_read (fd, ptr, len)// READ returns -1 or 0 on error/EOF, otherwise > 0
385
+ # define READ1(fd,ptr) (size_t)_read (fd, ptr, 1) // READ returns -1 or 0 on error/EOF, otherwise > 0
386
+ # define WRITE(fd,ptr,len) (size_t)_write (fd, ptr, len)// WRITE returns -1 or 0 on error/EOF, otherwise > 0
387
+ # define SEEK(fd,offs,lbl) lseek (fd, offs, lbl) // SEEK returns -1 on error, otherwise >= 0
388
+ # define FILEPOS(fd) lseek (fd, 0L, SEEK_CUR) // FILEPOS returns -1 on error, otherwise >= 0
389
+ # define STDIN 0
390
+ # define STDOUT 1
391
+ # define STDERR 2
392
+ # undef SETBINARY_IN
393
+ # undef SETBINARY_OUT
394
+ # define SETBINARY_IN(fd) (fd)
395
+ # define SETBINARY_OUT(fd) (fd)
396
+ # define FDOPEN(fd,mode) (fd)
397
+ # define UNBUFFER(fd) (void)(fd)
398
+ # define FLUSH(fd) (void)(fd)
399
+ #endif /* FILEIO==3 */
400
+
401
+ #if FILEIO != 2 && defined USE_HTTP
402
+ # error HTTP can only be used by FILEIO==2
403
+ #endif
404
+
405
+ #if defined _WIN32 || defined __BEOS__
406
+ # define WRITE_SOCKET(sock,ptr,len) send (sock, ptr, len, 0)
407
+ # define READ_SOCKET(sock,ptr,len) recv (sock, ptr, len, 0)
408
+ #else
409
+ # define WRITE_SOCKET(sock,ptr,len) write (sock, ptr, len)
410
+ # define READ_SOCKET(sock,ptr,len) read (sock, ptr, len)
411
+ #endif
412
+
413
+ #ifdef _WIN32
414
+ # define POPEN_READ_BINARY_OPEN(cmd) _popen ((cmd), "rb")
415
+ # define POPEN_WRITE_BINARY_OPEN(cmd) _popen ((cmd), "wb")
416
+ # define PCLOSE(fp) _pclose(fp)
417
+ #else
418
+ # define POPEN_READ_BINARY_OPEN(cmd) popen ((cmd), "r")
419
+ # define POPEN_WRITE_BINARY_OPEN(cmd) popen ((cmd), "w")
420
+ # define PCLOSE(fp) pclose(fp)
421
+ #endif
422
+
423
+ #if defined _WIN32
424
+ # define STRUCT_STAT struct _stat
425
+ # define STAT_CMD(f,s) _stat (f, s)
426
+ #else
427
+ # define STRUCT_STAT struct stat
428
+ # define STAT_CMD(f,s) stat (f, s)
429
+ #endif /* WIN32 */
430
+
431
+ #ifndef S_ISDIR
432
+ # if defined S_IFDIR
433
+ # define S_ISDIR(x) ((x) & S_IFDIR)
434
+ # elif defined _S_IFDIR
435
+ # define S_ISDIR(x) ((x) & _S_IFDIR)
436
+ # elif defined __S_IFDIR
437
+ # define S_ISDIR(x) ((x) & __S_IFDIR)
438
+ # else
439
+ # error Cannot find a way to test for a directory
440
+ # endif
441
+ #endif /* !S_ISDIR */
442
+
443
+ #if defined __unix__ || defined __bsdi__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ || defined __TURBOC__ || defined _WIN32 || defined __APPLE__
444
+ # define ISATTY(fd) isatty (fd)
445
+ #else
446
+ # define ISATTY(fd) 0
447
+ #endif
448
+
449
+ // Path separator
450
+ #if defined __unix__ || defined __bsdi__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ || defined __APPLE__
451
+ //# define PATH_SEP '/'
452
+ # define DRIVE_SEP '\0'
453
+ # define EXE_EXT ""
454
+ # define DEV_NULL "/dev/null"
455
+ # define ENVPATH_SEP ':'
456
+ #elif defined _WIN32 || defined __TURBOC__ || defined __ZTC__ || defined _MSC_VER
457
+ //# define PATH_SEP '\\'
458
+ # define DRIVE_SEP ':'
459
+ # define EXE_EXT ".exe"
460
+ # define DEV_NULL "\\nul"
461
+ # define ENVPATH_SEP ';'
462
+ #else
463
+ //# define PATH_SEP '/' // Amiga: C:/
464
+ # define DRIVE_SEP ':'
465
+ # define EXE_EXT ""
466
+ # define DEV_NULL "nul"
467
+ # define ENVPATH_SEP ';'
468
+ #endif
469
+
470
+ // maximum length of file names
471
+ #ifndef PATHLEN_MAX
472
+ # if defined FILENAME_MAX
473
+ # define PATHLEN_MAX FILENAME_MAX
474
+ # elif INT_MAX < 2147483647L
475
+ # define PATHLEN_MAX 128
476
+ # else
477
+ # define PATHLEN_MAX 1024
478
+ # endif
479
+ #endif /* !PATHLEN_MAX */
480
+
481
+ #ifdef _WIN32
482
+ # define TitleBar(text) SetConsoleTitle (text)
483
+ #else
484
+ # define TitleBar(text) (void) (text)
485
+ #endif
486
+
487
+
488
+ //// constants /////////////////////////////////////////////////////
489
+ #ifdef USE_SV8
490
+ # define MAX_SV "SV8"
491
+ #else
492
+ # define MAX_SV "SV7"
493
+ #endif
494
+
495
+ #ifdef USE_ASM
496
+ # define BUILD "3DNow/SSE"
497
+ #else
498
+ # define BUILD ""
499
+ #endif
500
+
501
+
502
+ #define COPYRIGHT "(C) 1999-2003 Buschmann/Klemm/Piecha/Wolf"
503
+
504
+ #define DECODER_DELAY (512 - 32 + 1)
505
+ #define BLK_SIZE (36 * 32)
506
+
507
+
508
+ //// logging defines, for development only /////////////////////////
509
+ #if defined _WIN32 || defined __TURBOC__
510
+ # define LOGPATH ".\\"
511
+ # define MUSICPATH "D:\\AUDIO\\"
512
+ #else
513
+ # define LOGPATH "./"
514
+ # define MUSICPATH "/Archive/Audio/"
515
+ #endif
516
+ //#define _(x) (void)(fprintf(stderr,"<%d>\n",(x)),fflush(stderr))
517
+
518
+ #ifdef DEBUG
519
+ # define REP(x) (void)(x)
520
+ #else
521
+ # define REP(x)
522
+ #endif
523
+
524
+
525
+ //// numerical constants ///////////////////////////////////////////
526
+ #define C00 (Float) 0.500000000000000000000000L // Cxx = 0.5 / cos (xx*M_PI/64)
527
+ #define C01 (Float) 0.500602998235196301334178L
528
+ #define C02 (Float) 0.502419286188155705518560L
529
+ #define C03 (Float) 0.505470959897543659956626L
530
+ #define C04 (Float) 0.509795579104159168925062L
531
+ #define C05 (Float) 0.515447309922624546962323L
532
+ #define C06 (Float) 0.522498614939688880640101L
533
+ #define C07 (Float) 0.531042591089784174473998L
534
+ #define C08 (Float) 0.541196100146196984405269L
535
+ #define C09 (Float) 0.553103896034444527838540L
536
+ #define C10 (Float) 0.566944034816357703685831L
537
+ #define C11 (Float) 0.582934968206133873665654L
538
+ #define C12 (Float) 0.601344886935045280535340L
539
+ #define C13 (Float) 0.622504123035664816182728L
540
+ #define C14 (Float) 0.646821783359990129535794L
541
+ #define C15 (Float) 0.674808341455005746033820L
542
+ #define C16 (Float) 0.707106781186547524436104L
543
+ #define C17 (Float) 0.744536271002298449773679L
544
+ #define C18 (Float) 0.788154623451250224773056L
545
+ #define C19 (Float) 0.839349645415527038721463L
546
+ #define C20 (Float) 0.899976223136415704611808L
547
+ #define C21 (Float) 0.972568237861960693780520L
548
+ #define C22 (Float) 1.060677685990347471323668L
549
+ #define C23 (Float) 1.169439933432884955134476L
550
+ #define C24 (Float) 1.306562964876376527851784L
551
+ #define C25 (Float) 1.484164616314166277319733L
552
+ #define C26 (Float) 1.722447098238333927796261L
553
+ #define C27 (Float) 2.057781009953411550808880L
554
+ #define C28 (Float) 2.562915447741506178719328L
555
+ #define C29 (Float) 3.407608418468718785698107L
556
+ #define C30 (Float) 5.101148618689163857960189L
557
+ #define C31 (Float)10.190008123548056810994678L
558
+
559
+ #define SS05 (Float) 0.840896415253714543018917L // 0.5^0.25
560
+
561
+
562
+ #ifndef M_PI
563
+ # define M_PI 3.1415926535897932384626433832795029 // 4*atan(1)
564
+ # define M_PIl 3.1415926535897932384626433832795029L
565
+ # define M_LN2 0.6931471805599453094172321214581766 // ln(2)
566
+ # define M_LN2l 0.6931471805599453094172321214581766L
567
+ # define M_LN10 2.3025850929940456840179914546843642 // ln 10 */
568
+ # define M_LN10l 2.3025850929940456840179914546843642L
569
+ #endif
570
+
571
+
572
+ //// 'Cdecl' forces to use standard C/C++ calling convention ///////
573
+ #if defined _WIN32
574
+ # define Cdecl __cdecl
575
+ #elif defined __ZTC__
576
+ # define Cdecl _cdecl
577
+ #elif defined __TURBOC__
578
+ # define Cdecl cdecl
579
+ #else
580
+ # define Cdecl
581
+ #endif
582
+
583
+ //// expect handling of GCC ////////////////////////////////////////
584
+ #ifdef __GNUC__
585
+ # if __GNUC__ < 3
586
+ # define __builtin_expect(cond,exp) (cond)
587
+ # ifndef expect
588
+ # define expect(cond,exp) __builtin_expect(cond,exp)
589
+ # endif
590
+ # else
591
+ # ifndef expect
592
+ # define expect(cond,exp) __builtin_expect(cond,exp)
593
+ # endif
594
+ # endif
595
+ #else
596
+ # define __builtin_expect(cond,exp) (cond)
597
+ # ifndef expect
598
+ # define expect(cond,exp) __builtin_expect(cond,exp)
599
+ # endif
600
+ #endif
601
+
602
+ #define if0(x) if (expect(x,0))
603
+ #define if1(x) if (expect(x,1))
604
+ #define while0(x) while (expect(x,0))
605
+ #define while1(x) while (expect(x,1))
606
+
607
+ #ifndef __GNUC__
608
+ # define __attribute__(x)
609
+ #else
610
+ # define __attribute__(x)
611
+ #endif
612
+
613
+ //// Remaining macros //////////////////////////////////////////////
614
+ // selects input buffer size and some constants needed for input buffer handling
615
+ #ifndef IBUFLOG2 // must be at least 10 (bitrate always <626 kbps) or better 11 ( <1253 kbps)
616
+ # if INT_MAX < 2147483647L
617
+ # define IBUFLOG2 11 // 8 KByte buffer, possible 11...13 (32 KByte limit)
618
+ # else
619
+ # define IBUFLOG2 21 // 8 MByte buffer, possible 11...29 ( 2 GByte limit)
620
+ # endif
621
+ #endif
622
+ #define IBUFSIZE ((size_t)(1LU<<(IBUFLOG2)))
623
+ #define IBUFSIZE2 ((size_t)((IBUFSIZE)/2))
624
+ #define IBUFMASK ((size_t)((IBUFSIZE)-1))
625
+
626
+ // save memory space for 16 bit compiler (data + stack < 64 KByte)
627
+ #if INT_MAX < 2147483647L
628
+ # if VIRT_SHIFT > 6
629
+ # undef VIRT_SHIFT
630
+ # define VIRT_SHIFT 6
631
+ # endif
632
+ # if IBUFLOG2 > 11
633
+ # undef IBUFLOG2
634
+ # define IBUFLOG2 11
635
+ # endif
636
+ # define USE_HUFF_PACK
637
+ # define USE_ARRAY_PACK
638
+ #endif
639
+
640
+ // generate a macro which contains information about compile time settings
641
+ #define STR(x) _STR(x)
642
+ #define _STR(x) #x
643
+ #ifdef NDEBUG
644
+ # define T1 ""
645
+ #else
646
+ # define T1 "DEBUG "
647
+ #endif
648
+ #if defined USE_OSS_AUDIO || defined USE_ESD_AUDIO || defined USE_SUN_AUDIO || defined USE_WIN_AUDIO
649
+ # define T2 "SND "
650
+ #else
651
+ # define T2 ""
652
+ #endif
653
+ #ifdef USE_NICE
654
+ # define T3 "NICE "
655
+ #else
656
+ # define T3 ""
657
+ #endif
658
+ #if defined USE_REALTIME
659
+ # define T4 "RT "
660
+ #else
661
+ # define T4 ""
662
+ #endif
663
+ #ifdef HAVE_IEEE754_FLOAT
664
+ # define T5 "IEEE "
665
+ #else
666
+ # define T5 ""
667
+ #endif
668
+ #define T6 "IO=" STR(FILEIO) " "
669
+ #ifdef USE_HUFF_PACK
670
+ # define T7 "H-PCK "
671
+ #else
672
+ # define T7 ""
673
+ #endif
674
+ #ifdef USE_ARRAY_PACK
675
+ # define T8 "A-PCK "
676
+ #else
677
+ # define T8 ""
678
+ #endif
679
+ #define T9 "SHFT=" STR(VIRT_SHIFT) " "
680
+ #define T10 "IBUF=" STR(IBUFLOG2) " "
681
+
682
+ #define COMPILER_FLAGS T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
683
+
684
+ // align a pointer by maybe incrementing it
685
+ #define ALIGN(ptr,alignment) \
686
+ (void*)((((ptrdiff_t)(ptr)) & (-(ptrdiff_t)(alignment))) + (alignment)) // aligns a pointer with alignment, the source array should be at least alignment-1 Bytes longer than the needed length
687
+
688
+
689
+ //// Simple types //////////////////////////////////////////////////
690
+
691
+ #if CHAR_BIT == 8 && SCHAR_MAX == 127L
692
+ typedef unsigned char Uint8_t; // guaranteed 8 bit unsigned integer type with range 0...255
693
+ typedef signed char Int8_t; // guaranteed 8 bit signed integer type with range -128...127
694
+ #else
695
+ # error No 8 bit int type found. Tested: char
696
+ #endif
697
+
698
+ #if SHRT_MAX == 32767L
699
+ typedef unsigned short int Uint16_t; // guaranteed 16 bit unsigned integer type with range 0...65535
700
+ typedef signed short int Int16_t; // guaranteed 16 bit signed integer type with range -32768...32767
701
+ #else
702
+ # error No 16 bit int type found. Tested: short
703
+ #endif
704
+
705
+ #if INT_MAX == 2147483647L
706
+ typedef unsigned int Uint32_t; // guaranteed 32 bit unsigned integer type with range 0...4294967295
707
+ typedef signed int Int32_t; // guaranteed 32 bit signed integer type with range -2147483648...2147483647
708
+ #elif LONG_MAX == 2147483647L
709
+ typedef unsigned long int Uint32_t; // guaranteed 32 bit unsigned integer type with range 0...4294967295
710
+ typedef signed long int Int32_t; // guaranteed 32 bit signed integer type with range -2147483648...2147483647
711
+ #else
712
+ # error No 32 bit int type found. Tested: int, long
713
+ #endif
714
+
715
+ #if defined __C99__ // C9x has a type which is exact 64 bit
716
+ typedef int64_t Int64_t;
717
+ typedef uint64_t Uint64_t;
718
+ typedef intmax_t IntMax_t;
719
+ typedef uintmax_t UintMax_t;
720
+ # define IntMax_MIN -9223372036854775808
721
+ # define IntMax_MAX 9223372036854775807
722
+ # define UintMax_MAX 18446744073709551615
723
+ # define UintMAX_FP(x) (long double)(x)
724
+ #elif defined __GNUC__ // GCC uses long long as 64 bit
725
+ typedef signed long long Int64_t;
726
+ typedef unsigned long long Uint64_t;
727
+ typedef signed long long IntMax_t;
728
+ typedef unsigned long long UintMax_t;
729
+ # define IntMax_MIN -9223372036854775808LL
730
+ # define IntMax_MAX 9223372036854775807LL
731
+ # define UintMax_MAX 18446744073709551615LLU
732
+ # define UintMAX_FP(x) (long double)(x)
733
+ #elif defined _MSC_VER
734
+ typedef signed __int64 Int64_t;
735
+ typedef unsigned __int64 Uint64_t;
736
+ typedef signed __int64 IntMax_t;
737
+ typedef unsigned __int64 UintMax_t;
738
+ # define IntMax_MIN -9223372036854775808I64
739
+ # define IntMax_MAX 9223372036854775807I64
740
+ # define UintMax_MAX 18446744073709551615UI64
741
+ # define UintMAX_FP(x) (long double)(IntMax_t)(x)
742
+ #elif defined LLONG_MAX // long long (when existing) is normally 64 bit
743
+ typedef signed long long Int64_t;
744
+ typedef unsigned long long Uint64_t;
745
+ typedef signed long long IntMax_t;
746
+ typedef unsigned long long UintMax_t;
747
+ # define IntMax_MIN -9223372036854775808LL
748
+ # define IntMax_MAX 9223372036854775807LL
749
+ # define UintMax_MAX 18446744073709551615LLU
750
+ # define UintMAX_FP(x) (long double)(x)
751
+ #elif LONG_MAX > 0xFFFFFFFFLU // long is longer than 33 bit, assume 64 bit
752
+ typedef signed long Int64_t;
753
+ typedef unsigned long Uint64_t;
754
+ typedef signed long IntMax_t;
755
+ typedef unsigned long UintMax_t;
756
+ # define IntMax_MIN -9223372036854775808L
757
+ # define IntMax_MAX 9223372036854775807L
758
+ # define UintMax_MAX 18446744073709551615LU
759
+ # define UintMAX_FP(x) (long double)(x)
760
+ #elif defined _WIN32 // Microsoft and Intel call it __int64
761
+ typedef signed __int64 Int64_t;
762
+ typedef unsigned __int64 Uint64_t;
763
+ typedef signed __int64 IntMax_t;
764
+ typedef unsigned __int64 UintMax_t;
765
+ # define IntMax_MIN -9223372036854775808I64
766
+ # define IntMax_MAX 9223372036854775807I64
767
+ # define UintMax_MAX 18446744073709551615UI64
768
+ # define UintMAX_FP(x) (long double)(IntMax_t)(x)
769
+ #else
770
+ # define NO_INT64_T // no type mapped to 64 bit integer
771
+ typedef signed long IntMax_t;
772
+ typedef unsigned long UintMax_t;
773
+ # define IntMax_MIN -2147483648L
774
+ # define IntMax_MAX 2147483647L
775
+ # define UintMax_MAX 4294967295LU
776
+ # define UintMAX_FP(x) (long double)(x)
777
+ #endif
778
+
779
+
780
+ #if defined _WIN32 && !defined __GNUC__ && !defined __C99__
781
+ typedef signed long ssize_t;
782
+ #endif
783
+
784
+ #ifdef USE_ARRAY_PACK
785
+ typedef signed char Bool_t; // ==0: false, !=0: true
786
+ #else
787
+ typedef signed int Bool_t; // ==0: false, !=0: true
788
+ #endif
789
+ typedef Uint32_t Ibuf_t; // type for input buffer, currently this type must be 32 bit
790
+ typedef signed char Schar; // at least -127...+127
791
+ typedef unsigned char Uchar; // at least 0...255
792
+ typedef signed short int Short; // at least -32767...+32767, memory economic type
793
+ typedef unsigned short int Ushort; // at least 0...65535, memory economic type
794
+ typedef signed int Int; // at least -32767...+32767, fast type
795
+ typedef unsigned int Uint; // at least 0...65535, fast type
796
+ typedef signed long int Long; // at least -2147483647...+2147483647, but more is better
797
+ typedef unsigned long int Ulong; // at least 0...4294967295, but more is better
798
+ // size_t; // size of memory objects
799
+ // ptrdiff_t; // pointer differences, may be larger than size_t
800
+ typedef float Float32_t; // guaranteed 32 bit floating point type
801
+ typedef double Float64_t; // guaranteed 64 bit floating point type
802
+ typedef float Float; // fastest floating point type, memory economic (used for all PCM calculations)
803
+ #define SIZEOF_Float 4 // size of the type 'Float' in sizeof units
804
+ typedef double Double; // floating point with extended precision (more than 32 bit mantissa)
805
+ typedef long double Ldouble; // most exact floating point format
806
+ typedef Int16_t Int2x16_t [2];
807
+ typedef Int32_t Int2x32_t [2];
808
+
809
+ #if defined MAKE_16BIT || defined MAKE_24BIT || defined MAKE_32BIT
810
+ # ifdef NO_INT64_T
811
+ # error No 64 bit int type found, needed for HQ 16...32 bit output
812
+ # endif
813
+ typedef Int2x32_t Int2xSample_t;
814
+ # if defined MAKE_32BIT
815
+ # define SAMPLE_SIZE 32
816
+ # define PROG_NAME "mppdec32"
817
+ # define SAMPLE_SIZE_STRING " (32 bit HQ)"
818
+ # define Write_PCM(fd,p,b) Write_PCM_HQ_2x32bit ( fd, p, b )
819
+ # define Synthese_Filter(Stream,offset,Vi,Yi,ch) \
820
+ Synthese_Filter_32_C ( Stream, offset, Vi, Yi, ch )
821
+ # undef USE_ESD_AUDIO
822
+ # elif defined MAKE_24BIT
823
+ # define SAMPLE_SIZE 24
824
+ # define PROG_NAME "mppdec24"
825
+ # define SAMPLE_SIZE_STRING " (24 bit HQ)"
826
+ # define Write_PCM(fd,p,b) Write_PCM_HQ_2x24bit ( fd, p, b )
827
+ # define Synthese_Filter(Stream,offset,Vi,Yi,ch) \
828
+ Synthese_Filter_32_C ( Stream, offset, Vi, Yi, ch )
829
+ # undef USE_ESD_AUDIO
830
+ # elif defined MAKE_16BIT
831
+ # define SAMPLE_SIZE 16
832
+ # define PROG_NAME "mppdec16"
833
+ # define SAMPLE_SIZE_STRING " (16 bit HQ)"
834
+ # define Write_PCM(fd,p,b) Write_PCM_HQ_2x16bit ( fd, p, b )
835
+ # define Synthese_Filter(Stream,offset,Vi,Yi,ch) \
836
+ Synthese_Filter_32_C ( Stream, offset, Vi, Yi, ch )
837
+ # endif
838
+ #else
839
+ typedef Int2x16_t Int2xSample_t;
840
+ # define SAMPLE_SIZE 16
841
+ # define PROG_NAME "mppdec"
842
+ # define SAMPLE_SIZE_STRING ""
843
+ # define Write_PCM(fd,p,b) Write_PCM_2x16bit ( fd, p, b )
844
+ # ifdef USE_ASM
845
+ # define Synthese_Filter(Stream,offset,Vi,Yi,ch) \
846
+ Synthese_Filter_16 ( Stream, offset, Vi, Yi )
847
+ # else
848
+ # define Synthese_Filter(Stream,offset,Vi,Yi,ch) \
849
+ Synthese_Filter_16_C ( Stream, offset, Vi, Yi )
850
+ # endif /* USE_ASM */
851
+ #endif
852
+
853
+
854
+ //// More complex types ////////////////////////////////////////////
855
+ typedef struct {
856
+ Int L [36];
857
+ Int R [36];
858
+ } Quant_t ;
859
+
860
+ typedef struct {
861
+ Uint L;
862
+ Uint R;
863
+ } UPair_t ;
864
+
865
+ typedef struct {
866
+ Int L;
867
+ Int R;
868
+ } Pair_t ;
869
+
870
+ typedef struct {
871
+ #ifdef USE_ARRAY_PACK
872
+ Schar L;
873
+ Schar R;
874
+ #else
875
+ Int L;
876
+ Int R;
877
+ #endif
878
+ } CPair_t ;
879
+
880
+ typedef Float FloatArray [32];
881
+ typedef UPair_t UPairArray [32];
882
+ typedef Pair_t PairArray [32];
883
+ typedef CPair_t CPairArray [32];
884
+ typedef Float SCFTriple [3];
885
+ typedef struct {
886
+ #ifndef MPP_ENCODER
887
+ Uint32_t Code; // >=32 bit
888
+ # ifdef USE_HUFF_PACK
889
+ Schar Value; // >= 7 bit
890
+ Uchar Length; // >= 4 bit
891
+ # else
892
+ Int Value;
893
+ Uint Length;
894
+ # endif
895
+ #else
896
+ # ifdef USE_HUFF_PACK
897
+ Uint8_t Length; // >= 4 bit
898
+ Uint8_t ___;
899
+ Uint16_t Code; // >= 14 bit
900
+ # else
901
+ Uint Code;
902
+ Uint Length;
903
+ # endif
904
+ #endif
905
+ } Huffman_t ;
906
+
907
+ typedef struct {
908
+ Uint Code : 16; // >= 14 bit
909
+ Uint Length : 8; // >= 4 bit
910
+ } HuffSrc_t ;
911
+
912
+ typedef struct {
913
+ OFF_T FileSize;
914
+ Int GenreNo;
915
+ Int TrackNo;
916
+ char Genre [128];
917
+ char Year [ 20];
918
+ char Track [ 8];
919
+ char Title [256];
920
+ char Artist [256];
921
+ char Album [256];
922
+ char Comment [512];
923
+ } TagInfo_t ;
924
+
925
+ typedef void (*SyntheseFilter16_t) ( Int2x16_t* Stream, Int* const offset, Float* Vi, const FloatArray* Yi );
926
+ typedef void (*SyntheseFilter32_t) ( Int2x32_t* Stream, Int* const offset, Float* Vi, const FloatArray* Yi, int ch );
927
+ typedef Int (*HeaderWriter_t) ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels, Ulong SamplesPerChannel );
928
+
929
+ #if defined MAKE_16BIT || defined MAKE_24BIT || defined MAKE_32BIT
930
+ typedef struct {
931
+ const Float* FilterCoeff;
932
+ Uint64_t Mask;
933
+ Float64_t Add;
934
+ Float Dither;
935
+ Uint32_t Overdrives;
936
+ Int64_t MaxLevel;
937
+ Bool_t NoShaping;
938
+ Float ErrorHistory [2] [16]; // max. 2 channels, 16th order Noise shaping
939
+ Float DitherHistory [2] [16];
940
+ Int32_t LastRandomNumber [2];
941
+ } dither_t;
942
+ #else
943
+ typedef struct {
944
+ Uint32_t Overdrives;
945
+ Int32_t MaxLevel;
946
+ } dither_t;
947
+ #endif
948
+
949
+
950
+ //// Variables /////////////////////////////////////////////////////
951
+
952
+ // decode.c
953
+ extern Ibuf_t InputBuff [IBUFSIZE]; // read buffer for the MP+ data stream
954
+ extern size_t InputCnt; // current offset in this buffer
955
+
956
+ // huffsv7.c
957
+ extern Huffman_t HuffHdr [10];
958
+ extern Huffman_t HuffSCFI [ 4];
959
+ extern Huffman_t HuffDSCF [16];
960
+ extern Huffman_t HuffQ1 [2] [ 3*3*3];
961
+ extern Huffman_t HuffQ2 [2] [ 5*5];
962
+ extern Huffman_t HuffQ3 [2] [ 7];
963
+ extern Huffman_t HuffN3 [2] [ 7*7];
964
+ extern Huffman_t HuffQ4 [2] [ 9];
965
+ extern Huffman_t HuffQ5 [2] [15];
966
+ extern Huffman_t HuffQ6 [2] [31];
967
+ extern Huffman_t HuffQ7 [2] [63];
968
+ extern Huffman_t HuffN8 [2][127];
969
+ extern const Huffman_t* HuffQ [2] [ 8];
970
+ extern const Huffman_t* HuffN [2] [ 9];
971
+ extern Uint8_t LUT1_0 [1<< 6];
972
+ extern Uint8_t LUT1_1 [1<< 9];
973
+ extern Uint8_t LUT2_0 [1<< 7];
974
+ extern Uint8_t LUT2_1 [1<<10];
975
+ extern Uint8_t LUT3_0 [1<< 4];
976
+ extern Uint8_t LUT3_1 [1<< 5];
977
+ extern Uint8_t LUT4_0 [1<< 4];
978
+ extern Uint8_t LUT4_1 [1<< 5];
979
+ extern Uint8_t LUT5_0 [1<< 6];
980
+ extern Uint8_t LUT5_1 [1<< 8];
981
+ extern Uint8_t LUT6_0 [1<< 7];
982
+ extern Uint8_t LUT6_1 [1<< 7];
983
+ extern Uint8_t LUT7_0 [1<< 8];
984
+ extern Uint8_t LUT7_1 [1<< 8];
985
+ extern Uint8_t LUTDSCF [1<< 6];
986
+
987
+ // huffsv46.c
988
+ extern const Huffman_t* Entropie [18];
989
+ extern const Huffman_t* Region [32];
990
+ extern Huffman_t SCFI_Bundle [ 8];
991
+ extern Huffman_t DSCF_Entropie [13];
992
+
993
+ // mppdec.c
994
+ extern Float Y_L [36] [32];
995
+ extern Float Y_R [36] [32];
996
+ extern CPair_t SCF_Index [3] [32]; // Scalefactor
997
+ extern CPair_t Res [32]; // resolution steps of the subbands
998
+ extern Quant_t Q [32]; // quantized samples
999
+ extern CPair_t SCFI [32]; // transfer order of the SCF
1000
+ extern Bool_t MS_Band [32]; // subband-wise flag for M/S-signal guidance
1001
+ extern Bool_t MS_used; // global flag for M/S-signal guidance
1002
+ extern Bool_t IS_used;
1003
+
1004
+ #define LITTLE 0
1005
+ #define BIG 1
1006
+ extern Bool_t output_endianess;
1007
+ #if ENDIAN == HAVE_LITTLE_ENDIAN
1008
+ # define machine_endianess LITTLE
1009
+ #elif ENDIAN == HAVE_BIG_ENDIAN
1010
+ # define machine_endianess BIG
1011
+ #endif
1012
+
1013
+ // requant.c
1014
+ extern Float __SCF [6 + 128]; // tabulated Scalefactors from -6 to +127
1015
+ #define SCF ( __SCF + 6 )
1016
+ extern Int8_t Q_bit [32]; // number of bits to save the resolution (SV6)
1017
+ extern Int8_t Q_res [32] [16]; // Index -> resolution (SV6)
1018
+ extern Uint Bitrate;
1019
+ extern Int Min_Band;
1020
+ extern Int Max_Band;
1021
+ extern Float __Cc [1 + 18];
1022
+ extern const Uint __Dc [1 + 18];
1023
+ #define Cc ( __Cc + 1 )
1024
+ #define Dc ( __Dc + 1 )
1025
+
1026
+ // synthtab.c
1027
+ extern const Float Cos64 [32];
1028
+ extern const Float Di_opt [32] [16];
1029
+
1030
+ // stderr.c
1031
+
1032
+
1033
+ //// procedures/functions //////////////////////////////////////////
1034
+ // cpu_feat.c
1035
+ Bool_t Cdecl Has_MMX ( void );
1036
+ Bool_t Cdecl Has_SIMD ( void );
1037
+ Bool_t Cdecl Has_SIMD2 ( void );
1038
+ Bool_t Cdecl Has_3DNow ( void );
1039
+
1040
+ // decode.c
1041
+ void Bitstream_init ( void );
1042
+ Ulong BitsRead ( void );
1043
+ Uint32_t Bitstream_read ( Int bits );
1044
+ Uint32_t Bitstream_peek ( Uint pos, Int bits );
1045
+ void Bitstream_skip ( Uint bits );
1046
+ Uint32_t Bitstream_preview ( Int bits ); // same as above, but data doesn't get receipted yet
1047
+ void Read_Bitstream_SV6 ( void );
1048
+ void Read_Bitstream_SV7 ( void );
1049
+ void Read_Bitstream_SV8 ( void );
1050
+
1051
+ // http.c
1052
+ int http_open ( const char* URL );
1053
+
1054
+ // huffsv7.c
1055
+ void Init_Huffman_Decoder_SV7 ( void );
1056
+ void Init_Huffman_Encoder_SV7 ( void );
1057
+
1058
+ // huffsv46.c
1059
+ void Init_Huffman_Decoder_SV4_6 ( void );
1060
+
1061
+ // id3tag.c
1062
+ Int Read_ID3V1_Tags ( FILE_T fp, TagInfo_t* tip );
1063
+ Int Read_APE_Tags ( FILE_T fp, TagInfo_t* tip );
1064
+
1065
+ // requant.c
1066
+ void Init_QuantTab ( Int maximum_Band, Bool_t used_IS, Double amplification, Uint StreamVersion );
1067
+
1068
+ // synth.c
1069
+ Uint32_t random_int ( void );
1070
+
1071
+ void Cdecl Calculate_New_V_i387 ( const Float* Sample, Float* V );
1072
+ void Cdecl Calculate_New_V_3DNow ( const Float* Sample, Float* V );
1073
+ void Cdecl New_V_Helper2 ( Float* A, const Float* Sample );
1074
+ void Cdecl New_V_Helper3 ( Float* A, const Float* Sample );
1075
+ void Cdecl New_V_Helper4 ( Float* V );
1076
+
1077
+ void Cdecl VectorMult_i387 ( void* buff, const Float* V );
1078
+ void Cdecl VectorMult_3DNow ( void* buff, const Float* V );
1079
+ void Cdecl VectorMult_SIMD ( void* buff, const Float* V );
1080
+
1081
+ void Synthese_Filter_16_C ( Int2x16_t* Stream, Int* const offset, Float* Vi, const FloatArray* Yi );
1082
+ void Synthese_Filter_32_C ( Int2x32_t* Stream, Int* const offset, Float* Vi, const FloatArray* Yi, Uint channel );
1083
+
1084
+ void Cdecl Reset_FPU ( void );
1085
+ void Cdecl Reset_FPU_3DNow ( void );
1086
+ void Cdecl memcpy_dn_MMX ( void* dst, const void* src, size_t words64byte );
1087
+ void Cdecl memcpy_dn_SIMD ( void* dst, const void* src, size_t words128byte );
1088
+
1089
+ void Init_Dither ( Int bits, int shapingtype, Double dither );
1090
+ void OverdriveReport ( void );
1091
+ SyntheseFilter16_t
1092
+ Get_Synthese_Filter ( void );
1093
+
1094
+ // tools.c
1095
+ size_t Read_LittleEndians ( FILE_T fp, Uint32_t* dst, size_t words32bit );
1096
+ void Requantize_MidSideStereo ( Int Stop_Band, const Bool_t* used_MS );
1097
+ void Requantize_IntensityStereo ( Int Start_Band, Int Stop_Band );
1098
+ void Resort_HuffTable ( Huffman_t* const Table, const size_t elements, Int offset );
1099
+ void Make_HuffTable ( Huffman_t* dst, const HuffSrc_t* src, size_t len );
1100
+ void Make_LookupTable ( Uint8_t* LUT, size_t LUT_len, const Huffman_t* const Table, const size_t elements );
1101
+ size_t complete_read ( int fd, void* dest, size_t bytes );
1102
+ int isdir ( const char* Name );
1103
+ void Init_FPU ( void );
1104
+
1105
+ // wave_out.c
1106
+ Int Write_WAVE_Header ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels, Ulong SamplesPerChannel );
1107
+ Int Write_AIFF_Header ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels, Ulong SamplesPerChannel );
1108
+ Int Write_Raw_Header ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels, Ulong SamplesPerChannel );
1109
+ Int Set_DSP_OSS_Params ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
1110
+ Int Set_DSP_Sun_Params ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
1111
+ Int Set_ESD_Params ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
1112
+ Int Set_WIN_Params ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
1113
+ Int Set_IRIX_Params ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
1114
+ size_t Write_PCM_2x16bit ( FILE_T outputFile, Int2x16_t* data, size_t len );
1115
+ size_t Write_PCM_HQ_2x16bit ( FILE_T outputFile, Int2x32_t* data, size_t len );
1116
+ size_t Write_PCM_HQ_2x24bit ( FILE_T outputFile, Int2x32_t* data, size_t len );
1117
+ size_t Write_PCM_HQ_2x32bit ( FILE_T outputFile, Int2x32_t* data, size_t len );
1118
+ int WIN_Play_Samples ( const void* buff, size_t len );
1119
+ int IRIX_Play_Samples ( const void* buff, size_t len );
1120
+ int WIN_Audio_close ( void );
1121
+ int IRIX_Audio_close ( void );
1122
+ void DisableSUID ( void );
1123
+ void EnableSUID ( void );
1124
+
1125
+ // pipeopen.c
1126
+ FILE* pipeopen ( const char* command, const char* filename );
1127
+
1128
+ // stderr.c
1129
+ void SetStderrSilent ( Bool_t state );
1130
+ Bool_t GetStderrSilent ( void );
1131
+ int Cdecl stderr_printf ( const char* format, ... );
1132
+
1133
+ // _setargv.c
1134
+ long treewalk ( const char* start, const char** mask, int (*fn)(const char* filename, void* aux), void* aux );
1135
+ void mysetargv ( int* argc, char*** argv, const char** extentions );
1136
+
1137
+ #if ENDIAN == HAVE_BIG_ENDIAN
1138
+
1139
+ # define ReadLE32(dst,psrc) dst = *(Uint32_t*)(psrc)
1140
+ # define ReadBE32(dst,psrc) \
1141
+ ((Uint8_t*)&(dst))[0] = ((Uint8_t*)(psrc))[3], \
1142
+ ((Uint8_t*)&(dst))[1] = ((Uint8_t*)(psrc))[2], \
1143
+ ((Uint8_t*)&(dst))[2] = ((Uint8_t*)(psrc))[1], \
1144
+ ((Uint8_t*)&(dst))[3] = ((Uint8_t*)(psrc))[0]
1145
+
1146
+
1147
+ #elif defined __i386__ /* 486+ */
1148
+
1149
+ # define ReadBE32(dst,psrc) __asm__ ( "bswap %0" : "=r" (dst) : "0" (*(Uint32_t*)(psrc)) )
1150
+ # define ReadLE32(dst,psrc) dst = *(Uint32_t*)(psrc)
1151
+
1152
+ # else
1153
+
1154
+ # define ReadBE32(dst,psrc) \
1155
+ ((Uint8_t*)&(dst))[0] = ((Uint8_t*)(psrc))[3], \
1156
+ ((Uint8_t*)&(dst))[1] = ((Uint8_t*)(psrc))[2], \
1157
+ ((Uint8_t*)&(dst))[2] = ((Uint8_t*)(psrc))[1], \
1158
+ ((Uint8_t*)&(dst))[3] = ((Uint8_t*)(psrc))[0]
1159
+ # define ReadLE32(dst,psrc) dst = *(Uint32_t*)(psrc)
1160
+
1161
+ # endif
1162
+
1163
+ //// Profiler include //////////////////////////////////////////////
1164
+
1165
+ #ifdef _MSC_VER
1166
+ #pragma warning ( disable : 4244 )
1167
+ #endif
1168
+
1169
+ #endif /* MPPDEC_MPPDEC_H */
1170
+
1171
+ /* end of mppdec.h */