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