1 /* 2 * AltiVec optimizations for libjpeg-turbo 3 * 4 * Copyright (C) 2015, D. R. Commander. 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 /* YCC --> RGB CONVERSION */ 24 25 #include "jsimd_altivec.h" 26 27 28 #define F_0_344 22554 /* FIX(0.34414) */ 29 #define F_0_714 46802 /* FIX(0.71414) */ 30 #define F_1_402 91881 /* FIX(1.40200) */ 31 #define F_1_772 116130 /* FIX(1.77200) */ 32 #define F_0_402 (F_1_402 - 65536) /* FIX(1.40200) - FIX(1) */ 33 #define F_0_285 (65536 - F_0_714) /* FIX(1) - FIX(0.71414) */ 34 #define F_0_228 (131072 - F_1_772) /* FIX(2) - FIX(1.77200) */ 35 36 #define SCALEBITS 16 37 #define ONE_HALF (1 << (SCALEBITS - 1)) 38 39 #define RGB_INDEX0 \ 40 { 0, 1, 8, 2, 3, 10, 4, 5, 12, 6, 7, 14, 16, 17, 24, 18 } 41 #define RGB_INDEX1 \ 42 { 3, 10, 4, 5, 12, 6, 7, 14, 16, 17, 24, 18, 19, 26, 20, 21 } 43 #define RGB_INDEX2 \ 44 { 12, 6, 7, 14, 16, 17, 24, 18, 19, 26, 20, 21, 28, 22, 23, 30 } 45 #include "jdcolext-altivec.c" 46 #undef RGB_PIXELSIZE 47 48 #define RGB_PIXELSIZE EXT_RGB_PIXELSIZE 49 #define jsimd_ycc_rgb_convert_altivec jsimd_ycc_extrgb_convert_altivec 50 #include "jdcolext-altivec.c" 51 #undef RGB_PIXELSIZE 52 #undef RGB_INDEX0 53 #undef RGB_INDEX1 54 #undef RGB_INDEX2 55 #undef jsimd_ycc_rgb_convert_altivec 56 57 #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE 58 #define RGB_INDEX \ 59 { 0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15 } 60 #define jsimd_ycc_rgb_convert_altivec jsimd_ycc_extrgbx_convert_altivec 61 #include "jdcolext-altivec.c" 62 #undef RGB_PIXELSIZE 63 #undef RGB_INDEX 64 #undef jsimd_ycc_rgb_convert_altivec 65 66 #define RGB_PIXELSIZE EXT_BGR_PIXELSIZE 67 #define RGB_INDEX0 \ 68 { 8, 1, 0, 10, 3, 2, 12, 5, 4, 14, 7, 6, 24, 17, 16, 26 } 69 #define RGB_INDEX1 \ 70 { 3, 2, 12, 5, 4, 14, 7, 6, 24, 17, 16, 26, 19, 18, 28, 21 } 71 #define RGB_INDEX2 \ 72 { 4, 14, 7, 6, 24, 17, 16, 26, 19, 18, 28, 21, 20, 30, 23, 22 } 73 #define jsimd_ycc_rgb_convert_altivec jsimd_ycc_extbgr_convert_altivec 74 #include "jdcolext-altivec.c" 75 #undef RGB_PIXELSIZE 76 #undef RGB_INDEX0 77 #undef RGB_INDEX1 78 #undef RGB_INDEX2 79 #undef jsimd_ycc_rgb_convert_altivec 80 81 #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE 82 #define RGB_INDEX \ 83 { 8, 1, 0, 9, 10, 3, 2, 11, 12, 5, 4, 13, 14, 7, 6, 15 } 84 #define jsimd_ycc_rgb_convert_altivec jsimd_ycc_extbgrx_convert_altivec 85 #include "jdcolext-altivec.c" 86 #undef RGB_PIXELSIZE 87 #undef RGB_INDEX 88 #undef jsimd_ycc_rgb_convert_altivec 89 90 #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE 91 #define RGB_INDEX \ 92 { 9, 8, 1, 0, 11, 10, 3, 2, 13, 12, 5, 4, 15, 14, 7, 6 } 93 #define jsimd_ycc_rgb_convert_altivec jsimd_ycc_extxbgr_convert_altivec 94 #include "jdcolext-altivec.c" 95 #undef RGB_PIXELSIZE 96 #undef RGB_INDEX 97 #undef jsimd_ycc_rgb_convert_altivec 98 99 #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE 100 #define RGB_INDEX \ 101 { 9, 0, 1, 8, 11, 2, 3, 10, 13, 4, 5, 12, 15, 6, 7, 14 } 102 #define jsimd_ycc_rgb_convert_altivec jsimd_ycc_extxrgb_convert_altivec 103 #include "jdcolext-altivec.c" 104 #undef RGB_PIXELSIZE 105 #undef RGB_INDEX 106 #undef jsimd_ycc_rgb_convert_altivec 107