2 * Loongson SIMD optimized pixblockdsp
4 * Copyright (c) 2015 Loongson Technology Corporation Limited
5 * Copyright (c) 2015 Zhou Xiaoyong <zhouxiaoyong@loongson.cn>
7 * This file is part of FFmpeg.
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "pixblockdsp_mips.h"
25 #include "libavutil/mips/asmdefs.h"
27 void ff_get_pixels_8_mmi(int16_t *av_restrict block, const uint8_t *pixels,
34 "li %[tmp1], 0x08 \n\t"
35 "move %[tmp0], $0 \n\t"
36 "xor %[ftmp0], %[ftmp0], %[ftmp0] \n\t"
38 "gsldlc1 %[ftmp1], 0x07(%[pixels]) \n\t"
39 "gsldrc1 %[ftmp1], 0x00(%[pixels]) \n\t"
40 "punpcklbh %[ftmp2], %[ftmp1], %[ftmp0] \n\t"
41 "punpckhbh %[ftmp5], %[ftmp1], %[ftmp0] \n\t"
42 "gssdxc1 %[ftmp2], 0x00(%[block], %[tmp0]) \n\t"
43 "gssdxc1 %[ftmp5], 0x08(%[block], %[tmp0]) \n\t"
44 PTR_ADDI "%[tmp1], %[tmp1], -0x01 \n\t"
45 PTR_ADDIU "%[tmp0], %[tmp0], 0x10 \n\t"
46 PTR_ADDU "%[pixels], %[pixels], %[line_size] \n\t"
47 "bnez %[tmp1], 1b \n\t"
48 : [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]),
49 [ftmp2]"=&f"(ftmp[2]), [ftmp3]"=&f"(ftmp[3]),
50 [ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]),
51 [tmp0]"=&r"(tmp[0]), [tmp1]"=&r"(tmp[1]),
53 : [block]"r"((mips_reg)block), [line_size]"r"((mips_reg)line_size)
58 void ff_diff_pixels_mmi(int16_t *av_restrict block, const uint8_t *src1,
59 const uint8_t *src2, int stride)
65 "li %[tmp0], 0x08 \n\t"
66 "xor %[ftmp4], %[ftmp4], %[ftmp4] \n\t"
68 "gsldlc1 %[ftmp0], 0x07(%[src1]) \n\t"
69 "gsldrc1 %[ftmp0], 0x00(%[src1]) \n\t"
70 "or %[ftmp1], %[ftmp0], %[ftmp0] \n\t"
71 "gsldlc1 %[ftmp2], 0x07(%[src2]) \n\t"
72 "gsldrc1 %[ftmp2], 0x00(%[src2]) \n\t"
73 "or %[ftmp3], %[ftmp2], %[ftmp2] \n\t"
74 "punpcklbh %[ftmp0], %[ftmp0], %[ftmp4] \n\t"
75 "punpckhbh %[ftmp1], %[ftmp1], %[ftmp4] \n\t"
76 "punpcklbh %[ftmp2], %[ftmp2], %[ftmp4] \n\t"
77 "punpckhbh %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
78 "psubh %[ftmp0], %[ftmp0], %[ftmp2] \n\t"
79 "psubh %[ftmp1], %[ftmp1], %[ftmp3] \n\t"
80 "gssdlc1 %[ftmp0], 0x07(%[block]) \n\t"
81 "gssdrc1 %[ftmp0], 0x00(%[block]) \n\t"
82 "gssdlc1 %[ftmp1], 0x0f(%[block]) \n\t"
83 "gssdrc1 %[ftmp1], 0x08(%[block]) \n\t"
84 PTR_ADDI "%[tmp0], %[tmp0], -0x01 \n\t"
85 PTR_ADDIU "%[block], %[block], 0x10 \n\t"
86 PTR_ADDU "%[src1], %[src1], %[stride] \n\t"
87 PTR_ADDU "%[src2], %[src2], %[stride] \n\t"
88 "bgtz %[tmp0], 1b \n\t"
89 : [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]),
90 [ftmp2]"=&f"(ftmp[2]), [ftmp3]"=&f"(ftmp[3]),
91 [ftmp4]"=&f"(ftmp[4]),
93 [block]"+&r"(block), [src1]"+&r"(src1),
95 : [stride]"r"((mips_reg)stride)