1 /*!
2 * \copy
3 * Copyright (C) 2020 Loongson Technology Co. Ltd.
4 * Contributed by Gu Xiwei(guxiwei-hf@loongson.cn)
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 *
33 * \file copy_mb_msa.c
34 *
35 * \brief MIPS MSA optimizations
36 *
37 * \date 14/05/2020 Created
38 *
39 *************************************************************************************
40 */
41
42 #include <stdint.h>
43 #include "msa_macros.h"
44
WelsCopy8x8_msa(uint8_t * pDst,int32_t iStrideD,uint8_t * pSrc,int32_t iStrideS)45 void WelsCopy8x8_msa(uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc,
46 int32_t iStrideS ) {
47 v16u8 src0, src1;
48 for (int i = 0; i < 4; i++) {
49 MSA_LD_V2(v16u8, pSrc, iStrideS, src0, src1);
50 MSA_ST_D(src0, 0, pDst);
51 MSA_ST_D(src1, 0, pDst + iStrideD);
52 pSrc += 2 * iStrideS;
53 pDst += 2 * iStrideD;
54 }
55 }
56
WelsCopy8x16_msa(uint8_t * pDst,int32_t iStrideD,uint8_t * pSrc,int32_t iStrideS)57 void WelsCopy8x16_msa(uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc,
58 int32_t iStrideS) {
59 WelsCopy8x8_msa(pDst, iStrideD, pSrc, iStrideS);
60 WelsCopy8x8_msa(pDst + 8 * iStrideD, iStrideD,
61 pSrc + 8 * iStrideS, iStrideS);
62 }
63
WelsCopy16x8_msa(uint8_t * pDst,int32_t iStrideD,uint8_t * pSrc,int32_t iStrideS)64 void WelsCopy16x8_msa(uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc,
65 int32_t iStrideS) {
66 v16u8 src0, src1;
67 for (int i = 0; i < 4; i++) {
68 MSA_LD_V2(v16u8, pSrc, iStrideS, src0, src1);
69 MSA_ST_V2(v16u8, src0, src1, pDst, iStrideD);
70 pSrc += 2 * iStrideS;
71 pDst += 2 * iStrideD;
72 }
73 }
74
WelsCopy16x16_msa(uint8_t * pDst,int32_t iStrideD,uint8_t * pSrc,int32_t iStrideS)75 void WelsCopy16x16_msa(uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc,
76 int32_t iStrideS) {
77 WelsCopy16x8_msa(pDst, iStrideD, pSrc, iStrideS);
78 WelsCopy16x8_msa(pDst + 8 * iStrideD, iStrideD,
79 pSrc + 8 * iStrideS, iStrideS);
80 };
81