• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Loongson MMI optimizations for libjpeg-turbo
3  *
4  * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
5  *                          All Rights Reserved.
6  * Authors:  ZhuChen     <zhuchen@loongson.cn>
7  *           CaiWanwei   <caiwanwei@loongson.cn>
8  *           SunZhangzhi <sunzhangzhi-cq@loongson.cn>
9  *           QingfaLiu   <liuqingfa-hf@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 #define JPEG_INTERNALS
29 #include "../../jinclude.h"
30 #include "../../jpeglib.h"
31 #include "../../jdct.h"
32 #include "loongson-mmintrin.h"
33 
34 
35 /* Common code */
36 #if defined(_ABI64) && _MIPS_SIM == _ABI64
37 # define PTR_ADDU  "daddu "
38 # define PTR_SLL   "dsll "
39 #else
40 # define PTR_ADDU  "addu "
41 # define PTR_SLL   "sll "
42 #endif
43 
44 #define SIZEOF_MMWORD  8
45 #define BYTE_BIT  8
46 #define WORD_BIT  16
47 #define SCALEBITS  16
48 
49 #define _uint64_set_pi8(a, b, c, d, e, f, g, h) \
50   (((uint64_t)(uint8_t)a << 56) | \
51    ((uint64_t)(uint8_t)b << 48) | \
52    ((uint64_t)(uint8_t)c << 40) | \
53    ((uint64_t)(uint8_t)d << 32) | \
54    ((uint64_t)(uint8_t)e << 24) | \
55    ((uint64_t)(uint8_t)f << 16) | \
56    ((uint64_t)(uint8_t)g << 8)  | \
57    ((uint64_t)(uint8_t)h))
58 #define _uint64_set1_pi8(a)  _uint64_set_pi8(a, a, a, a, a, a, a, a)
59 #define _uint64_set_pi16(a, b, c, d) \
60   (((uint64_t)(uint16_t)a << 48) | \
61    ((uint64_t)(uint16_t)b << 32) | \
62    ((uint64_t)(uint16_t)c << 16) | \
63    ((uint64_t)(uint16_t)d))
64 #define _uint64_set1_pi16(a)  _uint64_set_pi16(a, a, a, a)
65 #define _uint64_set_pi32(a, b) \
66   (((uint64_t)(uint32_t)a << 32) | \
67    ((uint64_t)(uint32_t)b))
68 
69 #define get_const_value(index)  (*(__m64 *)&const_value[index])
70