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 
23 #define JPEG_INTERNALS
24 #include "../../jinclude.h"
25 #include "../../jpeglib.h"
26 #include "../../jsimd.h"
27 #include "../../jdct.h"
28 #include "../../jsimddct.h"
29 #include "../jsimd.h"
30 #include "align.h"
31 
32 #include <arm_neon.h>
33 
34 
35 /* RGB -> Grayscale conversion constants */
36 
37 #define F_0_298  19595
38 #define F_0_587  38470
39 #define F_0_113  7471
40 
41 
42 /* Include inline routines for colorspace extensions. */
43 
44 #include "jcgryext-neon.c"
45 #undef RGB_RED
46 #undef RGB_GREEN
47 #undef RGB_BLUE
48 #undef RGB_PIXELSIZE
49 
50 #define RGB_RED  EXT_RGB_RED
51 #define RGB_GREEN  EXT_RGB_GREEN
52 #define RGB_BLUE  EXT_RGB_BLUE
53 #define RGB_PIXELSIZE  EXT_RGB_PIXELSIZE
54 #define jsimd_rgb_gray_convert_neon  jsimd_extrgb_gray_convert_neon
55 #include "jcgryext-neon.c"
56 #undef RGB_RED
57 #undef RGB_GREEN
58 #undef RGB_BLUE
59 #undef RGB_PIXELSIZE
60 #undef jsimd_rgb_gray_convert_neon
61 
62 #define RGB_RED  EXT_RGBX_RED
63 #define RGB_GREEN  EXT_RGBX_GREEN
64 #define RGB_BLUE  EXT_RGBX_BLUE
65 #define RGB_PIXELSIZE  EXT_RGBX_PIXELSIZE
66 #define jsimd_rgb_gray_convert_neon  jsimd_extrgbx_gray_convert_neon
67 #include "jcgryext-neon.c"
68 #undef RGB_RED
69 #undef RGB_GREEN
70 #undef RGB_BLUE
71 #undef RGB_PIXELSIZE
72 #undef jsimd_rgb_gray_convert_neon
73 
74 #define RGB_RED  EXT_BGR_RED
75 #define RGB_GREEN  EXT_BGR_GREEN
76 #define RGB_BLUE  EXT_BGR_BLUE
77 #define RGB_PIXELSIZE  EXT_BGR_PIXELSIZE
78 #define jsimd_rgb_gray_convert_neon  jsimd_extbgr_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 
86 #define RGB_RED  EXT_BGRX_RED
87 #define RGB_GREEN  EXT_BGRX_GREEN
88 #define RGB_BLUE  EXT_BGRX_BLUE
89 #define RGB_PIXELSIZE  EXT_BGRX_PIXELSIZE
90 #define jsimd_rgb_gray_convert_neon  jsimd_extbgrx_gray_convert_neon
91 #include "jcgryext-neon.c"
92 #undef RGB_RED
93 #undef RGB_GREEN
94 #undef RGB_BLUE
95 #undef RGB_PIXELSIZE
96 #undef jsimd_rgb_gray_convert_neon
97 
98 #define RGB_RED  EXT_XBGR_RED
99 #define RGB_GREEN  EXT_XBGR_GREEN
100 #define RGB_BLUE  EXT_XBGR_BLUE
101 #define RGB_PIXELSIZE  EXT_XBGR_PIXELSIZE
102 #define jsimd_rgb_gray_convert_neon  jsimd_extxbgr_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
109 
110 #define RGB_RED  EXT_XRGB_RED
111 #define RGB_GREEN  EXT_XRGB_GREEN
112 #define RGB_BLUE  EXT_XRGB_BLUE
113 #define RGB_PIXELSIZE  EXT_XRGB_PIXELSIZE
114 #define jsimd_rgb_gray_convert_neon  jsimd_extxrgb_gray_convert_neon
115 #include "jcgryext-neon.c"
116 #undef RGB_RED
117 #undef RGB_GREEN
118 #undef RGB_BLUE
119 #undef RGB_PIXELSIZE
120 #undef jsimd_rgb_gray_convert_neon
121