Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: third_party/libwebp/dsp/upsampling_sse2.c

Issue 1546003002: libwebp: update to 0.5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase around clang-cl fix Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // SSE2 version of YUV to RGB upsampling functions. 10 // SSE2 version of YUV to RGB upsampling functions.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 const __m128i t_b = _mm_avg_epu8(b, db); /* (3a + 9b + c + 3d + 8) / 16 */ \ 53 const __m128i t_b = _mm_avg_epu8(b, db); /* (3a + 9b + c + 3d + 8) / 16 */ \
54 const __m128i t_1 = _mm_unpacklo_epi8(t_a, t_b); \ 54 const __m128i t_1 = _mm_unpacklo_epi8(t_a, t_b); \
55 const __m128i t_2 = _mm_unpackhi_epi8(t_a, t_b); \ 55 const __m128i t_2 = _mm_unpackhi_epi8(t_a, t_b); \
56 _mm_store_si128(((__m128i*)(out)) + 0, t_1); \ 56 _mm_store_si128(((__m128i*)(out)) + 0, t_1); \
57 _mm_store_si128(((__m128i*)(out)) + 1, t_2); \ 57 _mm_store_si128(((__m128i*)(out)) + 1, t_2); \
58 } while (0) 58 } while (0)
59 59
60 // Loads 17 pixels each from rows r1 and r2 and generates 32 pixels. 60 // Loads 17 pixels each from rows r1 and r2 and generates 32 pixels.
61 #define UPSAMPLE_32PIXELS(r1, r2, out) { \ 61 #define UPSAMPLE_32PIXELS(r1, r2, out) { \
62 const __m128i one = _mm_set1_epi8(1); \ 62 const __m128i one = _mm_set1_epi8(1); \
63 const __m128i a = _mm_loadu_si128((__m128i*)&(r1)[0]); \ 63 const __m128i a = _mm_loadu_si128((const __m128i*)&(r1)[0]); \
64 const __m128i b = _mm_loadu_si128((__m128i*)&(r1)[1]); \ 64 const __m128i b = _mm_loadu_si128((const __m128i*)&(r1)[1]); \
65 const __m128i c = _mm_loadu_si128((__m128i*)&(r2)[0]); \ 65 const __m128i c = _mm_loadu_si128((const __m128i*)&(r2)[0]); \
66 const __m128i d = _mm_loadu_si128((__m128i*)&(r2)[1]); \ 66 const __m128i d = _mm_loadu_si128((const __m128i*)&(r2)[1]); \
67 \ 67 \
68 const __m128i s = _mm_avg_epu8(a, d); /* s = (a + d + 1) / 2 */ \ 68 const __m128i s = _mm_avg_epu8(a, d); /* s = (a + d + 1) / 2 */ \
69 const __m128i t = _mm_avg_epu8(b, c); /* t = (b + c + 1) / 2 */ \ 69 const __m128i t = _mm_avg_epu8(b, c); /* t = (b + c + 1) / 2 */ \
70 const __m128i st = _mm_xor_si128(s, t); /* st = s^t */ \ 70 const __m128i st = _mm_xor_si128(s, t); /* st = s^t */ \
71 \ 71 \
72 const __m128i ad = _mm_xor_si128(a, d); /* ad = a^d */ \ 72 const __m128i ad = _mm_xor_si128(a, d); /* ad = a^d */ \
73 const __m128i bc = _mm_xor_si128(b, c); /* bc = b^c */ \ 73 const __m128i bc = _mm_xor_si128(b, c); /* bc = b^c */ \
74 \ 74 \
75 const __m128i t1 = _mm_or_si128(ad, bc); /* (a^d) | (b^c) */ \ 75 const __m128i t1 = _mm_or_si128(ad, bc); /* (a^d) | (b^c) */ \
76 const __m128i t2 = _mm_or_si128(t1, st); /* (a^d) | (b^c) | (s^t) */ \ 76 const __m128i t2 = _mm_or_si128(t1, st); /* (a^d) | (b^c) | (s^t) */ \
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 CONVERT2RGB(FUNC, XSTEP, top_y, bottom_y, top_dst, bottom_dst, \ 166 CONVERT2RGB(FUNC, XSTEP, top_y, bottom_y, top_dst, bottom_dst, \
167 pos, len - pos); \ 167 pos, len - pos); \
168 } \ 168 } \
169 } 169 }
170 170
171 // SSE2 variants of the fancy upsampler. 171 // SSE2 variants of the fancy upsampler.
172 SSE2_UPSAMPLE_FUNC(UpsampleRgbLinePair, VP8YuvToRgb, 3) 172 SSE2_UPSAMPLE_FUNC(UpsampleRgbLinePair, VP8YuvToRgb, 3)
173 SSE2_UPSAMPLE_FUNC(UpsampleBgrLinePair, VP8YuvToBgr, 3) 173 SSE2_UPSAMPLE_FUNC(UpsampleBgrLinePair, VP8YuvToBgr, 3)
174 SSE2_UPSAMPLE_FUNC(UpsampleRgbaLinePair, VP8YuvToRgba, 4) 174 SSE2_UPSAMPLE_FUNC(UpsampleRgbaLinePair, VP8YuvToRgba, 4)
175 SSE2_UPSAMPLE_FUNC(UpsampleBgraLinePair, VP8YuvToBgra, 4) 175 SSE2_UPSAMPLE_FUNC(UpsampleBgraLinePair, VP8YuvToBgra, 4)
176 SSE2_UPSAMPLE_FUNC(UpsampleArgbLinePair, VP8YuvToArgb, 4)
177 SSE2_UPSAMPLE_FUNC(UpsampleRgba4444LinePair, VP8YuvToRgba4444, 2)
178 SSE2_UPSAMPLE_FUNC(UpsampleRgb565LinePair, VP8YuvToRgb565, 2)
176 179
177 #undef GET_M 180 #undef GET_M
178 #undef PACK_AND_STORE 181 #undef PACK_AND_STORE
179 #undef UPSAMPLE_32PIXELS 182 #undef UPSAMPLE_32PIXELS
180 #undef UPSAMPLE_LAST_BLOCK 183 #undef UPSAMPLE_LAST_BLOCK
181 #undef CONVERT2RGB 184 #undef CONVERT2RGB
182 #undef CONVERT2RGB_32 185 #undef CONVERT2RGB_32
183 #undef SSE2_UPSAMPLE_FUNC 186 #undef SSE2_UPSAMPLE_FUNC
184 187
185 #endif // FANCY_UPSAMPLING 188 //------------------------------------------------------------------------------
189 // Entry point
186 190
187 #endif // WEBP_USE_SSE2 191 extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];
188
189 //------------------------------------------------------------------------------
190 192
191 extern void WebPInitUpsamplersSSE2(void); 193 extern void WebPInitUpsamplersSSE2(void);
192 194
193 #ifdef FANCY_UPSAMPLING 195 WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplersSSE2(void) {
194
195 extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];
196
197 void WebPInitUpsamplersSSE2(void) {
198 #if defined(WEBP_USE_SSE2)
199 VP8YUVInitSSE2();
200 WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair; 196 WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
201 WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair; 197 WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;
202 WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair; 198 WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair;
203 WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair; 199 WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair;
200 WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair;
204 WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair; 201 WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair;
205 WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair; 202 WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair;
206 #endif // WEBP_USE_SSE2 203 WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair;
204 WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair;
205 WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair;
206 WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair;
207 }
208
209 #endif // FANCY_UPSAMPLING
210
211 //------------------------------------------------------------------------------
212
213 extern WebPYUV444Converter WebPYUV444Converters[/* MODE_LAST */];
214 extern void WebPInitYUV444ConvertersSSE2(void);
215
216 #define YUV444_FUNC(FUNC_NAME, CALL, XSTEP) \
217 extern void WebP##FUNC_NAME##C(const uint8_t* y, const uint8_t* u, \
218 const uint8_t* v, uint8_t* dst, int len); \
219 static void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
220 uint8_t* dst, int len) { \
221 int i; \
222 const int max_len = len & ~31; \
223 for (i = 0; i < max_len; i += 32) CALL(y + i, u + i, v + i, dst + i * XSTEP);\
224 if (i < len) { /* C-fallback */ \
225 WebP##FUNC_NAME##C(y + i, u + i, v + i, dst + i * XSTEP, len - i); \
226 } \
227 }
228
229 YUV444_FUNC(Yuv444ToRgba, VP8YuvToRgba32, 4);
230 YUV444_FUNC(Yuv444ToBgra, VP8YuvToBgra32, 4);
231 YUV444_FUNC(Yuv444ToRgb, VP8YuvToRgb32, 3);
232 YUV444_FUNC(Yuv444ToBgr, VP8YuvToBgr32, 3);
233
234 WEBP_TSAN_IGNORE_FUNCTION void WebPInitYUV444ConvertersSSE2(void) {
235 WebPYUV444Converters[MODE_RGBA] = Yuv444ToRgba;
236 WebPYUV444Converters[MODE_BGRA] = Yuv444ToBgra;
237 WebPYUV444Converters[MODE_RGB] = Yuv444ToRgb;
238 WebPYUV444Converters[MODE_BGR] = Yuv444ToBgr;
207 } 239 }
208 240
209 #else 241 #else
210 242
211 // this empty function is to avoid an empty .o 243 WEBP_DSP_INIT_STUB(WebPInitYUV444ConvertersSSE2)
212 void WebPInitUpsamplersSSE2(void) {}
213 244
214 #endif // FANCY_UPSAMPLING 245 #endif // WEBP_USE_SSE2
246
247 #if !(defined(FANCY_UPSAMPLING) && defined(WEBP_USE_SSE2))
248 WEBP_DSP_INIT_STUB(WebPInitUpsamplersSSE2)
249 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698