annotate libaf/af_format_alaw.c @ 9373:e1e2177841ef

dvds have covers too - Andreas Hess <jaska@gmx.net>
author alex
date Sun, 09 Feb 2003 19:01:00 +0000
parents e8832e66babd
children 14090f7300a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8167
e8832e66babd New features:
anders
parents:
diff changeset
1 /*=============================================================================
e8832e66babd New features:
anders
parents:
diff changeset
2 //
e8832e66babd New features:
anders
parents:
diff changeset
3 // This software has been released under the terms of the GNU Public
e8832e66babd New features:
anders
parents:
diff changeset
4 // license. See http://www.gnu.org/copyleft/gpl.html for details.
e8832e66babd New features:
anders
parents:
diff changeset
5 //
e8832e66babd New features:
anders
parents:
diff changeset
6 // Copyright 2002 Anders Johansson ajh@watri.uwa.edu.au
e8832e66babd New features:
anders
parents:
diff changeset
7 //
e8832e66babd New features:
anders
parents:
diff changeset
8 // This file is based on a part of libsndfile, the work of
e8832e66babd New features:
anders
parents:
diff changeset
9 // Erik de Castro Lopo <erikd@zip.com.au>
e8832e66babd New features:
anders
parents:
diff changeset
10 //
e8832e66babd New features:
anders
parents:
diff changeset
11 //=============================================================================
e8832e66babd New features:
anders
parents:
diff changeset
12 */
e8832e66babd New features:
anders
parents:
diff changeset
13
e8832e66babd New features:
anders
parents:
diff changeset
14 #ifndef __af_format_alaw_c
e8832e66babd New features:
anders
parents:
diff changeset
15 #define __af_format_alaw_c
e8832e66babd New features:
anders
parents:
diff changeset
16
e8832e66babd New features:
anders
parents:
diff changeset
17 #include <unistd.h>
e8832e66babd New features:
anders
parents:
diff changeset
18 #include <inttypes.h>
e8832e66babd New features:
anders
parents:
diff changeset
19
e8832e66babd New features:
anders
parents:
diff changeset
20 #include "af.h"
e8832e66babd New features:
anders
parents:
diff changeset
21
e8832e66babd New features:
anders
parents:
diff changeset
22 // Conversion tables (the function are below)
e8832e66babd New features:
anders
parents:
diff changeset
23 static short alaw_decode [128] =
e8832e66babd New features:
anders
parents:
diff changeset
24 { -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
e8832e66babd New features:
anders
parents:
diff changeset
25 -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
e8832e66babd New features:
anders
parents:
diff changeset
26 -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
e8832e66babd New features:
anders
parents:
diff changeset
27 -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
e8832e66babd New features:
anders
parents:
diff changeset
28 -22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944,
e8832e66babd New features:
anders
parents:
diff changeset
29 -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136,
e8832e66babd New features:
anders
parents:
diff changeset
30 -11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472,
e8832e66babd New features:
anders
parents:
diff changeset
31 -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568,
e8832e66babd New features:
anders
parents:
diff changeset
32 -344, -328, -376, -360, -280, -264, -312, -296,
e8832e66babd New features:
anders
parents:
diff changeset
33 -472, -456, -504, -488, -408, -392, -440, -424,
e8832e66babd New features:
anders
parents:
diff changeset
34 -88, -72, -120, -104, -24, -8, -56, -40,
e8832e66babd New features:
anders
parents:
diff changeset
35 -216, -200, -248, -232, -152, -136, -184, -168,
e8832e66babd New features:
anders
parents:
diff changeset
36 -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
e8832e66babd New features:
anders
parents:
diff changeset
37 -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
e8832e66babd New features:
anders
parents:
diff changeset
38 -688, -656, -752, -720, -560, -528, -624, -592,
e8832e66babd New features:
anders
parents:
diff changeset
39 -944, -912, -1008, -976, -816, -784, -880, -848
e8832e66babd New features:
anders
parents:
diff changeset
40 } ; /* alaw_decode */
e8832e66babd New features:
anders
parents:
diff changeset
41
e8832e66babd New features:
anders
parents:
diff changeset
42 static unsigned char alaw_encode [2049] =
e8832e66babd New features:
anders
parents:
diff changeset
43 { 0xD5, 0xD4, 0xD7, 0xD6, 0xD1, 0xD0, 0xD3, 0xD2, 0xDD, 0xDC, 0xDF, 0xDE,
e8832e66babd New features:
anders
parents:
diff changeset
44 0xD9, 0xD8, 0xDB, 0xDA, 0xC5, 0xC4, 0xC7, 0xC6, 0xC1, 0xC0, 0xC3, 0xC2,
e8832e66babd New features:
anders
parents:
diff changeset
45 0xCD, 0xCC, 0xCF, 0xCE, 0xC9, 0xC8, 0xCB, 0xCA, 0xF5, 0xF5, 0xF4, 0xF4,
e8832e66babd New features:
anders
parents:
diff changeset
46 0xF7, 0xF7, 0xF6, 0xF6, 0xF1, 0xF1, 0xF0, 0xF0, 0xF3, 0xF3, 0xF2, 0xF2,
e8832e66babd New features:
anders
parents:
diff changeset
47 0xFD, 0xFD, 0xFC, 0xFC, 0xFF, 0xFF, 0xFE, 0xFE, 0xF9, 0xF9, 0xF8, 0xF8,
e8832e66babd New features:
anders
parents:
diff changeset
48 0xFB, 0xFB, 0xFA, 0xFA, 0xE5, 0xE5, 0xE5, 0xE5, 0xE4, 0xE4, 0xE4, 0xE4,
e8832e66babd New features:
anders
parents:
diff changeset
49 0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE1, 0xE1, 0xE1, 0xE1,
e8832e66babd New features:
anders
parents:
diff changeset
50 0xE0, 0xE0, 0xE0, 0xE0, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2,
e8832e66babd New features:
anders
parents:
diff changeset
51 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEF, 0xEF, 0xEF, 0xEF,
e8832e66babd New features:
anders
parents:
diff changeset
52 0xEE, 0xEE, 0xEE, 0xEE, 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8,
e8832e66babd New features:
anders
parents:
diff changeset
53 0xEB, 0xEB, 0xEB, 0xEB, 0xEA, 0xEA, 0xEA, 0xEA, 0x95, 0x95, 0x95, 0x95,
e8832e66babd New features:
anders
parents:
diff changeset
54 0x95, 0x95, 0x95, 0x95, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94,
e8832e66babd New features:
anders
parents:
diff changeset
55 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x96, 0x96, 0x96, 0x96,
e8832e66babd New features:
anders
parents:
diff changeset
56 0x96, 0x96, 0x96, 0x96, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91,
e8832e66babd New features:
anders
parents:
diff changeset
57 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x93, 0x93, 0x93, 0x93,
e8832e66babd New features:
anders
parents:
diff changeset
58 0x93, 0x93, 0x93, 0x93, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92,
e8832e66babd New features:
anders
parents:
diff changeset
59 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9C, 0x9C, 0x9C, 0x9C,
e8832e66babd New features:
anders
parents:
diff changeset
60 0x9C, 0x9C, 0x9C, 0x9C, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F,
e8832e66babd New features:
anders
parents:
diff changeset
61 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x99, 0x99, 0x99, 0x99,
e8832e66babd New features:
anders
parents:
diff changeset
62 0x99, 0x99, 0x99, 0x99, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98,
e8832e66babd New features:
anders
parents:
diff changeset
63 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9A, 0x9A, 0x9A, 0x9A,
e8832e66babd New features:
anders
parents:
diff changeset
64 0x9A, 0x9A, 0x9A, 0x9A, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85,
e8832e66babd New features:
anders
parents:
diff changeset
65 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x84, 0x84, 0x84, 0x84,
e8832e66babd New features:
anders
parents:
diff changeset
66 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84,
e8832e66babd New features:
anders
parents:
diff changeset
67 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87,
e8832e66babd New features:
anders
parents:
diff changeset
68 0x87, 0x87, 0x87, 0x87, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86,
e8832e66babd New features:
anders
parents:
diff changeset
69 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x81, 0x81, 0x81, 0x81,
e8832e66babd New features:
anders
parents:
diff changeset
70 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
e8832e66babd New features:
anders
parents:
diff changeset
71 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
e8832e66babd New features:
anders
parents:
diff changeset
72 0x80, 0x80, 0x80, 0x80, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83,
e8832e66babd New features:
anders
parents:
diff changeset
73 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x82, 0x82, 0x82, 0x82,
e8832e66babd New features:
anders
parents:
diff changeset
74 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82,
e8832e66babd New features:
anders
parents:
diff changeset
75 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D,
e8832e66babd New features:
anders
parents:
diff changeset
76 0x8D, 0x8D, 0x8D, 0x8D, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C,
e8832e66babd New features:
anders
parents:
diff changeset
77 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8F, 0x8F, 0x8F, 0x8F,
e8832e66babd New features:
anders
parents:
diff changeset
78 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F,
e8832e66babd New features:
anders
parents:
diff changeset
79 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E,
e8832e66babd New features:
anders
parents:
diff changeset
80 0x8E, 0x8E, 0x8E, 0x8E, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
e8832e66babd New features:
anders
parents:
diff changeset
81 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x88, 0x88, 0x88, 0x88,
e8832e66babd New features:
anders
parents:
diff changeset
82 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
e8832e66babd New features:
anders
parents:
diff changeset
83 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B,
e8832e66babd New features:
anders
parents:
diff changeset
84 0x8B, 0x8B, 0x8B, 0x8B, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A,
e8832e66babd New features:
anders
parents:
diff changeset
85 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0xB5, 0xB5, 0xB5, 0xB5,
e8832e66babd New features:
anders
parents:
diff changeset
86 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5,
e8832e66babd New features:
anders
parents:
diff changeset
87 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5,
e8832e66babd New features:
anders
parents:
diff changeset
88 0xB5, 0xB5, 0xB5, 0xB5, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4,
e8832e66babd New features:
anders
parents:
diff changeset
89 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4,
e8832e66babd New features:
anders
parents:
diff changeset
90 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4,
e8832e66babd New features:
anders
parents:
diff changeset
91 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7,
e8832e66babd New features:
anders
parents:
diff changeset
92 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7,
e8832e66babd New features:
anders
parents:
diff changeset
93 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB6, 0xB6, 0xB6, 0xB6,
e8832e66babd New features:
anders
parents:
diff changeset
94 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6,
e8832e66babd New features:
anders
parents:
diff changeset
95 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6,
e8832e66babd New features:
anders
parents:
diff changeset
96 0xB6, 0xB6, 0xB6, 0xB6, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1,
e8832e66babd New features:
anders
parents:
diff changeset
97 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1,
e8832e66babd New features:
anders
parents:
diff changeset
98 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1,
e8832e66babd New features:
anders
parents:
diff changeset
99 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0,
e8832e66babd New features:
anders
parents:
diff changeset
100 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0,
e8832e66babd New features:
anders
parents:
diff changeset
101 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB3, 0xB3, 0xB3, 0xB3,
e8832e66babd New features:
anders
parents:
diff changeset
102 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3,
e8832e66babd New features:
anders
parents:
diff changeset
103 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3,
e8832e66babd New features:
anders
parents:
diff changeset
104 0xB3, 0xB3, 0xB3, 0xB3, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2,
e8832e66babd New features:
anders
parents:
diff changeset
105 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2,
e8832e66babd New features:
anders
parents:
diff changeset
106 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2,
e8832e66babd New features:
anders
parents:
diff changeset
107 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD,
e8832e66babd New features:
anders
parents:
diff changeset
108 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD,
e8832e66babd New features:
anders
parents:
diff changeset
109 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBC, 0xBC, 0xBC, 0xBC,
e8832e66babd New features:
anders
parents:
diff changeset
110 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC,
e8832e66babd New features:
anders
parents:
diff changeset
111 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC,
e8832e66babd New features:
anders
parents:
diff changeset
112 0xBC, 0xBC, 0xBC, 0xBC, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF,
e8832e66babd New features:
anders
parents:
diff changeset
113 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF,
e8832e66babd New features:
anders
parents:
diff changeset
114 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF,
e8832e66babd New features:
anders
parents:
diff changeset
115 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE,
e8832e66babd New features:
anders
parents:
diff changeset
116 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE,
e8832e66babd New features:
anders
parents:
diff changeset
117 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xB9, 0xB9, 0xB9, 0xB9,
e8832e66babd New features:
anders
parents:
diff changeset
118 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9,
e8832e66babd New features:
anders
parents:
diff changeset
119 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9,
e8832e66babd New features:
anders
parents:
diff changeset
120 0xB9, 0xB9, 0xB9, 0xB9, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8,
e8832e66babd New features:
anders
parents:
diff changeset
121 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8,
e8832e66babd New features:
anders
parents:
diff changeset
122 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8,
e8832e66babd New features:
anders
parents:
diff changeset
123 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB,
e8832e66babd New features:
anders
parents:
diff changeset
124 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB,
e8832e66babd New features:
anders
parents:
diff changeset
125 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBA, 0xBA, 0xBA, 0xBA,
e8832e66babd New features:
anders
parents:
diff changeset
126 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA,
e8832e66babd New features:
anders
parents:
diff changeset
127 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA,
e8832e66babd New features:
anders
parents:
diff changeset
128 0xBA, 0xBA, 0xBA, 0xBA, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5,
e8832e66babd New features:
anders
parents:
diff changeset
129 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5,
e8832e66babd New features:
anders
parents:
diff changeset
130 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5,
e8832e66babd New features:
anders
parents:
diff changeset
131 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5,
e8832e66babd New features:
anders
parents:
diff changeset
132 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5,
e8832e66babd New features:
anders
parents:
diff changeset
133 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA4, 0xA4, 0xA4, 0xA4,
e8832e66babd New features:
anders
parents:
diff changeset
134 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4,
e8832e66babd New features:
anders
parents:
diff changeset
135 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4,
e8832e66babd New features:
anders
parents:
diff changeset
136 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4,
e8832e66babd New features:
anders
parents:
diff changeset
137 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4,
e8832e66babd New features:
anders
parents:
diff changeset
138 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4,
e8832e66babd New features:
anders
parents:
diff changeset
139 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7,
e8832e66babd New features:
anders
parents:
diff changeset
140 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7,
e8832e66babd New features:
anders
parents:
diff changeset
141 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7,
e8832e66babd New features:
anders
parents:
diff changeset
142 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7,
e8832e66babd New features:
anders
parents:
diff changeset
143 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7,
e8832e66babd New features:
anders
parents:
diff changeset
144 0xA7, 0xA7, 0xA7, 0xA7, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
e8832e66babd New features:
anders
parents:
diff changeset
145 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
e8832e66babd New features:
anders
parents:
diff changeset
146 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
e8832e66babd New features:
anders
parents:
diff changeset
147 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
e8832e66babd New features:
anders
parents:
diff changeset
148 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
e8832e66babd New features:
anders
parents:
diff changeset
149 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA1, 0xA1, 0xA1, 0xA1,
e8832e66babd New features:
anders
parents:
diff changeset
150 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1,
e8832e66babd New features:
anders
parents:
diff changeset
151 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1,
e8832e66babd New features:
anders
parents:
diff changeset
152 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1,
e8832e66babd New features:
anders
parents:
diff changeset
153 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1,
e8832e66babd New features:
anders
parents:
diff changeset
154 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1,
e8832e66babd New features:
anders
parents:
diff changeset
155 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,
e8832e66babd New features:
anders
parents:
diff changeset
156 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,
e8832e66babd New features:
anders
parents:
diff changeset
157 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,
e8832e66babd New features:
anders
parents:
diff changeset
158 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,
e8832e66babd New features:
anders
parents:
diff changeset
159 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,
e8832e66babd New features:
anders
parents:
diff changeset
160 0xA0, 0xA0, 0xA0, 0xA0, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
e8832e66babd New features:
anders
parents:
diff changeset
161 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
e8832e66babd New features:
anders
parents:
diff changeset
162 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
e8832e66babd New features:
anders
parents:
diff changeset
163 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
e8832e66babd New features:
anders
parents:
diff changeset
164 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
e8832e66babd New features:
anders
parents:
diff changeset
165 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA2, 0xA2, 0xA2, 0xA2,
e8832e66babd New features:
anders
parents:
diff changeset
166 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2,
e8832e66babd New features:
anders
parents:
diff changeset
167 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2,
e8832e66babd New features:
anders
parents:
diff changeset
168 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2,
e8832e66babd New features:
anders
parents:
diff changeset
169 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2,
e8832e66babd New features:
anders
parents:
diff changeset
170 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2,
e8832e66babd New features:
anders
parents:
diff changeset
171 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD,
e8832e66babd New features:
anders
parents:
diff changeset
172 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD,
e8832e66babd New features:
anders
parents:
diff changeset
173 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD,
e8832e66babd New features:
anders
parents:
diff changeset
174 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD,
e8832e66babd New features:
anders
parents:
diff changeset
175 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD,
e8832e66babd New features:
anders
parents:
diff changeset
176 0xAD, 0xAD, 0xAD, 0xAD, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC,
e8832e66babd New features:
anders
parents:
diff changeset
177 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC,
e8832e66babd New features:
anders
parents:
diff changeset
178 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC,
e8832e66babd New features:
anders
parents:
diff changeset
179 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC,
e8832e66babd New features:
anders
parents:
diff changeset
180 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC,
e8832e66babd New features:
anders
parents:
diff changeset
181 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAF, 0xAF, 0xAF, 0xAF,
e8832e66babd New features:
anders
parents:
diff changeset
182 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF,
e8832e66babd New features:
anders
parents:
diff changeset
183 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF,
e8832e66babd New features:
anders
parents:
diff changeset
184 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF,
e8832e66babd New features:
anders
parents:
diff changeset
185 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF,
e8832e66babd New features:
anders
parents:
diff changeset
186 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF,
e8832e66babd New features:
anders
parents:
diff changeset
187 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE,
e8832e66babd New features:
anders
parents:
diff changeset
188 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE,
e8832e66babd New features:
anders
parents:
diff changeset
189 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE,
e8832e66babd New features:
anders
parents:
diff changeset
190 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE,
e8832e66babd New features:
anders
parents:
diff changeset
191 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE,
e8832e66babd New features:
anders
parents:
diff changeset
192 0xAE, 0xAE, 0xAE, 0xAE, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9,
e8832e66babd New features:
anders
parents:
diff changeset
193 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9,
e8832e66babd New features:
anders
parents:
diff changeset
194 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9,
e8832e66babd New features:
anders
parents:
diff changeset
195 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9,
e8832e66babd New features:
anders
parents:
diff changeset
196 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9,
e8832e66babd New features:
anders
parents:
diff changeset
197 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA8, 0xA8, 0xA8, 0xA8,
e8832e66babd New features:
anders
parents:
diff changeset
198 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8,
e8832e66babd New features:
anders
parents:
diff changeset
199 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8,
e8832e66babd New features:
anders
parents:
diff changeset
200 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8,
e8832e66babd New features:
anders
parents:
diff changeset
201 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8,
e8832e66babd New features:
anders
parents:
diff changeset
202 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8,
e8832e66babd New features:
anders
parents:
diff changeset
203 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
e8832e66babd New features:
anders
parents:
diff changeset
204 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
e8832e66babd New features:
anders
parents:
diff changeset
205 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
e8832e66babd New features:
anders
parents:
diff changeset
206 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
e8832e66babd New features:
anders
parents:
diff changeset
207 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
e8832e66babd New features:
anders
parents:
diff changeset
208 0xAB, 0xAB, 0xAB, 0xAB, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
e8832e66babd New features:
anders
parents:
diff changeset
209 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
e8832e66babd New features:
anders
parents:
diff changeset
210 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
e8832e66babd New features:
anders
parents:
diff changeset
211 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
e8832e66babd New features:
anders
parents:
diff changeset
212 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
e8832e66babd New features:
anders
parents:
diff changeset
213 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x2A
e8832e66babd New features:
anders
parents:
diff changeset
214 } ; /* alaw_encode */
e8832e66babd New features:
anders
parents:
diff changeset
215
e8832e66babd New features:
anders
parents:
diff changeset
216 /* Convert from alaw to signd int8 to signed int32 or float */
e8832e66babd New features:
anders
parents:
diff changeset
217 static int from_alaw(void* in, void* out, int len, int bps, int format)
e8832e66babd New features:
anders
parents:
diff changeset
218 {
e8832e66babd New features:
anders
parents:
diff changeset
219 register int i;
e8832e66babd New features:
anders
parents:
diff changeset
220 // Make sure the input parametrs are OK
e8832e66babd New features:
anders
parents:
diff changeset
221 if(format & (AF_FORMAT_SPECIAL_MASK | AF_FORMAT_US))
e8832e66babd New features:
anders
parents:
diff changeset
222 return AF_ERROR;
e8832e66babd New features:
anders
parents:
diff changeset
223
e8832e66babd New features:
anders
parents:
diff changeset
224 // Convert to int or to float
e8832e66babd New features:
anders
parents:
diff changeset
225 if((format & AF_FORMAT_POINT_MASK) == AF_FORMAT_I){
e8832e66babd New features:
anders
parents:
diff changeset
226 switch(bps){
e8832e66babd New features:
anders
parents:
diff changeset
227 case(1):
e8832e66babd New features:
anders
parents:
diff changeset
228 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
229 if(((int8_t*)in)[i] & 0x80)
e8832e66babd New features:
anders
parents:
diff changeset
230 ((int8_t*)out)[i] = (-1 * alaw_decode[(((int8_t*)in)[i]) & 0x7F]) >> 8;
e8832e66babd New features:
anders
parents:
diff changeset
231 else
e8832e66babd New features:
anders
parents:
diff changeset
232 ((int8_t*)out)[i] = (alaw_decode[(((int8_t*)in)[i]) & 0x7F]) >> 8;
e8832e66babd New features:
anders
parents:
diff changeset
233 }
e8832e66babd New features:
anders
parents:
diff changeset
234 break;
e8832e66babd New features:
anders
parents:
diff changeset
235 case(2):
e8832e66babd New features:
anders
parents:
diff changeset
236 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
237 if(((int8_t*)in)[i] & 0x80)
e8832e66babd New features:
anders
parents:
diff changeset
238 ((int16_t*)out)[i] = -1 * alaw_decode[(((int8_t*)in)[i]) & 0x7F];
e8832e66babd New features:
anders
parents:
diff changeset
239 else
e8832e66babd New features:
anders
parents:
diff changeset
240 ((int16_t*)out)[i] = alaw_decode[(((int8_t*)in)[i]) & 0x7F];
e8832e66babd New features:
anders
parents:
diff changeset
241 }
e8832e66babd New features:
anders
parents:
diff changeset
242 break;
e8832e66babd New features:
anders
parents:
diff changeset
243 case(4):
e8832e66babd New features:
anders
parents:
diff changeset
244 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
245 if(((int8_t*)in)[i] & 0x80)
e8832e66babd New features:
anders
parents:
diff changeset
246 ((int32_t*)out)[i] = (-1 * alaw_decode[(((int8_t*)in)[i]) & 0x7F]) << 16;
e8832e66babd New features:
anders
parents:
diff changeset
247 else
e8832e66babd New features:
anders
parents:
diff changeset
248 ((int32_t*)out)[i] = (alaw_decode[(((int8_t*)in)[i]) & 0x7F]) << 16;
e8832e66babd New features:
anders
parents:
diff changeset
249 }
e8832e66babd New features:
anders
parents:
diff changeset
250 break;
e8832e66babd New features:
anders
parents:
diff changeset
251 default:
e8832e66babd New features:
anders
parents:
diff changeset
252 return AF_ERROR;
e8832e66babd New features:
anders
parents:
diff changeset
253 }
e8832e66babd New features:
anders
parents:
diff changeset
254 }
e8832e66babd New features:
anders
parents:
diff changeset
255 else{
e8832e66babd New features:
anders
parents:
diff changeset
256 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
257 if(((int8_t*)in)[i] & 0x80)
e8832e66babd New features:
anders
parents:
diff changeset
258 ((float*)out)[i] = -1.0/32768.0 * (float)alaw_decode[(((int8_t*)in)[i]) & 0x7F];
e8832e66babd New features:
anders
parents:
diff changeset
259 else
e8832e66babd New features:
anders
parents:
diff changeset
260 ((float*)out)[i] = +1.0/32768.0 * (float)alaw_decode[(((int8_t*)in)[i]) & 0x7F];
e8832e66babd New features:
anders
parents:
diff changeset
261 }
e8832e66babd New features:
anders
parents:
diff changeset
262 }
e8832e66babd New features:
anders
parents:
diff changeset
263 return AF_OK;
e8832e66babd New features:
anders
parents:
diff changeset
264 }
e8832e66babd New features:
anders
parents:
diff changeset
265
e8832e66babd New features:
anders
parents:
diff changeset
266 /* Convert from singed int8 to singned int32 or float to alaw */
e8832e66babd New features:
anders
parents:
diff changeset
267 static int to_alaw(void* in, void* out, int len, int bps, int format)
e8832e66babd New features:
anders
parents:
diff changeset
268 {
e8832e66babd New features:
anders
parents:
diff changeset
269 register int i;
e8832e66babd New features:
anders
parents:
diff changeset
270 // Make sure the input parametrs are OK
e8832e66babd New features:
anders
parents:
diff changeset
271 if(format & (AF_FORMAT_SPECIAL_MASK | AF_FORMAT_US))
e8832e66babd New features:
anders
parents:
diff changeset
272 return AF_ERROR;
e8832e66babd New features:
anders
parents:
diff changeset
273
e8832e66babd New features:
anders
parents:
diff changeset
274 // Convert from int or to float
e8832e66babd New features:
anders
parents:
diff changeset
275 if((format & AF_FORMAT_POINT_MASK) == AF_FORMAT_I){
e8832e66babd New features:
anders
parents:
diff changeset
276 switch(bps){
e8832e66babd New features:
anders
parents:
diff changeset
277 case(1):
e8832e66babd New features:
anders
parents:
diff changeset
278 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
279 if(((int8_t*)in)[i] >= 0)
e8832e66babd New features:
anders
parents:
diff changeset
280 ((int8_t*)out)[i] = alaw_encode[((int8_t*)in)[i] << 4];
e8832e66babd New features:
anders
parents:
diff changeset
281 else
e8832e66babd New features:
anders
parents:
diff changeset
282 ((int8_t*)out)[i] = 0x7F & alaw_encode[-((int8_t*)in)[i] << 4];
e8832e66babd New features:
anders
parents:
diff changeset
283 }
e8832e66babd New features:
anders
parents:
diff changeset
284 break;
e8832e66babd New features:
anders
parents:
diff changeset
285 case(2):
e8832e66babd New features:
anders
parents:
diff changeset
286 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
287 if(((int16_t*)in)[i] >= 0)
e8832e66babd New features:
anders
parents:
diff changeset
288 ((int8_t*)out)[i] = alaw_encode[((int16_t*)in)[i] / 16];
e8832e66babd New features:
anders
parents:
diff changeset
289 else
e8832e66babd New features:
anders
parents:
diff changeset
290 ((int8_t*)out)[i] = 0x7F & alaw_encode[((int16_t*)in)[i] / -16];
e8832e66babd New features:
anders
parents:
diff changeset
291 }
e8832e66babd New features:
anders
parents:
diff changeset
292 break;
e8832e66babd New features:
anders
parents:
diff changeset
293 case(4):
e8832e66babd New features:
anders
parents:
diff changeset
294 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
295 if(((int32_t*)in)[i] >= 0)
e8832e66babd New features:
anders
parents:
diff changeset
296 ((int8_t*)out)[i] = alaw_encode[((int32_t*)in)[i] >> (16 + 4)];
e8832e66babd New features:
anders
parents:
diff changeset
297 else
e8832e66babd New features:
anders
parents:
diff changeset
298 ((int8_t*)out)[i] = 0x7F & alaw_encode[-((int32_t*)in)[i] >> (16 + 4)];
e8832e66babd New features:
anders
parents:
diff changeset
299 }
e8832e66babd New features:
anders
parents:
diff changeset
300 break;
e8832e66babd New features:
anders
parents:
diff changeset
301 default:
e8832e66babd New features:
anders
parents:
diff changeset
302 return AF_ERROR;
e8832e66babd New features:
anders
parents:
diff changeset
303 }
e8832e66babd New features:
anders
parents:
diff changeset
304 }
e8832e66babd New features:
anders
parents:
diff changeset
305 else{
e8832e66babd New features:
anders
parents:
diff changeset
306 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
307 if(((float*)in)[i] >= 0)
e8832e66babd New features:
anders
parents:
diff changeset
308 ((int8_t*)out)[i] = alaw_encode[(int)(32767.0/16.0 * ((float*)in)[i])];
e8832e66babd New features:
anders
parents:
diff changeset
309 else
e8832e66babd New features:
anders
parents:
diff changeset
310 ((int8_t*)out)[i] = 0x7F & alaw_encode[(int)(-32767.0/16.0 * ((float*)in)[i])];
e8832e66babd New features:
anders
parents:
diff changeset
311 }
e8832e66babd New features:
anders
parents:
diff changeset
312 }
e8832e66babd New features:
anders
parents:
diff changeset
313 return AF_OK;
e8832e66babd New features:
anders
parents:
diff changeset
314 }
e8832e66babd New features:
anders
parents:
diff changeset
315 #endif /* __af_format_alaw_c */