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