1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
/*
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#include "config/aom_dsp_rtcd.h"
#include "aom_dsp/mips/macros_msa.h"
static void sub_blk_4x4_msa(const uint8_t *src_ptr, int32_t src_stride,
const uint8_t *pred_ptr, int32_t pred_stride,
int16_t *diff_ptr, int32_t diff_stride) {
uint32_t src0, src1, src2, src3;
uint32_t pred0, pred1, pred2, pred3;
v16i8 src = { 0 };
v16i8 pred = { 0 };
v16u8 src_l0, src_l1;
v8i16 diff0, diff1;
LW4(src_ptr, src_stride, src0, src1, src2, src3);
LW4(pred_ptr, pred_stride, pred0, pred1, pred2, pred3);
INSERT_W4_SB(src0, src1, src2, src3, src);
INSERT_W4_SB(pred0, pred1, pred2, pred3, pred);
ILVRL_B2_UB(src, pred, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST8x4_UB(diff0, diff1, diff_ptr, (2 * diff_stride));
}
static void sub_blk_8x8_msa(const uint8_t *src_ptr, int32_t src_stride,
const uint8_t *pred_ptr, int32_t pred_stride,
int16_t *diff_ptr, int32_t diff_stride) {
uint32_t loop_cnt;
uint64_t src0, src1, pred0, pred1;
v16i8 src = { 0 };
v16i8 pred = { 0 };
v16u8 src_l0, src_l1;
v8i16 diff0, diff1;
for (loop_cnt = 4; loop_cnt--;) {
LD2(src_ptr, src_stride, src0, src1);
src_ptr += (2 * src_stride);
LD2(pred_ptr, pred_stride, pred0, pred1);
pred_ptr += (2 * pred_stride);
INSERT_D2_SB(src0, src1, src);
INSERT_D2_SB(pred0, pred1, pred);
ILVRL_B2_UB(src, pred, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff_ptr, diff_stride);
diff_ptr += (2 * diff_stride);
}
}
static void sub_blk_16x16_msa(const uint8_t *src, int32_t src_stride,
const uint8_t *pred, int32_t pred_stride,
int16_t *diff, int32_t diff_stride) {
int8_t count;
v16i8 src0, src1, src2, src3, src4, src5, src6, src7;
v16i8 pred0, pred1, pred2, pred3, pred4, pred5, pred6, pred7;
v16u8 src_l0, src_l1;
v8i16 diff0, diff1;
for (count = 2; count--;) {
LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
src += (8 * src_stride);
LD_SB8(pred, pred_stride, pred0, pred1, pred2, pred3, pred4, pred5, pred6,
pred7);
pred += (8 * pred_stride);
ILVRL_B2_UB(src0, pred0, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
diff += diff_stride;
ILVRL_B2_UB(src1, pred1, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
diff += diff_stride;
ILVRL_B2_UB(src2, pred2, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
diff += diff_stride;
ILVRL_B2_UB(src3, pred3, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
diff += diff_stride;
ILVRL_B2_UB(src4, pred4, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
diff += diff_stride;
ILVRL_B2_UB(src5, pred5, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
diff += diff_stride;
ILVRL_B2_UB(src6, pred6, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
diff += diff_stride;
ILVRL_B2_UB(src7, pred7, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
diff += diff_stride;
}
}
static void sub_blk_32x32_msa(const uint8_t *src, int32_t src_stride,
const uint8_t *pred, int32_t pred_stride,
int16_t *diff, int32_t diff_stride) {
uint32_t loop_cnt;
v16i8 src0, src1, src2, src3, src4, src5, src6, src7;
v16i8 pred0, pred1, pred2, pred3, pred4, pred5, pred6, pred7;
v16u8 src_l0, src_l1;
v8i16 diff0, diff1;
for (loop_cnt = 8; loop_cnt--;) {
LD_SB2(src, 16, src0, src1);
src += src_stride;
LD_SB2(src, 16, src2, src3);
src += src_stride;
LD_SB2(src, 16, src4, src5);
src += src_stride;
LD_SB2(src, 16, src6, src7);
src += src_stride;
LD_SB2(pred, 16, pred0, pred1);
pred += pred_stride;
LD_SB2(pred, 16, pred2, pred3);
pred += pred_stride;
LD_SB2(pred, 16, pred4, pred5);
pred += pred_stride;
LD_SB2(pred, 16, pred6, pred7);
pred += pred_stride;
ILVRL_B2_UB(src0, pred0, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
ILVRL_B2_UB(src1, pred1, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff + 16, 8);
diff += diff_stride;
ILVRL_B2_UB(src2, pred2, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
ILVRL_B2_UB(src3, pred3, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff + 16, 8);
diff += diff_stride;
ILVRL_B2_UB(src4, pred4, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
ILVRL_B2_UB(src5, pred5, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff + 16, 8);
diff += diff_stride;
ILVRL_B2_UB(src6, pred6, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
ILVRL_B2_UB(src7, pred7, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff + 16, 8);
diff += diff_stride;
}
}
static void sub_blk_64x64_msa(const uint8_t *src, int32_t src_stride,
const uint8_t *pred, int32_t pred_stride,
int16_t *diff, int32_t diff_stride) {
uint32_t loop_cnt;
v16i8 src0, src1, src2, src3, src4, src5, src6, src7;
v16i8 pred0, pred1, pred2, pred3, pred4, pred5, pred6, pred7;
v16u8 src_l0, src_l1;
v8i16 diff0, diff1;
for (loop_cnt = 32; loop_cnt--;) {
LD_SB4(src, 16, src0, src1, src2, src3);
src += src_stride;
LD_SB4(src, 16, src4, src5, src6, src7);
src += src_stride;
LD_SB4(pred, 16, pred0, pred1, pred2, pred3);
pred += pred_stride;
LD_SB4(pred, 16, pred4, pred5, pred6, pred7);
pred += pred_stride;
ILVRL_B2_UB(src0, pred0, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
ILVRL_B2_UB(src1, pred1, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff + 16, 8);
ILVRL_B2_UB(src2, pred2, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff + 32, 8);
ILVRL_B2_UB(src3, pred3, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff + 48, 8);
diff += diff_stride;
ILVRL_B2_UB(src4, pred4, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff, 8);
ILVRL_B2_UB(src5, pred5, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff + 16, 8);
ILVRL_B2_UB(src6, pred6, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff + 32, 8);
ILVRL_B2_UB(src7, pred7, src_l0, src_l1);
HSUB_UB2_SH(src_l0, src_l1, diff0, diff1);
ST_SH2(diff0, diff1, diff + 48, 8);
diff += diff_stride;
}
}
void aom_subtract_block_msa(int32_t rows, int32_t cols, int16_t *diff_ptr,
ptrdiff_t diff_stride, const uint8_t *src_ptr,
ptrdiff_t src_stride, const uint8_t *pred_ptr,
ptrdiff_t pred_stride) {
if (rows == cols) {
switch (rows) {
case 4:
sub_blk_4x4_msa(src_ptr, src_stride, pred_ptr, pred_stride, diff_ptr,
diff_stride);
break;
case 8:
sub_blk_8x8_msa(src_ptr, src_stride, pred_ptr, pred_stride, diff_ptr,
diff_stride);
break;
case 16:
sub_blk_16x16_msa(src_ptr, src_stride, pred_ptr, pred_stride, diff_ptr,
diff_stride);
break;
case 32:
sub_blk_32x32_msa(src_ptr, src_stride, pred_ptr, pred_stride, diff_ptr,
diff_stride);
break;
case 64:
sub_blk_64x64_msa(src_ptr, src_stride, pred_ptr, pred_stride, diff_ptr,
diff_stride);
break;
default:
aom_subtract_block_c(rows, cols, diff_ptr, diff_stride, src_ptr,
src_stride, pred_ptr, pred_stride);
break;
}
} else {
aom_subtract_block_c(rows, cols, diff_ptr, diff_stride, src_ptr, src_stride,
pred_ptr, pred_stride);
}
}
|