1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #include "aom_dsp/mips/common_dspr2.h"
13 
14 #if HAVE_DSPR2
aom_h_predictor_16x16_dspr2(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)15 void aom_h_predictor_16x16_dspr2(uint8_t *dst, ptrdiff_t stride,
16                                  const uint8_t *above, const uint8_t *left) {
17   int32_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
18   int32_t tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
19 
20   (void)above;
21 
22   __asm__ __volatile__(
23       "lb         %[tmp1],      (%[left])                    \n\t"
24       "lb         %[tmp2],      1(%[left])                   \n\t"
25       "lb         %[tmp3],      2(%[left])                   \n\t"
26       "lb         %[tmp4],      3(%[left])                   \n\t"
27       "lb         %[tmp5],      4(%[left])                   \n\t"
28       "lb         %[tmp6],      5(%[left])                   \n\t"
29       "lb         %[tmp7],      6(%[left])                   \n\t"
30       "lb         %[tmp8],      7(%[left])                   \n\t"
31       "lb         %[tmp9],      8(%[left])                   \n\t"
32       "lb         %[tmp10],     9(%[left])                   \n\t"
33       "lb         %[tmp11],     10(%[left])                  \n\t"
34       "lb         %[tmp12],     11(%[left])                  \n\t"
35       "lb         %[tmp13],     12(%[left])                  \n\t"
36       "lb         %[tmp14],     13(%[left])                  \n\t"
37       "lb         %[tmp15],     14(%[left])                  \n\t"
38       "lb         %[tmp16],     15(%[left])                  \n\t"
39 
40       "replv.qb   %[tmp1],      %[tmp1]                      \n\t"
41       "replv.qb   %[tmp2],      %[tmp2]                      \n\t"
42       "replv.qb   %[tmp3],      %[tmp3]                      \n\t"
43       "replv.qb   %[tmp4],      %[tmp4]                      \n\t"
44       "replv.qb   %[tmp5],      %[tmp5]                      \n\t"
45       "replv.qb   %[tmp6],      %[tmp6]                      \n\t"
46       "replv.qb   %[tmp7],      %[tmp7]                      \n\t"
47       "replv.qb   %[tmp8],      %[tmp8]                      \n\t"
48       "replv.qb   %[tmp9],      %[tmp9]                      \n\t"
49       "replv.qb   %[tmp10],     %[tmp10]                     \n\t"
50       "replv.qb   %[tmp11],     %[tmp11]                     \n\t"
51       "replv.qb   %[tmp12],     %[tmp12]                     \n\t"
52       "replv.qb   %[tmp13],     %[tmp13]                     \n\t"
53       "replv.qb   %[tmp14],     %[tmp14]                     \n\t"
54       "replv.qb   %[tmp15],     %[tmp15]                     \n\t"
55       "replv.qb   %[tmp16],     %[tmp16]                     \n\t"
56 
57       "sw         %[tmp1],      (%[dst])                     \n\t"
58       "sw         %[tmp1],      4(%[dst])                    \n\t"
59       "sw         %[tmp1],      8(%[dst])                    \n\t"
60       "sw         %[tmp1],      12(%[dst])                   \n\t"
61 
62       "add        %[dst],       %[dst],         %[stride]    \n\t"
63       "sw         %[tmp2],      (%[dst])                     \n\t"
64       "sw         %[tmp2],      4(%[dst])                    \n\t"
65       "sw         %[tmp2],      8(%[dst])                    \n\t"
66       "sw         %[tmp2],      12(%[dst])                   \n\t"
67 
68       "add        %[dst],       %[dst],         %[stride]    \n\t"
69       "sw         %[tmp3],      (%[dst])                     \n\t"
70       "sw         %[tmp3],      4(%[dst])                    \n\t"
71       "sw         %[tmp3],      8(%[dst])                    \n\t"
72       "sw         %[tmp3],      12(%[dst])                   \n\t"
73 
74       "add        %[dst],       %[dst],         %[stride]    \n\t"
75       "sw         %[tmp4],      (%[dst])                     \n\t"
76       "sw         %[tmp4],      4(%[dst])                    \n\t"
77       "sw         %[tmp4],      8(%[dst])                    \n\t"
78       "sw         %[tmp4],      12(%[dst])                   \n\t"
79 
80       "add        %[dst],       %[dst],         %[stride]    \n\t"
81       "sw         %[tmp5],      (%[dst])                     \n\t"
82       "sw         %[tmp5],      4(%[dst])                    \n\t"
83       "sw         %[tmp5],      8(%[dst])                    \n\t"
84       "sw         %[tmp5],      12(%[dst])                   \n\t"
85 
86       "add        %[dst],       %[dst],         %[stride]    \n\t"
87       "sw         %[tmp6],      (%[dst])                     \n\t"
88       "sw         %[tmp6],      4(%[dst])                    \n\t"
89       "sw         %[tmp6],      8(%[dst])                    \n\t"
90       "sw         %[tmp6],      12(%[dst])                   \n\t"
91 
92       "add        %[dst],       %[dst],         %[stride]    \n\t"
93       "sw         %[tmp7],      (%[dst])                     \n\t"
94       "sw         %[tmp7],      4(%[dst])                    \n\t"
95       "sw         %[tmp7],      8(%[dst])                    \n\t"
96       "sw         %[tmp7],      12(%[dst])                   \n\t"
97 
98       "add        %[dst],       %[dst],         %[stride]    \n\t"
99       "sw         %[tmp8],      (%[dst])                     \n\t"
100       "sw         %[tmp8],      4(%[dst])                    \n\t"
101       "sw         %[tmp8],      8(%[dst])                    \n\t"
102       "sw         %[tmp8],      12(%[dst])                   \n\t"
103 
104       "add        %[dst],       %[dst],         %[stride]    \n\t"
105       "sw         %[tmp9],      (%[dst])                     \n\t"
106       "sw         %[tmp9],      4(%[dst])                    \n\t"
107       "sw         %[tmp9],      8(%[dst])                    \n\t"
108       "sw         %[tmp9],      12(%[dst])                   \n\t"
109 
110       "add        %[dst],       %[dst],         %[stride]    \n\t"
111       "sw         %[tmp10],     (%[dst])                     \n\t"
112       "sw         %[tmp10],     4(%[dst])                    \n\t"
113       "sw         %[tmp10],     8(%[dst])                    \n\t"
114       "sw         %[tmp10],     12(%[dst])                   \n\t"
115 
116       "add        %[dst],       %[dst],         %[stride]    \n\t"
117       "sw         %[tmp11],     (%[dst])                     \n\t"
118       "sw         %[tmp11],     4(%[dst])                    \n\t"
119       "sw         %[tmp11],     8(%[dst])                    \n\t"
120       "sw         %[tmp11],     12(%[dst])                   \n\t"
121 
122       "add        %[dst],       %[dst],         %[stride]    \n\t"
123       "sw         %[tmp12],     (%[dst])                     \n\t"
124       "sw         %[tmp12],     4(%[dst])                    \n\t"
125       "sw         %[tmp12],     8(%[dst])                    \n\t"
126       "sw         %[tmp12],     12(%[dst])                   \n\t"
127 
128       "add        %[dst],       %[dst],         %[stride]    \n\t"
129       "sw         %[tmp13],     (%[dst])                     \n\t"
130       "sw         %[tmp13],     4(%[dst])                    \n\t"
131       "sw         %[tmp13],     8(%[dst])                    \n\t"
132       "sw         %[tmp13],     12(%[dst])                   \n\t"
133 
134       "add        %[dst],       %[dst],         %[stride]    \n\t"
135       "sw         %[tmp14],     (%[dst])                     \n\t"
136       "sw         %[tmp14],     4(%[dst])                    \n\t"
137       "sw         %[tmp14],     8(%[dst])                    \n\t"
138       "sw         %[tmp14],     12(%[dst])                   \n\t"
139 
140       "add        %[dst],       %[dst],         %[stride]    \n\t"
141       "sw         %[tmp15],     (%[dst])                     \n\t"
142       "sw         %[tmp15],     4(%[dst])                    \n\t"
143       "sw         %[tmp15],     8(%[dst])                    \n\t"
144       "sw         %[tmp15],     12(%[dst])                   \n\t"
145 
146       "add        %[dst],       %[dst],         %[stride]    \n\t"
147       "sw         %[tmp16],     (%[dst])                     \n\t"
148       "sw         %[tmp16],     4(%[dst])                    \n\t"
149       "sw         %[tmp16],     8(%[dst])                    \n\t"
150       "sw         %[tmp16],     12(%[dst])                   \n\t"
151 
152       : [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [tmp3] "=&r"(tmp3),
153         [tmp4] "=&r"(tmp4), [tmp5] "=&r"(tmp5), [tmp7] "=&r"(tmp7),
154         [tmp6] "=&r"(tmp6), [tmp8] "=&r"(tmp8), [tmp9] "=&r"(tmp9),
155         [tmp10] "=&r"(tmp10), [tmp11] "=&r"(tmp11), [tmp12] "=&r"(tmp12),
156         [tmp13] "=&r"(tmp13), [tmp14] "=&r"(tmp14), [tmp15] "=&r"(tmp15),
157         [tmp16] "=&r"(tmp16)
158       : [left] "r"(left), [dst] "r"(dst), [stride] "r"(stride));
159 }
160 
aom_dc_predictor_16x16_dspr2(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)161 void aom_dc_predictor_16x16_dspr2(uint8_t *dst, ptrdiff_t stride,
162                                   const uint8_t *above, const uint8_t *left) {
163   int32_t expected_dc;
164   int32_t average;
165   int32_t tmp, above1, above_l1, above_r1, left1, left_r1, left_l1;
166   int32_t above2, left2;
167 
168   __asm__ __volatile__(
169       "lw              %[above1],           (%[above])                    \n\t"
170       "lw              %[above2],           4(%[above])                   \n\t"
171       "lw              %[left1],            (%[left])                     \n\t"
172       "lw              %[left2],            4(%[left])                    \n\t"
173 
174       "preceu.ph.qbl   %[above_l1],         %[above1]                     \n\t"
175       "preceu.ph.qbr   %[above_r1],         %[above1]                     \n\t"
176       "preceu.ph.qbl   %[left_l1],          %[left1]                      \n\t"
177       "preceu.ph.qbr   %[left_r1],          %[left1]                      \n\t"
178 
179       "addu.ph         %[average],          %[above_r1],     %[above_l1]  \n\t"
180       "addu.ph         %[average],          %[average],      %[left_l1]   \n\t"
181       "addu.ph         %[average],          %[average],      %[left_r1]   \n\t"
182 
183       "preceu.ph.qbl   %[above_l1],         %[above2]                     \n\t"
184       "preceu.ph.qbr   %[above_r1],         %[above2]                     \n\t"
185       "preceu.ph.qbl   %[left_l1],          %[left2]                      \n\t"
186       "preceu.ph.qbr   %[left_r1],          %[left2]                      \n\t"
187 
188       "addu.ph         %[average],          %[average],      %[above_l1]  \n\t"
189       "addu.ph         %[average],          %[average],      %[above_r1]  \n\t"
190       "addu.ph         %[average],          %[average],      %[left_l1]   \n\t"
191       "addu.ph         %[average],          %[average],      %[left_r1]   \n\t"
192 
193       "lw              %[above1],           8(%[above])                   \n\t"
194       "lw              %[above2],           12(%[above])                  \n\t"
195       "lw              %[left1],            8(%[left])                    \n\t"
196       "lw              %[left2],            12(%[left])                   \n\t"
197 
198       "preceu.ph.qbl   %[above_l1],         %[above1]                     \n\t"
199       "preceu.ph.qbr   %[above_r1],         %[above1]                     \n\t"
200       "preceu.ph.qbl   %[left_l1],          %[left1]                      \n\t"
201       "preceu.ph.qbr   %[left_r1],          %[left1]                      \n\t"
202 
203       "addu.ph         %[average],          %[average],      %[above_l1]  \n\t"
204       "addu.ph         %[average],          %[average],      %[above_r1]  \n\t"
205       "addu.ph         %[average],          %[average],      %[left_l1]   \n\t"
206       "addu.ph         %[average],          %[average],      %[left_r1]   \n\t"
207 
208       "preceu.ph.qbl   %[above_l1],         %[above2]                     \n\t"
209       "preceu.ph.qbr   %[above_r1],         %[above2]                     \n\t"
210       "preceu.ph.qbl   %[left_l1],          %[left2]                      \n\t"
211       "preceu.ph.qbr   %[left_r1],          %[left2]                      \n\t"
212 
213       "addu.ph         %[average],          %[average],      %[above_l1]  \n\t"
214       "addu.ph         %[average],          %[average],      %[above_r1]  \n\t"
215       "addu.ph         %[average],          %[average],      %[left_l1]   \n\t"
216       "addu.ph         %[average],          %[average],      %[left_r1]   \n\t"
217 
218       "addiu           %[average],          %[average],      16           \n\t"
219       "srl             %[tmp],              %[average],      16           \n\t"
220       "addu.ph         %[average],          %[tmp],          %[average]   \n\t"
221       "srl             %[expected_dc],      %[average],      5            \n\t"
222       "replv.qb        %[expected_dc],      %[expected_dc]                \n\t"
223 
224       "sw              %[expected_dc],      (%[dst])                      \n\t"
225       "sw              %[expected_dc],      4(%[dst])                     \n\t"
226       "sw              %[expected_dc],      8(%[dst])                     \n\t"
227       "sw              %[expected_dc],      12(%[dst])                    \n\t"
228 
229       "add             %[dst],              %[dst],          %[stride]    \n\t"
230       "sw              %[expected_dc],      (%[dst])                      \n\t"
231       "sw              %[expected_dc],      4(%[dst])                     \n\t"
232       "sw              %[expected_dc],      8(%[dst])                     \n\t"
233       "sw              %[expected_dc],      12(%[dst])                    \n\t"
234 
235       "add             %[dst],              %[dst],          %[stride]    \n\t"
236       "sw              %[expected_dc],      (%[dst])                      \n\t"
237       "sw              %[expected_dc],      4(%[dst])                     \n\t"
238       "sw              %[expected_dc],      8(%[dst])                     \n\t"
239       "sw              %[expected_dc],      12(%[dst])                    \n\t"
240 
241       "add             %[dst],              %[dst],          %[stride]    \n\t"
242       "sw              %[expected_dc],      (%[dst])                      \n\t"
243       "sw              %[expected_dc],      4(%[dst])                     \n\t"
244       "sw              %[expected_dc],      8(%[dst])                     \n\t"
245       "sw              %[expected_dc],      12(%[dst])                    \n\t"
246 
247       "add             %[dst],              %[dst],          %[stride]    \n\t"
248       "sw              %[expected_dc],      (%[dst])                      \n\t"
249       "sw              %[expected_dc],      4(%[dst])                     \n\t"
250       "sw              %[expected_dc],      8(%[dst])                     \n\t"
251       "sw              %[expected_dc],      12(%[dst])                    \n\t"
252 
253       "add             %[dst],              %[dst],          %[stride]    \n\t"
254       "sw              %[expected_dc],      (%[dst])                      \n\t"
255       "sw              %[expected_dc],      4(%[dst])                     \n\t"
256       "sw              %[expected_dc],      8(%[dst])                     \n\t"
257       "sw              %[expected_dc],      12(%[dst])                    \n\t"
258 
259       "add             %[dst],              %[dst],          %[stride]    \n\t"
260       "sw              %[expected_dc],      (%[dst])                      \n\t"
261       "sw              %[expected_dc],      4(%[dst])                     \n\t"
262       "sw              %[expected_dc],      8(%[dst])                     \n\t"
263       "sw              %[expected_dc],      12(%[dst])                    \n\t"
264 
265       "add             %[dst],              %[dst],          %[stride]    \n\t"
266       "sw              %[expected_dc],      (%[dst])                      \n\t"
267       "sw              %[expected_dc],      4(%[dst])                     \n\t"
268       "sw              %[expected_dc],      8(%[dst])                     \n\t"
269       "sw              %[expected_dc],      12(%[dst])                    \n\t"
270 
271       "add             %[dst],              %[dst],          %[stride]    \n\t"
272       "sw              %[expected_dc],      (%[dst])                      \n\t"
273       "sw              %[expected_dc],      4(%[dst])                     \n\t"
274       "sw              %[expected_dc],      8(%[dst])                     \n\t"
275       "sw              %[expected_dc],      12(%[dst])                    \n\t"
276 
277       "add             %[dst],              %[dst],          %[stride]    \n\t"
278       "sw              %[expected_dc],      (%[dst])                      \n\t"
279       "sw              %[expected_dc],      4(%[dst])                     \n\t"
280       "sw              %[expected_dc],      8(%[dst])                     \n\t"
281       "sw              %[expected_dc],      12(%[dst])                    \n\t"
282 
283       "add             %[dst],              %[dst],          %[stride]    \n\t"
284       "sw              %[expected_dc],      (%[dst])                      \n\t"
285       "sw              %[expected_dc],      4(%[dst])                     \n\t"
286       "sw              %[expected_dc],      8(%[dst])                     \n\t"
287       "sw              %[expected_dc],      12(%[dst])                    \n\t"
288 
289       "add             %[dst],              %[dst],          %[stride]    \n\t"
290       "sw              %[expected_dc],      (%[dst])                      \n\t"
291       "sw              %[expected_dc],      4(%[dst])                     \n\t"
292       "sw              %[expected_dc],      8(%[dst])                     \n\t"
293       "sw              %[expected_dc],      12(%[dst])                    \n\t"
294 
295       "add             %[dst],              %[dst],          %[stride]    \n\t"
296       "sw              %[expected_dc],      (%[dst])                      \n\t"
297       "sw              %[expected_dc],      4(%[dst])                     \n\t"
298       "sw              %[expected_dc],      8(%[dst])                     \n\t"
299       "sw              %[expected_dc],      12(%[dst])                    \n\t"
300 
301       "add             %[dst],              %[dst],          %[stride]    \n\t"
302       "sw              %[expected_dc],      (%[dst])                      \n\t"
303       "sw              %[expected_dc],      4(%[dst])                     \n\t"
304       "sw              %[expected_dc],      8(%[dst])                     \n\t"
305       "sw              %[expected_dc],      12(%[dst])                    \n\t"
306 
307       "add             %[dst],              %[dst],          %[stride]    \n\t"
308       "sw              %[expected_dc],      (%[dst])                      \n\t"
309       "sw              %[expected_dc],      4(%[dst])                     \n\t"
310       "sw              %[expected_dc],      8(%[dst])                     \n\t"
311       "sw              %[expected_dc],      12(%[dst])                    \n\t"
312 
313       "add             %[dst],              %[dst],          %[stride]    \n\t"
314       "sw              %[expected_dc],      (%[dst])                      \n\t"
315       "sw              %[expected_dc],      4(%[dst])                     \n\t"
316       "sw              %[expected_dc],      8(%[dst])                     \n\t"
317       "sw              %[expected_dc],      12(%[dst])                    \n\t"
318 
319       : [left1] "=&r"(left1), [above1] "=&r"(above1), [left_l1] "=&r"(left_l1),
320         [above_l1] "=&r"(above_l1), [left_r1] "=&r"(left_r1),
321         [above_r1] "=&r"(above_r1), [above2] "=&r"(above2),
322         [left2] "=&r"(left2), [average] "=&r"(average), [tmp] "=&r"(tmp),
323         [expected_dc] "=&r"(expected_dc)
324       : [above] "r"(above), [left] "r"(left), [dst] "r"(dst),
325         [stride] "r"(stride));
326 }
327 #endif  // #if HAVE_DSPR2
328