2015-04-27 09:56:10 +03:00
|
|
|
/*
|
2016-09-02 00:32:49 +03:00
|
|
|
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
2015-04-27 09:56:10 +03:00
|
|
|
*
|
2016-09-02 00:32:49 +03:00
|
|
|
* 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.
|
2015-04-27 09:56:10 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
2016-08-23 02:08:15 +03:00
|
|
|
#include "aom_dsp/mips/macros_msa.h"
|
2015-04-27 09:56:10 +03:00
|
|
|
|
|
|
|
static void copy_width8_msa(const uint8_t *src, int32_t src_stride,
|
2015-06-02 07:59:56 +03:00
|
|
|
uint8_t *dst, int32_t dst_stride, int32_t height) {
|
2015-04-27 09:56:10 +03:00
|
|
|
int32_t cnt;
|
|
|
|
uint64_t out0, out1, out2, out3, out4, out5, out6, out7;
|
|
|
|
v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
|
|
|
|
|
|
|
|
if (0 == height % 12) {
|
|
|
|
for (cnt = (height / 12); cnt--;) {
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (8 * src_stride);
|
|
|
|
|
|
|
|
out0 = __msa_copy_u_d((v2i64)src0, 0);
|
|
|
|
out1 = __msa_copy_u_d((v2i64)src1, 0);
|
|
|
|
out2 = __msa_copy_u_d((v2i64)src2, 0);
|
|
|
|
out3 = __msa_copy_u_d((v2i64)src3, 0);
|
|
|
|
out4 = __msa_copy_u_d((v2i64)src4, 0);
|
|
|
|
out5 = __msa_copy_u_d((v2i64)src5, 0);
|
|
|
|
out6 = __msa_copy_u_d((v2i64)src6, 0);
|
|
|
|
out7 = __msa_copy_u_d((v2i64)src7, 0);
|
|
|
|
|
2015-06-02 07:59:56 +03:00
|
|
|
SD4(out0, out1, out2, out3, dst, dst_stride);
|
|
|
|
dst += (4 * dst_stride);
|
|
|
|
SD4(out4, out5, out6, out7, dst, dst_stride);
|
|
|
|
dst += (4 * dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB4(src, src_stride, src0, src1, src2, src3);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (4 * src_stride);
|
|
|
|
|
|
|
|
out0 = __msa_copy_u_d((v2i64)src0, 0);
|
|
|
|
out1 = __msa_copy_u_d((v2i64)src1, 0);
|
|
|
|
out2 = __msa_copy_u_d((v2i64)src2, 0);
|
|
|
|
out3 = __msa_copy_u_d((v2i64)src3, 0);
|
2015-06-02 07:59:56 +03:00
|
|
|
SD4(out0, out1, out2, out3, dst, dst_stride);
|
|
|
|
dst += (4 * dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
}
|
|
|
|
} else if (0 == height % 8) {
|
|
|
|
for (cnt = height >> 3; cnt--;) {
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (8 * src_stride);
|
|
|
|
|
|
|
|
out0 = __msa_copy_u_d((v2i64)src0, 0);
|
|
|
|
out1 = __msa_copy_u_d((v2i64)src1, 0);
|
|
|
|
out2 = __msa_copy_u_d((v2i64)src2, 0);
|
|
|
|
out3 = __msa_copy_u_d((v2i64)src3, 0);
|
|
|
|
out4 = __msa_copy_u_d((v2i64)src4, 0);
|
|
|
|
out5 = __msa_copy_u_d((v2i64)src5, 0);
|
|
|
|
out6 = __msa_copy_u_d((v2i64)src6, 0);
|
|
|
|
out7 = __msa_copy_u_d((v2i64)src7, 0);
|
|
|
|
|
2015-06-02 07:59:56 +03:00
|
|
|
SD4(out0, out1, out2, out3, dst, dst_stride);
|
|
|
|
dst += (4 * dst_stride);
|
|
|
|
SD4(out4, out5, out6, out7, dst, dst_stride);
|
|
|
|
dst += (4 * dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
}
|
|
|
|
} else if (0 == height % 4) {
|
|
|
|
for (cnt = (height / 4); cnt--;) {
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB4(src, src_stride, src0, src1, src2, src3);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (4 * src_stride);
|
|
|
|
out0 = __msa_copy_u_d((v2i64)src0, 0);
|
|
|
|
out1 = __msa_copy_u_d((v2i64)src1, 0);
|
|
|
|
out2 = __msa_copy_u_d((v2i64)src2, 0);
|
|
|
|
out3 = __msa_copy_u_d((v2i64)src3, 0);
|
|
|
|
|
2015-06-02 07:59:56 +03:00
|
|
|
SD4(out0, out1, out2, out3, dst, dst_stride);
|
|
|
|
dst += (4 * dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
}
|
|
|
|
} else if (0 == height % 2) {
|
|
|
|
for (cnt = (height / 2); cnt--;) {
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB2(src, src_stride, src0, src1);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (2 * src_stride);
|
|
|
|
out0 = __msa_copy_u_d((v2i64)src0, 0);
|
|
|
|
out1 = __msa_copy_u_d((v2i64)src1, 0);
|
|
|
|
|
2015-06-02 07:59:56 +03:00
|
|
|
SD(out0, dst);
|
2015-04-27 09:56:10 +03:00
|
|
|
dst += dst_stride;
|
2015-06-02 07:59:56 +03:00
|
|
|
SD(out1, dst);
|
2015-04-27 09:56:10 +03:00
|
|
|
dst += dst_stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_16multx8mult_msa(const uint8_t *src, int32_t src_stride,
|
|
|
|
uint8_t *dst, int32_t dst_stride,
|
|
|
|
int32_t height, int32_t width) {
|
|
|
|
int32_t cnt, loop_cnt;
|
|
|
|
const uint8_t *src_tmp;
|
|
|
|
uint8_t *dst_tmp;
|
|
|
|
v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
|
|
|
|
|
|
|
|
for (cnt = (width >> 4); cnt--;) {
|
|
|
|
src_tmp = src;
|
|
|
|
dst_tmp = dst;
|
|
|
|
|
|
|
|
for (loop_cnt = (height >> 3); loop_cnt--;) {
|
2016-08-09 08:59:08 +03:00
|
|
|
LD_UB8(src_tmp, src_stride, src0, src1, src2, src3, src4, src5, src6,
|
|
|
|
src7);
|
2015-04-27 09:56:10 +03:00
|
|
|
src_tmp += (8 * src_stride);
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, dst_tmp,
|
|
|
|
dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
dst_tmp += (8 * dst_stride);
|
|
|
|
}
|
|
|
|
|
|
|
|
src += 16;
|
|
|
|
dst += 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_width16_msa(const uint8_t *src, int32_t src_stride,
|
2015-06-02 07:59:56 +03:00
|
|
|
uint8_t *dst, int32_t dst_stride, int32_t height) {
|
2015-04-27 09:56:10 +03:00
|
|
|
int32_t cnt;
|
|
|
|
v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
|
|
|
|
|
|
|
|
if (0 == height % 12) {
|
|
|
|
for (cnt = (height / 12); cnt--;) {
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (8 * src_stride);
|
2015-06-02 07:59:56 +03:00
|
|
|
ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, dst, dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
dst += (8 * dst_stride);
|
|
|
|
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB4(src, src_stride, src0, src1, src2, src3);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (4 * src_stride);
|
2015-06-02 07:59:56 +03:00
|
|
|
ST_UB4(src0, src1, src2, src3, dst, dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
dst += (4 * dst_stride);
|
|
|
|
}
|
|
|
|
} else if (0 == height % 8) {
|
|
|
|
copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 16);
|
|
|
|
} else if (0 == height % 4) {
|
|
|
|
for (cnt = (height >> 2); cnt--;) {
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB4(src, src_stride, src0, src1, src2, src3);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (4 * src_stride);
|
|
|
|
|
2015-06-02 07:59:56 +03:00
|
|
|
ST_UB4(src0, src1, src2, src3, dst, dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
dst += (4 * dst_stride);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_width32_msa(const uint8_t *src, int32_t src_stride,
|
2015-06-02 07:59:56 +03:00
|
|
|
uint8_t *dst, int32_t dst_stride, int32_t height) {
|
2015-04-27 09:56:10 +03:00
|
|
|
int32_t cnt;
|
|
|
|
v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
|
|
|
|
|
|
|
|
if (0 == height % 12) {
|
|
|
|
for (cnt = (height / 12); cnt--;) {
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB4(src, src_stride, src0, src1, src2, src3);
|
|
|
|
LD_UB4(src + 16, src_stride, src4, src5, src6, src7);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (4 * src_stride);
|
2015-06-02 07:59:56 +03:00
|
|
|
ST_UB4(src0, src1, src2, src3, dst, dst_stride);
|
|
|
|
ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
dst += (4 * dst_stride);
|
|
|
|
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB4(src, src_stride, src0, src1, src2, src3);
|
|
|
|
LD_UB4(src + 16, src_stride, src4, src5, src6, src7);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (4 * src_stride);
|
2015-06-02 07:59:56 +03:00
|
|
|
ST_UB4(src0, src1, src2, src3, dst, dst_stride);
|
|
|
|
ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
dst += (4 * dst_stride);
|
|
|
|
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB4(src, src_stride, src0, src1, src2, src3);
|
|
|
|
LD_UB4(src + 16, src_stride, src4, src5, src6, src7);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (4 * src_stride);
|
2015-06-02 07:59:56 +03:00
|
|
|
ST_UB4(src0, src1, src2, src3, dst, dst_stride);
|
|
|
|
ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
dst += (4 * dst_stride);
|
|
|
|
}
|
|
|
|
} else if (0 == height % 8) {
|
|
|
|
copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 32);
|
|
|
|
} else if (0 == height % 4) {
|
|
|
|
for (cnt = (height >> 2); cnt--;) {
|
2015-06-02 07:59:56 +03:00
|
|
|
LD_UB4(src, src_stride, src0, src1, src2, src3);
|
|
|
|
LD_UB4(src + 16, src_stride, src4, src5, src6, src7);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += (4 * src_stride);
|
2015-06-02 07:59:56 +03:00
|
|
|
ST_UB4(src0, src1, src2, src3, dst, dst_stride);
|
|
|
|
ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride);
|
2015-04-27 09:56:10 +03:00
|
|
|
dst += (4 * dst_stride);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_width64_msa(const uint8_t *src, int32_t src_stride,
|
2015-06-02 07:59:56 +03:00
|
|
|
uint8_t *dst, int32_t dst_stride, int32_t height) {
|
2015-04-27 09:56:10 +03:00
|
|
|
copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 64);
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
void aom_convolve_copy_msa(const uint8_t *src, ptrdiff_t src_stride,
|
2015-04-27 09:56:10 +03:00
|
|
|
uint8_t *dst, ptrdiff_t dst_stride,
|
|
|
|
const int16_t *filter_x, int32_t filter_x_stride,
|
|
|
|
const int16_t *filter_y, int32_t filter_y_stride,
|
|
|
|
int32_t w, int32_t h) {
|
|
|
|
(void)filter_x;
|
|
|
|
(void)filter_y;
|
|
|
|
(void)filter_x_stride;
|
|
|
|
(void)filter_y_stride;
|
|
|
|
|
|
|
|
switch (w) {
|
|
|
|
case 4: {
|
|
|
|
uint32_t cnt, tmp;
|
|
|
|
/* 1 word storage */
|
|
|
|
for (cnt = h; cnt--;) {
|
2015-06-02 07:59:56 +03:00
|
|
|
tmp = LW(src);
|
|
|
|
SW(tmp, dst);
|
2015-04-27 09:56:10 +03:00
|
|
|
src += src_stride;
|
|
|
|
dst += dst_stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 8: {
|
|
|
|
copy_width8_msa(src, src_stride, dst, dst_stride, h);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 16: {
|
|
|
|
copy_width16_msa(src, src_stride, dst, dst_stride, h);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 32: {
|
|
|
|
copy_width32_msa(src, src_stride, dst, dst_stride, h);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 64: {
|
|
|
|
copy_width64_msa(src, src_stride, dst, dst_stride, h);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
uint32_t cnt;
|
|
|
|
for (cnt = h; cnt--;) {
|
|
|
|
memcpy(dst, src, w);
|
|
|
|
src += src_stride;
|
|
|
|
dst += dst_stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|