Mercurial > libavcodec.hg
annotate alpha/dsputil_alpha.c @ 12492:58a960d6e34c libavcodec
Rename h264_idct_sse2.asm to h264_idct.asm; move inline IDCT asm from
h264dsp_mmx.c to h264_idct.asm (as yasm code). Because the loops are now
coded in asm instead of C, this is (depending on the function) up to 50%
faster for cases where gcc didn't do a great job at looping.
Since h264_idct_add8() is now faster than the manual loop setup in h264.c,
in-asm idct calling can now be enabled for chroma as well (see r16207). For
MMX, this is 5% faster. For SSE2 (which isn't done for chroma if h264.c does
the looping), this makes it up to 50% faster. Speed gain overall is ~0.5-1.0%.
author | rbultje |
---|---|
date | Tue, 14 Sep 2010 13:36:26 +0000 |
parents | 9e7d38743146 |
children |
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 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
429 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
10 * version 2.1 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
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
12 * FFmpeg 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
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
429 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * 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
|
16 * |
429 | 17 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2967
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
20 */ |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
21 |
6763 | 22 #include "libavcodec/dsputil.h" |
11396 | 23 #include "dsputil_alpha.h" |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
24 #include "asm.h" |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
25 |
897 | 26 void (*put_pixels_clamped_axp_p)(const DCTELEM *block, uint8_t *pixels, |
27 int line_size); | |
2967 | 28 void (*add_pixels_clamped_axp_p)(const DCTELEM *block, uint8_t *pixels, |
897 | 29 int line_size); |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
30 |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
31 #if 0 |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
32 /* 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
|
33 and remain here for documentation purposes. */ |
2967 | 34 static void put_pixels_clamped_mvi(const DCTELEM *block, uint8_t *pixels, |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
35 int line_size) |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
36 { |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
37 int i = 8; |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
38 uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */ |
505
7a976bf93394
Ugly hack to make the assembler accept MVI instructions.
mellum
parents:
429
diff
changeset
|
39 |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
40 do { |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
41 uint64_t shorts0, shorts1; |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
42 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
43 shorts0 = ldq(block); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
44 shorts0 = maxsw4(shorts0, 0); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
45 shorts0 = minsw4(shorts0, clampmask); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
46 stl(pkwb(shorts0), pixels); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
47 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
48 shorts1 = ldq(block + 4); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
49 shorts1 = maxsw4(shorts1, 0); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
50 shorts1 = minsw4(shorts1, clampmask); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
51 stl(pkwb(shorts1), pixels + 4); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
52 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
53 pixels += line_size; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
54 block += 8; |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
55 } while (--i); |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
56 } |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
57 |
2967 | 58 void add_pixels_clamped_mvi(const DCTELEM *block, uint8_t *pixels, |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
59 int line_size) |
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 int h = 8; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
62 /* 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
|
63 manually (mainly for the hack value ;-). */ |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
64 uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */ |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
65 uint64_t signmask = zap(-1, 0x33); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
66 signmask ^= signmask >> 1; /* 0x8000800080008000 */ |
505
7a976bf93394
Ugly hack to make the assembler accept MVI instructions.
mellum
parents:
429
diff
changeset
|
67 |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
68 do { |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
69 uint64_t shorts0, pix0, signs0; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
70 uint64_t shorts1, pix1, signs1; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
71 |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
72 shorts0 = ldq(block); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
73 shorts1 = ldq(block + 4); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
74 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
75 pix0 = unpkbw(ldl(pixels)); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
76 /* Signed subword add (MMX paddw). */ |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
77 signs0 = shorts0 & signmask; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
78 shorts0 &= ~signmask; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
79 shorts0 += pix0; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
80 shorts0 ^= signs0; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
81 /* Clamp. */ |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
82 shorts0 = maxsw4(shorts0, 0); |
2967 | 83 shorts0 = minsw4(shorts0, clampmask); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
84 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
85 /* Next 4. */ |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
86 pix1 = unpkbw(ldl(pixels + 4)); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
87 signs1 = shorts1 & signmask; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
88 shorts1 &= ~signmask; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
89 shorts1 += pix1; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
90 shorts1 ^= signs1; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
91 shorts1 = maxsw4(shorts1, 0); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
92 shorts1 = minsw4(shorts1, clampmask); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
93 |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
94 stl(pkwb(shorts0), pixels); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
95 stl(pkwb(shorts1), pixels + 4); |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
96 |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
97 pixels += line_size; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
98 block += 8; |
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
99 } while (--h); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
100 } |
509
cab79946302f
Implement put_pixels_clamped and add_pixels_clamped in Assembler. This
mellum
parents:
505
diff
changeset
|
101 #endif |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
102 |
518 | 103 static void clear_blocks_axp(DCTELEM *blocks) { |
104 uint64_t *p = (uint64_t *) blocks; | |
105 int n = sizeof(DCTELEM) * 6 * 64; | |
106 | |
107 do { | |
108 p[0] = 0; | |
109 p[1] = 0; | |
110 p[2] = 0; | |
111 p[3] = 0; | |
112 p[4] = 0; | |
113 p[5] = 0; | |
114 p[6] = 0; | |
115 p[7] = 0; | |
116 p += 8; | |
117 n -= 8 * 8; | |
118 } while (n); | |
119 } | |
120 | |
513 | 121 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
|
122 { |
513 | 123 return (a & b) + (((a ^ b) & BYTE_VEC(0xfe)) >> 1); |
124 } | |
125 | |
126 static inline uint64_t avg2(uint64_t a, uint64_t b) | |
127 { | |
2967 | 128 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
|
129 } |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
130 |
546 | 131 #if 0 |
132 /* The XY2 routines basically utilize this scheme, but reuse parts in | |
133 each iteration. */ | |
513 | 134 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
|
135 { |
513 | 136 uint64_t r1 = ((l1 & ~BYTE_VEC(0x03)) >> 2) |
897 | 137 + ((l2 & ~BYTE_VEC(0x03)) >> 2) |
138 + ((l3 & ~BYTE_VEC(0x03)) >> 2) | |
139 + ((l4 & ~BYTE_VEC(0x03)) >> 2); | |
513 | 140 uint64_t r2 = (( (l1 & BYTE_VEC(0x03)) |
897 | 141 + (l2 & BYTE_VEC(0x03)) |
142 + (l3 & BYTE_VEC(0x03)) | |
143 + (l4 & BYTE_VEC(0x03)) | |
144 + BYTE_VEC(0x02)) >> 2) & BYTE_VEC(0x03); | |
513 | 145 return r1 + r2; |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
146 } |
546 | 147 #endif |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
148 |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
149 #define OP(LOAD, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
150 do { \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
151 STORE(LOAD(pixels), block); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
152 pixels += line_size; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
153 block += line_size; \ |
513 | 154 } while (--h) |
155 | |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
156 #define OP_X2(LOAD, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
157 do { \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
158 uint64_t pix1, pix2; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
159 \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
160 pix1 = LOAD(pixels); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
161 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
|
162 STORE(AVG2(pix1, pix2), block); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
163 pixels += line_size; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
164 block += line_size; \ |
513 | 165 } while (--h) |
166 | |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
167 #define OP_Y2(LOAD, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
168 do { \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
169 uint64_t pix = LOAD(pixels); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
170 do { \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
171 uint64_t next_pix; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
172 \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
173 pixels += line_size; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
174 next_pix = LOAD(pixels); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
175 STORE(AVG2(pix, next_pix), block); \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
176 block += line_size; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
177 pix = next_pix; \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
178 } while (--h); \ |
513 | 179 } while (0) |
180 | |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
181 #define OP_XY2(LOAD, STORE) \ |
546 | 182 do { \ |
183 uint64_t pix1 = LOAD(pixels); \ | |
184 uint64_t pix2 = pix1 >> 8 | ((uint64_t) pixels[8] << 56); \ | |
185 uint64_t pix_l = (pix1 & BYTE_VEC(0x03)) \ | |
186 + (pix2 & BYTE_VEC(0x03)); \ | |
187 uint64_t pix_h = ((pix1 & ~BYTE_VEC(0x03)) >> 2) \ | |
188 + ((pix2 & ~BYTE_VEC(0x03)) >> 2); \ | |
189 \ | |
190 do { \ | |
191 uint64_t npix1, npix2; \ | |
192 uint64_t npix_l, npix_h; \ | |
193 uint64_t avg; \ | |
194 \ | |
195 pixels += line_size; \ | |
196 npix1 = LOAD(pixels); \ | |
197 npix2 = npix1 >> 8 | ((uint64_t) pixels[8] << 56); \ | |
198 npix_l = (npix1 & BYTE_VEC(0x03)) \ | |
199 + (npix2 & BYTE_VEC(0x03)); \ | |
200 npix_h = ((npix1 & ~BYTE_VEC(0x03)) >> 2) \ | |
201 + ((npix2 & ~BYTE_VEC(0x03)) >> 2); \ | |
202 avg = (((pix_l + npix_l + AVG4_ROUNDER) >> 2) & BYTE_VEC(0x03)) \ | |
203 + pix_h + npix_h; \ | |
204 STORE(avg, block); \ | |
205 \ | |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
206 block += line_size; \ |
546 | 207 pix_l = npix_l; \ |
208 pix_h = npix_h; \ | |
209 } while (--h); \ | |
513 | 210 } while (0) |
211 | |
670
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
212 #define MAKE_OP(OPNAME, SUFF, OPKIND, STORE) \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
213 static void OPNAME ## _pixels ## SUFF ## _axp \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
214 (uint8_t *restrict block, const uint8_t *restrict pixels, \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
215 int line_size, int h) \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
216 { \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
217 if ((size_t) pixels & 0x7) { \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
218 OPKIND(uldq, STORE); \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
219 } else { \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
220 OPKIND(ldq, STORE); \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
221 } \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
222 } \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
223 \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
224 static void OPNAME ## _pixels16 ## SUFF ## _axp \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
225 (uint8_t *restrict block, const uint8_t *restrict pixels, \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
226 int line_size, int h) \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
227 { \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
228 OPNAME ## _pixels ## SUFF ## _axp(block, pixels, line_size, h); \ |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
229 OPNAME ## _pixels ## SUFF ## _axp(block + 8, pixels + 8, line_size, h); \ |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
230 } |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
231 |
548
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
232 #define PIXOP(OPNAME, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
233 MAKE_OP(OPNAME, , OP, STORE) \ |
3f05be811b5a
Remove support for variable BSIZE and INCR, as sub_pixels_* is no
mellum
parents:
546
diff
changeset
|
234 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
|
235 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
|
236 MAKE_OP(OPNAME, _xy2, OP_XY2, STORE) |
513 | 237 |
238 /* Rounding primitives. */ | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
239 #define AVG2 avg2 |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
240 #define AVG4 avg4 |
546 | 241 #define AVG4_ROUNDER BYTE_VEC(0x02) |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
242 #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
|
243 PIXOP(put, STORE); |
513 | 244 |
245 #undef STORE | |
246 #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
|
247 PIXOP(avg, STORE); |
513 | 248 |
249 /* Not rounding primitives. */ | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
250 #undef AVG2 |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
251 #undef AVG4 |
546 | 252 #undef AVG4_ROUNDER |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
253 #undef STORE |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
254 #define AVG2 avg2_no_rnd |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
255 #define AVG4 avg4_no_rnd |
546 | 256 #define AVG4_ROUNDER BYTE_VEC(0x01) |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
257 #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
|
258 PIXOP(put_no_rnd, STORE); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
259 |
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 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
|
262 PIXOP(avg_no_rnd, STORE); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
263 |
11396 | 264 static void put_pixels16_axp_asm(uint8_t *block, const uint8_t *pixels, |
265 int line_size, int h) | |
670
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
266 { |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
267 put_pixels_axp_asm(block, pixels, line_size, h); |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
268 put_pixels_axp_asm(block + 8, pixels + 8, line_size, h); |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
269 } |
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
270 |
1092 | 271 void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx) |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
272 { |
856
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
273 c->put_pixels_tab[0][0] = put_pixels16_axp_asm; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
274 c->put_pixels_tab[0][1] = put_pixels16_x2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
275 c->put_pixels_tab[0][2] = put_pixels16_y2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
276 c->put_pixels_tab[0][3] = put_pixels16_xy2_axp; |
670
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
277 |
856
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
278 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_axp_asm; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
279 c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
280 c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
281 c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_axp; |
670
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
282 |
856
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
283 c->avg_pixels_tab[0][0] = avg_pixels16_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
284 c->avg_pixels_tab[0][1] = avg_pixels16_x2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
285 c->avg_pixels_tab[0][2] = avg_pixels16_y2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
286 c->avg_pixels_tab[0][3] = avg_pixels16_xy2_axp; |
670
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
287 |
856
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
288 c->avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
289 c->avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
290 c->avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
291 c->avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_axp; |
670
340e3ba84119
Synthesize pixels16 functions from pixels functions.
mellum
parents:
663
diff
changeset
|
292 |
856
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
293 c->put_pixels_tab[1][0] = put_pixels_axp_asm; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
294 c->put_pixels_tab[1][1] = put_pixels_x2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
295 c->put_pixels_tab[1][2] = put_pixels_y2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
296 c->put_pixels_tab[1][3] = put_pixels_xy2_axp; |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
297 |
856
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
298 c->put_no_rnd_pixels_tab[1][0] = put_pixels_axp_asm; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
299 c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels_x2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
300 c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels_y2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
301 c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels_xy2_axp; |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
302 |
856
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
303 c->avg_pixels_tab[1][0] = avg_pixels_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
304 c->avg_pixels_tab[1][1] = avg_pixels_x2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
305 c->avg_pixels_tab[1][2] = avg_pixels_y2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
306 c->avg_pixels_tab[1][3] = avg_pixels_xy2_axp; |
513 | 307 |
856
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
308 c->avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
309 c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels_x2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
310 c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels_y2_axp; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
311 c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels_xy2_axp; |
513 | 312 |
856
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
313 c->clear_blocks = clear_blocks_axp; |
518 | 314 |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
315 /* 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
|
316 if (amask(AMASK_MVI) == 0) { |
856
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
317 c->put_pixels_clamped = put_pixels_clamped_mvi_asm; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
318 c->add_pixels_clamped = add_pixels_clamped_mvi_asm; |
586 | 319 |
856
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
320 c->get_pixels = get_pixels_mvi; |
3c6df37177dd
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
744
diff
changeset
|
321 c->diff_pixels = diff_pixels_mvi; |
8625 | 322 c->sad[0] = pix_abs16x16_mvi_asm; |
1708 | 323 c->sad[1] = pix_abs8x8_mvi; |
8625 | 324 c->pix_abs[0][0] = pix_abs16x16_mvi_asm; |
1708 | 325 c->pix_abs[1][0] = pix_abs8x8_mvi; |
326 c->pix_abs[0][1] = pix_abs16x16_x2_mvi; | |
327 c->pix_abs[0][2] = pix_abs16x16_y2_mvi; | |
328 c->pix_abs[0][3] = pix_abs16x16_xy2_mvi; | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
329 } |
897 | 330 |
331 put_pixels_clamped_axp_p = c->put_pixels_clamped; | |
332 add_pixels_clamped_axp_p = c->add_pixels_clamped; | |
2967 | 333 |
8619 | 334 if (!avctx->lowres && |
335 (avctx->idct_algo == FF_IDCT_AUTO || | |
336 avctx->idct_algo == FF_IDCT_SIMPLEALPHA)) { | |
8621 | 337 c->idct_put = ff_simple_idct_put_axp; |
338 c->idct_add = ff_simple_idct_add_axp; | |
339 c->idct = ff_simple_idct_axp; | |
8619 | 340 } |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
341 } |