summaryrefslogtreecommitdiff
path: root/main/alaw.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2008-03-04 23:04:29 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2008-03-04 23:04:29 +0000
commitcfc1df4c1a5605bf57191dee4d137122cbafded7 (patch)
tree36a818ef47a50925ad9a7269bc290cb079783e52 /main/alaw.c
parent96e04792bdb8aa2235f6a8b5b1a3e4204b78eacf (diff)
Whitespace changes only
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@105840 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/alaw.c')
-rw-r--r--main/alaw.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/main/alaw.c b/main/alaw.c
index 8d3595206..367de0b77 100644
--- a/main/alaw.c
+++ b/main/alaw.c
@@ -34,31 +34,32 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static inline unsigned char linear2alaw(short int linear)
{
- int mask;
- int seg;
- int pcm_val;
- static int seg_end[8] =
+ int mask;
+ int seg;
+ int pcm_val;
+ static int seg_end[8] =
{
0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF
};
-
- pcm_val = linear;
- if (pcm_val >= 0) {
- /* Sign (7th) bit = 1 */
- mask = AMI_MASK | 0x80;
- } else {
- /* Sign bit = 0 */
- mask = AMI_MASK;
- pcm_val = -pcm_val;
- }
-
- /* Convert the scaled magnitude to segment number. */
- for (seg = 0; seg < 8; seg++) {
- if (pcm_val <= seg_end[seg])
- break;
- }
- /* Combine the sign, segment, and quantization bits. */
- return ((seg << 4) | ((pcm_val >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask;
+
+ pcm_val = linear;
+ if (pcm_val >= 0) {
+ /* Sign (7th) bit = 1 */
+ mask = AMI_MASK | 0x80;
+ } else {
+ /* Sign bit = 0 */
+ mask = AMI_MASK;
+ pcm_val = -pcm_val;
+ }
+
+ /* Convert the scaled magnitude to segment number. */
+ for (seg = 0; seg < 8; seg++) {
+ if (pcm_val <= seg_end[seg]) {
+ break;
+ }
+ }
+ /* Combine the sign, segment, and quantization bits. */
+ return ((seg << 4) | ((pcm_val >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask;
}
#else
static unsigned char linear2alaw(short sample, int full_coding)
@@ -107,15 +108,16 @@ static unsigned char linear2alaw(short sample, int full_coding)
#ifndef G711_NEW_ALGORITHM
static inline short int alaw2linear (unsigned char alaw)
{
- int i;
- int seg;
-
- alaw ^= AMI_MASK;
- i = ((alaw & 0x0F) << 4) + 8 /* rounding error */;
- seg = (((int) alaw & 0x70) >> 4);
- if (seg)
- i = (i + 0x100) << (seg - 1);
- return (short int) ((alaw & 0x80) ? i : -i);
+ int i;
+ int seg;
+
+ alaw ^= AMI_MASK;
+ i = ((alaw & 0x0F) << 4) + 8 /* rounding error */;
+ seg = (((int) alaw & 0x70) >> 4);
+ if (seg) {
+ i = (i + 0x100) << (seg - 1);
+ }
+ return (short int) ((alaw & 0x80) ? i : -i);
}
#else
static inline short alaw2linear(unsigned char alawbyte)