use WEBP_INLINE for inline function declarations

removes a #define inline, objectionable in certain projects

Change-Id: Iebe0ce0b25a030756304d402679ef769e5f854d1
This commit is contained in:
James Zern 2011-11-04 19:44:57 -07:00
parent 90880a11b4
commit 964387ed19
25 changed files with 151 additions and 134 deletions

View File

@ -17,7 +17,7 @@
typedef LARGE_INTEGER Stopwatch; typedef LARGE_INTEGER Stopwatch;
static inline double StopwatchReadAndReset(Stopwatch* watch) { static WEBP_INLINE double StopwatchReadAndReset(Stopwatch* watch) {
const LARGE_INTEGER old_value = *watch; const LARGE_INTEGER old_value = *watch;
LARGE_INTEGER freq; LARGE_INTEGER freq;
if (!QueryPerformanceCounter(watch)) if (!QueryPerformanceCounter(watch))
@ -35,7 +35,7 @@ static inline double StopwatchReadAndReset(Stopwatch* watch) {
typedef struct timeval Stopwatch; typedef struct timeval Stopwatch;
static inline double StopwatchReadAndReset(Stopwatch* watch) { static WEBP_INLINE double StopwatchReadAndReset(Stopwatch* watch) {
const struct timeval old_value = *watch; const struct timeval old_value = *watch;
gettimeofday(watch, NULL); gettimeofday(watch, NULL);
return watch->tv_sec - old_value.tv_sec + return watch->tv_sec - old_value.tv_sec +

View File

@ -193,7 +193,7 @@ int VP8InitFrame(VP8Decoder* const dec, VP8Io* io) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Filtering // Filtering
static inline int hev_thresh_from_level(int level, int keyframe) { static WEBP_INLINE int hev_thresh_from_level(int level, int keyframe) {
if (keyframe) { if (keyframe) {
return (level >= 40) ? 2 : (level >= 15) ? 1 : 0; return (level >= 40) ? 2 : (level >= 15) ? 1 : 0;
} else { } else {
@ -520,7 +520,7 @@ static const int kScan[16] = {
0 + 12 * BPS, 4 + 12 * BPS, 8 + 12 * BPS, 12 + 12 * BPS 0 + 12 * BPS, 4 + 12 * BPS, 8 + 12 * BPS, 12 + 12 * BPS
}; };
static inline int CheckMode(VP8Decoder* const dec, int mode) { static WEBP_INLINE int CheckMode(VP8Decoder* const dec, int mode) {
if (mode == B_DC_PRED) { if (mode == B_DC_PRED) {
if (dec->mb_x_ == 0) { if (dec->mb_x_ == 0) {
return (dec->mb_y_ == 0) ? B_DC_PRED_NOTOPLEFT : B_DC_PRED_NOLEFT; return (dec->mb_y_ == 0) ? B_DC_PRED_NOTOPLEFT : B_DC_PRED_NOLEFT;
@ -531,7 +531,7 @@ static inline int CheckMode(VP8Decoder* const dec, int mode) {
return mode; return mode;
} }
static inline void Copy32b(uint8_t* dst, uint8_t* src) { static WEBP_INLINE void Copy32b(uint8_t* dst, uint8_t* src) {
*(uint32_t*)dst = *(uint32_t*)src; *(uint32_t*)dst = *(uint32_t*)src;
} }

View File

@ -82,7 +82,7 @@ typedef struct {
#define REMAP(PTR, OLD_BASE, NEW_BASE) (PTR) = (NEW_BASE) + ((PTR) - OLD_BASE) #define REMAP(PTR, OLD_BASE, NEW_BASE) (PTR) = (NEW_BASE) + ((PTR) - OLD_BASE)
static inline size_t MemDataSize(const MemBuffer* mem) { static WEBP_INLINE size_t MemDataSize(const MemBuffer* mem) {
return (mem->end_ - mem->start_); return (mem->end_ - mem->start_);
} }

View File

@ -239,8 +239,8 @@ static void InitRescaler(WebPRescaler* const wrk,
wrk->frow = work + dst_width; wrk->frow = work + dst_width;
} }
static inline void ImportRow(const uint8_t* const src, static WEBP_INLINE void ImportRow(const uint8_t* const src,
WebPRescaler* const wrk) { WebPRescaler* const wrk) {
int x_in = 0; int x_in = 0;
int x_out; int x_out;
int accum = 0; int accum = 0;

View File

@ -15,7 +15,7 @@
extern "C" { extern "C" {
#endif #endif
static inline int clip(int v, int M) { static WEBP_INLINE int clip(int v, int M) {
return v < 0 ? 0 : v > M ? M : v; return v < 0 ? 0 : v > M ? M : v;
} }

View File

@ -38,7 +38,7 @@ extern "C" {
// All 32-bits sizes are in little-endian order. // All 32-bits sizes are in little-endian order.
// Note: chunk data must be padded to multiple of 2 in size // Note: chunk data must be padded to multiple of 2 in size
static inline uint32_t get_le32(const uint8_t* const data) { static WEBP_INLINE uint32_t get_le32(const uint8_t* const data) {
return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
} }

View File

@ -22,7 +22,7 @@ extern "C" {
// //
#if defined(__pic__) && defined(__i386__) #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 ( __asm__ volatile (
"mov %%ebx, %%edi\n" "mov %%ebx, %%edi\n"
"cpuid\n" "cpuid\n"
@ -31,7 +31,7 @@ static inline void GetCPUInfo(int cpu_info[4], int info_type) {
: "a"(info_type)); : "a"(info_type));
} }
#elif defined(__i386__) || defined(__x86_64__) #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 ( __asm__ volatile (
"cpuid\n" "cpuid\n"
: "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])

View File

@ -49,7 +49,7 @@ static void DspInitTables(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; return (!(v & ~0xff)) ? v : (v < 0) ? 0 : 255;
} }
@ -171,7 +171,7 @@ void (*VP8TransformWHT)(const int16_t* in, int16_t* out) = TransformWHT;
#define DST(x, y) dst[(x) + (y) * BPS] #define DST(x, y) dst[(x) + (y) * BPS]
static inline void TrueMotion(uint8_t *dst, int size) { static WEBP_INLINE void TrueMotion(uint8_t *dst, int size) {
const uint8_t* top = dst - BPS; const uint8_t* top = dst - BPS;
const uint8_t* const clip0 = clip1 + 255 - top[-1]; const uint8_t* const clip0 = clip1 + 255 - top[-1];
int y; int y;
@ -206,7 +206,7 @@ static void HE16(uint8_t *dst) { // horizontal
} }
} }
static inline void Put16(int v, uint8_t* dst) { static WEBP_INLINE void Put16(int v, uint8_t* dst) {
int j; int j;
for (j = 0; j < 16; ++j) { for (j = 0; j < 16; ++j) {
memset(dst + j * BPS, v, 16); memset(dst + j * BPS, v, 16);
@ -426,7 +426,7 @@ static void HE8uv(uint8_t *dst) { // horizontal
} }
// helper for chroma-DC predictions // helper for chroma-DC predictions
static inline void Put8x8uv(uint64_t v, uint8_t* dst) { static WEBP_INLINE void Put8x8uv(uint64_t v, uint8_t* dst) {
int j; int j;
for (j = 0; j < 8; ++j) { for (j = 0; j < 8; ++j) {
*(uint64_t*)(dst + j * BPS) = v; *(uint64_t*)(dst + j * BPS) = v;
@ -485,7 +485,7 @@ VP8PredFunc VP8PredChroma8[/*NUM_B_DC_MODES */] = {
// Edge filtering functions // Edge filtering functions
// 4 pixels in, 2 pixels out // 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 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 a = 3 * (q0 - p0) + sclip1[1020 + p1 - q1];
const int a1 = sclip2[112 + ((a + 4) >> 3)]; const int a1 = sclip2[112 + ((a + 4) >> 3)];
@ -495,7 +495,7 @@ static inline void do_filter2(uint8_t* p, int step) {
} }
// 4 pixels in, 4 pixels out // 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 p1 = p[-2*step], p0 = p[-step], q0 = p[0], q1 = p[step];
const int a = 3 * (q0 - p0); const int a = 3 * (q0 - p0);
const int a1 = sclip2[112 + ((a + 4) >> 3)]; const int a1 = sclip2[112 + ((a + 4) >> 3)];
@ -508,7 +508,7 @@ static inline void do_filter4(uint8_t* p, int step) {
} }
// 6 pixels in, 6 pixels out // 6 pixels in, 6 pixels out
static inline void do_filter6(uint8_t* p, int step) { static WEBP_INLINE void do_filter6(uint8_t* p, int step) {
const int p2 = p[-3*step], p1 = p[-2*step], p0 = p[-step]; const int p2 = p[-3*step], p1 = p[-2*step], p0 = p[-step];
const int q0 = p[0], q1 = p[step], q2 = p[2*step]; const int q0 = p[0], q1 = p[step], q2 = p[2*step];
const int a = sclip1[1020 + 3 * (q0 - p0) + sclip1[1020 + p1 - q1]]; const int a = sclip1[1020 + 3 * (q0 - p0) + sclip1[1020 + p1 - q1]];
@ -523,17 +523,18 @@ static inline void do_filter6(uint8_t* p, int step) {
p[ 2*step] = clip1[255 + q2 - a3]; p[ 2*step] = clip1[255 + q2 - a3];
} }
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]; 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); 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]; 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; 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 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]; 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) if ((2 * abs0[255 + p0 - q0] + abs1[255 + p1 - q1]) > t)
@ -583,8 +584,9 @@ static void SimpleHFilter16i(uint8_t* p, int stride, int thresh) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Complex In-loop filtering (Paragraph 15.3) // Complex In-loop filtering (Paragraph 15.3)
static inline void FilterLoop26(uint8_t* p, int hstride, int vstride, int size, static WEBP_INLINE void FilterLoop26(uint8_t* p,
int thresh, int ithresh, int hev_thresh) { int hstride, int vstride, int size,
int thresh, int ithresh, int hev_thresh) {
while (size-- > 0) { while (size-- > 0) {
if (needs_filter2(p, hstride, thresh, ithresh)) { if (needs_filter2(p, hstride, thresh, ithresh)) {
if (hev(p, hstride, hev_thresh)) { if (hev(p, hstride, hev_thresh)) {
@ -597,8 +599,9 @@ static inline void FilterLoop26(uint8_t* p, int hstride, int vstride, int size,
} }
} }
static inline void FilterLoop24(uint8_t* p, int hstride, int vstride, int size, static WEBP_INLINE void FilterLoop24(uint8_t* p,
int thresh, int ithresh, int hev_thresh) { int hstride, int vstride, int size,
int thresh, int ithresh, int hev_thresh) {
while (size-- > 0) { while (size-- > 0) {
if (needs_filter2(p, hstride, thresh, ithresh)) { if (needs_filter2(p, hstride, thresh, ithresh)) {
if (hev(p, hstride, hev_thresh)) { if (hev(p, hstride, hev_thresh)) {

View File

@ -341,8 +341,8 @@ static void NeedsFilter(const __m128i* p1, const __m128i* p0, const __m128i* q0,
// Edge filtering functions // Edge filtering functions
// Applies filter on 2 pixels (p0 and q0) // Applies filter on 2 pixels (p0 and q0)
static inline void DoFilter2(const __m128i* p1, __m128i* p0, __m128i* q0, static WEBP_INLINE void DoFilter2(const __m128i* p1, __m128i* p0, __m128i* q0,
const __m128i* q1, int thresh) { const __m128i* q1, int thresh) {
__m128i a, mask; __m128i a, mask;
const __m128i sign_bit = _mm_set1_epi8(0x80); const __m128i sign_bit = _mm_set1_epi8(0x80);
const __m128i p1s = _mm_xor_si128(*p1, sign_bit); const __m128i p1s = _mm_xor_si128(*p1, sign_bit);
@ -362,8 +362,9 @@ static inline void DoFilter2(const __m128i* p1, __m128i* p0, __m128i* q0,
} }
// Applies filter on 4 pixels (p1, p0, q0 and q1) // Applies filter on 4 pixels (p1, p0, q0 and q1)
static inline void DoFilter4(__m128i* p1, __m128i *p0, __m128i* q0, __m128i* q1, static WEBP_INLINE void DoFilter4(__m128i* p1, __m128i *p0,
const __m128i* mask, int hev_thresh) { __m128i* q0, __m128i* q1,
const __m128i* mask, int hev_thresh) {
__m128i not_hev; __m128i not_hev;
__m128i t1, t2, t3; __m128i t1, t2, t3;
const __m128i sign_bit = _mm_set1_epi8(0x80); const __m128i sign_bit = _mm_set1_epi8(0x80);
@ -408,9 +409,9 @@ static inline void DoFilter4(__m128i* p1, __m128i *p0, __m128i* q0, __m128i* q1,
} }
// Applies filter on 6 pixels (p2, p1, p0, q0, q1 and q2) // Applies filter on 6 pixels (p2, p1, p0, q0, q1 and q2)
static inline void DoFilter6(__m128i *p2, __m128i* p1, __m128i *p0, static WEBP_INLINE void DoFilter6(__m128i *p2, __m128i* p1, __m128i *p0,
__m128i* q0, __m128i* q1, __m128i *q2, __m128i* q0, __m128i* q1, __m128i *q2,
const __m128i* mask, int hev_thresh) { const __m128i* mask, int hev_thresh) {
__m128i a, not_hev; __m128i a, not_hev;
const __m128i sign_bit = _mm_set1_epi8(0x80); const __m128i sign_bit = _mm_set1_epi8(0x80);
@ -466,8 +467,8 @@ static inline void DoFilter6(__m128i *p2, __m128i* p1, __m128i *p0,
// //
// TODO(somnath): Investigate _mm_shuffle* also see if it can be broken into // TODO(somnath): Investigate _mm_shuffle* also see if it can be broken into
// two Load4x4() to avoid code duplication. // two Load4x4() to avoid code duplication.
static inline void Load8x4(const uint8_t* b, int stride, static WEBP_INLINE void Load8x4(const uint8_t* b, int stride,
__m128i* p, __m128i* q) { __m128i* p, __m128i* q) {
__m128i t1, t2; __m128i t1, t2;
// Load 0th, 1st, 4th and 5th rows // Load 0th, 1st, 4th and 5th rows
@ -506,9 +507,10 @@ static inline void Load8x4(const uint8_t* b, int stride,
*q = _mm_unpackhi_epi32(t1, t2); *q = _mm_unpackhi_epi32(t1, t2);
} }
static inline void Load16x4(const uint8_t* r0, const uint8_t* r8, int stride, static WEBP_INLINE void Load16x4(const uint8_t* r0, const uint8_t* r8,
__m128i* p1, __m128i* p0, int stride,
__m128i* q0, __m128i* q1) { __m128i* p1, __m128i* p0,
__m128i* q0, __m128i* q1) {
__m128i t1, t2; __m128i t1, t2;
// Assume the pixels around the edge (|) are numbered as follows // Assume the pixels around the edge (|) are numbered as follows
// 00 01 | 02 03 // 00 01 | 02 03
@ -540,7 +542,7 @@ static inline void Load16x4(const uint8_t* r0, const uint8_t* r8, int stride,
*q1 = _mm_unpackhi_epi64(t2, *q1); *q1 = _mm_unpackhi_epi64(t2, *q1);
} }
static inline void Store4x4(__m128i* x, uint8_t* dst, int stride) { static WEBP_INLINE void Store4x4(__m128i* x, uint8_t* dst, int stride) {
int i; int i;
for (i = 0; i < 4; ++i, dst += stride) { for (i = 0; i < 4; ++i, dst += stride) {
*((int32_t*)dst) = _mm_cvtsi128_si32(*x); *((int32_t*)dst) = _mm_cvtsi128_si32(*x);
@ -549,8 +551,9 @@ static inline void Store4x4(__m128i* x, uint8_t* dst, int stride) {
} }
// Transpose back and store // Transpose back and store
static inline void Store16x4(uint8_t* r0, uint8_t* r8, int stride, __m128i* p1, static WEBP_INLINE void Store16x4(uint8_t* r0, uint8_t* r8, int stride,
__m128i* p0, __m128i* q0, __m128i* q1) { __m128i* p1, __m128i* p0,
__m128i* q0, __m128i* q1) {
__m128i t1; __m128i t1;
// p0 = 71 70 61 60 51 50 41 40 31 30 21 20 11 10 01 00 // p0 = 71 70 61 60 51 50 41 40 31 30 21 20 11 10 01 00

View File

@ -93,7 +93,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; return (!(v & ~0xff)) ? v : v < 0 ? 0 : 255;
} }
@ -107,8 +107,8 @@ static const int kC1 = 20091 + (1 << 16);
static const int kC2 = 35468; static const int kC2 = 35468;
#define MUL(a, b) (((a) * (b)) >> 16) #define MUL(a, b) (((a) * (b)) >> 16)
static inline void ITransformOne(const uint8_t* ref, const int16_t* in, static WEBP_INLINE void ITransformOne(const uint8_t* ref, const int16_t* in,
uint8_t* dst) { uint8_t* dst) {
int C[4 * 4], *tmp; int C[4 * 4], *tmp;
int i; int i;
tmp = C; tmp = C;
@ -241,14 +241,15 @@ static void FTransformWHT(const int16_t* in, int16_t* out) {
#define DST(x, y) dst[(x) + (y) * BPS] #define DST(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; int j;
for (j = 0; j < size; ++j) { for (j = 0; j < size; ++j) {
memset(dst + j * BPS, value, size); 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; int j;
if (top) { if (top) {
for (j = 0; j < size; ++j) memcpy(dst + j * BPS, top, size); for (j = 0; j < size; ++j) memcpy(dst + j * BPS, top, size);
@ -257,7 +258,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) { if (left) {
int j; int j;
for (j = 0; j < size; ++j) { for (j = 0; j < size; ++j) {
@ -268,8 +270,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, static WEBP_INLINE void TrueMotion(uint8_t* dst, const uint8_t* left,
const uint8_t* top, int size) { const uint8_t* top, int size) {
int y; int y;
if (left) { if (left) {
if (top) { if (top) {
@ -298,9 +300,9 @@ static inline void TrueMotion(uint8_t* dst, const uint8_t* left,
} }
} }
static inline void DCMode(uint8_t* dst, const uint8_t* left, static WEBP_INLINE void DCMode(uint8_t* dst, const uint8_t* left,
const uint8_t* top, const uint8_t* top,
int size, int round, int shift) { int size, int round, int shift) {
int DC = 0; int DC = 0;
int j; int j;
if (top) { if (top) {
@ -543,7 +545,8 @@ static void Intra4Preds(uint8_t* dst, const uint8_t* top) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Metric // 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 count = 0;
int y, x; int y, x;
for (y = 0; y < h; ++y) { for (y = 0; y < h; ++y) {
@ -667,7 +670,7 @@ static int QuantizeBlock(int16_t in[16], int16_t out[16],
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Block copy // 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; int y;
for (y = 0; y < size; ++y) { for (y = 0; y < size; ++y) {
memcpy(dst, src, size); memcpy(dst, src, size);

View File

@ -24,7 +24,7 @@ uint8_t VP8kClip4Bits[YUV_RANGE_MAX - YUV_RANGE_MIN];
static int done = 0; static int done = 0;
static inline uint8_t clip(int v, int max_value) { static WEBP_INLINE uint8_t clip(int v, int max_value) {
return v < 0 ? 0 : v > max_value ? max_value : v; return v < 0 ? 0 : v > max_value ? max_value : v;
} }

View File

@ -27,8 +27,8 @@ extern int32_t VP8kVToG[256], VP8kUToG[256];
extern uint8_t VP8kClip[YUV_RANGE_MAX - YUV_RANGE_MIN]; extern uint8_t VP8kClip[YUV_RANGE_MAX - YUV_RANGE_MIN];
extern uint8_t VP8kClip4Bits[YUV_RANGE_MAX - YUV_RANGE_MIN]; extern uint8_t VP8kClip4Bits[YUV_RANGE_MAX - YUV_RANGE_MIN];
static inline void VP8YuvToRgb(uint8_t y, uint8_t u, uint8_t v, static WEBP_INLINE void VP8YuvToRgb(uint8_t y, uint8_t u, uint8_t v,
uint8_t* const rgb) { uint8_t* const rgb) {
const int r_off = VP8kVToR[v]; const int r_off = VP8kVToR[v];
const int g_off = (VP8kVToG[v] + VP8kUToG[u]) >> YUV_FIX; const int g_off = (VP8kVToG[v] + VP8kUToG[u]) >> YUV_FIX;
const int b_off = VP8kUToB[u]; const int b_off = VP8kUToB[u];
@ -37,8 +37,8 @@ static inline void VP8YuvToRgb(uint8_t y, uint8_t u, uint8_t v,
rgb[2] = VP8kClip[y + b_off - YUV_RANGE_MIN]; rgb[2] = VP8kClip[y + b_off - YUV_RANGE_MIN];
} }
static inline void VP8YuvToRgb565(uint8_t y, uint8_t u, uint8_t v, static WEBP_INLINE void VP8YuvToRgb565(uint8_t y, uint8_t u, uint8_t v,
uint8_t* const rgb) { uint8_t* const rgb) {
const int r_off = VP8kVToR[v]; const int r_off = VP8kVToR[v];
const int g_off = (VP8kVToG[v] + VP8kUToG[u]) >> YUV_FIX; const int g_off = (VP8kVToG[v] + VP8kUToG[u]) >> YUV_FIX;
const int b_off = VP8kUToB[u]; const int b_off = VP8kUToB[u];
@ -48,20 +48,20 @@ static inline void VP8YuvToRgb565(uint8_t y, uint8_t u, uint8_t v,
(VP8kClip[y + b_off - YUV_RANGE_MIN] >> 3)); (VP8kClip[y + b_off - YUV_RANGE_MIN] >> 3));
} }
static inline void VP8YuvToArgbKeepA(uint8_t y, uint8_t u, uint8_t v, static WEBP_INLINE void VP8YuvToArgbKeepA(uint8_t y, uint8_t u, uint8_t v,
uint8_t* const argb) { uint8_t* const argb) {
// Don't update Aplha (argb[0]) // Don't update Aplha (argb[0])
VP8YuvToRgb(y, u, v, argb + 1); VP8YuvToRgb(y, u, v, argb + 1);
} }
static inline void VP8YuvToArgb(uint8_t y, uint8_t u, uint8_t v, static WEBP_INLINE void VP8YuvToArgb(uint8_t y, uint8_t u, uint8_t v,
uint8_t* const argb) { uint8_t* const argb) {
argb[0] = 0xff; argb[0] = 0xff;
VP8YuvToArgbKeepA(y, u, v, argb); VP8YuvToArgbKeepA(y, u, v, argb);
} }
static inline void VP8YuvToRgba4444KeepA(uint8_t y, uint8_t u, uint8_t v, static WEBP_INLINE void VP8YuvToRgba4444KeepA(uint8_t y, uint8_t u, uint8_t v,
uint8_t* const argb) { uint8_t* const argb) {
const int r_off = VP8kVToR[v]; const int r_off = VP8kVToR[v];
const int g_off = (VP8kVToG[v] + VP8kUToG[u]) >> YUV_FIX; const int g_off = (VP8kVToG[v] + VP8kUToG[u]) >> YUV_FIX;
const int b_off = VP8kUToB[u]; const int b_off = VP8kUToB[u];
@ -71,14 +71,14 @@ static inline void VP8YuvToRgba4444KeepA(uint8_t y, uint8_t u, uint8_t v,
argb[1] = (argb[1] & 0x0f) | (VP8kClip4Bits[y + b_off - YUV_RANGE_MIN] << 4); argb[1] = (argb[1] & 0x0f) | (VP8kClip4Bits[y + b_off - YUV_RANGE_MIN] << 4);
} }
static inline void VP8YuvToRgba4444(uint8_t y, uint8_t u, uint8_t v, static WEBP_INLINE void VP8YuvToRgba4444(uint8_t y, uint8_t u, uint8_t v,
uint8_t* const argb) { uint8_t* const argb) {
argb[1] = 0x0f; argb[1] = 0x0f;
VP8YuvToRgba4444KeepA(y, u, v, argb); VP8YuvToRgba4444KeepA(y, u, v, argb);
} }
static inline void VP8YuvToBgr(uint8_t y, uint8_t u, uint8_t v, static WEBP_INLINE void VP8YuvToBgr(uint8_t y, uint8_t u, uint8_t v,
uint8_t* const bgr) { uint8_t* const bgr) {
const int r_off = VP8kVToR[v]; const int r_off = VP8kVToR[v];
const int g_off = (VP8kVToG[v] + VP8kUToG[u]) >> YUV_FIX; const int g_off = (VP8kVToG[v] + VP8kUToG[u]) >> YUV_FIX;
const int b_off = VP8kUToB[u]; const int b_off = VP8kUToB[u];
@ -87,14 +87,14 @@ static inline void VP8YuvToBgr(uint8_t y, uint8_t u, uint8_t v,
bgr[2] = VP8kClip[y + r_off - YUV_RANGE_MIN]; bgr[2] = VP8kClip[y + r_off - YUV_RANGE_MIN];
} }
static inline void VP8YuvToBgra(uint8_t y, uint8_t u, uint8_t v, static WEBP_INLINE void VP8YuvToBgra(uint8_t y, uint8_t u, uint8_t v,
uint8_t* const bgra) { uint8_t* const bgra) {
VP8YuvToBgr(y, u, v, bgra); VP8YuvToBgr(y, u, v, bgra);
bgra[3] = 0xff; bgra[3] = 0xff;
} }
static inline void VP8YuvToRgba(uint8_t y, uint8_t u, uint8_t v, static WEBP_INLINE void VP8YuvToRgba(uint8_t y, uint8_t u, uint8_t v,
uint8_t* const rgba) { uint8_t* const rgba) {
VP8YuvToRgb(y, u, v, rgba); VP8YuvToRgb(y, u, v, rgba);
rgba[3] = 0xff; rgba[3] = 0xff;
} }

View File

@ -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; return v < m ? m : v > M ? M : v;
} }

View File

@ -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) extern const uint16_t VP8EntropyCost[256]; // 8bit fixed-point log(p)
// Cost of coding one event with probability 'proba'. // 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]; return !bit ? VP8EntropyCost[proba] : VP8EntropyCost[255 - proba];
} }
// Cost of coding 'nb' 1's and 'total-nb' 0's using 'proba' probability. // 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, static WEBP_INLINE uint64_t VP8BranchCost(uint64_t nb, uint64_t total,
uint8_t proba) { uint8_t proba) {
return nb * VP8BitCost(1, proba) + (total - nb) * VP8BitCost(0, proba); return nb * VP8BitCost(1, proba) + (total - nb) * VP8BitCost(0, proba);
} }
// Level cost calculations // Level cost calculations
extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2]; extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2];
void VP8CalculateLevelCosts(VP8Proba* const proba); 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] return VP8LevelFixedCosts[level]
+ table[level > MAX_VARIABLE_LEVEL ? MAX_VARIABLE_LEVEL : level]; + table[level > MAX_VARIABLE_LEVEL ? MAX_VARIABLE_LEVEL : level];
} }

View File

@ -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; return (!(v & ~0xff)) ? v : v < 0 ? 0 : 255;
} }
@ -97,8 +97,8 @@ static const int kC1 = 20091 + (1 << 16);
static const int kC2 = 35468; static const int kC2 = 35468;
#define MUL(a, b) (((a) * (b)) >> 16) #define MUL(a, b) (((a) * (b)) >> 16)
static inline void ITransformOne(const uint8_t* ref, const int16_t* in, static WEBP_INLINE void ITransformOne(const uint8_t* ref, const int16_t* in,
uint8_t* dst) { uint8_t* dst) {
int C[4 * 4], *tmp; int C[4 * 4], *tmp;
int i; int i;
tmp = C; tmp = C;
@ -231,14 +231,15 @@ static void FTransformWHT(const int16_t* in, int16_t* out) {
#define OUT(x, y) dst[(x) + (y) * BPS] #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; int j;
for (j = 0; j < size; ++j) { for (j = 0; j < size; ++j) {
memset(dst + j * BPS, value, size); 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; int j;
if (top) { if (top) {
for (j = 0; j < size; ++j) memcpy(dst + j * BPS, top, size); 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) { if (left) {
int j; int j;
for (j = 0; j < size; ++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, static WEBP_INLINE void TrueMotion(uint8_t* dst, const uint8_t* left,
const uint8_t* top, int size) { const uint8_t* top, int size) {
int y; int y;
if (left) { if (left) {
if (top) { 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, static WEBP_INLINE void DCMode(uint8_t* dst, const uint8_t* left,
const uint8_t* top, const uint8_t* top,
int size, int round, int shift) { int size, int round, int shift) {
int DC = 0; int DC = 0;
int j; int j;
if (top) { if (top) {
@ -532,7 +534,8 @@ static void Intra4Preds(uint8_t* dst, const uint8_t* top) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Metric // 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 count = 0;
int y, x; int y, x;
for (y = 0; y < h; ++y) { for (y = 0; y < h; ++y) {
@ -652,7 +655,7 @@ static int QuantizeBlock(int16_t in[16], int16_t out[16],
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Block copy // 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; int y;
for (y = 0; y < size; ++y) { for (y = 0; y < size; ++y) {
memcpy(dst, src, size); 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__) #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 ( __asm__ volatile (
"mov %%ebx, %%edi\n" "mov %%ebx, %%edi\n"
"cpuid\n" "cpuid\n"
@ -679,7 +682,7 @@ static inline void GetCPUInfo(int cpu_info[4], int info_type) {
: "a"(info_type)); : "a"(info_type));
} }
#elif defined(__i386__) || defined(__x86_64__) #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 ( __asm__ volatile (
"cpuid\n" "cpuid\n"
: "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])

View File

@ -49,7 +49,7 @@ static void InitTables(void) {
// Edge filtering functions // Edge filtering functions
// 4 pixels in, 2 pixels out // 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 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 a = 3 * (q0 - p0) + sclip1[1020 + p1 - q1];
const int a1 = sclip2[112 + ((a + 4) >> 3)]; 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 // 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 p1 = p[-2*step], p0 = p[-step], q0 = p[0], q1 = p[step];
const int a = 3 * (q0 - p0); const int a = 3 * (q0 - p0);
const int a1 = sclip2[112 + ((a + 4) >> 3)]; 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 // 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]; 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); 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]; 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; 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 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]; 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) 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) // Complex In-loop filtering (Paragraph 15.3)
static inline void FilterLoop24(uint8_t* p, int hstride, int vstride, int size, static WEBP_INLINE void FilterLoop24(uint8_t* p,
int thresh, int ithresh, int hev_thresh) { int hstride, int vstride, int size,
int thresh, int ithresh, int hev_thresh) {
while (size-- > 0) { while (size-- > 0) {
if (needs_filter2(p, hstride, thresh, ithresh)) { if (needs_filter2(p, hstride, thresh, ithresh)) {
if (hev(p, hstride, hev_thresh)) { if (hev(p, hstride, hev_thresh)) {

View File

@ -224,8 +224,8 @@ int WebPPictureCrop(WebPPicture* const pic,
#define RFIX 30 #define RFIX 30
#define MULT(x,y) (((int64_t)(x) * (y) + (1 << (RFIX - 1))) >> RFIX) #define MULT(x,y) (((int64_t)(x) * (y) + (1 << (RFIX - 1))) >> RFIX)
static inline void ImportRow(const uint8_t* src, int src_width, static WEBP_INLINE void ImportRow(const uint8_t* src, int src_width,
int32_t* frow, int32_t* irow, int dst_width) { int32_t* frow, int32_t* irow, int dst_width) {
const int x_expand = (src_width < dst_width); const int x_expand = (src_width < dst_width);
const int fx_scale = (1 << RFIX) / dst_width; const int fx_scale = (1 << RFIX) / dst_width;
int x_in = 0; int x_in = 0;
@ -429,22 +429,22 @@ static int WebPMemoryWrite(const uint8_t* data, size_t data_size,
enum { YUV_FRAC = 16 }; 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); v = (v + (257 << (YUV_FRAC + 2 - 1))) >> (YUV_FRAC + 2);
return ((v & ~0xff) == 0) ? v : (v < 0) ? 0 : 255; 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 kRound = (1 << (YUV_FRAC - 1)) + (16 << YUV_FRAC);
const int luma = 16839 * r + 33059 * g + 6420 * b; const int luma = 16839 * r + 33059 * g + 6420 * b;
return (luma + kRound) >> YUV_FRAC; // no need to clip 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); 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); return clip_uv(+28800 * r - 24116 * g - 4684 * b);
} }

View File

@ -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; return v < m ? m : v > M ? M : v;
} }
@ -406,13 +406,13 @@ typedef struct {
#define NUM_NODES (MIN_DELTA + 1 + MAX_DELTA) #define NUM_NODES (MIN_DELTA + 1 + MAX_DELTA)
#define NODE(n, l) (nodes[(n) + 1][(l) + MIN_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? // TODO: incorporate the "* 256" in the tables?
rd->score = rd->R * lambda + 256 * (rd->D + rd->SD); rd->score = rd->R * lambda + 256 * (rd->D + rd->SD);
} }
static inline score_t RDScoreTrellis(int lambda, score_t rate, static WEBP_INLINE score_t RDScoreTrellis(int lambda, score_t rate,
score_t distortion) { score_t distortion) {
return rate * lambda + 256 * distortion; return rate * lambda + 256 * distortion;
} }

View File

@ -157,7 +157,7 @@ typedef int64_t score_t; // type used for scores, rate, distortion
#define BIAS(b) ((b) << (QFIX - 8)) #define BIAS(b) ((b) << (QFIX - 8))
// Fun fact: this is the _only_ line where we're actually being lossy and // Fun fact: this is the _only_ line where we're actually being lossy and
// discarding bits. // 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; return (n * iQ + B) >> QFIX;
} }
extern const uint8_t VP8Zigzag[16]; extern const uint8_t VP8Zigzag[16];

View File

@ -40,7 +40,7 @@ void VP8InitBitReader(VP8BitReader* const br,
// return the next value made of 'num_bits' bits // return the next value made of 'num_bits' bits
uint32_t VP8GetValue(VP8BitReader* const br, int num_bits); uint32_t VP8GetValue(VP8BitReader* const br, int num_bits);
static inline uint32_t VP8Get(VP8BitReader* const br) { static WEBP_INLINE uint32_t VP8Get(VP8BitReader* const br) {
return VP8GetValue(br, 1); return VP8GetValue(br, 1);
} }
@ -50,7 +50,7 @@ int32_t VP8GetSignedValue(VP8BitReader* const br, int num_bits);
// Read a bit with proba 'prob'. Speed-critical function! // Read a bit with proba 'prob'. Speed-critical function!
extern const uint8_t kVP8Log2Range[128]; extern const uint8_t kVP8Log2Range[128];
extern const uint8_t kVP8NewRange[128]; extern const uint8_t kVP8NewRange[128];
static inline uint32_t VP8GetByte(VP8BitReader* const br) { static WEBP_INLINE uint32_t VP8GetByte(VP8BitReader* const br) {
assert(br); assert(br);
if (br->buf_ < br->buf_end_) { if (br->buf_ < br->buf_end_) {
assert(br->buf_); assert(br->buf_);
@ -60,7 +60,8 @@ static inline uint32_t VP8GetByte(VP8BitReader* const br) {
return 0xff; return 0xff;
} }
static inline uint32_t VP8BitUpdate(VP8BitReader* const br, uint32_t split) { static WEBP_INLINE uint32_t VP8BitUpdate(
VP8BitReader* const br, uint32_t split) {
uint32_t bit; uint32_t bit;
const uint32_t value_split = (split + 1) << 8; const uint32_t value_split = (split + 1) << 8;
// Make sure we have a least 8 bits in 'value_' // Make sure we have a least 8 bits in 'value_'
@ -78,7 +79,7 @@ static inline uint32_t VP8BitUpdate(VP8BitReader* const br, uint32_t split) {
return bit; return bit;
} }
static inline void VP8Shift(VP8BitReader* const br) { static WEBP_INLINE void VP8Shift(VP8BitReader* const br) {
// range_ is in [0..127] interval here. // range_ is in [0..127] interval here.
const int shift = kVP8Log2Range[br->range_]; const int shift = kVP8Log2Range[br->range_];
br->range_ = kVP8NewRange[br->range_]; br->range_ = kVP8NewRange[br->range_];
@ -86,7 +87,7 @@ static inline void VP8Shift(VP8BitReader* const br) {
br->missing_ += shift; br->missing_ += shift;
} }
static inline uint32_t VP8GetBit(VP8BitReader* const br, int prob) { static WEBP_INLINE uint32_t VP8GetBit(VP8BitReader* const br, int prob) {
const uint32_t split = (br->range_ * prob) >> 8; const uint32_t split = (br->range_ * prob) >> 8;
const uint32_t bit = VP8BitUpdate(br, split); const uint32_t bit = VP8BitUpdate(br, split);
if (br->range_ < 0x7f) { if (br->range_ < 0x7f) {
@ -95,7 +96,7 @@ static inline uint32_t VP8GetBit(VP8BitReader* const br, int prob) {
return bit; return bit;
} }
static inline int VP8GetSigned(VP8BitReader* const br, int v) { static WEBP_INLINE int VP8GetSigned(VP8BitReader* const br, int v) {
const uint32_t split = br->range_ >> 1; const uint32_t split = br->range_ >> 1;
const uint32_t bit = VP8BitUpdate(br, split); const uint32_t bit = VP8BitUpdate(br, split);
VP8Shift(br); VP8Shift(br);

View File

@ -43,14 +43,14 @@ int VP8BitWriterAppend(VP8BitWriter* const bw,
const uint8_t* data, size_t size); const uint8_t* data, size_t size);
// return approximate write position (in bits) // return approximate write position (in bits)
static inline uint64_t VP8BitWriterPos(const VP8BitWriter* const bw) { static WEBP_INLINE uint64_t VP8BitWriterPos(const VP8BitWriter* const bw) {
return (uint64_t)(bw->pos_ + bw->run_) * 8 + 8 + bw->nb_bits_; return (uint64_t)(bw->pos_ + bw->run_) * 8 + 8 + bw->nb_bits_;
} }
static inline uint8_t* VP8BitWriterBuf(const VP8BitWriter* const bw) { static WEBP_INLINE uint8_t* VP8BitWriterBuf(const VP8BitWriter* const bw) {
return bw->buf_; return bw->buf_;
} }
static inline size_t VP8BitWriterSize(const VP8BitWriter* const bw) { static WEBP_INLINE size_t VP8BitWriterSize(const VP8BitWriter* const bw) {
return bw->pos_; return bw->pos_;
} }

View File

@ -154,7 +154,7 @@ WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer* const, int);
// Initialize the structure as empty. Must be called before any other use. // Initialize the structure as empty. Must be called before any other use.
// Returns false in case of version mismatch // Returns false in case of version mismatch
static inline int WebPInitDecBuffer(WebPDecBuffer* const buffer) { static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* const buffer) {
return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION); return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION);
} }
@ -332,9 +332,9 @@ WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal(
// with information gathered from the bitstream. // with information gathered from the bitstream.
// Returns false in case of error or version mismatch. // Returns false in case of error or version mismatch.
// In case of error, features->bitstream_status will reflect the error code. // In case of error, features->bitstream_status will reflect the error code.
static inline static WEBP_INLINE VP8StatusCode WebPGetFeatures(
VP8StatusCode WebPGetFeatures(const uint8_t* data, uint32_t data_size, const uint8_t* data, uint32_t data_size,
WebPBitstreamFeatures* const features) { WebPBitstreamFeatures* const features) {
return WebPGetFeaturesInternal(data, data_size, features, return WebPGetFeaturesInternal(data, data_size, features,
WEBP_DECODER_ABI_VERSION); WEBP_DECODER_ABI_VERSION);
} }
@ -367,7 +367,7 @@ WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig* const, int);
// Initialize the configuration as empty. This function must always be // Initialize the configuration as empty. This function must always be
// called first, unless WebPGetFeatures() is to be called. // called first, unless WebPGetFeatures() is to be called.
// Returns false in case of mismatched version. // Returns false in case of mismatched version.
static inline int WebPInitDecoderConfig(WebPDecoderConfig* const config) { static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* const config) {
return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION); return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION);
} }

View File

@ -124,7 +124,7 @@ WEBP_EXTERN(VP8Decoder*) VP8New(void);
// Must be called to make sure 'io' is initialized properly. // Must be called to make sure 'io' is initialized properly.
// Returns false in case of version mismatch. Upon such failure, no other // Returns false in case of version mismatch. Upon such failure, no other
// decoding function should be called (VP8Decode, VP8GetHeaders, ...) // decoding function should be called (VP8Decode, VP8GetHeaders, ...)
static inline int VP8InitIo(VP8Io* const io) { static WEBP_INLINE int VP8InitIo(VP8Io* const io) {
return VP8InitIoInternal(io, WEBP_DECODER_ABI_VERSION); return VP8InitIoInternal(io, WEBP_DECODER_ABI_VERSION);
} }

View File

@ -92,7 +92,7 @@ WEBP_EXTERN(int) WebPConfigInitInternal(
// Should always be called, to initialize a fresh WebPConfig structure before // Should always be called, to initialize a fresh WebPConfig structure before
// modification. Returns 0 in case of version mismatch. WebPConfigInit() must // modification. Returns 0 in case of version mismatch. WebPConfigInit() must
// have succeeded before using the 'config' object. // have succeeded before using the 'config' object.
static inline int WebPConfigInit(WebPConfig* const config) { static WEBP_INLINE int WebPConfigInit(WebPConfig* const config) {
return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f, return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f,
WEBP_ENCODER_ABI_VERSION); WEBP_ENCODER_ABI_VERSION);
} }
@ -101,8 +101,8 @@ static inline int WebPConfigInit(WebPConfig* const config) {
// set of parameters (referred to by 'preset') and a given quality factor. // set of parameters (referred to by 'preset') and a given quality factor.
// This function can be called as a replacement to WebPConfigInit(). Will // This function can be called as a replacement to WebPConfigInit(). Will
// return 0 in case of error. // return 0 in case of error.
static inline int WebPConfigPreset(WebPConfig* const config, static WEBP_INLINE int WebPConfigPreset(WebPConfig* const config,
WebPPreset preset, float quality) { WebPPreset preset, float quality) {
return WebPConfigInitInternal(config, preset, quality, return WebPConfigInitInternal(config, preset, quality,
WEBP_ENCODER_ABI_VERSION); WEBP_ENCODER_ABI_VERSION);
} }
@ -209,7 +209,7 @@ WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture* const, int);
// Should always be called, to initialize the structure. Returns 0 in case of // Should always be called, to initialize the structure. Returns 0 in case of
// version mismatch. WebPPictureInit() must have succeeded before using the // version mismatch. WebPPictureInit() must have succeeded before using the
// 'picture' object. // 'picture' object.
static inline int WebPPictureInit(WebPPicture* const picture) { static WEBP_INLINE int WebPPictureInit(WebPPicture* const picture) {
return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION); return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION);
} }

View File

@ -14,9 +14,11 @@
#ifndef _MSC_VER #ifndef _MSC_VER
#include <inttypes.h> #include <inttypes.h>
#ifdef ANSI #ifdef __STRICT_ANSI__
#define inline #define WEBP_INLINE
#endif /* ANSI */ #else /* __STRICT_ANSI__ */
#define WEBP_INLINE inline
#endif
#else #else
typedef signed char int8_t; typedef signed char int8_t;
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
@ -26,7 +28,7 @@ typedef signed int int32_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t; typedef unsigned long long int uint64_t;
typedef long long int int64_t; typedef long long int int64_t;
#define inline __forceinline #define WEBP_INLINE __forceinline
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#ifndef WEBP_EXTERN #ifndef WEBP_EXTERN