annotate src/shnplug/shorten.h @ 2815:cc6f02424609

added initial support for xiph streaming directory; small bug fixes & code cleanups
author Calin Crisan ccrisan@gmail.com
date Sun, 13 Jul 2008 04:00:04 +0300
parents fa9f85cebade
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1305
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
1 /******************************************************************************
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
2 * *
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
3 * Copyright (C) 1992-1995 Tony Robinson *
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
4 * *
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
5 * See the file doc/LICENSE.shorten for conditions on distribution and usage *
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
6 * *
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
7 ******************************************************************************/
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
8
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
9 /*
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
10 * $Id: shorten.h,v 1.4 2001/12/30 05:12:04 jason Exp $
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
11 */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
12
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
13 #ifndef _SHORTEN_H
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
14 #define _SHORTEN_H
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
15
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
16 #include "config.h"
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
17
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
18 #include <stdlib.h>
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
19 #include <pthread.h>
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
20
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
21 #ifdef HAVE_INTTYPES_H
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
22 # include <inttypes.h>
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
23 #else
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
24 # if SIZEOF_UNSIGNED_LONG == 4
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
25 # define uint32_t unsigned long
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
26 # define int32_t long
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
27 # else
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
28 # define uint32_t unsigned int
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
29 # define int32_t int
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
30 # endif
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
31 # define uint16_t unsigned short
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
32 # define uint8_t unsigned char
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
33 # define int16_t short
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
34 # define int8_t char
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
35 #endif
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
36
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
37 #undef ulong
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
38 #undef ushort
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
39 #undef uchar
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
40 #undef slong
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
41 #undef sshort
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
42 #undef schar
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
43 #define ulong uint32_t
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
44 #define ushort uint16_t
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
45 #define uchar uint8_t
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
46 #define slong int32_t
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
47 #define sshort int16_t
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
48 #define schar int8_t
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
49
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
50 #include "shn.h"
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
51
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
52 extern shn_file *shnfile;
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
53
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
54 #define MAGIC "ajkg"
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
55 #define FORMAT_VERSION 2
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
56 #define MIN_SUPPORTED_VERSION 1
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
57 #define MAX_SUPPORTED_VERSION 3
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
58 #define MAX_VERSION 7
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
59
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
60 #define UNDEFINED_UINT -1
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
61 #define DEFAULT_BLOCK_SIZE 256
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
62 #define DEFAULT_V0NMEAN 0
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
63 #define DEFAULT_V2NMEAN 4
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
64 #define DEFAULT_MAXNLPC 0
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
65 #define DEFAULT_NCHAN 1
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
66 #define DEFAULT_NSKIP 0
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
67 #define DEFAULT_NDISCARD 0
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
68 #define NBITPERLONG 32
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
69 #define DEFAULT_MINSNR 256
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
70 #define DEFAULT_MAXRESNSTR "32.0"
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
71 #define DEFAULT_QUANTERROR 0
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
72 #define MINBITRATE 2.5
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
73
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
74 #define MAX_LPC_ORDER 64
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
75 #define CHANSIZE 0
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
76 #define ENERGYSIZE 3
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
77 #define BITSHIFTSIZE 2
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
78 #define NWRAP 3
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
79
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
80 #define FNSIZE 2
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
81 #define FN_DIFF0 0
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
82 #define FN_DIFF1 1
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
83 #define FN_DIFF2 2
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
84 #define FN_DIFF3 3
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
85 #define FN_QUIT 4
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
86 #define FN_BLOCKSIZE 5
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
87 #define FN_BITSHIFT 6
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
88 #define FN_QLPC 7
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
89 #define FN_ZERO 8
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
90 #define FN_VERBATIM 9
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
91
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
92 #define VERBATIM_CKSIZE_SIZE 5 /* a var_put code size */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
93 #define VERBATIM_BYTE_SIZE 8 /* code size 8 on single bytes means
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
94 * no compression at all */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
95 #define VERBATIM_CHUNK_MAX 256 /* max. size of a FN_VERBATIM chunk */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
96
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
97 #define ULONGSIZE 2
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
98 #define NSKIPSIZE 1
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
99 #define LPCQSIZE 2
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
100 #define LPCQUANT 5
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
101 #define XBYTESIZE 7
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
102
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
103 #define TYPESIZE 4
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
104 #define TYPE_AU1 0 /* original lossless ulaw */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
105 #define TYPE_S8 1 /* signed 8 bit characters */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
106 #define TYPE_U8 2 /* unsigned 8 bit characters */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
107 #define TYPE_S16HL 3 /* signed 16 bit shorts: high-low */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
108 #define TYPE_U16HL 4 /* unsigned 16 bit shorts: high-low */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
109 #define TYPE_S16LH 5 /* signed 16 bit shorts: low-high */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
110 #define TYPE_U16LH 6 /* unsigned 16 bit shorts: low-high */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
111 #define TYPE_ULAW 7 /* lossy ulaw: internal conversion to linear */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
112 #define TYPE_AU2 8 /* new ulaw with zero mapping */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
113 #define TYPE_AU3 9 /* lossless alaw */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
114 #define TYPE_ALAW 10 /* lossy alaw: internal conversion to linear */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
115 #define TYPE_RIFF_WAVE 11 /* Microsoft .WAV files */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
116 #define TYPE_EOF 12
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
117 #define TYPE_GENERIC_ULAW 128
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
118 #define TYPE_GENERIC_ALAW 129
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
119
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
120 #define POSITIVE_ULAW_ZERO 0xff
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
121 #define NEGATIVE_ULAW_ZERO 0x7f
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
122
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
123 #ifndef MAX_PATH
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
124 #define MAX_PATH 2048
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
125 #endif
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
126
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
127 #ifndef MIN
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
128 #define MIN(a,b) (((a)<(b))?(a):(b))
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
129 #endif
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
130
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
131 #ifndef MAX
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
132 #define MAX(a,b) (((a)>(b))?(a):(b))
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
133 #endif
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
134
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
135 #if defined(unix) && !defined(linux)
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
136 #define labs abs
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
137 #endif
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
138
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
139 #define ROUNDEDSHIFTDOWN(x, n) (((n) == 0) ? (x) : ((x) >> ((n) - 1)) >> 1)
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
140
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
141 #ifndef M_LN2
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
142 #define M_LN2 0.69314718055994530942
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
143 #endif
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
144
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
145 #ifndef M_PI
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
146 #define M_PI 3.14159265358979323846
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
147 #endif
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
148
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
149 /* BUFSIZ must be a multiple of four to contain a whole number of words */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
150 #ifdef BUFSIZ
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
151 #undef BUFSIZ
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
152 #endif
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
153
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
154 #define BUFSIZ 512
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
155
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
156 #define V2LPCQOFFSET (1 << LPCQUANT);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
157
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
158 #define UINT_GET(nbit, shnfile) \
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
159 ((version == 0) ? uvar_get(nbit, shnfile) : ulong_get(shnfile))
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
160
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
161 #define putc_exit(val, stream)\
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
162 { char rval;\
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
163 if((rval = putc((val), (stream))) != (char) (val))\
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
164 complain("FATALERROR: write failed: putc returns EOF");\
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
165 }
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
166
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
167 extern int getc_exit_val;
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
168 #define getc_exit(stream)\
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
169 (((getc_exit_val = aud_vfs_getc(stream)) == EOF) ? \
1305
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
170 complain("FATALERROR: read failed: getc returns EOF"), 0: getc_exit_val)
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
171
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
172 /************************/
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
173 /* defined in shorten.c */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
174 extern void init_offset(slong**, int, int, int);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
175 extern int shorten(FILE*, FILE*, int, char**);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
176
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
177 /**************************/
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
178 /* defined in Sulawalaw.c */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
179 extern int Sulaw2lineartab[];
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
180 #define Sulaw2linear(i) (Sulaw2lineartab[i])
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
181 #ifndef Sulaw2linear
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
182 extern int Sulaw2linear(uchar);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
183 #endif
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
184 extern uchar Slinear2ulaw(int);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
185
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
186 extern int Salaw2lineartab[];
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
187 #define Salaw2linear(i) (Salaw2lineartab[i])
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
188 #ifndef Salaw2linear
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
189 extern int Salaw2linear(uchar);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
190 #endif
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
191 extern uchar Slinear2alaw(int);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
192
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
193 /**********************/
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
194 /* defined in fixio.c */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
195 extern void init_sizeof_sample(void);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
196 extern void fwrite_type_init(shn_file*);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
197 extern void fwrite_type(slong**,int,int,int,shn_file*);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
198 extern void fwrite_type_quit(shn_file*);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
199 extern void fix_bitshift(slong*, int, int, int);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
200
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
201 /**********************/
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
202 /* defined in vario.c */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
203 extern void var_get_init(shn_file*);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
204 extern slong uvar_get(int, shn_file*);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
205 extern slong var_get(int, shn_file*);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
206 extern ulong ulong_get(shn_file*);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
207 extern void var_get_quit(shn_file*);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
208
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
209 extern int sizeof_uvar(ulong, int);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
210 extern int sizeof_var(slong, int);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
211
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
212 extern void mkmasktab(void);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
213 extern ulong word_get(shn_file*);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
214
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
215 /**********************/
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
216 /* defined in array.c */
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
217 extern void* pmalloc(ulong, shn_file*);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
218 extern slong** long2d(ulong, ulong, shn_file*);
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
219
51bf0e431e02 Add SHNplug.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
220 #endif