jdmerge-mmi.c (5118B)
1 /* 2 * Loongson MMI optimizations for libjpeg-turbo 3 * 4 * Copyright (C) 2011, 2015, D. R. Commander. All Rights Reserved. 5 * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing. 6 * All Rights Reserved. 7 * Authors: ZhangLixia <zhanglixia-hf@loongson.cn> 8 * 9 * This software is provided 'as-is', without any express or implied 10 * warranty. In no event will the authors be held liable for any damages 11 * arising from the use of this software. 12 * 13 * Permission is granted to anyone to use this software for any purpose, 14 * including commercial applications, and to alter it and redistribute it 15 * freely, subject to the following restrictions: 16 * 17 * 1. The origin of this software must not be misrepresented; you must not 18 * claim that you wrote the original software. If you use this software 19 * in a product, an acknowledgment in the product documentation would be 20 * appreciated but is not required. 21 * 2. Altered source versions must be plainly marked as such, and must not be 22 * misrepresented as being the original software. 23 * 3. This notice may not be removed or altered from any source distribution. 24 */ 25 26 /* YCC --> RGB CONVERSION */ 27 28 #include "jsimd_mmi.h" 29 30 31 #define F_0_344 ((short)22554) /* FIX(0.34414) */ 32 #define F_0_402 ((short)26345) /* FIX(1.40200) - FIX(1) */ 33 #define F_0_285 ((short)18734) /* FIX(1) - FIX(0.71414) */ 34 #define F_0_228 ((short)14942) /* FIX(2) - FIX(1.77200) */ 35 36 enum const_index { 37 index_PW_ONE, 38 index_PW_F0402, 39 index_PW_MF0228, 40 index_PW_MF0344_F0285, 41 index_PD_ONEHALF 42 }; 43 44 static uint64_t const_value[] = { 45 _uint64_set_pi16(1, 1, 1, 1), 46 _uint64_set_pi16(F_0_402, F_0_402, F_0_402, F_0_402), 47 _uint64_set_pi16(-F_0_228, -F_0_228, -F_0_228, -F_0_228), 48 _uint64_set_pi16(F_0_285, -F_0_344, F_0_285, -F_0_344), 49 _uint64_set_pi32((int)(1 << (SCALEBITS - 1)), (int)(1 << (SCALEBITS - 1))) 50 }; 51 52 #define PW_ONE get_const_value(index_PW_ONE) 53 #define PW_F0402 get_const_value(index_PW_F0402) 54 #define PW_MF0228 get_const_value(index_PW_MF0228) 55 #define PW_MF0344_F0285 get_const_value(index_PW_MF0344_F0285) 56 #define PD_ONEHALF get_const_value(index_PD_ONEHALF) 57 58 #define RGBX_FILLER_0XFF 1 59 60 61 #include "jdmrgext-mmi.c" 62 #undef RGB_RED 63 #undef RGB_GREEN 64 #undef RGB_BLUE 65 #undef RGB_PIXELSIZE 66 67 #define RGB_RED EXT_RGB_RED 68 #define RGB_GREEN EXT_RGB_GREEN 69 #define RGB_BLUE EXT_RGB_BLUE 70 #define RGB_PIXELSIZE EXT_RGB_PIXELSIZE 71 #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extrgb_merged_upsample_mmi 72 #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extrgb_merged_upsample_mmi 73 #include "jdmrgext-mmi.c" 74 #undef RGB_RED 75 #undef RGB_GREEN 76 #undef RGB_BLUE 77 #undef RGB_PIXELSIZE 78 #undef jsimd_h2v1_merged_upsample_mmi 79 #undef jsimd_h2v2_merged_upsample_mmi 80 81 #define RGB_RED EXT_RGBX_RED 82 #define RGB_GREEN EXT_RGBX_GREEN 83 #define RGB_BLUE EXT_RGBX_BLUE 84 #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE 85 #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extrgbx_merged_upsample_mmi 86 #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extrgbx_merged_upsample_mmi 87 #include "jdmrgext-mmi.c" 88 #undef RGB_RED 89 #undef RGB_GREEN 90 #undef RGB_BLUE 91 #undef RGB_PIXELSIZE 92 #undef jsimd_h2v1_merged_upsample_mmi 93 #undef jsimd_h2v2_merged_upsample_mmi 94 95 #define RGB_RED EXT_BGR_RED 96 #define RGB_GREEN EXT_BGR_GREEN 97 #define RGB_BLUE EXT_BGR_BLUE 98 #define RGB_PIXELSIZE EXT_BGR_PIXELSIZE 99 #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extbgr_merged_upsample_mmi 100 #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extbgr_merged_upsample_mmi 101 #include "jdmrgext-mmi.c" 102 #undef RGB_RED 103 #undef RGB_GREEN 104 #undef RGB_BLUE 105 #undef RGB_PIXELSIZE 106 #undef jsimd_h2v1_merged_upsample_mmi 107 #undef jsimd_h2v2_merged_upsample_mmi 108 109 #define RGB_RED EXT_BGRX_RED 110 #define RGB_GREEN EXT_BGRX_GREEN 111 #define RGB_BLUE EXT_BGRX_BLUE 112 #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE 113 #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extbgrx_merged_upsample_mmi 114 #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extbgrx_merged_upsample_mmi 115 #include "jdmrgext-mmi.c" 116 #undef RGB_RED 117 #undef RGB_GREEN 118 #undef RGB_BLUE 119 #undef RGB_PIXELSIZE 120 #undef jsimd_h2v1_merged_upsample_mmi 121 #undef jsimd_h2v2_merged_upsample_mmi 122 123 #define RGB_RED EXT_XBGR_RED 124 #define RGB_GREEN EXT_XBGR_GREEN 125 #define RGB_BLUE EXT_XBGR_BLUE 126 #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE 127 #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extxbgr_merged_upsample_mmi 128 #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extxbgr_merged_upsample_mmi 129 #include "jdmrgext-mmi.c" 130 #undef RGB_RED 131 #undef RGB_GREEN 132 #undef RGB_BLUE 133 #undef RGB_PIXELSIZE 134 #undef jsimd_h2v1_merged_upsample_mmi 135 #undef jsimd_h2v2_merged_upsample_mmi 136 137 #define RGB_RED EXT_XRGB_RED 138 #define RGB_GREEN EXT_XRGB_GREEN 139 #define RGB_BLUE EXT_XRGB_BLUE 140 #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE 141 #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extxrgb_merged_upsample_mmi 142 #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extxrgb_merged_upsample_mmi 143 #include "jdmrgext-mmi.c" 144 #undef RGB_RED 145 #undef RGB_GREEN 146 #undef RGB_BLUE 147 #undef RGB_PIXELSIZE 148 #undef jsimd_h2v1_merged_upsample_mmi 149 #undef jsimd_h2v2_merged_upsample_mmi