blob: ba4012281e84ae9402cff599fabc65b65f81de18 [file] [log] [blame]
Parag Salasakar2301d102015-04-27 12:26:10 +05301/*
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 <string.h>
Johann6a82f0d2015-06-05 09:54:19 -070012#include "vpx_dsp/mips/macros_msa.h"
Parag Salasakar2301d102015-04-27 12:26:10 +053013
14static void copy_width8_msa(const uint8_t *src, int32_t src_stride,
Parag Salasakarebf74662015-06-02 10:29:56 +053015 uint8_t *dst, int32_t dst_stride, int32_t height) {
Parag Salasakar2301d102015-04-27 12:26:10 +053016 int32_t cnt;
17 uint64_t out0, out1, out2, out3, out4, out5, out6, out7;
18 v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
19
20 if (0 == height % 12) {
21 for (cnt = (height / 12); cnt--;) {
Parag Salasakarebf74662015-06-02 10:29:56 +053022 LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
Parag Salasakar2301d102015-04-27 12:26:10 +053023 src += (8 * src_stride);
24
25 out0 = __msa_copy_u_d((v2i64)src0, 0);
26 out1 = __msa_copy_u_d((v2i64)src1, 0);
27 out2 = __msa_copy_u_d((v2i64)src2, 0);
28 out3 = __msa_copy_u_d((v2i64)src3, 0);
29 out4 = __msa_copy_u_d((v2i64)src4, 0);
30 out5 = __msa_copy_u_d((v2i64)src5, 0);
31 out6 = __msa_copy_u_d((v2i64)src6, 0);
32 out7 = __msa_copy_u_d((v2i64)src7, 0);
33
Parag Salasakarebf74662015-06-02 10:29:56 +053034 SD4(out0, out1, out2, out3, dst, dst_stride);
35 dst += (4 * dst_stride);
36 SD4(out4, out5, out6, out7, dst, dst_stride);
37 dst += (4 * dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +053038
Parag Salasakarebf74662015-06-02 10:29:56 +053039 LD_UB4(src, src_stride, src0, src1, src2, src3);
Parag Salasakar2301d102015-04-27 12:26:10 +053040 src += (4 * src_stride);
41
42 out0 = __msa_copy_u_d((v2i64)src0, 0);
43 out1 = __msa_copy_u_d((v2i64)src1, 0);
44 out2 = __msa_copy_u_d((v2i64)src2, 0);
45 out3 = __msa_copy_u_d((v2i64)src3, 0);
Parag Salasakarebf74662015-06-02 10:29:56 +053046 SD4(out0, out1, out2, out3, dst, dst_stride);
47 dst += (4 * dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +053048 }
49 } else if (0 == height % 8) {
50 for (cnt = height >> 3; cnt--;) {
Parag Salasakarebf74662015-06-02 10:29:56 +053051 LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
Parag Salasakar2301d102015-04-27 12:26:10 +053052 src += (8 * src_stride);
53
54 out0 = __msa_copy_u_d((v2i64)src0, 0);
55 out1 = __msa_copy_u_d((v2i64)src1, 0);
56 out2 = __msa_copy_u_d((v2i64)src2, 0);
57 out3 = __msa_copy_u_d((v2i64)src3, 0);
58 out4 = __msa_copy_u_d((v2i64)src4, 0);
59 out5 = __msa_copy_u_d((v2i64)src5, 0);
60 out6 = __msa_copy_u_d((v2i64)src6, 0);
61 out7 = __msa_copy_u_d((v2i64)src7, 0);
62
Parag Salasakarebf74662015-06-02 10:29:56 +053063 SD4(out0, out1, out2, out3, dst, dst_stride);
64 dst += (4 * dst_stride);
65 SD4(out4, out5, out6, out7, dst, dst_stride);
66 dst += (4 * dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +053067 }
68 } else if (0 == height % 4) {
69 for (cnt = (height / 4); cnt--;) {
Parag Salasakarebf74662015-06-02 10:29:56 +053070 LD_UB4(src, src_stride, src0, src1, src2, src3);
Parag Salasakar2301d102015-04-27 12:26:10 +053071 src += (4 * src_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +053072 out0 = __msa_copy_u_d((v2i64)src0, 0);
73 out1 = __msa_copy_u_d((v2i64)src1, 0);
74 out2 = __msa_copy_u_d((v2i64)src2, 0);
75 out3 = __msa_copy_u_d((v2i64)src3, 0);
76
Parag Salasakarebf74662015-06-02 10:29:56 +053077 SD4(out0, out1, out2, out3, dst, dst_stride);
78 dst += (4 * dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +053079 }
80 } else if (0 == height % 2) {
81 for (cnt = (height / 2); cnt--;) {
Parag Salasakarebf74662015-06-02 10:29:56 +053082 LD_UB2(src, src_stride, src0, src1);
Parag Salasakar2301d102015-04-27 12:26:10 +053083 src += (2 * src_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +053084 out0 = __msa_copy_u_d((v2i64)src0, 0);
85 out1 = __msa_copy_u_d((v2i64)src1, 0);
86
Parag Salasakarebf74662015-06-02 10:29:56 +053087 SD(out0, dst);
Parag Salasakar2301d102015-04-27 12:26:10 +053088 dst += dst_stride;
Parag Salasakarebf74662015-06-02 10:29:56 +053089 SD(out1, dst);
Parag Salasakar2301d102015-04-27 12:26:10 +053090 dst += dst_stride;
91 }
92 }
93}
94
95static void copy_16multx8mult_msa(const uint8_t *src, int32_t src_stride,
96 uint8_t *dst, int32_t dst_stride,
97 int32_t height, int32_t width) {
98 int32_t cnt, loop_cnt;
99 const uint8_t *src_tmp;
100 uint8_t *dst_tmp;
101 v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
102
103 for (cnt = (width >> 4); cnt--;) {
104 src_tmp = src;
105 dst_tmp = dst;
106
107 for (loop_cnt = (height >> 3); loop_cnt--;) {
Parag Salasakarebf74662015-06-02 10:29:56 +0530108 LD_UB8(src_tmp, src_stride,
109 src0, src1, src2, src3, src4, src5, src6, src7);
Parag Salasakar2301d102015-04-27 12:26:10 +0530110 src_tmp += (8 * src_stride);
111
Parag Salasakarebf74662015-06-02 10:29:56 +0530112 ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7,
113 dst_tmp, dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +0530114 dst_tmp += (8 * dst_stride);
115 }
116
117 src += 16;
118 dst += 16;
119 }
120}
121
122static void copy_width16_msa(const uint8_t *src, int32_t src_stride,
Parag Salasakarebf74662015-06-02 10:29:56 +0530123 uint8_t *dst, int32_t dst_stride, int32_t height) {
Parag Salasakar2301d102015-04-27 12:26:10 +0530124 int32_t cnt;
125 v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
126
127 if (0 == height % 12) {
128 for (cnt = (height / 12); cnt--;) {
Parag Salasakarebf74662015-06-02 10:29:56 +0530129 LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
Parag Salasakar2301d102015-04-27 12:26:10 +0530130 src += (8 * src_stride);
Parag Salasakarebf74662015-06-02 10:29:56 +0530131 ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, dst, dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +0530132 dst += (8 * dst_stride);
133
Parag Salasakarebf74662015-06-02 10:29:56 +0530134 LD_UB4(src, src_stride, src0, src1, src2, src3);
Parag Salasakar2301d102015-04-27 12:26:10 +0530135 src += (4 * src_stride);
Parag Salasakarebf74662015-06-02 10:29:56 +0530136 ST_UB4(src0, src1, src2, src3, dst, dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +0530137 dst += (4 * dst_stride);
138 }
139 } else if (0 == height % 8) {
140 copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 16);
141 } else if (0 == height % 4) {
142 for (cnt = (height >> 2); cnt--;) {
Parag Salasakarebf74662015-06-02 10:29:56 +0530143 LD_UB4(src, src_stride, src0, src1, src2, src3);
Parag Salasakar2301d102015-04-27 12:26:10 +0530144 src += (4 * src_stride);
145
Parag Salasakarebf74662015-06-02 10:29:56 +0530146 ST_UB4(src0, src1, src2, src3, dst, dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +0530147 dst += (4 * dst_stride);
148 }
149 }
150}
151
152static void copy_width32_msa(const uint8_t *src, int32_t src_stride,
Parag Salasakarebf74662015-06-02 10:29:56 +0530153 uint8_t *dst, int32_t dst_stride, int32_t height) {
Parag Salasakar2301d102015-04-27 12:26:10 +0530154 int32_t cnt;
155 v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
156
157 if (0 == height % 12) {
158 for (cnt = (height / 12); cnt--;) {
Parag Salasakarebf74662015-06-02 10:29:56 +0530159 LD_UB4(src, src_stride, src0, src1, src2, src3);
160 LD_UB4(src + 16, src_stride, src4, src5, src6, src7);
Parag Salasakar2301d102015-04-27 12:26:10 +0530161 src += (4 * src_stride);
Parag Salasakarebf74662015-06-02 10:29:56 +0530162 ST_UB4(src0, src1, src2, src3, dst, dst_stride);
163 ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +0530164 dst += (4 * dst_stride);
165
Parag Salasakarebf74662015-06-02 10:29:56 +0530166 LD_UB4(src, src_stride, src0, src1, src2, src3);
167 LD_UB4(src + 16, src_stride, src4, src5, src6, src7);
Parag Salasakar2301d102015-04-27 12:26:10 +0530168 src += (4 * src_stride);
Parag Salasakarebf74662015-06-02 10:29:56 +0530169 ST_UB4(src0, src1, src2, src3, dst, dst_stride);
170 ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +0530171 dst += (4 * dst_stride);
172
Parag Salasakarebf74662015-06-02 10:29:56 +0530173 LD_UB4(src, src_stride, src0, src1, src2, src3);
174 LD_UB4(src + 16, src_stride, src4, src5, src6, src7);
Parag Salasakar2301d102015-04-27 12:26:10 +0530175 src += (4 * src_stride);
Parag Salasakarebf74662015-06-02 10:29:56 +0530176 ST_UB4(src0, src1, src2, src3, dst, dst_stride);
177 ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +0530178 dst += (4 * dst_stride);
179 }
180 } else if (0 == height % 8) {
181 copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 32);
182 } else if (0 == height % 4) {
183 for (cnt = (height >> 2); cnt--;) {
Parag Salasakarebf74662015-06-02 10:29:56 +0530184 LD_UB4(src, src_stride, src0, src1, src2, src3);
185 LD_UB4(src + 16, src_stride, src4, src5, src6, src7);
Parag Salasakar2301d102015-04-27 12:26:10 +0530186 src += (4 * src_stride);
Parag Salasakarebf74662015-06-02 10:29:56 +0530187 ST_UB4(src0, src1, src2, src3, dst, dst_stride);
188 ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride);
Parag Salasakar2301d102015-04-27 12:26:10 +0530189 dst += (4 * dst_stride);
190 }
191 }
192}
193
194static void copy_width64_msa(const uint8_t *src, int32_t src_stride,
Parag Salasakarebf74662015-06-02 10:29:56 +0530195 uint8_t *dst, int32_t dst_stride, int32_t height) {
Parag Salasakar2301d102015-04-27 12:26:10 +0530196 copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 64);
197}
198
Zoe Liu7186a2d2015-07-22 10:40:42 -0700199void vpx_convolve_copy_msa(const uint8_t *src, ptrdiff_t src_stride,
Parag Salasakar2301d102015-04-27 12:26:10 +0530200 uint8_t *dst, ptrdiff_t dst_stride,
201 const int16_t *filter_x, int32_t filter_x_stride,
202 const int16_t *filter_y, int32_t filter_y_stride,
203 int32_t w, int32_t h) {
204 (void)filter_x;
205 (void)filter_y;
206 (void)filter_x_stride;
207 (void)filter_y_stride;
208
209 switch (w) {
210 case 4: {
211 uint32_t cnt, tmp;
212 /* 1 word storage */
213 for (cnt = h; cnt--;) {
Parag Salasakarebf74662015-06-02 10:29:56 +0530214 tmp = LW(src);
215 SW(tmp, dst);
Parag Salasakar2301d102015-04-27 12:26:10 +0530216 src += src_stride;
217 dst += dst_stride;
218 }
219 break;
220 }
221 case 8: {
222 copy_width8_msa(src, src_stride, dst, dst_stride, h);
223 break;
224 }
225 case 16: {
226 copy_width16_msa(src, src_stride, dst, dst_stride, h);
227 break;
228 }
229 case 32: {
230 copy_width32_msa(src, src_stride, dst, dst_stride, h);
231 break;
232 }
233 case 64: {
234 copy_width64_msa(src, src_stride, dst, dst_stride, h);
235 break;
236 }
237 default: {
238 uint32_t cnt;
239 for (cnt = h; cnt--;) {
240 memcpy(dst, src, w);
241 src += src_stride;
242 dst += dst_stride;
243 }
244 break;
245 }
246 }
247}