~ubuntu-branches/ubuntu/maverick/gwhere/maverick

« back to all changes in this revision

Viewing changes to src/plugins/descr/mppdec.h

  • Committer: Bazaar Package Importer
  • Author(s): Sébastien LECACHEUR
  • Date: 2004-09-27 00:41:00 UTC
  • Revision ID: james.westby@ubuntu.com-20040927004100-q23139ty7b94kryi
Tags: upstream-0.1.6
Import upstream version 0.1.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  Copyright (C) Andree Buschmann and Frank Klemm
 
2
 *  Modified Raphael MARINIER
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; either version 2 of the License, or
 
7
 *  (at your option) any later version.
 
8
 *
 
9
 *  This program is distributed in the hope that it will be useful,
 
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *  GNU General Public License for more details.
 
13
 *
 
14
 *  You should have received a copy of the GNU General Public License
 
15
 *  along with this program; if not, write to the Free Software
 
16
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 */
 
18
 
 
19
//// Macros typical for Compilers:
 
20
//
 
21
//  __TURBOC__          Turbo-C, Borland-C
 
22
//  __BORLANDC__        Borland-C
 
23
//  __ZTC__             Zortech-C
 
24
//  _MSC_VER            Microsoft-C
 
25
//  __EMX__             Eberhard Mattes EMX (GNU based)
 
26
//  __GNUC__            GNU C based compiler (also Cygwin)
 
27
//  __CYGWIN__          Cygnus Windows C-Compiler (GNU based)
 
28
 
 
29
 
 
30
//// Macros typical for Operating Systems
 
31
//
 
32
//  __linux__           Linux
 
33
//  __bsdi__            BSDi
 
34
//  __FreeBSD__         FreeBSD
 
35
//  __NetBSD__          NetBSD
 
36
//  __OpenBSD__         OpenBSD
 
37
//  __unix__            Unix ????????
 
38
//  _WIN16              16 bit-Windows
 
39
//  _WIN32              32 bit-Windows (WIN32 is wrong, not defined by not MSC) (also __GNUC__ + _WIN32 is possible)
 
40
//  _HPUX_SOURCE        HP-UX
 
41
//  __BEOS__            BeOS
 
42
//  ???????             MS-DOS and relatives
 
43
 
 
44
 
 
45
//// Macros typical for special conformances
 
46
//                      System 5 Release 4 (SVr4)
 
47
//                      System 5 ID     (SVID)
 
48
//                      POSIX 1.0
 
49
//                      POSIX 1.0b
 
50
//                      X/OPEN
 
51
//                      BSD 4.3
 
52
//                      BSD 4.4
 
53
//                      ANSI
 
54
 
 
55
 
 
56
// Makros zum Manipulieren von Sockets + Files in einem rein (+0x4000)
 
57
// Zeiten wieder raus TIME/TIME_T/DTIME
 
58
 
 
59
#ifndef MPPDEC_MPPDEC_H
 
60
#define MPPDEC_MPPDEC_H
 
61
 
 
62
//// optimization/feature defines //////////////////////////////////
 
63
/*#ifndef NOT_INCLUDE_CONFIG_H
 
64
# include "config.h"
 
65
#endif
 
66
#include "./mpp.h"
 
67
*/
 
68
 
 
69
//// portable system includes //////////////////////////////////////
 
70
#include <stdio.h>
 
71
#include <stdlib.h>
 
72
#include <stddef.h>
 
73
#include <stdarg.h>
 
74
#include <string.h>
 
75
#include <limits.h>
 
76
#include <assert.h>
 
77
#include <math.h>
 
78
 
 
79
//// system dependent system includes //////////////////////////////
 
80
// low level I/O, where are prototypes and constants?
 
81
#if   defined _WIN32  ||  defined __TURBOC__  ||  defined __ZTC__  ||  defined _MSC_VER
 
82
# include <io.h>
 
83
# include <fcntl.h>
 
84
# include <time.h>
 
85
# include <sys/types.h>
 
86
# include <sys/stat.h>
 
87
#elif defined __unix__  ||  defined __linux__
 
88
# include <fcntl.h>
 
89
# include <unistd.h>
 
90
# include <sys/time.h>
 
91
# include <sys/ioctl.h>
 
92
# include <sys/types.h>
 
93
# include <sys/stat.h>
 
94
#else
 
95
// .... hier Includes f�r neues Betriebssystem einf�gen (mit vorgestellten: #elif defined)
 
96
# include <fcntl.h>
 
97
# include <unistd.h>
 
98
# include <sys/ioctl.h>
 
99
# include <sys/stat.h>
 
100
#endif
 
101
 
 
102
 
 
103
#if   defined __linux__
 
104
#  include <fpu_control.h>
 
105
#elif defined __FreeBSD__
 
106
# include <machine/floatingpoint.h>
 
107
#elif defined _MSC_VER
 
108
# include <float.h>
 
109
#endif
 
110
 
 
111
 
 
112
#if defined _WIN32
 
113
# undef USE_OSS_AUDIO
 
114
# undef USE_ESD_AUDIO
 
115
# undef USE_SUN_AUDIO
 
116
#else
 
117
# undef USE_WIN_AUDIO
 
118
#endif
 
119
 
 
120
#if defined __TURBOC__
 
121
# undef USE_OSS_AUDIO
 
122
# undef USE_ESD_AUDIO
 
123
# undef USE_SUN_AUDIO
 
124
# undef USE_NICE
 
125
# undef USE_REALTIME
 
126
#endif
 
127
 
 
128
#if defined MAKE_32BIT_FPU
 
129
# undef USE_OSS_AUDIO
 
130
# undef USE_ESD_AUDIO
 
131
# undef USE_SUN_AUDIO
 
132
#endif
 
133
 
 
134
#if defined USE_DIET  ||  defined MAKE_24BIT  ||  defined MAKE_32BIT  ||  defined MAKE_32BIT_FPU
 
135
# undef USE_ESD_AUDIO
 
136
#endif
 
137
 
 
138
#if defined MAKE_16BIT  ||  defined MAKE_24BIT  ||  defined MAKE_32BIT  ||  defined MAKE_32BIT_FPU
 
139
# undef USE_ASM
 
140
#endif
 
141
 
 
142
#if INT_MAX < 2147483647L
 
143
# undef USE_ASM
 
144
#endif
 
145
 
 
146
// sound card
 
147
#if defined USE_OSS_AUDIO
 
148
# include <sys/ioctl.h>
 
149
# include <sys/time.h>
 
150
# if   defined __linux__
 
151
#  include <linux/soundcard.h>
 
152
# elif defined __bsdi__
 
153
#  include <sys/soundcard.h>
 
154
# elif defined __FreeBSD__
 
155
#  include <machine/soundcard.h>
 
156
# elif defined __NetBSD__  ||  defined __OpenBSD__
 
157
#  include <soundcard.h>
 
158
# else
 
159
#  include <soundcard.h>
 
160
# endif
 
161
#endif /* USE_OSS_AUDIO */
 
162
 
 
163
#if defined USE_ESD_AUDIO
 
164
#undef USE_ESD_AUDIO
 
165
//# include <esd.h>
 
166
#endif
 
167
 
 
168
#if defined USE_SUN_AUDIO
 
169
# include <sys/audioio.h>
 
170
#endif
 
171
 
 
172
#ifdef MPP_ENCODER
 
173
# undef USE_HTTP
 
174
#endif
 
175
 
 
176
#ifdef USE_HTTP
 
177
# ifdef _WIN32
 
178
#  include <winsock2.h>
 
179
# else
 
180
#  include <sys/socket.h>
 
181
# endif
 
182
#endif
 
183
 
 
184
#if   defined USE_WIN_AUDIO
 
185
# include <windows.h>
 
186
# define WINAUDIO_FD            ((FILE_T)-128)
 
187
#elif defined USE_IRIX_AUDIO
 
188
# define IRIXAUDIO_FD           ((FILE_T)-127)
 
189
#endif
 
190
#define  NULL_FD                ((FILE_T)-126)
 
191
 
 
192
#if defined USE_NICE  &&  !defined _WIN32
 
193
# include <sys/resource.h>
 
194
#endif
 
195
 
 
196
// scheduler stuff
 
197
#if defined USE_REALTIME  &&  !defined _WIN32
 
198
# include <sched.h>
 
199
#endif
 
200
 
 
201
 
 
202
#ifndef O_BINARY
 
203
# ifdef _O_BINARY
 
204
#  define O_BINARY              _O_BINARY
 
205
# else
 
206
#  define O_BINARY              0
 
207
# endif
 
208
#endif
 
209
 
 
210
#if defined _WIN32  ||  defined __TURBOC__
 
211
# define strncasecmp(__s1,__s2,__n) strnicmp ((__s1), (__s2), (__n))
 
212
# define strcasecmp(__s1,__s2)      stricmp  ((__s1), (__s2))
 
213
# define MKDIR(__dir,__attr)        mkdir ((__dir))
 
214
#else
 
215
# define MKDIR(__dir,__attr)        mkdir ((__dir), (__attr))
 
216
#endif
 
217
 
 
218
#if defined _WIN32
 
219
# include <direct.h>
 
220
# define snprintf                   _snprintf
 
221
# define getcwd(__buff,__len)       _getcwd ((__buff), (__len))
 
222
# define sleep(__sec)               Sleep ((__sec) * 1000)
 
223
#endif
 
224
 
 
225
#if defined _WIN32
 
226
# define TIME_T                     long
 
227
# define TIME(__x)                  time ( &(__x) )
 
228
# define DTIME(__x,__y)             ( (double)(__y) - (__x) )
 
229
#else
 
230
# define TIME_T                     struct timeval
 
231
# define TIME(__x)                  gettimeofday ( &(__x), NULL )
 
232
# define DTIME(__x,__y)             ( ((double)(__y).tv_sec - (__x).tv_sec) + 1.e-6 * ((double)(__y).tv_usec - (__x).tv_usec) )
 
233
#endif
 
234
 
 
235
#if   defined __GNUC__
 
236
# define inline                 __inline__
 
237
# define restrict
 
238
#elif defined _WIN32
 
239
# define inline                 __inline
 
240
# define restrict
 
241
#else
 
242
# define inline
 
243
# define restrict
 
244
#endif
 
245
 
 
246
 
 
247
#define FILEIO 1
 
248
 
 
249
//// Binary/Low-Level-IO ///////////////////////////////////////////
 
250
//
 
251
// All file I/O is basicly handled via an ANSI file pointer (type: FILE*) in
 
252
// FILEIO-Mode 1 and via a POSIX file descriptor (type: int) in
 
253
// FILEIO-Mode 2 and 3.
 
254
//
 
255
// Some operation are only available via the POSIX interface (fcntl, setmode,
 
256
// ...) so we need a function to get the file descriptor from a file pointer.
 
257
// In FILEIO-Mode 2 and 3 this is a dummy function because we always working
 
258
// with this file descriptors.
 
259
//
 
260
 
 
261
#if  FILEIO == 1
 
262
# if   defined __BORLANDC__  ||  defined _WIN32
 
263
#  define FILENO(__fp)          _fileno ((__fp))
 
264
# elif defined __CYGWIN__  ||  defined __TURBOC__  ||  defined __unix__  ||  defined __EMX__  ||  defined _MSC_VER
 
265
#  define FILENO(__fp)          fileno  ((__fp))
 
266
# else
 
267
#  define FILENO(__fp)          fileno  ((__fp))
 
268
# endif
 
269
#else
 
270
#  define FILENO(__fd)          (__fd)
 
271
#endif
 
272
 
 
273
 
 
274
//
 
275
// If we have access to a file via file name, we can open the file with an
 
276
// additional "b" or a O_BINARY within the (f)open function to get a
 
277
// transparent untranslated data stream which is necessary for audio bitstream
 
278
// data and also for PCM data. If we are working with
 
279
// stdin/stdout/FILENO_STDIN/FILENO_STDOUT we can't open the file with this
 
280
// attributes, because the files are already open. So we need a non
 
281
// standardized sequence to switch to this mode (not necessary for Unix).
 
282
// Mostly the sequency is the same for incoming and outgoing streams, but only
 
283
// mostly so we need one for IN and one for OUT.
 
284
// Macros are called with the file pointer and you get back the untransalted file
 
285
// pointer which can be equal or different from the original.
 
286
//
 
287
 
 
288
#if   defined __EMX__
 
289
# define SETBINARY_IN(__fp)     (_fsetmode ( (__fp), "b" ), (__fp))
 
290
# define SETBINARY_OUT(__fp)    (_fsetmode ( (__fp), "b" ), (__fp))
 
291
#elif defined __TURBOC__ || defined __BORLANDC__
 
292
# define SETBINARY_IN(__fp)     (setmode   ( FILENO ((__fp)),  O_BINARY ), (__fp))
 
293
# define SETBINARY_OUT(__fp)    (setmode   ( FILENO ((__fp)),  O_BINARY ), (__fp))
 
294
#elif defined __CYGWIN__
 
295
# define SETBINARY_IN(__fp)     (setmode   ( FILENO ((__fp)), _O_BINARY ), (__fp))
 
296
# define SETBINARY_OUT(__fp)    (setmode   ( FILENO ((__fp)), _O_BINARY ), (__fp))
 
297
#elif defined _WIN32
 
298
# define SETBINARY_IN(__fp)     (_setmode  ( FILENO ((__fp)), _O_BINARY ), (__fp))
 
299
# define SETBINARY_OUT(__fp)    (_setmode  ( FILENO ((__fp)), _O_BINARY ), (__fp))
 
300
#elif defined _MSC_VER
 
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 __unix__
 
304
# define SETBINARY_IN(__fp)     (__fp)
 
305
# define SETBINARY_OUT(__fp)    (__fp)
 
306
#elif 0
 
307
# define SETBINARY_IN(__fp)     (freopen   ( NULL, "rb", (__fp) ), (__fp))
 
308
# define SETBINARY_OUT(__fp)    (freopen   ( NULL, "wb", (__fp) ), (__fp))
 
309
#else
 
310
# define SETBINARY_IN(__fp)     (__fp)
 
311
# define SETBINARY_OUT(__fp)    (__fp)
 
312
#endif
 
313
 
 
314
// file I/O using ANSI buffered file I/O via file pointer FILE* (fopen, fread, fwrite, fclose)
 
315
#if  FILEIO == 1
 
316
# define OFF_T                  signed long
 
317
# define FILE_T                 FILE*
 
318
# define OPEN(name)             fopen  (name, "rb" )
 
319
# define OPENRW(name)           fopen  (name, "r+b")
 
320
# define CREATE(name)           fopen  (name, "wb" )
 
321
# define INVALID_FILEDESC       NULL
 
322
# define CLOSE(fp)              fclose (fp)                  // CLOSE   returns -1 on error, otherwise 0
 
323
# define READ(fp,ptr,len)       fread  (ptr, 1, len, fp)     // READ    returns -1 or 0 on error/EOF, otherwise > 0
 
324
# define READ1(fp,ptr)          fread  (ptr, 1, 1, fp)       // READ    returns -1 or 0 on error/EOF, otherwise > 0
 
325
# define WRITE(fp,ptr,len)      fwrite (ptr, 1, len, fp)     // WRITE   returns -1 or 0 on error/EOF, otherwise > 0
 
326
# define SEEK(fp,offs,lbl)      fseek  (fp, offs, lbl)       // SEEK    returns -1 on error, otherwise >= 0
 
327
# define FILEPOS(fp)            ftell  (fp)                  // FILEPOS returns -1 on error, otherwise >= 0
 
328
# define STDIN                  stdin
 
329
# define STDOUT                 stdout
 
330
# define STDERR                 stderr
 
331
# define FDOPEN(fd,mode)        fdopen (fd, mode)
 
332
# define FLUSH(fp)              fflush (fp)
 
333
# define FEOF(fp)               feof (fp)
 
334
#endif /* FILEIO==1 */
 
335
 
 
336
// file I/O using POSIX unbuffered file I/O via file descriptors (open, read, write, close)
 
337
#if  FILEIO == 2
 
338
# ifdef WIN32
 
339
#  define OFF_T                 _off_t
 
340
# else
 
341
#  define OFF_T                 off_t
 
342
# endif
 
343
# define FILE_T                 int
 
344
# define OPEN(name)             open  (name, O_RDONLY|O_BINARY)
 
345
# define OPENRW(name)           open  (name, O_RDWR  |O_BINARY)
 
346
# define CREATE(name)           open  (name, O_WRONLY|O_BINARY|O_TRUNC|O_CREAT, 0644)
 
347
# define INVALID_FILEDESC       (-1)
 
348
# define CLOSE(fd)              close (fd)                   // CLOSE   returns -1 on error, otherwise 0
 
349
# if defined HAVE_INCOMPLETE_READ
 
350
#  define READ(fd,ptr,len)      complete_read (fd, ptr, len) // READ    returns -1 or 0 on error/EOF, otherwise > 0
 
351
# else
 
352
#  define READ(fd,ptr,len)      (size_t)read   (fd, ptr, len)// READ    returns -1 or 0 on error/EOF, otherwise > 0
 
353
# endif
 
354
# define READ1(fd,ptr)          (size_t)read   (fd, ptr, 1)  // READ    returns -1 or 0 on error/EOF, otherwise > 0
 
355
# define WRITE(fd,ptr,len)      (size_t)write  (fd, ptr, len)// WRITE   returns -1 or 0 on error/EOF, otherwise > 0
 
356
# define SEEK(fd,offs,lbl)      lseek  (fd, offs, lbl)       // SEEK    returns -1 on error, otherwise >= 0
 
357
# define FILEPOS(fd)            lseek  (fd, 0L, SEEK_CUR)    // FILEPOS returns -1 on error, otherwise >= 0
 
358
# define STDIN                  0
 
359
# define STDOUT                 1
 
360
# define STDERR                 2
 
361
# define FDOPEN(fd,mode)        (fd)
 
362
# define FLUSH(fd)              (void)(fd)
 
363
# ifdef _WIN32
 
364
#  define FEOF(fd)              _eof (fd)
 
365
# else
 
366
#  define FEOF(fd)              ((void)fd,0)
 
367
# endif
 
368
#endif /* FILEIO==2 */
 
369
 
 
370
// file I/O using Turbo-C lowest level unbuffered file I/O via file descriptors (_open, _read, _write, _close)
 
371
#if  FILEIO == 3
 
372
# define OFF_T                  signed long
 
373
# define FILE_T                 int
 
374
# define OPEN(name)             _open (name, O_RDONLY)
 
375
# define OPENRW(name)           _open (name, O_RDWR  )
 
376
# define CREATE(name)           _creat(name, 0)
 
377
# define INVALID_FILEDESC       (-1)
 
378
# define CLOSE(fd)              _close (fd)                  // CLOSE   returns -1 on error, otherwise 0
 
379
# define READ(fd,ptr,len)       (size_t)_read  (fd, ptr, len)// READ    returns -1 or 0 on error/EOF, otherwise > 0
 
380
# define READ1(fd,ptr)          (size_t)_read  (fd, ptr, 1)  // READ    returns -1 or 0 on error/EOF, otherwise > 0
 
381
# define WRITE(fd,ptr,len)      (size_t)_write (fd, ptr, len)// WRITE   returns -1 or 0 on error/EOF, otherwise > 0
 
382
# define SEEK(fd,offs,lbl)      lseek  (fd, offs, lbl)       // SEEK    returns -1 on error, otherwise >= 0
 
383
# define FILEPOS(fd)            lseek  (fd, 0L, SEEK_CUR)    // FILEPOS returns -1 on error, otherwise >= 0
 
384
# define STDIN                  0
 
385
# define STDOUT                 1
 
386
# define STDERR                 2
 
387
# undef  SETBINARY_IN
 
388
# undef  SETBINARY_OUT
 
389
# define SETBINARY_IN(fd)       (fd)
 
390
# define SETBINARY_OUT(fd)      (fd)
 
391
# define FDOPEN(fd,mode)        (fd)
 
392
# define FLUSH(fd)              (void)(fd)
 
393
# define FEOF(fd)               ((void)fd,0)
 
394
#endif /* FILEIO==3 */
 
395
 
 
396
 
 
397
#if FILEIO != 2  &&  defined USE_HTTP
 
398
# error HTTP can only be used by FILEIO==2
 
399
#endif
 
400
 
 
401
#if defined _WIN32  ||  defined __BEOS__
 
402
# define WRITE_SOCKET(sock,ptr,len)     send (sock, ptr, len, 0)
 
403
# define READ_SOCKET(sock,ptr,len)      recv (sock, ptr, len, 0)
 
404
#else
 
405
# define WRITE_SOCKET(sock,ptr,len)     write (sock, ptr, len)
 
406
# define READ_SOCKET(sock,ptr,len)      read  (sock, ptr, len)
 
407
#endif
 
408
 
 
409
#ifdef _WIN32
 
410
# define POPEN_READ_BINARY_OPEN(cmd)    _popen ((cmd), "rb")
 
411
# define POPEN_WRITE_BINARY_OPEN(cmd)   _popen ((cmd), "wb")
 
412
# define PCLOSE(fp)                     _pclose(fp)
 
413
#else
 
414
# define POPEN_READ_BINARY_OPEN(cmd)    popen ((cmd), "r")
 
415
# define POPEN_WRITE_BINARY_OPEN(cmd)   popen ((cmd), "w")
 
416
# define PCLOSE(fp)                     pclose(fp)
 
417
#endif
 
418
 
 
419
#if defined __unix__  ||  defined __bsdi__  ||  defined __FreeBSD__  ||  defined __OpenBSD__  ||  defined __NetBSD__  ||  defined __TURBOC__  ||  defined _WIN32
 
420
# define ISATTY(fd)             isatty (fd)
 
421
#else
 
422
# define ISATTY(fd)             0
 
423
#endif
 
424
 
 
425
// Path separator
 
426
#if defined __unix__  ||  defined __bsdi__  ||  defined __FreeBSD__  ||  defined __OpenBSD__  ||  defined __NetBSD__
 
427
# define PATH_SEP               '/'
 
428
# define DRIVE_SEP              '\0'
 
429
# define EXE_EXT                ""
 
430
# define DEV_NULL               "/dev/null"
 
431
# define ENVPATH_SEP            ':'
 
432
#elif defined _WIN32  ||  defined __TURBOC__  ||  defined __ZTC__  ||  defined _MSC_VER
 
433
# define PATH_SEP               '\\'
 
434
# define DRIVE_SEP              ':'
 
435
# define EXE_EXT                ".exe"
 
436
# define DEV_NULL               "\\nul"
 
437
# define ENVPATH_SEP            ';'
 
438
#else
 
439
# define PATH_SEP               '/'         // Amiga: C:/
 
440
# define DRIVE_SEP              ':'
 
441
# define EXE_EXT                ""
 
442
# define DEV_NULL               "nul"
 
443
# define ENVPATH_SEP            ';'
 
444
#endif
 
445
 
 
446
 
 
447
// maximum length of file names
 
448
#ifndef PATHLEN_MAX
 
449
# if   defined FILENAME_MAX
 
450
#  define PATHLEN_MAX           FILENAME_MAX
 
451
# elif INT_MAX < 2147483647L
 
452
#  define PATHLEN_MAX            128
 
453
# else
 
454
#  define PATHLEN_MAX           1024
 
455
# endif
 
456
#endif /* !PATHLEN_MAX */
 
457
 
 
458
#ifdef _WIN32
 
459
# define TitleBar(text)   SetConsoleTitle (text)
 
460
#else
 
461
# define TitleBar(text)   (void) (text)
 
462
#endif
 
463
 
 
464
 
 
465
#define SPEAKER_FRONT_LEFT             0x00000001
 
466
#define SPEAKER_FRONT_RIGHT            0x00000002
 
467
#define SPEAKER_FRONT_CENTER           0x00000004
 
468
#define SPEAKER_LOW_FREQUENCY          0x00000008
 
469
#define SPEAKER_BACK_LEFT              0x00000010
 
470
#define SPEAKER_BACK_RIGHT             0x00000020
 
471
#define SPEAKER_FRONT_LEFT_OF_CENTER   0x00000040
 
472
#define SPEAKER_FRONT_RIGHT_OF_CENTER  0x00000080
 
473
#define SPEAKER_BACK_CENTER            0x00000100
 
474
#define SPEAKER_SIDE_LEFT              0x00000200
 
475
#define SPEAKER_SIDE_RIGHT             0x00000400
 
476
#define SPEAKER_TOP_CENTER             0x00000800
 
477
#define SPEAKER_TOP_FRONT_LEFT         0x00001000
 
478
#define SPEAKER_TOP_FRONT_CENTER       0x00002000
 
479
#define SPEAKER_TOP_FRONT_RIGHT        0x00004000
 
480
#define SPEAKER_TOP_BACK_LEFT          0x00008000
 
481
#define SPEAKER_TOP_BACK_CENTER        0x00010000
 
482
#define SPEAKER_TOP_BACK_RIGHT         0x00020000
 
483
#define SPEAKER_RESERVED               0x80000000
 
484
 
 
485
 
 
486
 
 
487
//// constants /////////////////////////////////////////////////////
 
488
 
 
489
#define MAXCH            2
 
490
 
 
491
 
 
492
#ifdef USE_SV8
 
493
# define MAX_SV          "SV8"
 
494
#else
 
495
# define MAX_SV          "SV7"
 
496
#endif
 
497
 
 
498
#ifdef USE_ASM
 
499
# define BUILD           "3DNow/SSE"
 
500
#else
 
501
# define BUILD           ""
 
502
#endif
 
503
 
 
504
 
 
505
#define COPYRIGHT        "(C) 1999-2003 Buschmann/Klemm/Piecha/Wolf"
 
506
 
 
507
#define DECODER_DELAY    (512 - 32 + 1)
 
508
#define BLK_SIZE         (36 * 32)
 
509
 
 
510
 
 
511
//// logging defines, for development only /////////////////////////
 
512
#if defined _WIN32  ||  defined __TURBOC__
 
513
# define LOGPATH         ".\\"
 
514
# define MUSICPATH       "D:\\AUDIO\\"
 
515
#else
 
516
# define LOGPATH         "./"
 
517
# define MUSICPATH       "/Archive/Audio/"
 
518
#endif
 
519
#define _(x)             (void)(fprintf(stderr,"<%d>\n",(x)),fflush(stderr))
 
520
 
 
521
#ifdef DEBUG
 
522
# define REP(x)          (void)(x)
 
523
#else
 
524
# define REP(x)
 
525
#endif
 
526
 
 
527
 
 
528
//// numerical constants ///////////////////////////////////////////
 
529
#define C00              (Float) 0.500000000000000000000000L    // Cxx = 0.5 / cos (xx*M_PI/64)
 
530
#define C01              (Float) 0.500602998235196301334178L
 
531
#define C02              (Float) 0.502419286188155705518560L
 
532
#define C03              (Float) 0.505470959897543659956626L
 
533
#define C04              (Float) 0.509795579104159168925062L
 
534
#define C05              (Float) 0.515447309922624546962323L
 
535
#define C06              (Float) 0.522498614939688880640101L
 
536
#define C07              (Float) 0.531042591089784174473998L
 
537
#define C08              (Float) 0.541196100146196984405269L
 
538
#define C09              (Float) 0.553103896034444527838540L
 
539
#define C10              (Float) 0.566944034816357703685831L
 
540
#define C11              (Float) 0.582934968206133873665654L
 
541
#define C12              (Float) 0.601344886935045280535340L
 
542
#define C13              (Float) 0.622504123035664816182728L
 
543
#define C14              (Float) 0.646821783359990129535794L
 
544
#define C15              (Float) 0.674808341455005746033820L
 
545
#define C16              (Float) 0.707106781186547524436104L
 
546
#define C17              (Float) 0.744536271002298449773679L
 
547
#define C18              (Float) 0.788154623451250224773056L
 
548
#define C19              (Float) 0.839349645415527038721463L
 
549
#define C20              (Float) 0.899976223136415704611808L
 
550
#define C21              (Float) 0.972568237861960693780520L
 
551
#define C22              (Float) 1.060677685990347471323668L
 
552
#define C23              (Float) 1.169439933432884955134476L
 
553
#define C24              (Float) 1.306562964876376527851784L
 
554
#define C25              (Float) 1.484164616314166277319733L
 
555
#define C26              (Float) 1.722447098238333927796261L
 
556
#define C27              (Float) 2.057781009953411550808880L
 
557
#define C28              (Float) 2.562915447741506178719328L
 
558
#define C29              (Float) 3.407608418468718785698107L
 
559
#define C30              (Float) 5.101148618689163857960189L
 
560
#define C31              (Float)10.190008123548056810994678L
 
561
 
 
562
#define SS05             (Float) 0.840896415253714543018917L      // 0.5^0.25
 
563
 
 
564
 
 
565
#ifndef M_PI
 
566
# define M_PI            3.1415926535897932384626433832795029     // 4*atan(1)
 
567
# define M_PIl           3.1415926535897932384626433832795029L
 
568
# define M_LN2           0.6931471805599453094172321214581766     // ln(2)
 
569
# define M_LN2l          0.6931471805599453094172321214581766L
 
570
# define M_LN10          2.3025850929940456840179914546843642     // ln 10 */
 
571
# define M_LN10l         2.3025850929940456840179914546843642L
 
572
#endif
 
573
 
 
574
 
 
575
//// 'Cdecl' forces to use standard C/C++ calling convention ///////
 
576
#if   defined _WIN32
 
577
# define Cdecl           __cdecl
 
578
#elif defined __ZTC__
 
579
# define Cdecl           _cdecl
 
580
#elif defined __TURBOC__
 
581
# define Cdecl           cdecl
 
582
#else
 
583
# define Cdecl
 
584
#endif
 
585
 
 
586
//// expect handling of GCC ////////////////////////////////////////
 
587
#ifdef __GNUC__
 
588
# if __GNUC__ < 3
 
589
#  define __builtin_expect(cond,exp)  (cond)
 
590
#  ifndef expect
 
591
#    define expect(cond,exp)          __builtin_expect(cond,exp)
 
592
#  endif
 
593
# else
 
594
#  ifndef expect
 
595
#   define expect(cond,exp)           __builtin_expect(cond,exp)
 
596
#  endif
 
597
# endif
 
598
#else
 
599
# define __builtin_expect(cond,exp)   (cond)
 
600
# ifndef expect
 
601
#  define expect(cond,exp)            __builtin_expect(cond,exp)
 
602
# endif
 
603
#endif
 
604
 
 
605
#define if0(x)                        if (expect(x,0))
 
606
#define if1(x)                        if (expect(x,1))
 
607
#define while0(x)                     while (expect(x,0))
 
608
#define while1(x)                     while (expect(x,1))
 
609
 
 
610
#ifndef __GNUC__
 
611
# define __attribute__(x)
 
612
#else
 
613
# define __attribute__(x)
 
614
#endif
 
615
 
 
616
//// Remaining macros //////////////////////////////////////////////
 
617
// selects input buffer size and some constants needed for input buffer handling
 
618
#ifndef IBUFLOG2                 // must be at least 10 (bitrate always <626 kbps) or better 11 ( <1253 kbps)
 
619
# if INT_MAX < 2147483647L
 
620
#  define IBUFLOG2       11      // 8 KByte buffer, possible 11...13 (32 KByte limit)
 
621
# else
 
622
#  define IBUFLOG2       21      // 8 MByte buffer, possible 11...29 ( 2 GByte limit)
 
623
# endif
 
624
#endif
 
625
#define IBUFSIZE         ((size_t)(1LU<<(IBUFLOG2)))
 
626
#define IBUFSIZE2        ((size_t)((IBUFSIZE)/2))
 
627
#define IBUFMASK         ((size_t)((IBUFSIZE)-1))
 
628
 
 
629
// save memory space for 16 bit compiler (data + stack < 64 KByte)
 
630
#if INT_MAX < 2147483647L
 
631
# if VIRT_SHIFT     >  6
 
632
#  undef  VIRT_SHIFT
 
633
#  define VIRT_SHIFT   6
 
634
# endif
 
635
# if      IBUFLOG2  > 11
 
636
#  undef  IBUFLOG2
 
637
#  define IBUFLOG2    11
 
638
# endif
 
639
# define USE_HUFF_PACK
 
640
# define USE_ARRAY_PACK
 
641
#endif
 
642
 
 
643
// generate a macro which contains information about compile time settings
 
644
#define STR(x)   _STR(x)
 
645
#define _STR(x)  #x
 
646
#ifdef NDEBUG
 
647
# define _T1  ""
 
648
#else
 
649
# define _T1  "DEBUG "
 
650
#endif
 
651
#if  defined USE_OSS_AUDIO  ||  defined USE_ESD_AUDIO  ||  defined USE_SUN_AUDIO  ||  defined USE_WIN_AUDIO
 
652
# define _T2  "SND "
 
653
#else
 
654
# define _T2  ""
 
655
#endif
 
656
#ifdef USE_NICE
 
657
# define _T3  "NICE "
 
658
#else
 
659
# define _T3  ""
 
660
#endif
 
661
#if defined USE_REALTIME
 
662
# define _T4  "RT "
 
663
#else
 
664
# define _T4  ""
 
665
#endif
 
666
#ifdef HAVE_IEEE754_FLOAT
 
667
# define _T5  "IEEE "
 
668
#else
 
669
# define _T5  ""
 
670
#endif
 
671
#define _T6  "IO=" STR(FILEIO) " "
 
672
#ifdef USE_HUFF_PACK
 
673
# define _T7  "H-PCK "
 
674
#else
 
675
# define _T7  ""
 
676
#endif
 
677
#ifdef USE_ARRAY_PACK
 
678
# define _T8  "A-PCK "
 
679
#else
 
680
# define _T8  ""
 
681
#endif
 
682
#define _T9  "SHFT=" STR(VIRT_SHIFT) " "
 
683
#define _T10 "IBUF=" STR(IBUFLOG2) " "
 
684
 
 
685
#define COMPILER_FLAGS  _T1 _T2 _T3 _T4 _T5 _T6 _T7 _T8 _T9 _T10
 
686
 
 
687
// align a pointer by maybe incrementing it
 
688
#define ALIGN(ptr,alignment) \
 
689
                    (void*)((((ptrdiff_t)(ptr)) & (-(ptrdiff_t)(alignment))) + (alignment))   // alignt einen Zeiger mit alignment, das Quellarray sollte mindestens alignment-1 Bytes l�nger als die erforderliche L�nge sein
 
690
 
 
691
 
 
692
//// Simple types //////////////////////////////////////////////////
 
693
 
 
694
#if   CHAR_BIT == 8  &&  SCHAR_MAX == 127L
 
695
typedef unsigned char       Uint8_t;    // guaranteed  8 bit unsigned integer type with range 0...255
 
696
typedef signed   char       Int8_t;     // guaranteed  8 bit signed   integer type with range -128...127
 
697
#else
 
698
# error No  8 bit int type found. Tested: char
 
699
#endif
 
700
 
 
701
#if   SHRT_MAX == 32767L
 
702
typedef unsigned short int  Uint16_t;   // guaranteed 16 bit unsigned integer type with range 0...65535
 
703
typedef signed   short int  Int16_t;    // guaranteed 16 bit signed   integer type with range -32768...32767
 
704
#else
 
705
# error No 16 bit int type found. Tested: short
 
706
#endif
 
707
 
 
708
#if   INT_MAX == 2147483647L
 
709
typedef unsigned int        Uint32_t;   // guaranteed 32 bit unsigned integer type with range 0...4294967295
 
710
typedef signed   int        Int32_t;    // guaranteed 32 bit signed   integer type with range -2147483648...2147483647
 
711
#elif LONG_MAX == 2147483647L
 
712
typedef unsigned long int   Uint32_t;   // guaranteed 32 bit unsigned integer type with range 0...4294967295
 
713
typedef signed   long int   Int32_t;    // guaranteed 32 bit signed   integer type with range -2147483648...2147483647
 
714
#else
 
715
# error No 32 bit int type found. Tested: int, long
 
716
#endif
 
717
 
 
718
#if    defined __C99__                 // C9x has a type which is exact 64 bit
 
719
typedef int64_t             Int64_t;
 
720
typedef uint64_t            Uint64_t;
 
721
#elif  defined __GNUC__                // GCC uses long long as 64 bit
 
722
typedef signed   long long  Int64_t;
 
723
typedef unsigned long long  Uint64_t;
 
724
#elif  defined LLONG_MAX               // long long (when existing) is normally 64 bit
 
725
typedef signed   long long  Int64_t;
 
726
typedef unsigned long long  Uint64_t;
 
727
#elif  LONG_MAX > 0xFFFFFFFFLU         // long is longer than 33 bit, assume 64 bit
 
728
typedef signed   long       Int64_t;
 
729
typedef unsigned long       Uint64_t;
 
730
#elif  defined _WIN32                  // Microsoft and Intel call it __int64
 
731
typedef signed   __int64    Int64_t;
 
732
typedef unsigned __int64    Uint64_t;
 
733
#else
 
734
# define NO_INT64_T                    // no type mapped to 64 bit integer
 
735
#endif
 
736
 
 
737
 
 
738
#if defined _WIN32  &&  !defined __GNUC__  &&  !defined __C99__
 
739
typedef signed long         ssize_t;
 
740
#endif
 
741
 
 
742
#ifdef USE_ARRAY_PACK
 
743
typedef signed char         Bool_t;     // ==0: false, !=0: true
 
744
#else
 
745
typedef signed int          Bool_t;     // ==0: false, !=0: true
 
746
#endif
 
747
typedef Uint32_t            Ibuf_t;     // type for input buffer, currently this type must be 32 bit
 
748
typedef signed   char       Schar;      // at least -127...+127
 
749
typedef unsigned char       Uchar;      // at least 0...255
 
750
typedef signed   short int  Short;      // at least -32767...+32767, memory economic type
 
751
typedef unsigned short int  Ushort;     // at least 0...65535, memory economic type
 
752
typedef signed   int        Int;        // at least -32767...+32767, fast type
 
753
typedef unsigned int        Uint;       // at least 0...65535, fast type
 
754
typedef signed   long int   Long;       // at least -2147483647...+2147483647, but more is better
 
755
typedef unsigned long int   Ulong;      // at least 0...4294967295, but more is better
 
756
//                          size_t;     // size of memory objects
 
757
//                          ptrdiff_t;  // pointer differences, may be larger than size_t
 
758
typedef float               Float32_t;  // guaranteed 32 bit floating point type
 
759
typedef double              Float64_t;  // guaranteed 64 bit floating point type
 
760
typedef float               Float;      // fastest floating point type, memory economic (used for all PCM calculations)
 
761
#define SIZEOF_Float  4                 // size of the type 'Float' in sizeof units
 
762
typedef double              Double;     // floating point with extended precision (more than 32 bit mantissa)
 
763
typedef long double         Ldouble;    // most exact floating point format
 
764
 
 
765
#if   defined MAKE_16BIT  ||  defined MAKE_24BIT  ||  defined MAKE_32BIT
 
766
# ifdef NO_INT64_T
 
767
#   error No 64 bit int type found, needed for HQ 16...32 bit output
 
768
# endif
 
769
typedef Int32_t              IntSample_t;
 
770
# if defined MAKE_32BIT
 
771
#  define SAMPLE_SIZE        32
 
772
#  define PROG_NAME          "mppdec32"
 
773
#  define SAMPLE_SIZE_STRING " (32 bit HQ)"
 
774
#  define Write_PCM(fd,p,b)  Write_PCM_HQ_32bit ( fd, p, b )
 
775
#  define Synthese_Filter(Stream,offset,Vi,Yi,chs,ch) \
 
776
                            Synthese_Filter_32_C ( Stream, offset, Vi, Yi, chs, ch )
 
777
#  undef  USE_ESD_AUDIO
 
778
# elif defined MAKE_24BIT
 
779
#  define SAMPLE_SIZE        24
 
780
#  define PROG_NAME          "mppdec24"
 
781
#  define SAMPLE_SIZE_STRING " (24 bit HQ)"
 
782
#  define Write_PCM(fd,p,b)  Write_PCM_HQ_24bit ( fd, p, b )
 
783
#  define Synthese_Filter(Stream,offset,Vi,Yi,chs,ch) \
 
784
                            Synthese_Filter_32_C ( Stream, offset, Vi, Yi, chs, ch )
 
785
#  undef  USE_ESD_AUDIO
 
786
# elif defined MAKE_16BIT
 
787
#  define SAMPLE_SIZE        16
 
788
#  define PROG_NAME          "mppdec16"
 
789
#  define SAMPLE_SIZE_STRING " (16 bit HQ)"
 
790
#  define Write_PCM(fd,p,b)  Write_PCM_HQ_16bit ( fd, p, b )
 
791
#  define Synthese_Filter(Stream,offset,Vi,Yi,chs,ch) \
 
792
                            Synthese_Filter_32_C ( Stream, offset, Vi, Yi, chs, ch )
 
793
# endif
 
794
#elif defined MAKE_32BIT_FPU
 
795
typedef Float32_t           IntSample_t;
 
796
# define SAMPLE_SIZE        32
 
797
# define PROG_NAME          "mppdec32FP"
 
798
# define SAMPLE_SIZE_STRING " (32 bit FP)"
 
799
# define Write_PCM(fd,p,b)  Write_PCM_32bit ( fd, p, b )
 
800
# define Synthese_Filter(Stream,offset,Vi,Yi,chs,ch) \
 
801
                            Synthese_Filter_32FP_C ( Stream, offset, Vi, Yi, chs )
 
802
#else
 
803
typedef Int16_t             IntSample_t;
 
804
# define SAMPLE_SIZE        16
 
805
# define PROG_NAME          "mppdec"
 
806
# define SAMPLE_SIZE_STRING ""
 
807
# define Write_PCM(fd,p,b)  Write_PCM_16bit ( fd, p, b )
 
808
# ifdef USE_ASM
 
809
#  define Synthese_Filter(Stream,offset,Vi,Yi,chs,ch) \
 
810
                            Synthese_Filter_16   ( Stream, offset, Vi, Yi, chs )
 
811
# else
 
812
#  define Synthese_Filter(Stream,offset,Vi,Yi,chs,ch) \
 
813
                            Synthese_Filter_16_C ( Stream, offset, Vi, Yi, chs )
 
814
# endif /* USE_ASM */
 
815
#endif
 
816
 
 
817
 
 
818
//// More complex types ////////////////////////////////////////////
 
819
 
 
820
typedef Int    quant_t ;
 
821
#ifdef USE_ARRAY_PACK
 
822
typedef Schar  scf_t ;
 
823
typedef Schar  res_t ;
 
824
typedef Uchar  pack_t;
 
825
#else
 
826
typedef Int    scf_t ;
 
827
typedef Int    res_t ;
 
828
typedef Int   pack_t;
 
829
#endif
 
830
 
 
831
typedef struct {
 
832
#ifndef MPP_ENCODER
 
833
    Uint32_t      Code;         // >=32 bit
 
834
# ifdef USE_HUFF_PACK
 
835
    Schar         Value;        // >= 7 bit
 
836
    Uchar         Length;       // >= 4 bit
 
837
# else
 
838
    Int           Value;
 
839
    Uint          Length;
 
840
# endif
 
841
#else
 
842
# ifdef USE_HUFF_PACK
 
843
    Uint8_t       Length;      // >=  4 bit
 
844
    Uint8_t       ___;
 
845
    Uint16_t      Code;        // >= 14 bit
 
846
# else
 
847
    Uint          Code;
 
848
    Uint          Length;
 
849
# endif
 
850
#endif
 
851
} Huffman_t ;
 
852
 
 
853
typedef struct {
 
854
    Uint          Code   : 16;  // >= 14 bit
 
855
    Uint          Length :  8;  // >=  4 bit
 
856
} HuffSrc_t ;
 
857
 
 
858
typedef struct {
 
859
    OFF_T         FileSize;
 
860
    Int           GenreNo;
 
861
    Int           TrackNo;
 
862
    char*         Genre  ;
 
863
    char*         Year   ;
 
864
    char*         Track  ;
 
865
    char*         Title  ;
 
866
    char*         Artist ;
 
867
    char*         Album  ;
 
868
    char*         Comment;
 
869
} TagInfo_t ;
 
870
 
 
871
typedef void  (*SyntheseFilter16_t) ( Int16_t* Stream, Int* const offset, Float* Vi, const Float Yi[36][32], Uint channels );
 
872
typedef void  (*SyntheseFilter32_t) ( Int32_t* Stream, Int* const offset, Float* Vi, const Float Yi[36][32], Uint channels, Uint ch );
 
873
typedef Int   (*HeaderWriter_t)     ( FILE_T outputFile, Ldouble  SampleFreq, Uint BitsPerSample, Uint Channels, Double SamplesPerChannel );
 
874
 
 
875
#if defined MAKE_16BIT  ||  defined MAKE_24BIT  ||  defined MAKE_32BIT
 
876
typedef struct {
 
877
    const Float*  FilterCoeff;
 
878
    Uint64_t      Mask;
 
879
    Float64_t     Add;
 
880
    Float         Dither;
 
881
    Uint32_t      Overdrives;
 
882
    Int64_t       MaxLevel;
 
883
    Bool_t        NoShaping;
 
884
    Float         ErrorHistory     [MAXCH] [16];       // max. 2 channels, 16th order Noise shaping
 
885
    Float         DitherHistory    [MAXCH] [16];
 
886
    Int32_t       LastRandomNumber [MAXCH];
 
887
} dither_t;
 
888
#else
 
889
typedef struct {
 
890
    Uint32_t      Overdrives;
 
891
    Int32_t       MaxLevel;
 
892
} dither_t;
 
893
#endif
 
894
 
 
895
 
 
896
//// Variables /////////////////////////////////////////////////////
 
897
 
 
898
// decode.c
 
899
extern Ibuf_t             InputBuff [IBUFSIZE]; // Lesebuffer f�r den MP+-Datenstrom
 
900
extern size_t             InputCnt;             // aktueller Offset in diesem Buffer
 
901
 
 
902
// huffsv7.c
 
903
extern Huffman_t          HuffHdr    [10];
 
904
extern Huffman_t          HuffSCFI   [ 4];
 
905
extern Huffman_t          HuffDSCF   [16];
 
906
extern Huffman_t          HuffQ1 [2] [ 3*3*3];
 
907
extern Huffman_t          HuffQ2 [2] [ 5*5];
 
908
extern Huffman_t          HuffQ3 [2] [ 7];
 
909
extern Huffman_t          HuffN3 [2] [ 7*7];
 
910
extern Huffman_t          HuffQ4 [2] [ 9];
 
911
extern Huffman_t          HuffQ5 [2] [15];
 
912
extern Huffman_t          HuffQ6 [2] [31];
 
913
extern Huffman_t          HuffQ7 [2] [63];
 
914
extern Huffman_t          HuffN8 [2][127];
 
915
extern const Huffman_t*   HuffQ  [2] [ 8];
 
916
extern const Huffman_t*   HuffN  [2] [ 9];
 
917
extern Uint8_t            LUT1_0  [1<< 6];
 
918
extern Uint8_t            LUT1_1  [1<< 9];
 
919
extern Uint8_t            LUT2_0  [1<< 7];
 
920
extern Uint8_t            LUT2_1  [1<<10];
 
921
extern Uint8_t            LUT3_0  [1<< 4];
 
922
extern Uint8_t            LUT3_1  [1<< 5];
 
923
extern Uint8_t            LUT4_0  [1<< 4];
 
924
extern Uint8_t            LUT4_1  [1<< 5];
 
925
extern Uint8_t            LUT5_0  [1<< 6];
 
926
extern Uint8_t            LUT5_1  [1<< 8];
 
927
extern Uint8_t            LUT6_0  [1<< 7];
 
928
extern Uint8_t            LUT6_1  [1<< 7];
 
929
extern Uint8_t            LUT7_0  [1<< 8];
 
930
extern Uint8_t            LUT7_1  [1<< 8];
 
931
extern Uint8_t            LUTDSCF [1<< 6];
 
932
 
 
933
// huffsv46.c
 
934
extern const Huffman_t*   Entropie      [18];
 
935
extern const Huffman_t*   Region        [32];
 
936
extern Huffman_t          SCFI_Bundle   [ 8];
 
937
extern Huffman_t          DSCF_Entropie [13];
 
938
 
 
939
// mppdec.c
 
940
extern Float              YY       [MAXCH] [36] [32];
 
941
extern scf_t              SCF_Index[MAXCH] [32] [ 3];  // Skalierungsfaktor
 
942
extern res_t              Res      [MAXCH] [32];       // Aufl�sungsstufen der Teilb�nder
 
943
extern quant_t            QQ       [MAXCH] [32] [36];      // quantisierte Samples
 
944
extern Bool_t             MS_Band          [32];       // subbandweiser Flag f�r M/S-Signalf�hrung
 
945
extern Bool_t             MS_used;                  // globaler Flag f�r M/S-Signalf�hrung
 
946
extern Bool_t             IS_used;
 
947
extern Uint               DUMPSELECT;
 
948
 
 
949
#define LITTLE                  0
 
950
#define BIG                     1
 
951
extern Bool_t                   output_endianess;
 
952
#if   defined HAVE_LITTLE_ENDIAN
 
953
# define machine_endianess      LITTLE
 
954
#elif defined HAVE_BIG_ENDIAN
 
955
# define machine_endianess      BIG
 
956
#endif
 
957
 
 
958
// requant.c
 
959
extern Float              __SCF    [8 + 128];       // tabellierte Skalenfaktoren von -8 bis +127
 
960
#define SCF             ( __SCF + 8 )
 
961
extern Int8_t             Q_bit         [32];       // Anzahl Bits f�r Speicherung der Aufl�sung (SV6)
 
962
extern Int8_t             Q_res         [32] [16];  // Index -> Aufl�sung (SV6)
 
963
extern Int                Min_Band;
 
964
extern Int                Max_Band;
 
965
extern Float              __Cc7         [1 + 18];
 
966
extern const Uint         __Dc7         [1 + 18];
 
967
#define Cc7             ( __Cc7 + 1 )
 
968
#define Dc7             ( __Dc7 + 1 )
 
969
extern Float              Cc8           [20];
 
970
extern const Uint         Dc8           [20];
 
971
 
 
972
// synthtab.c
 
973
extern const Float        Cos64         [32];
 
974
extern const Float        Di_opt        [32] [16];
 
975
 
 
976
// stderr.c
 
977
extern Bool_t             stderr_silent;
 
978
 
 
979
 
 
980
//// procedures/functions //////////////////////////////////////////
 
981
// cpu_feat.c
 
982
Bool_t Cdecl  Has_MMX                 ( void );
 
983
Bool_t Cdecl  Has_SIMD                ( void );
 
984
Bool_t Cdecl  Has_SIMD2               ( void );
 
985
Bool_t Cdecl  Has_3DNow               ( void );
 
986
 
 
987
// decode.c
 
988
void       Bitstream_init             ( void );
 
989
Ulong      BitsRead                   ( void );
 
990
Uint32_t   Bitstream_read             ( Int  bits );
 
991
Uint32_t   Bitstream_peek             ( Uint pos, Int bits );
 
992
void       Bitstream_skip             ( Uint bits );
 
993
Uint32_t   Bitstream_preview          ( Int  bits );  // dto., aber Daten werden noch nicht abquitiert
 
994
int        Read_Bitstream             ( Uint StreamVersion, Uint channels );
 
995
 
 
996
// directory.c
 
997
int        IsDirectory                ( const char* path );
 
998
 
 
999
// http.c
 
1000
int        http_open                  ( const char* URL );
 
1001
 
 
1002
// huffsv7.c
 
1003
void       Init_Huffman_Decoder_SV7   ( void );
 
1004
void       Init_Huffman_Encoder_SV7   ( void );
 
1005
 
 
1006
// huffsv46.c
 
1007
void       Init_Huffman_Decoder_SV4_6 ( void );
 
1008
 
 
1009
// id3tag.c
 
1010
Int        Read_ID3V1_Tags            ( FILE_T fp, TagInfo_t* tip );
 
1011
Int        Read_APE_Tags              ( FILE_T fp, TagInfo_t* tip );
 
1012
 
 
1013
// codetable_enc.c/codetable_dec.c
 
1014
void       Init_Decoder_Huffman_Tables ( void );
 
1015
void       Init_Encoder_Huffman_Tables ( void );
 
1016
 
 
1017
// requant.c
 
1018
void       Init_QuantTab              ( Int maximum_Band, Bool_t used_IS, Double amplification, Uint StreamVersion );
 
1019
 
 
1020
// synth.c
 
1021
Uint32_t   random_int                 ( void );
 
1022
 
 
1023
void Cdecl Calculate_New_V_i387       ( const Float* Sample, Float* V );
 
1024
void Cdecl Calculate_New_V_3DNow      ( const Float* Sample, Float* V );
 
1025
void Cdecl New_V_Helper2              ( Float* A, const Float* Sample );
 
1026
void Cdecl New_V_Helper3              ( Float* A, const Float* Sample );
 
1027
void Cdecl New_V_Helper4              ( Float* V );
 
1028
 
 
1029
void Cdecl VectorMult_i387            ( void* buff, const Float* V );
 
1030
void Cdecl VectorMult_3DNow           ( void* buff, const Float* V );
 
1031
void Cdecl VectorMult_SIMD            ( void* buff, const Float* V );
 
1032
 
 
1033
void       Synthese_Filter_16_C       ( Int16_t* Stream, Int* const offset, Float* Vi, const Float Yi[36][32], Uint channels );
 
1034
void       Synthese_Filter_32_C       ( Int32_t* Stream, Int* const offset, Float* Vi, const Float Yi[36][32], Uint channels, Uint channel );
 
1035
 
 
1036
void Cdecl Reset_FPU                  ( void );
 
1037
void Cdecl Reset_FPU_3DNow            ( void );
 
1038
void Cdecl memcpy_dn_MMX              ( void* dst, const void* src, size_t words64byte  );
 
1039
void Cdecl memcpy_dn_SIMD             ( void* dst, const void* src, size_t words128byte );
 
1040
 
 
1041
void       Init_Dither                ( Int bits, int shapingtype, Double dither );
 
1042
void       OverdriveReport            ( void );
 
1043
SyntheseFilter16_t
 
1044
           Get_Synthese_Filter        ( void );
 
1045
 
 
1046
// tools.c
 
1047
size_t     Read_LittleEndians         ( FILE_T fp, Uint32_t* dst, size_t words32bit );
 
1048
void       Requantize_MidSideStereo   ( Int Stop_Band, const Bool_t* used_MS, unsigned int StreamVersion );
 
1049
void       Requantize_IntensityStereo ( Int Start_Band, Int Stop_Band );
 
1050
void       Resort_HuffTable           ( Huffman_t* const Table, const size_t elements, Int offset );
 
1051
void       Make_HuffTable             ( Huffman_t* dst, const HuffSrc_t* src, size_t len );
 
1052
void       Make_LookupTable           ( Uint8_t* LUT, size_t LUT_len, const Huffman_t* const Table, const size_t elements );
 
1053
size_t     complete_read              ( int fd, void* dest, size_t bytes );
 
1054
 
 
1055
 
 
1056
// cpu.h
 
1057
void       Init_FPU                   ( void );
 
1058
 
 
1059
 
 
1060
// wave_out.c
 
1061
Int        Write_WAVE_Header          ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels, Double SamplesPerChannel );
 
1062
Int        Write_AIFF_Header          ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels, Double SamplesPerChannel );
 
1063
Int        Write_Raw_Header           ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels, Double SamplesPerChannel );
 
1064
Int        Set_DSP_OSS_Params         ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
 
1065
Int        Set_DSP_Sun_Params         ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
 
1066
Int        Set_ESD_Params             ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
 
1067
Int        Set_WIN_Params             ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
 
1068
Int        Set_IRIX_Params            ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
 
1069
size_t     Write_PCM_16bit            ( FILE_T outputFile, const Int16_t* data, size_t len );
 
1070
size_t     Write_PCM_HQ_16bit         ( FILE_T outputFile, const Int32_t* data, size_t len );
 
1071
size_t     Write_PCM_HQ_24bit         ( FILE_T outputFile, const Int32_t* data, size_t len );
 
1072
size_t     Write_PCM_HQ_32bit         ( FILE_T outputFile, const Int32_t* data, size_t len );
 
1073
int        WIN_Play_Samples           ( const void* buff, size_t len );
 
1074
int        IRIX_Play_Samples          ( const void* buff, size_t len );
 
1075
int        WIN_Audio_close            ( void );
 
1076
int        IRIX_Audio_close           ( void );
 
1077
 
 
1078
// priority.c
 
1079
void       DisableSUID                ( void );
 
1080
void       EnableSUID                 ( void );
 
1081
int        SetPriority                ( unsigned int prio );
 
1082
 
 
1083
// pipeopen.c
 
1084
FILE*      pipeopen                   ( const char* command, const char* filename );
 
1085
 
 
1086
// stderr.c
 
1087
void       SetStderrSilent            ( Bool_t state );
 
1088
Bool_t     GetStderrSilent            ( void );
 
1089
int Cdecl  stderr_printf              ( const char* format, ... );
 
1090
 
 
1091
// _setargv.c
 
1092
long       treewalk                   ( const char* start, const char** mask, int (*fn)(const char* filename, void* aux), void* aux );
 
1093
void       mysetargv                  ( int* argc, char*** argv, const char** extentions );
 
1094
 
 
1095
 
 
1096
#if ENDIAN == HAVE_BIG_ENDIAN
 
1097
 
 
1098
# define swab32(dst,psrc)       dst = *(uint32_t*)(psrc)
 
1099
 
 
1100
#else
 
1101
 
 
1102
# if defined __i386__           /* 486+ */
 
1103
 
 
1104
#  define swab32(dst,psrc)      __asm__ ( "bswap %0" : "=r" (dst) : "0" (*(uint32_t*)(psrc)) )
 
1105
 
 
1106
# else
 
1107
 
 
1108
#  define swab32(dst,psrc)                            \
 
1109
       ((uint8_t*)&(dst))[0] = ((uint8_t*)(psrc))[3], \
 
1110
       ((uint8_t*)&(dst))[1] = ((uint8_t*)(psrc))[2], \
 
1111
       ((uint8_t*)&(dst))[2] = ((uint8_t*)(psrc))[1], \
 
1112
       ((uint8_t*)&(dst))[3] = ((uint8_t*)(psrc))[0]
 
1113
 
 
1114
# endif
 
1115
 
 
1116
#endif
 
1117
 
 
1118
 
 
1119
#endif /* MPPDEC_MPPDEC_H */
 
1120
 
 
1121
/* end of mppdec.h */