ref: d262a6ae9a36aea61daf5af03f246287a30c45dd
parent: 9a48df2e5794b0378f256b4721789bd9271f8a82
author: Steve Lhomme <robux4@ycbcr.xyz>
date: Fri Sep 28 05:43:41 EDT 2018
replace direct calls to __builtin_clz/ctz with generic functions
--- a/include/common/intops.h
+++ b/include/common/intops.h
@@ -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 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) {
--- a/src/decode.c
+++ b/src/decode.c
@@ -296,7 +296,7 @@
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 @@
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;
--- a/src/msac.c
+++ b/src/msac.c
@@ -32,7 +32,7 @@
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