summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-01-27 20:39:29 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-01-27 20:39:29 +0000
commitc81f034988f173a5cc0cf75c3384652fe7fe73bd (patch)
tree33e59f093f9527a560742046f2fdbd396e3c81b5 /libavcodec
parent425ed6e223b8dd190e9fbeb4a41c6479f3fc8df0 (diff)
optimizing av_log2
Originally committed as revision 1515 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/common.c11
-rw-r--r--libavcodec/common.h29
2 files changed, 29 insertions, 11 deletions
diff --git a/libavcodec/common.c b/libavcodec/common.c
index 4868bc0237..aa766280b3 100644
--- a/libavcodec/common.c
+++ b/libavcodec/common.c
@@ -27,6 +27,17 @@ const UINT8 ff_sqrt_tab[128]={
9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11
};
+const uint8_t ff_log2_tab[256]={
+ 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
+};
+
void init_put_bits(PutBitContext *s,
UINT8 *buffer, int buffer_size,
void *opaque,
diff --git a/libavcodec/common.h b/libavcodec/common.h
index bdfa398a47..dadc184447 100644
--- a/libavcodec/common.h
+++ b/libavcodec/common.h
@@ -804,6 +804,7 @@ void print_stats(void);
#endif
/* misc math functions */
+extern const uint8_t ff_log2_tab[256];
static inline int av_log2(unsigned int v)
{
@@ -818,20 +819,26 @@ static inline int av_log2(unsigned int v)
v >>= 8;
n += 8;
}
- if (v & 0xf0) {
- v >>= 4;
- n += 4;
- }
- if (v & 0xc) {
- v >>= 2;
- n += 2;
- }
- if (v & 0x2) {
- n++;
+ n += ff_log2_tab[v];
+
+ return n;
+}
+
+static inline int av_log2_16bit(unsigned int v)
+{
+ int n;
+
+ n = 0;
+ if (v & 0xff00) {
+ v >>= 8;
+ n += 8;
}
+ n += ff_log2_tab[v];
+
return n;
}
+
/* median of 3 */
static inline int mid_pred(int a, int b, int c)
{
@@ -861,7 +868,7 @@ static inline int clip(int a, int amin, int amax)
}
/* math */
-extern const UINT8 ff_sqrt_tab[128];
+extern const uint8_t ff_sqrt_tab[128];
int ff_gcd(int a, int b);