1 /* 2 * jdcolor-neon.c - 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 "jconfigint.h" 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 33 #include <arm_neon.h> 34 35 36 /* YCbCr -> RGB conversion constants */ 37 38 #define F_0_344 11277 /* 0.3441467 = 11277 * 2^-15 */ 39 #define F_0_714 23401 /* 0.7141418 = 23401 * 2^-15 */ 40 #define F_1_402 22971 /* 1.4020386 = 22971 * 2^-14 */ 41 #define F_1_772 29033 /* 1.7720337 = 29033 * 2^-14 */ 42 43 ALIGN(16) static const int16_t jsimd_ycc_rgb_convert_neon_consts[] = { 44 -F_0_344, F_0_714, F_1_402, F_1_772 45 }; 46 47 48 /* Include inline routines for colorspace extensions. */ 49 50 #include "jdcolext-neon.c" 51 #undef RGB_RED 52 #undef RGB_GREEN 53 #undef RGB_BLUE 54 #undef RGB_PIXELSIZE 55 56 #define RGB_RED EXT_RGB_RED 57 #define RGB_GREEN EXT_RGB_GREEN 58 #define RGB_BLUE EXT_RGB_BLUE 59 #define RGB_PIXELSIZE EXT_RGB_PIXELSIZE 60 #define jsimd_ycc_rgb_convert_neon jsimd_ycc_extrgb_convert_neon 61 #include "jdcolext-neon.c" 62 #undef RGB_RED 63 #undef RGB_GREEN 64 #undef RGB_BLUE 65 #undef RGB_PIXELSIZE 66 #undef jsimd_ycc_rgb_convert_neon 67 68 #define RGB_RED EXT_RGBX_RED 69 #define RGB_GREEN EXT_RGBX_GREEN 70 #define RGB_BLUE EXT_RGBX_BLUE 71 #define RGB_ALPHA 3 72 #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE 73 #define jsimd_ycc_rgb_convert_neon jsimd_ycc_extrgbx_convert_neon 74 #include "jdcolext-neon.c" 75 #undef RGB_RED 76 #undef RGB_GREEN 77 #undef RGB_BLUE 78 #undef RGB_ALPHA 79 #undef RGB_PIXELSIZE 80 #undef jsimd_ycc_rgb_convert_neon 81 82 #define RGB_RED EXT_BGR_RED 83 #define RGB_GREEN EXT_BGR_GREEN 84 #define RGB_BLUE EXT_BGR_BLUE 85 #define RGB_PIXELSIZE EXT_BGR_PIXELSIZE 86 #define jsimd_ycc_rgb_convert_neon jsimd_ycc_extbgr_convert_neon 87 #include "jdcolext-neon.c" 88 #undef RGB_RED 89 #undef RGB_GREEN 90 #undef RGB_BLUE 91 #undef RGB_PIXELSIZE 92 #undef jsimd_ycc_rgb_convert_neon 93 94 #define RGB_RED EXT_BGRX_RED 95 #define RGB_GREEN EXT_BGRX_GREEN 96 #define RGB_BLUE EXT_BGRX_BLUE 97 #define RGB_ALPHA 3 98 #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE 99 #define jsimd_ycc_rgb_convert_neon jsimd_ycc_extbgrx_convert_neon 100 #include "jdcolext-neon.c" 101 #undef RGB_RED 102 #undef RGB_GREEN 103 #undef RGB_BLUE 104 #undef RGB_ALPHA 105 #undef RGB_PIXELSIZE 106 #undef jsimd_ycc_rgb_convert_neon 107 108 #define RGB_RED EXT_XBGR_RED 109 #define RGB_GREEN EXT_XBGR_GREEN 110 #define RGB_BLUE EXT_XBGR_BLUE 111 #define RGB_ALPHA 0 112 #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE 113 #define jsimd_ycc_rgb_convert_neon jsimd_ycc_extxbgr_convert_neon 114 #include "jdcolext-neon.c" 115 #undef RGB_RED 116 #undef RGB_GREEN 117 #undef RGB_BLUE 118 #undef RGB_ALPHA 119 #undef RGB_PIXELSIZE 120 #undef jsimd_ycc_rgb_convert_neon 121 122 #define RGB_RED EXT_XRGB_RED 123 #define RGB_GREEN EXT_XRGB_GREEN 124 #define RGB_BLUE EXT_XRGB_BLUE 125 #define RGB_ALPHA 0 126 #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE 127 #define jsimd_ycc_rgb_convert_neon jsimd_ycc_extxrgb_convert_neon 128 #include "jdcolext-neon.c" 129 #undef RGB_RED 130 #undef RGB_GREEN 131 #undef RGB_BLUE 132 #undef RGB_ALPHA 133 #undef RGB_PIXELSIZE 134 #undef jsimd_ycc_rgb_convert_neon 135 136 /* YCbCr -> RGB565 Conversion */ 137 138 #define RGB_PIXELSIZE 2 139 #define jsimd_ycc_rgb_convert_neon jsimd_ycc_rgb565_convert_neon 140 #include "jdcolext-neon.c" 141 #undef RGB_PIXELSIZE 142 #undef jsimd_ycc_rgb_convert_neon 143