]> git.sesse.net Git - ffmpeg/blob - libavcodec/mips/blockdsp_mmi.c
AAC: MIPS: Add missing codebooks in quantize funcs
[ffmpeg] / libavcodec / mips / blockdsp_mmi.c
1 /*
2  * Loongson SIMD optimized blockdsp
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 "blockdsp_mips.h"
25
26 void ff_fill_block16_mmi(uint8_t *block, uint8_t value, int line_size, int h)
27 {
28     __asm__ volatile (
29         "move $8, %3                \r\n"
30         "move $9, %0                \r\n"
31         "dmtc1 %1, $f2              \r\n"
32         "punpcklbh $f2, $f2, $f2    \r\n"
33         "punpcklbh $f2, $f2, $f2    \r\n"
34         "punpcklbh $f2, $f2, $f2    \r\n"
35         "1:                         \r\n"
36         "gssdlc1 $f2, 7($9)         \r\n"
37         "gssdrc1 $f2, 0($9)         \r\n"
38         "gssdlc1 $f2, 15($9)        \r\n"
39         "gssdrc1 $f2, 8($9)         \r\n"
40         "daddi $8, $8, -1           \r\n"
41         "daddu $9, $9, %2           \r\n"
42         "bnez $8, 1b                \r\n"
43         ::"r"(block),"r"(value),"r"(line_size),"r"(h)
44         : "$8","$9"
45     );
46 }
47
48 void ff_fill_block8_mmi(uint8_t *block, uint8_t value, int line_size, int h)
49 {
50     __asm__ volatile (
51         "move $8, %3                \r\n"
52         "move $9, %0                \r\n"
53         "dmtc1 %1, $f2              \r\n"
54         "punpcklbh $f2, $f2, $f2    \r\n"
55         "punpcklbh $f2, $f2, $f2    \r\n"
56         "punpcklbh $f2, $f2, $f2    \r\n"
57         "1:                         \r\n"
58         "gssdlc1 $f2, 7($9)         \r\n"
59         "gssdrc1 $f2, 0($9)         \r\n"
60         "daddi $8, $8, -1           \r\n"
61         "daddu $9, $9, %2           \r\n"
62         "bnez $8, 1b                \r\n"
63         ::"r"(block),"r"(value),"r"(line_size),"r"(h)
64         : "$8","$9"
65     );
66 }
67
68 void ff_clear_block_mmi(int16_t *block)
69 {
70     __asm__ volatile (
71         "xor $f0, $f0, $f0              \r\n"
72         "xor $f2, $f2, $f2              \r\n"
73         "gssqc1 $f0, $f2,   0(%0)       \r\n"
74         "gssqc1 $f0, $f2,  16(%0)       \r\n"
75         "gssqc1 $f0, $f2,  32(%0)       \r\n"
76         "gssqc1 $f0, $f2,  48(%0)       \r\n"
77         "gssqc1 $f0, $f2,  64(%0)       \r\n"
78         "gssqc1 $f0, $f2,  80(%0)       \r\n"
79         "gssqc1 $f0, $f2,  96(%0)       \r\n"
80         "gssqc1 $f0, $f2, 112(%0)       \r\n"
81         ::"r"(block)
82         : "memory"
83     );
84 }
85
86 void ff_clear_blocks_mmi(int16_t *block)
87 {
88     __asm__ volatile (
89         "xor $f0, $f0, $f0              \r\n"
90         "xor $f2, $f2, $f2              \r\n"
91         "gssqc1 $f0, $f2,   0(%0)       \r\n"
92         "gssqc1 $f0, $f2,  16(%0)       \r\n"
93         "gssqc1 $f0, $f2,  32(%0)       \r\n"
94         "gssqc1 $f0, $f2,  48(%0)       \r\n"
95         "gssqc1 $f0, $f2,  64(%0)       \r\n"
96         "gssqc1 $f0, $f2,  80(%0)       \r\n"
97         "gssqc1 $f0, $f2,  96(%0)       \r\n"
98         "gssqc1 $f0, $f2, 112(%0)       \r\n"
99
100         "gssqc1 $f0, $f2, 128(%0)       \r\n"
101         "gssqc1 $f0, $f2, 144(%0)       \r\n"
102         "gssqc1 $f0, $f2, 160(%0)       \r\n"
103         "gssqc1 $f0, $f2, 176(%0)       \r\n"
104         "gssqc1 $f0, $f2, 192(%0)       \r\n"
105         "gssqc1 $f0, $f2, 208(%0)       \r\n"
106         "gssqc1 $f0, $f2, 224(%0)       \r\n"
107         "gssqc1 $f0, $f2, 240(%0)       \r\n"
108
109         "gssqc1 $f0, $f2, 256(%0)       \r\n"
110         "gssqc1 $f0, $f2, 272(%0)       \r\n"
111         "gssqc1 $f0, $f2, 288(%0)       \r\n"
112         "gssqc1 $f0, $f2, 304(%0)       \r\n"
113         "gssqc1 $f0, $f2, 320(%0)       \r\n"
114         "gssqc1 $f0, $f2, 336(%0)       \r\n"
115         "gssqc1 $f0, $f2, 352(%0)       \r\n"
116         "gssqc1 $f0, $f2, 368(%0)       \r\n"
117
118         "gssqc1 $f0, $f2, 384(%0)       \r\n"
119         "gssqc1 $f0, $f2, 400(%0)       \r\n"
120         "gssqc1 $f0, $f2, 416(%0)       \r\n"
121         "gssqc1 $f0, $f2, 432(%0)       \r\n"
122         "gssqc1 $f0, $f2, 448(%0)       \r\n"
123         "gssqc1 $f0, $f2, 464(%0)       \r\n"
124         "gssqc1 $f0, $f2, 480(%0)       \r\n"
125         "gssqc1 $f0, $f2, 496(%0)       \r\n"
126
127         "gssqc1 $f0, $f2, 512(%0)       \r\n"
128         "gssqc1 $f0, $f2, 528(%0)       \r\n"
129         "gssqc1 $f0, $f2, 544(%0)       \r\n"
130         "gssqc1 $f0, $f2, 560(%0)       \r\n"
131         "gssqc1 $f0, $f2, 576(%0)       \r\n"
132         "gssqc1 $f0, $f2, 592(%0)       \r\n"
133         "gssqc1 $f0, $f2, 608(%0)       \r\n"
134         "gssqc1 $f0, $f2, 624(%0)       \r\n"
135
136         "gssqc1 $f0, $f2, 640(%0)       \r\n"
137         "gssqc1 $f0, $f2, 656(%0)       \r\n"
138         "gssqc1 $f0, $f2, 672(%0)       \r\n"
139         "gssqc1 $f0, $f2, 688(%0)       \r\n"
140         "gssqc1 $f0, $f2, 704(%0)       \r\n"
141         "gssqc1 $f0, $f2, 720(%0)       \r\n"
142         "gssqc1 $f0, $f2, 736(%0)       \r\n"
143         "gssqc1 $f0, $f2, 752(%0)       \r\n"
144         ::"r"(block)
145         : "memory"
146     );
147 }