FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pixblockdsp_mmi.c
Go to the documentation of this file.
1 /*
2  * Loongson SIMD optimized pixblockdsp
3  *
4  * Copyright (c) 2015 Loongson Technology Corporation Limited
5  * Copyright (c) 2015 Zhou Xiaoyong <zhouxiaoyong@loongson.cn>
6  *
7  * This file is part of FFmpeg.
8  *
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.
13  *
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.
18  *
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
22  */
23 
24 #include "pixblockdsp_mips.h"
25 #include "libavutil/mips/asmdefs.h"
26 
27 void ff_get_pixels_8_mmi(int16_t *av_restrict block, const uint8_t *pixels,
28  ptrdiff_t line_size)
29 {
30  double ftmp[6];
31  mips_reg tmp[2];
32 
33  __asm__ volatile (
34  "li %[tmp1], 0x08 \n\t"
35  "move %[tmp0], $0 \n\t"
36  "xor %[ftmp0], %[ftmp0], %[ftmp0] \n\t"
37  "1: \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]),
52  [pixels]"+&r"(pixels)
53  : [block]"r"((mips_reg)block), [line_size]"r"((mips_reg)line_size)
54  : "memory"
55  );
56 }
57 
58 void ff_diff_pixels_mmi(int16_t *av_restrict block, const uint8_t *src1,
59  const uint8_t *src2, int stride)
60 {
61  double ftmp[5];
62  mips_reg tmp[1];
63 
64  __asm__ volatile (
65  "li %[tmp0], 0x08 \n\t"
66  "xor %[ftmp4], %[ftmp4], %[ftmp4] \n\t"
67  "1: \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]),
92  [tmp0]"=&r"(tmp[0]),
93  [block]"+&r"(block), [src1]"+&r"(src1),
94  [src2]"+&r"(src2)
95  : [stride]"r"((mips_reg)stride)
96  : "memory"
97  );
98 }
#define mips_reg
Definition: asmdefs.h:44
MIPS assembly defines from sys/asm.h but rewritten for use with C inline assembly (rather than from w...
static int16_t block[64]
Definition: dct.c:113
uint8_t
#define PTR_ADDI
Definition: asmdefs.h:49
#define src1
Definition: h264pred.c:139
#define PTR_ADDIU
Definition: asmdefs.h:48
void ff_get_pixels_8_mmi(int16_t *av_restrict block, const uint8_t *pixels, ptrdiff_t line_size)
GLint GLenum GLboolean GLsizei stride
Definition: opengl_enc.c:105
int pixels
Definition: avisynth_c.h:298
static uint8_t tmp[8]
Definition: des.c:38
#define PTR_ADDU
Definition: asmdefs.h:47
#define stride
void ff_diff_pixels_mmi(int16_t *av_restrict block, const uint8_t *src1, const uint8_t *src2, int stride)