diff options
| author | Nils Wallménius <nils@rockbox.org> | 2009-12-06 02:03:03 +0000 |
|---|---|---|
| committer | Nils Wallménius <nils@rockbox.org> | 2009-12-06 02:03:03 +0000 |
| commit | cd22b32450757b5c204bca9add59b177c27cf4e7 (patch) | |
| tree | 8f7d2b9734ecaa146ec0043b8b44aa61f3cb5b83 /apps/codecs/lib | |
| parent | 491e0978ece89bf0a5831f313b67c8670af2dcb3 (diff) | |
| download | rockbox-cd22b32450757b5c204bca9add59b177c27cf4e7.zip rockbox-cd22b32450757b5c204bca9add59b177c27cf4e7.tar.gz rockbox-cd22b32450757b5c204bca9add59b177c27cf4e7.tar.bz2 rockbox-cd22b32450757b5c204bca9add59b177c27cf4e7.tar.xz | |
slightly faster asm av_log2 for armv6 (currently only Gigabeat S)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23868 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/lib')
| -rw-r--r-- | apps/codecs/lib/codeclib.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/apps/codecs/lib/codeclib.h b/apps/codecs/lib/codeclib.h index f4fe0a9..4f30b30 100644 --- a/apps/codecs/lib/codeclib.h +++ b/apps/codecs/lib/codeclib.h @@ -76,12 +76,24 @@ unsigned udiv32_arm(unsigned a, unsigned b); /* TODO figure out if we really need to care about calculating av_log2(0) */ -#if (defined(CPU_ARM) && (ARM_ARCH > 4)) +#ifdef CPU_ARM +#if ARM_ARCH > 5 +static inline unsigned int av_log2(uint32_t v) +{ + unsigned int r; + asm volatile("clz %[r], %[v]\n\t" /* count leading zeroes */ + "rsb %[r], %[r], #31\n\t" /* r = 31 - leading zeroes */ + "usat %[r], #5, %[r]\n\t" /* unsigned saturate r so -1 -> 0 */ + :[r] "=r" (r) : [v] "r" (v)); + return(r); +} +#elif ARM_ARCH > 4 static inline unsigned int av_log2(uint32_t v) { return v ? 31 - __builtin_clz(v) : 0; } -#else +#endif +#else /* CPU_ARM */ /* From libavutil/common.h */ extern const uint8_t ff_log2_tab[256] ICONST_ATTR; |