intel_init.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* intel_init.c - SSE2 optimized filter functions
  2. *
  3. * Copyright (c) 2016 Google, Inc.
  4. * Written by Mike Klein and Matt Sarett
  5. * Derived from arm/arm_init.c, which was
  6. * Copyright (c) 2014,2016 Glenn Randers-Pehrson
  7. *
  8. * Last changed in libpng 1.6.22 [May 26, 2016]
  9. *
  10. * This code is released under the libpng license.
  11. * For conditions of distribution and use, see the disclaimer
  12. * and license in png.h
  13. */
  14. #include "../pngpriv.h"
  15. #ifdef PNG_READ_SUPPORTED
  16. #if PNG_INTEL_SSE_IMPLEMENTATION > 0
  17. void
  18. png_init_filter_functions_sse2(png_structp pp, unsigned int bpp)
  19. {
  20. /* The techniques used to implement each of these filters in SSE operate on
  21. * one pixel at a time.
  22. * So they generally speed up 3bpp images about 3x, 4bpp images about 4x.
  23. * They can scale up to 6 and 8 bpp images and down to 2 bpp images,
  24. * but they'd not likely have any benefit for 1bpp images.
  25. * Most of these can be implemented using only MMX and 64-bit registers,
  26. * but they end up a bit slower than using the equally-ubiquitous SSE2.
  27. */
  28. png_debug(1, "in png_init_filter_functions_sse2");
  29. if (bpp == 3)
  30. {
  31. pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_sse2;
  32. pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_sse2;
  33. pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
  34. png_read_filter_row_paeth3_sse2;
  35. }
  36. else if (bpp == 4)
  37. {
  38. pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_sse2;
  39. pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_sse2;
  40. pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
  41. png_read_filter_row_paeth4_sse2;
  42. }
  43. /* No need optimize PNG_FILTER_VALUE_UP. The compiler should
  44. * autovectorize.
  45. */
  46. }
  47. #endif /* PNG_INTEL_SSE_IMPLEMENTATION > 0 */
  48. #endif /* PNG_READ_SUPPORTED */