jcgray-neon.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * jcgray-neon.c - grayscale colorspace conversion (Arm Neon)
  3. *
  4. * Copyright (C) 2020, Arm Limited. All Rights Reserved.
  5. *
  6. * This software is provided 'as-is', without any express or implied
  7. * warranty. In no event will the authors be held liable for any damages
  8. * arising from the use of this software.
  9. *
  10. * Permission is granted to anyone to use this software for any purpose,
  11. * including commercial applications, and to alter it and redistribute it
  12. * freely, subject to the following restrictions:
  13. *
  14. * 1. The origin of this software must not be misrepresented; you must not
  15. * claim that you wrote the original software. If you use this software
  16. * in a product, an acknowledgment in the product documentation would be
  17. * appreciated but is not required.
  18. * 2. Altered source versions must be plainly marked as such, and must not be
  19. * misrepresented as being the original software.
  20. * 3. This notice may not be removed or altered from any source distribution.
  21. */
  22. #define JPEG_INTERNALS
  23. #include "../../jinclude.h"
  24. #include "../../jpeglib.h"
  25. #include "../../jsimd.h"
  26. #include "../../jdct.h"
  27. #include "../../jsimddct.h"
  28. #include "../jsimd.h"
  29. #include "align.h"
  30. #include <arm_neon.h>
  31. /* RGB -> Grayscale conversion constants */
  32. #define F_0_298 19595
  33. #define F_0_587 38470
  34. #define F_0_113 7471
  35. /* Include inline routines for colorspace extensions. */
  36. #include "jcgryext-neon.c"
  37. #undef RGB_RED
  38. #undef RGB_GREEN
  39. #undef RGB_BLUE
  40. #undef RGB_PIXELSIZE
  41. #define RGB_RED EXT_RGB_RED
  42. #define RGB_GREEN EXT_RGB_GREEN
  43. #define RGB_BLUE EXT_RGB_BLUE
  44. #define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
  45. #define jsimd_rgb_gray_convert_neon jsimd_extrgb_gray_convert_neon
  46. #include "jcgryext-neon.c"
  47. #undef RGB_RED
  48. #undef RGB_GREEN
  49. #undef RGB_BLUE
  50. #undef RGB_PIXELSIZE
  51. #undef jsimd_rgb_gray_convert_neon
  52. #define RGB_RED EXT_RGBX_RED
  53. #define RGB_GREEN EXT_RGBX_GREEN
  54. #define RGB_BLUE EXT_RGBX_BLUE
  55. #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
  56. #define jsimd_rgb_gray_convert_neon jsimd_extrgbx_gray_convert_neon
  57. #include "jcgryext-neon.c"
  58. #undef RGB_RED
  59. #undef RGB_GREEN
  60. #undef RGB_BLUE
  61. #undef RGB_PIXELSIZE
  62. #undef jsimd_rgb_gray_convert_neon
  63. #define RGB_RED EXT_BGR_RED
  64. #define RGB_GREEN EXT_BGR_GREEN
  65. #define RGB_BLUE EXT_BGR_BLUE
  66. #define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
  67. #define jsimd_rgb_gray_convert_neon jsimd_extbgr_gray_convert_neon
  68. #include "jcgryext-neon.c"
  69. #undef RGB_RED
  70. #undef RGB_GREEN
  71. #undef RGB_BLUE
  72. #undef RGB_PIXELSIZE
  73. #undef jsimd_rgb_gray_convert_neon
  74. #define RGB_RED EXT_BGRX_RED
  75. #define RGB_GREEN EXT_BGRX_GREEN
  76. #define RGB_BLUE EXT_BGRX_BLUE
  77. #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
  78. #define jsimd_rgb_gray_convert_neon jsimd_extbgrx_gray_convert_neon
  79. #include "jcgryext-neon.c"
  80. #undef RGB_RED
  81. #undef RGB_GREEN
  82. #undef RGB_BLUE
  83. #undef RGB_PIXELSIZE
  84. #undef jsimd_rgb_gray_convert_neon
  85. #define RGB_RED EXT_XBGR_RED
  86. #define RGB_GREEN EXT_XBGR_GREEN
  87. #define RGB_BLUE EXT_XBGR_BLUE
  88. #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
  89. #define jsimd_rgb_gray_convert_neon jsimd_extxbgr_gray_convert_neon
  90. #include "jcgryext-neon.c"
  91. #undef RGB_RED
  92. #undef RGB_GREEN
  93. #undef RGB_BLUE
  94. #undef RGB_PIXELSIZE
  95. #undef jsimd_rgb_gray_convert_neon
  96. #define RGB_RED EXT_XRGB_RED
  97. #define RGB_GREEN EXT_XRGB_GREEN
  98. #define RGB_BLUE EXT_XRGB_BLUE
  99. #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
  100. #define jsimd_rgb_gray_convert_neon jsimd_extxrgb_gray_convert_neon
  101. #include "jcgryext-neon.c"
  102. #undef RGB_RED
  103. #undef RGB_GREEN
  104. #undef RGB_BLUE
  105. #undef RGB_PIXELSIZE
  106. #undef jsimd_rgb_gray_convert_neon