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 
18   __asm__ __volatile__ (
19       "lb         %[tmp1],      (%[left])                    \n\t"
20       "lb         %[tmp2],      1(%[left])                   \n\t"
21       "lb         %[tmp3],      2(%[left])                   \n\t"
22       "lb         %[tmp4],      3(%[left])                   \n\t"
23       "replv.qb   %[tmp1],      %[tmp1]                      \n\t"
24       "replv.qb   %[tmp2],      %[tmp2]                      \n\t"
25       "replv.qb   %[tmp3],      %[tmp3]                      \n\t"
26       "replv.qb   %[tmp4],      %[tmp4]                      \n\t"
27       "sw         %[tmp1],      (%[dst])                     \n\t"
28       "add        %[dst],       %[dst],         %[stride]    \n\t"
29       "sw         %[tmp2],      (%[dst])                     \n\t"
30       "add        %[dst],       %[dst],         %[stride]    \n\t"
31       "sw         %[tmp3],      (%[dst])                     \n\t"
32       "add        %[dst],       %[dst],         %[stride]    \n\t"
33       "sw         %[tmp4],      (%[dst])                     \n\t"
34 
35       : [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2),
36         [tmp3] "=&r" (tmp3), [tmp4] "=&r" (tmp4)
37       : [left] "r" (left), [dst] "r" (dst), [stride] "r" (stride)
38   );
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),
79         [dst] "r" (dst), [stride] "r" (stride)
80   );
81 }
82 
vpx_tm_predictor_4x4_dspr2(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)83 void vpx_tm_predictor_4x4_dspr2(uint8_t *dst, ptrdiff_t stride,
84                                 const uint8_t *above, const uint8_t *left) {
85   int32_t  abovel, abover;
86   int32_t  left0, left1, left2, left3;
87   int32_t  res0, res1;
88   int32_t  resl;
89   int32_t  resr;
90   int32_t  top_left;
91   uint8_t  *cm = vpx_ff_cropTbl;
92 
93   __asm__ __volatile__ (
94       "ulw             %[resl],       (%[above])                         \n\t"
95 
96       "lbu             %[left0],       (%[left])                         \n\t"
97       "lbu             %[left1],       1(%[left])                        \n\t"
98       "lbu             %[left2],       2(%[left])                        \n\t"
99       "lbu             %[left3],       3(%[left])                        \n\t"
100 
101       "lbu             %[top_left],    -1(%[above])                      \n\t"
102 
103       "preceu.ph.qbl   %[abovel],      %[resl]                           \n\t"
104       "preceu.ph.qbr   %[abover],      %[resl]                           \n\t"
105 
106       "replv.ph        %[left0],       %[left0]                          \n\t"
107       "replv.ph        %[left1],       %[left1]                          \n\t"
108       "replv.ph        %[left2],       %[left2]                          \n\t"
109       "replv.ph        %[left3],       %[left3]                          \n\t"
110 
111       "replv.ph        %[top_left],    %[top_left]                       \n\t"
112 
113       "addu.ph         %[resl],        %[abovel],         %[left0]       \n\t"
114       "subu.ph         %[resl],        %[resl],           %[top_left]    \n\t"
115 
116       "addu.ph         %[resr],        %[abover],         %[left0]       \n\t"
117       "subu.ph         %[resr],        %[resr],           %[top_left]    \n\t"
118 
119       "sll             %[res0],        %[resr],           16             \n\t"
120       "sra             %[res0],        %[res0],           16             \n\t"
121       "lbux            %[res0],        %[res0](%[cm])                    \n\t"
122 
123       "sra             %[res1],        %[resr],           16             \n\t"
124       "lbux            %[res1],        %[res1](%[cm])                    \n\t"
125       "sb              %[res0],        (%[dst])                          \n\t"
126 
127       "sll             %[res0],        %[resl],           16             \n\t"
128       "sra             %[res0],        %[res0],           16             \n\t"
129       "lbux            %[res0],        %[res0](%[cm])                    \n\t"
130       "sb              %[res1],        1(%[dst])                         \n\t"
131 
132       "sra             %[res1],        %[resl],           16             \n\t"
133       "lbux            %[res1],        %[res1](%[cm])                    \n\t"
134 
135       "addu.ph         %[resl],        %[abovel],         %[left1]       \n\t"
136       "subu.ph         %[resl],        %[resl],           %[top_left]    \n\t"
137 
138       "addu.ph         %[resr],        %[abover],         %[left1]       \n\t"
139       "subu.ph         %[resr],        %[resr],           %[top_left]    \n\t"
140 
141       "sb              %[res0],        2(%[dst])                         \n\t"
142       "sb              %[res1],        3(%[dst])                         \n\t"
143 
144       "add             %[dst],          %[dst],           %[stride]      \n\t"
145 
146       "sll             %[res0],        %[resr],           16             \n\t"
147       "sra             %[res0],        %[res0],           16             \n\t"
148       "lbux            %[res0],        %[res0](%[cm])                    \n\t"
149 
150       "sra             %[res1],        %[resr],           16             \n\t"
151       "lbux            %[res1],        %[res1](%[cm])                    \n\t"
152       "sb              %[res0],        (%[dst])                          \n\t"
153 
154       "sll             %[res0],        %[resl],           16             \n\t"
155       "sra             %[res0],        %[res0],           16             \n\t"
156       "lbux            %[res0],        %[res0](%[cm])                    \n\t"
157 
158       "sb              %[res1],        1(%[dst])                         \n\t"
159       "sra             %[res1],        %[resl],           16             \n\t"
160       "lbux            %[res1],        %[res1](%[cm])                    \n\t"
161 
162       "addu.ph         %[resl],        %[abovel],         %[left2]       \n\t"
163       "subu.ph         %[resl],        %[resl],           %[top_left]    \n\t"
164 
165       "addu.ph         %[resr],        %[abover],         %[left2]       \n\t"
166       "subu.ph         %[resr],        %[resr],           %[top_left]    \n\t"
167 
168       "sb              %[res0],        2(%[dst])                         \n\t"
169       "sb              %[res1],        3(%[dst])                         \n\t"
170 
171       "add             %[dst],          %[dst],           %[stride]      \n\t"
172 
173       "sll             %[res0],        %[resr],           16             \n\t"
174       "sra             %[res0],        %[res0],           16             \n\t"
175       "lbux            %[res0],        %[res0](%[cm])                    \n\t"
176 
177 
178       "sra             %[res1],        %[resr],           16             \n\t"
179       "lbux            %[res1],        %[res1](%[cm])                    \n\t"
180       "sb              %[res0],        (%[dst])                          \n\t"
181 
182       "sll             %[res0],        %[resl],           16             \n\t"
183       "sra             %[res0],        %[res0],           16             \n\t"
184       "lbux            %[res0],        %[res0](%[cm])                    \n\t"
185 
186 
187       "sb              %[res1],        1(%[dst])                         \n\t"
188       "sra             %[res1],        %[resl],           16             \n\t"
189       "lbux            %[res1],        %[res1](%[cm])                    \n\t"
190 
191       "addu.ph         %[resl],        %[abovel],        %[left3]        \n\t"
192       "subu.ph         %[resl],        %[resl],          %[top_left]     \n\t"
193 
194       "addu.ph         %[resr],        %[abover],        %[left3]        \n\t"
195       "subu.ph         %[resr],        %[resr],          %[top_left]     \n\t"
196 
197       "sb              %[res0],        2(%[dst])                         \n\t"
198       "sb              %[res1],        3(%[dst])                         \n\t"
199 
200       "add             %[dst],          %[dst],          %[stride]       \n\t"
201 
202       "sll             %[res0],        %[resr],           16             \n\t"
203       "sra             %[res0],        %[res0],           16             \n\t"
204       "lbux            %[res0],        %[res0](%[cm])                    \n\t"
205 
206       "sra             %[res1],        %[resr],           16             \n\t"
207       "lbux            %[res1],        %[res1](%[cm])                    \n\t"
208       "sb              %[res0],        (%[dst])                          \n\t"
209 
210       "sll             %[res0],        %[resl],           16             \n\t"
211       "sra             %[res0],        %[res0],           16             \n\t"
212       "lbux            %[res0],        %[res0](%[cm])                    \n\t"
213       "sb              %[res1],        1(%[dst])                         \n\t"
214 
215       "sra             %[res1],        %[resl],           16             \n\t"
216       "lbux            %[res1],        %[res1](%[cm])                    \n\t"
217 
218       "sb              %[res0],        2(%[dst])                         \n\t"
219       "sb              %[res1],        3(%[dst])                         \n\t"
220 
221       : [abovel] "=&r" (abovel), [abover] "=&r" (abover),
222         [left0] "=&r" (left0), [left1] "=&r" (left1), [left2] "=&r" (left2),
223         [res0] "=&r" (res0), [res1] "=&r" (res1), [left3] "=&r" (left3),
224         [resl] "=&r" (resl), [resr] "=&r" (resr), [top_left] "=&r" (top_left)
225       : [above] "r" (above), [left] "r" (left),
226         [dst] "r" (dst), [stride] "r" (stride), [cm] "r" (cm)
227   );
228 }
229 #endif  // #if HAVE_DSPR2
230