Mercurial > libavcodec.hg
comparison alac.c @ 6627:33a41b13fbfe libavcodec
indent
author | michael |
---|---|
date | Thu, 17 Apr 2008 03:22:35 +0000 |
parents | a2f1a461dac6 |
children | 4aa644a88500 |
comparison
equal
deleted
inserted
replaced
6626:a2f1a461dac6 | 6627:33a41b13fbfe |
---|---|
152 | 152 |
153 if (x > 8) { /* RICE THRESHOLD */ | 153 if (x > 8) { /* RICE THRESHOLD */ |
154 /* use alternative encoding */ | 154 /* use alternative encoding */ |
155 x = get_bits(gb, readsamplesize); | 155 x = get_bits(gb, readsamplesize); |
156 } else { | 156 } else { |
157 if (k >= limit) | 157 if (k >= limit) |
158 k = limit; | 158 k = limit; |
159 | 159 |
160 if (k != 1) { | 160 if (k != 1) { |
161 int extrabits = show_bits(gb, k); | 161 int extrabits = show_bits(gb, k); |
162 | 162 |
163 /* multiply x by 2^k - 1, as part of their strange algorithm */ | 163 /* multiply x by 2^k - 1, as part of their strange algorithm */ |
164 x = (x << k) - x; | 164 x = (x << k) - x; |
165 | 165 |
166 if (extrabits > 1) { | 166 if (extrabits > 1) { |
167 x += extrabits - 1; | 167 x += extrabits - 1; |
168 skip_bits(gb, k); | 168 skip_bits(gb, k); |
169 } else | 169 } else |
170 skip_bits(gb, k - 1); | 170 skip_bits(gb, k - 1); |
171 } | 171 } |
172 } | 172 } |
173 return x; | 173 return x; |
174 } | 174 } |
175 | 175 |
176 static void bastardized_rice_decompress(ALACContext *alac, | 176 static void bastardized_rice_decompress(ALACContext *alac, |
190 for (output_count = 0; output_count < output_size; output_count++) { | 190 for (output_count = 0; output_count < output_size; output_count++) { |
191 int32_t x; | 191 int32_t x; |
192 int32_t x_modified; | 192 int32_t x_modified; |
193 int32_t final_val; | 193 int32_t final_val; |
194 | 194 |
195 /* standard rice encoding */ | 195 /* standard rice encoding */ |
196 int k; /* size of extra bits */ | 196 int k; /* size of extra bits */ |
197 | 197 |
198 /* read k, that is bits as is */ | 198 /* read k, that is bits as is */ |
199 k = 31 - count_leading_zeros((history >> 9) + 3); | 199 k = 31 - count_leading_zeros((history >> 9) + 3); |
200 x= decode_scalar(&alac->gb, k, rice_kmodifier, readsamplesize); | 200 x= decode_scalar(&alac->gb, k, rice_kmodifier, readsamplesize); |
201 | 201 |
202 x_modified = sign_modifier + x; | 202 x_modified = sign_modifier + x; |
203 final_val = (x_modified + 1) / 2; | 203 final_val = (x_modified + 1) / 2; |
204 if (x_modified & 1) final_val *= -1; | 204 if (x_modified & 1) final_val *= -1; |
205 | 205 |
218 if ((history < 128) && (output_count+1 < output_size)) { | 218 if ((history < 128) && (output_count+1 < output_size)) { |
219 int block_size, k; | 219 int block_size, k; |
220 | 220 |
221 sign_modifier = 1; | 221 sign_modifier = 1; |
222 | 222 |
223 k = count_leading_zeros(history) + ((history + 16) >> 6 /* / 64 */) - 24; | 223 k = count_leading_zeros(history) + ((history + 16) >> 6 /* / 64 */) - 24; |
224 | 224 |
225 block_size= decode_scalar(&alac->gb, k, rice_kmodifier, 16); | 225 block_size= decode_scalar(&alac->gb, k, rice_kmodifier, 16); |
226 | 226 |
227 if (block_size > 0) { | 227 if (block_size > 0) { |
228 memset(&output_buffer[output_count+1], 0, block_size * 4); | 228 memset(&output_buffer[output_count+1], 0, block_size * 4); |
229 output_count += block_size; | 229 output_count += block_size; |
230 } | 230 } |