summaryrefslogtreecommitdiff
path: root/apps/codecs/libfaad
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libfaad')
-rw-r--r--apps/codecs/libfaad/common.c53
-rw-r--r--apps/codecs/libfaad/common.h4
-rw-r--r--apps/codecs/libfaad/sbr_hfgen.c8
3 files changed, 2 insertions, 63 deletions
diff --git a/apps/codecs/libfaad/common.c b/apps/codecs/libfaad/common.c
index debc125b3e..e8340d318d 100644
--- a/apps/codecs/libfaad/common.c
+++ b/apps/codecs/libfaad/common.c
@@ -241,58 +241,7 @@ uint32_t random_int(void)
241 return (__r1 = (t3 >> 1) | t1 ) ^ (__r2 = (t4 + t4) | t2 ); 241 return (__r1 = (t3 >> 1) | t1 ) ^ (__r2 = (t4 + t4) | t2 );
242} 242}
243 243
244uint32_t ones32(uint32_t x) 244#define floor_log2(x) bs_generic(x, BS_LOG2)
245{
246 x -= ((x >> 1) & 0x55555555);
247 x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
248 x = (((x >> 4) + x) & 0x0f0f0f0f);
249 x += (x >> 8);
250 x += (x >> 16);
251
252 return (x & 0x0000003f);
253}
254
255uint32_t floor_log2(uint32_t x)
256{
257#if 1
258 x |= (x >> 1);
259 x |= (x >> 2);
260 x |= (x >> 4);
261 x |= (x >> 8);
262 x |= (x >> 16);
263
264 return (ones32(x) - 1);
265#else
266 uint32_t count = 0;
267
268 while (x >>= 1)
269 count++;
270
271 return count;
272#endif
273}
274
275/* returns position of first bit that is not 0 from msb,
276 * starting count at lsb */
277uint32_t wl_min_lzc(uint32_t x)
278{
279#if 1
280 x |= (x >> 1);
281 x |= (x >> 2);
282 x |= (x >> 4);
283 x |= (x >> 8);
284 x |= (x >> 16);
285
286 return (ones32(x));
287#else
288 uint32_t count = 0;
289
290 while (x >>= 1)
291 count++;
292
293 return (count + 1);
294#endif
295}
296 245
297#ifdef FIXED_POINT 246#ifdef FIXED_POINT
298 247
diff --git a/apps/codecs/libfaad/common.h b/apps/codecs/libfaad/common.h
index ea028b1b8e..fe0d02b228 100644
--- a/apps/codecs/libfaad/common.h
+++ b/apps/codecs/libfaad/common.h
@@ -399,9 +399,7 @@ typedef real_t complex_t[2];
399/* common functions */ 399/* common functions */
400uint8_t cpu_has_sse(void); 400uint8_t cpu_has_sse(void);
401uint32_t random_int(void); 401uint32_t random_int(void);
402uint32_t ones32(uint32_t x); 402#define wl_min_lzc(x) bs_generic(x, BS_LOG2|BS_0_0)
403uint32_t floor_log2(uint32_t x);
404uint32_t wl_min_lzc(uint32_t x);
405#ifdef FIXED_POINT 403#ifdef FIXED_POINT
406#define LOG2_MIN_INF REAL_CONST(-10000) 404#define LOG2_MIN_INF REAL_CONST(-10000)
407int32_t log2_int(uint32_t val); 405int32_t log2_int(uint32_t val);
diff --git a/apps/codecs/libfaad/sbr_hfgen.c b/apps/codecs/libfaad/sbr_hfgen.c
index 4991839218..f77bbd052f 100644
--- a/apps/codecs/libfaad/sbr_hfgen.c
+++ b/apps/codecs/libfaad/sbr_hfgen.c
@@ -222,10 +222,6 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
222 222
223 exp = wl_min_lzc(mask); 223 exp = wl_min_lzc(mask);
224 224
225 /* improves accuracy */
226 if (exp > 0)
227 exp -= 1;
228
229 for (j = offset; j < len + offset; j++) 225 for (j = offset; j < len + offset; j++)
230 { 226 {
231 real_t buf_j = ((QMF_RE(buffer[j][bd])+(1<<(exp-1)))>>exp); 227 real_t buf_j = ((QMF_RE(buffer[j][bd])+(1<<(exp-1)))>>exp);
@@ -292,10 +288,6 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
292 } 288 }
293 289
294 exp = wl_min_lzc(mask); 290 exp = wl_min_lzc(mask);
295
296 /* improves accuracy */
297 if (exp > 0)
298 exp -= 1;
299 291
300 pow2_to_exp = 1<<(exp-1); 292 pow2_to_exp = 1<<(exp-1);
301 293