annotate alpha/dsputil_alpha.c @ 546:8cefba09f2e8 libavcodec

* Improve xy2 routines slightly * Mark MC pointer arguments as restrict
author mellum
date Sat, 13 Jul 2002 16:17:38 +0000
parents 70113647b50d
children 3f05be811b5a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
5 * This library is free software; you can redistribute it and/or
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
7 * License as published by the Free Software Foundation; either
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
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
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
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
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
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
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
16 * License along with this library; if not, write to the Free Software
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
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
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
32 #if 0
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
33 /* 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
34 and remain here for documentation purposes. */
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
35 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
36 int line_size)
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
37 {
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
38 int i = 8;
509
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
39 uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */
505
7a976bf93394 Ugly hack to make the assembler accept MVI instructions.
mellum
parents: 429
diff changeset
40
7a976bf93394 Ugly hack to make the assembler accept MVI instructions.
mellum
parents: 429
diff changeset
41 ASM_ACCEPT_MVI;
7a976bf93394 Ugly hack to make the assembler accept MVI instructions.
mellum
parents: 429
diff changeset
42
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
43 do {
509
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
44 uint64_t shorts0, shorts1;
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
45
509
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
46 shorts0 = ldq(block);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
47 shorts0 = maxsw4(shorts0, 0);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
48 shorts0 = minsw4(shorts0, clampmask);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
49 stl(pkwb(shorts0), pixels);
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
50
509
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
51 shorts1 = ldq(block + 4);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
52 shorts1 = maxsw4(shorts1, 0);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
53 shorts1 = minsw4(shorts1, clampmask);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
54 stl(pkwb(shorts1), pixels + 4);
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 pixels += line_size;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
57 block += 8;
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
58 } while (--i);
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
59 }
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 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
62 int line_size)
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
63 {
509
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
64 int h = 8;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
65 /* 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
66 manually (mainly for the hack value ;-). */
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
67 uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
68 uint64_t signmask = zap(-1, 0x33);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
69 signmask ^= signmask >> 1; /* 0x8000800080008000 */
505
7a976bf93394 Ugly hack to make the assembler accept MVI instructions.
mellum
parents: 429
diff changeset
70
7a976bf93394 Ugly hack to make the assembler accept MVI instructions.
mellum
parents: 429
diff changeset
71 ASM_ACCEPT_MVI;
7a976bf93394 Ugly hack to make the assembler accept MVI instructions.
mellum
parents: 429
diff changeset
72
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
73 do {
509
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
74 uint64_t shorts0, pix0, signs0;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
75 uint64_t shorts1, pix1, signs1;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
76
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
77 shorts0 = ldq(block);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
78 shorts1 = ldq(block + 4);
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
79
509
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
80 pix0 = unpkbw(ldl(pixels));
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
81 /* Signed subword add (MMX paddw). */
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
82 signs0 = shorts0 & signmask;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
83 shorts0 &= ~signmask;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
84 shorts0 += pix0;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
85 shorts0 ^= signs0;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
86 /* Clamp. */
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
87 shorts0 = maxsw4(shorts0, 0);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
88 shorts0 = minsw4(shorts0, clampmask);
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 /* Next 4. */
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
91 pix1 = unpkbw(ldl(pixels + 4));
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
92 signs1 = shorts1 & signmask;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
93 shorts1 &= ~signmask;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
94 shorts1 += pix1;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
95 shorts1 ^= signs1;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
96 shorts1 = maxsw4(shorts1, 0);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
97 shorts1 = minsw4(shorts1, clampmask);
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
98
509
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
99 stl(pkwb(shorts0), pixels);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
100 stl(pkwb(shorts1), pixels + 4);
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
101
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
102 pixels += line_size;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
103 block += 8;
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
104 } while (--h);
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
105 }
509
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
106 #endif
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
107
518
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
108 static void clear_blocks_axp(DCTELEM *blocks) {
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
109 uint64_t *p = (uint64_t *) blocks;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
110 int n = sizeof(DCTELEM) * 6 * 64;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
111
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
112 do {
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
113 p[0] = 0;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
114 p[1] = 0;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
115 p[2] = 0;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
116 p[3] = 0;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
117 p[4] = 0;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
118 p[5] = 0;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
119 p[6] = 0;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
120 p[7] = 0;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
121 p += 8;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
122 n -= 8 * 8;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
123 } while (n);
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
124 }
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
125
513
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
126 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
127 {
513
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
128 return (a & b) + (((a ^ b) & BYTE_VEC(0xfe)) >> 1);
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
129 }
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
130
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
131 static inline uint64_t avg2(uint64_t a, uint64_t b)
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
132 {
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
133 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
134 }
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
135
546
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
136 #if 0
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
137 /* The XY2 routines basically utilize this scheme, but reuse parts in
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
138 each iteration. */
513
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
139 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
140 {
513
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
141 uint64_t r1 = ((l1 & ~BYTE_VEC(0x03)) >> 2)
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
142 + ((l2 & ~BYTE_VEC(0x03)) >> 2)
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
143 + ((l3 & ~BYTE_VEC(0x03)) >> 2)
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
144 + ((l4 & ~BYTE_VEC(0x03)) >> 2);
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
145 uint64_t r2 = (( (l1 & BYTE_VEC(0x03))
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
146 + (l2 & BYTE_VEC(0x03))
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
147 + (l3 & BYTE_VEC(0x03))
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
148 + (l4 & BYTE_VEC(0x03))
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
149 + BYTE_VEC(0x02)) >> 2) & BYTE_VEC(0x03);
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
150 return r1 + r2;
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
151 }
546
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
152 #endif
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
153
513
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
154 #define OP(LOAD, STORE, INCR) \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
155 do { \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
156 STORE(LOAD(pixels), block); \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
157 pixels += line_size; \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
158 block += INCR; \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
159 } while (--h)
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
160
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
161 #define OP_X2(LOAD, STORE, INCR) \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
162 do { \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
163 uint64_t pix1, pix2; \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
164 \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
165 pix1 = LOAD(pixels); \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
166 pix2 = pix1 >> 8 | ((uint64_t) pixels[8] << 56); \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
167 STORE(AVG2(pix1, pix2), block); \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
168 pixels += line_size; \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
169 block += INCR; \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
170 } while (--h)
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
171
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
172 #define OP_Y2(LOAD, STORE, INCR) \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
173 do { \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
174 uint64_t pix = LOAD(pixels); \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
175 do { \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
176 uint64_t next_pix; \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
177 \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
178 pixels += line_size; \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
179 next_pix = LOAD(pixels); \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
180 STORE(AVG2(pix, next_pix), block); \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
181 block += INCR; \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
182 pix = next_pix; \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
183 } while (--h); \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
184 } while (0)
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
185
546
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
186 #define OP_XY2(LOAD, STORE, INCR) \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
187 do { \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
188 uint64_t pix1 = LOAD(pixels); \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
189 uint64_t pix2 = pix1 >> 8 | ((uint64_t) pixels[8] << 56); \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
190 uint64_t pix_l = (pix1 & BYTE_VEC(0x03)) \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
191 + (pix2 & BYTE_VEC(0x03)); \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
192 uint64_t pix_h = ((pix1 & ~BYTE_VEC(0x03)) >> 2) \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
193 + ((pix2 & ~BYTE_VEC(0x03)) >> 2); \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
194 \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
195 do { \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
196 uint64_t npix1, npix2; \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
197 uint64_t npix_l, npix_h; \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
198 uint64_t avg; \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
199 \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
200 pixels += line_size; \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
201 npix1 = LOAD(pixels); \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
202 npix2 = npix1 >> 8 | ((uint64_t) pixels[8] << 56); \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
203 npix_l = (npix1 & BYTE_VEC(0x03)) \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
204 + (npix2 & BYTE_VEC(0x03)); \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
205 npix_h = ((npix1 & ~BYTE_VEC(0x03)) >> 2) \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
206 + ((npix2 & ~BYTE_VEC(0x03)) >> 2); \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
207 avg = (((pix_l + npix_l + AVG4_ROUNDER) >> 2) & BYTE_VEC(0x03)) \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
208 + pix_h + npix_h; \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
209 STORE(avg, block); \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
210 \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
211 block += INCR; \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
212 pix_l = npix_l; \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
213 pix_h = npix_h; \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
214 } while (--h); \
513
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
215 } while (0)
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
216
546
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
217 #define MAKE_OP(BTYPE, OPNAME, SUFF, OPKIND, STORE, INCR) \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
218 static void OPNAME ## _pixels ## SUFF ## _axp \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
219 (BTYPE *restrict block, const uint8_t *restrict pixels, \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
220 int line_size, int h) \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
221 { \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
222 if ((size_t) pixels & 0x7) { \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
223 OPKIND(uldq, STORE, INCR); \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
224 } else { \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
225 OPKIND(ldq, STORE, INCR); \
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
226 } \
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
227 }
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
228
513
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
229 #define PIXOP(BTYPE, OPNAME, STORE, INCR) \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
230 MAKE_OP(BTYPE, OPNAME, , OP, STORE, INCR); \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
231 MAKE_OP(BTYPE, OPNAME, _x2, OP_X2, STORE, INCR); \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
232 MAKE_OP(BTYPE, OPNAME, _y2, OP_Y2, STORE, INCR); \
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
233 MAKE_OP(BTYPE, OPNAME, _xy2, OP_XY2, STORE, INCR);
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
234
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
235 /* Rounding primitives. */
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
236 #define AVG2 avg2
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
237 #define AVG4 avg4
546
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
238 #define AVG4_ROUNDER BYTE_VEC(0x02)
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
239 #define STORE(l, b) stq(l, b)
513
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
240 PIXOP(uint8_t, put, STORE, line_size);
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
241
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
242 #undef STORE
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
243 #define STORE(l, b) stq(AVG2(l, ldq(b)), b);
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
244 PIXOP(uint8_t, avg, STORE, line_size);
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
245
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
246 /* Not rounding primitives. */
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
247 #undef AVG2
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
248 #undef AVG4
546
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
249 #undef AVG4_ROUNDER
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
250 #undef STORE
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
251 #define AVG2 avg2_no_rnd
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
252 #define AVG4 avg4_no_rnd
546
8cefba09f2e8 * Improve xy2 routines slightly
mellum
parents: 518
diff changeset
253 #define AVG4_ROUNDER BYTE_VEC(0x01)
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
254 #define STORE(l, b) stq(l, b)
513
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
255 PIXOP(uint8_t, put_no_rnd, STORE, line_size);
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
256
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
257 #undef STORE
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
258 #define STORE(l, b) stq(AVG2(l, ldq(b)), b);
513
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
259 PIXOP(uint8_t, avg_no_rnd, STORE, line_size);
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
260
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
261 void dsputil_init_alpha(void)
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
262 {
511
fa4425cf6b31 Assembly version of put_pixels. This is currently the function that
mellum
parents: 509
diff changeset
263 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
264 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
265 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
266 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
267
511
fa4425cf6b31 Assembly version of put_pixels. This is currently the function that
mellum
parents: 509
diff changeset
268 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
269 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
270 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
271 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
272
513
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
273 avg_pixels_tab[0] = avg_pixels_axp;
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
274 avg_pixels_tab[1] = avg_pixels_x2_axp;
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
275 avg_pixels_tab[2] = avg_pixels_y2_axp;
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
276 avg_pixels_tab[3] = avg_pixels_xy2_axp;
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
277
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
278 avg_no_rnd_pixels_tab[0] = avg_no_rnd_pixels_axp;
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
279 avg_no_rnd_pixels_tab[1] = avg_no_rnd_pixels_x2_axp;
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
280 avg_no_rnd_pixels_tab[2] = avg_no_rnd_pixels_y2_axp;
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
281 avg_no_rnd_pixels_tab[3] = avg_no_rnd_pixels_xy2_axp;
fb670ca9f8eb Use updated motion compensation routines.
mellum
parents: 511
diff changeset
282
518
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
283 clear_blocks = clear_blocks_axp;
70113647b50d Implement clear_blocks_axp.
mellum
parents: 513
diff changeset
284
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
285 /* 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
286 if (amask(AMASK_MVI) == 0) {
509
cab79946302f Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents: 505
diff changeset
287 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
288 add_pixels_clamped = add_pixels_clamped_mvi_asm;
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
289 }
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
290 }