mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 06:24:27 +02:00
use WEBP_INLINE for inline function declarations
removes a #define inline, objectionable in certain projects Change-Id: Iebe0ce0b25a030756304d402679ef769e5f854d1
This commit is contained in:
@ -112,7 +112,7 @@ static void SetSegmentProbas(VP8Encoder* const enc) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline int clip(int v, int m, int M) {
|
||||
static WEBP_INLINE int clip(int v, int m, int M) {
|
||||
return v < m ? m : v > M ? M : v;
|
||||
}
|
||||
|
||||
|
@ -22,20 +22,20 @@ extern const uint16_t VP8LevelFixedCosts[2048]; // approximate cost per level
|
||||
extern const uint16_t VP8EntropyCost[256]; // 8bit fixed-point log(p)
|
||||
|
||||
// Cost of coding one event with probability 'proba'.
|
||||
static inline int VP8BitCost(int bit, uint8_t proba) {
|
||||
static WEBP_INLINE int VP8BitCost(int bit, uint8_t proba) {
|
||||
return !bit ? VP8EntropyCost[proba] : VP8EntropyCost[255 - proba];
|
||||
}
|
||||
|
||||
// Cost of coding 'nb' 1's and 'total-nb' 0's using 'proba' probability.
|
||||
static inline uint64_t VP8BranchCost(uint64_t nb, uint64_t total,
|
||||
uint8_t proba) {
|
||||
static WEBP_INLINE uint64_t VP8BranchCost(uint64_t nb, uint64_t total,
|
||||
uint8_t proba) {
|
||||
return nb * VP8BitCost(1, proba) + (total - nb) * VP8BitCost(0, proba);
|
||||
}
|
||||
|
||||
// Level cost calculations
|
||||
extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2];
|
||||
void VP8CalculateLevelCosts(VP8Proba* const proba);
|
||||
static inline int VP8LevelCost(const uint16_t* const table, int level) {
|
||||
static WEBP_INLINE int VP8LevelCost(const uint16_t* const table, int level) {
|
||||
return VP8LevelFixedCosts[level]
|
||||
+ table[level > MAX_VARIABLE_LEVEL ? MAX_VARIABLE_LEVEL : level];
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ static void InitTables(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint8_t clip_8b(int v) {
|
||||
static WEBP_INLINE uint8_t clip_8b(int v) {
|
||||
return (!(v & ~0xff)) ? v : v < 0 ? 0 : 255;
|
||||
}
|
||||
|
||||
@ -97,8 +97,8 @@ static const int kC1 = 20091 + (1 << 16);
|
||||
static const int kC2 = 35468;
|
||||
#define MUL(a, b) (((a) * (b)) >> 16)
|
||||
|
||||
static inline void ITransformOne(const uint8_t* ref, const int16_t* in,
|
||||
uint8_t* dst) {
|
||||
static WEBP_INLINE void ITransformOne(const uint8_t* ref, const int16_t* in,
|
||||
uint8_t* dst) {
|
||||
int C[4 * 4], *tmp;
|
||||
int i;
|
||||
tmp = C;
|
||||
@ -231,14 +231,15 @@ static void FTransformWHT(const int16_t* in, int16_t* out) {
|
||||
|
||||
#define OUT(x, y) dst[(x) + (y) * BPS]
|
||||
|
||||
static inline void Fill(uint8_t* dst, int value, int size) {
|
||||
static WEBP_INLINE void Fill(uint8_t* dst, int value, int size) {
|
||||
int j;
|
||||
for (j = 0; j < size; ++j) {
|
||||
memset(dst + j * BPS, value, size);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void VerticalPred(uint8_t* dst, const uint8_t* top, int size) {
|
||||
static WEBP_INLINE void VerticalPred(uint8_t* dst,
|
||||
const uint8_t* top, int size) {
|
||||
int j;
|
||||
if (top) {
|
||||
for (j = 0; j < size; ++j) memcpy(dst + j * BPS, top, size);
|
||||
@ -247,7 +248,8 @@ static inline void VerticalPred(uint8_t* dst, const uint8_t* top, int size) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline void HorizontalPred(uint8_t* dst, const uint8_t* left, int size) {
|
||||
static WEBP_INLINE void HorizontalPred(uint8_t* dst,
|
||||
const uint8_t* left, int size) {
|
||||
if (left) {
|
||||
int j;
|
||||
for (j = 0; j < size; ++j) {
|
||||
@ -258,8 +260,8 @@ static inline void HorizontalPred(uint8_t* dst, const uint8_t* left, int size) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline void TrueMotion(uint8_t* dst, const uint8_t* left,
|
||||
const uint8_t* top, int size) {
|
||||
static WEBP_INLINE void TrueMotion(uint8_t* dst, const uint8_t* left,
|
||||
const uint8_t* top, int size) {
|
||||
int y;
|
||||
if (left) {
|
||||
if (top) {
|
||||
@ -288,9 +290,9 @@ static inline void TrueMotion(uint8_t* dst, const uint8_t* left,
|
||||
}
|
||||
}
|
||||
|
||||
static inline void DCMode(uint8_t* dst, const uint8_t* left,
|
||||
const uint8_t* top,
|
||||
int size, int round, int shift) {
|
||||
static WEBP_INLINE void DCMode(uint8_t* dst, const uint8_t* left,
|
||||
const uint8_t* top,
|
||||
int size, int round, int shift) {
|
||||
int DC = 0;
|
||||
int j;
|
||||
if (top) {
|
||||
@ -532,7 +534,8 @@ static void Intra4Preds(uint8_t* dst, const uint8_t* top) {
|
||||
//------------------------------------------------------------------------------
|
||||
// Metric
|
||||
|
||||
static inline int GetSSE(const uint8_t* a, const uint8_t* b, int w, int h) {
|
||||
static WEBP_INLINE int GetSSE(const uint8_t* a, const uint8_t* b,
|
||||
int w, int h) {
|
||||
int count = 0;
|
||||
int y, x;
|
||||
for (y = 0; y < h; ++y) {
|
||||
@ -652,7 +655,7 @@ static int QuantizeBlock(int16_t in[16], int16_t out[16],
|
||||
//------------------------------------------------------------------------------
|
||||
// Block copy
|
||||
|
||||
static inline void Copy(const uint8_t* src, uint8_t* dst, int size) {
|
||||
static WEBP_INLINE void Copy(const uint8_t* src, uint8_t* dst, int size) {
|
||||
int y;
|
||||
for (y = 0; y < size; ++y) {
|
||||
memcpy(dst, src, size);
|
||||
@ -670,7 +673,7 @@ static void Copy16x16(const uint8_t* src, uint8_t* dst) { Copy(src, dst, 16); }
|
||||
//
|
||||
|
||||
#if defined(__pic__) && defined(__i386__)
|
||||
static inline void GetCPUInfo(int cpu_info[4], int info_type) {
|
||||
static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
|
||||
__asm__ volatile (
|
||||
"mov %%ebx, %%edi\n"
|
||||
"cpuid\n"
|
||||
@ -679,7 +682,7 @@ static inline void GetCPUInfo(int cpu_info[4], int info_type) {
|
||||
: "a"(info_type));
|
||||
}
|
||||
#elif defined(__i386__) || defined(__x86_64__)
|
||||
static inline void GetCPUInfo(int cpu_info[4], int info_type) {
|
||||
static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
|
||||
__asm__ volatile (
|
||||
"cpuid\n"
|
||||
: "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
|
||||
|
@ -49,7 +49,7 @@ static void InitTables(void) {
|
||||
// Edge filtering functions
|
||||
|
||||
// 4 pixels in, 2 pixels out
|
||||
static inline void do_filter2(uint8_t* p, int step) {
|
||||
static WEBP_INLINE void do_filter2(uint8_t* p, int step) {
|
||||
const int p1 = p[-2*step], p0 = p[-step], q0 = p[0], q1 = p[step];
|
||||
const int a = 3 * (q0 - p0) + sclip1[1020 + p1 - q1];
|
||||
const int a1 = sclip2[112 + ((a + 4) >> 3)];
|
||||
@ -59,7 +59,7 @@ static inline void do_filter2(uint8_t* p, int step) {
|
||||
}
|
||||
|
||||
// 4 pixels in, 4 pixels out
|
||||
static inline void do_filter4(uint8_t* p, int step) {
|
||||
static WEBP_INLINE void do_filter4(uint8_t* p, int step) {
|
||||
const int p1 = p[-2*step], p0 = p[-step], q0 = p[0], q1 = p[step];
|
||||
const int a = 3 * (q0 - p0);
|
||||
const int a1 = sclip2[112 + ((a + 4) >> 3)];
|
||||
@ -72,17 +72,18 @@ static inline void do_filter4(uint8_t* p, int step) {
|
||||
}
|
||||
|
||||
// high edge-variance
|
||||
static inline int hev(const uint8_t* p, int step, int thresh) {
|
||||
static WEBP_INLINE int hev(const uint8_t* p, int step, int thresh) {
|
||||
const int p1 = p[-2*step], p0 = p[-step], q0 = p[0], q1 = p[step];
|
||||
return (abs0[255 + p1 - p0] > thresh) || (abs0[255 + q1 - q0] > thresh);
|
||||
}
|
||||
|
||||
static inline int needs_filter(const uint8_t* p, int step, int thresh) {
|
||||
static WEBP_INLINE int needs_filter(const uint8_t* p, int step, int thresh) {
|
||||
const int p1 = p[-2*step], p0 = p[-step], q0 = p[0], q1 = p[step];
|
||||
return (2 * abs0[255 + p0 - q0] + abs1[255 + p1 - q1]) <= thresh;
|
||||
}
|
||||
|
||||
static inline int needs_filter2(const uint8_t* p, int step, int t, int it) {
|
||||
static WEBP_INLINE int needs_filter2(const uint8_t* p,
|
||||
int step, int t, int it) {
|
||||
const int p3 = p[-4*step], p2 = p[-3*step], p1 = p[-2*step], p0 = p[-step];
|
||||
const int q0 = p[0], q1 = p[step], q2 = p[2*step], q3 = p[3*step];
|
||||
if ((2 * abs0[255 + p0 - q0] + abs1[255 + p1 - q1]) > t)
|
||||
@ -132,8 +133,9 @@ static void SimpleHFilter16i(uint8_t* p, int stride, int thresh) {
|
||||
//------------------------------------------------------------------------------
|
||||
// Complex In-loop filtering (Paragraph 15.3)
|
||||
|
||||
static inline void FilterLoop24(uint8_t* p, int hstride, int vstride, int size,
|
||||
int thresh, int ithresh, int hev_thresh) {
|
||||
static WEBP_INLINE void FilterLoop24(uint8_t* p,
|
||||
int hstride, int vstride, int size,
|
||||
int thresh, int ithresh, int hev_thresh) {
|
||||
while (size-- > 0) {
|
||||
if (needs_filter2(p, hstride, thresh, ithresh)) {
|
||||
if (hev(p, hstride, hev_thresh)) {
|
||||
|
@ -224,8 +224,8 @@ int WebPPictureCrop(WebPPicture* const pic,
|
||||
|
||||
#define RFIX 30
|
||||
#define MULT(x,y) (((int64_t)(x) * (y) + (1 << (RFIX - 1))) >> RFIX)
|
||||
static inline void ImportRow(const uint8_t* src, int src_width,
|
||||
int32_t* frow, int32_t* irow, int dst_width) {
|
||||
static WEBP_INLINE void ImportRow(const uint8_t* src, int src_width,
|
||||
int32_t* frow, int32_t* irow, int dst_width) {
|
||||
const int x_expand = (src_width < dst_width);
|
||||
const int fx_scale = (1 << RFIX) / dst_width;
|
||||
int x_in = 0;
|
||||
@ -429,22 +429,22 @@ static int WebPMemoryWrite(const uint8_t* data, size_t data_size,
|
||||
|
||||
enum { YUV_FRAC = 16 };
|
||||
|
||||
static inline int clip_uv(int v) {
|
||||
static WEBP_INLINE int clip_uv(int v) {
|
||||
v = (v + (257 << (YUV_FRAC + 2 - 1))) >> (YUV_FRAC + 2);
|
||||
return ((v & ~0xff) == 0) ? v : (v < 0) ? 0 : 255;
|
||||
}
|
||||
|
||||
static inline int rgb_to_y(int r, int g, int b) {
|
||||
static WEBP_INLINE int rgb_to_y(int r, int g, int b) {
|
||||
const int kRound = (1 << (YUV_FRAC - 1)) + (16 << YUV_FRAC);
|
||||
const int luma = 16839 * r + 33059 * g + 6420 * b;
|
||||
return (luma + kRound) >> YUV_FRAC; // no need to clip
|
||||
}
|
||||
|
||||
static inline int rgb_to_u(int r, int g, int b) {
|
||||
static WEBP_INLINE int rgb_to_u(int r, int g, int b) {
|
||||
return clip_uv(-9719 * r - 19081 * g + 28800 * b);
|
||||
}
|
||||
|
||||
static inline int rgb_to_v(int r, int g, int b) {
|
||||
static WEBP_INLINE int rgb_to_v(int r, int g, int b) {
|
||||
return clip_uv(+28800 * r - 24116 * g - 4684 * b);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ extern "C" {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static inline int clip(int v, int m, int M) {
|
||||
static WEBP_INLINE int clip(int v, int m, int M) {
|
||||
return v < m ? m : v > M ? M : v;
|
||||
}
|
||||
|
||||
@ -406,13 +406,13 @@ typedef struct {
|
||||
#define NUM_NODES (MIN_DELTA + 1 + MAX_DELTA)
|
||||
#define NODE(n, l) (nodes[(n) + 1][(l) + MIN_DELTA])
|
||||
|
||||
static inline void SetRDScore(int lambda, VP8ModeScore* const rd) {
|
||||
static WEBP_INLINE void SetRDScore(int lambda, VP8ModeScore* const rd) {
|
||||
// TODO: incorporate the "* 256" in the tables?
|
||||
rd->score = rd->R * lambda + 256 * (rd->D + rd->SD);
|
||||
}
|
||||
|
||||
static inline score_t RDScoreTrellis(int lambda, score_t rate,
|
||||
score_t distortion) {
|
||||
static WEBP_INLINE score_t RDScoreTrellis(int lambda, score_t rate,
|
||||
score_t distortion) {
|
||||
return rate * lambda + 256 * distortion;
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ typedef int64_t score_t; // type used for scores, rate, distortion
|
||||
#define BIAS(b) ((b) << (QFIX - 8))
|
||||
// Fun fact: this is the _only_ line where we're actually being lossy and
|
||||
// discarding bits.
|
||||
static inline int QUANTDIV(int n, int iQ, int B) {
|
||||
static WEBP_INLINE int QUANTDIV(int n, int iQ, int B) {
|
||||
return (n * iQ + B) >> QFIX;
|
||||
}
|
||||
extern const uint8_t VP8Zigzag[16];
|
||||
|
Reference in New Issue
Block a user