jcgray-neon.c 3.5 KB

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