Mercurial > libavcodec.hg
annotate libpostproc/postprocess_template.c @ 2038:02b59a3c62cd libavcodec
faster c lowpass filter
author | michael |
---|---|
date | Thu, 27 May 2004 16:16:09 +0000 |
parents | 98d8283534bb |
children | f25e485a7850 |
rev | line source |
---|---|
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1 /* |
223 | 2 Copyright (C) 2001-2002 Michael Niedermayer (michaelni@gmx.at) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
4 This program is free software; you can redistribute it and/or modify |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
6 the Free Software Foundation; either version 2 of the License, or |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
7 (at your option) any later version. |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
8 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
12 GNU General Public License for more details. |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
13 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
15 along with this program; if not, write to the Free Software |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
17 */ |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
18 |
1109 | 19 /** |
20 * @file postprocess_template.c | |
21 * mmx/mmx2/3dnow postprocess code. | |
22 */ | |
23 | |
24 | |
169 | 25 #undef PAVGB |
26 #undef PMINUB | |
27 #undef PMAXUB | |
104 | 28 |
29 #ifdef HAVE_MMX2 | |
30 #define PAVGB(a,b) "pavgb " #a ", " #b " \n\t" | |
31 #elif defined (HAVE_3DNOW) | |
32 #define PAVGB(a,b) "pavgusb " #a ", " #b " \n\t" | |
33 #endif | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
34 |
134 | 35 #ifdef HAVE_MMX2 |
36 #define PMINUB(a,b,t) "pminub " #a ", " #b " \n\t" | |
37 #elif defined (HAVE_MMX) | |
38 #define PMINUB(b,a,t) \ | |
39 "movq " #a ", " #t " \n\t"\ | |
40 "psubusb " #b ", " #t " \n\t"\ | |
41 "psubb " #t ", " #a " \n\t" | |
42 #endif | |
43 | |
44 #ifdef HAVE_MMX2 | |
45 #define PMAXUB(a,b) "pmaxub " #a ", " #b " \n\t" | |
46 #elif defined (HAVE_MMX) | |
47 #define PMAXUB(a,b) \ | |
48 "psubusb " #a ", " #b " \n\t"\ | |
49 "paddb " #a ", " #b " \n\t" | |
50 #endif | |
51 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
52 //FIXME? |255-0| = 1 (shouldnt be a problem ...) |
787 | 53 #ifdef HAVE_MMX |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
54 /** |
111 | 55 * Check if the middle 8x8 Block in the given 8x16 block is flat |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
56 */ |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
57 static inline int RENAME(vertClassify)(uint8_t src[], int stride, PPContext *c){ |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
58 int numEq= 0, dcOk; |
111 | 59 src+= stride*4; // src points to begin of the 8x8 Block |
119 | 60 asm volatile( |
1331 | 61 "movq %0, %%mm7 \n\t" |
62 "movq %1, %%mm6 \n\t" | |
63 : : "m" (c->mmxDcOffset[c->nonBQP]), "m" (c->mmxDcThreshold[c->nonBQP]) | |
64 ); | |
65 | |
66 asm volatile( | |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
67 "leal (%2, %3), %%eax \n\t" |
119 | 68 // 0 1 2 3 4 5 6 7 8 9 |
787 | 69 // %1 eax eax+%2 eax+2%2 %1+4%2 ecx ecx+%2 ecx+2%2 %1+8%2 ecx+4%2 |
791 | 70 |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
71 "movq (%2), %%mm0 \n\t" |
119 | 72 "movq (%%eax), %%mm1 \n\t" |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
73 "movq %%mm0, %%mm3 \n\t" |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
74 "movq %%mm0, %%mm4 \n\t" |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
75 PMAXUB(%%mm1, %%mm4) |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
76 PMINUB(%%mm1, %%mm3, %%mm5) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
77 "psubb %%mm1, %%mm0 \n\t" // mm0 = differnece |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
78 "paddb %%mm7, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
79 "pcmpgtb %%mm6, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
80 |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
81 "movq (%%eax,%3), %%mm2 \n\t" |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
82 PMAXUB(%%mm2, %%mm4) |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
83 PMINUB(%%mm2, %%mm3, %%mm5) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
84 "psubb %%mm2, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
85 "paddb %%mm7, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
86 "pcmpgtb %%mm6, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
87 "paddb %%mm1, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
88 |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
89 "movq (%%eax, %3, 2), %%mm1 \n\t" |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
90 PMAXUB(%%mm1, %%mm4) |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
91 PMINUB(%%mm1, %%mm3, %%mm5) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
92 "psubb %%mm1, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
93 "paddb %%mm7, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
94 "pcmpgtb %%mm6, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
95 "paddb %%mm2, %%mm0 \n\t" |
787 | 96 |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
97 "leal (%%eax, %3, 4), %%eax \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
98 |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
99 "movq (%2, %3, 4), %%mm2 \n\t" |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
100 PMAXUB(%%mm2, %%mm4) |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
101 PMINUB(%%mm2, %%mm3, %%mm5) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
102 "psubb %%mm2, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
103 "paddb %%mm7, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
104 "pcmpgtb %%mm6, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
105 "paddb %%mm1, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
106 |
787 | 107 "movq (%%eax), %%mm1 \n\t" |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
108 PMAXUB(%%mm1, %%mm4) |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
109 PMINUB(%%mm1, %%mm3, %%mm5) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
110 "psubb %%mm1, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
111 "paddb %%mm7, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
112 "pcmpgtb %%mm6, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
113 "paddb %%mm2, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
114 |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
115 "movq (%%eax, %3), %%mm2 \n\t" |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
116 PMAXUB(%%mm2, %%mm4) |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
117 PMINUB(%%mm2, %%mm3, %%mm5) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
118 "psubb %%mm2, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
119 "paddb %%mm7, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
120 "pcmpgtb %%mm6, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
121 "paddb %%mm1, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
122 |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
123 "movq (%%eax, %3, 2), %%mm1 \n\t" |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
124 PMAXUB(%%mm1, %%mm4) |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
125 PMINUB(%%mm1, %%mm3, %%mm5) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
126 "psubb %%mm1, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
127 "paddb %%mm7, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
128 "pcmpgtb %%mm6, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
129 "paddb %%mm2, %%mm0 \n\t" |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
130 "psubusb %%mm3, %%mm4 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
131 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
132 " \n\t" |
167 | 133 #ifdef HAVE_MMX2 |
134 "pxor %%mm7, %%mm7 \n\t" | |
135 "psadbw %%mm7, %%mm0 \n\t" | |
136 #else | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
137 "movq %%mm0, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
138 "psrlw $8, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
139 "paddb %%mm1, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
140 "movq %%mm0, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
141 "psrlq $16, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
142 "paddb %%mm1, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
143 "movq %%mm0, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
144 "psrlq $32, %%mm0 \n\t" |
167 | 145 "paddb %%mm1, %%mm0 \n\t" |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
146 #endif |
1331 | 147 "movq %4, %%mm7 \n\t" // QP,..., QP |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
148 "paddusb %%mm7, %%mm7 \n\t" // 2QP ... 2QP |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
149 "psubusb %%mm7, %%mm4 \n\t" // Diff <= 2QP -> 0 |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
150 "packssdw %%mm4, %%mm4 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
151 "movd %%mm0, %0 \n\t" |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
152 "movd %%mm4, %1 \n\t" |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
153 |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
154 : "=r" (numEq), "=r" (dcOk) |
1331 | 155 : "r" (src), "r" (stride), "m" (c->pQPb) |
787 | 156 : "%eax" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
157 ); |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
158 |
167 | 159 numEq= (-numEq) &0xFF; |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
160 if(numEq > c->ppMode.flatnessThreshold){ |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
161 if(dcOk) return 0; |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
162 else return 1; |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
163 }else{ |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
164 return 2; |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
165 } |
787 | 166 } |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
167 #endif |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
168 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
169 /** |
111 | 170 * Do a vertical low pass filter on the 8x16 block (only write to the 8x8 block in the middle) |
107 | 171 * using the 9-Tap Filter (1,1,2,2,4,2,2,1,1)/16 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
172 */ |
2036
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
173 #ifndef HAVE_ALTIVEC |
787 | 174 static inline void RENAME(doVertLowPass)(uint8_t *src, int stride, PPContext *c) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
175 { |
96 | 176 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
111 | 177 src+= stride*3; |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
178 asm volatile( //"movv %0 %1 %2\n\t" |
787 | 179 "movq %2, %%mm0 \n\t" // QP,..., QP |
180 "pxor %%mm4, %%mm4 \n\t" | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
181 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
182 "movq (%0), %%mm6 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
183 "movq (%0, %1), %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
184 "movq %%mm5, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
185 "movq %%mm6, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
186 "psubusb %%mm6, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
187 "psubusb %%mm1, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
188 "por %%mm5, %%mm2 \n\t" // ABS Diff of lines |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
189 "psubusb %%mm0, %%mm2 \n\t" // diff <= QP -> 0 |
787 | 190 "pcmpeqb %%mm4, %%mm2 \n\t" // diff <= QP -> FF |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
191 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
192 "pand %%mm2, %%mm6 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
193 "pandn %%mm1, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
194 "por %%mm2, %%mm6 \n\t"// First Line to Filter |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
195 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
196 "movq (%0, %1, 8), %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
197 "leal (%0, %1, 4), %%eax \n\t" |
787 | 198 "leal (%0, %1, 8), %%ecx \n\t" |
199 "subl %1, %%ecx \n\t" | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
200 "addl %1, %0 \n\t" // %0 points to line 1 not 0 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
201 "movq (%0, %1, 8), %%mm7 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
202 "movq %%mm5, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
203 "movq %%mm7, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
204 "psubusb %%mm7, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
205 "psubusb %%mm1, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
206 "por %%mm5, %%mm2 \n\t" // ABS Diff of lines |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
207 "psubusb %%mm0, %%mm2 \n\t" // diff <= QP -> 0 |
787 | 208 "pcmpeqb %%mm4, %%mm2 \n\t" // diff <= QP -> FF |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
209 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
210 "pand %%mm2, %%mm7 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
211 "pandn %%mm1, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
212 "por %%mm2, %%mm7 \n\t" // First Line to Filter |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
213 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
214 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
215 // 1 2 3 4 5 6 7 8 |
787 | 216 // %0 %0+%1 %0+2%1 eax %0+4%1 eax+2%1 ecx eax+4%1 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
217 // 6 4 2 2 1 1 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
218 // 6 4 4 2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
219 // 6 8 2 |
111 | 220 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
221 "movq (%0, %1), %%mm0 \n\t" // 1 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
222 "movq %%mm0, %%mm1 \n\t" // 1 |
96 | 223 PAVGB(%%mm6, %%mm0) //1 1 /2 |
224 PAVGB(%%mm6, %%mm0) //3 1 /4 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
225 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
226 "movq (%0, %1, 4), %%mm2 \n\t" // 1 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
227 "movq %%mm2, %%mm5 \n\t" // 1 |
96 | 228 PAVGB((%%eax), %%mm2) // 11 /2 |
229 PAVGB((%0, %1, 2), %%mm2) // 211 /4 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
230 "movq %%mm2, %%mm3 \n\t" // 211 /4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
231 "movq (%0), %%mm4 \n\t" // 1 |
96 | 232 PAVGB(%%mm4, %%mm3) // 4 211 /8 |
233 PAVGB(%%mm0, %%mm3) //642211 /16 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
234 "movq %%mm3, (%0) \n\t" // X |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
235 // mm1=2 mm2=3(211) mm4=1 mm5=5 mm6=0 mm7=9 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
236 "movq %%mm1, %%mm0 \n\t" // 1 |
96 | 237 PAVGB(%%mm6, %%mm0) //1 1 /2 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
238 "movq %%mm4, %%mm3 \n\t" // 1 |
96 | 239 PAVGB((%0,%1,2), %%mm3) // 1 1 /2 |
240 PAVGB((%%eax,%1,2), %%mm5) // 11 /2 | |
241 PAVGB((%%eax), %%mm5) // 211 /4 | |
242 PAVGB(%%mm5, %%mm3) // 2 2211 /8 | |
243 PAVGB(%%mm0, %%mm3) //4242211 /16 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
244 "movq %%mm3, (%0,%1) \n\t" // X |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
245 // mm1=2 mm2=3(211) mm4=1 mm5=4(211) mm6=0 mm7=9 |
96 | 246 PAVGB(%%mm4, %%mm6) //11 /2 |
787 | 247 "movq (%%ecx), %%mm0 \n\t" // 1 |
96 | 248 PAVGB((%%eax, %1, 2), %%mm0) // 11/2 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
249 "movq %%mm0, %%mm3 \n\t" // 11/2 |
96 | 250 PAVGB(%%mm1, %%mm0) // 2 11/4 |
251 PAVGB(%%mm6, %%mm0) //222 11/8 | |
252 PAVGB(%%mm2, %%mm0) //22242211/16 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
253 "movq (%0, %1, 2), %%mm2 \n\t" // 1 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
254 "movq %%mm0, (%0, %1, 2) \n\t" // X |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
255 // mm1=2 mm2=3 mm3=6(11) mm4=1 mm5=4(211) mm6=0(11) mm7=9 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
256 "movq (%%eax, %1, 4), %%mm0 \n\t" // 1 |
787 | 257 PAVGB((%%ecx), %%mm0) // 11 /2 |
96 | 258 PAVGB(%%mm0, %%mm6) //11 11 /4 |
259 PAVGB(%%mm1, %%mm4) // 11 /2 | |
260 PAVGB(%%mm2, %%mm1) // 11 /2 | |
261 PAVGB(%%mm1, %%mm6) //1122 11 /8 | |
262 PAVGB(%%mm5, %%mm6) //112242211 /16 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
263 "movq (%%eax), %%mm5 \n\t" // 1 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
264 "movq %%mm6, (%%eax) \n\t" // X |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
265 // mm0=7(11) mm1=2(11) mm2=3 mm3=6(11) mm4=1(11) mm5=4 mm7=9 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
266 "movq (%%eax, %1, 4), %%mm6 \n\t" // 1 |
96 | 267 PAVGB(%%mm7, %%mm6) // 11 /2 |
268 PAVGB(%%mm4, %%mm6) // 11 11 /4 | |
269 PAVGB(%%mm3, %%mm6) // 11 2211 /8 | |
270 PAVGB(%%mm5, %%mm2) // 11 /2 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
271 "movq (%0, %1, 4), %%mm4 \n\t" // 1 |
96 | 272 PAVGB(%%mm4, %%mm2) // 112 /4 |
273 PAVGB(%%mm2, %%mm6) // 112242211 /16 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
274 "movq %%mm6, (%0, %1, 4) \n\t" // X |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
275 // mm0=7(11) mm1=2(11) mm2=3(112) mm3=6(11) mm4=5 mm5=4 mm7=9 |
96 | 276 PAVGB(%%mm7, %%mm1) // 11 2 /4 |
277 PAVGB(%%mm4, %%mm5) // 11 /2 | |
278 PAVGB(%%mm5, %%mm0) // 11 11 /4 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
279 "movq (%%eax, %1, 2), %%mm6 \n\t" // 1 |
96 | 280 PAVGB(%%mm6, %%mm1) // 11 4 2 /8 |
281 PAVGB(%%mm0, %%mm1) // 11224222 /16 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
282 "movq %%mm1, (%%eax, %1, 2) \n\t" // X |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
283 // mm2=3(112) mm3=6(11) mm4=5 mm5=4(11) mm6=6 mm7=9 |
787 | 284 PAVGB((%%ecx), %%mm2) // 112 4 /8 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
285 "movq (%%eax, %1, 4), %%mm0 \n\t" // 1 |
96 | 286 PAVGB(%%mm0, %%mm6) // 1 1 /2 |
287 PAVGB(%%mm7, %%mm6) // 1 12 /4 | |
288 PAVGB(%%mm2, %%mm6) // 1122424 /4 | |
787 | 289 "movq %%mm6, (%%ecx) \n\t" // X |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
290 // mm0=8 mm3=6(11) mm4=5 mm5=4(11) mm7=9 |
96 | 291 PAVGB(%%mm7, %%mm5) // 11 2 /4 |
292 PAVGB(%%mm7, %%mm5) // 11 6 /8 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
293 |
96 | 294 PAVGB(%%mm3, %%mm0) // 112 /4 |
295 PAVGB(%%mm0, %%mm5) // 112246 /16 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
296 "movq %%mm5, (%%eax, %1, 4) \n\t" // X |
140 | 297 "subl %1, %0 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
298 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
299 : |
787 | 300 : "r" (src), "r" (stride), "m" (c->pQPb) |
301 : "%eax", "%ecx" | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
302 ); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
303 #else |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
304 const int l1= stride; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
305 const int l2= stride + l1; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
306 const int l3= stride + l2; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
307 const int l4= stride + l3; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
308 const int l5= stride + l4; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
309 const int l6= stride + l5; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
310 const int l7= stride + l6; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
311 const int l8= stride + l7; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
312 const int l9= stride + l8; |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
313 int x; |
111 | 314 src+= stride*3; |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
315 for(x=0; x<BLOCK_SIZE; x++) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
316 { |
787 | 317 const int first= ABS(src[0] - src[l1]) < c->QP ? src[0] : src[l1]; |
318 const int last= ABS(src[l8] - src[l9]) < c->QP ? src[l9] : src[l8]; | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
319 |
2038 | 320 int sums[10]; |
321 sums[0] = 4*first + src[l1] + src[l2] + src[l3] + 4; | |
322 sums[1] = sums[0] - first + src[l4]; | |
323 sums[2] = sums[1] - first + src[l5]; | |
324 sums[3] = sums[2] - first + src[l6]; | |
325 sums[4] = sums[3] - first + src[l7]; | |
326 sums[5] = sums[4] - src[l1] + src[l8]; | |
327 sums[6] = sums[5] - src[l2] + last; | |
328 sums[7] = sums[6] - src[l3] + last; | |
329 sums[8] = sums[7] - src[l4] + last; | |
330 sums[9] = sums[8] - src[l5] + last; | |
331 | |
332 src[l1]= (sums[0] + sums[2] + 2*src[l1])>>4; | |
333 src[l2]= (sums[1] + sums[3] + 2*src[l2])>>4; | |
334 src[l3]= (sums[2] + sums[4] + 2*src[l3])>>4; | |
335 src[l4]= (sums[3] + sums[5] + 2*src[l4])>>4; | |
336 src[l5]= (sums[4] + sums[6] + 2*src[l5])>>4; | |
337 src[l6]= (sums[5] + sums[7] + 2*src[l6])>>4; | |
338 src[l7]= (sums[6] + sums[8] + 2*src[l7])>>4; | |
339 src[l8]= (sums[7] + sums[9] + 2*src[l8])>>4; | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
340 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
341 src++; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
342 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
343 #endif |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
344 } |
2036
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
345 #endif //HAVE_ALTIVEC |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
346 |
787 | 347 #if 0 |
96 | 348 /** |
349 * Experimental implementation of the filter (Algorithm 1) described in a paper from Ramkishor & Karandikar | |
350 * values are correctly clipped (MMX2) | |
351 * values are wraparound (C) | |
352 * conclusion: its fast, but introduces ugly horizontal patterns if there is a continious gradient | |
353 0 8 16 24 | |
354 x = 8 | |
355 x/2 = 4 | |
356 x/8 = 1 | |
357 1 12 12 23 | |
358 */ | |
169 | 359 static inline void RENAME(vertRK1Filter)(uint8_t *src, int stride, int QP) |
96 | 360 { |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
361 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
111 | 362 src+= stride*3; |
96 | 363 // FIXME rounding |
364 asm volatile( | |
365 "pxor %%mm7, %%mm7 \n\t" // 0 | |
210 | 366 "movq "MANGLE(b80)", %%mm6 \n\t" // MIN_SIGNED_BYTE |
96 | 367 "leal (%0, %1), %%eax \n\t" |
787 | 368 "leal (%%eax, %1, 4), %%ecx \n\t" |
96 | 369 // 0 1 2 3 4 5 6 7 8 9 |
787 | 370 // %0 eax eax+%1 eax+2%1 %0+4%1 ecx ecx+%1 ecx+2%1 %0+8%1 ecx+4%1 |
210 | 371 "movq "MANGLE(pQPb)", %%mm0 \n\t" // QP,..., QP |
96 | 372 "movq %%mm0, %%mm1 \n\t" // QP,..., QP |
210 | 373 "paddusb "MANGLE(b02)", %%mm0 \n\t" |
96 | 374 "psrlw $2, %%mm0 \n\t" |
210 | 375 "pand "MANGLE(b3F)", %%mm0 \n\t" // QP/4,..., QP/4 |
96 | 376 "paddusb %%mm1, %%mm0 \n\t" // QP*1.25 ... |
377 "movq (%0, %1, 4), %%mm2 \n\t" // line 4 | |
787 | 378 "movq (%%ecx), %%mm3 \n\t" // line 5 |
96 | 379 "movq %%mm2, %%mm4 \n\t" // line 4 |
380 "pcmpeqb %%mm5, %%mm5 \n\t" // -1 | |
381 "pxor %%mm2, %%mm5 \n\t" // -line 4 - 1 | |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
382 PAVGB(%%mm3, %%mm5) |
96 | 383 "paddb %%mm6, %%mm5 \n\t" // (l5-l4)/2 |
384 "psubusb %%mm3, %%mm4 \n\t" | |
385 "psubusb %%mm2, %%mm3 \n\t" | |
386 "por %%mm3, %%mm4 \n\t" // |l4 - l5| | |
387 "psubusb %%mm0, %%mm4 \n\t" | |
388 "pcmpeqb %%mm7, %%mm4 \n\t" | |
389 "pand %%mm4, %%mm5 \n\t" // d/2 | |
390 | |
391 // "paddb %%mm6, %%mm2 \n\t" // line 4 + 0x80 | |
392 "paddb %%mm5, %%mm2 \n\t" | |
393 // "psubb %%mm6, %%mm2 \n\t" | |
394 "movq %%mm2, (%0,%1, 4) \n\t" | |
395 | |
787 | 396 "movq (%%ecx), %%mm2 \n\t" |
96 | 397 // "paddb %%mm6, %%mm2 \n\t" // line 5 + 0x80 |
398 "psubb %%mm5, %%mm2 \n\t" | |
399 // "psubb %%mm6, %%mm2 \n\t" | |
787 | 400 "movq %%mm2, (%%ecx) \n\t" |
96 | 401 |
402 "paddb %%mm6, %%mm5 \n\t" | |
403 "psrlw $2, %%mm5 \n\t" | |
210 | 404 "pand "MANGLE(b3F)", %%mm5 \n\t" |
405 "psubb "MANGLE(b20)", %%mm5 \n\t" // (l5-l4)/8 | |
96 | 406 |
407 "movq (%%eax, %1, 2), %%mm2 \n\t" | |
408 "paddb %%mm6, %%mm2 \n\t" // line 3 + 0x80 | |
409 "paddsb %%mm5, %%mm2 \n\t" | |
410 "psubb %%mm6, %%mm2 \n\t" | |
411 "movq %%mm2, (%%eax, %1, 2) \n\t" | |
412 | |
787 | 413 "movq (%%ecx, %1), %%mm2 \n\t" |
96 | 414 "paddb %%mm6, %%mm2 \n\t" // line 6 + 0x80 |
415 "psubsb %%mm5, %%mm2 \n\t" | |
416 "psubb %%mm6, %%mm2 \n\t" | |
787 | 417 "movq %%mm2, (%%ecx, %1) \n\t" |
96 | 418 |
419 : | |
420 : "r" (src), "r" (stride) | |
787 | 421 : "%eax", "%ecx" |
96 | 422 ); |
423 #else | |
424 const int l1= stride; | |
425 const int l2= stride + l1; | |
426 const int l3= stride + l2; | |
427 const int l4= stride + l3; | |
428 const int l5= stride + l4; | |
429 const int l6= stride + l5; | |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
430 // const int l7= stride + l6; |
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
431 // const int l8= stride + l7; |
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
432 // const int l9= stride + l8; |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
433 int x; |
141 | 434 const int QP15= QP + (QP>>2); |
111 | 435 src+= stride*3; |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
436 for(x=0; x<BLOCK_SIZE; x++) |
96 | 437 { |
141 | 438 const int v = (src[x+l5] - src[x+l4]); |
439 if(ABS(v) < QP15) | |
96 | 440 { |
141 | 441 src[x+l3] +=v>>3; |
442 src[x+l4] +=v>>1; | |
443 src[x+l5] -=v>>1; | |
444 src[x+l6] -=v>>3; | |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
445 |
96 | 446 } |
447 } | |
448 | |
449 #endif | |
450 } | |
787 | 451 #endif |
96 | 452 |
453 /** | |
454 * Experimental Filter 1 | |
99 | 455 * will not damage linear gradients |
456 * Flat blocks should look like they where passed through the (1,1,2,2,4,2,2,1,1) 9-Tap filter | |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
457 * can only smooth blocks at the expected locations (it cant smooth them if they did move) |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
458 * MMX2 version does correct clipping C version doesnt |
96 | 459 */ |
787 | 460 static inline void RENAME(vertX1Filter)(uint8_t *src, int stride, PPContext *co) |
96 | 461 { |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
462 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
111 | 463 src+= stride*3; |
464 | |
96 | 465 asm volatile( |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
466 "pxor %%mm7, %%mm7 \n\t" // 0 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
467 "leal (%0, %1), %%eax \n\t" |
787 | 468 "leal (%%eax, %1, 4), %%ecx \n\t" |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
469 // 0 1 2 3 4 5 6 7 8 9 |
787 | 470 // %0 eax eax+%1 eax+2%1 %0+4%1 ecx ecx+%1 ecx+2%1 %0+8%1 ecx+4%1 |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
471 "movq (%%eax, %1, 2), %%mm0 \n\t" // line 3 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
472 "movq (%0, %1, 4), %%mm1 \n\t" // line 4 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
473 "movq %%mm1, %%mm2 \n\t" // line 4 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
474 "psubusb %%mm0, %%mm1 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
475 "psubusb %%mm2, %%mm0 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
476 "por %%mm1, %%mm0 \n\t" // |l2 - l3| |
787 | 477 "movq (%%ecx), %%mm3 \n\t" // line 5 |
478 "movq (%%ecx, %1), %%mm4 \n\t" // line 6 | |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
479 "movq %%mm3, %%mm5 \n\t" // line 5 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
480 "psubusb %%mm4, %%mm3 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
481 "psubusb %%mm5, %%mm4 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
482 "por %%mm4, %%mm3 \n\t" // |l5 - l6| |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
483 PAVGB(%%mm3, %%mm0) // (|l2 - l3| + |l5 - l6|)/2 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
484 "movq %%mm2, %%mm1 \n\t" // line 4 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
485 "psubusb %%mm5, %%mm2 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
486 "movq %%mm2, %%mm4 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
487 "pcmpeqb %%mm7, %%mm2 \n\t" // (l4 - l5) <= 0 ? -1 : 0 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
488 "psubusb %%mm1, %%mm5 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
489 "por %%mm5, %%mm4 \n\t" // |l4 - l5| |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
490 "psubusb %%mm0, %%mm4 \n\t" //d = MAX(0, |l4-l5| - (|l2-l3| + |l5-l6|)/2) |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
491 "movq %%mm4, %%mm3 \n\t" // d |
787 | 492 "movq %2, %%mm0 \n\t" |
334 | 493 "paddusb %%mm0, %%mm0 \n\t" |
494 "psubusb %%mm0, %%mm4 \n\t" | |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
495 "pcmpeqb %%mm7, %%mm4 \n\t" // d <= QP ? -1 : 0 |
210 | 496 "psubusb "MANGLE(b01)", %%mm3 \n\t" |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
497 "pand %%mm4, %%mm3 \n\t" // d <= QP ? d : 0 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
498 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
499 PAVGB(%%mm7, %%mm3) // d/2 |
99 | 500 "movq %%mm3, %%mm1 \n\t" // d/2 |
501 PAVGB(%%mm7, %%mm3) // d/4 | |
502 PAVGB(%%mm1, %%mm3) // 3*d/8 | |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
503 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
504 "movq (%0, %1, 4), %%mm0 \n\t" // line 4 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
505 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l4-1 : l4 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
506 "psubusb %%mm3, %%mm0 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
507 "pxor %%mm2, %%mm0 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
508 "movq %%mm0, (%0, %1, 4) \n\t" // line 4 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
509 |
787 | 510 "movq (%%ecx), %%mm0 \n\t" // line 5 |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
511 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l5-1 : l5 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
512 "paddusb %%mm3, %%mm0 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
513 "pxor %%mm2, %%mm0 \n\t" |
787 | 514 "movq %%mm0, (%%ecx) \n\t" // line 5 |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
515 |
99 | 516 PAVGB(%%mm7, %%mm1) // d/4 |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
517 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
518 "movq (%%eax, %1, 2), %%mm0 \n\t" // line 3 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
519 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l4-1 : l4 |
99 | 520 "psubusb %%mm1, %%mm0 \n\t" |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
521 "pxor %%mm2, %%mm0 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
522 "movq %%mm0, (%%eax, %1, 2) \n\t" // line 3 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
523 |
787 | 524 "movq (%%ecx, %1), %%mm0 \n\t" // line 6 |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
525 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l5-1 : l5 |
99 | 526 "paddusb %%mm1, %%mm0 \n\t" |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
527 "pxor %%mm2, %%mm0 \n\t" |
787 | 528 "movq %%mm0, (%%ecx, %1) \n\t" // line 6 |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
529 |
99 | 530 PAVGB(%%mm7, %%mm1) // d/8 |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
531 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
532 "movq (%%eax, %1), %%mm0 \n\t" // line 2 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
533 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l2-1 : l2 |
99 | 534 "psubusb %%mm1, %%mm0 \n\t" |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
535 "pxor %%mm2, %%mm0 \n\t" |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
536 "movq %%mm0, (%%eax, %1) \n\t" // line 2 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
537 |
787 | 538 "movq (%%ecx, %1, 2), %%mm0 \n\t" // line 7 |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
539 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l7-1 : l7 |
99 | 540 "paddusb %%mm1, %%mm0 \n\t" |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
541 "pxor %%mm2, %%mm0 \n\t" |
787 | 542 "movq %%mm0, (%%ecx, %1, 2) \n\t" // line 7 |
96 | 543 |
544 : | |
787 | 545 : "r" (src), "r" (stride), "m" (co->pQPb) |
546 : "%eax", "%ecx" | |
96 | 547 ); |
548 #else | |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
549 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
550 const int l1= stride; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
551 const int l2= stride + l1; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
552 const int l3= stride + l2; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
553 const int l4= stride + l3; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
554 const int l5= stride + l4; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
555 const int l6= stride + l5; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
556 const int l7= stride + l6; |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
557 // const int l8= stride + l7; |
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
558 // const int l9= stride + l8; |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
559 int x; |
111 | 560 |
561 src+= stride*3; | |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
562 for(x=0; x<BLOCK_SIZE; x++) |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
563 { |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
564 int a= src[l3] - src[l4]; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
565 int b= src[l4] - src[l5]; |
99 | 566 int c= src[l5] - src[l6]; |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
567 |
141 | 568 int d= ABS(b) - ((ABS(a) + ABS(c))>>1); |
569 d= MAX(d, 0); | |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
570 |
787 | 571 if(d < co->QP*2) |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
572 { |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
573 int v = d * SIGN(-b); |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
574 |
141 | 575 src[l2] +=v>>3; |
576 src[l3] +=v>>2; | |
577 src[l4] +=(3*v)>>3; | |
578 src[l5] -=(3*v)>>3; | |
579 src[l6] -=v>>2; | |
580 src[l7] -=v>>3; | |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
581 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
582 } |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
583 src++; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
584 } |
96 | 585 #endif |
586 } | |
587 | |
2036
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
588 #ifndef HAVE_ALTIVEC |
787 | 589 static inline void RENAME(doVertDefFilter)(uint8_t src[], int stride, PPContext *c) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
590 { |
163 | 591 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
592 /* | |
593 uint8_t tmp[16]; | |
594 const int l1= stride; | |
595 const int l2= stride + l1; | |
596 const int l3= stride + l2; | |
597 const int l4= (int)tmp - (int)src - stride*3; | |
598 const int l5= (int)tmp - (int)src - stride*3 + 8; | |
599 const int l6= stride*3 + l3; | |
600 const int l7= stride + l6; | |
601 const int l8= stride + l7; | |
602 | |
603 memcpy(tmp, src+stride*7, 8); | |
604 memcpy(tmp+8, src+stride*8, 8); | |
605 */ | |
111 | 606 src+= stride*4; |
163 | 607 asm volatile( |
608 | |
609 #if 0 //sligtly more accurate and slightly slower | |
610 "pxor %%mm7, %%mm7 \n\t" // 0 | |
611 "leal (%0, %1), %%eax \n\t" | |
787 | 612 "leal (%%eax, %1, 4), %%ecx \n\t" |
163 | 613 // 0 1 2 3 4 5 6 7 |
787 | 614 // %0 %0+%1 %0+2%1 eax+2%1 %0+4%1 eax+4%1 ecx+%1 ecx+2%1 |
615 // %0 eax eax+%1 eax+2%1 %0+4%1 ecx ecx+%1 ecx+2%1 | |
163 | 616 |
617 | |
618 "movq (%0, %1, 2), %%mm0 \n\t" // l2 | |
619 "movq (%0), %%mm1 \n\t" // l0 | |
620 "movq %%mm0, %%mm2 \n\t" // l2 | |
621 PAVGB(%%mm7, %%mm0) // ~l2/2 | |
622 PAVGB(%%mm1, %%mm0) // ~(l2 + 2l0)/4 | |
623 PAVGB(%%mm2, %%mm0) // ~(5l2 + 2l0)/8 | |
624 | |
625 "movq (%%eax), %%mm1 \n\t" // l1 | |
626 "movq (%%eax, %1, 2), %%mm3 \n\t" // l3 | |
627 "movq %%mm1, %%mm4 \n\t" // l1 | |
628 PAVGB(%%mm7, %%mm1) // ~l1/2 | |
629 PAVGB(%%mm3, %%mm1) // ~(l1 + 2l3)/4 | |
630 PAVGB(%%mm4, %%mm1) // ~(5l1 + 2l3)/8 | |
631 | |
632 "movq %%mm0, %%mm4 \n\t" // ~(5l2 + 2l0)/8 | |
633 "psubusb %%mm1, %%mm0 \n\t" | |
634 "psubusb %%mm4, %%mm1 \n\t" | |
635 "por %%mm0, %%mm1 \n\t" // ~|2l0 - 5l1 + 5l2 - 2l3|/8 | |
636 // mm1= |lenergy|, mm2= l2, mm3= l3, mm7=0 | |
637 | |
638 "movq (%0, %1, 4), %%mm0 \n\t" // l4 | |
639 "movq %%mm0, %%mm4 \n\t" // l4 | |
640 PAVGB(%%mm7, %%mm0) // ~l4/2 | |
641 PAVGB(%%mm2, %%mm0) // ~(l4 + 2l2)/4 | |
642 PAVGB(%%mm4, %%mm0) // ~(5l4 + 2l2)/8 | |
643 | |
787 | 644 "movq (%%ecx), %%mm2 \n\t" // l5 |
163 | 645 "movq %%mm3, %%mm5 \n\t" // l3 |
646 PAVGB(%%mm7, %%mm3) // ~l3/2 | |
647 PAVGB(%%mm2, %%mm3) // ~(l3 + 2l5)/4 | |
648 PAVGB(%%mm5, %%mm3) // ~(5l3 + 2l5)/8 | |
649 | |
650 "movq %%mm0, %%mm6 \n\t" // ~(5l4 + 2l2)/8 | |
651 "psubusb %%mm3, %%mm0 \n\t" | |
652 "psubusb %%mm6, %%mm3 \n\t" | |
653 "por %%mm0, %%mm3 \n\t" // ~|2l2 - 5l3 + 5l4 - 2l5|/8 | |
654 "pcmpeqb %%mm7, %%mm0 \n\t" // SIGN(2l2 - 5l3 + 5l4 - 2l5) | |
655 // mm0= SIGN(menergy), mm1= |lenergy|, mm2= l5, mm3= |menergy|, mm4=l4, mm5= l3, mm7=0 | |
656 | |
787 | 657 "movq (%%ecx, %1), %%mm6 \n\t" // l6 |
163 | 658 "movq %%mm6, %%mm5 \n\t" // l6 |
659 PAVGB(%%mm7, %%mm6) // ~l6/2 | |
660 PAVGB(%%mm4, %%mm6) // ~(l6 + 2l4)/4 | |
661 PAVGB(%%mm5, %%mm6) // ~(5l6 + 2l4)/8 | |
662 | |
787 | 663 "movq (%%ecx, %1, 2), %%mm5 \n\t" // l7 |
163 | 664 "movq %%mm2, %%mm4 \n\t" // l5 |
665 PAVGB(%%mm7, %%mm2) // ~l5/2 | |
666 PAVGB(%%mm5, %%mm2) // ~(l5 + 2l7)/4 | |
667 PAVGB(%%mm4, %%mm2) // ~(5l5 + 2l7)/8 | |
668 | |
669 "movq %%mm6, %%mm4 \n\t" // ~(5l6 + 2l4)/8 | |
670 "psubusb %%mm2, %%mm6 \n\t" | |
671 "psubusb %%mm4, %%mm2 \n\t" | |
672 "por %%mm6, %%mm2 \n\t" // ~|2l4 - 5l5 + 5l6 - 2l7|/8 | |
673 // mm0= SIGN(menergy), mm1= |lenergy|/8, mm2= |renergy|/8, mm3= |menergy|/8, mm7=0 | |
674 | |
675 | |
676 PMINUB(%%mm2, %%mm1, %%mm4) // MIN(|lenergy|,|renergy|)/8 | |
787 | 677 "movq %2, %%mm4 \n\t" // QP //FIXME QP+1 ? |
210 | 678 "paddusb "MANGLE(b01)", %%mm4 \n\t" |
163 | 679 "pcmpgtb %%mm3, %%mm4 \n\t" // |menergy|/8 < QP |
680 "psubusb %%mm1, %%mm3 \n\t" // d=|menergy|/8-MIN(|lenergy|,|renergy|)/8 | |
681 "pand %%mm4, %%mm3 \n\t" | |
682 | |
683 "movq %%mm3, %%mm1 \n\t" | |
210 | 684 // "psubusb "MANGLE(b01)", %%mm3 \n\t" |
163 | 685 PAVGB(%%mm7, %%mm3) |
686 PAVGB(%%mm7, %%mm3) | |
687 "paddusb %%mm1, %%mm3 \n\t" | |
210 | 688 // "paddusb "MANGLE(b01)", %%mm3 \n\t" |
163 | 689 |
690 "movq (%%eax, %1, 2), %%mm6 \n\t" //l3 | |
691 "movq (%0, %1, 4), %%mm5 \n\t" //l4 | |
692 "movq (%0, %1, 4), %%mm4 \n\t" //l4 | |
693 "psubusb %%mm6, %%mm5 \n\t" | |
694 "psubusb %%mm4, %%mm6 \n\t" | |
695 "por %%mm6, %%mm5 \n\t" // |l3-l4| | |
696 "pcmpeqb %%mm7, %%mm6 \n\t" // SIGN(l3-l4) | |
697 "pxor %%mm6, %%mm0 \n\t" | |
698 "pand %%mm0, %%mm3 \n\t" | |
699 PMINUB(%%mm5, %%mm3, %%mm0) | |
700 | |
210 | 701 "psubusb "MANGLE(b01)", %%mm3 \n\t" |
163 | 702 PAVGB(%%mm7, %%mm3) |
703 | |
704 "movq (%%eax, %1, 2), %%mm0 \n\t" | |
705 "movq (%0, %1, 4), %%mm2 \n\t" | |
706 "pxor %%mm6, %%mm0 \n\t" | |
707 "pxor %%mm6, %%mm2 \n\t" | |
708 "psubb %%mm3, %%mm0 \n\t" | |
709 "paddb %%mm3, %%mm2 \n\t" | |
710 "pxor %%mm6, %%mm0 \n\t" | |
711 "pxor %%mm6, %%mm2 \n\t" | |
712 "movq %%mm0, (%%eax, %1, 2) \n\t" | |
713 "movq %%mm2, (%0, %1, 4) \n\t" | |
714 #endif | |
715 | |
716 "leal (%0, %1), %%eax \n\t" | |
717 "pcmpeqb %%mm6, %%mm6 \n\t" // -1 | |
718 // 0 1 2 3 4 5 6 7 | |
787 | 719 // %0 %0+%1 %0+2%1 eax+2%1 %0+4%1 eax+4%1 ecx+%1 ecx+2%1 |
720 // %0 eax eax+%1 eax+2%1 %0+4%1 ecx ecx+%1 ecx+2%1 | |
163 | 721 |
722 | |
723 "movq (%%eax, %1, 2), %%mm1 \n\t" // l3 | |
724 "movq (%0, %1, 4), %%mm0 \n\t" // l4 | |
725 "pxor %%mm6, %%mm1 \n\t" // -l3-1 | |
726 PAVGB(%%mm1, %%mm0) // -q+128 = (l4-l3+256)/2 | |
727 // mm1=-l3-1, mm0=128-q | |
728 | |
729 "movq (%%eax, %1, 4), %%mm2 \n\t" // l5 | |
730 "movq (%%eax, %1), %%mm3 \n\t" // l2 | |
731 "pxor %%mm6, %%mm2 \n\t" // -l5-1 | |
732 "movq %%mm2, %%mm5 \n\t" // -l5-1 | |
210 | 733 "movq "MANGLE(b80)", %%mm4 \n\t" // 128 |
787 | 734 "leal (%%eax, %1, 4), %%ecx \n\t" |
163 | 735 PAVGB(%%mm3, %%mm2) // (l2-l5+256)/2 |
736 PAVGB(%%mm0, %%mm4) // ~(l4-l3)/4 + 128 | |
737 PAVGB(%%mm2, %%mm4) // ~(l2-l5)/4 +(l4-l3)/8 + 128 | |
738 PAVGB(%%mm0, %%mm4) // ~(l2-l5)/8 +5(l4-l3)/16 + 128 | |
739 // mm1=-l3-1, mm0=128-q, mm3=l2, mm4=menergy/16 + 128, mm5= -l5-1 | |
740 | |
741 "movq (%%eax), %%mm2 \n\t" // l1 | |
742 "pxor %%mm6, %%mm2 \n\t" // -l1-1 | |
743 PAVGB(%%mm3, %%mm2) // (l2-l1+256)/2 | |
744 PAVGB((%0), %%mm1) // (l0-l3+256)/2 | |
210 | 745 "movq "MANGLE(b80)", %%mm3 \n\t" // 128 |
163 | 746 PAVGB(%%mm2, %%mm3) // ~(l2-l1)/4 + 128 |
747 PAVGB(%%mm1, %%mm3) // ~(l0-l3)/4 +(l2-l1)/8 + 128 | |
748 PAVGB(%%mm2, %%mm3) // ~(l0-l3)/8 +5(l2-l1)/16 + 128 | |
749 // mm0=128-q, mm3=lenergy/16 + 128, mm4= menergy/16 + 128, mm5= -l5-1 | |
750 | |
787 | 751 PAVGB((%%ecx, %1), %%mm5) // (l6-l5+256)/2 |
752 "movq (%%ecx, %1, 2), %%mm1 \n\t" // l7 | |
163 | 753 "pxor %%mm6, %%mm1 \n\t" // -l7-1 |
754 PAVGB((%0, %1, 4), %%mm1) // (l4-l7+256)/2 | |
210 | 755 "movq "MANGLE(b80)", %%mm2 \n\t" // 128 |
163 | 756 PAVGB(%%mm5, %%mm2) // ~(l6-l5)/4 + 128 |
757 PAVGB(%%mm1, %%mm2) // ~(l4-l7)/4 +(l6-l5)/8 + 128 | |
758 PAVGB(%%mm5, %%mm2) // ~(l4-l7)/8 +5(l6-l5)/16 + 128 | |
759 // mm0=128-q, mm2=renergy/16 + 128, mm3=lenergy/16 + 128, mm4= menergy/16 + 128 | |
760 | |
210 | 761 "movq "MANGLE(b00)", %%mm1 \n\t" // 0 |
762 "movq "MANGLE(b00)", %%mm5 \n\t" // 0 | |
163 | 763 "psubb %%mm2, %%mm1 \n\t" // 128 - renergy/16 |
764 "psubb %%mm3, %%mm5 \n\t" // 128 - lenergy/16 | |
765 PMAXUB(%%mm1, %%mm2) // 128 + |renergy/16| | |
766 PMAXUB(%%mm5, %%mm3) // 128 + |lenergy/16| | |
767 PMINUB(%%mm2, %%mm3, %%mm1) // 128 + MIN(|lenergy|,|renergy|)/16 | |
768 | |
769 // mm0=128-q, mm3=128 + MIN(|lenergy|,|renergy|)/16, mm4= menergy/16 + 128 | |
770 | |
210 | 771 "movq "MANGLE(b00)", %%mm7 \n\t" // 0 |
787 | 772 "movq %2, %%mm2 \n\t" // QP |
163 | 773 PAVGB(%%mm6, %%mm2) // 128 + QP/2 |
774 "psubb %%mm6, %%mm2 \n\t" | |
775 | |
776 "movq %%mm4, %%mm1 \n\t" | |
777 "pcmpgtb %%mm7, %%mm1 \n\t" // SIGN(menergy) | |
778 "pxor %%mm1, %%mm4 \n\t" | |
779 "psubb %%mm1, %%mm4 \n\t" // 128 + |menergy|/16 | |
780 "pcmpgtb %%mm4, %%mm2 \n\t" // |menergy|/16 < QP/2 | |
781 "psubusb %%mm3, %%mm4 \n\t" //d=|menergy|/16 - MIN(|lenergy|,|renergy|)/16 | |
782 // mm0=128-q, mm1= SIGN(menergy), mm2= |menergy|/16 < QP/2, mm4= d/16 | |
783 | |
784 "movq %%mm4, %%mm3 \n\t" // d | |
210 | 785 "psubusb "MANGLE(b01)", %%mm4 \n\t" |
163 | 786 PAVGB(%%mm7, %%mm4) // d/32 |
787 PAVGB(%%mm7, %%mm4) // (d + 32)/64 | |
788 "paddb %%mm3, %%mm4 \n\t" // 5d/64 | |
789 "pand %%mm2, %%mm4 \n\t" | |
790 | |
210 | 791 "movq "MANGLE(b80)", %%mm5 \n\t" // 128 |
163 | 792 "psubb %%mm0, %%mm5 \n\t" // q |
793 "paddsb %%mm6, %%mm5 \n\t" // fix bad rounding | |
794 "pcmpgtb %%mm5, %%mm7 \n\t" // SIGN(q) | |
795 "pxor %%mm7, %%mm5 \n\t" | |
796 | |
797 PMINUB(%%mm5, %%mm4, %%mm3) // MIN(|q|, 5d/64) | |
798 "pxor %%mm1, %%mm7 \n\t" // SIGN(d*q) | |
799 | |
800 "pand %%mm7, %%mm4 \n\t" | |
801 "movq (%%eax, %1, 2), %%mm0 \n\t" | |
802 "movq (%0, %1, 4), %%mm2 \n\t" | |
803 "pxor %%mm1, %%mm0 \n\t" | |
804 "pxor %%mm1, %%mm2 \n\t" | |
805 "paddb %%mm4, %%mm0 \n\t" | |
806 "psubb %%mm4, %%mm2 \n\t" | |
807 "pxor %%mm1, %%mm0 \n\t" | |
808 "pxor %%mm1, %%mm2 \n\t" | |
809 "movq %%mm0, (%%eax, %1, 2) \n\t" | |
810 "movq %%mm2, (%0, %1, 4) \n\t" | |
811 | |
812 : | |
787 | 813 : "r" (src), "r" (stride), "m" (c->pQPb) |
814 : "%eax", "%ecx" | |
163 | 815 ); |
816 | |
817 /* | |
818 { | |
819 int x; | |
820 src-= stride; | |
821 for(x=0; x<BLOCK_SIZE; x++) | |
822 { | |
823 const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]); | |
824 if(ABS(middleEnergy)< 8*QP) | |
825 { | |
826 const int q=(src[l4] - src[l5])/2; | |
827 const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]); | |
828 const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]); | |
829 | |
830 int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) ); | |
831 d= MAX(d, 0); | |
832 | |
833 d= (5*d + 32) >> 6; | |
834 d*= SIGN(-middleEnergy); | |
835 | |
836 if(q>0) | |
837 { | |
838 d= d<0 ? 0 : d; | |
839 d= d>q ? q : d; | |
840 } | |
841 else | |
842 { | |
843 d= d>0 ? 0 : d; | |
844 d= d<q ? q : d; | |
845 } | |
846 | |
847 src[l4]-= d; | |
848 src[l5]+= d; | |
849 } | |
850 src++; | |
851 } | |
852 src-=8; | |
853 for(x=0; x<8; x++) | |
854 { | |
855 int y; | |
856 for(y=4; y<6; y++) | |
857 { | |
858 int d= src[x+y*stride] - tmp[x+(y-4)*8]; | |
859 int ad= ABS(d); | |
860 static int max=0; | |
861 static int sum=0; | |
862 static int num=0; | |
863 static int bias=0; | |
864 | |
865 if(max<ad) max=ad; | |
866 sum+= ad>3 ? 1 : 0; | |
867 if(ad>3) | |
868 { | |
869 src[0] = src[7] = src[stride*7] = src[(stride+1)*7]=255; | |
870 } | |
871 if(y==4) bias+=d; | |
872 num++; | |
873 if(num%1000000 == 0) | |
874 { | |
875 printf(" %d %d %d %d\n", num, sum, max, bias); | |
876 } | |
877 } | |
878 } | |
879 } | |
880 */ | |
881 #elif defined (HAVE_MMX) | |
882 src+= stride*4; | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
883 asm volatile( |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
884 "pxor %%mm7, %%mm7 \n\t" |
787 | 885 "leal -40(%%esp), %%ecx \n\t" // make space for 4 8-byte vars |
886 "andl $0xFFFFFFF8, %%ecx \n\t" // align | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
887 // 0 1 2 3 4 5 6 7 |
787 | 888 // %0 %0+%1 %0+2%1 eax+2%1 %0+4%1 eax+4%1 edx+%1 edx+2%1 |
889 // %0 eax eax+%1 eax+2%1 %0+4%1 edx edx+%1 edx+2%1 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
890 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
891 "movq (%0), %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
892 "movq %%mm0, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
893 "punpcklbw %%mm7, %%mm0 \n\t" // low part of line 0 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
894 "punpckhbw %%mm7, %%mm1 \n\t" // high part of line 0 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
895 |
810 | 896 "movq (%0, %1), %%mm2 \n\t" |
897 "leal (%0, %1, 2), %%eax \n\t" | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
898 "movq %%mm2, %%mm3 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
899 "punpcklbw %%mm7, %%mm2 \n\t" // low part of line 1 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
900 "punpckhbw %%mm7, %%mm3 \n\t" // high part of line 1 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
901 |
810 | 902 "movq (%%eax), %%mm4 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
903 "movq %%mm4, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
904 "punpcklbw %%mm7, %%mm4 \n\t" // low part of line 2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
905 "punpckhbw %%mm7, %%mm5 \n\t" // high part of line 2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
906 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
907 "paddw %%mm0, %%mm0 \n\t" // 2L0 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
908 "paddw %%mm1, %%mm1 \n\t" // 2H0 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
909 "psubw %%mm4, %%mm2 \n\t" // L1 - L2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
910 "psubw %%mm5, %%mm3 \n\t" // H1 - H2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
911 "psubw %%mm2, %%mm0 \n\t" // 2L0 - L1 + L2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
912 "psubw %%mm3, %%mm1 \n\t" // 2H0 - H1 + H2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
913 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
914 "psllw $2, %%mm2 \n\t" // 4L1 - 4L2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
915 "psllw $2, %%mm3 \n\t" // 4H1 - 4H2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
916 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
917 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
918 |
810 | 919 "movq (%%eax, %1), %%mm2 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
920 "movq %%mm2, %%mm3 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
921 "punpcklbw %%mm7, %%mm2 \n\t" // L3 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
922 "punpckhbw %%mm7, %%mm3 \n\t" // H3 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
923 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
924 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2 - L3 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
925 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2 - H3 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
926 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2 - 2L3 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
927 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2 - 2H3 |
787 | 928 "movq %%mm0, (%%ecx) \n\t" // 2L0 - 5L1 + 5L2 - 2L3 |
929 "movq %%mm1, 8(%%ecx) \n\t" // 2H0 - 5H1 + 5H2 - 2H3 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
930 |
810 | 931 "movq (%%eax, %1, 2), %%mm0 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
932 "movq %%mm0, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
933 "punpcklbw %%mm7, %%mm0 \n\t" // L4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
934 "punpckhbw %%mm7, %%mm1 \n\t" // H4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
935 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
936 "psubw %%mm0, %%mm2 \n\t" // L3 - L4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
937 "psubw %%mm1, %%mm3 \n\t" // H3 - H4 |
787 | 938 "movq %%mm2, 16(%%ecx) \n\t" // L3 - L4 |
939 "movq %%mm3, 24(%%ecx) \n\t" // H3 - H4 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
940 "paddw %%mm4, %%mm4 \n\t" // 2L2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
941 "paddw %%mm5, %%mm5 \n\t" // 2H2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
942 "psubw %%mm2, %%mm4 \n\t" // 2L2 - L3 + L4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
943 "psubw %%mm3, %%mm5 \n\t" // 2H2 - H3 + H4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
944 |
810 | 945 "leal (%%eax, %1), %0 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
946 "psllw $2, %%mm2 \n\t" // 4L3 - 4L4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
947 "psllw $2, %%mm3 \n\t" // 4H3 - 4H4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
948 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
949 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
950 //50 opcodes so far |
810 | 951 "movq (%0, %1, 2), %%mm2 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
952 "movq %%mm2, %%mm3 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
953 "punpcklbw %%mm7, %%mm2 \n\t" // L5 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
954 "punpckhbw %%mm7, %%mm3 \n\t" // H5 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
955 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4 - L5 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
956 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4 - H5 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
957 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4 - 2L5 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
958 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4 - 2H5 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
959 |
810 | 960 "movq (%%eax, %1, 4), %%mm6 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
961 "punpcklbw %%mm7, %%mm6 \n\t" // L6 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
962 "psubw %%mm6, %%mm2 \n\t" // L5 - L6 |
810 | 963 "movq (%%eax, %1, 4), %%mm6 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
964 "punpckhbw %%mm7, %%mm6 \n\t" // H6 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
965 "psubw %%mm6, %%mm3 \n\t" // H5 - H6 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
966 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
967 "paddw %%mm0, %%mm0 \n\t" // 2L4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
968 "paddw %%mm1, %%mm1 \n\t" // 2H4 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
969 "psubw %%mm2, %%mm0 \n\t" // 2L4 - L5 + L6 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
970 "psubw %%mm3, %%mm1 \n\t" // 2H4 - H5 + H6 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
971 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
972 "psllw $2, %%mm2 \n\t" // 4L5 - 4L6 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
973 "psllw $2, %%mm3 \n\t" // 4H5 - 4H6 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
974 "psubw %%mm2, %%mm0 \n\t" // 2L4 - 5L5 + 5L6 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
975 "psubw %%mm3, %%mm1 \n\t" // 2H4 - 5H5 + 5H6 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
976 |
810 | 977 "movq (%0, %1, 4), %%mm2 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
978 "movq %%mm2, %%mm3 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
979 "punpcklbw %%mm7, %%mm2 \n\t" // L7 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
980 "punpckhbw %%mm7, %%mm3 \n\t" // H7 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
981 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
982 "paddw %%mm2, %%mm2 \n\t" // 2L7 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
983 "paddw %%mm3, %%mm3 \n\t" // 2H7 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
984 "psubw %%mm2, %%mm0 \n\t" // 2L4 - 5L5 + 5L6 - 2L7 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
985 "psubw %%mm3, %%mm1 \n\t" // 2H4 - 5H5 + 5H6 - 2H7 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
986 |
787 | 987 "movq (%%ecx), %%mm2 \n\t" // 2L0 - 5L1 + 5L2 - 2L3 |
988 "movq 8(%%ecx), %%mm3 \n\t" // 2H0 - 5H1 + 5H2 - 2H3 | |
140 | 989 |
990 #ifdef HAVE_MMX2 | |
991 "movq %%mm7, %%mm6 \n\t" // 0 | |
992 "psubw %%mm0, %%mm6 \n\t" | |
993 "pmaxsw %%mm6, %%mm0 \n\t" // |2L4 - 5L5 + 5L6 - 2L7| | |
994 "movq %%mm7, %%mm6 \n\t" // 0 | |
995 "psubw %%mm1, %%mm6 \n\t" | |
996 "pmaxsw %%mm6, %%mm1 \n\t" // |2H4 - 5H5 + 5H6 - 2H7| | |
997 "movq %%mm7, %%mm6 \n\t" // 0 | |
998 "psubw %%mm2, %%mm6 \n\t" | |
999 "pmaxsw %%mm6, %%mm2 \n\t" // |2L0 - 5L1 + 5L2 - 2L3| | |
1000 "movq %%mm7, %%mm6 \n\t" // 0 | |
1001 "psubw %%mm3, %%mm6 \n\t" | |
1002 "pmaxsw %%mm6, %%mm3 \n\t" // |2H0 - 5H1 + 5H2 - 2H3| | |
1003 #else | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1004 "movq %%mm7, %%mm6 \n\t" // 0 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1005 "pcmpgtw %%mm0, %%mm6 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1006 "pxor %%mm6, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1007 "psubw %%mm6, %%mm0 \n\t" // |2L4 - 5L5 + 5L6 - 2L7| |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1008 "movq %%mm7, %%mm6 \n\t" // 0 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1009 "pcmpgtw %%mm1, %%mm6 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1010 "pxor %%mm6, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1011 "psubw %%mm6, %%mm1 \n\t" // |2H4 - 5H5 + 5H6 - 2H7| |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1012 "movq %%mm7, %%mm6 \n\t" // 0 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1013 "pcmpgtw %%mm2, %%mm6 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1014 "pxor %%mm6, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1015 "psubw %%mm6, %%mm2 \n\t" // |2L0 - 5L1 + 5L2 - 2L3| |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1016 "movq %%mm7, %%mm6 \n\t" // 0 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1017 "pcmpgtw %%mm3, %%mm6 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1018 "pxor %%mm6, %%mm3 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1019 "psubw %%mm6, %%mm3 \n\t" // |2H0 - 5H1 + 5H2 - 2H3| |
140 | 1020 #endif |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1021 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1022 #ifdef HAVE_MMX2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1023 "pminsw %%mm2, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1024 "pminsw %%mm3, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1025 #else |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1026 "movq %%mm0, %%mm6 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1027 "psubusw %%mm2, %%mm6 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1028 "psubw %%mm6, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1029 "movq %%mm1, %%mm6 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1030 "psubusw %%mm3, %%mm6 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1031 "psubw %%mm6, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1032 #endif |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1033 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1034 "movq %%mm7, %%mm6 \n\t" // 0 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1035 "pcmpgtw %%mm4, %%mm6 \n\t" // sign(2L2 - 5L3 + 5L4 - 2L5) |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1036 "pxor %%mm6, %%mm4 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1037 "psubw %%mm6, %%mm4 \n\t" // |2L2 - 5L3 + 5L4 - 2L5| |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1038 "pcmpgtw %%mm5, %%mm7 \n\t" // sign(2H2 - 5H3 + 5H4 - 2H5) |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1039 "pxor %%mm7, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1040 "psubw %%mm7, %%mm5 \n\t" // |2H2 - 5H3 + 5H4 - 2H5| |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1041 // 100 opcodes |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1042 "movd %2, %%mm2 \n\t" // QP |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1043 "psllw $3, %%mm2 \n\t" // 8QP |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1044 "movq %%mm2, %%mm3 \n\t" // 8QP |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1045 "pcmpgtw %%mm4, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1046 "pcmpgtw %%mm5, %%mm3 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1047 "pand %%mm2, %%mm4 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1048 "pand %%mm3, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1049 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1050 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1051 "psubusw %%mm0, %%mm4 \n\t" // hd |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1052 "psubusw %%mm1, %%mm5 \n\t" // ld |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1053 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1054 |
211 | 1055 "movq "MANGLE(w05)", %%mm2 \n\t" // 5 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1056 "pmullw %%mm2, %%mm4 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1057 "pmullw %%mm2, %%mm5 \n\t" |
211 | 1058 "movq "MANGLE(w20)", %%mm2 \n\t" // 32 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1059 "paddw %%mm2, %%mm4 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1060 "paddw %%mm2, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1061 "psrlw $6, %%mm4 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1062 "psrlw $6, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1063 |
787 | 1064 "movq 16(%%ecx), %%mm0 \n\t" // L3 - L4 |
1065 "movq 24(%%ecx), %%mm1 \n\t" // H3 - H4 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1066 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1067 "pxor %%mm2, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1068 "pxor %%mm3, %%mm3 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1069 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1070 "pcmpgtw %%mm0, %%mm2 \n\t" // sign (L3-L4) |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1071 "pcmpgtw %%mm1, %%mm3 \n\t" // sign (H3-H4) |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1072 "pxor %%mm2, %%mm0 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1073 "pxor %%mm3, %%mm1 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1074 "psubw %%mm2, %%mm0 \n\t" // |L3-L4| |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1075 "psubw %%mm3, %%mm1 \n\t" // |H3-H4| |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
1076 "psrlw $1, %%mm0 \n\t" // |L3 - L4|/2 |
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
1077 "psrlw $1, %%mm1 \n\t" // |H3 - H4|/2 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1078 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1079 "pxor %%mm6, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1080 "pxor %%mm7, %%mm3 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1081 "pand %%mm2, %%mm4 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1082 "pand %%mm3, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1083 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1084 #ifdef HAVE_MMX2 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1085 "pminsw %%mm0, %%mm4 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1086 "pminsw %%mm1, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1087 #else |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1088 "movq %%mm4, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1089 "psubusw %%mm0, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1090 "psubw %%mm2, %%mm4 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1091 "movq %%mm5, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1092 "psubusw %%mm1, %%mm2 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1093 "psubw %%mm2, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1094 #endif |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1095 "pxor %%mm6, %%mm4 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1096 "pxor %%mm7, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1097 "psubw %%mm6, %%mm4 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1098 "psubw %%mm7, %%mm5 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1099 "packsswb %%mm5, %%mm4 \n\t" |
810 | 1100 "movq (%0), %%mm0 \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1101 "paddb %%mm4, %%mm0 \n\t" |
810 | 1102 "movq %%mm0, (%0) \n\t" |
1103 "movq (%0, %1), %%mm0 \n\t" | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1104 "psubb %%mm4, %%mm0 \n\t" |
810 | 1105 "movq %%mm0, (%0, %1) \n\t" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1106 |
810 | 1107 : "+r" (src) |
1108 : "r" (stride), "m" (c->pQPb) | |
1109 : "%eax", "%ecx" | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1110 ); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1111 #else |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1112 const int l1= stride; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1113 const int l2= stride + l1; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1114 const int l3= stride + l2; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1115 const int l4= stride + l3; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1116 const int l5= stride + l4; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1117 const int l6= stride + l5; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1118 const int l7= stride + l6; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1119 const int l8= stride + l7; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1120 // const int l9= stride + l8; |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
1121 int x; |
111 | 1122 src+= stride*3; |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
1123 for(x=0; x<BLOCK_SIZE; x++) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1124 { |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1125 const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]); |
787 | 1126 if(ABS(middleEnergy) < 8*c->QP) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1127 { |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1128 const int q=(src[l4] - src[l5])/2; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1129 const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1130 const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1131 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1132 int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) ); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1133 d= MAX(d, 0); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1134 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1135 d= (5*d + 32) >> 6; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1136 d*= SIGN(-middleEnergy); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1137 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1138 if(q>0) |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1139 { |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1140 d= d<0 ? 0 : d; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1141 d= d>q ? q : d; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1142 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1143 else |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1144 { |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1145 d= d>0 ? 0 : d; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1146 d= d<q ? q : d; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1147 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1148 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1149 src[l4]-= d; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1150 src[l5]+= d; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1151 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1152 src++; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1153 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1154 #endif |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1155 } |
2036
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
1156 #endif //HAVE_ALTIVEC |
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
1157 |
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
1158 #ifndef HAVE_ALTIVEC |
787 | 1159 static inline void RENAME(dering)(uint8_t src[], int stride, PPContext *c) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1160 { |
132 | 1161 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1162 asm volatile( |
787 | 1163 "pxor %%mm6, %%mm6 \n\t" |
1164 "pcmpeqb %%mm7, %%mm7 \n\t" | |
1165 "movq %2, %%mm0 \n\t" | |
1166 "punpcklbw %%mm6, %%mm0 \n\t" | |
1167 "psrlw $1, %%mm0 \n\t" | |
1168 "psubw %%mm7, %%mm0 \n\t" | |
1169 "packuswb %%mm0, %%mm0 \n\t" | |
1170 "movq %%mm0, %3 \n\t" | |
130 | 1171 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1172 "leal (%0, %1), %%eax \n\t" |
787 | 1173 "leal (%%eax, %1, 4), %%edx \n\t" |
1174 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1175 // 0 1 2 3 4 5 6 7 8 9 |
787 | 1176 // %0 eax eax+%1 eax+2%1 %0+4%1 edx edx+%1 edx+2%1 %0+8%1 edx+4%1 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1177 |
169 | 1178 #undef FIND_MIN_MAX |
132 | 1179 #ifdef HAVE_MMX2 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1180 #define FIND_MIN_MAX(addr)\ |
130 | 1181 "movq " #addr ", %%mm0 \n\t"\ |
167 | 1182 "pminub %%mm0, %%mm7 \n\t"\ |
1183 "pmaxub %%mm0, %%mm6 \n\t" | |
132 | 1184 #else |
1185 #define FIND_MIN_MAX(addr)\ | |
1186 "movq " #addr ", %%mm0 \n\t"\ | |
167 | 1187 "movq %%mm7, %%mm1 \n\t"\ |
1188 "psubusb %%mm0, %%mm6 \n\t"\ | |
1189 "paddb %%mm0, %%mm6 \n\t"\ | |
132 | 1190 "psubusb %%mm0, %%mm1 \n\t"\ |
167 | 1191 "psubb %%mm1, %%mm7 \n\t" |
132 | 1192 #endif |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1193 |
130 | 1194 FIND_MIN_MAX((%%eax)) |
1195 FIND_MIN_MAX((%%eax, %1)) | |
1196 FIND_MIN_MAX((%%eax, %1, 2)) | |
1197 FIND_MIN_MAX((%0, %1, 4)) | |
787 | 1198 FIND_MIN_MAX((%%edx)) |
1199 FIND_MIN_MAX((%%edx, %1)) | |
1200 FIND_MIN_MAX((%%edx, %1, 2)) | |
130 | 1201 FIND_MIN_MAX((%0, %1, 8)) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1202 |
167 | 1203 "movq %%mm7, %%mm4 \n\t" |
1204 "psrlq $8, %%mm7 \n\t" | |
1205 #ifdef HAVE_MMX2 | |
1206 "pminub %%mm4, %%mm7 \n\t" // min of pixels | |
1207 "pshufw $0xF9, %%mm7, %%mm4 \n\t" | |
1208 "pminub %%mm4, %%mm7 \n\t" // min of pixels | |
1209 "pshufw $0xFE, %%mm7, %%mm4 \n\t" | |
1210 "pminub %%mm4, %%mm7 \n\t" | |
1211 #else | |
1212 "movq %%mm7, %%mm1 \n\t" | |
1213 "psubusb %%mm4, %%mm1 \n\t" | |
1214 "psubb %%mm1, %%mm7 \n\t" | |
1215 "movq %%mm7, %%mm4 \n\t" | |
1216 "psrlq $16, %%mm7 \n\t" | |
1217 "movq %%mm7, %%mm1 \n\t" | |
1218 "psubusb %%mm4, %%mm1 \n\t" | |
1219 "psubb %%mm1, %%mm7 \n\t" | |
1220 "movq %%mm7, %%mm4 \n\t" | |
1221 "psrlq $32, %%mm7 \n\t" | |
1222 "movq %%mm7, %%mm1 \n\t" | |
1223 "psubusb %%mm4, %%mm1 \n\t" | |
1224 "psubb %%mm1, %%mm7 \n\t" | |
1225 #endif | |
1226 | |
1227 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1228 "movq %%mm6, %%mm4 \n\t" |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
1229 "psrlq $8, %%mm6 \n\t" |
132 | 1230 #ifdef HAVE_MMX2 |
167 | 1231 "pmaxub %%mm4, %%mm6 \n\t" // max of pixels |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
1232 "pshufw $0xF9, %%mm6, %%mm4 \n\t" |
167 | 1233 "pmaxub %%mm4, %%mm6 \n\t" |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
1234 "pshufw $0xFE, %%mm6, %%mm4 \n\t" |
167 | 1235 "pmaxub %%mm4, %%mm6 \n\t" |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
1236 #else |
167 | 1237 "psubusb %%mm4, %%mm6 \n\t" |
1238 "paddb %%mm4, %%mm6 \n\t" | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1239 "movq %%mm6, %%mm4 \n\t" |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1240 "psrlq $16, %%mm6 \n\t" |
167 | 1241 "psubusb %%mm4, %%mm6 \n\t" |
1242 "paddb %%mm4, %%mm6 \n\t" | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1243 "movq %%mm6, %%mm4 \n\t" |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
1244 "psrlq $32, %%mm6 \n\t" |
167 | 1245 "psubusb %%mm4, %%mm6 \n\t" |
1246 "paddb %%mm4, %%mm6 \n\t" | |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
1247 #endif |
167 | 1248 "movq %%mm6, %%mm0 \n\t" // max |
1249 "psubb %%mm7, %%mm6 \n\t" // max - min | |
1250 "movd %%mm6, %%ecx \n\t" | |
210 | 1251 "cmpb "MANGLE(deringThreshold)", %%cl \n\t" |
167 | 1252 " jb 1f \n\t" |
787 | 1253 "leal -24(%%esp), %%ecx \n\t" |
1254 "andl $0xFFFFFFF8, %%ecx \n\t" | |
167 | 1255 PAVGB(%%mm0, %%mm7) // a=(max + min)/2 |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
1256 "punpcklbw %%mm7, %%mm7 \n\t" |
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
1257 "punpcklbw %%mm7, %%mm7 \n\t" |
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
1258 "punpcklbw %%mm7, %%mm7 \n\t" |
787 | 1259 "movq %%mm7, (%%ecx) \n\t" |
130 | 1260 |
1261 "movq (%0), %%mm0 \n\t" // L10 | |
1262 "movq %%mm0, %%mm1 \n\t" // L10 | |
1263 "movq %%mm0, %%mm2 \n\t" // L10 | |
1264 "psllq $8, %%mm1 \n\t" | |
1265 "psrlq $8, %%mm2 \n\t" | |
1266 "movd -4(%0), %%mm3 \n\t" | |
1267 "movd 8(%0), %%mm4 \n\t" | |
1268 "psrlq $24, %%mm3 \n\t" | |
1269 "psllq $56, %%mm4 \n\t" | |
1270 "por %%mm3, %%mm1 \n\t" // L00 | |
1271 "por %%mm4, %%mm2 \n\t" // L20 | |
1272 "movq %%mm1, %%mm3 \n\t" // L00 | |
1273 PAVGB(%%mm2, %%mm1) // (L20 + L00)/2 | |
1274 PAVGB(%%mm0, %%mm1) // (L20 + L00 + 2L10)/4 | |
1275 "psubusb %%mm7, %%mm0 \n\t" | |
1276 "psubusb %%mm7, %%mm2 \n\t" | |
1277 "psubusb %%mm7, %%mm3 \n\t" | |
210 | 1278 "pcmpeqb "MANGLE(b00)", %%mm0 \n\t" // L10 > a ? 0 : -1 |
1279 "pcmpeqb "MANGLE(b00)", %%mm2 \n\t" // L20 > a ? 0 : -1 | |
1280 "pcmpeqb "MANGLE(b00)", %%mm3 \n\t" // L00 > a ? 0 : -1 | |
130 | 1281 "paddb %%mm2, %%mm0 \n\t" |
1282 "paddb %%mm3, %%mm0 \n\t" | |
1283 | |
1284 "movq (%%eax), %%mm2 \n\t" // L11 | |
1285 "movq %%mm2, %%mm3 \n\t" // L11 | |
1286 "movq %%mm2, %%mm4 \n\t" // L11 | |
1287 "psllq $8, %%mm3 \n\t" | |
1288 "psrlq $8, %%mm4 \n\t" | |
1289 "movd -4(%%eax), %%mm5 \n\t" | |
1290 "movd 8(%%eax), %%mm6 \n\t" | |
1291 "psrlq $24, %%mm5 \n\t" | |
1292 "psllq $56, %%mm6 \n\t" | |
1293 "por %%mm5, %%mm3 \n\t" // L01 | |
1294 "por %%mm6, %%mm4 \n\t" // L21 | |
1295 "movq %%mm3, %%mm5 \n\t" // L01 | |
1296 PAVGB(%%mm4, %%mm3) // (L21 + L01)/2 | |
1297 PAVGB(%%mm2, %%mm3) // (L21 + L01 + 2L11)/4 | |
1298 "psubusb %%mm7, %%mm2 \n\t" | |
1299 "psubusb %%mm7, %%mm4 \n\t" | |
1300 "psubusb %%mm7, %%mm5 \n\t" | |
210 | 1301 "pcmpeqb "MANGLE(b00)", %%mm2 \n\t" // L11 > a ? 0 : -1 |
1302 "pcmpeqb "MANGLE(b00)", %%mm4 \n\t" // L21 > a ? 0 : -1 | |
1303 "pcmpeqb "MANGLE(b00)", %%mm5 \n\t" // L01 > a ? 0 : -1 | |
130 | 1304 "paddb %%mm4, %%mm2 \n\t" |
1305 "paddb %%mm5, %%mm2 \n\t" | |
1306 // 0, 2, 3, 1 | |
1307 #define DERING_CORE(dst,src,ppsx,psx,sx,pplx,plx,lx,t0,t1) \ | |
1308 "movq " #src ", " #sx " \n\t" /* src[0] */\ | |
1309 "movq " #sx ", " #lx " \n\t" /* src[0] */\ | |
1310 "movq " #sx ", " #t0 " \n\t" /* src[0] */\ | |
1311 "psllq $8, " #lx " \n\t"\ | |
1312 "psrlq $8, " #t0 " \n\t"\ | |
1313 "movd -4" #src ", " #t1 " \n\t"\ | |
1314 "psrlq $24, " #t1 " \n\t"\ | |
1315 "por " #t1 ", " #lx " \n\t" /* src[-1] */\ | |
1316 "movd 8" #src ", " #t1 " \n\t"\ | |
1317 "psllq $56, " #t1 " \n\t"\ | |
1318 "por " #t1 ", " #t0 " \n\t" /* src[+1] */\ | |
1319 "movq " #lx ", " #t1 " \n\t" /* src[-1] */\ | |
1320 PAVGB(t0, lx) /* (src[-1] + src[+1])/2 */\ | |
1321 PAVGB(sx, lx) /* (src[-1] + 2src[0] + src[+1])/4 */\ | |
135 | 1322 PAVGB(lx, pplx) \ |
787 | 1323 "movq " #lx ", 8(%%ecx) \n\t"\ |
1324 "movq (%%ecx), " #lx " \n\t"\ | |
140 | 1325 "psubusb " #lx ", " #t1 " \n\t"\ |
1326 "psubusb " #lx ", " #t0 " \n\t"\ | |
1327 "psubusb " #lx ", " #sx " \n\t"\ | |
210 | 1328 "movq "MANGLE(b00)", " #lx " \n\t"\ |
140 | 1329 "pcmpeqb " #lx ", " #t1 " \n\t" /* src[-1] > a ? 0 : -1*/\ |
1330 "pcmpeqb " #lx ", " #t0 " \n\t" /* src[+1] > a ? 0 : -1*/\ | |
1331 "pcmpeqb " #lx ", " #sx " \n\t" /* src[0] > a ? 0 : -1*/\ | |
130 | 1332 "paddb " #t1 ", " #t0 " \n\t"\ |
1333 "paddb " #t0 ", " #sx " \n\t"\ | |
1334 \ | |
1335 PAVGB(plx, pplx) /* filtered */\ | |
1336 "movq " #dst ", " #t0 " \n\t" /* dst */\ | |
134 | 1337 "movq " #t0 ", " #t1 " \n\t" /* dst */\ |
787 | 1338 "psubusb %3, " #t0 " \n\t"\ |
1339 "paddusb %3, " #t1 " \n\t"\ | |
134 | 1340 PMAXUB(t0, pplx)\ |
1341 PMINUB(t1, pplx, t0)\ | |
130 | 1342 "paddb " #sx ", " #ppsx " \n\t"\ |
1343 "paddb " #psx ", " #ppsx " \n\t"\ | |
210 | 1344 "#paddb "MANGLE(b02)", " #ppsx " \n\t"\ |
1345 "pand "MANGLE(b08)", " #ppsx " \n\t"\ | |
140 | 1346 "pcmpeqb " #lx ", " #ppsx " \n\t"\ |
134 | 1347 "pand " #ppsx ", " #pplx " \n\t"\ |
130 | 1348 "pandn " #dst ", " #ppsx " \n\t"\ |
140 | 1349 "por " #pplx ", " #ppsx " \n\t"\ |
135 | 1350 "movq " #ppsx ", " #dst " \n\t"\ |
787 | 1351 "movq 8(%%ecx), " #lx " \n\t" |
134 | 1352 |
130 | 1353 /* |
1354 0000000 | |
1355 1111111 | |
1356 | |
1357 1111110 | |
1358 1111101 | |
1359 1111100 | |
1360 1111011 | |
1361 1111010 | |
1362 1111001 | |
1363 | |
1364 1111000 | |
1365 1110111 | |
1366 | |
1367 */ | |
1368 //DERING_CORE(dst,src ,ppsx ,psx ,sx ,pplx ,plx ,lx ,t0 ,t1) | |
1369 DERING_CORE((%%eax),(%%eax, %1) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7) | |
1370 DERING_CORE((%%eax, %1),(%%eax, %1, 2) ,%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7) | |
1371 DERING_CORE((%%eax, %1, 2),(%0, %1, 4) ,%%mm4,%%mm0,%%mm2,%%mm5,%%mm1,%%mm3,%%mm6,%%mm7) | |
787 | 1372 DERING_CORE((%0, %1, 4),(%%edx) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7) |
1373 DERING_CORE((%%edx),(%%edx, %1) ,%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7) | |
1374 DERING_CORE((%%edx, %1), (%%edx, %1, 2),%%mm4,%%mm0,%%mm2,%%mm5,%%mm1,%%mm3,%%mm6,%%mm7) | |
1375 DERING_CORE((%%edx, %1, 2),(%0, %1, 8) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7) | |
1376 DERING_CORE((%0, %1, 8),(%%edx, %1, 4) ,%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7) | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1377 |
167 | 1378 "1: \n\t" |
787 | 1379 : : "r" (src), "r" (stride), "m" (c->pQPb), "m"(c->pQPb2) |
1380 : "%eax", "%edx", "%ecx" | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1381 ); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1382 #else |
134 | 1383 int y; |
1384 int min=255; | |
1385 int max=0; | |
1386 int avg; | |
1387 uint8_t *p; | |
1388 int s[10]; | |
787 | 1389 const int QP2= c->QP/2 + 1; |
134 | 1390 |
1391 for(y=1; y<9; y++) | |
1392 { | |
1393 int x; | |
1394 p= src + stride*y; | |
1395 for(x=1; x<9; x++) | |
1396 { | |
1397 p++; | |
1398 if(*p > max) max= *p; | |
1399 if(*p < min) min= *p; | |
1400 } | |
1401 } | |
787 | 1402 avg= (min + max + 1)>>1; |
134 | 1403 |
167 | 1404 if(max - min <deringThreshold) return; |
1405 | |
134 | 1406 for(y=0; y<10; y++) |
1407 { | |
1408 int t = 0; | |
787 | 1409 |
1410 if(src[stride*y + 0] > avg) t+= 1; | |
1411 if(src[stride*y + 1] > avg) t+= 2; | |
1412 if(src[stride*y + 2] > avg) t+= 4; | |
1413 if(src[stride*y + 3] > avg) t+= 8; | |
1414 if(src[stride*y + 4] > avg) t+= 16; | |
1415 if(src[stride*y + 5] > avg) t+= 32; | |
1416 if(src[stride*y + 6] > avg) t+= 64; | |
1417 if(src[stride*y + 7] > avg) t+= 128; | |
1418 if(src[stride*y + 8] > avg) t+= 256; | |
1419 if(src[stride*y + 9] > avg) t+= 512; | |
1420 | |
134 | 1421 t |= (~t)<<16; |
1422 t &= (t<<1) & (t>>1); | |
1423 s[y] = t; | |
1424 } | |
787 | 1425 |
1426 for(y=1; y<9; y++) | |
1427 { | |
1428 int t = s[y-1] & s[y] & s[y+1]; | |
1429 t|= t>>16; | |
1430 s[y-1]= t; | |
1431 } | |
134 | 1432 |
1433 for(y=1; y<9; y++) | |
1434 { | |
1435 int x; | |
787 | 1436 int t = s[y-1]; |
134 | 1437 |
1438 p= src + stride*y; | |
1439 for(x=1; x<9; x++) | |
1440 { | |
1441 p++; | |
1442 if(t & (1<<x)) | |
1443 { | |
1444 int f= (*(p-stride-1)) + 2*(*(p-stride)) + (*(p-stride+1)) | |
1445 +2*(*(p -1)) + 4*(*p ) + 2*(*(p +1)) | |
1446 +(*(p+stride-1)) + 2*(*(p+stride)) + (*(p+stride+1)); | |
1447 f= (f + 8)>>4; | |
1448 | |
167 | 1449 #ifdef DEBUG_DERING_THRESHOLD |
1450 asm volatile("emms\n\t":); | |
1451 { | |
1452 static long long numPixels=0; | |
1453 if(x!=1 && x!=8 && y!=1 && y!=8) numPixels++; | |
1454 // if((max-min)<20 || (max-min)*QP<200) | |
1455 // if((max-min)*QP < 500) | |
1456 // if(max-min<QP/2) | |
1457 if(max-min < 20) | |
1458 { | |
1459 static int numSkiped=0; | |
1460 static int errorSum=0; | |
1461 static int worstQP=0; | |
1462 static int worstRange=0; | |
1463 static int worstDiff=0; | |
1464 int diff= (f - *p); | |
1465 int absDiff= ABS(diff); | |
1466 int error= diff*diff; | |
1467 | |
1468 if(x==1 || x==8 || y==1 || y==8) continue; | |
1469 | |
1470 numSkiped++; | |
1471 if(absDiff > worstDiff) | |
1472 { | |
1473 worstDiff= absDiff; | |
1474 worstQP= QP; | |
1475 worstRange= max-min; | |
1476 } | |
1477 errorSum+= error; | |
1478 | |
1479 if(1024LL*1024LL*1024LL % numSkiped == 0) | |
1480 { | |
1481 printf( "sum:%1.3f, skip:%d, wQP:%d, " | |
1482 "wRange:%d, wDiff:%d, relSkip:%1.3f\n", | |
1483 (float)errorSum/numSkiped, numSkiped, worstQP, worstRange, | |
1484 worstDiff, (float)numSkiped/numPixels); | |
1485 } | |
1486 } | |
1487 } | |
1488 #endif | |
787 | 1489 if (*p + QP2 < f) *p= *p + QP2; |
1490 else if(*p - QP2 > f) *p= *p - QP2; | |
134 | 1491 else *p=f; |
1492 } | |
1493 } | |
1494 } | |
167 | 1495 #ifdef DEBUG_DERING_THRESHOLD |
1496 if(max-min < 20) | |
1497 { | |
1498 for(y=1; y<9; y++) | |
1499 { | |
1500 int x; | |
1501 int t = 0; | |
1502 p= src + stride*y; | |
1503 for(x=1; x<9; x++) | |
1504 { | |
1505 p++; | |
1506 *p = MIN(*p + 20, 255); | |
1507 } | |
1508 } | |
1509 // src[0] = src[7]=src[stride*7]=src[stride*7 + 7]=255; | |
1510 } | |
1511 #endif | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1512 #endif |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1513 } |
2036
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
1514 #endif //HAVE_ALTIVEC |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1515 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1516 /** |
1109 | 1517 * Deinterlaces the given block by linearly interpolating every second line. |
142 | 1518 * will be called for every 8x8 block and can read & write from line 4-15 |
1519 * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too | |
1520 * lines 4-12 will be read into the deblocking filter and should be deinterlaced | |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1521 */ |
169 | 1522 static inline void RENAME(deInterlaceInterpolateLinear)(uint8_t src[], int stride) |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1523 { |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1524 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
142 | 1525 src+= 4*stride; |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1526 asm volatile( |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1527 "leal (%0, %1), %%eax \n\t" |
787 | 1528 "leal (%%eax, %1, 4), %%ecx \n\t" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1529 // 0 1 2 3 4 5 6 7 8 9 |
787 | 1530 // %0 eax eax+%1 eax+2%1 %0+4%1 ecx ecx+%1 ecx+2%1 %0+8%1 ecx+4%1 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1531 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1532 "movq (%0), %%mm0 \n\t" |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1533 "movq (%%eax, %1), %%mm1 \n\t" |
111 | 1534 PAVGB(%%mm1, %%mm0) |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1535 "movq %%mm0, (%%eax) \n\t" |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1536 "movq (%0, %1, 4), %%mm0 \n\t" |
111 | 1537 PAVGB(%%mm0, %%mm1) |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1538 "movq %%mm1, (%%eax, %1, 2) \n\t" |
787 | 1539 "movq (%%ecx, %1), %%mm1 \n\t" |
111 | 1540 PAVGB(%%mm1, %%mm0) |
787 | 1541 "movq %%mm0, (%%ecx) \n\t" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1542 "movq (%0, %1, 8), %%mm0 \n\t" |
111 | 1543 PAVGB(%%mm0, %%mm1) |
787 | 1544 "movq %%mm1, (%%ecx, %1, 2) \n\t" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1545 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1546 : : "r" (src), "r" (stride) |
787 | 1547 : "%eax", "%ecx" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1548 ); |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1549 #else |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1550 int a, b, x; |
142 | 1551 src+= 4*stride; |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1552 |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1553 for(x=0; x<2; x++){ |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1554 a= *(uint32_t*)&src[stride*0]; |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1555 b= *(uint32_t*)&src[stride*2]; |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1556 *(uint32_t*)&src[stride*1]= (a|b) - (((a^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1557 a= *(uint32_t*)&src[stride*4]; |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1558 *(uint32_t*)&src[stride*3]= (a|b) - (((a^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1559 b= *(uint32_t*)&src[stride*6]; |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1560 *(uint32_t*)&src[stride*5]= (a|b) - (((a^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1561 a= *(uint32_t*)&src[stride*8]; |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1562 *(uint32_t*)&src[stride*7]= (a|b) - (((a^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1563 src += 4; |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1564 } |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1565 #endif |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1566 } |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1567 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1568 /** |
1109 | 1569 * Deinterlaces the given block by cubic interpolating every second line. |
142 | 1570 * will be called for every 8x8 block and can read & write from line 4-15 |
1571 * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too | |
1572 * lines 4-12 will be read into the deblocking filter and should be deinterlaced | |
1573 * this filter will read lines 3-15 and write 7-13 | |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1574 */ |
169 | 1575 static inline void RENAME(deInterlaceInterpolateCubic)(uint8_t src[], int stride) |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1576 { |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1577 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
142 | 1578 src+= stride*3; |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1579 asm volatile( |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1580 "leal (%0, %1), %%eax \n\t" |
787 | 1581 "leal (%%eax, %1, 4), %%edx \n\t" |
1582 "leal (%%edx, %1, 4), %%ecx \n\t" | |
111 | 1583 "addl %1, %%ecx \n\t" |
1584 "pxor %%mm7, %%mm7 \n\t" | |
1585 // 0 1 2 3 4 5 6 7 8 9 10 | |
787 | 1586 // %0 eax eax+%1 eax+2%1 %0+4%1 edx edx+%1 edx+2%1 %0+8%1 edx+4%1 ecx |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1587 |
111 | 1588 #define DEINT_CUBIC(a,b,c,d,e)\ |
1589 "movq " #a ", %%mm0 \n\t"\ | |
1590 "movq " #b ", %%mm1 \n\t"\ | |
1591 "movq " #d ", %%mm2 \n\t"\ | |
1592 "movq " #e ", %%mm3 \n\t"\ | |
1593 PAVGB(%%mm2, %%mm1) /* (b+d) /2 */\ | |
1594 PAVGB(%%mm3, %%mm0) /* a(a+e) /2 */\ | |
1595 "movq %%mm0, %%mm2 \n\t"\ | |
1596 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1597 "punpckhbw %%mm7, %%mm2 \n\t"\ | |
1598 "movq %%mm1, %%mm3 \n\t"\ | |
1599 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
1600 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
1601 "psubw %%mm1, %%mm0 \n\t" /* L(a+e - (b+d))/2 */\ | |
1602 "psubw %%mm3, %%mm2 \n\t" /* H(a+e - (b+d))/2 */\ | |
1603 "psraw $3, %%mm0 \n\t" /* L(a+e - (b+d))/16 */\ | |
1604 "psraw $3, %%mm2 \n\t" /* H(a+e - (b+d))/16 */\ | |
1605 "psubw %%mm0, %%mm1 \n\t" /* L(9b + 9d - a - e)/16 */\ | |
1606 "psubw %%mm2, %%mm3 \n\t" /* H(9b + 9d - a - e)/16 */\ | |
1607 "packuswb %%mm3, %%mm1 \n\t"\ | |
1608 "movq %%mm1, " #c " \n\t" | |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1609 |
787 | 1610 DEINT_CUBIC((%0), (%%eax, %1), (%%eax, %1, 2), (%0, %1, 4), (%%edx, %1)) |
1611 DEINT_CUBIC((%%eax, %1), (%0, %1, 4), (%%edx), (%%edx, %1), (%0, %1, 8)) | |
1612 DEINT_CUBIC((%0, %1, 4), (%%edx, %1), (%%edx, %1, 2), (%0, %1, 8), (%%ecx)) | |
1613 DEINT_CUBIC((%%edx, %1), (%0, %1, 8), (%%edx, %1, 4), (%%ecx), (%%ecx, %1, 2)) | |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1614 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1615 : : "r" (src), "r" (stride) |
787 | 1616 : "%eax", "%edx", "ecx" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1617 ); |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1618 #else |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1619 int x; |
142 | 1620 src+= stride*3; |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1621 for(x=0; x<8; x++) |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1622 { |
1157 | 1623 src[stride*3] = CLIP((-src[0] + 9*src[stride*2] + 9*src[stride*4] - src[stride*6])>>4); |
1624 src[stride*5] = CLIP((-src[stride*2] + 9*src[stride*4] + 9*src[stride*6] - src[stride*8])>>4); | |
1625 src[stride*7] = CLIP((-src[stride*4] + 9*src[stride*6] + 9*src[stride*8] - src[stride*10])>>4); | |
1626 src[stride*9] = CLIP((-src[stride*6] + 9*src[stride*8] + 9*src[stride*10] - src[stride*12])>>4); | |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1627 src++; |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1628 } |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1629 #endif |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1630 } |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1631 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1632 /** |
1109 | 1633 * Deinterlaces the given block by filtering every second line with a (-1 4 2 4 -1) filter. |
142 | 1634 * will be called for every 8x8 block and can read & write from line 4-15 |
1635 * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too | |
1636 * lines 4-12 will be read into the deblocking filter and should be deinterlaced | |
787 | 1637 * this filter will read lines 4-13 and write 5-11 |
1638 */ | |
1639 static inline void RENAME(deInterlaceFF)(uint8_t src[], int stride, uint8_t *tmp) | |
1640 { | |
1641 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1642 src+= stride*4; | |
1643 asm volatile( | |
1644 "leal (%0, %1), %%eax \n\t" | |
1645 "leal (%%eax, %1, 4), %%edx \n\t" | |
1646 "pxor %%mm7, %%mm7 \n\t" | |
1647 "movq (%2), %%mm0 \n\t" | |
1648 // 0 1 2 3 4 5 6 7 8 9 10 | |
1649 // %0 eax eax+%1 eax+2%1 %0+4%1 edx edx+%1 edx+2%1 %0+8%1 edx+4%1 ecx | |
1650 | |
1651 #define DEINT_FF(a,b,c,d)\ | |
1652 "movq " #a ", %%mm1 \n\t"\ | |
1653 "movq " #b ", %%mm2 \n\t"\ | |
1654 "movq " #c ", %%mm3 \n\t"\ | |
1655 "movq " #d ", %%mm4 \n\t"\ | |
1656 PAVGB(%%mm3, %%mm1) \ | |
1657 PAVGB(%%mm4, %%mm0) \ | |
1658 "movq %%mm0, %%mm3 \n\t"\ | |
1659 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1660 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
1661 "movq %%mm1, %%mm4 \n\t"\ | |
1662 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
1663 "punpckhbw %%mm7, %%mm4 \n\t"\ | |
1664 "psllw $2, %%mm1 \n\t"\ | |
1665 "psllw $2, %%mm4 \n\t"\ | |
1666 "psubw %%mm0, %%mm1 \n\t"\ | |
1667 "psubw %%mm3, %%mm4 \n\t"\ | |
1668 "movq %%mm2, %%mm5 \n\t"\ | |
1669 "movq %%mm2, %%mm0 \n\t"\ | |
1670 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1671 "punpckhbw %%mm7, %%mm5 \n\t"\ | |
1672 "paddw %%mm2, %%mm1 \n\t"\ | |
1673 "paddw %%mm5, %%mm4 \n\t"\ | |
1674 "psraw $2, %%mm1 \n\t"\ | |
1675 "psraw $2, %%mm4 \n\t"\ | |
1676 "packuswb %%mm4, %%mm1 \n\t"\ | |
1677 "movq %%mm1, " #b " \n\t"\ | |
1678 | |
1679 DEINT_FF((%0) , (%%eax) , (%%eax, %1), (%%eax, %1, 2)) | |
1680 DEINT_FF((%%eax, %1), (%%eax, %1, 2), (%0, %1, 4), (%%edx) ) | |
1681 DEINT_FF((%0, %1, 4), (%%edx) , (%%edx, %1), (%%edx, %1, 2)) | |
1682 DEINT_FF((%%edx, %1), (%%edx, %1, 2), (%0, %1, 8), (%%edx, %1, 4)) | |
1683 | |
1684 "movq %%mm0, (%2) \n\t" | |
1685 : : "r" (src), "r" (stride), "r"(tmp) | |
1686 : "%eax", "%edx" | |
1687 ); | |
1688 #else | |
1689 int x; | |
1690 src+= stride*4; | |
1691 for(x=0; x<8; x++) | |
1692 { | |
1693 int t1= tmp[x]; | |
1694 int t2= src[stride*1]; | |
1695 | |
1157 | 1696 src[stride*1]= CLIP((-t1 + 4*src[stride*0] + 2*t2 + 4*src[stride*2] - src[stride*3] + 4)>>3); |
787 | 1697 t1= src[stride*4]; |
1157 | 1698 src[stride*3]= CLIP((-t2 + 4*src[stride*2] + 2*t1 + 4*src[stride*4] - src[stride*5] + 4)>>3); |
787 | 1699 t2= src[stride*6]; |
1157 | 1700 src[stride*5]= CLIP((-t1 + 4*src[stride*4] + 2*t2 + 4*src[stride*6] - src[stride*7] + 4)>>3); |
787 | 1701 t1= src[stride*8]; |
1157 | 1702 src[stride*7]= CLIP((-t2 + 4*src[stride*6] + 2*t1 + 4*src[stride*8] - src[stride*9] + 4)>>3); |
787 | 1703 tmp[x]= t1; |
1704 | |
1705 src++; | |
1706 } | |
1707 #endif | |
1708 } | |
1709 | |
1710 /** | |
1157 | 1711 * Deinterlaces the given block by filtering every line with a (-1 2 6 2 -1) filter. |
1712 * will be called for every 8x8 block and can read & write from line 4-15 | |
1713 * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too | |
1714 * lines 4-12 will be read into the deblocking filter and should be deinterlaced | |
1715 * this filter will read lines 4-13 and write 4-11 | |
1716 */ | |
1717 static inline void RENAME(deInterlaceL5)(uint8_t src[], int stride, uint8_t *tmp, uint8_t *tmp2) | |
1718 { | |
1719 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1720 src+= stride*4; | |
1721 asm volatile( | |
1722 "leal (%0, %1), %%eax \n\t" | |
1723 "leal (%%eax, %1, 4), %%edx \n\t" | |
1724 "pxor %%mm7, %%mm7 \n\t" | |
1725 "movq (%2), %%mm0 \n\t" | |
1726 "movq (%3), %%mm1 \n\t" | |
1727 // 0 1 2 3 4 5 6 7 8 9 10 | |
1728 // %0 eax eax+%1 eax+2%1 %0+4%1 edx edx+%1 edx+2%1 %0+8%1 edx+4%1 ecx | |
1729 | |
1730 #define DEINT_L5(t1,t2,a,b,c)\ | |
1731 "movq " #a ", %%mm2 \n\t"\ | |
1732 "movq " #b ", %%mm3 \n\t"\ | |
1733 "movq " #c ", %%mm4 \n\t"\ | |
1734 PAVGB(t2, %%mm3) \ | |
1735 PAVGB(t1, %%mm4) \ | |
1736 "movq %%mm2, %%mm5 \n\t"\ | |
1737 "movq %%mm2, " #t1 " \n\t"\ | |
1738 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1739 "punpckhbw %%mm7, %%mm5 \n\t"\ | |
1740 "movq %%mm2, %%mm6 \n\t"\ | |
1741 "paddw %%mm2, %%mm2 \n\t"\ | |
1742 "paddw %%mm6, %%mm2 \n\t"\ | |
1743 "movq %%mm5, %%mm6 \n\t"\ | |
1744 "paddw %%mm5, %%mm5 \n\t"\ | |
1745 "paddw %%mm6, %%mm5 \n\t"\ | |
1746 "movq %%mm3, %%mm6 \n\t"\ | |
1747 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
1748 "punpckhbw %%mm7, %%mm6 \n\t"\ | |
1749 "paddw %%mm3, %%mm3 \n\t"\ | |
1750 "paddw %%mm6, %%mm6 \n\t"\ | |
1751 "paddw %%mm3, %%mm2 \n\t"\ | |
1752 "paddw %%mm6, %%mm5 \n\t"\ | |
1753 "movq %%mm4, %%mm6 \n\t"\ | |
1754 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
1755 "punpckhbw %%mm7, %%mm6 \n\t"\ | |
1756 "psubw %%mm4, %%mm2 \n\t"\ | |
1757 "psubw %%mm6, %%mm5 \n\t"\ | |
1758 "psraw $2, %%mm2 \n\t"\ | |
1759 "psraw $2, %%mm5 \n\t"\ | |
1760 "packuswb %%mm5, %%mm2 \n\t"\ | |
1761 "movq %%mm2, " #a " \n\t"\ | |
1762 | |
1763 DEINT_L5(%%mm0, %%mm1, (%0) , (%%eax) , (%%eax, %1) ) | |
1764 DEINT_L5(%%mm1, %%mm0, (%%eax) , (%%eax, %1) , (%%eax, %1, 2)) | |
1765 DEINT_L5(%%mm0, %%mm1, (%%eax, %1) , (%%eax, %1, 2), (%0, %1, 4) ) | |
1766 DEINT_L5(%%mm1, %%mm0, (%%eax, %1, 2), (%0, %1, 4) , (%%edx) ) | |
1767 DEINT_L5(%%mm0, %%mm1, (%0, %1, 4) , (%%edx) , (%%edx, %1) ) | |
1768 DEINT_L5(%%mm1, %%mm0, (%%edx) , (%%edx, %1) , (%%edx, %1, 2)) | |
1769 DEINT_L5(%%mm0, %%mm1, (%%edx, %1) , (%%edx, %1, 2), (%0, %1, 8) ) | |
1770 DEINT_L5(%%mm1, %%mm0, (%%edx, %1, 2), (%0, %1, 8) , (%%edx, %1, 4)) | |
1771 | |
1772 "movq %%mm0, (%2) \n\t" | |
1773 "movq %%mm1, (%3) \n\t" | |
1774 : : "r" (src), "r" (stride), "r"(tmp), "r"(tmp2) | |
1775 : "%eax", "%edx" | |
1776 ); | |
1777 #else | |
1778 int x; | |
1779 src+= stride*4; | |
1780 for(x=0; x<8; x++) | |
1781 { | |
1782 int t1= tmp[x]; | |
1783 int t2= tmp2[x]; | |
1784 int t3= src[0]; | |
1785 | |
1786 src[stride*0]= CLIP((-(t1 + src[stride*2]) + 2*(t2 + src[stride*1]) + 6*t3 + 4)>>3); | |
1787 t1= src[stride*1]; | |
1788 src[stride*1]= CLIP((-(t2 + src[stride*3]) + 2*(t3 + src[stride*2]) + 6*t1 + 4)>>3); | |
1789 t2= src[stride*2]; | |
1790 src[stride*2]= CLIP((-(t3 + src[stride*4]) + 2*(t1 + src[stride*3]) + 6*t2 + 4)>>3); | |
1791 t3= src[stride*3]; | |
1792 src[stride*3]= CLIP((-(t1 + src[stride*5]) + 2*(t2 + src[stride*4]) + 6*t3 + 4)>>3); | |
1793 t1= src[stride*4]; | |
1794 src[stride*4]= CLIP((-(t2 + src[stride*6]) + 2*(t3 + src[stride*5]) + 6*t1 + 4)>>3); | |
1795 t2= src[stride*5]; | |
1796 src[stride*5]= CLIP((-(t3 + src[stride*7]) + 2*(t1 + src[stride*6]) + 6*t2 + 4)>>3); | |
1797 t3= src[stride*6]; | |
1798 src[stride*6]= CLIP((-(t1 + src[stride*8]) + 2*(t2 + src[stride*7]) + 6*t3 + 4)>>3); | |
1799 t1= src[stride*7]; | |
1800 src[stride*7]= CLIP((-(t2 + src[stride*9]) + 2*(t3 + src[stride*8]) + 6*t1 + 4)>>3); | |
1801 | |
1802 tmp[x]= t3; | |
1803 tmp2[x]= t1; | |
1804 | |
1805 src++; | |
1806 } | |
1807 #endif | |
1808 } | |
1809 | |
1810 /** | |
1109 | 1811 * Deinterlaces the given block by filtering all lines with a (1 2 1) filter. |
787 | 1812 * will be called for every 8x8 block and can read & write from line 4-15 |
1813 * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too | |
1814 * lines 4-12 will be read into the deblocking filter and should be deinterlaced | |
142 | 1815 * this filter will read lines 4-13 and write 4-11 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1816 */ |
1581 | 1817 static inline void RENAME(deInterlaceBlendLinear)(uint8_t src[], int stride, uint8_t *tmp) |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1818 { |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1819 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
142 | 1820 src+= 4*stride; |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1821 asm volatile( |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1822 "leal (%0, %1), %%eax \n\t" |
787 | 1823 "leal (%%eax, %1, 4), %%edx \n\t" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1824 // 0 1 2 3 4 5 6 7 8 9 |
787 | 1825 // %0 eax eax+%1 eax+2%1 %0+4%1 edx edx+%1 edx+2%1 %0+8%1 edx+4%1 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1826 |
1581 | 1827 "movq (%2), %%mm0 \n\t" // L0 |
1828 "movq (%%eax), %%mm1 \n\t" // L2 | |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1829 PAVGB(%%mm1, %%mm0) // L0+L2 |
1581 | 1830 "movq (%0), %%mm2 \n\t" // L1 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1831 PAVGB(%%mm2, %%mm0) |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1832 "movq %%mm0, (%0) \n\t" |
1581 | 1833 "movq (%%eax, %1), %%mm0 \n\t" // L3 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1834 PAVGB(%%mm0, %%mm2) // L1+L3 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1835 PAVGB(%%mm1, %%mm2) // 2L2 + L1 + L3 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1836 "movq %%mm2, (%%eax) \n\t" |
1581 | 1837 "movq (%%eax, %1, 2), %%mm2 \n\t" // L4 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1838 PAVGB(%%mm2, %%mm1) // L2+L4 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1839 PAVGB(%%mm0, %%mm1) // 2L3 + L2 + L4 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1840 "movq %%mm1, (%%eax, %1) \n\t" |
1581 | 1841 "movq (%0, %1, 4), %%mm1 \n\t" // L5 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1842 PAVGB(%%mm1, %%mm0) // L3+L5 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1843 PAVGB(%%mm2, %%mm0) // 2L4 + L3 + L5 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1844 "movq %%mm0, (%%eax, %1, 2) \n\t" |
1581 | 1845 "movq (%%edx), %%mm0 \n\t" // L6 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1846 PAVGB(%%mm0, %%mm2) // L4+L6 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1847 PAVGB(%%mm1, %%mm2) // 2L5 + L4 + L6 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1848 "movq %%mm2, (%0, %1, 4) \n\t" |
1581 | 1849 "movq (%%edx, %1), %%mm2 \n\t" // L7 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1850 PAVGB(%%mm2, %%mm1) // L5+L7 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1851 PAVGB(%%mm0, %%mm1) // 2L6 + L5 + L7 |
787 | 1852 "movq %%mm1, (%%edx) \n\t" |
1581 | 1853 "movq (%%edx, %1, 2), %%mm1 \n\t" // L8 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1854 PAVGB(%%mm1, %%mm0) // L6+L8 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1855 PAVGB(%%mm2, %%mm0) // 2L7 + L6 + L8 |
787 | 1856 "movq %%mm0, (%%edx, %1) \n\t" |
1581 | 1857 "movq (%0, %1, 8), %%mm0 \n\t" // L9 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1858 PAVGB(%%mm0, %%mm2) // L7+L9 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1859 PAVGB(%%mm1, %%mm2) // 2L8 + L7 + L9 |
787 | 1860 "movq %%mm2, (%%edx, %1, 2) \n\t" |
1581 | 1861 "movq %%mm1, (%2) \n\t" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1862 |
1581 | 1863 : : "r" (src), "r" (stride), "r" (tmp) |
787 | 1864 : "%eax", "%edx" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1865 ); |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1866 #else |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1867 int a, b, c, x; |
142 | 1868 src+= 4*stride; |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1869 |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1870 for(x=0; x<2; x++){ |
1581 | 1871 a= *(uint32_t*)&tmp[stride*0]; |
1872 b= *(uint32_t*)&src[stride*0]; | |
1873 c= *(uint32_t*)&src[stride*1]; | |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1874 a= (a&c) + (((a^c)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1875 *(uint32_t*)&src[stride*0]= (a|b) - (((a^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1876 |
1581 | 1877 a= *(uint32_t*)&src[stride*2]; |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1878 b= (a&b) + (((a^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1879 *(uint32_t*)&src[stride*1]= (c|b) - (((c^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1880 |
1581 | 1881 b= *(uint32_t*)&src[stride*3]; |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1882 c= (b&c) + (((b^c)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1883 *(uint32_t*)&src[stride*2]= (c|a) - (((c^a)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1884 |
1581 | 1885 c= *(uint32_t*)&src[stride*4]; |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1886 a= (a&c) + (((a^c)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1887 *(uint32_t*)&src[stride*3]= (a|b) - (((a^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1888 |
1581 | 1889 a= *(uint32_t*)&src[stride*5]; |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1890 b= (a&b) + (((a^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1891 *(uint32_t*)&src[stride*4]= (c|b) - (((c^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1892 |
1581 | 1893 b= *(uint32_t*)&src[stride*6]; |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1894 c= (b&c) + (((b^c)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1895 *(uint32_t*)&src[stride*5]= (c|a) - (((c^a)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1896 |
1581 | 1897 c= *(uint32_t*)&src[stride*7]; |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1898 a= (a&c) + (((a^c)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1899 *(uint32_t*)&src[stride*6]= (a|b) - (((a^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1900 |
1581 | 1901 a= *(uint32_t*)&src[stride*8]; |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1902 b= (a&b) + (((a^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1903 *(uint32_t*)&src[stride*7]= (c|b) - (((c^b)&0xFEFEFEFEUL)>>1); |
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1904 |
1581 | 1905 *(uint32_t*)&tmp[stride*0]= c; |
1158
71d890b5c13b
faster C linear blend & interpolate deinterlacers
michaelni
parents:
1157
diff
changeset
|
1906 src += 4; |
1581 | 1907 tmp += 4; |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1908 } |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1909 #endif |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1910 } |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1911 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1912 /** |
1109 | 1913 * Deinterlaces the given block by applying a median filter to every second line. |
142 | 1914 * will be called for every 8x8 block and can read & write from line 4-15, |
1915 * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too | |
1916 * lines 4-12 will be read into the deblocking filter and should be deinterlaced | |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1917 */ |
169 | 1918 static inline void RENAME(deInterlaceMedian)(uint8_t src[], int stride) |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1919 { |
107 | 1920 #ifdef HAVE_MMX |
142 | 1921 src+= 4*stride; |
107 | 1922 #ifdef HAVE_MMX2 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1923 asm volatile( |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1924 "leal (%0, %1), %%eax \n\t" |
787 | 1925 "leal (%%eax, %1, 4), %%edx \n\t" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1926 // 0 1 2 3 4 5 6 7 8 9 |
787 | 1927 // %0 eax eax+%1 eax+2%1 %0+4%1 edx edx+%1 edx+2%1 %0+8%1 edx+4%1 |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1928 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1929 "movq (%0), %%mm0 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1930 "movq (%%eax, %1), %%mm2 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1931 "movq (%%eax), %%mm1 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1932 "movq %%mm0, %%mm3 \n\t" |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1933 "pmaxub %%mm1, %%mm0 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1934 "pminub %%mm3, %%mm1 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1935 "pmaxub %%mm2, %%mm1 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1936 "pminub %%mm1, %%mm0 \n\t" |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1937 "movq %%mm0, (%%eax) \n\t" |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1938 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1939 "movq (%0, %1, 4), %%mm0 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1940 "movq (%%eax, %1, 2), %%mm1 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1941 "movq %%mm2, %%mm3 \n\t" |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1942 "pmaxub %%mm1, %%mm2 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1943 "pminub %%mm3, %%mm1 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1944 "pmaxub %%mm0, %%mm1 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1945 "pminub %%mm1, %%mm2 \n\t" |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1946 "movq %%mm2, (%%eax, %1, 2) \n\t" |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1947 |
787 | 1948 "movq (%%edx), %%mm2 \n\t" // |
1949 "movq (%%edx, %1), %%mm1 \n\t" // | |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1950 "movq %%mm2, %%mm3 \n\t" |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1951 "pmaxub %%mm0, %%mm2 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1952 "pminub %%mm3, %%mm0 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1953 "pmaxub %%mm1, %%mm0 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1954 "pminub %%mm0, %%mm2 \n\t" |
787 | 1955 "movq %%mm2, (%%edx) \n\t" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1956 |
787 | 1957 "movq (%%edx, %1, 2), %%mm2 \n\t" // |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1958 "movq (%0, %1, 8), %%mm0 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1959 "movq %%mm2, %%mm3 \n\t" |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1960 "pmaxub %%mm0, %%mm2 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1961 "pminub %%mm3, %%mm0 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1962 "pmaxub %%mm1, %%mm0 \n\t" // |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1963 "pminub %%mm0, %%mm2 \n\t" |
787 | 1964 "movq %%mm2, (%%edx, %1, 2) \n\t" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1965 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1966 |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1967 : : "r" (src), "r" (stride) |
787 | 1968 : "%eax", "%edx" |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
1969 ); |
107 | 1970 |
1971 #else // MMX without MMX2 | |
1972 asm volatile( | |
1973 "leal (%0, %1), %%eax \n\t" | |
787 | 1974 "leal (%%eax, %1, 4), %%edx \n\t" |
107 | 1975 // 0 1 2 3 4 5 6 7 8 9 |
787 | 1976 // %0 eax eax+%1 eax+2%1 %0+4%1 edx edx+%1 edx+2%1 %0+8%1 edx+4%1 |
107 | 1977 "pxor %%mm7, %%mm7 \n\t" |
1978 | |
1979 #define MEDIAN(a,b,c)\ | |
1980 "movq " #a ", %%mm0 \n\t"\ | |
1981 "movq " #b ", %%mm2 \n\t"\ | |
1982 "movq " #c ", %%mm1 \n\t"\ | |
1983 "movq %%mm0, %%mm3 \n\t"\ | |
1984 "movq %%mm1, %%mm4 \n\t"\ | |
1985 "movq %%mm2, %%mm5 \n\t"\ | |
1986 "psubusb %%mm1, %%mm3 \n\t"\ | |
1987 "psubusb %%mm2, %%mm4 \n\t"\ | |
1988 "psubusb %%mm0, %%mm5 \n\t"\ | |
1989 "pcmpeqb %%mm7, %%mm3 \n\t"\ | |
1990 "pcmpeqb %%mm7, %%mm4 \n\t"\ | |
1991 "pcmpeqb %%mm7, %%mm5 \n\t"\ | |
1992 "movq %%mm3, %%mm6 \n\t"\ | |
1993 "pxor %%mm4, %%mm3 \n\t"\ | |
1994 "pxor %%mm5, %%mm4 \n\t"\ | |
1995 "pxor %%mm6, %%mm5 \n\t"\ | |
1996 "por %%mm3, %%mm1 \n\t"\ | |
1997 "por %%mm4, %%mm2 \n\t"\ | |
1998 "por %%mm5, %%mm0 \n\t"\ | |
1999 "pand %%mm2, %%mm0 \n\t"\ | |
2000 "pand %%mm1, %%mm0 \n\t"\ | |
2001 "movq %%mm0, " #b " \n\t" | |
2002 | |
2003 MEDIAN((%0), (%%eax), (%%eax, %1)) | |
2004 MEDIAN((%%eax, %1), (%%eax, %1, 2), (%0, %1, 4)) | |
787 | 2005 MEDIAN((%0, %1, 4), (%%edx), (%%edx, %1)) |
2006 MEDIAN((%%edx, %1), (%%edx, %1, 2), (%0, %1, 8)) | |
107 | 2007 |
2008 : : "r" (src), "r" (stride) | |
787 | 2009 : "%eax", "%edx" |
107 | 2010 ); |
2011 #endif // MMX | |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
2012 #else |
1029
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2013 int x, y; |
142 | 2014 src+= 4*stride; |
1029
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2015 // FIXME - there should be a way to do a few columns in parallel like w/mmx |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
2016 for(x=0; x<8; x++) |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
2017 { |
1029
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2018 uint8_t *colsrc = src; |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2019 for (y=0; y<4; y++) |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2020 { |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2021 int a, b, c, d, e, f; |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2022 a = colsrc[0 ]; |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2023 b = colsrc[stride ]; |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2024 c = colsrc[stride*2]; |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2025 d = (a-b)>>31; |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2026 e = (b-c)>>31; |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2027 f = (c-a)>>31; |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2028 colsrc[stride ] = (a|(d^f)) & (b|(d^e)) & (c|(e^f)); |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2029 colsrc += stride*2; |
804cc05a3f61
C implementation of the median deinterlacer (seems to be the only one
rfelker
parents:
957
diff
changeset
|
2030 } |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
2031 src++; |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
2032 } |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
2033 #endif |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
2034 } |
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
2035 |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
2036 #ifdef HAVE_MMX |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2037 /** |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2038 * transposes and shift the given 8x8 Block into dst1 and dst2 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2039 */ |
169 | 2040 static inline void RENAME(transpose1)(uint8_t *dst1, uint8_t *dst2, uint8_t *src, int srcStride) |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2041 { |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2042 asm( |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2043 "leal (%0, %1), %%eax \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2044 // 0 1 2 3 4 5 6 7 8 9 |
787 | 2045 // %0 eax eax+%1 eax+2%1 %0+4%1 edx edx+%1 edx+2%1 %0+8%1 edx+4%1 |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2046 "movq (%0), %%mm0 \n\t" // 12345678 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2047 "movq (%%eax), %%mm1 \n\t" // abcdefgh |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2048 "movq %%mm0, %%mm2 \n\t" // 12345678 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2049 "punpcklbw %%mm1, %%mm0 \n\t" // 1a2b3c4d |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2050 "punpckhbw %%mm1, %%mm2 \n\t" // 5e6f7g8h |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2051 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2052 "movq (%%eax, %1), %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2053 "movq (%%eax, %1, 2), %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2054 "movq %%mm1, %%mm4 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2055 "punpcklbw %%mm3, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2056 "punpckhbw %%mm3, %%mm4 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2057 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2058 "movq %%mm0, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2059 "punpcklwd %%mm1, %%mm0 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2060 "punpckhwd %%mm1, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2061 "movq %%mm2, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2062 "punpcklwd %%mm4, %%mm2 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2063 "punpckhwd %%mm4, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2064 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2065 "movd %%mm0, 128(%2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2066 "psrlq $32, %%mm0 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2067 "movd %%mm0, 144(%2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2068 "movd %%mm3, 160(%2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2069 "psrlq $32, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2070 "movd %%mm3, 176(%2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2071 "movd %%mm3, 48(%3) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2072 "movd %%mm2, 192(%2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2073 "movd %%mm2, 64(%3) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2074 "psrlq $32, %%mm2 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2075 "movd %%mm2, 80(%3) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2076 "movd %%mm1, 96(%3) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2077 "psrlq $32, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2078 "movd %%mm1, 112(%3) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2079 |
789
54079a650ba8
using fewer registers (fixes compilation bug hopefully)
michael
parents:
788
diff
changeset
|
2080 "leal (%%eax, %1, 4), %%eax \n\t" |
54079a650ba8
using fewer registers (fixes compilation bug hopefully)
michael
parents:
788
diff
changeset
|
2081 |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2082 "movq (%0, %1, 4), %%mm0 \n\t" // 12345678 |
789
54079a650ba8
using fewer registers (fixes compilation bug hopefully)
michael
parents:
788
diff
changeset
|
2083 "movq (%%eax), %%mm1 \n\t" // abcdefgh |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2084 "movq %%mm0, %%mm2 \n\t" // 12345678 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2085 "punpcklbw %%mm1, %%mm0 \n\t" // 1a2b3c4d |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2086 "punpckhbw %%mm1, %%mm2 \n\t" // 5e6f7g8h |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2087 |
789
54079a650ba8
using fewer registers (fixes compilation bug hopefully)
michael
parents:
788
diff
changeset
|
2088 "movq (%%eax, %1), %%mm1 \n\t" |
54079a650ba8
using fewer registers (fixes compilation bug hopefully)
michael
parents:
788
diff
changeset
|
2089 "movq (%%eax, %1, 2), %%mm3 \n\t" |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2090 "movq %%mm1, %%mm4 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2091 "punpcklbw %%mm3, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2092 "punpckhbw %%mm3, %%mm4 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2093 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2094 "movq %%mm0, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2095 "punpcklwd %%mm1, %%mm0 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2096 "punpckhwd %%mm1, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2097 "movq %%mm2, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2098 "punpcklwd %%mm4, %%mm2 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2099 "punpckhwd %%mm4, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2100 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2101 "movd %%mm0, 132(%2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2102 "psrlq $32, %%mm0 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2103 "movd %%mm0, 148(%2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2104 "movd %%mm3, 164(%2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2105 "psrlq $32, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2106 "movd %%mm3, 180(%2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2107 "movd %%mm3, 52(%3) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2108 "movd %%mm2, 196(%2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2109 "movd %%mm2, 68(%3) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2110 "psrlq $32, %%mm2 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2111 "movd %%mm2, 84(%3) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2112 "movd %%mm1, 100(%3) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2113 "psrlq $32, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2114 "movd %%mm1, 116(%3) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2115 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2116 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2117 :: "r" (src), "r" (srcStride), "r" (dst1), "r" (dst2) |
789
54079a650ba8
using fewer registers (fixes compilation bug hopefully)
michael
parents:
788
diff
changeset
|
2118 : "%eax" |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2119 ); |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2120 } |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2121 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2122 /** |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2123 * transposes the given 8x8 block |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2124 */ |
169 | 2125 static inline void RENAME(transpose2)(uint8_t *dst, int dstStride, uint8_t *src) |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2126 { |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2127 asm( |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2128 "leal (%0, %1), %%eax \n\t" |
787 | 2129 "leal (%%eax, %1, 4), %%edx \n\t" |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2130 // 0 1 2 3 4 5 6 7 8 9 |
787 | 2131 // %0 eax eax+%1 eax+2%1 %0+4%1 edx edx+%1 edx+2%1 %0+8%1 edx+4%1 |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2132 "movq (%2), %%mm0 \n\t" // 12345678 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2133 "movq 16(%2), %%mm1 \n\t" // abcdefgh |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2134 "movq %%mm0, %%mm2 \n\t" // 12345678 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2135 "punpcklbw %%mm1, %%mm0 \n\t" // 1a2b3c4d |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2136 "punpckhbw %%mm1, %%mm2 \n\t" // 5e6f7g8h |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2137 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2138 "movq 32(%2), %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2139 "movq 48(%2), %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2140 "movq %%mm1, %%mm4 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2141 "punpcklbw %%mm3, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2142 "punpckhbw %%mm3, %%mm4 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2143 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2144 "movq %%mm0, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2145 "punpcklwd %%mm1, %%mm0 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2146 "punpckhwd %%mm1, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2147 "movq %%mm2, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2148 "punpcklwd %%mm4, %%mm2 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2149 "punpckhwd %%mm4, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2150 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2151 "movd %%mm0, (%0) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2152 "psrlq $32, %%mm0 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2153 "movd %%mm0, (%%eax) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2154 "movd %%mm3, (%%eax, %1) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2155 "psrlq $32, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2156 "movd %%mm3, (%%eax, %1, 2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2157 "movd %%mm2, (%0, %1, 4) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2158 "psrlq $32, %%mm2 \n\t" |
787 | 2159 "movd %%mm2, (%%edx) \n\t" |
2160 "movd %%mm1, (%%edx, %1) \n\t" | |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2161 "psrlq $32, %%mm1 \n\t" |
787 | 2162 "movd %%mm1, (%%edx, %1, 2) \n\t" |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2163 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2164 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2165 "movq 64(%2), %%mm0 \n\t" // 12345678 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2166 "movq 80(%2), %%mm1 \n\t" // abcdefgh |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2167 "movq %%mm0, %%mm2 \n\t" // 12345678 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2168 "punpcklbw %%mm1, %%mm0 \n\t" // 1a2b3c4d |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2169 "punpckhbw %%mm1, %%mm2 \n\t" // 5e6f7g8h |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2170 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2171 "movq 96(%2), %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2172 "movq 112(%2), %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2173 "movq %%mm1, %%mm4 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2174 "punpcklbw %%mm3, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2175 "punpckhbw %%mm3, %%mm4 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2176 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2177 "movq %%mm0, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2178 "punpcklwd %%mm1, %%mm0 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2179 "punpckhwd %%mm1, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2180 "movq %%mm2, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2181 "punpcklwd %%mm4, %%mm2 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2182 "punpckhwd %%mm4, %%mm1 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2183 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2184 "movd %%mm0, 4(%0) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2185 "psrlq $32, %%mm0 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2186 "movd %%mm0, 4(%%eax) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2187 "movd %%mm3, 4(%%eax, %1) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2188 "psrlq $32, %%mm3 \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2189 "movd %%mm3, 4(%%eax, %1, 2) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2190 "movd %%mm2, 4(%0, %1, 4) \n\t" |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2191 "psrlq $32, %%mm2 \n\t" |
787 | 2192 "movd %%mm2, 4(%%edx) \n\t" |
2193 "movd %%mm1, 4(%%edx, %1) \n\t" | |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2194 "psrlq $32, %%mm1 \n\t" |
787 | 2195 "movd %%mm1, 4(%%edx, %1, 2) \n\t" |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2196 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2197 :: "r" (dst), "r" (dstStride), "r" (src) |
787 | 2198 : "%eax", "%edx" |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2199 ); |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2200 } |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
2201 #endif |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2202 //static int test=0; |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
2203 |
943 | 2204 static inline void RENAME(tempNoiseReducer)(uint8_t *src, int stride, |
158 | 2205 uint8_t *tempBlured, uint32_t *tempBluredPast, int *maxNoise) |
156 | 2206 { |
787 | 2207 // to save a register (FIXME do this outside of the loops) |
2208 tempBluredPast[127]= maxNoise[0]; | |
2209 tempBluredPast[128]= maxNoise[1]; | |
2210 tempBluredPast[129]= maxNoise[2]; | |
2211 | |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2212 #define FAST_L2_DIFF |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2213 //#define L1_DIFF //u should change the thresholds too if u try that one |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2214 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2215 asm volatile( |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2216 "leal (%2, %2, 2), %%eax \n\t" // 3*stride |
787 | 2217 "leal (%2, %2, 4), %%edx \n\t" // 5*stride |
2218 "leal (%%edx, %2, 2), %%ecx \n\t" // 7*stride | |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2219 // 0 1 2 3 4 5 6 7 8 9 |
787 | 2220 // %x %x+%2 %x+2%2 %x+eax %x+4%2 %x+edx %x+2eax %x+ecx %x+8%2 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2221 //FIXME reorder? |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2222 #ifdef L1_DIFF //needs mmx2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2223 "movq (%0), %%mm0 \n\t" // L0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2224 "psadbw (%1), %%mm0 \n\t" // |L0-R0| |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2225 "movq (%0, %2), %%mm1 \n\t" // L1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2226 "psadbw (%1, %2), %%mm1 \n\t" // |L1-R1| |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2227 "movq (%0, %2, 2), %%mm2 \n\t" // L2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2228 "psadbw (%1, %2, 2), %%mm2 \n\t" // |L2-R2| |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2229 "movq (%0, %%eax), %%mm3 \n\t" // L3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2230 "psadbw (%1, %%eax), %%mm3 \n\t" // |L3-R3| |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2231 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2232 "movq (%0, %2, 4), %%mm4 \n\t" // L4 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2233 "paddw %%mm1, %%mm0 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2234 "psadbw (%1, %2, 4), %%mm4 \n\t" // |L4-R4| |
787 | 2235 "movq (%0, %%edx), %%mm5 \n\t" // L5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2236 "paddw %%mm2, %%mm0 \n\t" |
787 | 2237 "psadbw (%1, %%edx), %%mm5 \n\t" // |L5-R5| |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2238 "movq (%0, %%eax, 2), %%mm6 \n\t" // L6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2239 "paddw %%mm3, %%mm0 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2240 "psadbw (%1, %%eax, 2), %%mm6 \n\t" // |L6-R6| |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2241 "movq (%0, %%ecx), %%mm7 \n\t" // L7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2242 "paddw %%mm4, %%mm0 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2243 "psadbw (%1, %%ecx), %%mm7 \n\t" // |L7-R7| |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2244 "paddw %%mm5, %%mm6 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2245 "paddw %%mm7, %%mm6 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2246 "paddw %%mm6, %%mm0 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2247 #elif defined (FAST_L2_DIFF) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2248 "pcmpeqb %%mm7, %%mm7 \n\t" |
210 | 2249 "movq "MANGLE(b80)", %%mm6 \n\t" |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2250 "pxor %%mm0, %%mm0 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2251 #define L2_DIFF_CORE(a, b)\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2252 "movq " #a ", %%mm5 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2253 "movq " #b ", %%mm2 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2254 "pxor %%mm7, %%mm2 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2255 PAVGB(%%mm2, %%mm5)\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2256 "paddb %%mm6, %%mm5 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2257 "movq %%mm5, %%mm2 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2258 "psllw $8, %%mm5 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2259 "pmaddwd %%mm5, %%mm5 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2260 "pmaddwd %%mm2, %%mm2 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2261 "paddd %%mm2, %%mm5 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2262 "psrld $14, %%mm5 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2263 "paddd %%mm5, %%mm0 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2264 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2265 L2_DIFF_CORE((%0), (%1)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2266 L2_DIFF_CORE((%0, %2), (%1, %2)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2267 L2_DIFF_CORE((%0, %2, 2), (%1, %2, 2)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2268 L2_DIFF_CORE((%0, %%eax), (%1, %%eax)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2269 L2_DIFF_CORE((%0, %2, 4), (%1, %2, 4)) |
787 | 2270 L2_DIFF_CORE((%0, %%edx), (%1, %%edx)) |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2271 L2_DIFF_CORE((%0, %%eax,2), (%1, %%eax,2)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2272 L2_DIFF_CORE((%0, %%ecx), (%1, %%ecx)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2273 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2274 #else |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2275 "pxor %%mm7, %%mm7 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2276 "pxor %%mm0, %%mm0 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2277 #define L2_DIFF_CORE(a, b)\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2278 "movq " #a ", %%mm5 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2279 "movq " #b ", %%mm2 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2280 "movq %%mm5, %%mm1 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2281 "movq %%mm2, %%mm3 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2282 "punpcklbw %%mm7, %%mm5 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2283 "punpckhbw %%mm7, %%mm1 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2284 "punpcklbw %%mm7, %%mm2 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2285 "punpckhbw %%mm7, %%mm3 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2286 "psubw %%mm2, %%mm5 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2287 "psubw %%mm3, %%mm1 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2288 "pmaddwd %%mm5, %%mm5 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2289 "pmaddwd %%mm1, %%mm1 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2290 "paddd %%mm1, %%mm5 \n\t"\ |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2291 "paddd %%mm5, %%mm0 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2292 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2293 L2_DIFF_CORE((%0), (%1)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2294 L2_DIFF_CORE((%0, %2), (%1, %2)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2295 L2_DIFF_CORE((%0, %2, 2), (%1, %2, 2)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2296 L2_DIFF_CORE((%0, %%eax), (%1, %%eax)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2297 L2_DIFF_CORE((%0, %2, 4), (%1, %2, 4)) |
787 | 2298 L2_DIFF_CORE((%0, %%edx), (%1, %%edx)) |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2299 L2_DIFF_CORE((%0, %%eax,2), (%1, %%eax,2)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2300 L2_DIFF_CORE((%0, %%ecx), (%1, %%ecx)) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2301 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2302 #endif |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2303 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2304 "movq %%mm0, %%mm4 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2305 "psrlq $32, %%mm0 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2306 "paddd %%mm0, %%mm4 \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2307 "movd %%mm4, %%ecx \n\t" |
158 | 2308 "shll $2, %%ecx \n\t" |
787 | 2309 "movl %3, %%edx \n\t" |
2310 "addl -4(%%edx), %%ecx \n\t" | |
2311 "addl 4(%%edx), %%ecx \n\t" | |
2312 "addl -1024(%%edx), %%ecx \n\t" | |
158 | 2313 "addl $4, %%ecx \n\t" |
787 | 2314 "addl 1024(%%edx), %%ecx \n\t" |
158 | 2315 "shrl $3, %%ecx \n\t" |
787 | 2316 "movl %%ecx, (%%edx) \n\t" |
158 | 2317 |
210 | 2318 // "movl %3, %%ecx \n\t" |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2319 // "movl %%ecx, test \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2320 // "jmp 4f \n\t" |
787 | 2321 "cmpl 512(%%edx), %%ecx \n\t" |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2322 " jb 2f \n\t" |
787 | 2323 "cmpl 516(%%edx), %%ecx \n\t" |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2324 " jb 1f \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2325 |
787 | 2326 "leal (%%eax, %2, 2), %%edx \n\t" // 5*stride |
2327 "leal (%%edx, %2, 2), %%ecx \n\t" // 7*stride | |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2328 "movq (%0), %%mm0 \n\t" // L0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2329 "movq (%0, %2), %%mm1 \n\t" // L1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2330 "movq (%0, %2, 2), %%mm2 \n\t" // L2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2331 "movq (%0, %%eax), %%mm3 \n\t" // L3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2332 "movq (%0, %2, 4), %%mm4 \n\t" // L4 |
787 | 2333 "movq (%0, %%edx), %%mm5 \n\t" // L5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2334 "movq (%0, %%eax, 2), %%mm6 \n\t" // L6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2335 "movq (%0, %%ecx), %%mm7 \n\t" // L7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2336 "movq %%mm0, (%1) \n\t" // L0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2337 "movq %%mm1, (%1, %2) \n\t" // L1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2338 "movq %%mm2, (%1, %2, 2) \n\t" // L2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2339 "movq %%mm3, (%1, %%eax) \n\t" // L3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2340 "movq %%mm4, (%1, %2, 4) \n\t" // L4 |
787 | 2341 "movq %%mm5, (%1, %%edx) \n\t" // L5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2342 "movq %%mm6, (%1, %%eax, 2) \n\t" // L6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2343 "movq %%mm7, (%1, %%ecx) \n\t" // L7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2344 "jmp 4f \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2345 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2346 "1: \n\t" |
787 | 2347 "leal (%%eax, %2, 2), %%edx \n\t" // 5*stride |
2348 "leal (%%edx, %2, 2), %%ecx \n\t" // 7*stride | |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2349 "movq (%0), %%mm0 \n\t" // L0 |
363
ff766a367974
3dnow temporal denoiser bugfix by R«±mi Guyomarch <rguyom@pobox.com>
michael
parents:
334
diff
changeset
|
2350 PAVGB((%1), %%mm0) // L0 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2351 "movq (%0, %2), %%mm1 \n\t" // L1 |
363
ff766a367974
3dnow temporal denoiser bugfix by R«±mi Guyomarch <rguyom@pobox.com>
michael
parents:
334
diff
changeset
|
2352 PAVGB((%1, %2), %%mm1) // L1 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2353 "movq (%0, %2, 2), %%mm2 \n\t" // L2 |
363
ff766a367974
3dnow temporal denoiser bugfix by R«±mi Guyomarch <rguyom@pobox.com>
michael
parents:
334
diff
changeset
|
2354 PAVGB((%1, %2, 2), %%mm2) // L2 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2355 "movq (%0, %%eax), %%mm3 \n\t" // L3 |
363
ff766a367974
3dnow temporal denoiser bugfix by R«±mi Guyomarch <rguyom@pobox.com>
michael
parents:
334
diff
changeset
|
2356 PAVGB((%1, %%eax), %%mm3) // L3 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2357 "movq (%0, %2, 4), %%mm4 \n\t" // L4 |
363
ff766a367974
3dnow temporal denoiser bugfix by R«±mi Guyomarch <rguyom@pobox.com>
michael
parents:
334
diff
changeset
|
2358 PAVGB((%1, %2, 4), %%mm4) // L4 |
787 | 2359 "movq (%0, %%edx), %%mm5 \n\t" // L5 |
2360 PAVGB((%1, %%edx), %%mm5) // L5 | |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2361 "movq (%0, %%eax, 2), %%mm6 \n\t" // L6 |
363
ff766a367974
3dnow temporal denoiser bugfix by R«±mi Guyomarch <rguyom@pobox.com>
michael
parents:
334
diff
changeset
|
2362 PAVGB((%1, %%eax, 2), %%mm6) // L6 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2363 "movq (%0, %%ecx), %%mm7 \n\t" // L7 |
363
ff766a367974
3dnow temporal denoiser bugfix by R«±mi Guyomarch <rguyom@pobox.com>
michael
parents:
334
diff
changeset
|
2364 PAVGB((%1, %%ecx), %%mm7) // L7 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2365 "movq %%mm0, (%1) \n\t" // R0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2366 "movq %%mm1, (%1, %2) \n\t" // R1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2367 "movq %%mm2, (%1, %2, 2) \n\t" // R2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2368 "movq %%mm3, (%1, %%eax) \n\t" // R3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2369 "movq %%mm4, (%1, %2, 4) \n\t" // R4 |
787 | 2370 "movq %%mm5, (%1, %%edx) \n\t" // R5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2371 "movq %%mm6, (%1, %%eax, 2) \n\t" // R6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2372 "movq %%mm7, (%1, %%ecx) \n\t" // R7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2373 "movq %%mm0, (%0) \n\t" // L0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2374 "movq %%mm1, (%0, %2) \n\t" // L1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2375 "movq %%mm2, (%0, %2, 2) \n\t" // L2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2376 "movq %%mm3, (%0, %%eax) \n\t" // L3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2377 "movq %%mm4, (%0, %2, 4) \n\t" // L4 |
787 | 2378 "movq %%mm5, (%0, %%edx) \n\t" // L5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2379 "movq %%mm6, (%0, %%eax, 2) \n\t" // L6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2380 "movq %%mm7, (%0, %%ecx) \n\t" // L7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2381 "jmp 4f \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2382 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2383 "2: \n\t" |
787 | 2384 "cmpl 508(%%edx), %%ecx \n\t" |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2385 " jb 3f \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2386 |
787 | 2387 "leal (%%eax, %2, 2), %%edx \n\t" // 5*stride |
2388 "leal (%%edx, %2, 2), %%ecx \n\t" // 7*stride | |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2389 "movq (%0), %%mm0 \n\t" // L0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2390 "movq (%0, %2), %%mm1 \n\t" // L1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2391 "movq (%0, %2, 2), %%mm2 \n\t" // L2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2392 "movq (%0, %%eax), %%mm3 \n\t" // L3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2393 "movq (%1), %%mm4 \n\t" // R0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2394 "movq (%1, %2), %%mm5 \n\t" // R1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2395 "movq (%1, %2, 2), %%mm6 \n\t" // R2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2396 "movq (%1, %%eax), %%mm7 \n\t" // R3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2397 PAVGB(%%mm4, %%mm0) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2398 PAVGB(%%mm5, %%mm1) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2399 PAVGB(%%mm6, %%mm2) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2400 PAVGB(%%mm7, %%mm3) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2401 PAVGB(%%mm4, %%mm0) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2402 PAVGB(%%mm5, %%mm1) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2403 PAVGB(%%mm6, %%mm2) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2404 PAVGB(%%mm7, %%mm3) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2405 "movq %%mm0, (%1) \n\t" // R0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2406 "movq %%mm1, (%1, %2) \n\t" // R1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2407 "movq %%mm2, (%1, %2, 2) \n\t" // R2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2408 "movq %%mm3, (%1, %%eax) \n\t" // R3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2409 "movq %%mm0, (%0) \n\t" // L0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2410 "movq %%mm1, (%0, %2) \n\t" // L1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2411 "movq %%mm2, (%0, %2, 2) \n\t" // L2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2412 "movq %%mm3, (%0, %%eax) \n\t" // L3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2413 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2414 "movq (%0, %2, 4), %%mm0 \n\t" // L4 |
787 | 2415 "movq (%0, %%edx), %%mm1 \n\t" // L5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2416 "movq (%0, %%eax, 2), %%mm2 \n\t" // L6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2417 "movq (%0, %%ecx), %%mm3 \n\t" // L7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2418 "movq (%1, %2, 4), %%mm4 \n\t" // R4 |
787 | 2419 "movq (%1, %%edx), %%mm5 \n\t" // R5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2420 "movq (%1, %%eax, 2), %%mm6 \n\t" // R6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2421 "movq (%1, %%ecx), %%mm7 \n\t" // R7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2422 PAVGB(%%mm4, %%mm0) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2423 PAVGB(%%mm5, %%mm1) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2424 PAVGB(%%mm6, %%mm2) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2425 PAVGB(%%mm7, %%mm3) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2426 PAVGB(%%mm4, %%mm0) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2427 PAVGB(%%mm5, %%mm1) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2428 PAVGB(%%mm6, %%mm2) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2429 PAVGB(%%mm7, %%mm3) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2430 "movq %%mm0, (%1, %2, 4) \n\t" // R4 |
787 | 2431 "movq %%mm1, (%1, %%edx) \n\t" // R5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2432 "movq %%mm2, (%1, %%eax, 2) \n\t" // R6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2433 "movq %%mm3, (%1, %%ecx) \n\t" // R7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2434 "movq %%mm0, (%0, %2, 4) \n\t" // L4 |
787 | 2435 "movq %%mm1, (%0, %%edx) \n\t" // L5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2436 "movq %%mm2, (%0, %%eax, 2) \n\t" // L6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2437 "movq %%mm3, (%0, %%ecx) \n\t" // L7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2438 "jmp 4f \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2439 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2440 "3: \n\t" |
787 | 2441 "leal (%%eax, %2, 2), %%edx \n\t" // 5*stride |
2442 "leal (%%edx, %2, 2), %%ecx \n\t" // 7*stride | |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2443 "movq (%0), %%mm0 \n\t" // L0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2444 "movq (%0, %2), %%mm1 \n\t" // L1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2445 "movq (%0, %2, 2), %%mm2 \n\t" // L2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2446 "movq (%0, %%eax), %%mm3 \n\t" // L3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2447 "movq (%1), %%mm4 \n\t" // R0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2448 "movq (%1, %2), %%mm5 \n\t" // R1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2449 "movq (%1, %2, 2), %%mm6 \n\t" // R2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2450 "movq (%1, %%eax), %%mm7 \n\t" // R3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2451 PAVGB(%%mm4, %%mm0) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2452 PAVGB(%%mm5, %%mm1) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2453 PAVGB(%%mm6, %%mm2) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2454 PAVGB(%%mm7, %%mm3) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2455 PAVGB(%%mm4, %%mm0) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2456 PAVGB(%%mm5, %%mm1) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2457 PAVGB(%%mm6, %%mm2) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2458 PAVGB(%%mm7, %%mm3) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2459 PAVGB(%%mm4, %%mm0) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2460 PAVGB(%%mm5, %%mm1) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2461 PAVGB(%%mm6, %%mm2) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2462 PAVGB(%%mm7, %%mm3) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2463 "movq %%mm0, (%1) \n\t" // R0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2464 "movq %%mm1, (%1, %2) \n\t" // R1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2465 "movq %%mm2, (%1, %2, 2) \n\t" // R2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2466 "movq %%mm3, (%1, %%eax) \n\t" // R3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2467 "movq %%mm0, (%0) \n\t" // L0 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2468 "movq %%mm1, (%0, %2) \n\t" // L1 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2469 "movq %%mm2, (%0, %2, 2) \n\t" // L2 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2470 "movq %%mm3, (%0, %%eax) \n\t" // L3 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2471 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2472 "movq (%0, %2, 4), %%mm0 \n\t" // L4 |
787 | 2473 "movq (%0, %%edx), %%mm1 \n\t" // L5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2474 "movq (%0, %%eax, 2), %%mm2 \n\t" // L6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2475 "movq (%0, %%ecx), %%mm3 \n\t" // L7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2476 "movq (%1, %2, 4), %%mm4 \n\t" // R4 |
787 | 2477 "movq (%1, %%edx), %%mm5 \n\t" // R5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2478 "movq (%1, %%eax, 2), %%mm6 \n\t" // R6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2479 "movq (%1, %%ecx), %%mm7 \n\t" // R7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2480 PAVGB(%%mm4, %%mm0) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2481 PAVGB(%%mm5, %%mm1) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2482 PAVGB(%%mm6, %%mm2) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2483 PAVGB(%%mm7, %%mm3) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2484 PAVGB(%%mm4, %%mm0) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2485 PAVGB(%%mm5, %%mm1) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2486 PAVGB(%%mm6, %%mm2) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2487 PAVGB(%%mm7, %%mm3) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2488 PAVGB(%%mm4, %%mm0) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2489 PAVGB(%%mm5, %%mm1) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2490 PAVGB(%%mm6, %%mm2) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2491 PAVGB(%%mm7, %%mm3) |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2492 "movq %%mm0, (%1, %2, 4) \n\t" // R4 |
787 | 2493 "movq %%mm1, (%1, %%edx) \n\t" // R5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2494 "movq %%mm2, (%1, %%eax, 2) \n\t" // R6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2495 "movq %%mm3, (%1, %%ecx) \n\t" // R7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2496 "movq %%mm0, (%0, %2, 4) \n\t" // L4 |
787 | 2497 "movq %%mm1, (%0, %%edx) \n\t" // L5 |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2498 "movq %%mm2, (%0, %%eax, 2) \n\t" // L6 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2499 "movq %%mm3, (%0, %%ecx) \n\t" // L7 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2500 |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2501 "4: \n\t" |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2502 |
158 | 2503 :: "r" (src), "r" (tempBlured), "r"(stride), "m" (tempBluredPast) |
787 | 2504 : "%eax", "%edx", "%ecx", "memory" |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2505 ); |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2506 //printf("%d\n", test); |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2507 #else |
788 | 2508 { |
156 | 2509 int y; |
2510 int d=0; | |
2511 int sysd=0; | |
158 | 2512 int i; |
156 | 2513 |
2514 for(y=0; y<8; y++) | |
2515 { | |
2516 int x; | |
2517 for(x=0; x<8; x++) | |
2518 { | |
2519 int ref= tempBlured[ x + y*stride ]; | |
2520 int cur= src[ x + y*stride ]; | |
2521 int d1=ref - cur; | |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2522 // if(x==0 || x==7) d1+= d1>>1; |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2523 // if(y==0 || y==7) d1+= d1>>1; |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2524 // d+= ABS(d1); |
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2525 d+= d1*d1; |
156 | 2526 sysd+= d1; |
2527 } | |
2528 } | |
158 | 2529 i=d; |
2530 d= ( | |
2531 4*d | |
2532 +(*(tempBluredPast-256)) | |
2533 +(*(tempBluredPast-1))+ (*(tempBluredPast+1)) | |
2534 +(*(tempBluredPast+256)) | |
2535 +4)>>3; | |
2536 *tempBluredPast=i; | |
2537 // ((*tempBluredPast)*3 + d + 2)>>2; | |
2538 | |
156 | 2539 //printf("%d %d %d\n", maxNoise[0], maxNoise[1], maxNoise[2]); |
2540 /* | |
2541 Switch between | |
2542 1 0 0 0 0 0 0 (0) | |
2543 64 32 16 8 4 2 1 (1) | |
2544 64 48 36 27 20 15 11 (33) (approx) | |
2545 64 56 49 43 37 33 29 (200) (approx) | |
2546 */ | |
2547 if(d > maxNoise[1]) | |
2548 { | |
2549 if(d < maxNoise[2]) | |
2550 { | |
2551 for(y=0; y<8; y++) | |
2552 { | |
2553 int x; | |
2554 for(x=0; x<8; x++) | |
2555 { | |
2556 int ref= tempBlured[ x + y*stride ]; | |
2557 int cur= src[ x + y*stride ]; | |
2558 tempBlured[ x + y*stride ]= | |
2559 src[ x + y*stride ]= | |
2560 (ref + cur + 1)>>1; | |
2561 } | |
2562 } | |
2563 } | |
2564 else | |
2565 { | |
2566 for(y=0; y<8; y++) | |
2567 { | |
2568 int x; | |
2569 for(x=0; x<8; x++) | |
2570 { | |
2571 tempBlured[ x + y*stride ]= src[ x + y*stride ]; | |
2572 } | |
2573 } | |
2574 } | |
2575 } | |
2576 else | |
2577 { | |
2578 if(d < maxNoise[0]) | |
2579 { | |
2580 for(y=0; y<8; y++) | |
2581 { | |
2582 int x; | |
2583 for(x=0; x<8; x++) | |
2584 { | |
2585 int ref= tempBlured[ x + y*stride ]; | |
2586 int cur= src[ x + y*stride ]; | |
2587 tempBlured[ x + y*stride ]= | |
2588 src[ x + y*stride ]= | |
2589 (ref*7 + cur + 4)>>3; | |
2590 } | |
2591 } | |
2592 } | |
2593 else | |
2594 { | |
2595 for(y=0; y<8; y++) | |
2596 { | |
2597 int x; | |
2598 for(x=0; x<8; x++) | |
2599 { | |
2600 int ref= tempBlured[ x + y*stride ]; | |
2601 int cur= src[ x + y*stride ]; | |
2602 tempBlured[ x + y*stride ]= | |
2603 src[ x + y*stride ]= | |
2604 (ref*3 + cur + 2)>>2; | |
2605 } | |
2606 } | |
2607 } | |
2608 } | |
788 | 2609 } |
157
bc12fd7e6153
temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
michael
parents:
156
diff
changeset
|
2610 #endif |
156 | 2611 } |
2612 | |
169 | 2613 static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, |
787 | 2614 QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c); |
96 | 2615 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2616 /** |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2617 * Copies a block from src to dst and fixes the blacklevel |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2618 * levelFix == 0 -> dont touch the brighness & contrast |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2619 */ |
634
be1cb0e1f276
warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
600
diff
changeset
|
2620 #undef SCALED_CPY |
be1cb0e1f276
warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
600
diff
changeset
|
2621 |
169 | 2622 static inline void RENAME(blockCopy)(uint8_t dst[], int dstStride, uint8_t src[], int srcStride, |
787 | 2623 int levelFix, int64_t *packedOffsetAndScale) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2624 { |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
2625 #ifndef HAVE_MMX |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2626 int i; |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
2627 #endif |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2628 if(levelFix) |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2629 { |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2630 #ifdef HAVE_MMX |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2631 asm volatile( |
787 | 2632 "movq (%%eax), %%mm2 \n\t" // packedYOffset |
2633 "movq 8(%%eax), %%mm3 \n\t" // packedYScale | |
2634 "leal (%2,%4), %%eax \n\t" | |
2635 "leal (%3,%5), %%edx \n\t" | |
101
fcf4e8fcb34b
fixed a sig4 bug an non mmx2 cpus (in case of more sig4 errors please send me a "disassemble $eip-16 $eip+16" from gdb)
michael
parents:
100
diff
changeset
|
2636 "pxor %%mm4, %%mm4 \n\t" |
173 | 2637 #ifdef HAVE_MMX2 |
2638 #define SCALED_CPY(src1, src2, dst1, dst2) \ | |
2639 "movq " #src1 ", %%mm0 \n\t"\ | |
2640 "movq " #src1 ", %%mm5 \n\t"\ | |
2641 "movq " #src2 ", %%mm1 \n\t"\ | |
2642 "movq " #src2 ", %%mm6 \n\t"\ | |
2643 "punpcklbw %%mm0, %%mm0 \n\t"\ | |
2644 "punpckhbw %%mm5, %%mm5 \n\t"\ | |
2645 "punpcklbw %%mm1, %%mm1 \n\t"\ | |
2646 "punpckhbw %%mm6, %%mm6 \n\t"\ | |
2647 "pmulhuw %%mm3, %%mm0 \n\t"\ | |
2648 "pmulhuw %%mm3, %%mm5 \n\t"\ | |
2649 "pmulhuw %%mm3, %%mm1 \n\t"\ | |
2650 "pmulhuw %%mm3, %%mm6 \n\t"\ | |
2651 "psubw %%mm2, %%mm0 \n\t"\ | |
2652 "psubw %%mm2, %%mm5 \n\t"\ | |
2653 "psubw %%mm2, %%mm1 \n\t"\ | |
2654 "psubw %%mm2, %%mm6 \n\t"\ | |
2655 "packuswb %%mm5, %%mm0 \n\t"\ | |
2656 "packuswb %%mm6, %%mm1 \n\t"\ | |
2657 "movq %%mm0, " #dst1 " \n\t"\ | |
2658 "movq %%mm1, " #dst2 " \n\t"\ | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2659 |
173 | 2660 #else //HAVE_MMX2 |
166 | 2661 #define SCALED_CPY(src1, src2, dst1, dst2) \ |
2662 "movq " #src1 ", %%mm0 \n\t"\ | |
2663 "movq " #src1 ", %%mm5 \n\t"\ | |
101
fcf4e8fcb34b
fixed a sig4 bug an non mmx2 cpus (in case of more sig4 errors please send me a "disassemble $eip-16 $eip+16" from gdb)
michael
parents:
100
diff
changeset
|
2664 "punpcklbw %%mm4, %%mm0 \n\t"\ |
fcf4e8fcb34b
fixed a sig4 bug an non mmx2 cpus (in case of more sig4 errors please send me a "disassemble $eip-16 $eip+16" from gdb)
michael
parents:
100
diff
changeset
|
2665 "punpckhbw %%mm4, %%mm5 \n\t"\ |
117 | 2666 "psubw %%mm2, %%mm0 \n\t"\ |
2667 "psubw %%mm2, %%mm5 \n\t"\ | |
166 | 2668 "movq " #src2 ", %%mm1 \n\t"\ |
117 | 2669 "psllw $6, %%mm0 \n\t"\ |
2670 "psllw $6, %%mm5 \n\t"\ | |
101
fcf4e8fcb34b
fixed a sig4 bug an non mmx2 cpus (in case of more sig4 errors please send me a "disassemble $eip-16 $eip+16" from gdb)
michael
parents:
100
diff
changeset
|
2671 "pmulhw %%mm3, %%mm0 \n\t"\ |
166 | 2672 "movq " #src2 ", %%mm6 \n\t"\ |
101
fcf4e8fcb34b
fixed a sig4 bug an non mmx2 cpus (in case of more sig4 errors please send me a "disassemble $eip-16 $eip+16" from gdb)
michael
parents:
100
diff
changeset
|
2673 "pmulhw %%mm3, %%mm5 \n\t"\ |
fcf4e8fcb34b
fixed a sig4 bug an non mmx2 cpus (in case of more sig4 errors please send me a "disassemble $eip-16 $eip+16" from gdb)
michael
parents:
100
diff
changeset
|
2674 "punpcklbw %%mm4, %%mm1 \n\t"\ |
118
3dd1950ac98d
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
117
diff
changeset
|
2675 "punpckhbw %%mm4, %%mm6 \n\t"\ |
117 | 2676 "psubw %%mm2, %%mm1 \n\t"\ |
118
3dd1950ac98d
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
117
diff
changeset
|
2677 "psubw %%mm2, %%mm6 \n\t"\ |
117 | 2678 "psllw $6, %%mm1 \n\t"\ |
118
3dd1950ac98d
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
117
diff
changeset
|
2679 "psllw $6, %%mm6 \n\t"\ |
101
fcf4e8fcb34b
fixed a sig4 bug an non mmx2 cpus (in case of more sig4 errors please send me a "disassemble $eip-16 $eip+16" from gdb)
michael
parents:
100
diff
changeset
|
2680 "pmulhw %%mm3, %%mm1 \n\t"\ |
118
3dd1950ac98d
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
117
diff
changeset
|
2681 "pmulhw %%mm3, %%mm6 \n\t"\ |
3dd1950ac98d
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
117
diff
changeset
|
2682 "packuswb %%mm5, %%mm0 \n\t"\ |
3dd1950ac98d
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
117
diff
changeset
|
2683 "packuswb %%mm6, %%mm1 \n\t"\ |
166 | 2684 "movq %%mm0, " #dst1 " \n\t"\ |
2685 "movq %%mm1, " #dst2 " \n\t"\ | |
2686 | |
173 | 2687 #endif //!HAVE_MMX2 |
2688 | |
787 | 2689 SCALED_CPY((%2) , (%2, %4) , (%3) , (%3, %5)) |
2690 SCALED_CPY((%2, %4, 2), (%%eax, %4, 2), (%3, %5, 2), (%%edx, %5, 2)) | |
2691 SCALED_CPY((%2, %4, 4), (%%eax, %4, 4), (%3, %5, 4), (%%edx, %5, 4)) | |
2692 "leal (%%eax,%4,4), %%eax \n\t" | |
2693 "leal (%%edx,%5,4), %%edx \n\t" | |
2694 SCALED_CPY((%%eax, %4), (%%eax, %4, 2), (%%edx, %5), (%%edx, %5, 2)) | |
166 | 2695 |
2696 | |
787 | 2697 : "=&a" (packedOffsetAndScale) |
2698 : "0" (packedOffsetAndScale), | |
2699 "r"(src), | |
166 | 2700 "r"(dst), |
2701 "r" (srcStride), | |
118
3dd1950ac98d
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
117
diff
changeset
|
2702 "r" (dstStride) |
787 | 2703 : "%edx" |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2704 ); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2705 #else |
164 | 2706 for(i=0; i<8; i++) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2707 memcpy( &(dst[dstStride*i]), |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2708 &(src[srcStride*i]), BLOCK_SIZE); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2709 #endif |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2710 } |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2711 else |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2712 { |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2713 #ifdef HAVE_MMX |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2714 asm volatile( |
166 | 2715 "leal (%0,%2), %%eax \n\t" |
787 | 2716 "leal (%1,%3), %%edx \n\t" |
166 | 2717 |
2718 #define SIMPLE_CPY(src1, src2, dst1, dst2) \ | |
2719 "movq " #src1 ", %%mm0 \n\t"\ | |
2720 "movq " #src2 ", %%mm1 \n\t"\ | |
2721 "movq %%mm0, " #dst1 " \n\t"\ | |
2722 "movq %%mm1, " #dst2 " \n\t"\ | |
2723 | |
2724 SIMPLE_CPY((%0) , (%0, %2) , (%1) , (%1, %3)) | |
787 | 2725 SIMPLE_CPY((%0, %2, 2), (%%eax, %2, 2), (%1, %3, 2), (%%edx, %3, 2)) |
2726 SIMPLE_CPY((%0, %2, 4), (%%eax, %2, 4), (%1, %3, 4), (%%edx, %3, 4)) | |
166 | 2727 "leal (%%eax,%2,4), %%eax \n\t" |
787 | 2728 "leal (%%edx,%3,4), %%edx \n\t" |
2729 SIMPLE_CPY((%%eax, %2), (%%eax, %2, 2), (%%edx, %3), (%%edx, %3, 2)) | |
166 | 2730 |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2731 : : "r" (src), |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2732 "r" (dst), |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2733 "r" (srcStride), |
164 | 2734 "r" (dstStride) |
787 | 2735 : "%eax", "%edx" |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2736 ); |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2737 #else |
164 | 2738 for(i=0; i<8; i++) |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2739 memcpy( &(dst[dstStride*i]), |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2740 &(src[srcStride*i]), BLOCK_SIZE); |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2741 #endif |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2742 } |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2743 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2744 |
224 | 2745 /** |
2746 * Duplicates the given 8 src pixels ? times upward | |
2747 */ | |
2748 static inline void RENAME(duplicate)(uint8_t src[], int stride) | |
2749 { | |
2750 #ifdef HAVE_MMX | |
2751 asm volatile( | |
2752 "movq (%0), %%mm0 \n\t" | |
2753 "addl %1, %0 \n\t" | |
2754 "movq %%mm0, (%0) \n\t" | |
2755 "movq %%mm0, (%0, %1) \n\t" | |
2756 "movq %%mm0, (%0, %1, 2) \n\t" | |
2757 : "+r" (src) | |
2758 : "r" (-stride) | |
2759 ); | |
2760 #else | |
2761 int i; | |
2762 uint8_t *p=src; | |
2763 for(i=0; i<3; i++) | |
2764 { | |
2765 p-= stride; | |
2766 memcpy(p, src, 8); | |
2767 } | |
2768 #endif | |
2769 } | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2770 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2771 /** |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2772 * Filters array of bytes (Y or U or V values) |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2773 */ |
169 | 2774 static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, |
787 | 2775 QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2776 { |
787 | 2777 PPContext __attribute__((aligned(8))) c= *c2; //copy to stack for faster access |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2778 int x,y; |
172
a0efaf471d6b
compiletime pp-mode support (luminance = chrominance filters though) 1-2% faster with -benchmark -vo null -nosound
michael
parents:
169
diff
changeset
|
2779 #ifdef COMPILE_TIME_MODE |
a0efaf471d6b
compiletime pp-mode support (luminance = chrominance filters though) 1-2% faster with -benchmark -vo null -nosound
michael
parents:
169
diff
changeset
|
2780 const int mode= COMPILE_TIME_MODE; |
a0efaf471d6b
compiletime pp-mode support (luminance = chrominance filters though) 1-2% faster with -benchmark -vo null -nosound
michael
parents:
169
diff
changeset
|
2781 #else |
787 | 2782 const int mode= isColor ? c.ppMode.chromMode : c.ppMode.lumMode; |
172
a0efaf471d6b
compiletime pp-mode support (luminance = chrominance filters though) 1-2% faster with -benchmark -vo null -nosound
michael
parents:
169
diff
changeset
|
2783 #endif |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2784 int black=0, white=255; // blackest black and whitest white in the picture |
223 | 2785 int QPCorrecture= 256*256; |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2786 |
886
3abff5a87548
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
810
diff
changeset
|
2787 int copyAhead; |
3abff5a87548
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
810
diff
changeset
|
2788 #ifdef HAVE_MMX |
3abff5a87548
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
810
diff
changeset
|
2789 int i; |
3abff5a87548
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
810
diff
changeset
|
2790 #endif |
164 | 2791 |
957 | 2792 const int qpHShift= isColor ? 4-c.hChromaSubSample : 4; |
2793 const int qpVShift= isColor ? 4-c.vChromaSubSample : 4; | |
2794 | |
787 | 2795 //FIXME remove |
2796 uint64_t * const yHistogram= c.yHistogram; | |
2797 uint8_t * const tempSrc= c.tempSrc; | |
2798 uint8_t * const tempDst= c.tempDst; | |
2031
4225c131a2eb
warning fixes by (Michael Roitzsch <mroi at users dot sourceforge dot net>)
michael
parents:
1724
diff
changeset
|
2799 //const int mbWidth= isColor ? (width+7)>>3 : (width+15)>>4; |
182
3ccd74a91074
minor brightness/contrast bugfix / moved some global vars into ppMode
michael
parents:
181
diff
changeset
|
2800 |
158 | 2801 #ifdef HAVE_MMX |
1724 | 2802 for(i=0; i<57; i++){ |
791 | 2803 int offset= ((i*c.ppMode.baseDcDiff)>>8) + 1; |
2804 int threshold= offset*2 + 1; | |
2805 c.mmxDcOffset[i]= 0x7F - offset; | |
2806 c.mmxDcThreshold[i]= 0x7F - threshold; | |
2807 c.mmxDcOffset[i]*= 0x0101010101010101LL; | |
2808 c.mmxDcThreshold[i]*= 0x0101010101010101LL; | |
2809 } | |
158 | 2810 #endif |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2811 |
164 | 2812 if(mode & CUBIC_IPOL_DEINT_FILTER) copyAhead=16; |
787 | 2813 else if( (mode & LINEAR_BLEND_DEINT_FILTER) |
1157 | 2814 || (mode & FFMPEG_DEINT_FILTER) |
2815 || (mode & LOWPASS5_DEINT_FILTER)) copyAhead=14; | |
164 | 2816 else if( (mode & V_DEBLOCK) |
2817 || (mode & LINEAR_IPOL_DEINT_FILTER) | |
2037
98d8283534bb
accurate/slow (per line instead of per block) deblock filter spport which is identical to what is recommanded in the mpeg4 spec
michael
parents:
2036
diff
changeset
|
2818 || (mode & MEDIAN_DEINT_FILTER) |
98d8283534bb
accurate/slow (per line instead of per block) deblock filter spport which is identical to what is recommanded in the mpeg4 spec
michael
parents:
2036
diff
changeset
|
2819 || (mode & V_A_DEBLOCK)) copyAhead=13; |
164 | 2820 else if(mode & V_X1_FILTER) copyAhead=11; |
787 | 2821 // else if(mode & V_RK1_FILTER) copyAhead=10; |
164 | 2822 else if(mode & DERING) copyAhead=9; |
2823 else copyAhead=8; | |
2824 | |
2825 copyAhead-= 8; | |
2826 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2827 if(!isColor) |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2828 { |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2829 uint64_t sum= 0; |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2830 int i; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2831 uint64_t maxClipped; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2832 uint64_t clipped; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2833 double scale; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2834 |
787 | 2835 c.frameNum++; |
2836 // first frame is fscked so we ignore it | |
2837 if(c.frameNum == 1) yHistogram[0]= width*height/64*15/256; | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2838 |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2839 for(i=0; i<256; i++) |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2840 { |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2841 sum+= yHistogram[i]; |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2842 // printf("%d ", yHistogram[i]); |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2843 } |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2844 // printf("\n\n"); |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2845 |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2846 /* we allways get a completly black picture first */ |
793 | 2847 maxClipped= (uint64_t)(sum * c.ppMode.maxClippedThreshold); |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2848 |
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
2849 clipped= sum; |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2850 for(black=255; black>0; black--) |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2851 { |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2852 if(clipped < maxClipped) break; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2853 clipped-= yHistogram[black]; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2854 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2855 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2856 clipped= sum; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2857 for(white=0; white<256; white++) |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2858 { |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2859 if(clipped < maxClipped) break; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2860 clipped-= yHistogram[white]; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2861 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2862 |
787 | 2863 scale= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(white-black); |
173 | 2864 |
2865 #ifdef HAVE_MMX2 | |
787 | 2866 c.packedYScale= (uint16_t)(scale*256.0 + 0.5); |
2867 c.packedYOffset= (((black*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF; | |
173 | 2868 #else |
787 | 2869 c.packedYScale= (uint16_t)(scale*1024.0 + 0.5); |
2870 c.packedYOffset= (black - c.ppMode.minAllowedY) & 0xFFFF; | |
173 | 2871 #endif |
2872 | |
787 | 2873 c.packedYOffset|= c.packedYOffset<<32; |
2874 c.packedYOffset|= c.packedYOffset<<16; | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2875 |
787 | 2876 c.packedYScale|= c.packedYScale<<32; |
2877 c.packedYScale|= c.packedYScale<<16; | |
223 | 2878 |
2879 if(mode & LEVEL_FIX) QPCorrecture= (int)(scale*256*256 + 0.5); | |
2880 else QPCorrecture= 256*256; | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2881 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2882 else |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2883 { |
787 | 2884 c.packedYScale= 0x0100010001000100LL; |
2885 c.packedYOffset= 0; | |
223 | 2886 QPCorrecture= 256*256; |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2887 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2888 |
148
1cfc4d567c0a
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
142
diff
changeset
|
2889 /* copy & deinterlace first row of blocks */ |
142 | 2890 y=-BLOCK_SIZE; |
2891 { | |
2892 uint8_t *srcBlock= &(src[y*srcStride]); | |
224 | 2893 uint8_t *dstBlock= tempDst + dstStride; |
142 | 2894 |
2895 // From this point on it is guranteed that we can read and write 16 lines downward | |
2896 // finish 1 block before the next otherwise we´ll might have a problem | |
2897 // with the L1 Cache of the P4 ... or only a few blocks at a time or soemthing | |
2898 for(x=0; x<width; x+=BLOCK_SIZE) | |
2899 { | |
2900 | |
2901 #ifdef HAVE_MMX2 | |
2902 /* | |
2903 prefetchnta(srcBlock + (((x>>2)&6) + 5)*srcStride + 32); | |
2904 prefetchnta(srcBlock + (((x>>2)&6) + 6)*srcStride + 32); | |
2905 prefetcht0(dstBlock + (((x>>2)&6) + 5)*dstStride + 32); | |
2906 prefetcht0(dstBlock + (((x>>2)&6) + 6)*dstStride + 32); | |
2907 */ | |
2908 | |
2909 asm( | |
2910 "movl %4, %%eax \n\t" | |
2911 "shrl $2, %%eax \n\t" | |
2912 "andl $6, %%eax \n\t" | |
164 | 2913 "addl %5, %%eax \n\t" |
787 | 2914 "movl %%eax, %%edx \n\t" |
142 | 2915 "imul %1, %%eax \n\t" |
787 | 2916 "imul %3, %%edx \n\t" |
142 | 2917 "prefetchnta 32(%%eax, %0) \n\t" |
787 | 2918 "prefetcht0 32(%%edx, %2) \n\t" |
142 | 2919 "addl %1, %%eax \n\t" |
787 | 2920 "addl %3, %%edx \n\t" |
142 | 2921 "prefetchnta 32(%%eax, %0) \n\t" |
787 | 2922 "prefetcht0 32(%%edx, %2) \n\t" |
142 | 2923 :: "r" (srcBlock), "r" (srcStride), "r" (dstBlock), "r" (dstStride), |
164 | 2924 "m" (x), "m" (copyAhead) |
787 | 2925 : "%eax", "%edx" |
142 | 2926 ); |
2927 | |
2928 #elif defined(HAVE_3DNOW) | |
2929 //FIXME check if this is faster on an 3dnow chip or if its faster without the prefetch or ... | |
2930 /* prefetch(srcBlock + (((x>>3)&3) + 5)*srcStride + 32); | |
2931 prefetch(srcBlock + (((x>>3)&3) + 9)*srcStride + 32); | |
2932 prefetchw(dstBlock + (((x>>3)&3) + 5)*dstStride + 32); | |
2933 prefetchw(dstBlock + (((x>>3)&3) + 9)*dstStride + 32); | |
2934 */ | |
2935 #endif | |
2936 | |
224 | 2937 RENAME(blockCopy)(dstBlock + dstStride*8, dstStride, |
787 | 2938 srcBlock + srcStride*8, srcStride, mode & LEVEL_FIX, &c.packedYOffset); |
224 | 2939 |
2940 RENAME(duplicate)(dstBlock + dstStride*8, dstStride); | |
142 | 2941 |
2942 if(mode & LINEAR_IPOL_DEINT_FILTER) | |
169 | 2943 RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride); |
142 | 2944 else if(mode & LINEAR_BLEND_DEINT_FILTER) |
1581 | 2945 RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x); |
142 | 2946 else if(mode & MEDIAN_DEINT_FILTER) |
169 | 2947 RENAME(deInterlaceMedian)(dstBlock, dstStride); |
142 | 2948 else if(mode & CUBIC_IPOL_DEINT_FILTER) |
169 | 2949 RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride); |
787 | 2950 else if(mode & FFMPEG_DEINT_FILTER) |
2951 RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x); | |
1157 | 2952 else if(mode & LOWPASS5_DEINT_FILTER) |
2953 RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x); | |
142 | 2954 /* else if(mode & CUBIC_BLEND_DEINT_FILTER) |
169 | 2955 RENAME(deInterlaceBlendCubic)(dstBlock, dstStride); |
142 | 2956 */ |
2957 dstBlock+=8; | |
2958 srcBlock+=8; | |
2959 } | |
941 | 2960 if(width==dstStride) |
2961 memcpy(dst, tempDst + 9*dstStride, copyAhead*dstStride); | |
2962 else | |
2963 { | |
943 | 2964 int i; |
941 | 2965 for(i=0; i<copyAhead; i++) |
2966 { | |
2967 memcpy(dst + i*dstStride, tempDst + (9+i)*dstStride, width); | |
2968 } | |
2969 } | |
142 | 2970 } |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2971 |
787 | 2972 //printf("\n"); |
111 | 2973 for(y=0; y<height; y+=BLOCK_SIZE) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2974 { |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2975 //1% speedup if these are here instead of the inner loop |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2976 uint8_t *srcBlock= &(src[y*srcStride]); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2977 uint8_t *dstBlock= &(dst[y*dstStride]); |
169 | 2978 #ifdef HAVE_MMX |
787 | 2979 uint8_t *tempBlock1= c.tempBlocks; |
2980 uint8_t *tempBlock2= c.tempBlocks + 8; | |
169 | 2981 #endif |
957 | 2982 int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride]; |
1196 | 2983 int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*QPStride]; |
156 | 2984 int QP=0; |
130 | 2985 /* can we mess with a 8x16 block from srcBlock/dstBlock downwards and 1 line upwards |
2986 if not than use a temporary buffer */ | |
111 | 2987 if(y+15 >= height) |
2988 { | |
156 | 2989 int i; |
164 | 2990 /* copy from line (copyAhead) to (copyAhead+7) of src, these will be copied with |
111 | 2991 blockcopy to dst later */ |
164 | 2992 memcpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead, |
2993 srcStride*MAX(height-y-copyAhead, 0) ); | |
2994 | |
2995 /* duplicate last line of src to fill the void upto line (copyAhead+7) */ | |
2996 for(i=MAX(height-y, 8); i<copyAhead+8; i++) | |
156 | 2997 memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), srcStride); |
2998 | |
164 | 2999 /* copy up to (copyAhead+1) lines of dst (line -1 to (copyAhead-1))*/ |
3000 memcpy(tempDst, dstBlock - dstStride, dstStride*MIN(height-y+1, copyAhead+1) ); | |
3001 | |
3002 /* duplicate last line of dst to fill the void upto line (copyAhead) */ | |
3003 for(i=height-y+1; i<=copyAhead; i++) | |
156 | 3004 memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), dstStride); |
3005 | |
130 | 3006 dstBlock= tempDst + dstStride; |
111 | 3007 srcBlock= tempSrc; |
3008 } | |
787 | 3009 //printf("\n"); |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3010 |
112 | 3011 // From this point on it is guranteed that we can read and write 16 lines downward |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3012 // finish 1 block before the next otherwise we´ll might have a problem |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3013 // with the L1 Cache of the P4 ... or only a few blocks at a time or soemthing |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
3014 for(x=0; x<width; x+=BLOCK_SIZE) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3015 { |
97
e57b1d38d71f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
96
diff
changeset
|
3016 const int stride= dstStride; |
169 | 3017 #ifdef HAVE_MMX |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3018 uint8_t *tmpXchg; |
169 | 3019 #endif |
791 | 3020 if(isColor) |
121 | 3021 { |
957 | 3022 QP= QPptr[x>>qpHShift]; |
3023 c.nonBQP= nonBQPptr[x>>qpHShift]; | |
791 | 3024 } |
3025 else | |
3026 { | |
3027 QP= QPptr[x>>4]; | |
223 | 3028 QP= (QP* QPCorrecture + 256*128)>>16; |
791 | 3029 c.nonBQP= nonBQPptr[x>>4]; |
3030 c.nonBQP= (c.nonBQP* QPCorrecture + 256*128)>>16; | |
148
1cfc4d567c0a
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
142
diff
changeset
|
3031 yHistogram[ srcBlock[srcStride*12 + 4] ]++; |
121 | 3032 } |
787 | 3033 c.QP= QP; |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3034 #ifdef HAVE_MMX |
111 | 3035 asm volatile( |
787 | 3036 "movd %1, %%mm7 \n\t" |
111 | 3037 "packuswb %%mm7, %%mm7 \n\t" // 0, 0, 0, QP, 0, 0, 0, QP |
3038 "packuswb %%mm7, %%mm7 \n\t" // 0,QP, 0, QP, 0,QP, 0, QP | |
3039 "packuswb %%mm7, %%mm7 \n\t" // QP,..., QP | |
787 | 3040 "movq %%mm7, %0 \n\t" |
3041 : "=m" (c.pQPb) | |
3042 : "r" (QP) | |
111 | 3043 ); |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3044 #endif |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3045 |
96 | 3046 |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3047 #ifdef HAVE_MMX2 |
126 | 3048 /* |
3049 prefetchnta(srcBlock + (((x>>2)&6) + 5)*srcStride + 32); | |
3050 prefetchnta(srcBlock + (((x>>2)&6) + 6)*srcStride + 32); | |
3051 prefetcht0(dstBlock + (((x>>2)&6) + 5)*dstStride + 32); | |
3052 prefetcht0(dstBlock + (((x>>2)&6) + 6)*dstStride + 32); | |
3053 */ | |
3054 | |
3055 asm( | |
3056 "movl %4, %%eax \n\t" | |
3057 "shrl $2, %%eax \n\t" | |
3058 "andl $6, %%eax \n\t" | |
164 | 3059 "addl %5, %%eax \n\t" |
787 | 3060 "movl %%eax, %%edx \n\t" |
126 | 3061 "imul %1, %%eax \n\t" |
787 | 3062 "imul %3, %%edx \n\t" |
126 | 3063 "prefetchnta 32(%%eax, %0) \n\t" |
787 | 3064 "prefetcht0 32(%%edx, %2) \n\t" |
126 | 3065 "addl %1, %%eax \n\t" |
787 | 3066 "addl %3, %%edx \n\t" |
126 | 3067 "prefetchnta 32(%%eax, %0) \n\t" |
787 | 3068 "prefetcht0 32(%%edx, %2) \n\t" |
126 | 3069 :: "r" (srcBlock), "r" (srcStride), "r" (dstBlock), "r" (dstStride), |
164 | 3070 "m" (x), "m" (copyAhead) |
787 | 3071 : "%eax", "%edx" |
126 | 3072 ); |
3073 | |
96 | 3074 #elif defined(HAVE_3DNOW) |
3075 //FIXME check if this is faster on an 3dnow chip or if its faster without the prefetch or ... | |
111 | 3076 /* prefetch(srcBlock + (((x>>3)&3) + 5)*srcStride + 32); |
3077 prefetch(srcBlock + (((x>>3)&3) + 9)*srcStride + 32); | |
3078 prefetchw(dstBlock + (((x>>3)&3) + 5)*dstStride + 32); | |
3079 prefetchw(dstBlock + (((x>>3)&3) + 9)*dstStride + 32); | |
96 | 3080 */ |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3081 #endif |
111 | 3082 |
169 | 3083 RENAME(blockCopy)(dstBlock + dstStride*copyAhead, dstStride, |
787 | 3084 srcBlock + srcStride*copyAhead, srcStride, mode & LEVEL_FIX, &c.packedYOffset); |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3085 |
111 | 3086 if(mode & LINEAR_IPOL_DEINT_FILTER) |
169 | 3087 RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride); |
111 | 3088 else if(mode & LINEAR_BLEND_DEINT_FILTER) |
1581 | 3089 RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x); |
111 | 3090 else if(mode & MEDIAN_DEINT_FILTER) |
169 | 3091 RENAME(deInterlaceMedian)(dstBlock, dstStride); |
111 | 3092 else if(mode & CUBIC_IPOL_DEINT_FILTER) |
169 | 3093 RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride); |
787 | 3094 else if(mode & FFMPEG_DEINT_FILTER) |
3095 RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x); | |
1157 | 3096 else if(mode & LOWPASS5_DEINT_FILTER) |
3097 RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x); | |
111 | 3098 /* else if(mode & CUBIC_BLEND_DEINT_FILTER) |
169 | 3099 RENAME(deInterlaceBlendCubic)(dstBlock, dstStride); |
106
389391a6d0bf
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
105
diff
changeset
|
3100 */ |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3101 |
111 | 3102 /* only deblock if we have 2 blocks */ |
3103 if(y + 8 < height) | |
3104 { | |
787 | 3105 if(mode & V_X1_FILTER) |
3106 RENAME(vertX1Filter)(dstBlock, stride, &c); | |
115
4514b8e7f0f1
more logic behavior if the altenative deblock filters are used (turning a alt filter on without turning the deblock filter on uses the alt filter instead of using no filter now)
michael
parents:
113
diff
changeset
|
3107 else if(mode & V_DEBLOCK) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3108 { |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
3109 const int t= RENAME(vertClassify)(dstBlock, stride, &c); |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
3110 |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
3111 if(t==1) |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
3112 RENAME(doVertLowPass)(dstBlock, stride, &c); |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
3113 else if(t==2) |
787 | 3114 RENAME(doVertDefFilter)(dstBlock, stride, &c); |
2037
98d8283534bb
accurate/slow (per line instead of per block) deblock filter spport which is identical to what is recommanded in the mpeg4 spec
michael
parents:
2036
diff
changeset
|
3115 }else if(mode & V_A_DEBLOCK){ |
98d8283534bb
accurate/slow (per line instead of per block) deblock filter spport which is identical to what is recommanded in the mpeg4 spec
michael
parents:
2036
diff
changeset
|
3116 do_a_deblock(dstBlock, stride, 1, &c); |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3117 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3118 } |
130 | 3119 |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3120 #ifdef HAVE_MMX |
169 | 3121 RENAME(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride); |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3122 #endif |
111 | 3123 /* check if we have a previous block to deblock it with dstBlock */ |
112 | 3124 if(x - 8 >= 0) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3125 { |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3126 #ifdef HAVE_MMX |
787 | 3127 if(mode & H_X1_FILTER) |
3128 RENAME(vertX1Filter)(tempBlock1, 16, &c); | |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3129 else if(mode & H_DEBLOCK) |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3130 { |
1327
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
3131 //START_TIMER |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
3132 const int t= RENAME(vertClassify)(tempBlock1, 16, &c); |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
3133 //STOP_TIMER("dc & minmax") |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
3134 if(t==1) |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
3135 RENAME(doVertLowPass)(tempBlock1, 16, &c); |
854571532c89
blinking blocks around thin vertical lines and dots bugfix
michaelni
parents:
1196
diff
changeset
|
3136 else if(t==2) |
787 | 3137 RENAME(doVertDefFilter)(tempBlock1, 16, &c); |
2037
98d8283534bb
accurate/slow (per line instead of per block) deblock filter spport which is identical to what is recommanded in the mpeg4 spec
michael
parents:
2036
diff
changeset
|
3138 }else if(mode & H_A_DEBLOCK){ |
98d8283534bb
accurate/slow (per line instead of per block) deblock filter spport which is identical to what is recommanded in the mpeg4 spec
michael
parents:
2036
diff
changeset
|
3139 do_a_deblock(tempBlock1, 16, 1, &c); |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3140 } |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3141 |
169 | 3142 RENAME(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16); |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3143 |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3144 #else |
115
4514b8e7f0f1
more logic behavior if the altenative deblock filters are used (turning a alt filter on without turning the deblock filter on uses the alt filter instead of using no filter now)
michael
parents:
113
diff
changeset
|
3145 if(mode & H_X1_FILTER) |
4514b8e7f0f1
more logic behavior if the altenative deblock filters are used (turning a alt filter on without turning the deblock filter on uses the alt filter instead of using no filter now)
michael
parents:
113
diff
changeset
|
3146 horizX1Filter(dstBlock-4, stride, QP); |
4514b8e7f0f1
more logic behavior if the altenative deblock filters are used (turning a alt filter on without turning the deblock filter on uses the alt filter instead of using no filter now)
michael
parents:
113
diff
changeset
|
3147 else if(mode & H_DEBLOCK) |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3148 { |
2036
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
3149 const int t= RENAME(horizClassify)(dstBlock-4, stride, &c); |
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
3150 |
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
3151 if(t==1) |
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
3152 RENAME(doHorizLowPass)(dstBlock-4, stride, &c); |
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
3153 else if(t==2) |
6a6c678517b3
altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2031
diff
changeset
|
3154 RENAME(doHorizDefFilter)(dstBlock-4, stride, &c); |
2037
98d8283534bb
accurate/slow (per line instead of per block) deblock filter spport which is identical to what is recommanded in the mpeg4 spec
michael
parents:
2036
diff
changeset
|
3155 }else if(mode & H_A_DEBLOCK){ |
98d8283534bb
accurate/slow (per line instead of per block) deblock filter spport which is identical to what is recommanded in the mpeg4 spec
michael
parents:
2036
diff
changeset
|
3156 do_a_deblock(dstBlock-8, 1, stride, &c); |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3157 } |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3158 #endif |
130 | 3159 if(mode & DERING) |
3160 { | |
3161 //FIXME filter first line | |
787 | 3162 if(y>0) RENAME(dering)(dstBlock - stride - 8, stride, &c); |
130 | 3163 } |
156 | 3164 |
3165 if(mode & TEMP_NOISE_FILTER) | |
3166 { | |
169 | 3167 RENAME(tempNoiseReducer)(dstBlock-8, stride, |
787 | 3168 c.tempBlured[isColor] + y*dstStride + x, |
3169 c.tempBluredPast[isColor] + (y>>3)*256 + (x>>3), | |
3170 c.ppMode.maxTmpNoise); | |
156 | 3171 } |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3172 } |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3173 |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3174 dstBlock+=8; |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3175 srcBlock+=8; |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3176 |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
3177 #ifdef HAVE_MMX |
128
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3178 tmpXchg= tempBlock1; |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3179 tempBlock1= tempBlock2; |
e5266b8e79be
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
126
diff
changeset
|
3180 tempBlock2 = tmpXchg; |
129
be35346e27c1
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
128
diff
changeset
|
3181 #endif |
111 | 3182 } |
3183 | |
156 | 3184 if(mode & DERING) |
3185 { | |
787 | 3186 if(y > 0) RENAME(dering)(dstBlock - dstStride - 8, dstStride, &c); |
156 | 3187 } |
3188 | |
3189 if((mode & TEMP_NOISE_FILTER)) | |
3190 { | |
169 | 3191 RENAME(tempNoiseReducer)(dstBlock-8, dstStride, |
787 | 3192 c.tempBlured[isColor] + y*dstStride + x, |
3193 c.tempBluredPast[isColor] + (y>>3)*256 + (x>>3), | |
3194 c.ppMode.maxTmpNoise); | |
156 | 3195 } |
3196 | |
142 | 3197 /* did we use a tmp buffer for the last lines*/ |
112 | 3198 if(y+15 >= height) |
111 | 3199 { |
3200 uint8_t *dstBlock= &(dst[y*dstStride]); | |
941 | 3201 if(width==dstStride) |
3202 memcpy(dstBlock, tempDst + dstStride, dstStride*(height-y)); | |
3203 else | |
3204 { | |
944 | 3205 int i; |
941 | 3206 for(i=0; i<height-y; i++) |
3207 { | |
3208 memcpy(dstBlock + i*dstStride, tempDst + (i+1)*dstStride, width); | |
3209 } | |
3210 } | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3211 } |
163 | 3212 /* |
3213 for(x=0; x<width; x+=32) | |
3214 { | |
164 | 3215 volatile int i; |
163 | 3216 i+= + dstBlock[x + 7*dstStride] + dstBlock[x + 8*dstStride] |
3217 + dstBlock[x + 9*dstStride] + dstBlock[x +10*dstStride] | |
164 | 3218 + dstBlock[x +11*dstStride] + dstBlock[x +12*dstStride]; |
3219 // + dstBlock[x +13*dstStride] | |
3220 // + dstBlock[x +14*dstStride] + dstBlock[x +15*dstStride]; | |
3221 }*/ | |
3222 } | |
96 | 3223 #ifdef HAVE_3DNOW |
3224 asm volatile("femms"); | |
3225 #elif defined (HAVE_MMX) | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3226 asm volatile("emms"); |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3227 #endif |
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3228 |
163 | 3229 #ifdef DEBUG_BRIGHTNESS |
3230 if(!isColor) | |
3231 { | |
3232 int max=1; | |
3233 int i; | |
3234 for(i=0; i<256; i++) | |
3235 if(yHistogram[i] > max) max=yHistogram[i]; | |
3236 | |
3237 for(i=1; i<256; i++) | |
3238 { | |
3239 int x; | |
3240 int start=yHistogram[i-1]/(max/256+1); | |
3241 int end=yHistogram[i]/(max/256+1); | |
3242 int inc= end > start ? 1 : -1; | |
3243 for(x=start; x!=end+inc; x+=inc) | |
3244 dst[ i*dstStride + x]+=128; | |
3245 } | |
3246 | |
3247 for(i=0; i<100; i+=2) | |
3248 { | |
3249 dst[ (white)*dstStride + i]+=128; | |
3250 dst[ (black)*dstStride + i]+=128; | |
3251 } | |
3252 | |
3253 } | |
3254 #endif | |
3255 | |
787 | 3256 *c2= c; //copy local context back |
3257 | |
95
8bce253b537c
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3258 } |