1/*
2 *  Copyright (c) 2013 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#include <stdlib.h>
11
12#include "./vp9_rtcd.h"
13#include "vp9/common/vp9_common.h"
14#include "vp9/common/mips/dspr2/vp9_common_dspr2.h"
15
16#if HAVE_DSPR2
17void vp9_h_predictor_16x16_dspr2(uint8_t *dst, ptrdiff_t stride,
18                                 const uint8_t *above, const uint8_t *left) {
19  int32_t  tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
20  int32_t  tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
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),
153        [tmp3] "=&r" (tmp3),   [tmp4] "=&r" (tmp4),
154        [tmp5] "=&r" (tmp5),   [tmp7] "=&r" (tmp7),
155        [tmp6] "=&r" (tmp6),   [tmp8] "=&r" (tmp8),
156        [tmp9] "=&r" (tmp9),   [tmp10] "=&r" (tmp10),
157        [tmp11] "=&r" (tmp11), [tmp12] "=&r" (tmp12),
158        [tmp13] "=&r" (tmp13), [tmp14] "=&r" (tmp14),
159        [tmp15] "=&r" (tmp15), [tmp16] "=&r" (tmp16)
160      : [left] "r" (left), [dst] "r" (dst), [stride] "r" (stride)
161  );
162}
163
164void vp9_dc_predictor_16x16_dspr2(uint8_t *dst, ptrdiff_t stride,
165                                  const uint8_t *above, const uint8_t *left) {
166  int32_t  expected_dc;
167  int32_t  average;
168  int32_t  tmp, above1, above_l1, above_r1, left1, left_r1, left_l1;
169  int32_t  above2, left2;
170
171  __asm__ __volatile__ (
172      "lw              %[above1],           (%[above])                    \n\t"
173      "lw              %[above2],           4(%[above])                   \n\t"
174      "lw              %[left1],            (%[left])                     \n\t"
175      "lw              %[left2],            4(%[left])                    \n\t"
176
177      "preceu.ph.qbl   %[above_l1],         %[above1]                     \n\t"
178      "preceu.ph.qbr   %[above_r1],         %[above1]                     \n\t"
179      "preceu.ph.qbl   %[left_l1],          %[left1]                      \n\t"
180      "preceu.ph.qbr   %[left_r1],          %[left1]                      \n\t"
181
182      "addu.ph         %[average],          %[above_r1],     %[above_l1]  \n\t"
183      "addu.ph         %[average],          %[average],      %[left_l1]   \n\t"
184      "addu.ph         %[average],          %[average],      %[left_r1]   \n\t"
185
186      "preceu.ph.qbl   %[above_l1],         %[above2]                     \n\t"
187      "preceu.ph.qbr   %[above_r1],         %[above2]                     \n\t"
188      "preceu.ph.qbl   %[left_l1],          %[left2]                      \n\t"
189      "preceu.ph.qbr   %[left_r1],          %[left2]                      \n\t"
190
191      "addu.ph         %[average],          %[average],      %[above_l1]  \n\t"
192      "addu.ph         %[average],          %[average],      %[above_r1]  \n\t"
193      "addu.ph         %[average],          %[average],      %[left_l1]   \n\t"
194      "addu.ph         %[average],          %[average],      %[left_r1]   \n\t"
195
196      "lw              %[above1],           8(%[above])                   \n\t"
197      "lw              %[above2],           12(%[above])                  \n\t"
198      "lw              %[left1],            8(%[left])                    \n\t"
199      "lw              %[left2],            12(%[left])                   \n\t"
200
201      "preceu.ph.qbl   %[above_l1],         %[above1]                     \n\t"
202      "preceu.ph.qbr   %[above_r1],         %[above1]                     \n\t"
203      "preceu.ph.qbl   %[left_l1],          %[left1]                      \n\t"
204      "preceu.ph.qbr   %[left_r1],          %[left1]                      \n\t"
205
206      "addu.ph         %[average],          %[average],      %[above_l1]  \n\t"
207      "addu.ph         %[average],          %[average],      %[above_r1]  \n\t"
208      "addu.ph         %[average],          %[average],      %[left_l1]   \n\t"
209      "addu.ph         %[average],          %[average],      %[left_r1]   \n\t"
210
211      "preceu.ph.qbl   %[above_l1],         %[above2]                     \n\t"
212      "preceu.ph.qbr   %[above_r1],         %[above2]                     \n\t"
213      "preceu.ph.qbl   %[left_l1],          %[left2]                      \n\t"
214      "preceu.ph.qbr   %[left_r1],          %[left2]                      \n\t"
215
216      "addu.ph         %[average],          %[average],      %[above_l1]  \n\t"
217      "addu.ph         %[average],          %[average],      %[above_r1]  \n\t"
218      "addu.ph         %[average],          %[average],      %[left_l1]   \n\t"
219      "addu.ph         %[average],          %[average],      %[left_r1]   \n\t"
220
221      "addiu           %[average],          %[average],      16           \n\t"
222      "srl             %[tmp],              %[average],      16           \n\t"
223      "addu.ph         %[average],          %[tmp],          %[average]   \n\t"
224      "srl             %[expected_dc],      %[average],      5            \n\t"
225      "replv.qb        %[expected_dc],      %[expected_dc]                \n\t"
226
227      "sw              %[expected_dc],      (%[dst])                      \n\t"
228      "sw              %[expected_dc],      4(%[dst])                     \n\t"
229      "sw              %[expected_dc],      8(%[dst])                     \n\t"
230      "sw              %[expected_dc],      12(%[dst])                    \n\t"
231
232      "add             %[dst],              %[dst],          %[stride]    \n\t"
233      "sw              %[expected_dc],      (%[dst])                      \n\t"
234      "sw              %[expected_dc],      4(%[dst])                     \n\t"
235      "sw              %[expected_dc],      8(%[dst])                     \n\t"
236      "sw              %[expected_dc],      12(%[dst])                    \n\t"
237
238      "add             %[dst],              %[dst],          %[stride]    \n\t"
239      "sw              %[expected_dc],      (%[dst])                      \n\t"
240      "sw              %[expected_dc],      4(%[dst])                     \n\t"
241      "sw              %[expected_dc],      8(%[dst])                     \n\t"
242      "sw              %[expected_dc],      12(%[dst])                    \n\t"
243
244      "add             %[dst],              %[dst],          %[stride]    \n\t"
245      "sw              %[expected_dc],      (%[dst])                      \n\t"
246      "sw              %[expected_dc],      4(%[dst])                     \n\t"
247      "sw              %[expected_dc],      8(%[dst])                     \n\t"
248      "sw              %[expected_dc],      12(%[dst])                    \n\t"
249
250      "add             %[dst],              %[dst],          %[stride]    \n\t"
251      "sw              %[expected_dc],      (%[dst])                      \n\t"
252      "sw              %[expected_dc],      4(%[dst])                     \n\t"
253      "sw              %[expected_dc],      8(%[dst])                     \n\t"
254      "sw              %[expected_dc],      12(%[dst])                    \n\t"
255
256      "add             %[dst],              %[dst],          %[stride]    \n\t"
257      "sw              %[expected_dc],      (%[dst])                      \n\t"
258      "sw              %[expected_dc],      4(%[dst])                     \n\t"
259      "sw              %[expected_dc],      8(%[dst])                     \n\t"
260      "sw              %[expected_dc],      12(%[dst])                    \n\t"
261
262      "add             %[dst],              %[dst],          %[stride]    \n\t"
263      "sw              %[expected_dc],      (%[dst])                      \n\t"
264      "sw              %[expected_dc],      4(%[dst])                     \n\t"
265      "sw              %[expected_dc],      8(%[dst])                     \n\t"
266      "sw              %[expected_dc],      12(%[dst])                    \n\t"
267
268      "add             %[dst],              %[dst],          %[stride]    \n\t"
269      "sw              %[expected_dc],      (%[dst])                      \n\t"
270      "sw              %[expected_dc],      4(%[dst])                     \n\t"
271      "sw              %[expected_dc],      8(%[dst])                     \n\t"
272      "sw              %[expected_dc],      12(%[dst])                    \n\t"
273
274      "add             %[dst],              %[dst],          %[stride]    \n\t"
275      "sw              %[expected_dc],      (%[dst])                      \n\t"
276      "sw              %[expected_dc],      4(%[dst])                     \n\t"
277      "sw              %[expected_dc],      8(%[dst])                     \n\t"
278      "sw              %[expected_dc],      12(%[dst])                    \n\t"
279
280      "add             %[dst],              %[dst],          %[stride]    \n\t"
281      "sw              %[expected_dc],      (%[dst])                      \n\t"
282      "sw              %[expected_dc],      4(%[dst])                     \n\t"
283      "sw              %[expected_dc],      8(%[dst])                     \n\t"
284      "sw              %[expected_dc],      12(%[dst])                    \n\t"
285
286      "add             %[dst],              %[dst],          %[stride]    \n\t"
287      "sw              %[expected_dc],      (%[dst])                      \n\t"
288      "sw              %[expected_dc],      4(%[dst])                     \n\t"
289      "sw              %[expected_dc],      8(%[dst])                     \n\t"
290      "sw              %[expected_dc],      12(%[dst])                    \n\t"
291
292      "add             %[dst],              %[dst],          %[stride]    \n\t"
293      "sw              %[expected_dc],      (%[dst])                      \n\t"
294      "sw              %[expected_dc],      4(%[dst])                     \n\t"
295      "sw              %[expected_dc],      8(%[dst])                     \n\t"
296      "sw              %[expected_dc],      12(%[dst])                    \n\t"
297
298      "add             %[dst],              %[dst],          %[stride]    \n\t"
299      "sw              %[expected_dc],      (%[dst])                      \n\t"
300      "sw              %[expected_dc],      4(%[dst])                     \n\t"
301      "sw              %[expected_dc],      8(%[dst])                     \n\t"
302      "sw              %[expected_dc],      12(%[dst])                    \n\t"
303
304      "add             %[dst],              %[dst],          %[stride]    \n\t"
305      "sw              %[expected_dc],      (%[dst])                      \n\t"
306      "sw              %[expected_dc],      4(%[dst])                     \n\t"
307      "sw              %[expected_dc],      8(%[dst])                     \n\t"
308      "sw              %[expected_dc],      12(%[dst])                    \n\t"
309
310      "add             %[dst],              %[dst],          %[stride]    \n\t"
311      "sw              %[expected_dc],      (%[dst])                      \n\t"
312      "sw              %[expected_dc],      4(%[dst])                     \n\t"
313      "sw              %[expected_dc],      8(%[dst])                     \n\t"
314      "sw              %[expected_dc],      12(%[dst])                    \n\t"
315
316      "add             %[dst],              %[dst],          %[stride]    \n\t"
317      "sw              %[expected_dc],      (%[dst])                      \n\t"
318      "sw              %[expected_dc],      4(%[dst])                     \n\t"
319      "sw              %[expected_dc],      8(%[dst])                     \n\t"
320      "sw              %[expected_dc],      12(%[dst])                    \n\t"
321
322      : [left1] "=&r" (left1), [above1] "=&r" (above1),
323        [left_l1] "=&r" (left_l1), [above_l1] "=&r" (above_l1),
324        [left_r1] "=&r" (left_r1), [above_r1] "=&r" (above_r1),
325        [above2] "=&r" (above2), [left2] "=&r" (left2),
326        [average] "=&r" (average), [tmp] "=&r" (tmp),
327        [expected_dc] "=&r" (expected_dc)
328      : [above] "r" (above), [left] "r" (left),
329        [dst] "r" (dst), [stride] "r" (stride)
330  );
331}
332#endif  // #if HAVE_DSPR2
333