loopfilter_4_msa.c revision 7ce0a1d1337c01056ba24006efab21f00e179e04
1/*
2 *  Copyright (c) 2015 The WebM 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#include "vpx_dsp/mips/loopfilter_msa.h"
12
13void vpx_lpf_horizontal_4_msa(uint8_t *src, int32_t pitch,
14                              const uint8_t *b_limit_ptr,
15                              const uint8_t *limit_ptr,
16                              const uint8_t *thresh_ptr,
17                              int32_t count) {
18  uint64_t p1_d, p0_d, q0_d, q1_d;
19  v16u8 mask, hev, flat, thresh, b_limit, limit;
20  v16u8 p3, p2, p1, p0, q3, q2, q1, q0, p1_out, p0_out, q0_out, q1_out;
21
22  (void)count;
23
24  /* load vector elements */
25  LD_UB8((src - 4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3);
26
27  thresh = (v16u8)__msa_fill_b(*thresh_ptr);
28  b_limit = (v16u8)__msa_fill_b(*b_limit_ptr);
29  limit = (v16u8)__msa_fill_b(*limit_ptr);
30
31  LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
32               hev, mask, flat);
33  VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, q1_out);
34
35  p1_d = __msa_copy_u_d((v2i64)p1_out, 0);
36  p0_d = __msa_copy_u_d((v2i64)p0_out, 0);
37  q0_d = __msa_copy_u_d((v2i64)q0_out, 0);
38  q1_d = __msa_copy_u_d((v2i64)q1_out, 0);
39  SD4(p1_d, p0_d, q0_d, q1_d, (src - 2 * pitch), pitch);
40}
41
42void vpx_lpf_horizontal_4_dual_msa(uint8_t *src, int32_t pitch,
43                                   const uint8_t *b_limit0_ptr,
44                                   const uint8_t *limit0_ptr,
45                                   const uint8_t *thresh0_ptr,
46                                   const uint8_t *b_limit1_ptr,
47                                   const uint8_t *limit1_ptr,
48                                   const uint8_t *thresh1_ptr) {
49  v16u8 mask, hev, flat, thresh0, b_limit0, limit0, thresh1, b_limit1, limit1;
50  v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
51
52  /* load vector elements */
53  LD_UB8((src - 4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3);
54
55  thresh0 = (v16u8)__msa_fill_b(*thresh0_ptr);
56  thresh1 = (v16u8)__msa_fill_b(*thresh1_ptr);
57  thresh0 = (v16u8)__msa_ilvr_d((v2i64)thresh1, (v2i64)thresh0);
58
59  b_limit0 = (v16u8)__msa_fill_b(*b_limit0_ptr);
60  b_limit1 = (v16u8)__msa_fill_b(*b_limit1_ptr);
61  b_limit0 = (v16u8)__msa_ilvr_d((v2i64)b_limit1, (v2i64)b_limit0);
62
63  limit0 = (v16u8)__msa_fill_b(*limit0_ptr);
64  limit1 = (v16u8)__msa_fill_b(*limit1_ptr);
65  limit0 = (v16u8)__msa_ilvr_d((v2i64)limit1, (v2i64)limit0);
66
67  LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit0, b_limit0, thresh0,
68               hev, mask, flat);
69  VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1, p0, q0, q1);
70
71  ST_UB4(p1, p0, q0, q1, (src - 2 * pitch), pitch);
72}
73
74void vpx_lpf_vertical_4_msa(uint8_t *src, int32_t pitch,
75                            const uint8_t *b_limit_ptr,
76                            const uint8_t *limit_ptr,
77                            const uint8_t *thresh_ptr,
78                            int32_t count) {
79  v16u8 mask, hev, flat, limit, thresh, b_limit;
80  v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
81  v8i16 vec0, vec1, vec2, vec3;
82
83  (void)count;
84
85  LD_UB8((src - 4), pitch, p3, p2, p1, p0, q0, q1, q2, q3);
86
87  thresh = (v16u8)__msa_fill_b(*thresh_ptr);
88  b_limit = (v16u8)__msa_fill_b(*b_limit_ptr);
89  limit = (v16u8)__msa_fill_b(*limit_ptr);
90
91  TRANSPOSE8x8_UB_UB(p3, p2, p1, p0, q0, q1, q2, q3,
92                     p3, p2, p1, p0, q0, q1, q2, q3);
93  LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
94               hev, mask, flat);
95  VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1, p0, q0, q1);
96  ILVR_B2_SH(p0, p1, q1, q0, vec0, vec1);
97  ILVRL_H2_SH(vec1, vec0, vec2, vec3);
98
99  src -= 2;
100  ST4x4_UB(vec2, vec2, 0, 1, 2, 3, src, pitch);
101  src += 4 * pitch;
102  ST4x4_UB(vec3, vec3, 0, 1, 2, 3, src, pitch);
103}
104
105void vpx_lpf_vertical_4_dual_msa(uint8_t *src, int32_t pitch,
106                                 const uint8_t *b_limit0_ptr,
107                                 const uint8_t *limit0_ptr,
108                                 const uint8_t *thresh0_ptr,
109                                 const uint8_t *b_limit1_ptr,
110                                 const uint8_t *limit1_ptr,
111                                 const uint8_t *thresh1_ptr) {
112  v16u8 mask, hev, flat;
113  v16u8 thresh0, b_limit0, limit0, thresh1, b_limit1, limit1;
114  v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
115  v16u8 row0, row1, row2, row3, row4, row5, row6, row7;
116  v16u8 row8, row9, row10, row11, row12, row13, row14, row15;
117  v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
118
119  LD_UB8(src - 4, pitch, row0, row1, row2, row3, row4, row5, row6, row7);
120  LD_UB8(src - 4 + (8 * pitch), pitch,
121         row8, row9, row10, row11, row12, row13, row14, row15);
122
123  TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7,
124                      row8, row9, row10, row11, row12, row13, row14, row15,
125                      p3, p2, p1, p0, q0, q1, q2, q3);
126
127  thresh0 = (v16u8)__msa_fill_b(*thresh0_ptr);
128  thresh1 = (v16u8)__msa_fill_b(*thresh1_ptr);
129  thresh0 = (v16u8)__msa_ilvr_d((v2i64)thresh1, (v2i64)thresh0);
130
131  b_limit0 = (v16u8)__msa_fill_b(*b_limit0_ptr);
132  b_limit1 = (v16u8)__msa_fill_b(*b_limit1_ptr);
133  b_limit0 = (v16u8)__msa_ilvr_d((v2i64)b_limit1, (v2i64)b_limit0);
134
135  limit0 = (v16u8)__msa_fill_b(*limit0_ptr);
136  limit1 = (v16u8)__msa_fill_b(*limit1_ptr);
137  limit0 = (v16u8)__msa_ilvr_d((v2i64)limit1, (v2i64)limit0);
138
139  LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit0, b_limit0, thresh0,
140               hev, mask, flat);
141  VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1, p0, q0, q1);
142  ILVR_B2_SH(p0, p1, q1, q0, tmp0, tmp1);
143  ILVRL_H2_SH(tmp1, tmp0, tmp2, tmp3);
144  ILVL_B2_SH(p0, p1, q1, q0, tmp0, tmp1);
145  ILVRL_H2_SH(tmp1, tmp0, tmp4, tmp5);
146
147  src -= 2;
148
149  ST4x8_UB(tmp2, tmp3, src, pitch);
150  src += (8 * pitch);
151  ST4x8_UB(tmp4, tmp5, src, pitch);
152}
153