Mercurial > libavcodec.hg
annotate alpha/dsputil_alpha.c @ 586:54b1c94977d5 libavcodec
MVI optimizations for motion estimation.
author | mellum |
---|---|
date | Mon, 29 Jul 2002 23:14:51 +0000 |
parents | 3f05be811b5a |
children | 76fef3b11680 |
rev | line source |
---|---|
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
1 /* |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
2 * Alpha optimized DSP utils |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
3 * Copyright (c) 2002 Falk Hueffner <falk@debian.org> |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
4 * |
429 | 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. | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
9 * |
429 | 10 * This library is distributed in the hope that it will be useful, |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
429 | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Lesser General Public License for more details. | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
14 * |
429 | 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 | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
18 */ |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
19 |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
20 #include "asm.h" |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
21 #include "../dsputil.h" |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
22 |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
23 void simple_idct_axp(DCTELEM *block); |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
24 |
511
fa4425cf6b31
Assembly version of put_pixels. This is currently the function that
mellum
parents:
509
diff
changeset
|
25 void put_pixels_axp_asm(uint8_t *block, const uint8_t *pixels, |
fa4425cf6b31
Assembly version of put_pixels. This is currently the function that
mellum
parents:
509
diff
changeset
|
26 int line_size, int h); |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
27 void put_pixels_clamped_mvi_asm(const DCTELEM *block, uint8_t *pixels, |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
28 int line_size); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
29 void add_pixels_clamped_mvi_asm(const DCTELEM *block, uint8_t *pixels, |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
30 int line_size); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
31 |
586 | 32 void get_pixels_mvi(DCTELEM *restrict block, |
33 const uint8_t *restrict pixels, int line_size); | |
34 void diff_pixels_mvi(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, | |
35 int stride); | |
36 int pix_abs8x8_mvi(uint8_t *pix1, uint8_t *pix2, int line_size); | |
37 int pix_abs16x16_mvi(uint8_t *pix1, uint8_t *pix2, int line_size); | |
38 int pix_abs16x16_x2_mvi(uint8_t *pix1, uint8_t *pix2, int line_size); | |
39 int pix_abs16x16_y2_mvi(uint8_t *pix1, uint8_t *pix2, int line_size); | |
40 int pix_abs16x16_xy2_mvi(uint8_t *pix1, uint8_t *pix2, int line_size); | |
41 | |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
42 #if 0 |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
43 /* These functions were the base for the optimized assembler routines, |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
44 and remain here for documentation purposes. */ |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
45 static void put_pixels_clamped_mvi(const DCTELEM *block, uint8_t *pixels, |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
46 int line_size) |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
47 { |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
48 int i = 8; |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
49 uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */ |
505
7a976bf93394
Ugly hack to make the assembler accept MVI instructions.
mellum
parents:
429
diff
changeset
|
50 |
7a976bf93394
Ugly hack to make the assembler accept MVI instructions.
mellum
parents:
429
diff
changeset
|
51 ASM_ACCEPT_MVI; |
7a976bf93394
Ugly hack to make the assembler accept MVI instructions.
mellum
parents:
429
diff
changeset
|
52 |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
53 do { |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
54 uint64_t shorts0, shorts1; |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
55 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
56 shorts0 = ldq(block); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
57 shorts0 = maxsw4(shorts0, 0); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
58 shorts0 = minsw4(shorts0, clampmask); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
59 stl(pkwb(shorts0), pixels); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
60 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
61 shorts1 = ldq(block + 4); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
62 shorts1 = maxsw4(shorts1, 0); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
63 shorts1 = minsw4(shorts1, clampmask); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
64 stl(pkwb(shorts1), pixels + 4); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
65 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
66 pixels += line_size; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
67 block += 8; |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
68 } while (--i); |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
69 } |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
70 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
71 void add_pixels_clamped_mvi(const DCTELEM *block, uint8_t *pixels, |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
72 int line_size) |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
73 { |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
74 int h = 8; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
75 /* Keep this function a leaf function by generating the constants |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
76 manually (mainly for the hack value ;-). */ |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
77 uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */ |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
78 uint64_t signmask = zap(-1, 0x33); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
79 signmask ^= signmask >> 1; /* 0x8000800080008000 */ |
505
7a976bf93394
Ugly hack to make the assembler accept MVI instructions.
mellum
parents:
429
diff
changeset
|
80 |
7a976bf93394
Ugly hack to make the assembler accept MVI instructions.
mellum
parents:
429
diff
changeset
|
81 ASM_ACCEPT_MVI; |
7a976bf93394
Ugly hack to make the assembler accept MVI instructions.
mellum
parents:
429
diff
changeset
|
82 |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
83 do { |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
84 uint64_t shorts0, pix0, signs0; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
85 uint64_t shorts1, pix1, signs1; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
86 |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
87 shorts0 = ldq(block); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
88 shorts1 = ldq(block + 4); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
89 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
90 pix0 = unpkbw(ldl(pixels)); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
91 /* Signed subword add (MMX paddw). */ |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
92 signs0 = shorts0 & signmask; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
93 shorts0 &= ~signmask; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
94 shorts0 += pix0; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
95 shorts0 ^= signs0; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
96 /* Clamp. */ |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
97 shorts0 = maxsw4(shorts0, 0); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
98 shorts0 = minsw4(shorts0, clampmask); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
99 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
100 /* Next 4. */ |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
101 pix1 = unpkbw(ldl(pixels + 4)); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
102 signs1 = shorts1 & signmask; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
103 shorts1 &= ~signmask; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
104 shorts1 += pix1; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
105 shorts1 ^= signs1; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
106 shorts1 = maxsw4(shorts1, 0); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
107 shorts1 = minsw4(shorts1, clampmask); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
108 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
109 stl(pkwb(shorts0), pixels); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
110 stl(pkwb(shorts1), pixels + 4); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
111 |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
112 pixels += line_size; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
113 block += 8; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
114 } while (--h); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
115 } |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
116 #endif |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
117 |
518 | 118 static void clear_blocks_axp(DCTELEM *blocks) { |
119 uint64_t *p = (uint64_t *) blocks; | |
120 int n = sizeof(DCTELEM) * 6 * 64; | |
121 | |
122 do { | |
123 p[0] = 0; | |
124 p[1] = 0; | |
125 p[2] = 0; | |
126 p[3] = 0; | |
127 p[4] = 0; | |
128 p[5] = 0; | |
129 p[6] = 0; | |
130 p[7] = 0; | |
131 p += 8; | |
132 n -= 8 * 8; | |
133 } while (n); | |
134 } | |
135 | |
513 | 136 static inline uint64_t avg2_no_rnd(uint64_t a, uint64_t b) |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
137 { |
513 | 138 return (a & b) + (((a ^ b) & BYTE_VEC(0xfe)) >> 1); |
139 } | |
140 | |
141 static inline uint64_t avg2(uint64_t a, uint64_t b) | |
142 { | |
143 return (a | b) - (((a ^ b) & BYTE_VEC(0xfe)) >> 1); | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
144 } |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
145 |
546 | 146 #if 0 |
147 /* The XY2 routines basically utilize this scheme, but reuse parts in | |
148 each iteration. */ | |
513 | 149 static inline uint64_t avg4(uint64_t l1, uint64_t l2, uint64_t l3, uint64_t l4) |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
150 { |
513 | 151 uint64_t r1 = ((l1 & ~BYTE_VEC(0x03)) >> 2) |
152 + ((l2 & ~BYTE_VEC(0x03)) >> 2) | |
153 + ((l3 & ~BYTE_VEC(0x03)) >> 2) | |
154 + ((l4 & ~BYTE_VEC(0x03)) >> 2); | |
155 uint64_t r2 = (( (l1 & BYTE_VEC(0x03)) | |
156 + (l2 & BYTE_VEC(0x03)) | |
157 + (l3 & BYTE_VEC(0x03)) | |
158 + (l4 & BYTE_VEC(0x03)) | |
159 + BYTE_VEC(0x02)) >> 2) & BYTE_VEC(0x03); | |
160 return r1 + r2; | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
161 } |
546 | 162 #endif |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
163 |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
164 #define OP(LOAD, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
165 do { \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
166 STORE(LOAD(pixels), block); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
167 pixels += line_size; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
168 block += line_size; \ |
513 | 169 } while (--h) |
170 | |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
171 #define OP_X2(LOAD, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
172 do { \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
173 uint64_t pix1, pix2; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
174 \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
175 pix1 = LOAD(pixels); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
176 pix2 = pix1 >> 8 | ((uint64_t) pixels[8] << 56); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
177 STORE(AVG2(pix1, pix2), block); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
178 pixels += line_size; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
179 block += line_size; \ |
513 | 180 } while (--h) |
181 | |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
182 #define OP_Y2(LOAD, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
183 do { \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
184 uint64_t pix = LOAD(pixels); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
185 do { \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
186 uint64_t next_pix; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
187 \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
188 pixels += line_size; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
189 next_pix = LOAD(pixels); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
190 STORE(AVG2(pix, next_pix), block); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
191 block += line_size; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
192 pix = next_pix; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
193 } while (--h); \ |
513 | 194 } while (0) |
195 | |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
196 #define OP_XY2(LOAD, STORE) \ |
546 | 197 do { \ |
198 uint64_t pix1 = LOAD(pixels); \ | |
199 uint64_t pix2 = pix1 >> 8 | ((uint64_t) pixels[8] << 56); \ | |
200 uint64_t pix_l = (pix1 & BYTE_VEC(0x03)) \ | |
201 + (pix2 & BYTE_VEC(0x03)); \ | |
202 uint64_t pix_h = ((pix1 & ~BYTE_VEC(0x03)) >> 2) \ | |
203 + ((pix2 & ~BYTE_VEC(0x03)) >> 2); \ | |
204 \ | |
205 do { \ | |
206 uint64_t npix1, npix2; \ | |
207 uint64_t npix_l, npix_h; \ | |
208 uint64_t avg; \ | |
209 \ | |
210 pixels += line_size; \ | |
211 npix1 = LOAD(pixels); \ | |
212 npix2 = npix1 >> 8 | ((uint64_t) pixels[8] << 56); \ | |
213 npix_l = (npix1 & BYTE_VEC(0x03)) \ | |
214 + (npix2 & BYTE_VEC(0x03)); \ | |
215 npix_h = ((npix1 & ~BYTE_VEC(0x03)) >> 2) \ | |
216 + ((npix2 & ~BYTE_VEC(0x03)) >> 2); \ | |
217 avg = (((pix_l + npix_l + AVG4_ROUNDER) >> 2) & BYTE_VEC(0x03)) \ | |
218 + pix_h + npix_h; \ | |
219 STORE(avg, block); \ | |
220 \ | |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
221 block += line_size; \ |
546 | 222 pix_l = npix_l; \ |
223 pix_h = npix_h; \ | |
224 } while (--h); \ | |
513 | 225 } while (0) |
226 | |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
227 #define MAKE_OP(OPNAME, SUFF, OPKIND, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
228 static void OPNAME ## _pixels ## SUFF ## _axp \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
229 (uint8_t *restrict block, const uint8_t *restrict pixels, \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
230 int line_size, int h) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
231 { \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
232 if ((size_t) pixels & 0x7) { \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
233 OPKIND(uldq, STORE); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
234 } else { \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
235 OPKIND(ldq, STORE); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
236 } \ |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
237 } |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
238 |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
239 #define PIXOP(OPNAME, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
240 MAKE_OP(OPNAME, , OP, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
241 MAKE_OP(OPNAME, _x2, OP_X2, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
242 MAKE_OP(OPNAME, _y2, OP_Y2, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
243 MAKE_OP(OPNAME, _xy2, OP_XY2, STORE) |
513 | 244 |
245 /* Rounding primitives. */ | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
246 #define AVG2 avg2 |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
247 #define AVG4 avg4 |
546 | 248 #define AVG4_ROUNDER BYTE_VEC(0x02) |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
249 #define STORE(l, b) stq(l, b) |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
250 PIXOP(put, STORE); |
513 | 251 |
252 #undef STORE | |
253 #define STORE(l, b) stq(AVG2(l, ldq(b)), b); | |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
254 PIXOP(avg, STORE); |
513 | 255 |
256 /* Not rounding primitives. */ | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
257 #undef AVG2 |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
258 #undef AVG4 |
546 | 259 #undef AVG4_ROUNDER |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
260 #undef STORE |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
261 #define AVG2 avg2_no_rnd |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
262 #define AVG4 avg4_no_rnd |
546 | 263 #define AVG4_ROUNDER BYTE_VEC(0x01) |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
264 #define STORE(l, b) stq(l, b) |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
265 PIXOP(put_no_rnd, STORE); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
266 |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
267 #undef STORE |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
268 #define STORE(l, b) stq(AVG2(l, ldq(b)), b); |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
269 PIXOP(avg_no_rnd, STORE); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
270 |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
271 void dsputil_init_alpha(void) |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
272 { |
511
fa4425cf6b31
Assembly version of put_pixels. This is currently the function that
mellum
parents:
509
diff
changeset
|
273 put_pixels_tab[0] = put_pixels_axp_asm; |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
274 put_pixels_tab[1] = put_pixels_x2_axp; |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
275 put_pixels_tab[2] = put_pixels_y2_axp; |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
276 put_pixels_tab[3] = put_pixels_xy2_axp; |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
277 |
511
fa4425cf6b31
Assembly version of put_pixels. This is currently the function that
mellum
parents:
509
diff
changeset
|
278 put_no_rnd_pixels_tab[0] = put_pixels_axp_asm; |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
279 put_no_rnd_pixels_tab[1] = put_no_rnd_pixels_x2_axp; |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
280 put_no_rnd_pixels_tab[2] = put_no_rnd_pixels_y2_axp; |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
281 put_no_rnd_pixels_tab[3] = put_no_rnd_pixels_xy2_axp; |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
282 |
513 | 283 avg_pixels_tab[0] = avg_pixels_axp; |
284 avg_pixels_tab[1] = avg_pixels_x2_axp; | |
285 avg_pixels_tab[2] = avg_pixels_y2_axp; | |
286 avg_pixels_tab[3] = avg_pixels_xy2_axp; | |
287 | |
288 avg_no_rnd_pixels_tab[0] = avg_no_rnd_pixels_axp; | |
289 avg_no_rnd_pixels_tab[1] = avg_no_rnd_pixels_x2_axp; | |
290 avg_no_rnd_pixels_tab[2] = avg_no_rnd_pixels_y2_axp; | |
291 avg_no_rnd_pixels_tab[3] = avg_no_rnd_pixels_xy2_axp; | |
292 | |
518 | 293 clear_blocks = clear_blocks_axp; |
294 | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
295 /* amask clears all bits that correspond to present features. */ |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
296 if (amask(AMASK_MVI) == 0) { |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
297 put_pixels_clamped = put_pixels_clamped_mvi_asm; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
298 add_pixels_clamped = add_pixels_clamped_mvi_asm; |
586 | 299 |
300 get_pixels = get_pixels_mvi; | |
301 diff_pixels = diff_pixels_mvi; | |
302 pix_abs8x8 = pix_abs8x8_mvi; | |
303 pix_abs16x16 = pix_abs16x16_mvi; | |
304 pix_abs16x16_x2 = pix_abs16x16_x2_mvi; | |
305 pix_abs16x16_y2 = pix_abs16x16_y2_mvi; | |
306 pix_abs16x16_xy2 = pix_abs16x16_xy2_mvi; | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
307 } |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
308 } |