comparison alac.c @ 6632:4aa644a88500 libavcodec

Remove wrapper around av_log2()
author vitor
date Thu, 17 Apr 2008 18:50:31 +0000
parents 33a41b13fbfe
children f1674aac3a1a
comparison
equal deleted inserted replaced
6631:76a252cc9ba3 6632:4aa644a88500
138 allocate_buffers(alac); 138 allocate_buffers(alac);
139 139
140 return 0; 140 return 0;
141 } 141 }
142 142
143 static inline int count_leading_zeros(int32_t input)
144 {
145 return 31-av_log2(input);
146 }
147
148
149 static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsamplesize){ 143 static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsamplesize){
150 /* read x - number of 1s before 0 represent the rice */ 144 /* read x - number of 1s before 0 represent the rice */
151 int x = get_unary_0_9(gb); 145 int x = get_unary_0_9(gb);
152 146
153 if (x > 8) { /* RICE THRESHOLD */ 147 if (x > 8) { /* RICE THRESHOLD */
194 188
195 /* standard rice encoding */ 189 /* standard rice encoding */
196 int k; /* size of extra bits */ 190 int k; /* size of extra bits */
197 191
198 /* read k, that is bits as is */ 192 /* read k, that is bits as is */
199 k = 31 - count_leading_zeros((history >> 9) + 3); 193 k = av_log2((history >> 9) + 3);
200 x= decode_scalar(&alac->gb, k, rice_kmodifier, readsamplesize); 194 x= decode_scalar(&alac->gb, k, rice_kmodifier, readsamplesize);
201 195
202 x_modified = sign_modifier + x; 196 x_modified = sign_modifier + x;
203 final_val = (x_modified + 1) / 2; 197 final_val = (x_modified + 1) / 2;
204 if (x_modified & 1) final_val *= -1; 198 if (x_modified & 1) final_val *= -1;
218 if ((history < 128) && (output_count+1 < output_size)) { 212 if ((history < 128) && (output_count+1 < output_size)) {
219 int block_size, k; 213 int block_size, k;
220 214
221 sign_modifier = 1; 215 sign_modifier = 1;
222 216
223 k = count_leading_zeros(history) + ((history + 16) >> 6 /* / 64 */) - 24; 217 k = 7 - av_log2(history) + ((history + 16) >> 6 /* / 64 */);
224 218
225 block_size= decode_scalar(&alac->gb, k, rice_kmodifier, 16); 219 block_size= decode_scalar(&alac->gb, k, rice_kmodifier, 16);
226 220
227 if (block_size > 0) { 221 if (block_size > 0) {
228 memset(&output_buffer[output_count+1], 0, block_size * 4); 222 memset(&output_buffer[output_count+1], 0, block_size * 4);