webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
macros_msa.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016 The LibYuv Project Authors. All rights reserved.
3  *
4  * Use of this source code is governed by a BSD-style license
5  * that can be found in the LICENSE file in the root of the source
6  * tree. An additional intellectual property rights grant can be found
7  * in the file PATENTS. All contributing project authors may
8  * be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef INCLUDE_LIBYUV_MACROS_MSA_H_
12 #define INCLUDE_LIBYUV_MACROS_MSA_H_
13 
14 #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
15 #include <stdint.h>
16 #include <msa.h>
17 
18 #define LD_B(RTYPE, psrc) *((RTYPE*)(psrc)) /* NOLINT */
19 #define LD_UB(...) LD_B(v16u8, __VA_ARGS__)
20 
21 #define ST_B(RTYPE, in, pdst) *((RTYPE*)(pdst)) = (in) /* NOLINT */
22 #define ST_UB(...) ST_B(v16u8, __VA_ARGS__)
23 
24 /* Description : Load two vectors with 16 'byte' sized elements
25  Arguments : Inputs - psrc, stride
26  Outputs - out0, out1
27  Return Type - as per RTYPE
28  Details : Load 16 byte elements in 'out0' from (psrc)
29  Load 16 byte elements in 'out1' from (psrc + stride)
30 */
31 #define LD_B2(RTYPE, psrc, stride, out0, out1) { \
32  out0 = LD_B(RTYPE, (psrc)); \
33  out1 = LD_B(RTYPE, (psrc) + stride); \
34 }
35 #define LD_UB2(...) LD_B2(v16u8, __VA_ARGS__)
36 
37 #define LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3) { \
38  LD_B2(RTYPE, (psrc), stride, out0, out1); \
39  LD_B2(RTYPE, (psrc) + 2 * stride , stride, out2, out3); \
40 }
41 #define LD_UB4(...) LD_B4(v16u8, __VA_ARGS__)
42 
43 /* Description : Store two vectors with stride each having 16 'byte' sized
44  elements
45  Arguments : Inputs - in0, in1, pdst, stride
46  Details : Store 16 byte elements from 'in0' to (pdst)
47  Store 16 byte elements from 'in1' to (pdst + stride)
48 */
49 #define ST_B2(RTYPE, in0, in1, pdst, stride) { \
50  ST_B(RTYPE, in0, (pdst)); \
51  ST_B(RTYPE, in1, (pdst) + stride); \
52 }
53 #define ST_UB2(...) ST_B2(v16u8, __VA_ARGS__)
54 #
55 #define ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride) { \
56  ST_B2(RTYPE, in0, in1, (pdst), stride); \
57  ST_B2(RTYPE, in2, in3, (pdst) + 2 * stride, stride); \
58 }
59 #define ST_UB4(...) ST_B4(v16u8, __VA_ARGS__)
60 #
61 /* Description : Shuffle byte vector elements as per mask vector
62  Arguments : Inputs - in0, in1, in2, in3, mask0, mask1
63  Outputs - out0, out1
64  Return Type - as per RTYPE
65  Details : Byte elements from 'in0' & 'in1' are copied selectively to
66  'out0' as per control vector 'mask0'
67 */
68 #define VSHF_B2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) { \
69  out0 = (RTYPE) __msa_vshf_b((v16i8) mask0, (v16i8) in1, (v16i8) in0); \
70  out1 = (RTYPE) __msa_vshf_b((v16i8) mask1, (v16i8) in3, (v16i8) in2); \
71 }
72 #define VSHF_B2_UB(...) VSHF_B2(v16u8, __VA_ARGS__)
73 
74 /* Description : Interleave both left and right half of input vectors
75  Arguments : Inputs - in0, in1
76  Outputs - out0, out1
77  Return Type - as per RTYPE
78  Details : Right half of byte elements from 'in0' and 'in1' are
79  interleaved and written to 'out0'
80 */
81 #define ILVRL_B2(RTYPE, in0, in1, out0, out1) { \
82  out0 = (RTYPE) __msa_ilvr_b((v16i8) in0, (v16i8) in1); \
83  out1 = (RTYPE) __msa_ilvl_b((v16i8) in0, (v16i8) in1); \
84 }
85 #define ILVRL_B2_UB(...) ILVRL_B2(v16u8, __VA_ARGS__)
86 
87 #endif /* !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) */
88 
89 #endif // INCLUDE_LIBYUV_MACROS_MSA_H_