u-Law to Signed linear conversion
More...
Go to the source code of this file.
|
#define | BIAS 0x84 |
|
#define | CLIP 32635 |
|
|
void | ast_ulaw_init (void) |
| Set up mu-law conversion table. More...
|
|
static unsigned char | linear2ulaw (short sample) |
|
u-Law to Signed linear conversion
- Author
- Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
Definition in file ulaw.c.
define the add-in bias for 16 bit samples
Definition at line 44 of file ulaw.c.
void ast_ulaw_init |
( |
void |
| ) |
|
Set up mu-law conversion table.
To init the ulaw to slinear conversion stuff, this needs to be run.
Definition at line 173 of file ulaw.c.
References __ast_lin2mu, and __ast_mulaw.
180 #ifndef G711_NEW_ALGORITHM
181 for (i = 0;i < 256;i++) {
183 static const short etab[]={0,132,396,924,1980,4092,8316,16764};
188 y = f * (1 << (e + 3));
190 if (mu & 0x80) y = -y;
194 for (i = -32768; i < 32768; i++) {
195 __ast_lin2mu[((
unsigned short)i) >> 2] = linear2ulaw(i);
199 for (i = 0; i < 256; i++) {
203 for (i = 0; i <= 32768; i += AST_ULAW_STEP) {
204 AST_LIN2MU_LOOKUP(i) = linear2ulaw(i, 0 );
208 #ifdef TEST_CODING_TABLES
209 for (i = -32768; i < 32768; ++i) {
210 #ifndef G711_NEW_ALGORITHM
211 unsigned char e1 = linear2ulaw(i);
213 unsigned char e1 = linear2ulaw(i, 1);
215 short d1 = ulaw2linear(e1);
216 unsigned char e2 = AST_LIN2MU(i);
217 short d2 = ulaw2linear(e2);
218 short d3 = AST_MULAW(e1);
220 if (e1 != e2 || d1 != d3 || d2 != d3) {
221 ast_log(LOG_WARNING,
"u-Law coding tables test failed on %d: e1=%u, e2=%u, d1=%d, d2=%d\n",
222 i, (
unsigned)e1, (
unsigned)e2, (
int)d1, (
int)d2);
225 ast_log(LOG_NOTICE,
"u-Law coding table test complete.\n");
228 #ifdef TEST_TANDEM_TRANSCODING
230 for (i = -32768; i < 32768; ++i) {
231 unsigned char e1 = AST_LIN2MU(i);
232 short d1 = AST_MULAW(e1);
233 unsigned char e2 = AST_LIN2MU(d1);
234 short d2 = AST_MULAW(e2);
235 unsigned char e3 = AST_LIN2MU(d2);
236 short d3 = AST_MULAW(e3);
238 if (i < 0 && e1 == 0x7f && e2 == 0xff && e3 == 0xff)
241 if (e1 != e2 || e2 != e3 || d1 != d2 || d2 != d3) {
242 ast_log(LOG_WARNING,
"u-Law tandem transcoding test failed on %d: e1=%u, e2=%u, d1=%d, d2=%d, d3=%d\n",
243 i, (
unsigned)e1, (
unsigned)e2, (
int)d1, (
int)d2, (
int)d3);
246 ast_log(LOG_NOTICE,
"u-Law tandem transcoding test complete.\n");
unsigned char __ast_lin2mu[16384]
converts signed linear to mulaw