1// Copyright 2015 Google Inc. All Rights Reserved. 2// 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 5// tree. An additional intellectual property rights grant can be found 6// in the file PATENTS. All contributing project authors may 7// be found in the AUTHORS file in the root of the source tree. 8// ----------------------------------------------------------------------------- 9// 10// SSE4.1 variant of methods for lossless encoder 11// 12// Author: Skal (pascal.massimino@gmail.com) 13 14#include "./dsp.h" 15 16#if defined(WEBP_USE_SSE41) 17#include <assert.h> 18#include <smmintrin.h> 19#include "./lossless.h" 20 21//------------------------------------------------------------------------------ 22// Subtract-Green Transform 23 24static void SubtractGreenFromBlueAndRed(uint32_t* argb_data, int num_pixels) { 25 int i; 26 const __m128i kCstShuffle = _mm_set_epi8(-1, 13, -1, 13, -1, 9, -1, 9, 27 -1, 5, -1, 5, -1, 1, -1, 1); 28 for (i = 0; i + 4 <= num_pixels; i += 4) { 29 const __m128i in = _mm_loadu_si128((__m128i*)&argb_data[i]); 30 const __m128i in_0g0g = _mm_shuffle_epi8(in, kCstShuffle); 31 const __m128i out = _mm_sub_epi8(in, in_0g0g); 32 _mm_storeu_si128((__m128i*)&argb_data[i], out); 33 } 34 // fallthrough and finish off with plain-C 35 VP8LSubtractGreenFromBlueAndRed_C(argb_data + i, num_pixels - i); 36} 37 38//------------------------------------------------------------------------------ 39// Entry point 40 41extern void VP8LEncDspInitSSE41(void); 42 43WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitSSE41(void) { 44 VP8LSubtractGreenFromBlueAndRed = SubtractGreenFromBlueAndRed; 45} 46 47#else // !WEBP_USE_SSE41 48 49WEBP_DSP_INIT_STUB(VP8LEncDspInitSSE41) 50 51#endif // WEBP_USE_SSE41 52