• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * jccolor-neon.c - colorspace conversion (Arm Neon)
3  *
4  * Copyright (C) 2020, Arm Limited.  All Rights Reserved.
5  * Copyright (C) 2020, 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 
24 #define JPEG_INTERNALS
25 #include "../../jinclude.h"
26 #include "../../jpeglib.h"
27 #include "../../jsimd.h"
28 #include "../../jdct.h"
29 #include "../../jsimddct.h"
30 #include "../jsimd.h"
31 #include "align.h"
32 #include "neon-compat.h"
33 
34 #include <arm_neon.h>
35 
36 
37 /* RGB -> YCbCr conversion constants */
38 
39 #define F_0_298  19595
40 #define F_0_587  38470
41 #define F_0_113  7471
42 #define F_0_168  11059
43 #define F_0_331  21709
44 #define F_0_500  32768
45 #define F_0_418  27439
46 #define F_0_081  5329
47 
48 ALIGN(16) static const uint16_t jsimd_rgb_ycc_neon_consts[] = {
49   F_0_298, F_0_587, F_0_113, F_0_168,
50   F_0_331, F_0_500, F_0_418, F_0_081
51 };
52 
53 
54 /* Include inline routines for colorspace extensions. */
55 
56 #if defined(__aarch64__) || defined(_M_ARM64)
57 #include "aarch64/jccolext-neon.c"
58 #else
59 #include "aarch32/jccolext-neon.c"
60 #endif
61 #undef RGB_RED
62 #undef RGB_GREEN
63 #undef RGB_BLUE
64 #undef RGB_PIXELSIZE
65 
66 #define RGB_RED  EXT_RGB_RED
67 #define RGB_GREEN  EXT_RGB_GREEN
68 #define RGB_BLUE  EXT_RGB_BLUE
69 #define RGB_PIXELSIZE  EXT_RGB_PIXELSIZE
70 #define jsimd_rgb_ycc_convert_neon  jsimd_extrgb_ycc_convert_neon
71 #if defined(__aarch64__) || defined(_M_ARM64)
72 #include "aarch64/jccolext-neon.c"
73 #else
74 #include "aarch32/jccolext-neon.c"
75 #endif
76 #undef RGB_RED
77 #undef RGB_GREEN
78 #undef RGB_BLUE
79 #undef RGB_PIXELSIZE
80 #undef jsimd_rgb_ycc_convert_neon
81 
82 #define RGB_RED  EXT_RGBX_RED
83 #define RGB_GREEN  EXT_RGBX_GREEN
84 #define RGB_BLUE  EXT_RGBX_BLUE
85 #define RGB_PIXELSIZE  EXT_RGBX_PIXELSIZE
86 #define jsimd_rgb_ycc_convert_neon  jsimd_extrgbx_ycc_convert_neon
87 #if defined(__aarch64__) || defined(_M_ARM64)
88 #include "aarch64/jccolext-neon.c"
89 #else
90 #include "aarch32/jccolext-neon.c"
91 #endif
92 #undef RGB_RED
93 #undef RGB_GREEN
94 #undef RGB_BLUE
95 #undef RGB_PIXELSIZE
96 #undef jsimd_rgb_ycc_convert_neon
97 
98 #define RGB_RED  EXT_BGR_RED
99 #define RGB_GREEN  EXT_BGR_GREEN
100 #define RGB_BLUE  EXT_BGR_BLUE
101 #define RGB_PIXELSIZE  EXT_BGR_PIXELSIZE
102 #define jsimd_rgb_ycc_convert_neon  jsimd_extbgr_ycc_convert_neon
103 #if defined(__aarch64__) || defined(_M_ARM64)
104 #include "aarch64/jccolext-neon.c"
105 #else
106 #include "aarch32/jccolext-neon.c"
107 #endif
108 #undef RGB_RED
109 #undef RGB_GREEN
110 #undef RGB_BLUE
111 #undef RGB_PIXELSIZE
112 #undef jsimd_rgb_ycc_convert_neon
113 
114 #define RGB_RED  EXT_BGRX_RED
115 #define RGB_GREEN  EXT_BGRX_GREEN
116 #define RGB_BLUE  EXT_BGRX_BLUE
117 #define RGB_PIXELSIZE  EXT_BGRX_PIXELSIZE
118 #define jsimd_rgb_ycc_convert_neon  jsimd_extbgrx_ycc_convert_neon
119 #if defined(__aarch64__) || defined(_M_ARM64)
120 #include "aarch64/jccolext-neon.c"
121 #else
122 #include "aarch32/jccolext-neon.c"
123 #endif
124 #undef RGB_RED
125 #undef RGB_GREEN
126 #undef RGB_BLUE
127 #undef RGB_PIXELSIZE
128 #undef jsimd_rgb_ycc_convert_neon
129 
130 #define RGB_RED  EXT_XBGR_RED
131 #define RGB_GREEN  EXT_XBGR_GREEN
132 #define RGB_BLUE  EXT_XBGR_BLUE
133 #define RGB_PIXELSIZE  EXT_XBGR_PIXELSIZE
134 #define jsimd_rgb_ycc_convert_neon  jsimd_extxbgr_ycc_convert_neon
135 #if defined(__aarch64__) || defined(_M_ARM64)
136 #include "aarch64/jccolext-neon.c"
137 #else
138 #include "aarch32/jccolext-neon.c"
139 #endif
140 #undef RGB_RED
141 #undef RGB_GREEN
142 #undef RGB_BLUE
143 #undef RGB_PIXELSIZE
144 #undef jsimd_rgb_ycc_convert_neon
145 
146 #define RGB_RED  EXT_XRGB_RED
147 #define RGB_GREEN  EXT_XRGB_GREEN
148 #define RGB_BLUE  EXT_XRGB_BLUE
149 #define RGB_PIXELSIZE  EXT_XRGB_PIXELSIZE
150 #define jsimd_rgb_ycc_convert_neon  jsimd_extxrgb_ycc_convert_neon
151 #if defined(__aarch64__) || defined(_M_ARM64)
152 #include "aarch64/jccolext-neon.c"
153 #else
154 #include "aarch32/jccolext-neon.c"
155 #endif
156 #undef RGB_RED
157 #undef RGB_GREEN
158 #undef RGB_BLUE
159 #undef RGB_PIXELSIZE
160 #undef jsimd_rgb_ycc_convert_neon
161