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