tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

jccolor-mmi.c (5115B)


      1 /*
      2 * Loongson MMI optimizations for libjpeg-turbo
      3 *
      4 * Copyright (C) 2011, 2014, D. R. Commander.  All Rights Reserved.
      5 * Copyright (C) 2016-2017, Loongson Technology Corporation Limited, BeiJing.
      6 *                          All Rights Reserved.
      7 * Authors:  ZhuChen     <zhuchen@loongson.cn>
      8 *           CaiWanwei   <caiwanwei@loongson.cn>
      9 *           SunZhangzhi <sunzhangzhi-cq@loongson.cn>
     10 *
     11 * This software is provided 'as-is', without any express or implied
     12 * warranty.  In no event will the authors be held liable for any damages
     13 * arising from the use of this software.
     14 *
     15 * Permission is granted to anyone to use this software for any purpose,
     16 * including commercial applications, and to alter it and redistribute it
     17 * freely, subject to the following restrictions:
     18 *
     19 * 1. The origin of this software must not be misrepresented; you must not
     20 *    claim that you wrote the original software. If you use this software
     21 *    in a product, an acknowledgment in the product documentation would be
     22 *    appreciated but is not required.
     23 * 2. Altered source versions must be plainly marked as such, and must not be
     24 *    misrepresented as being the original software.
     25 * 3. This notice may not be removed or altered from any source distribution.
     26 */
     27 
     28 /* RGB --> YCC CONVERSION */
     29 
     30 #include "jsimd_mmi.h"
     31 
     32 
     33 #define F_0_081  ((short)5329)                /* FIX(0.08131) */
     34 #define F_0_114  ((short)7471)                /* FIX(0.11400) */
     35 #define F_0_168  ((short)11059)               /* FIX(0.16874) */
     36 #define F_0_250  ((short)16384)               /* FIX(0.25000) */
     37 #define F_0_299  ((short)19595)               /* FIX(0.29900) */
     38 #define F_0_331  ((short)21709)               /* FIX(0.33126) */
     39 #define F_0_418  ((short)27439)               /* FIX(0.41869) */
     40 #define F_0_587  ((short)38470)               /* FIX(0.58700) */
     41 #define F_0_337  ((short)(F_0_587 - F_0_250)) /* FIX(0.58700) - FIX(0.25000) */
     42 
     43 enum const_index {
     44  index_PD_ONEHALF,
     45  index_PW_F0299_F0337,
     46  index_PW_F0114_F0250,
     47  index_PW_MF016_MF033,
     48  index_PW_MF008_MF041,
     49  index_PD_ONEHALFM1_CJ
     50 };
     51 
     52 static uint64_t const_value[] = {
     53  _uint64_set_pi32((int)(1 << (SCALEBITS - 1)), (int)(1 << (SCALEBITS - 1))),
     54  _uint64_set_pi16(F_0_337, F_0_299, F_0_337, F_0_299),
     55  _uint64_set_pi16(F_0_250, F_0_114, F_0_250, F_0_114),
     56  _uint64_set_pi16(-F_0_331, -F_0_168, -F_0_331, -F_0_168),
     57  _uint64_set_pi16(-F_0_418, -F_0_081, -F_0_418, -F_0_081),
     58  _uint64_set_pi32(((1 << (SCALEBITS - 1)) - 1 + (CENTERJSAMPLE << SCALEBITS)),
     59                   ((1 << (SCALEBITS - 1)) - 1 + (CENTERJSAMPLE << SCALEBITS)))
     60 };
     61 
     62 #define get_const_value(index)  (*(__m64 *)&const_value[index])
     63 
     64 #define PD_ONEHALF       get_const_value(index_PD_ONEHALF)
     65 #define PW_F0299_F0337   get_const_value(index_PW_F0299_F0337)
     66 #define PW_F0114_F0250   get_const_value(index_PW_F0114_F0250)
     67 #define PW_MF016_MF033   get_const_value(index_PW_MF016_MF033)
     68 #define PW_MF008_MF041   get_const_value(index_PW_MF008_MF041)
     69 #define PD_ONEHALFM1_CJ  get_const_value(index_PD_ONEHALFM1_CJ)
     70 
     71 
     72 #include "jccolext-mmi.c"
     73 #undef RGB_RED
     74 #undef RGB_GREEN
     75 #undef RGB_BLUE
     76 #undef RGB_PIXELSIZE
     77 
     78 #define RGB_RED  EXT_RGB_RED
     79 #define RGB_GREEN  EXT_RGB_GREEN
     80 #define RGB_BLUE  EXT_RGB_BLUE
     81 #define RGB_PIXELSIZE  EXT_RGB_PIXELSIZE
     82 #define jsimd_rgb_ycc_convert_mmi  jsimd_extrgb_ycc_convert_mmi
     83 #include "jccolext-mmi.c"
     84 #undef RGB_RED
     85 #undef RGB_GREEN
     86 #undef RGB_BLUE
     87 #undef RGB_PIXELSIZE
     88 #undef jsimd_rgb_ycc_convert_mmi
     89 
     90 #define RGB_RED  EXT_RGBX_RED
     91 #define RGB_GREEN  EXT_RGBX_GREEN
     92 #define RGB_BLUE  EXT_RGBX_BLUE
     93 #define RGB_PIXELSIZE  EXT_RGBX_PIXELSIZE
     94 #define jsimd_rgb_ycc_convert_mmi  jsimd_extrgbx_ycc_convert_mmi
     95 #include "jccolext-mmi.c"
     96 #undef RGB_RED
     97 #undef RGB_GREEN
     98 #undef RGB_BLUE
     99 #undef RGB_PIXELSIZE
    100 #undef jsimd_rgb_ycc_convert_mmi
    101 
    102 #define RGB_RED  EXT_BGR_RED
    103 #define RGB_GREEN  EXT_BGR_GREEN
    104 #define RGB_BLUE  EXT_BGR_BLUE
    105 #define RGB_PIXELSIZE  EXT_BGR_PIXELSIZE
    106 #define jsimd_rgb_ycc_convert_mmi  jsimd_extbgr_ycc_convert_mmi
    107 #include "jccolext-mmi.c"
    108 #undef RGB_RED
    109 #undef RGB_GREEN
    110 #undef RGB_BLUE
    111 #undef RGB_PIXELSIZE
    112 #undef jsimd_rgb_ycc_convert_mmi
    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_mmi  jsimd_extbgrx_ycc_convert_mmi
    119 #include "jccolext-mmi.c"
    120 #undef RGB_RED
    121 #undef RGB_GREEN
    122 #undef RGB_BLUE
    123 #undef RGB_PIXELSIZE
    124 #undef jsimd_rgb_ycc_convert_mmi
    125 
    126 #define RGB_RED  EXT_XBGR_RED
    127 #define RGB_GREEN  EXT_XBGR_GREEN
    128 #define RGB_BLUE  EXT_XBGR_BLUE
    129 #define RGB_PIXELSIZE  EXT_XBGR_PIXELSIZE
    130 #define jsimd_rgb_ycc_convert_mmi  jsimd_extxbgr_ycc_convert_mmi
    131 #include "jccolext-mmi.c"
    132 #undef RGB_RED
    133 #undef RGB_GREEN
    134 #undef RGB_BLUE
    135 #undef RGB_PIXELSIZE
    136 #undef jsimd_rgb_ycc_convert_mmi
    137 
    138 #define RGB_RED  EXT_XRGB_RED
    139 #define RGB_GREEN  EXT_XRGB_GREEN
    140 #define RGB_BLUE  EXT_XRGB_BLUE
    141 #define RGB_PIXELSIZE  EXT_XRGB_PIXELSIZE
    142 #define jsimd_rgb_ycc_convert_mmi  jsimd_extxrgb_ycc_convert_mmi
    143 #include "jccolext-mmi.c"
    144 #undef RGB_RED
    145 #undef RGB_GREEN
    146 #undef RGB_BLUE
    147 #undef RGB_PIXELSIZE
    148 #undef jsimd_rgb_ycc_convert_mmi