OLD | NEW |
1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
4 // that can be found in the COPYING file in the root of the source | 4 // that can be found in the COPYING file in the root of the source |
5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
9 // | 9 // |
10 // Speed-critical functions. | 10 // Speed-critical functions. |
(...skipping 14 matching lines...) Expand all Loading... |
25 #endif | 25 #endif |
26 | 26 |
27 //------------------------------------------------------------------------------ | 27 //------------------------------------------------------------------------------ |
28 // CPU detection | 28 // CPU detection |
29 | 29 |
30 #if defined(__GNUC__) | 30 #if defined(__GNUC__) |
31 # define LOCAL_GCC_VERSION ((__GNUC__ << 8) | __GNUC_MINOR__) | 31 # define LOCAL_GCC_VERSION ((__GNUC__ << 8) | __GNUC_MINOR__) |
32 # define LOCAL_GCC_PREREQ(maj, min) \ | 32 # define LOCAL_GCC_PREREQ(maj, min) \ |
33 (LOCAL_GCC_VERSION >= (((maj) << 8) | (min))) | 33 (LOCAL_GCC_VERSION >= (((maj) << 8) | (min))) |
34 #else | 34 #else |
| 35 # define LOCAL_GCC_VERSION 0 |
35 # define LOCAL_GCC_PREREQ(maj, min) 0 | 36 # define LOCAL_GCC_PREREQ(maj, min) 0 |
36 #endif | 37 #endif |
37 | 38 |
| 39 #ifdef __clang__ |
| 40 # define LOCAL_CLANG_VERSION ((__clang_major__ << 8) | __clang_minor__) |
| 41 # define LOCAL_CLANG_PREREQ(maj, min) \ |
| 42 (LOCAL_CLANG_VERSION >= (((maj) << 8) | (min))) |
| 43 #else |
| 44 # define LOCAL_CLANG_VERSION 0 |
| 45 # define LOCAL_CLANG_PREREQ(maj, min) 0 |
| 46 #endif // __clang__ |
| 47 |
38 #if defined(_MSC_VER) && _MSC_VER > 1310 && \ | 48 #if defined(_MSC_VER) && _MSC_VER > 1310 && \ |
39 (defined(_M_X64) || defined(_M_IX86)) | 49 (defined(_M_X64) || defined(_M_IX86)) |
40 #define WEBP_MSC_SSE2 // Visual C++ SSE2 targets | 50 #define WEBP_MSC_SSE2 // Visual C++ SSE2 targets |
41 #endif | 51 #endif |
42 | 52 |
43 // WEBP_HAVE_* are used to indicate the presence of the instruction set in dsp | 53 // WEBP_HAVE_* are used to indicate the presence of the instruction set in dsp |
44 // files without intrinsics, allowing the corresponding Init() to be called. | 54 // files without intrinsics, allowing the corresponding Init() to be called. |
45 // Files containing intrinsics will need to be built targeting the instruction | 55 // Files containing intrinsics will need to be built targeting the instruction |
46 // set so should succeed on one of the earlier tests. | 56 // set so should succeed on one of the earlier tests. |
47 #if defined(__SSE2__) || defined(WEBP_MSC_SSE2) || defined(WEBP_HAVE_SSE2) | 57 #if defined(__SSE2__) || defined(WEBP_MSC_SSE2) || defined(WEBP_HAVE_SSE2) |
48 #define WEBP_USE_SSE2 | 58 #define WEBP_USE_SSE2 |
49 #endif | 59 #endif |
50 | 60 |
51 #if defined(__AVX2__) || defined(WEBP_HAVE_AVX2) | 61 #if defined(__AVX2__) || defined(WEBP_HAVE_AVX2) |
52 #define WEBP_USE_AVX2 | 62 #define WEBP_USE_AVX2 |
53 #endif | 63 #endif |
54 | 64 |
55 #if defined(__ANDROID__) && defined(__ARM_ARCH_7A__) | 65 #if defined(__ANDROID__) && defined(__ARM_ARCH_7A__) |
56 #define WEBP_ANDROID_NEON // Android targets that might support NEON | 66 #define WEBP_ANDROID_NEON // Android targets that might support NEON |
57 #endif | 67 #endif |
58 | 68 |
59 #if defined(__ARM_NEON__) || defined(WEBP_ANDROID_NEON) || defined(__aarch64__) | 69 #if defined(__ARM_NEON__) || defined(WEBP_ANDROID_NEON) || defined(__aarch64__) |
60 #define WEBP_USE_NEON | 70 #define WEBP_USE_NEON |
61 #endif | 71 #endif |
62 | 72 |
63 #if defined(__mips__) && !defined(__mips64) && (__mips_isa_rev < 6) | 73 #if defined(__mips__) && !defined(__mips64) && (__mips_isa_rev < 6) |
64 #define WEBP_USE_MIPS32 | 74 #define WEBP_USE_MIPS32 |
| 75 #if (__mips_isa_rev >= 2) |
| 76 #define WEBP_USE_MIPS32_R2 |
| 77 #endif |
65 #endif | 78 #endif |
66 | 79 |
67 typedef enum { | 80 typedef enum { |
68 kSSE2, | 81 kSSE2, |
69 kSSE3, | 82 kSSE3, |
70 kAVX, | 83 kAVX, |
71 kAVX2, | 84 kAVX2, |
72 kNEON, | 85 kNEON, |
73 kMIPS32 | 86 kMIPS32 |
74 } CPUFeature; | 87 } CPUFeature; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 250 |
238 // Apply alpha pre-multiply on an rgba, bgra or argb plane of size w * h. | 251 // Apply alpha pre-multiply on an rgba, bgra or argb plane of size w * h. |
239 // alpha_first should be 0 for argb, 1 for rgba or bgra (where alpha is last). | 252 // alpha_first should be 0 for argb, 1 for rgba or bgra (where alpha is last). |
240 extern void (*WebPApplyAlphaMultiply)( | 253 extern void (*WebPApplyAlphaMultiply)( |
241 uint8_t* rgba, int alpha_first, int w, int h, int stride); | 254 uint8_t* rgba, int alpha_first, int w, int h, int stride); |
242 | 255 |
243 // Same, buf specifically for RGBA4444 format | 256 // Same, buf specifically for RGBA4444 format |
244 extern void (*WebPApplyAlphaMultiply4444)( | 257 extern void (*WebPApplyAlphaMultiply4444)( |
245 uint8_t* rgba4444, int w, int h, int stride); | 258 uint8_t* rgba4444, int w, int h, int stride); |
246 | 259 |
| 260 // Extract the alpha values from 32b values in argb[] and pack them into alpha[] |
| 261 // (this is the opposite of WebPDispatchAlpha). |
| 262 // Returns true if there's only trivial 0xff alpha values. |
| 263 extern int (*WebPExtractAlpha)(const uint8_t* argb, int argb_stride, |
| 264 int width, int height, |
| 265 uint8_t* alpha, int alpha_stride); |
| 266 |
247 // Pre-Multiply operation transforms x into x * A / 255 (where x=Y,R,G or B). | 267 // Pre-Multiply operation transforms x into x * A / 255 (where x=Y,R,G or B). |
248 // Un-Multiply operation transforms x into x * 255 / A. | 268 // Un-Multiply operation transforms x into x * 255 / A. |
249 | 269 |
250 // Pre-Multiply or Un-Multiply (if 'inverse' is true) argb values in a row. | 270 // Pre-Multiply or Un-Multiply (if 'inverse' is true) argb values in a row. |
251 extern void (*WebPMultARGBRow)(uint32_t* const ptr, int width, int inverse); | 271 extern void (*WebPMultARGBRow)(uint32_t* const ptr, int width, int inverse); |
252 | 272 |
253 // Same a WebPMultARGBRow(), but for several rows. | 273 // Same a WebPMultARGBRow(), but for several rows. |
254 void WebPMultARGBRows(uint8_t* ptr, int stride, int width, int num_rows, | 274 void WebPMultARGBRows(uint8_t* ptr, int stride, int width, int num_rows, |
255 int inverse); | 275 int inverse); |
256 | 276 |
257 // Same for a row of single values, with side alpha values. | 277 // Same for a row of single values, with side alpha values. |
258 extern void (*WebPMultRow)(uint8_t* const ptr, const uint8_t* const alpha, | 278 extern void (*WebPMultRow)(uint8_t* const ptr, const uint8_t* const alpha, |
259 int width, int inverse); | 279 int width, int inverse); |
260 | 280 |
261 // Same a WebPMultRow(), but for several 'num_rows' rows. | 281 // Same a WebPMultRow(), but for several 'num_rows' rows. |
262 void WebPMultRows(uint8_t* ptr, int stride, | 282 void WebPMultRows(uint8_t* ptr, int stride, |
263 const uint8_t* alpha, int alpha_stride, | 283 const uint8_t* alpha, int alpha_stride, |
264 int width, int num_rows, int inverse); | 284 int width, int num_rows, int inverse); |
265 | 285 |
266 // To be called first before using the above. | 286 // To be called first before using the above. |
267 void WebPInitAlphaProcessing(void); | 287 void WebPInitAlphaProcessing(void); |
268 | 288 |
269 #ifdef __cplusplus | 289 #ifdef __cplusplus |
270 } // extern "C" | 290 } // extern "C" |
271 #endif | 291 #endif |
272 | 292 |
273 #endif /* WEBP_DSP_DSP_H_ */ | 293 #endif /* WEBP_DSP_DSP_H_ */ |
OLD | NEW |