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/common_dspr2.h"
12
13 #if HAVE_DSPR2
vpx_h_predictor_4x4_dspr2(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)14 void vpx_h_predictor_4x4_dspr2(uint8_t *dst, ptrdiff_t stride,
15 const uint8_t *above, const uint8_t *left) {
16 int32_t tmp1, tmp2, tmp3, tmp4;
17 (void)above;
18
19 __asm__ __volatile__(
20 "lb %[tmp1], (%[left]) \n\t"
21 "lb %[tmp2], 1(%[left]) \n\t"
22 "lb %[tmp3], 2(%[left]) \n\t"
23 "lb %[tmp4], 3(%[left]) \n\t"
24 "replv.qb %[tmp1], %[tmp1] \n\t"
25 "replv.qb %[tmp2], %[tmp2] \n\t"
26 "replv.qb %[tmp3], %[tmp3] \n\t"
27 "replv.qb %[tmp4], %[tmp4] \n\t"
28 "sw %[tmp1], (%[dst]) \n\t"
29 "add %[dst], %[dst], %[stride] \n\t"
30 "sw %[tmp2], (%[dst]) \n\t"
31 "add %[dst], %[dst], %[stride] \n\t"
32 "sw %[tmp3], (%[dst]) \n\t"
33 "add %[dst], %[dst], %[stride] \n\t"
34 "sw %[tmp4], (%[dst]) \n\t"
35
36 : [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [tmp3] "=&r"(tmp3),
37 [tmp4] "=&r"(tmp4)
38 : [left] "r"(left), [dst] "r"(dst), [stride] "r"(stride));
39 }
40
vpx_dc_predictor_4x4_dspr2(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)41 void vpx_dc_predictor_4x4_dspr2(uint8_t *dst, ptrdiff_t stride,
42 const uint8_t *above, const uint8_t *left) {
43 int32_t expected_dc;
44 int32_t average;
45 int32_t tmp, above_c, above_l, above_r, left_c, left_r, left_l;
46
47 __asm__ __volatile__(
48 "lw %[above_c], (%[above]) \n\t"
49 "lw %[left_c], (%[left]) \n\t"
50
51 "preceu.ph.qbl %[above_l], %[above_c] \n\t"
52 "preceu.ph.qbr %[above_r], %[above_c] \n\t"
53 "preceu.ph.qbl %[left_l], %[left_c] \n\t"
54 "preceu.ph.qbr %[left_r], %[left_c] \n\t"
55
56 "addu.ph %[average], %[above_r], %[above_l] \n\t"
57 "addu.ph %[average], %[average], %[left_l] \n\t"
58 "addu.ph %[average], %[average], %[left_r] \n\t"
59 "addiu %[average], %[average], 4 \n\t"
60 "srl %[tmp], %[average], 16 \n\t"
61 "addu.ph %[average], %[tmp], %[average] \n\t"
62 "srl %[expected_dc], %[average], 3 \n\t"
63 "replv.qb %[expected_dc], %[expected_dc] \n\t"
64
65 "sw %[expected_dc], (%[dst]) \n\t"
66 "add %[dst], %[dst], %[stride] \n\t"
67 "sw %[expected_dc], (%[dst]) \n\t"
68 "add %[dst], %[dst], %[stride] \n\t"
69 "sw %[expected_dc], (%[dst]) \n\t"
70 "add %[dst], %[dst], %[stride] \n\t"
71 "sw %[expected_dc], (%[dst]) \n\t"
72
73 : [above_c] "=&r"(above_c), [above_l] "=&r"(above_l),
74 [above_r] "=&r"(above_r), [left_c] "=&r"(left_c),
75 [left_l] "=&r"(left_l), [left_r] "=&r"(left_r),
76 [average] "=&r"(average), [tmp] "=&r"(tmp),
77 [expected_dc] "=&r"(expected_dc)
78 : [above] "r"(above), [left] "r"(left), [dst] "r"(dst),
79 [stride] "r"(stride));
80 }
81
vpx_tm_predictor_4x4_dspr2(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)82 void vpx_tm_predictor_4x4_dspr2(uint8_t *dst, ptrdiff_t stride,
83 const uint8_t *above, const uint8_t *left) {
84 int32_t abovel, abover;
85 int32_t left0, left1, left2, left3;
86 int32_t res0, res1;
87 int32_t resl;
88 int32_t resr;
89 int32_t top_left;
90 uint8_t *cm = vpx_ff_cropTbl;
91
92 __asm__ __volatile__(
93 "ulw %[resl], (%[above]) \n\t"
94
95 "lbu %[left0], (%[left]) \n\t"
96 "lbu %[left1], 1(%[left]) \n\t"
97 "lbu %[left2], 2(%[left]) \n\t"
98 "lbu %[left3], 3(%[left]) \n\t"
99
100 "lbu %[top_left], -1(%[above]) \n\t"
101
102 "preceu.ph.qbl %[abovel], %[resl] \n\t"
103 "preceu.ph.qbr %[abover], %[resl] \n\t"
104
105 "replv.ph %[left0], %[left0] \n\t"
106 "replv.ph %[left1], %[left1] \n\t"
107 "replv.ph %[left2], %[left2] \n\t"
108 "replv.ph %[left3], %[left3] \n\t"
109
110 "replv.ph %[top_left], %[top_left] \n\t"
111
112 "addu.ph %[resl], %[abovel], %[left0] \n\t"
113 "subu.ph %[resl], %[resl], %[top_left] \n\t"
114
115 "addu.ph %[resr], %[abover], %[left0] \n\t"
116 "subu.ph %[resr], %[resr], %[top_left] \n\t"
117
118 "sll %[res0], %[resr], 16 \n\t"
119 "sra %[res0], %[res0], 16 \n\t"
120 "lbux %[res0], %[res0](%[cm]) \n\t"
121
122 "sra %[res1], %[resr], 16 \n\t"
123 "lbux %[res1], %[res1](%[cm]) \n\t"
124 "sb %[res0], (%[dst]) \n\t"
125
126 "sll %[res0], %[resl], 16 \n\t"
127 "sra %[res0], %[res0], 16 \n\t"
128 "lbux %[res0], %[res0](%[cm]) \n\t"
129 "sb %[res1], 1(%[dst]) \n\t"
130
131 "sra %[res1], %[resl], 16 \n\t"
132 "lbux %[res1], %[res1](%[cm]) \n\t"
133
134 "addu.ph %[resl], %[abovel], %[left1] \n\t"
135 "subu.ph %[resl], %[resl], %[top_left] \n\t"
136
137 "addu.ph %[resr], %[abover], %[left1] \n\t"
138 "subu.ph %[resr], %[resr], %[top_left] \n\t"
139
140 "sb %[res0], 2(%[dst]) \n\t"
141 "sb %[res1], 3(%[dst]) \n\t"
142
143 "add %[dst], %[dst], %[stride] \n\t"
144
145 "sll %[res0], %[resr], 16 \n\t"
146 "sra %[res0], %[res0], 16 \n\t"
147 "lbux %[res0], %[res0](%[cm]) \n\t"
148
149 "sra %[res1], %[resr], 16 \n\t"
150 "lbux %[res1], %[res1](%[cm]) \n\t"
151 "sb %[res0], (%[dst]) \n\t"
152
153 "sll %[res0], %[resl], 16 \n\t"
154 "sra %[res0], %[res0], 16 \n\t"
155 "lbux %[res0], %[res0](%[cm]) \n\t"
156
157 "sb %[res1], 1(%[dst]) \n\t"
158 "sra %[res1], %[resl], 16 \n\t"
159 "lbux %[res1], %[res1](%[cm]) \n\t"
160
161 "addu.ph %[resl], %[abovel], %[left2] \n\t"
162 "subu.ph %[resl], %[resl], %[top_left] \n\t"
163
164 "addu.ph %[resr], %[abover], %[left2] \n\t"
165 "subu.ph %[resr], %[resr], %[top_left] \n\t"
166
167 "sb %[res0], 2(%[dst]) \n\t"
168 "sb %[res1], 3(%[dst]) \n\t"
169
170 "add %[dst], %[dst], %[stride] \n\t"
171
172 "sll %[res0], %[resr], 16 \n\t"
173 "sra %[res0], %[res0], 16 \n\t"
174 "lbux %[res0], %[res0](%[cm]) \n\t"
175
176 "sra %[res1], %[resr], 16 \n\t"
177 "lbux %[res1], %[res1](%[cm]) \n\t"
178 "sb %[res0], (%[dst]) \n\t"
179
180 "sll %[res0], %[resl], 16 \n\t"
181 "sra %[res0], %[res0], 16 \n\t"
182 "lbux %[res0], %[res0](%[cm]) \n\t"
183
184 "sb %[res1], 1(%[dst]) \n\t"
185 "sra %[res1], %[resl], 16 \n\t"
186 "lbux %[res1], %[res1](%[cm]) \n\t"
187
188 "addu.ph %[resl], %[abovel], %[left3] \n\t"
189 "subu.ph %[resl], %[resl], %[top_left] \n\t"
190
191 "addu.ph %[resr], %[abover], %[left3] \n\t"
192 "subu.ph %[resr], %[resr], %[top_left] \n\t"
193
194 "sb %[res0], 2(%[dst]) \n\t"
195 "sb %[res1], 3(%[dst]) \n\t"
196
197 "add %[dst], %[dst], %[stride] \n\t"
198
199 "sll %[res0], %[resr], 16 \n\t"
200 "sra %[res0], %[res0], 16 \n\t"
201 "lbux %[res0], %[res0](%[cm]) \n\t"
202
203 "sra %[res1], %[resr], 16 \n\t"
204 "lbux %[res1], %[res1](%[cm]) \n\t"
205 "sb %[res0], (%[dst]) \n\t"
206
207 "sll %[res0], %[resl], 16 \n\t"
208 "sra %[res0], %[res0], 16 \n\t"
209 "lbux %[res0], %[res0](%[cm]) \n\t"
210 "sb %[res1], 1(%[dst]) \n\t"
211
212 "sra %[res1], %[resl], 16 \n\t"
213 "lbux %[res1], %[res1](%[cm]) \n\t"
214
215 "sb %[res0], 2(%[dst]) \n\t"
216 "sb %[res1], 3(%[dst]) \n\t"
217
218 : [abovel] "=&r"(abovel), [abover] "=&r"(abover), [left0] "=&r"(left0),
219 [left1] "=&r"(left1), [left2] "=&r"(left2), [res0] "=&r"(res0),
220 [res1] "=&r"(res1), [left3] "=&r"(left3), [resl] "=&r"(resl),
221 [resr] "=&r"(resr), [top_left] "=&r"(top_left)
222 : [above] "r"(above), [left] "r"(left), [dst] "r"(dst),
223 [stride] "r"(stride), [cm] "r"(cm));
224 }
225 #endif // #if HAVE_DSPR2
226