lossless_enc_sse41.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include "./dsp.h"
  14. #if defined(WEBP_USE_SSE41)
  15. #include <assert.h>
  16. #include <smmintrin.h>
  17. #include "./lossless.h"
  18. //------------------------------------------------------------------------------
  19. // Subtract-Green Transform
  20. static void SubtractGreenFromBlueAndRed(uint32_t* argb_data, int num_pixels) {
  21. int i;
  22. const __m128i kCstShuffle = _mm_set_epi8(-1, 13, -1, 13, -1, 9, -1, 9,
  23. -1, 5, -1, 5, -1, 1, -1, 1);
  24. for (i = 0; i + 4 <= num_pixels; i += 4) {
  25. const __m128i in = _mm_loadu_si128((__m128i*)&argb_data[i]);
  26. const __m128i in_0g0g = _mm_shuffle_epi8(in, kCstShuffle);
  27. const __m128i out = _mm_sub_epi8(in, in_0g0g);
  28. _mm_storeu_si128((__m128i*)&argb_data[i], out);
  29. }
  30. // fallthrough and finish off with plain-C
  31. if (i != num_pixels) {
  32. VP8LSubtractGreenFromBlueAndRed_C(argb_data + i, num_pixels - i);
  33. }
  34. }
  35. //------------------------------------------------------------------------------
  36. // Entry point
  37. extern void VP8LEncDspInitSSE41(void);
  38. WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitSSE41(void) {
  39. VP8LSubtractGreenFromBlueAndRed = SubtractGreenFromBlueAndRed;
  40. }
  41. #else // !WEBP_USE_SSE41
  42. WEBP_DSP_INIT_STUB(VP8LEncDspInitSSE41)
  43. #endif // WEBP_USE_SSE41