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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
|
/*
* 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 "./aom_dsp_rtcd.h"
#include "aom_dsp/mips/macros_msa.h"
#define IPRED_SUBS_UH2_UH(in0, in1, out0, out1) \
{ \
out0 = __msa_subs_u_h(out0, in0); \
out1 = __msa_subs_u_h(out1, in1); \
}
static void intra_predict_vert_4x4_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
uint32_t src_data;
src_data = LW(src);
SW4(src_data, src_data, src_data, src_data, dst, dst_stride);
}
static void intra_predict_vert_8x8_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
uint32_t row;
uint32_t src_data1, src_data2;
src_data1 = LW(src);
src_data2 = LW(src + 4);
for (row = 8; row--;) {
SW(src_data1, dst);
SW(src_data2, (dst + 4));
dst += dst_stride;
}
}
static void intra_predict_vert_16x16_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
uint32_t row;
v16u8 src0;
src0 = LD_UB(src);
for (row = 16; row--;) {
ST_UB(src0, dst);
dst += dst_stride;
}
}
static void intra_predict_vert_32x32_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
uint32_t row;
v16u8 src1, src2;
src1 = LD_UB(src);
src2 = LD_UB(src + 16);
for (row = 32; row--;) {
ST_UB2(src1, src2, dst, 16);
dst += dst_stride;
}
}
static void intra_predict_horiz_4x4_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
uint32_t out0, out1, out2, out3;
out0 = src[0] * 0x01010101;
out1 = src[1] * 0x01010101;
out2 = src[2] * 0x01010101;
out3 = src[3] * 0x01010101;
SW4(out0, out1, out2, out3, dst, dst_stride);
}
static void intra_predict_horiz_8x8_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
uint64_t out0, out1, out2, out3, out4, out5, out6, out7;
out0 = src[0] * 0x0101010101010101ull;
out1 = src[1] * 0x0101010101010101ull;
out2 = src[2] * 0x0101010101010101ull;
out3 = src[3] * 0x0101010101010101ull;
out4 = src[4] * 0x0101010101010101ull;
out5 = src[5] * 0x0101010101010101ull;
out6 = src[6] * 0x0101010101010101ull;
out7 = src[7] * 0x0101010101010101ull;
SD4(out0, out1, out2, out3, dst, dst_stride);
dst += (4 * dst_stride);
SD4(out4, out5, out6, out7, dst, dst_stride);
}
static void intra_predict_horiz_16x16_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
uint32_t row;
uint8_t inp0, inp1, inp2, inp3;
v16u8 src0, src1, src2, src3;
for (row = 4; row--;) {
inp0 = src[0];
inp1 = src[1];
inp2 = src[2];
inp3 = src[3];
src += 4;
src0 = (v16u8)__msa_fill_b(inp0);
src1 = (v16u8)__msa_fill_b(inp1);
src2 = (v16u8)__msa_fill_b(inp2);
src3 = (v16u8)__msa_fill_b(inp3);
ST_UB4(src0, src1, src2, src3, dst, dst_stride);
dst += (4 * dst_stride);
}
}
static void intra_predict_horiz_32x32_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
uint32_t row;
uint8_t inp0, inp1, inp2, inp3;
v16u8 src0, src1, src2, src3;
for (row = 8; row--;) {
inp0 = src[0];
inp1 = src[1];
inp2 = src[2];
inp3 = src[3];
src += 4;
src0 = (v16u8)__msa_fill_b(inp0);
src1 = (v16u8)__msa_fill_b(inp1);
src2 = (v16u8)__msa_fill_b(inp2);
src3 = (v16u8)__msa_fill_b(inp3);
ST_UB2(src0, src0, dst, 16);
dst += dst_stride;
ST_UB2(src1, src1, dst, 16);
dst += dst_stride;
ST_UB2(src2, src2, dst, 16);
dst += dst_stride;
ST_UB2(src3, src3, dst, 16);
dst += dst_stride;
}
}
static void intra_predict_dc_4x4_msa(const uint8_t *src_top,
const uint8_t *src_left, uint8_t *dst,
int32_t dst_stride) {
uint32_t val0, val1;
v16i8 store, src = { 0 };
v8u16 sum_h;
v4u32 sum_w;
v2u64 sum_d;
val0 = LW(src_top);
val1 = LW(src_left);
INSERT_W2_SB(val0, val1, src);
sum_h = __msa_hadd_u_h((v16u8)src, (v16u8)src);
sum_w = __msa_hadd_u_w(sum_h, sum_h);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_srari_w((v4i32)sum_d, 3);
store = __msa_splati_b((v16i8)sum_w, 0);
val0 = __msa_copy_u_w((v4i32)store, 0);
SW4(val0, val0, val0, val0, dst, dst_stride);
}
static void intra_predict_dc_tl_4x4_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
uint32_t val0;
v16i8 store, data = { 0 };
v8u16 sum_h;
v4u32 sum_w;
val0 = LW(src);
data = (v16i8)__msa_insert_w((v4i32)data, 0, val0);
sum_h = __msa_hadd_u_h((v16u8)data, (v16u8)data);
sum_w = __msa_hadd_u_w(sum_h, sum_h);
sum_w = (v4u32)__msa_srari_w((v4i32)sum_w, 2);
store = __msa_splati_b((v16i8)sum_w, 0);
val0 = __msa_copy_u_w((v4i32)store, 0);
SW4(val0, val0, val0, val0, dst, dst_stride);
}
static void intra_predict_128dc_4x4_msa(uint8_t *dst, int32_t dst_stride) {
uint32_t out;
const v16i8 store = __msa_ldi_b(128);
out = __msa_copy_u_w((v4i32)store, 0);
SW4(out, out, out, out, dst, dst_stride);
}
static void intra_predict_dc_8x8_msa(const uint8_t *src_top,
const uint8_t *src_left, uint8_t *dst,
int32_t dst_stride) {
uint64_t val0, val1;
v16i8 store;
v16u8 src = { 0 };
v8u16 sum_h;
v4u32 sum_w;
v2u64 sum_d;
val0 = LD(src_top);
val1 = LD(src_left);
INSERT_D2_UB(val0, val1, src);
sum_h = __msa_hadd_u_h(src, src);
sum_w = __msa_hadd_u_w(sum_h, sum_h);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_pckev_w((v4i32)sum_d, (v4i32)sum_d);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_srari_w((v4i32)sum_d, 4);
store = __msa_splati_b((v16i8)sum_w, 0);
val0 = __msa_copy_u_d((v2i64)store, 0);
SD4(val0, val0, val0, val0, dst, dst_stride);
dst += (4 * dst_stride);
SD4(val0, val0, val0, val0, dst, dst_stride);
}
static void intra_predict_dc_tl_8x8_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
uint64_t val0;
v16i8 store;
v16u8 data = { 0 };
v8u16 sum_h;
v4u32 sum_w;
v2u64 sum_d;
val0 = LD(src);
data = (v16u8)__msa_insert_d((v2i64)data, 0, val0);
sum_h = __msa_hadd_u_h(data, data);
sum_w = __msa_hadd_u_w(sum_h, sum_h);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_srari_w((v4i32)sum_d, 3);
store = __msa_splati_b((v16i8)sum_w, 0);
val0 = __msa_copy_u_d((v2i64)store, 0);
SD4(val0, val0, val0, val0, dst, dst_stride);
dst += (4 * dst_stride);
SD4(val0, val0, val0, val0, dst, dst_stride);
}
static void intra_predict_128dc_8x8_msa(uint8_t *dst, int32_t dst_stride) {
uint64_t out;
const v16i8 store = __msa_ldi_b(128);
out = __msa_copy_u_d((v2i64)store, 0);
SD4(out, out, out, out, dst, dst_stride);
dst += (4 * dst_stride);
SD4(out, out, out, out, dst, dst_stride);
}
static void intra_predict_dc_16x16_msa(const uint8_t *src_top,
const uint8_t *src_left, uint8_t *dst,
int32_t dst_stride) {
v16u8 top, left, out;
v8u16 sum_h, sum_top, sum_left;
v4u32 sum_w;
v2u64 sum_d;
top = LD_UB(src_top);
left = LD_UB(src_left);
HADD_UB2_UH(top, left, sum_top, sum_left);
sum_h = sum_top + sum_left;
sum_w = __msa_hadd_u_w(sum_h, sum_h);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_pckev_w((v4i32)sum_d, (v4i32)sum_d);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_srari_w((v4i32)sum_d, 5);
out = (v16u8)__msa_splati_b((v16i8)sum_w, 0);
ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride);
dst += (8 * dst_stride);
ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride);
}
static void intra_predict_dc_tl_16x16_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
v16u8 data, out;
v8u16 sum_h;
v4u32 sum_w;
v2u64 sum_d;
data = LD_UB(src);
sum_h = __msa_hadd_u_h(data, data);
sum_w = __msa_hadd_u_w(sum_h, sum_h);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_pckev_w((v4i32)sum_d, (v4i32)sum_d);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_srari_w((v4i32)sum_d, 4);
out = (v16u8)__msa_splati_b((v16i8)sum_w, 0);
ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride);
dst += (8 * dst_stride);
ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride);
}
static void intra_predict_128dc_16x16_msa(uint8_t *dst, int32_t dst_stride) {
const v16u8 out = (v16u8)__msa_ldi_b(128);
ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride);
dst += (8 * dst_stride);
ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride);
}
static void intra_predict_dc_32x32_msa(const uint8_t *src_top,
const uint8_t *src_left, uint8_t *dst,
int32_t dst_stride) {
uint32_t row;
v16u8 top0, top1, left0, left1, out;
v8u16 sum_h, sum_top0, sum_top1, sum_left0, sum_left1;
v4u32 sum_w;
v2u64 sum_d;
LD_UB2(src_top, 16, top0, top1);
LD_UB2(src_left, 16, left0, left1);
HADD_UB2_UH(top0, top1, sum_top0, sum_top1);
HADD_UB2_UH(left0, left1, sum_left0, sum_left1);
sum_h = sum_top0 + sum_top1;
sum_h += sum_left0 + sum_left1;
sum_w = __msa_hadd_u_w(sum_h, sum_h);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_pckev_w((v4i32)sum_d, (v4i32)sum_d);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_srari_w((v4i32)sum_d, 6);
out = (v16u8)__msa_splati_b((v16i8)sum_w, 0);
for (row = 16; row--;) {
ST_UB2(out, out, dst, 16);
dst += dst_stride;
ST_UB2(out, out, dst, 16);
dst += dst_stride;
}
}
static void intra_predict_dc_tl_32x32_msa(const uint8_t *src, uint8_t *dst,
int32_t dst_stride) {
uint32_t row;
v16u8 data0, data1, out;
v8u16 sum_h, sum_data0, sum_data1;
v4u32 sum_w;
v2u64 sum_d;
LD_UB2(src, 16, data0, data1);
HADD_UB2_UH(data0, data1, sum_data0, sum_data1);
sum_h = sum_data0 + sum_data1;
sum_w = __msa_hadd_u_w(sum_h, sum_h);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_pckev_w((v4i32)sum_d, (v4i32)sum_d);
sum_d = __msa_hadd_u_d(sum_w, sum_w);
sum_w = (v4u32)__msa_srari_w((v4i32)sum_d, 5);
out = (v16u8)__msa_splati_b((v16i8)sum_w, 0);
for (row = 16; row--;) {
ST_UB2(out, out, dst, 16);
dst += dst_stride;
ST_UB2(out, out, dst, 16);
dst += dst_stride;
}
}
static void intra_predict_128dc_32x32_msa(uint8_t *dst, int32_t dst_stride) {
uint32_t row;
const v16u8 out = (v16u8)__msa_ldi_b(128);
for (row = 16; row--;) {
ST_UB2(out, out, dst, 16);
dst += dst_stride;
ST_UB2(out, out, dst, 16);
dst += dst_stride;
}
}
void aom_v_predictor_4x4_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)left;
intra_predict_vert_4x4_msa(above, dst, y_stride);
}
void aom_v_predictor_8x8_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)left;
intra_predict_vert_8x8_msa(above, dst, y_stride);
}
void aom_v_predictor_16x16_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)left;
intra_predict_vert_16x16_msa(above, dst, y_stride);
}
void aom_v_predictor_32x32_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)left;
intra_predict_vert_32x32_msa(above, dst, y_stride);
}
void aom_h_predictor_4x4_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)above;
intra_predict_horiz_4x4_msa(left, dst, y_stride);
}
void aom_h_predictor_8x8_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)above;
intra_predict_horiz_8x8_msa(left, dst, y_stride);
}
void aom_h_predictor_16x16_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)above;
intra_predict_horiz_16x16_msa(left, dst, y_stride);
}
void aom_h_predictor_32x32_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)above;
intra_predict_horiz_32x32_msa(left, dst, y_stride);
}
void aom_dc_predictor_4x4_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
intra_predict_dc_4x4_msa(above, left, dst, y_stride);
}
void aom_dc_predictor_8x8_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
intra_predict_dc_8x8_msa(above, left, dst, y_stride);
}
void aom_dc_predictor_16x16_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
intra_predict_dc_16x16_msa(above, left, dst, y_stride);
}
void aom_dc_predictor_32x32_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
intra_predict_dc_32x32_msa(above, left, dst, y_stride);
}
void aom_dc_top_predictor_4x4_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)left;
intra_predict_dc_tl_4x4_msa(above, dst, y_stride);
}
void aom_dc_top_predictor_8x8_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)left;
intra_predict_dc_tl_8x8_msa(above, dst, y_stride);
}
void aom_dc_top_predictor_16x16_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)left;
intra_predict_dc_tl_16x16_msa(above, dst, y_stride);
}
void aom_dc_top_predictor_32x32_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)left;
intra_predict_dc_tl_32x32_msa(above, dst, y_stride);
}
void aom_dc_left_predictor_4x4_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)above;
intra_predict_dc_tl_4x4_msa(left, dst, y_stride);
}
void aom_dc_left_predictor_8x8_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)above;
intra_predict_dc_tl_8x8_msa(left, dst, y_stride);
}
void aom_dc_left_predictor_16x16_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above,
const uint8_t *left) {
(void)above;
intra_predict_dc_tl_16x16_msa(left, dst, y_stride);
}
void aom_dc_left_predictor_32x32_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above,
const uint8_t *left) {
(void)above;
intra_predict_dc_tl_32x32_msa(left, dst, y_stride);
}
void aom_dc_128_predictor_4x4_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)above;
(void)left;
intra_predict_128dc_4x4_msa(dst, y_stride);
}
void aom_dc_128_predictor_8x8_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)above;
(void)left;
intra_predict_128dc_8x8_msa(dst, y_stride);
}
void aom_dc_128_predictor_16x16_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)above;
(void)left;
intra_predict_128dc_16x16_msa(dst, y_stride);
}
void aom_dc_128_predictor_32x32_msa(uint8_t *dst, ptrdiff_t y_stride,
const uint8_t *above, const uint8_t *left) {
(void)above;
(void)left;
intra_predict_128dc_32x32_msa(dst, y_stride);
}
|