| 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. |
| 11 // | 11 // |
| 12 // Author: Skal (pascal.massimino@gmail.com) | 12 // Author: Skal (pascal.massimino@gmail.com) |
| 13 | 13 |
| 14 #ifndef WEBP_DSP_DSP_H_ | 14 #ifndef WEBP_DSP_DSP_H_ |
| 15 #define WEBP_DSP_DSP_H_ | 15 #define WEBP_DSP_DSP_H_ |
| 16 | 16 |
| 17 #include "../webp/types.h" | 17 #include "../webp/types.h" |
| 18 | 18 |
| 19 #if defined(__cplusplus) || defined(c_plusplus) | 19 #ifdef __cplusplus |
| 20 extern "C" { | 20 extern "C" { |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 //------------------------------------------------------------------------------ | 23 //------------------------------------------------------------------------------ |
| 24 // CPU detection | 24 // CPU detection |
| 25 | 25 |
| 26 #if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) | 26 #if defined(_MSC_VER) && _MSC_VER > 1310 && \ |
| 27 (defined(_M_X64) || defined(_M_IX86)) |
| 27 #define WEBP_MSC_SSE2 // Visual C++ SSE2 targets | 28 #define WEBP_MSC_SSE2 // Visual C++ SSE2 targets |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 #if defined(__SSE2__) || defined(WEBP_MSC_SSE2) | 31 #if defined(__SSE2__) || defined(WEBP_MSC_SSE2) |
| 31 #define WEBP_USE_SSE2 | 32 #define WEBP_USE_SSE2 |
| 32 #endif | 33 #endif |
| 33 | 34 |
| 34 #if defined(__ANDROID__) && defined(__ARM_ARCH_7A__) | 35 #if defined(__ANDROID__) && defined(__ARM_ARCH_7A__) |
| 35 #define WEBP_ANDROID_NEON // Android targets that might support NEON | 36 #define WEBP_ANDROID_NEON // Android targets that might support NEON |
| 36 #endif | 37 #endif |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 extern VP8WMetric VP8TDisto4x4, VP8TDisto16x16; | 79 extern VP8WMetric VP8TDisto4x4, VP8TDisto16x16; |
| 79 | 80 |
| 80 typedef void (*VP8BlockCopy)(const uint8_t* src, uint8_t* dst); | 81 typedef void (*VP8BlockCopy)(const uint8_t* src, uint8_t* dst); |
| 81 extern VP8BlockCopy VP8Copy4x4; | 82 extern VP8BlockCopy VP8Copy4x4; |
| 82 // Quantization | 83 // Quantization |
| 83 struct VP8Matrix; // forward declaration | 84 struct VP8Matrix; // forward declaration |
| 84 typedef int (*VP8QuantizeBlock)(int16_t in[16], int16_t out[16], | 85 typedef int (*VP8QuantizeBlock)(int16_t in[16], int16_t out[16], |
| 85 int n, const struct VP8Matrix* const mtx); | 86 int n, const struct VP8Matrix* const mtx); |
| 86 extern VP8QuantizeBlock VP8EncQuantizeBlock; | 87 extern VP8QuantizeBlock VP8EncQuantizeBlock; |
| 87 | 88 |
| 89 // specific to 2nd transform: |
| 90 typedef int (*VP8QuantizeBlockWHT)(int16_t in[16], int16_t out[16], |
| 91 const struct VP8Matrix* const mtx); |
| 92 extern VP8QuantizeBlockWHT VP8EncQuantizeBlockWHT; |
| 93 |
| 88 // Collect histogram for susceptibility calculation and accumulate in histo[]. | 94 // Collect histogram for susceptibility calculation and accumulate in histo[]. |
| 89 struct VP8Histogram; | 95 struct VP8Histogram; |
| 90 typedef void (*VP8CHisto)(const uint8_t* ref, const uint8_t* pred, | 96 typedef void (*VP8CHisto)(const uint8_t* ref, const uint8_t* pred, |
| 91 int start_block, int end_block, | 97 int start_block, int end_block, |
| 92 struct VP8Histogram* const histo); | 98 struct VP8Histogram* const histo); |
| 93 extern const int VP8DspScan[16 + 4 + 4]; | 99 extern const int VP8DspScan[16 + 4 + 4]; |
| 94 extern VP8CHisto VP8CollectHistogram; | 100 extern VP8CHisto VP8CollectHistogram; |
| 95 | 101 |
| 96 void VP8EncDspInit(void); // must be called before using any of the above | 102 void VP8EncDspInit(void); // must be called before using any of the above |
| 97 | 103 |
| 98 //------------------------------------------------------------------------------ | 104 //------------------------------------------------------------------------------ |
| 99 // Decoding | 105 // Decoding |
| 100 | 106 |
| 101 typedef void (*VP8DecIdct)(const int16_t* coeffs, uint8_t* dst); | 107 typedef void (*VP8DecIdct)(const int16_t* coeffs, uint8_t* dst); |
| 102 // when doing two transforms, coeffs is actually int16_t[2][16]. | 108 // when doing two transforms, coeffs is actually int16_t[2][16]. |
| 103 typedef void (*VP8DecIdct2)(const int16_t* coeffs, uint8_t* dst, int do_two); | 109 typedef void (*VP8DecIdct2)(const int16_t* coeffs, uint8_t* dst, int do_two); |
| 104 extern VP8DecIdct2 VP8Transform; | 110 extern VP8DecIdct2 VP8Transform; |
| 111 extern VP8DecIdct VP8TransformAC3; |
| 105 extern VP8DecIdct VP8TransformUV; | 112 extern VP8DecIdct VP8TransformUV; |
| 106 extern VP8DecIdct VP8TransformDC; | 113 extern VP8DecIdct VP8TransformDC; |
| 107 extern VP8DecIdct VP8TransformDCUV; | 114 extern VP8DecIdct VP8TransformDCUV; |
| 108 extern VP8WHT VP8TransformWHT; | 115 extern VP8WHT VP8TransformWHT; |
| 109 | 116 |
| 110 // *dst is the destination block, with stride BPS. Boundary samples are | 117 // *dst is the destination block, with stride BPS. Boundary samples are |
| 111 // assumed accessible when needed. | 118 // assumed accessible when needed. |
| 112 typedef void (*VP8PredFunc)(uint8_t* dst); | 119 typedef void (*VP8PredFunc)(uint8_t* dst); |
| 113 extern const VP8PredFunc VP8PredLuma16[/* NUM_B_DC_MODES */]; | 120 extern const VP8PredFunc VP8PredLuma16[/* NUM_B_DC_MODES */]; |
| 114 extern const VP8PredFunc VP8PredChroma8[/* NUM_B_DC_MODES */]; | 121 extern const VP8PredFunc VP8PredChroma8[/* NUM_B_DC_MODES */]; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 139 extern VP8ChromaFilterFunc VP8HFilter8i; | 146 extern VP8ChromaFilterFunc VP8HFilter8i; |
| 140 | 147 |
| 141 // must be called before anything using the above | 148 // must be called before anything using the above |
| 142 void VP8DspInit(void); | 149 void VP8DspInit(void); |
| 143 | 150 |
| 144 //------------------------------------------------------------------------------ | 151 //------------------------------------------------------------------------------ |
| 145 // WebP I/O | 152 // WebP I/O |
| 146 | 153 |
| 147 #define FANCY_UPSAMPLING // undefined to remove fancy upsampling support | 154 #define FANCY_UPSAMPLING // undefined to remove fancy upsampling support |
| 148 | 155 |
| 156 // Convert a pair of y/u/v lines together to the output rgb/a colorspace. |
| 157 // bottom_y can be NULL if only one line of output is needed (at top/bottom). |
| 149 typedef void (*WebPUpsampleLinePairFunc)( | 158 typedef void (*WebPUpsampleLinePairFunc)( |
| 150 const uint8_t* top_y, const uint8_t* bottom_y, | 159 const uint8_t* top_y, const uint8_t* bottom_y, |
| 151 const uint8_t* top_u, const uint8_t* top_v, | 160 const uint8_t* top_u, const uint8_t* top_v, |
| 152 const uint8_t* cur_u, const uint8_t* cur_v, | 161 const uint8_t* cur_u, const uint8_t* cur_v, |
| 153 uint8_t* top_dst, uint8_t* bottom_dst, int len); | 162 uint8_t* top_dst, uint8_t* bottom_dst, int len); |
| 154 | 163 |
| 155 #ifdef FANCY_UPSAMPLING | 164 #ifdef FANCY_UPSAMPLING |
| 156 | 165 |
| 157 // Fancy upsampling functions to convert YUV to RGB(A) modes | 166 // Fancy upsampling functions to convert YUV to RGB(A) modes |
| 158 extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */]; | 167 extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */]; |
| 159 | 168 |
| 160 // Initializes SSE2 version of the fancy upsamplers. | 169 // Initializes SSE2 version of the fancy upsamplers. |
| 161 void WebPInitUpsamplersSSE2(void); | 170 void WebPInitUpsamplersSSE2(void); |
| 162 | 171 |
| 163 #if defined(WEBP_USE_NEON) | |
| 164 // NEON version | 172 // NEON version |
| 165 void WebPInitUpsamplersNEON(void); | 173 void WebPInitUpsamplersNEON(void); |
| 166 #endif | |
| 167 | 174 |
| 168 #endif // FANCY_UPSAMPLING | 175 #endif // FANCY_UPSAMPLING |
| 169 | 176 |
| 170 // Point-sampling methods. | 177 // Point-sampling methods. |
| 171 typedef void (*WebPSampleLinePairFunc)( | 178 typedef void (*WebPSampleLinePairFunc)( |
| 172 const uint8_t* top_y, const uint8_t* bottom_y, | 179 const uint8_t* top_y, const uint8_t* bottom_y, |
| 173 const uint8_t* u, const uint8_t* v, | 180 const uint8_t* u, const uint8_t* v, |
| 174 uint8_t* top_dst, uint8_t* bottom_dst, int len); | 181 uint8_t* top_dst, uint8_t* bottom_dst, int len); |
| 175 | 182 |
| 176 extern const WebPSampleLinePairFunc WebPSamplers[/* MODE_LAST */]; | 183 extern const WebPSampleLinePairFunc WebPSamplers[/* MODE_LAST */]; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 199 uint8_t* rgba, int alpha_first, int w, int h, int stride); | 206 uint8_t* rgba, int alpha_first, int w, int h, int stride); |
| 200 | 207 |
| 201 // Same, buf specifically for RGBA4444 format | 208 // Same, buf specifically for RGBA4444 format |
| 202 extern void (*WebPApplyAlphaMultiply4444)( | 209 extern void (*WebPApplyAlphaMultiply4444)( |
| 203 uint8_t* rgba4444, int w, int h, int stride); | 210 uint8_t* rgba4444, int w, int h, int stride); |
| 204 | 211 |
| 205 // To be called first before using the above. | 212 // To be called first before using the above. |
| 206 void WebPInitPremultiply(void); | 213 void WebPInitPremultiply(void); |
| 207 | 214 |
| 208 void WebPInitPremultiplySSE2(void); // should not be called directly. | 215 void WebPInitPremultiplySSE2(void); // should not be called directly. |
| 209 | |
| 210 #if defined(WEBP_USE_NEON) | |
| 211 void WebPInitPremultiplyNEON(void); | 216 void WebPInitPremultiplyNEON(void); |
| 212 #endif | |
| 213 | 217 |
| 214 //------------------------------------------------------------------------------ | 218 //------------------------------------------------------------------------------ |
| 215 | 219 |
| 216 #if defined(__cplusplus) || defined(c_plusplus) | 220 #ifdef __cplusplus |
| 217 } // extern "C" | 221 } // extern "C" |
| 218 #endif | 222 #endif |
| 219 | 223 |
| 220 #endif /* WEBP_DSP_DSP_H_ */ | 224 #endif /* WEBP_DSP_DSP_H_ */ |
| OLD | NEW |