* UINTX -> uintx_t INTX -> intx_t
[libav.git] / libavcodec / ps2 / dsputil_mmi.c
1 /*
2 * MMI optimized DSP utils
3 * Copyright (c) 2000, 2001 Fabrice Bellard.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * MMI optimization by Leon van Stuivenberg <leonvs@iae.nl>
20 */
21
22 #include "../dsputil.h"
23 #include "mmi.h"
24
25
26 static void clear_blocks_mmi(DCTELEM * blocks)
27 {
28 int i;
29 for (i = 0; i < 6; i++) {
30 asm volatile(
31 "sq $0, 0(%0) \n\t"
32 "sq $0, 16(%0) \n\t"
33 "sq $0, 32(%0) \n\t"
34 "sq $0, 48(%0) \n\t"
35 "sq $0, 64(%0) \n\t"
36 "sq $0, 80(%0) \n\t"
37 "sq $0, 96(%0) \n\t"
38 "sq $0, 112(%0) \n\t" :: "r" (blocks) : "memory" );
39 blocks += 64;
40 }
41 }
42
43
44 static void get_pixels_mmi(DCTELEM *block, const uint8_t *pixels, int line_size)
45 {
46 int i;
47 for(i=0;i<8;i++) {
48 asm volatile(
49 ".set push \n\t"
50 ".set mips3 \n\t"
51 "ld $8, 0(%1) \n\t"
52 "add %1, %1, %2 \n\t"
53 "pextlb $8, $0, $8 \n\t"
54 "sq $8, 0(%0) \n\t"
55 ".set pop \n\t"
56 :: "r" (block), "r" (pixels), "r" (line_size) : "$8", "memory" );
57 block += 8;
58 }
59 }
60
61
62 static void put_pixels8_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
63 {
64 int i;
65 for(i=0; i<h; i++) {
66 asm volatile(
67 ".set push \n\t"
68 ".set mips3 \n\t"
69 "ldr $8, 0(%1) \n\t"
70 "ldl $8, 7(%1) \n\t"
71 "add %1, %1, %2 \n\t"
72 "sd $8, 0(%0) \n\t"
73 "add %0, %0, %2 \n\t"
74 ".set pop \n\t"
75 :: "r" (block), "r" (pixels), "r" (line_size) : "$8", "memory" );
76 }
77 }
78
79
80 static void put_pixels16_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
81 {
82 int i;
83 for(i=0; i<(h>>2); i++) {
84 asm volatile (
85 ".set push \n\t"
86 ".set mips3 \n\t"
87 #define PUTPIX16 \
88 "ldr $8, 0(%1) \n\t" \
89 "ldl $8, 7(%1) \n\t" \
90 "ldr $9, 8(%1) \n\t" \
91 "ldl $9, 15(%1) \n\t" \
92 "add %1, %1, %2 \n\t" \
93 "pcpyld $8, $9, $8 \n\t" \
94 "sq $8, 0(%0) \n\t" \
95 "add %0, %0, %2 \n\t"
96 PUTPIX16
97 PUTPIX16
98 PUTPIX16
99 PUTPIX16
100 ".set pop \n\t"
101 :: "r" (block), "r" (pixels), "r" (line_size) : "$8", "$9", "memory" );
102 }
103 }
104
105
106 void dsputil_init_mmi(DSPContext* c, unsigned mask)
107 {
108 c->clear_blocks = clear_blocks_mmi;
109
110 c->put_pixels_tab[1][0] = put_pixels8_mmi;
111 c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mmi;
112
113 c->put_pixels_tab[0][0] = put_pixels16_mmi;
114 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mmi;
115
116 c->get_pixels = get_pixels_mmi;
117 }
118