#include "asterisk.h"
#include "asterisk/alaw.h"
Include dependency graph for alaw.c:

Go to the source code of this file.
Defines | |
| #define | AMI_MASK 0x55 |
Functions | |
| static short int | alaw2linear (unsigned char alaw) |
| void | ast_alaw_init (void) |
| static unsigned char | linear2alaw (short int linear) |
Variables | |
| short | __ast_alaw [256] |
| unsigned char | __ast_lin2a [8192] |
Definition in file alaw.c.
|
|
Definition at line 31 of file alaw.c. Referenced by alaw2linear(), and linear2alaw(). |
|
|
Definition at line 67 of file alaw.c. References AMI_MASK. Referenced by ast_alaw_init(). 00068 {
00069 int i;
00070 int seg;
00071
00072 alaw ^= AMI_MASK;
00073 i = ((alaw & 0x0F) << 4);
00074 seg = (((int) alaw & 0x70) >> 4);
00075 if (seg)
00076 i = (i + 0x100) << (seg - 1);
00077 return (short int) ((alaw & 0x80) ? i : -i);
00078 }
|
|
|
To init the ulaw to slinear conversion stuff, this needs to be run. Definition at line 83 of file alaw.c. References __ast_alaw, __ast_lin2a, alaw2linear(), and linear2alaw(). Referenced by main(). 00084 {
00085 int i;
00086 /*
00087 * Set up mu-law conversion table
00088 */
00089 for(i = 0;i < 256;i++)
00090 {
00091 __ast_alaw[i] = alaw2linear(i);
00092 }
00093 /* set up the reverse (mu-law) conversion table */
00094 for(i = -32768; i < 32768; i++)
00095 {
00096 __ast_lin2a[((unsigned short)i) >> 3] = linear2alaw(i);
00097 }
00098
00099 }
|
|
|
Definition at line 33 of file alaw.c. References AMI_MASK. Referenced by ast_alaw_init(). 00034 {
00035 int mask;
00036 int seg;
00037 int pcm_val;
00038 static int seg_end[8] =
00039 {
00040 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF
00041 };
00042
00043 pcm_val = linear;
00044 if (pcm_val >= 0)
00045 {
00046 /* Sign (7th) bit = 1 */
00047 mask = AMI_MASK | 0x80;
00048 }
00049 else
00050 {
00051 /* Sign bit = 0 */
00052 mask = AMI_MASK;
00053 pcm_val = -pcm_val;
00054 }
00055
00056 /* Convert the scaled magnitude to segment number. */
00057 for (seg = 0; seg < 8; seg++)
00058 {
00059 if (pcm_val <= seg_end[seg])
00060 break;
00061 }
00062 /* Combine the sign, segment, and quantization bits. */
00063 return ((seg << 4) | ((pcm_val >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask;
00064 }
|
|
|
help Definition at line 81 of file alaw.c. Referenced by ast_alaw_init(). |
|
|
Definition at line 80 of file alaw.c. Referenced by ast_alaw_init(). |
1.4.2