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 // YUV to RGB upsampling functions. | 10 // YUV to RGB upsampling functions. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 return WebPUpsamplers[alpha_is_last ? MODE_BGRA : MODE_ARGB]; | 146 return WebPUpsamplers[alpha_is_last ? MODE_BGRA : MODE_ARGB]; |
147 #else | 147 #else |
148 return (alpha_is_last ? DualLineSamplerBGRA : DualLineSamplerARGB); | 148 return (alpha_is_last ? DualLineSamplerBGRA : DualLineSamplerARGB); |
149 #endif | 149 #endif |
150 } | 150 } |
151 | 151 |
152 //------------------------------------------------------------------------------ | 152 //------------------------------------------------------------------------------ |
153 // YUV444 converter | 153 // YUV444 converter |
154 | 154 |
155 #define YUV444_FUNC(FUNC_NAME, FUNC, XSTEP) \ | 155 #define YUV444_FUNC(FUNC_NAME, FUNC, XSTEP) \ |
156 static void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \ | 156 extern void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \ |
157 uint8_t* dst, int len) { \ | 157 uint8_t* dst, int len); \ |
| 158 void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \ |
| 159 uint8_t* dst, int len) { \ |
158 int i; \ | 160 int i; \ |
159 for (i = 0; i < len; ++i) FUNC(y[i], u[i], v[i], &dst[i * XSTEP]); \ | 161 for (i = 0; i < len; ++i) FUNC(y[i], u[i], v[i], &dst[i * XSTEP]); \ |
160 } | 162 } |
161 | 163 |
162 YUV444_FUNC(Yuv444ToRgb, VP8YuvToRgb, 3) | 164 YUV444_FUNC(WebPYuv444ToRgbC, VP8YuvToRgb, 3) |
163 YUV444_FUNC(Yuv444ToBgr, VP8YuvToBgr, 3) | 165 YUV444_FUNC(WebPYuv444ToBgrC, VP8YuvToBgr, 3) |
164 YUV444_FUNC(Yuv444ToRgba, VP8YuvToRgba, 4) | 166 YUV444_FUNC(WebPYuv444ToRgbaC, VP8YuvToRgba, 4) |
165 YUV444_FUNC(Yuv444ToBgra, VP8YuvToBgra, 4) | 167 YUV444_FUNC(WebPYuv444ToBgraC, VP8YuvToBgra, 4) |
166 YUV444_FUNC(Yuv444ToArgb, VP8YuvToArgb, 4) | 168 YUV444_FUNC(WebPYuv444ToArgbC, VP8YuvToArgb, 4) |
167 YUV444_FUNC(Yuv444ToRgba4444, VP8YuvToRgba4444, 2) | 169 YUV444_FUNC(WebPYuv444ToRgba4444C, VP8YuvToRgba4444, 2) |
168 YUV444_FUNC(Yuv444ToRgb565, VP8YuvToRgb565, 2) | 170 YUV444_FUNC(WebPYuv444ToRgb565C, VP8YuvToRgb565, 2) |
169 | 171 |
170 #undef YUV444_FUNC | 172 #undef YUV444_FUNC |
171 | 173 |
172 const WebPYUV444Converter WebPYUV444Converters[MODE_LAST] = { | 174 WebPYUV444Converter WebPYUV444Converters[MODE_LAST]; |
173 Yuv444ToRgb, // MODE_RGB | 175 |
174 Yuv444ToRgba, // MODE_RGBA | 176 extern void WebPInitYUV444ConvertersMIPSdspR2(void); |
175 Yuv444ToBgr, // MODE_BGR | 177 extern void WebPInitYUV444ConvertersSSE2(void); |
176 Yuv444ToBgra, // MODE_BGRA | 178 |
177 Yuv444ToArgb, // MODE_ARGB | 179 static volatile VP8CPUInfo upsampling_last_cpuinfo_used1 = |
178 Yuv444ToRgba4444, // MODE_RGBA_4444 | 180 (VP8CPUInfo)&upsampling_last_cpuinfo_used1; |
179 Yuv444ToRgb565, // MODE_RGB_565 | 181 |
180 Yuv444ToRgba, // MODE_rgbA | 182 WEBP_TSAN_IGNORE_FUNCTION void WebPInitYUV444Converters(void) { |
181 Yuv444ToBgra, // MODE_bgrA | 183 if (upsampling_last_cpuinfo_used1 == VP8GetCPUInfo) return; |
182 Yuv444ToArgb, // MODE_Argb | 184 |
183 Yuv444ToRgba4444 // MODE_rgbA_4444 | 185 WebPYUV444Converters[MODE_RGB] = WebPYuv444ToRgbC; |
184 }; | 186 WebPYUV444Converters[MODE_RGBA] = WebPYuv444ToRgbaC; |
| 187 WebPYUV444Converters[MODE_BGR] = WebPYuv444ToBgrC; |
| 188 WebPYUV444Converters[MODE_BGRA] = WebPYuv444ToBgraC; |
| 189 WebPYUV444Converters[MODE_ARGB] = WebPYuv444ToArgbC; |
| 190 WebPYUV444Converters[MODE_RGBA_4444] = WebPYuv444ToRgba4444C; |
| 191 WebPYUV444Converters[MODE_RGB_565] = WebPYuv444ToRgb565C; |
| 192 WebPYUV444Converters[MODE_rgbA] = WebPYuv444ToRgbaC; |
| 193 WebPYUV444Converters[MODE_bgrA] = WebPYuv444ToBgraC; |
| 194 WebPYUV444Converters[MODE_Argb] = WebPYuv444ToArgbC; |
| 195 WebPYUV444Converters[MODE_rgbA_4444] = WebPYuv444ToRgba4444C; |
| 196 |
| 197 if (VP8GetCPUInfo != NULL) { |
| 198 #if defined(WEBP_USE_SSE2) |
| 199 if (VP8GetCPUInfo(kSSE2)) { |
| 200 WebPInitYUV444ConvertersSSE2(); |
| 201 } |
| 202 #endif |
| 203 #if defined(WEBP_USE_MIPS_DSP_R2) |
| 204 if (VP8GetCPUInfo(kMIPSdspR2)) { |
| 205 WebPInitYUV444ConvertersMIPSdspR2(); |
| 206 } |
| 207 #endif |
| 208 } |
| 209 upsampling_last_cpuinfo_used1 = VP8GetCPUInfo; |
| 210 } |
185 | 211 |
186 //------------------------------------------------------------------------------ | 212 //------------------------------------------------------------------------------ |
187 // Main calls | 213 // Main calls |
188 | 214 |
189 extern void WebPInitUpsamplersSSE2(void); | 215 extern void WebPInitUpsamplersSSE2(void); |
190 extern void WebPInitUpsamplersNEON(void); | 216 extern void WebPInitUpsamplersNEON(void); |
| 217 extern void WebPInitUpsamplersMIPSdspR2(void); |
191 | 218 |
192 static volatile VP8CPUInfo upsampling_last_cpuinfo_used2 = | 219 static volatile VP8CPUInfo upsampling_last_cpuinfo_used2 = |
193 (VP8CPUInfo)&upsampling_last_cpuinfo_used2; | 220 (VP8CPUInfo)&upsampling_last_cpuinfo_used2; |
194 | 221 |
195 void WebPInitUpsamplers(void) { | 222 WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplers(void) { |
196 if (upsampling_last_cpuinfo_used2 == VP8GetCPUInfo) return; | 223 if (upsampling_last_cpuinfo_used2 == VP8GetCPUInfo) return; |
197 | 224 |
198 #ifdef FANCY_UPSAMPLING | 225 #ifdef FANCY_UPSAMPLING |
199 WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair; | 226 WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair; |
200 WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair; | 227 WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair; |
201 WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair; | 228 WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair; |
202 WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair; | 229 WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair; |
203 WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair; | 230 WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair; |
204 WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair; | 231 WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair; |
205 WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair; | 232 WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair; |
206 WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair; | 233 WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair; |
207 WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair; | 234 WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair; |
208 WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair; | 235 WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair; |
209 WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair; | 236 WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair; |
210 | 237 |
211 // If defined, use CPUInfo() to overwrite some pointers with faster versions. | 238 // If defined, use CPUInfo() to overwrite some pointers with faster versions. |
212 if (VP8GetCPUInfo != NULL) { | 239 if (VP8GetCPUInfo != NULL) { |
213 #if defined(WEBP_USE_SSE2) | 240 #if defined(WEBP_USE_SSE2) |
214 if (VP8GetCPUInfo(kSSE2)) { | 241 if (VP8GetCPUInfo(kSSE2)) { |
215 WebPInitUpsamplersSSE2(); | 242 WebPInitUpsamplersSSE2(); |
216 } | 243 } |
217 #endif | 244 #endif |
218 #if defined(WEBP_USE_NEON) | 245 #if defined(WEBP_USE_NEON) |
219 if (VP8GetCPUInfo(kNEON)) { | 246 if (VP8GetCPUInfo(kNEON)) { |
220 WebPInitUpsamplersNEON(); | 247 WebPInitUpsamplersNEON(); |
221 } | 248 } |
222 #endif | 249 #endif |
| 250 #if defined(WEBP_USE_MIPS_DSP_R2) |
| 251 if (VP8GetCPUInfo(kMIPSdspR2)) { |
| 252 WebPInitUpsamplersMIPSdspR2(); |
| 253 } |
| 254 #endif |
223 } | 255 } |
224 #endif // FANCY_UPSAMPLING | 256 #endif // FANCY_UPSAMPLING |
225 upsampling_last_cpuinfo_used2 = VP8GetCPUInfo; | 257 upsampling_last_cpuinfo_used2 = VP8GetCPUInfo; |
226 } | 258 } |
227 | 259 |
228 //------------------------------------------------------------------------------ | 260 //------------------------------------------------------------------------------ |
OLD | NEW |