author | llornkcor <llornkcor> | 2004-04-22 09:31:57 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-04-22 09:31:57 (UTC) |
commit | 0cfc21f93c66731a51f0982c0a6d357ab9c9a86b (patch) (unidiff) | |
tree | 5106cfa5bce47cdb29800f7921b6d0621fe52800 /core | |
parent | 731e459a8621fb359ca39ccf4d11bffcc024dcfa (diff) | |
download | opie-0cfc21f93c66731a51f0982c0a6d357ab9c9a86b.zip opie-0cfc21f93c66731a51f0982c0a6d357ab9c9a86b.tar.gz opie-0cfc21f93c66731a51f0982c0a6d357ab9c9a86b.tar.bz2 |
initialize
-rw-r--r-- | core/applets/vmemo/adpcm.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/applets/vmemo/adpcm.c b/core/applets/vmemo/adpcm.c index c4dfa50..a123249 100644 --- a/core/applets/vmemo/adpcm.c +++ b/core/applets/vmemo/adpcm.c | |||
@@ -65,50 +65,50 @@ static int stepsizeTable[89] = { | |||
65 | 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, | 65 | 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, |
66 | 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, | 66 | 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, |
67 | 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, | 67 | 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, |
68 | 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, | 68 | 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, |
69 | 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 | 69 | 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 |
70 | }; | 70 | }; |
71 | 71 | ||
72 | void | 72 | void |
73 | adpcm_coder(indata, outdata, len, state) | 73 | adpcm_coder(indata, outdata, len, state) |
74 | short indata[]; | 74 | short indata[]; |
75 | char outdata[]; | 75 | char outdata[]; |
76 | int len; | 76 | int len; |
77 | struct adpcm_state *state; | 77 | struct adpcm_state *state; |
78 | { | 78 | { |
79 | short *inp; /* Input buffer pointer */ | 79 | short *inp; /* Input buffer pointer */ |
80 | signed char *outp; /* output buffer pointer */ | 80 | signed char *outp; /* output buffer pointer */ |
81 | int val; /* Current input sample value */ | 81 | int val; /* Current input sample value */ |
82 | int sign; /* Current adpcm sign bit */ | 82 | int sign; /* Current adpcm sign bit */ |
83 | int delta; /* Current adpcm output value */ | 83 | int delta; /* Current adpcm output value */ |
84 | int diff; /* Difference between val and valprev */ | 84 | int diff; /* Difference between val and valprev */ |
85 | int step; /* Stepsize */ | 85 | int step; /* Stepsize */ |
86 | int valpred; /* Predicted output value */ | 86 | int valpred; /* Predicted output value */ |
87 | int vpdiff; /* Current change to valpred */ | 87 | int vpdiff; /* Current change to valpred */ |
88 | int index; /* Current step change index */ | 88 | int index; /* Current step change index */ |
89 | int outputbuffer; /* place to keep previous 4-bit value */ | 89 | int outputbuffer = 0; /* place to keep previous 4-bit value */ |
90 | int bufferstep; /* toggle between outputbuffer/output */ | 90 | int bufferstep = 0; /* toggle between outputbuffer/output */ |
91 | 91 | ||
92 | outp = (signed char *)outdata; | 92 | outp = (signed char *)outdata; |
93 | inp = indata; | 93 | inp = indata; |
94 | 94 | ||
95 | valpred = state->valprev; | 95 | valpred = state->valprev; |
96 | index = state->index; | 96 | index = state->index; |
97 | step = stepsizeTable[index]; | 97 | step = stepsizeTable[index]; |
98 | 98 | ||
99 | bufferstep = 1; | 99 | bufferstep = 1; |
100 | 100 | ||
101 | for ( ; len > 0 ; len-- ) { | 101 | for ( ; len > 0 ; len-- ) { |
102 | val = *inp++; | 102 | val = *inp++; |
103 | 103 | ||
104 | /* Step 1 - compute difference with previous value */ | 104 | /* Step 1 - compute difference with previous value */ |
105 | diff = val - valpred; | 105 | diff = val - valpred; |
106 | sign = (diff < 0) ? 8 : 0; | 106 | sign = (diff < 0) ? 8 : 0; |
107 | if ( sign ) diff = (-diff); | 107 | if ( sign ) diff = (-diff); |
108 | 108 | ||
109 | /* Step 2 - Divide and clamp */ | 109 | /* Step 2 - Divide and clamp */ |
110 | /* Note: | 110 | /* Note: |
111 | ** This code *approximately* computes: | 111 | ** This code *approximately* computes: |
112 | ** delta = diff*4/step; | 112 | ** delta = diff*4/step; |
113 | ** vpdiff = (delta+0.5)*step/4; | 113 | ** vpdiff = (delta+0.5)*step/4; |
114 | ** but in shift step bits are dropped. The net result of this is | 114 | ** but in shift step bits are dropped. The net result of this is |
@@ -166,50 +166,50 @@ adpcm_coder(indata, outdata, len, state) | |||
166 | 166 | ||
167 | /* Output last step, if needed */ | 167 | /* Output last step, if needed */ |
168 | if ( !bufferstep ) | 168 | if ( !bufferstep ) |
169 | *outp++ = outputbuffer; | 169 | *outp++ = outputbuffer; |
170 | 170 | ||
171 | state->valprev = valpred; | 171 | state->valprev = valpred; |
172 | state->index = index; | 172 | state->index = index; |
173 | } | 173 | } |
174 | 174 | ||
175 | void | 175 | void |
176 | adpcm_decoder(indata, outdata, len, state) | 176 | adpcm_decoder(indata, outdata, len, state) |
177 | char indata[]; | 177 | char indata[]; |
178 | short outdata[]; | 178 | short outdata[]; |
179 | int len; | 179 | int len; |
180 | struct adpcm_state *state; | 180 | struct adpcm_state *state; |
181 | { | 181 | { |
182 | signed char *inp; /* Input buffer pointer */ | 182 | signed char *inp; /* Input buffer pointer */ |
183 | short *outp; /* output buffer pointer */ | 183 | short *outp; /* output buffer pointer */ |
184 | int sign; /* Current adpcm sign bit */ | 184 | int sign; /* Current adpcm sign bit */ |
185 | int delta; /* Current adpcm output value */ | 185 | int delta; /* Current adpcm output value */ |
186 | int step; /* Stepsize */ | 186 | int step; /* Stepsize */ |
187 | int valpred; /* Predicted value */ | 187 | int valpred; /* Predicted value */ |
188 | int vpdiff; /* Current change to valpred */ | 188 | int vpdiff; /* Current change to valpred */ |
189 | int index; /* Current step change index */ | 189 | int index; /* Current step change index */ |
190 | int inputbuffer; /* place to keep next 4-bit value */ | 190 | int inputbuffer = 0; /* place to keep next 4-bit value */ |
191 | int bufferstep; /* toggle between inputbuffer/input */ | 191 | int bufferstep = 0; /* toggle between inputbuffer/input */ |
192 | 192 | ||
193 | outp = outdata; | 193 | outp = outdata; |
194 | inp = (signed char *)indata; | 194 | inp = (signed char *)indata; |
195 | 195 | ||
196 | valpred = state->valprev; | 196 | valpred = state->valprev; |
197 | index = state->index; | 197 | index = state->index; |
198 | step = stepsizeTable[index]; | 198 | step = stepsizeTable[index]; |
199 | 199 | ||
200 | bufferstep = 0; | 200 | bufferstep = 0; |
201 | 201 | ||
202 | for ( ; len > 0 ; len-- ) { | 202 | for ( ; len > 0 ; len-- ) { |
203 | 203 | ||
204 | /* Step 1 - get the delta value */ | 204 | /* Step 1 - get the delta value */ |
205 | if ( bufferstep ) { | 205 | if ( bufferstep ) { |
206 | delta = inputbuffer & 0xf; | 206 | delta = inputbuffer & 0xf; |
207 | } else { | 207 | } else { |
208 | inputbuffer = *inp++; | 208 | inputbuffer = *inp++; |
209 | delta = (inputbuffer >> 4) & 0xf; | 209 | delta = (inputbuffer >> 4) & 0xf; |
210 | } | 210 | } |
211 | bufferstep = !bufferstep; | 211 | bufferstep = !bufferstep; |
212 | 212 | ||
213 | /* Step 2 - Find new index value (for later) */ | 213 | /* Step 2 - Find new index value (for later) */ |
214 | index += indexTable[delta]; | 214 | index += indexTable[delta]; |
215 | if ( index < 0 ) index = 0; | 215 | if ( index < 0 ) index = 0; |