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