annotate libaf/af_format_alaw.c @ 25063:29260745e4fa

Pass all available formats to chain building routine and establish connection with first of available formats. This will make further format negotiation patch slightly simpler. To avoid pins connection error due to unsuported format at top of the list, put requested video format to the top of list. This will also useful with upcoming patch - negotiation will be started from requested format.
author voroshil
date Sun, 18 Nov 2007 10:51:22 +0000
parents 85f669a84e7a
children b0e5772d519e
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 //
13602
14090f7300a8 The full name of the GPL is GNU General Public License.
diego
parents: 8167
diff changeset
3 // This software has been released under the terms of the GNU General Public
8167
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 <inttypes.h>
e8832e66babd New features:
anders
parents:
diff changeset
18
e8832e66babd New features:
anders
parents:
diff changeset
19 #include "af.h"
e8832e66babd New features:
anders
parents:
diff changeset
20
e8832e66babd New features:
anders
parents:
diff changeset
21 // Conversion tables (the function are below)
e8832e66babd New features:
anders
parents:
diff changeset
22 static short alaw_decode [128] =
e8832e66babd New features:
anders
parents:
diff changeset
23 { -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
e8832e66babd New features:
anders
parents:
diff changeset
24 -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
e8832e66babd New features:
anders
parents:
diff changeset
25 -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
e8832e66babd New features:
anders
parents:
diff changeset
26 -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
e8832e66babd New features:
anders
parents:
diff changeset
27 -22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944,
e8832e66babd New features:
anders
parents:
diff changeset
28 -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136,
e8832e66babd New features:
anders
parents:
diff changeset
29 -11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472,
e8832e66babd New features:
anders
parents:
diff changeset
30 -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568,
e8832e66babd New features:
anders
parents:
diff changeset
31 -344, -328, -376, -360, -280, -264, -312, -296,
e8832e66babd New features:
anders
parents:
diff changeset
32 -472, -456, -504, -488, -408, -392, -440, -424,
e8832e66babd New features:
anders
parents:
diff changeset
33 -88, -72, -120, -104, -24, -8, -56, -40,
e8832e66babd New features:
anders
parents:
diff changeset
34 -216, -200, -248, -232, -152, -136, -184, -168,
e8832e66babd New features:
anders
parents:
diff changeset
35 -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
e8832e66babd New features:
anders
parents:
diff changeset
36 -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
e8832e66babd New features:
anders
parents:
diff changeset
37 -688, -656, -752, -720, -560, -528, -624, -592,
e8832e66babd New features:
anders
parents:
diff changeset
38 -944, -912, -1008, -976, -816, -784, -880, -848
e8832e66babd New features:
anders
parents:
diff changeset
39 } ; /* alaw_decode */
e8832e66babd New features:
anders
parents:
diff changeset
40
e8832e66babd New features:
anders
parents:
diff changeset
41 static unsigned char alaw_encode [2049] =
e8832e66babd New features:
anders
parents:
diff changeset
42 { 0xD5, 0xD4, 0xD7, 0xD6, 0xD1, 0xD0, 0xD3, 0xD2, 0xDD, 0xDC, 0xDF, 0xDE,
e8832e66babd New features:
anders
parents:
diff changeset
43 0xD9, 0xD8, 0xDB, 0xDA, 0xC5, 0xC4, 0xC7, 0xC6, 0xC1, 0xC0, 0xC3, 0xC2,
e8832e66babd New features:
anders
parents:
diff changeset
44 0xCD, 0xCC, 0xCF, 0xCE, 0xC9, 0xC8, 0xCB, 0xCA, 0xF5, 0xF5, 0xF4, 0xF4,
e8832e66babd New features:
anders
parents:
diff changeset
45 0xF7, 0xF7, 0xF6, 0xF6, 0xF1, 0xF1, 0xF0, 0xF0, 0xF3, 0xF3, 0xF2, 0xF2,
e8832e66babd New features:
anders
parents:
diff changeset
46 0xFD, 0xFD, 0xFC, 0xFC, 0xFF, 0xFF, 0xFE, 0xFE, 0xF9, 0xF9, 0xF8, 0xF8,
e8832e66babd New features:
anders
parents:
diff changeset
47 0xFB, 0xFB, 0xFA, 0xFA, 0xE5, 0xE5, 0xE5, 0xE5, 0xE4, 0xE4, 0xE4, 0xE4,
e8832e66babd New features:
anders
parents:
diff changeset
48 0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE1, 0xE1, 0xE1, 0xE1,
e8832e66babd New features:
anders
parents:
diff changeset
49 0xE0, 0xE0, 0xE0, 0xE0, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2,
e8832e66babd New features:
anders
parents:
diff changeset
50 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEF, 0xEF, 0xEF, 0xEF,
e8832e66babd New features:
anders
parents:
diff changeset
51 0xEE, 0xEE, 0xEE, 0xEE, 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8,
e8832e66babd New features:
anders
parents:
diff changeset
52 0xEB, 0xEB, 0xEB, 0xEB, 0xEA, 0xEA, 0xEA, 0xEA, 0x95, 0x95, 0x95, 0x95,
e8832e66babd New features:
anders
parents:
diff changeset
53 0x95, 0x95, 0x95, 0x95, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94,
e8832e66babd New features:
anders
parents:
diff changeset
54 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x96, 0x96, 0x96, 0x96,
e8832e66babd New features:
anders
parents:
diff changeset
55 0x96, 0x96, 0x96, 0x96, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91,
e8832e66babd New features:
anders
parents:
diff changeset
56 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x93, 0x93, 0x93, 0x93,
e8832e66babd New features:
anders
parents:
diff changeset
57 0x93, 0x93, 0x93, 0x93, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92,
e8832e66babd New features:
anders
parents:
diff changeset
58 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9C, 0x9C, 0x9C, 0x9C,
e8832e66babd New features:
anders
parents:
diff changeset
59 0x9C, 0x9C, 0x9C, 0x9C, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F,
e8832e66babd New features:
anders
parents:
diff changeset
60 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x99, 0x99, 0x99, 0x99,
e8832e66babd New features:
anders
parents:
diff changeset
61 0x99, 0x99, 0x99, 0x99, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98,
e8832e66babd New features:
anders
parents:
diff changeset
62 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9A, 0x9A, 0x9A, 0x9A,
e8832e66babd New features:
anders
parents:
diff changeset
63 0x9A, 0x9A, 0x9A, 0x9A, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85,
e8832e66babd New features:
anders
parents:
diff changeset
64 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x84, 0x84, 0x84, 0x84,
e8832e66babd New features:
anders
parents:
diff changeset
65 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84,
e8832e66babd New features:
anders
parents:
diff changeset
66 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87,
e8832e66babd New features:
anders
parents:
diff changeset
67 0x87, 0x87, 0x87, 0x87, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86,
e8832e66babd New features:
anders
parents:
diff changeset
68 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x81, 0x81, 0x81, 0x81,
e8832e66babd New features:
anders
parents:
diff changeset
69 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
e8832e66babd New features:
anders
parents:
diff changeset
70 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
e8832e66babd New features:
anders
parents:
diff changeset
71 0x80, 0x80, 0x80, 0x80, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83,
e8832e66babd New features:
anders
parents:
diff changeset
72 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x82, 0x82, 0x82, 0x82,
e8832e66babd New features:
anders
parents:
diff changeset
73 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82,
e8832e66babd New features:
anders
parents:
diff changeset
74 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D,
e8832e66babd New features:
anders
parents:
diff changeset
75 0x8D, 0x8D, 0x8D, 0x8D, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C,
e8832e66babd New features:
anders
parents:
diff changeset
76 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8F, 0x8F, 0x8F, 0x8F,
e8832e66babd New features:
anders
parents:
diff changeset
77 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F,
e8832e66babd New features:
anders
parents:
diff changeset
78 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E,
e8832e66babd New features:
anders
parents:
diff changeset
79 0x8E, 0x8E, 0x8E, 0x8E, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
e8832e66babd New features:
anders
parents:
diff changeset
80 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x88, 0x88, 0x88, 0x88,
e8832e66babd New features:
anders
parents:
diff changeset
81 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
e8832e66babd New features:
anders
parents:
diff changeset
82 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B,
e8832e66babd New features:
anders
parents:
diff changeset
83 0x8B, 0x8B, 0x8B, 0x8B, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A,
e8832e66babd New features:
anders
parents:
diff changeset
84 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0xB5, 0xB5, 0xB5, 0xB5,
e8832e66babd New features:
anders
parents:
diff changeset
85 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 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, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4,
e8832e66babd New features:
anders
parents:
diff changeset
88 0xB4, 0xB4, 0xB4, 0xB4, 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 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7,
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, 0xB6, 0xB6, 0xB6, 0xB6,
e8832e66babd New features:
anders
parents:
diff changeset
93 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 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, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1,
e8832e66babd New features:
anders
parents:
diff changeset
96 0xB1, 0xB1, 0xB1, 0xB1, 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 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0,
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, 0xB3, 0xB3, 0xB3, 0xB3,
e8832e66babd New features:
anders
parents:
diff changeset
101 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 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, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2,
e8832e66babd New features:
anders
parents:
diff changeset
104 0xB2, 0xB2, 0xB2, 0xB2, 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 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD,
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, 0xBC, 0xBC, 0xBC, 0xBC,
e8832e66babd New features:
anders
parents:
diff changeset
109 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 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, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF,
e8832e66babd New features:
anders
parents:
diff changeset
112 0xBF, 0xBF, 0xBF, 0xBF, 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 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE,
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, 0xB9, 0xB9, 0xB9, 0xB9,
e8832e66babd New features:
anders
parents:
diff changeset
117 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 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, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8,
e8832e66babd New features:
anders
parents:
diff changeset
120 0xB8, 0xB8, 0xB8, 0xB8, 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 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB,
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, 0xBA, 0xBA, 0xBA, 0xBA,
e8832e66babd New features:
anders
parents:
diff changeset
125 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 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, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5,
e8832e66babd New features:
anders
parents:
diff changeset
128 0xA5, 0xA5, 0xA5, 0xA5, 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, 0xA4, 0xA4, 0xA4, 0xA4,
e8832e66babd New features:
anders
parents:
diff changeset
133 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 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 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7,
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, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
e8832e66babd New features:
anders
parents:
diff changeset
144 0xA6, 0xA6, 0xA6, 0xA6, 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, 0xA1, 0xA1, 0xA1, 0xA1,
e8832e66babd New features:
anders
parents:
diff changeset
149 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 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 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,
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, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
e8832e66babd New features:
anders
parents:
diff changeset
160 0xA3, 0xA3, 0xA3, 0xA3, 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, 0xA2, 0xA2, 0xA2, 0xA2,
e8832e66babd New features:
anders
parents:
diff changeset
165 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 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 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD,
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, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC,
e8832e66babd New features:
anders
parents:
diff changeset
176 0xAC, 0xAC, 0xAC, 0xAC, 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, 0xAF, 0xAF, 0xAF, 0xAF,
e8832e66babd New features:
anders
parents:
diff changeset
181 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 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 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE,
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, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9,
e8832e66babd New features:
anders
parents:
diff changeset
192 0xA9, 0xA9, 0xA9, 0xA9, 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, 0xA8, 0xA8, 0xA8, 0xA8,
e8832e66babd New features:
anders
parents:
diff changeset
197 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 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 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
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, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
e8832e66babd New features:
anders
parents:
diff changeset
208 0xAA, 0xAA, 0xAA, 0xAA, 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, 0x2A
e8832e66babd New features:
anders
parents:
diff changeset
213 } ; /* alaw_encode */
e8832e66babd New features:
anders
parents:
diff changeset
214
e8832e66babd New features:
anders
parents:
diff changeset
215 /* Convert from alaw to signd int8 to signed int32 or float */
e8832e66babd New features:
anders
parents:
diff changeset
216 static int from_alaw(void* in, void* out, int len, int bps, int format)
e8832e66babd New features:
anders
parents:
diff changeset
217 {
e8832e66babd New features:
anders
parents:
diff changeset
218 register int i;
e8832e66babd New features:
anders
parents:
diff changeset
219 // Make sure the input parametrs are OK
e8832e66babd New features:
anders
parents:
diff changeset
220 if(format & (AF_FORMAT_SPECIAL_MASK | AF_FORMAT_US))
e8832e66babd New features:
anders
parents:
diff changeset
221 return AF_ERROR;
e8832e66babd New features:
anders
parents:
diff changeset
222
e8832e66babd New features:
anders
parents:
diff changeset
223 // Convert to int or to float
e8832e66babd New features:
anders
parents:
diff changeset
224 if((format & AF_FORMAT_POINT_MASK) == AF_FORMAT_I){
e8832e66babd New features:
anders
parents:
diff changeset
225 switch(bps){
e8832e66babd New features:
anders
parents:
diff changeset
226 case(1):
e8832e66babd New features:
anders
parents:
diff changeset
227 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
228 if(((int8_t*)in)[i] & 0x80)
e8832e66babd New features:
anders
parents:
diff changeset
229 ((int8_t*)out)[i] = (-1 * alaw_decode[(((int8_t*)in)[i]) & 0x7F]) >> 8;
e8832e66babd New features:
anders
parents:
diff changeset
230 else
e8832e66babd New features:
anders
parents:
diff changeset
231 ((int8_t*)out)[i] = (alaw_decode[(((int8_t*)in)[i]) & 0x7F]) >> 8;
e8832e66babd New features:
anders
parents:
diff changeset
232 }
e8832e66babd New features:
anders
parents:
diff changeset
233 break;
e8832e66babd New features:
anders
parents:
diff changeset
234 case(2):
e8832e66babd New features:
anders
parents:
diff changeset
235 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
236 if(((int8_t*)in)[i] & 0x80)
e8832e66babd New features:
anders
parents:
diff changeset
237 ((int16_t*)out)[i] = -1 * alaw_decode[(((int8_t*)in)[i]) & 0x7F];
e8832e66babd New features:
anders
parents:
diff changeset
238 else
e8832e66babd New features:
anders
parents:
diff changeset
239 ((int16_t*)out)[i] = alaw_decode[(((int8_t*)in)[i]) & 0x7F];
e8832e66babd New features:
anders
parents:
diff changeset
240 }
e8832e66babd New features:
anders
parents:
diff changeset
241 break;
e8832e66babd New features:
anders
parents:
diff changeset
242 case(4):
e8832e66babd New features:
anders
parents:
diff changeset
243 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
244 if(((int8_t*)in)[i] & 0x80)
e8832e66babd New features:
anders
parents:
diff changeset
245 ((int32_t*)out)[i] = (-1 * alaw_decode[(((int8_t*)in)[i]) & 0x7F]) << 16;
e8832e66babd New features:
anders
parents:
diff changeset
246 else
e8832e66babd New features:
anders
parents:
diff changeset
247 ((int32_t*)out)[i] = (alaw_decode[(((int8_t*)in)[i]) & 0x7F]) << 16;
e8832e66babd New features:
anders
parents:
diff changeset
248 }
e8832e66babd New features:
anders
parents:
diff changeset
249 break;
e8832e66babd New features:
anders
parents:
diff changeset
250 default:
e8832e66babd New features:
anders
parents:
diff changeset
251 return AF_ERROR;
e8832e66babd New features:
anders
parents:
diff changeset
252 }
e8832e66babd New features:
anders
parents:
diff changeset
253 }
e8832e66babd New features:
anders
parents:
diff changeset
254 else{
e8832e66babd New features:
anders
parents:
diff changeset
255 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
256 if(((int8_t*)in)[i] & 0x80)
e8832e66babd New features:
anders
parents:
diff changeset
257 ((float*)out)[i] = -1.0/32768.0 * (float)alaw_decode[(((int8_t*)in)[i]) & 0x7F];
e8832e66babd New features:
anders
parents:
diff changeset
258 else
e8832e66babd New features:
anders
parents:
diff changeset
259 ((float*)out)[i] = +1.0/32768.0 * (float)alaw_decode[(((int8_t*)in)[i]) & 0x7F];
e8832e66babd New features:
anders
parents:
diff changeset
260 }
e8832e66babd New features:
anders
parents:
diff changeset
261 }
e8832e66babd New features:
anders
parents:
diff changeset
262 return AF_OK;
e8832e66babd New features:
anders
parents:
diff changeset
263 }
e8832e66babd New features:
anders
parents:
diff changeset
264
24595
85f669a84e7a cosmetics: misc typo fixes
diego
parents: 22748
diff changeset
265 /* Convert from signed int8 to signed int32 or float to alaw */
8167
e8832e66babd New features:
anders
parents:
diff changeset
266 static int to_alaw(void* in, void* out, int len, int bps, int format)
e8832e66babd New features:
anders
parents:
diff changeset
267 {
e8832e66babd New features:
anders
parents:
diff changeset
268 register int i;
e8832e66babd New features:
anders
parents:
diff changeset
269 // Make sure the input parametrs are OK
e8832e66babd New features:
anders
parents:
diff changeset
270 if(format & (AF_FORMAT_SPECIAL_MASK | AF_FORMAT_US))
e8832e66babd New features:
anders
parents:
diff changeset
271 return AF_ERROR;
e8832e66babd New features:
anders
parents:
diff changeset
272
e8832e66babd New features:
anders
parents:
diff changeset
273 // Convert from int or to float
e8832e66babd New features:
anders
parents:
diff changeset
274 if((format & AF_FORMAT_POINT_MASK) == AF_FORMAT_I){
e8832e66babd New features:
anders
parents:
diff changeset
275 switch(bps){
e8832e66babd New features:
anders
parents:
diff changeset
276 case(1):
e8832e66babd New features:
anders
parents:
diff changeset
277 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
278 if(((int8_t*)in)[i] >= 0)
e8832e66babd New features:
anders
parents:
diff changeset
279 ((int8_t*)out)[i] = alaw_encode[((int8_t*)in)[i] << 4];
e8832e66babd New features:
anders
parents:
diff changeset
280 else
e8832e66babd New features:
anders
parents:
diff changeset
281 ((int8_t*)out)[i] = 0x7F & alaw_encode[-((int8_t*)in)[i] << 4];
e8832e66babd New features:
anders
parents:
diff changeset
282 }
e8832e66babd New features:
anders
parents:
diff changeset
283 break;
e8832e66babd New features:
anders
parents:
diff changeset
284 case(2):
e8832e66babd New features:
anders
parents:
diff changeset
285 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
286 if(((int16_t*)in)[i] >= 0)
e8832e66babd New features:
anders
parents:
diff changeset
287 ((int8_t*)out)[i] = alaw_encode[((int16_t*)in)[i] / 16];
e8832e66babd New features:
anders
parents:
diff changeset
288 else
e8832e66babd New features:
anders
parents:
diff changeset
289 ((int8_t*)out)[i] = 0x7F & alaw_encode[((int16_t*)in)[i] / -16];
e8832e66babd New features:
anders
parents:
diff changeset
290 }
e8832e66babd New features:
anders
parents:
diff changeset
291 break;
e8832e66babd New features:
anders
parents:
diff changeset
292 case(4):
e8832e66babd New features:
anders
parents:
diff changeset
293 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
294 if(((int32_t*)in)[i] >= 0)
e8832e66babd New features:
anders
parents:
diff changeset
295 ((int8_t*)out)[i] = alaw_encode[((int32_t*)in)[i] >> (16 + 4)];
e8832e66babd New features:
anders
parents:
diff changeset
296 else
e8832e66babd New features:
anders
parents:
diff changeset
297 ((int8_t*)out)[i] = 0x7F & alaw_encode[-((int32_t*)in)[i] >> (16 + 4)];
e8832e66babd New features:
anders
parents:
diff changeset
298 }
e8832e66babd New features:
anders
parents:
diff changeset
299 break;
e8832e66babd New features:
anders
parents:
diff changeset
300 default:
e8832e66babd New features:
anders
parents:
diff changeset
301 return AF_ERROR;
e8832e66babd New features:
anders
parents:
diff changeset
302 }
e8832e66babd New features:
anders
parents:
diff changeset
303 }
e8832e66babd New features:
anders
parents:
diff changeset
304 else{
e8832e66babd New features:
anders
parents:
diff changeset
305 for(i=0;i<len;i++){
e8832e66babd New features:
anders
parents:
diff changeset
306 if(((float*)in)[i] >= 0)
e8832e66babd New features:
anders
parents:
diff changeset
307 ((int8_t*)out)[i] = alaw_encode[(int)(32767.0/16.0 * ((float*)in)[i])];
e8832e66babd New features:
anders
parents:
diff changeset
308 else
e8832e66babd New features:
anders
parents:
diff changeset
309 ((int8_t*)out)[i] = 0x7F & alaw_encode[(int)(-32767.0/16.0 * ((float*)in)[i])];
e8832e66babd New features:
anders
parents:
diff changeset
310 }
e8832e66babd New features:
anders
parents:
diff changeset
311 }
e8832e66babd New features:
anders
parents:
diff changeset
312 return AF_OK;
e8832e66babd New features:
anders
parents:
diff changeset
313 }
e8832e66babd New features:
anders
parents:
diff changeset
314 #endif /* __af_format_alaw_c */