Commit d262a6ae authored by Steve Lhomme's avatar Steve Lhomme

replace direct calls to __builtin_clz/ctz with generic functions

parent 9a48df2e
......@@ -30,6 +30,8 @@
#include <stdint.h>
#include "common/attributes.h"
static inline int imax(const int a, const int b) {
return a > b ? a : b;
}
......@@ -51,11 +53,11 @@ static inline int apply_sign(const int v, const int s) {
}
static inline int ulog2(const unsigned v) {
return 31 - __builtin_clz(v);
return 31 - clz(v);
}
static inline int u64log2(const uint64_t v) {
return 63 - __builtin_clzll(v);
return 63 - clzll(v);
}
static inline unsigned rl16(const uint8_t *const ptr) {
......
......@@ -296,7 +296,7 @@ static void derive_warpmv(const Dav1dTileContext *const t,
const int off = t->bx & (bs(&r[-b4_stride])[0] - 1);
add_sample(-off, 0, 1, -1, &r[-b4_stride]);
} else for (unsigned off = 0, xmask = masks[0]; np < 8 && xmask;) { // top
const int tz = __builtin_ctz(xmask);
const int tz = ctz(xmask);
off += tz;
add_sample(off, 0, 1, -1, &r[off - b4_stride]);
xmask >>= tz + 1;
......@@ -306,7 +306,7 @@ static void derive_warpmv(const Dav1dTileContext *const t,
const int off = t->by & (bs(&r[-1])[1] - 1);
add_sample(0, -off, -1, 1, &r[-1 - off * b4_stride]);
} else for (unsigned off = 0, ymask = masks[1]; np < 8 && ymask;) { // left
const int tz = __builtin_ctz(ymask);
const int tz = ctz(ymask);
off += tz;
add_sample(0, off, -1, 1, &r[off * b4_stride - 1]);
ymask >>= tz + 1;
......
......@@ -32,7 +32,7 @@ typedef MsacContext od_ec_dec;
static inline int get_msb(unsigned int n) {
assert(n != 0);
return 31 ^ __builtin_clz(n);
return 31 ^ clz(n);
}
#define EC_PROB_SHIFT 6
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment