Mercurial > mplayer.hg
annotate postproc/postprocess.c @ 2871:ac3cd4680838
10l
author | gabucino |
---|---|
date | Tue, 13 Nov 2001 17:44:38 +0000 |
parents | 08b833fb875a |
children | dd3fabd01df0 |
rev | line source |
---|---|
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1 /* |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2 Copyright (C) 2001 Michael Niedermayer (michaelni@gmx.at) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3 |
508468a75be0
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 |
508468a75be0
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 |
508468a75be0
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 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
7 (at your option) any later version. |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
8 |
508468a75be0
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, |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
12 GNU General Public License for more details. |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
13 |
508468a75be0
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 |
508468a75be0
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 |
508468a75be0
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 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
17 */ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
18 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
19 /* |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
20 C MMX MMX2 3DNow |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
21 isVertDC Ec Ec |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
22 isVertMinMaxOk Ec Ec |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
23 doVertLowPass E e e |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
24 doVertDefFilter Ec Ec Ec |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
25 isHorizDC Ec Ec |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
26 isHorizMinMaxOk a E |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
27 doHorizLowPass E e e |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
28 doHorizDefFilter Ec Ec Ec |
2477 | 29 deRing E e e* |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
30 Vertical RKAlgo1 E a a |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
31 Horizontal RKAlgo1 a a |
2860 | 32 Vertical X1# a E E |
33 Horizontal X1# a E E | |
2246 | 34 LinIpolDeinterlace e E E* |
35 CubicIpolDeinterlace a e e* | |
36 LinBlendDeinterlace e E E* | |
2860 | 37 MedianDeinterlace# Ec Ec |
38 TempDeNoiser# a | |
39 | |
40 * i dont have a 3dnow CPU -> its untested, but noone said it doesnt work so it seems to work | |
41 # more or less selfinvented filters so the exactness isnt too meaningfull | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
42 E = Exact implementation |
2246 | 43 e = allmost exact implementation (slightly different rounding,...) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
44 a = alternative / approximate impl |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
45 c = checked against the other implementations (-vo md5) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
46 */ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
47 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
48 /* |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
49 TODO: |
2179 | 50 verify that everything workes as it should (how?) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
51 reduce the time wasted on the mem transfer |
2159 | 52 implement everything in C at least (done at the moment but ...) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
53 unroll stuff if instructions depend too much on the prior one |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
54 we use 8x8 blocks for the horizontal filters, opendivx seems to use 8x4? |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
55 move YScale thing to the end instead of fixing QP |
2159 | 56 write a faster and higher quality deblocking filter :) |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
57 make the mainloop more flexible (variable number of blocks at once |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
58 (the if/else stuff per block is slowing things down) |
2179 | 59 compare the quality & speed of all filters |
60 split this huge file | |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
61 border remover |
2570 | 62 optimize c versions |
2860 | 63 try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
64 ... |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
65 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
66 Notes: |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
67 */ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
68 |
2221 | 69 //Changelog: use the CVS log |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
70 |
2775 | 71 #include "../config.h" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
72 #include <inttypes.h> |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
73 #include <stdio.h> |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
74 #include <stdlib.h> |
2389 | 75 #include <string.h> |
2476 | 76 #ifdef HAVE_MALLOC_H |
77 #include <malloc.h> | |
78 #endif | |
2159 | 79 //#undef HAVE_MMX2 |
80 //#define HAVE_3DNOW | |
81 //#undef HAVE_MMX | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
82 #include "postprocess.h" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
83 |
2189 | 84 #define MIN(a,b) ((a) > (b) ? (b) : (a)) |
85 #define MAX(a,b) ((a) < (b) ? (b) : (a)) | |
86 #define ABS(a) ((a) > 0 ? (a) : (-(a))) | |
87 #define SIGN(a) ((a) > 0 ? 1 : -1) | |
88 | |
89 #ifdef HAVE_MMX2 | |
90 #define PAVGB(a,b) "pavgb " #a ", " #b " \n\t" | |
91 #elif defined (HAVE_3DNOW) | |
92 #define PAVGB(a,b) "pavgusb " #a ", " #b " \n\t" | |
93 #endif | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
94 |
2477 | 95 #ifdef HAVE_MMX2 |
96 #define PMINUB(a,b,t) "pminub " #a ", " #b " \n\t" | |
97 #elif defined (HAVE_MMX) | |
98 #define PMINUB(b,a,t) \ | |
99 "movq " #a ", " #t " \n\t"\ | |
100 "psubusb " #b ", " #t " \n\t"\ | |
101 "psubb " #t ", " #a " \n\t" | |
102 #endif | |
103 | |
104 #ifdef HAVE_MMX2 | |
105 #define PMAXUB(a,b) "pmaxub " #a ", " #b " \n\t" | |
106 #elif defined (HAVE_MMX) | |
107 #define PMAXUB(a,b) \ | |
108 "psubusb " #a ", " #b " \n\t"\ | |
109 "paddb " #a ", " #b " \n\t" | |
110 #endif | |
111 | |
112 | |
2389 | 113 #define GET_MODE_BUFFER_SIZE 500 |
114 #define OPTIONS_ARRAY_SIZE 10 | |
115 | |
2742
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
116 #ifdef HAVE_MMX |
2750
9ef09e232505
gcc does optimize writes to non volatile variables away if it didnt know that they were read in between
michael
parents:
2742
diff
changeset
|
117 static volatile uint64_t __attribute__((aligned(8))) packedYOffset= 0x0000000000000000LL; |
9ef09e232505
gcc does optimize writes to non volatile variables away if it didnt know that they were read in between
michael
parents:
2742
diff
changeset
|
118 static volatile uint64_t __attribute__((aligned(8))) packedYScale= 0x0100010001000100LL; |
2742
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
119 static uint64_t __attribute__((aligned(8))) w05= 0x0005000500050005LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
120 static uint64_t __attribute__((aligned(8))) w20= 0x0020002000200020LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
121 static uint64_t __attribute__((aligned(8))) w1400= 0x1400140014001400LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
122 static uint64_t __attribute__((aligned(8))) bm00000001= 0x00000000000000FFLL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
123 static uint64_t __attribute__((aligned(8))) bm00010000= 0x000000FF00000000LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
124 static uint64_t __attribute__((aligned(8))) bm00001000= 0x00000000FF000000LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
125 static uint64_t __attribute__((aligned(8))) bm10000000= 0xFF00000000000000LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
126 static uint64_t __attribute__((aligned(8))) bm10000001= 0xFF000000000000FFLL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
127 static uint64_t __attribute__((aligned(8))) bm11000011= 0xFFFF00000000FFFFLL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
128 static uint64_t __attribute__((aligned(8))) bm00000011= 0x000000000000FFFFLL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
129 static uint64_t __attribute__((aligned(8))) bm11111110= 0xFFFFFFFFFFFFFF00LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
130 static uint64_t __attribute__((aligned(8))) bm11000000= 0xFFFF000000000000LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
131 static uint64_t __attribute__((aligned(8))) bm00011000= 0x000000FFFF000000LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
132 static uint64_t __attribute__((aligned(8))) bm00110011= 0x0000FFFF0000FFFFLL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
133 static uint64_t __attribute__((aligned(8))) bm11001100= 0xFFFF0000FFFF0000LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
134 static uint64_t __attribute__((aligned(8))) b00= 0x0000000000000000LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
135 static uint64_t __attribute__((aligned(8))) b01= 0x0101010101010101LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
136 static uint64_t __attribute__((aligned(8))) b02= 0x0202020202020202LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
137 static uint64_t __attribute__((aligned(8))) b0F= 0x0F0F0F0F0F0F0F0FLL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
138 static uint64_t __attribute__((aligned(8))) b04= 0x0404040404040404LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
139 static uint64_t __attribute__((aligned(8))) b08= 0x0808080808080808LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
140 static uint64_t __attribute__((aligned(8))) bFF= 0xFFFFFFFFFFFFFFFFLL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
141 static uint64_t __attribute__((aligned(8))) b20= 0x2020202020202020LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
142 static uint64_t __attribute__((aligned(8))) b80= 0x8080808080808080LL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
143 static uint64_t __attribute__((aligned(8))) b7E= 0x7E7E7E7E7E7E7E7ELL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
144 static uint64_t __attribute__((aligned(8))) b7C= 0x7C7C7C7C7C7C7C7CLL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
145 static uint64_t __attribute__((aligned(8))) b3F= 0x3F3F3F3F3F3F3F3FLL; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
146 static uint64_t __attribute__((aligned(8))) temp0=0; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
147 static uint64_t __attribute__((aligned(8))) temp1=0; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
148 static uint64_t __attribute__((aligned(8))) temp2=0; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
149 static uint64_t __attribute__((aligned(8))) temp3=0; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
150 static uint64_t __attribute__((aligned(8))) temp4=0; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
151 static uint64_t __attribute__((aligned(8))) temp5=0; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
152 static uint64_t __attribute__((aligned(8))) pQPb=0; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
153 static uint64_t __attribute__((aligned(8))) pQPb2=0; |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
154 static uint8_t __attribute__((aligned(8))) tempBlocks[8*16*2]; //used for the horizontal code |
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
155 #else |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
156 static uint64_t packedYOffset= 0x0000000000000000LL; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
157 static uint64_t packedYScale= 0x0100010001000100LL; |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
158 static uint8_t tempBlocks[8*16*2]; //used for the horizontal code |
2742
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
159 #endif |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
160 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
161 int hFlatnessThreshold= 56 - 16; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
162 int vFlatnessThreshold= 56 - 16; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
163 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
164 //amount of "black" u r willing to loose to get a brightness corrected picture |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
165 double maxClippedThreshold= 0.01; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
166 |
2389 | 167 int maxAllowedY=234; |
2285 | 168 int minAllowedY=16; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
169 |
2389 | 170 static struct PPFilter filters[]= |
171 { | |
172 {"hb", "hdeblock", 1, 1, 3, H_DEBLOCK}, | |
173 {"vb", "vdeblock", 1, 2, 4, V_DEBLOCK}, | |
174 {"vr", "rkvdeblock", 1, 2, 4, H_RK1_FILTER}, | |
175 {"h1", "x1hdeblock", 1, 1, 3, H_X1_FILTER}, | |
176 {"v1", "x1vdeblock", 1, 2, 4, V_X1_FILTER}, | |
177 {"dr", "dering", 1, 5, 6, DERING}, | |
178 {"al", "autolevels", 0, 1, 2, LEVEL_FIX}, | |
179 {"lb", "linblenddeint", 0, 1, 6, LINEAR_BLEND_DEINT_FILTER}, | |
180 {"li", "linipoldeint", 0, 1, 6, LINEAR_IPOL_DEINT_FILTER}, | |
181 {"ci", "cubicipoldeint", 0, 1, 6, CUBIC_IPOL_DEINT_FILTER}, | |
182 {"md", "mediandeint", 0, 1, 6, MEDIAN_DEINT_FILTER}, | |
2860 | 183 {"tn", "tmpnoise", 1, 7, 8, TEMP_NOISE_FILTER}, |
2389 | 184 {NULL, NULL,0,0,0,0} //End Marker |
185 }; | |
186 | |
187 static char *replaceTable[]= | |
188 { | |
2860 | 189 "default", "hdeblock:a,vdeblock:a,dering:a,autolevels,tmpnoise:a:150:200:400", |
190 "de", "hdeblock:a,vdeblock:a,dering:a,autolevels,tmpnoise:a:150:200:400", | |
191 "fast", "x1hdeblock:a,x1vdeblock:a,dering:a,autolevels,tmpnoise:a:150:200:400", | |
192 "fa", "x1hdeblock:a,x1vdeblock:a,dering:a,autolevels,tmpnoise:a:150:200:400", | |
2389 | 193 NULL //End Marker |
194 }; | |
195 | |
2742
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
196 #ifdef HAVE_MMX |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
197 static inline void unusedVariableWarningFixer() |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
198 { |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
199 if( |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
200 packedYOffset + packedYScale + w05 + w20 + w1400 + bm00000001 + bm00010000 |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
201 + bm00001000 + bm10000000 + bm10000001 + bm11000011 + bm00000011 + bm11111110 |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
202 + bm11000000 + bm00011000 + bm00110011 + bm11001100 + b00 + b01 + b02 + b0F |
2742
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
203 + bFF + b20 + b04+ b08 + pQPb2 + b80 + b7E + b7C + b3F + temp0 + temp1 + temp2 + temp3 + temp4 |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
204 + temp5 + pQPb== 0) b00=0; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
205 } |
2742
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
206 #endif |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
207 |
2221 | 208 #ifdef TIMING |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
209 static inline long long rdtsc() |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
210 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
211 long long l; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
212 asm volatile( "rdtsc\n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
213 : "=A" (l) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
214 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
215 // printf("%d\n", int(l/1000)); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
216 return l; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
217 } |
2185 | 218 #endif |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
219 |
2185 | 220 #ifdef HAVE_MMX2 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
221 static inline void prefetchnta(void *p) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
222 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
223 asm volatile( "prefetchnta (%0)\n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
224 : : "r" (p) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
225 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
226 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
227 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
228 static inline void prefetcht0(void *p) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
229 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
230 asm volatile( "prefetcht0 (%0)\n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
231 : : "r" (p) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
232 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
233 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
234 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
235 static inline void prefetcht1(void *p) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
236 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
237 asm volatile( "prefetcht1 (%0)\n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
238 : : "r" (p) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
239 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
240 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
241 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
242 static inline void prefetcht2(void *p) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
243 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
244 asm volatile( "prefetcht2 (%0)\n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
245 : : "r" (p) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
246 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
247 } |
2185 | 248 #endif |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
249 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
250 //FIXME? |255-0| = 1 (shouldnt be a problem ...) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
251 /** |
2246 | 252 * Check if the middle 8x8 Block in the given 8x16 block is flat |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
253 */ |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
254 static inline int isVertDC(uint8_t src[], int stride){ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
255 int numEq= 0; |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
256 #ifndef HAVE_MMX |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
257 int y; |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
258 #endif |
2246 | 259 src+= stride*4; // src points to begin of the 8x8 Block |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
260 #ifdef HAVE_MMX |
2413 | 261 asm volatile( |
262 "leal (%1, %2), %%eax \n\t" | |
263 "leal (%%eax, %2, 4), %%ebx \n\t" | |
264 // 0 1 2 3 4 5 6 7 8 9 | |
265 // %1 eax eax+%2 eax+2%2 %1+4%2 ebx ebx+%2 ebx+2%2 %1+8%2 ebx+4%2 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
266 "movq b7E, %%mm7 \n\t" // mm7 = 0x7F |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
267 "movq b7C, %%mm6 \n\t" // mm6 = 0x7D |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
268 "movq (%1), %%mm0 \n\t" |
2413 | 269 "movq (%%eax), %%mm1 \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
270 "psubb %%mm1, %%mm0 \n\t" // mm0 = differnece |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
271 "paddb %%mm7, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
272 "pcmpgtb %%mm6, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
273 |
2413 | 274 "movq (%%eax,%2), %%mm2 \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
275 "psubb %%mm2, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
276 "paddb %%mm7, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
277 "pcmpgtb %%mm6, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
278 "paddb %%mm1, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
279 |
2413 | 280 "movq (%%eax, %2, 2), %%mm1 \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
281 "psubb %%mm1, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
282 "paddb %%mm7, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
283 "pcmpgtb %%mm6, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
284 "paddb %%mm2, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
285 |
2413 | 286 "movq (%1, %2, 4), %%mm2 \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
287 "psubb %%mm2, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
288 "paddb %%mm7, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
289 "pcmpgtb %%mm6, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
290 "paddb %%mm1, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
291 |
2413 | 292 "movq (%%ebx), %%mm1 \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
293 "psubb %%mm1, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
294 "paddb %%mm7, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
295 "pcmpgtb %%mm6, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
296 "paddb %%mm2, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
297 |
2413 | 298 "movq (%%ebx, %2), %%mm2 \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
299 "psubb %%mm2, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
300 "paddb %%mm7, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
301 "pcmpgtb %%mm6, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
302 "paddb %%mm1, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
303 |
2413 | 304 "movq (%%ebx, %2, 2), %%mm1 \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
305 "psubb %%mm1, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
306 "paddb %%mm7, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
307 "pcmpgtb %%mm6, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
308 "paddb %%mm2, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
309 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
310 " \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
311 "movq %%mm0, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
312 "psrlw $8, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
313 "paddb %%mm1, %%mm0 \n\t" |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
314 #ifdef HAVE_MMX2 |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
315 "pshufw $0xF9, %%mm0, %%mm1 \n\t" |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
316 "paddb %%mm1, %%mm0 \n\t" |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
317 "pshufw $0xFE, %%mm0, %%mm1 \n\t" |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
318 #else |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
319 "movq %%mm0, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
320 "psrlq $16, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
321 "paddb %%mm1, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
322 "movq %%mm0, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
323 "psrlq $32, %%mm0 \n\t" |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
324 #endif |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
325 "paddb %%mm1, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
326 "movd %%mm0, %0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
327 : "=r" (numEq) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
328 : "r" (src), "r" (stride) |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
329 : "%eax", "%ebx" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
330 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
331 |
2413 | 332 numEq= (256 - numEq) &0xFF; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
333 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
334 #else |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
335 for(y=0; y<BLOCK_SIZE-1; y++) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
336 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
337 if(((src[0] - src[0+stride] + 1)&0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
338 if(((src[1] - src[1+stride] + 1)&0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
339 if(((src[2] - src[2+stride] + 1)&0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
340 if(((src[3] - src[3+stride] + 1)&0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
341 if(((src[4] - src[4+stride] + 1)&0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
342 if(((src[5] - src[5+stride] + 1)&0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
343 if(((src[6] - src[6+stride] + 1)&0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
344 if(((src[7] - src[7+stride] + 1)&0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
345 src+= stride; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
346 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
347 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
348 /* if(abs(numEq - asmEq) > 0) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
349 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
350 printf("\nasm:%d c:%d\n", asmEq, numEq); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
351 for(int y=0; y<8; y++) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
352 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
353 for(int x=0; x<8; x++) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
354 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
355 printf("%d ", temp[x + y*stride]); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
356 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
357 printf("\n"); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
358 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
359 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
360 */ |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
361 // for(int i=0; i<numEq/8; i++) src[i]=255; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
362 return (numEq > vFlatnessThreshold) ? 1 : 0; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
363 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
364 |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
365 static inline int isVertMinMaxOk(uint8_t src[], int stride, int QP) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
366 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
367 #ifdef HAVE_MMX |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
368 int isOk; |
2246 | 369 src+= stride*3; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
370 asm volatile( |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
371 // "int $3 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
372 "movq (%1, %2), %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
373 "movq (%1, %2, 8), %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
374 "movq %%mm0, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
375 "psubusb %%mm1, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
376 "psubusb %%mm2, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
377 "por %%mm1, %%mm0 \n\t" // ABS Diff |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
378 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
379 "movq pQPb, %%mm7 \n\t" // QP,..., QP |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
380 "paddusb %%mm7, %%mm7 \n\t" // 2QP ... 2QP |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
381 "psubusb %%mm7, %%mm0 \n\t" // Diff <= 2QP -> 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
382 "pcmpeqd b00, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
383 "psrlq $16, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
384 "pcmpeqd bFF, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
385 // "movd %%mm0, (%1, %2, 4)\n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
386 "movd %%mm0, %0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
387 : "=r" (isOk) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
388 : "r" (src), "r" (stride) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
389 ); |
2416 | 390 return isOk; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
391 #else |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
392 |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
393 int isOk2= 1; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
394 int x; |
2246 | 395 src+= stride*3; |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
396 for(x=0; x<BLOCK_SIZE; x++) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
397 { |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
398 if(abs((int)src[x + stride] - (int)src[x + (stride<<3)]) > 2*QP) isOk2=0; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
399 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
400 /* if(isOk && !isOk2 || !isOk && isOk2) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
401 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
402 printf("\nasm:%d c:%d QP:%d\n", isOk, isOk2, QP); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
403 for(int y=0; y<9; y++) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
404 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
405 for(int x=0; x<8; x++) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
406 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
407 printf("%d ", src[x + y*stride]); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
408 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
409 printf("\n"); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
410 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
411 } */ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
412 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
413 return isOk2; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
414 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
415 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
416 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
417 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
418 /** |
2246 | 419 * Do a vertical low pass filter on the 8x16 block (only write to the 8x8 block in the middle) |
2221 | 420 * using the 9-Tap Filter (1,1,2,2,4,2,2,1,1)/16 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
421 */ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
422 static inline void doVertLowPass(uint8_t *src, int stride, int QP) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
423 { |
2159 | 424 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
2246 | 425 src+= stride*3; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
426 asm volatile( //"movv %0 %1 %2\n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
427 "movq pQPb, %%mm0 \n\t" // QP,..., QP |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
428 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
429 "movq (%0), %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
430 "movq (%0, %1), %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
431 "movq %%mm5, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
432 "movq %%mm6, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
433 "psubusb %%mm6, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
434 "psubusb %%mm1, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
435 "por %%mm5, %%mm2 \n\t" // ABS Diff of lines |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
436 "psubusb %%mm0, %%mm2 \n\t" // diff <= QP -> 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
437 "pcmpeqb b00, %%mm2 \n\t" // diff <= QP -> FF |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
438 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
439 "pand %%mm2, %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
440 "pandn %%mm1, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
441 "por %%mm2, %%mm6 \n\t"// First Line to Filter |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
442 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
443 "movq (%0, %1, 8), %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
444 "leal (%0, %1, 4), %%eax \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
445 "leal (%0, %1, 8), %%ebx \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
446 "subl %1, %%ebx \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
447 "addl %1, %0 \n\t" // %0 points to line 1 not 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
448 "movq (%0, %1, 8), %%mm7 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
449 "movq %%mm5, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
450 "movq %%mm7, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
451 "psubusb %%mm7, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
452 "psubusb %%mm1, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
453 "por %%mm5, %%mm2 \n\t" // ABS Diff of lines |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
454 "psubusb %%mm0, %%mm2 \n\t" // diff <= QP -> 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
455 "pcmpeqb b00, %%mm2 \n\t" // diff <= QP -> FF |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
456 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
457 "pand %%mm2, %%mm7 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
458 "pandn %%mm1, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
459 "por %%mm2, %%mm7 \n\t" // First Line to Filter |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
460 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
461 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
462 // 1 2 3 4 5 6 7 8 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
463 // %0 %0+%1 %0+2%1 eax %0+4%1 eax+2%1 ebx eax+4%1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
464 // 6 4 2 2 1 1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
465 // 6 4 4 2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
466 // 6 8 2 |
2246 | 467 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
468 "movq (%0, %1), %%mm0 \n\t" // 1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
469 "movq %%mm0, %%mm1 \n\t" // 1 |
2159 | 470 PAVGB(%%mm6, %%mm0) //1 1 /2 |
471 PAVGB(%%mm6, %%mm0) //3 1 /4 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
472 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
473 "movq (%0, %1, 4), %%mm2 \n\t" // 1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
474 "movq %%mm2, %%mm5 \n\t" // 1 |
2159 | 475 PAVGB((%%eax), %%mm2) // 11 /2 |
476 PAVGB((%0, %1, 2), %%mm2) // 211 /4 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
477 "movq %%mm2, %%mm3 \n\t" // 211 /4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
478 "movq (%0), %%mm4 \n\t" // 1 |
2159 | 479 PAVGB(%%mm4, %%mm3) // 4 211 /8 |
480 PAVGB(%%mm0, %%mm3) //642211 /16 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
481 "movq %%mm3, (%0) \n\t" // X |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
482 // mm1=2 mm2=3(211) mm4=1 mm5=5 mm6=0 mm7=9 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
483 "movq %%mm1, %%mm0 \n\t" // 1 |
2159 | 484 PAVGB(%%mm6, %%mm0) //1 1 /2 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
485 "movq %%mm4, %%mm3 \n\t" // 1 |
2159 | 486 PAVGB((%0,%1,2), %%mm3) // 1 1 /2 |
487 PAVGB((%%eax,%1,2), %%mm5) // 11 /2 | |
488 PAVGB((%%eax), %%mm5) // 211 /4 | |
489 PAVGB(%%mm5, %%mm3) // 2 2211 /8 | |
490 PAVGB(%%mm0, %%mm3) //4242211 /16 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
491 "movq %%mm3, (%0,%1) \n\t" // X |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
492 // mm1=2 mm2=3(211) mm4=1 mm5=4(211) mm6=0 mm7=9 |
2159 | 493 PAVGB(%%mm4, %%mm6) //11 /2 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
494 "movq (%%ebx), %%mm0 \n\t" // 1 |
2159 | 495 PAVGB((%%eax, %1, 2), %%mm0) // 11/2 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
496 "movq %%mm0, %%mm3 \n\t" // 11/2 |
2159 | 497 PAVGB(%%mm1, %%mm0) // 2 11/4 |
498 PAVGB(%%mm6, %%mm0) //222 11/8 | |
499 PAVGB(%%mm2, %%mm0) //22242211/16 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
500 "movq (%0, %1, 2), %%mm2 \n\t" // 1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
501 "movq %%mm0, (%0, %1, 2) \n\t" // X |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
502 // mm1=2 mm2=3 mm3=6(11) mm4=1 mm5=4(211) mm6=0(11) mm7=9 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
503 "movq (%%eax, %1, 4), %%mm0 \n\t" // 1 |
2159 | 504 PAVGB((%%ebx), %%mm0) // 11 /2 |
505 PAVGB(%%mm0, %%mm6) //11 11 /4 | |
506 PAVGB(%%mm1, %%mm4) // 11 /2 | |
507 PAVGB(%%mm2, %%mm1) // 11 /2 | |
508 PAVGB(%%mm1, %%mm6) //1122 11 /8 | |
509 PAVGB(%%mm5, %%mm6) //112242211 /16 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
510 "movq (%%eax), %%mm5 \n\t" // 1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
511 "movq %%mm6, (%%eax) \n\t" // X |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
512 // mm0=7(11) mm1=2(11) mm2=3 mm3=6(11) mm4=1(11) mm5=4 mm7=9 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
513 "movq (%%eax, %1, 4), %%mm6 \n\t" // 1 |
2159 | 514 PAVGB(%%mm7, %%mm6) // 11 /2 |
515 PAVGB(%%mm4, %%mm6) // 11 11 /4 | |
516 PAVGB(%%mm3, %%mm6) // 11 2211 /8 | |
517 PAVGB(%%mm5, %%mm2) // 11 /2 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
518 "movq (%0, %1, 4), %%mm4 \n\t" // 1 |
2159 | 519 PAVGB(%%mm4, %%mm2) // 112 /4 |
520 PAVGB(%%mm2, %%mm6) // 112242211 /16 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
521 "movq %%mm6, (%0, %1, 4) \n\t" // X |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
522 // mm0=7(11) mm1=2(11) mm2=3(112) mm3=6(11) mm4=5 mm5=4 mm7=9 |
2159 | 523 PAVGB(%%mm7, %%mm1) // 11 2 /4 |
524 PAVGB(%%mm4, %%mm5) // 11 /2 | |
525 PAVGB(%%mm5, %%mm0) // 11 11 /4 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
526 "movq (%%eax, %1, 2), %%mm6 \n\t" // 1 |
2159 | 527 PAVGB(%%mm6, %%mm1) // 11 4 2 /8 |
528 PAVGB(%%mm0, %%mm1) // 11224222 /16 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
529 "movq %%mm1, (%%eax, %1, 2) \n\t" // X |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
530 // mm2=3(112) mm3=6(11) mm4=5 mm5=4(11) mm6=6 mm7=9 |
2159 | 531 PAVGB((%%ebx), %%mm2) // 112 4 /8 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
532 "movq (%%eax, %1, 4), %%mm0 \n\t" // 1 |
2159 | 533 PAVGB(%%mm0, %%mm6) // 1 1 /2 |
534 PAVGB(%%mm7, %%mm6) // 1 12 /4 | |
535 PAVGB(%%mm2, %%mm6) // 1122424 /4 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
536 "movq %%mm6, (%%ebx) \n\t" // X |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
537 // mm0=8 mm3=6(11) mm4=5 mm5=4(11) mm7=9 |
2159 | 538 PAVGB(%%mm7, %%mm5) // 11 2 /4 |
539 PAVGB(%%mm7, %%mm5) // 11 6 /8 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
540 |
2159 | 541 PAVGB(%%mm3, %%mm0) // 112 /4 |
542 PAVGB(%%mm0, %%mm5) // 112246 /16 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
543 "movq %%mm5, (%%eax, %1, 4) \n\t" // X |
2570 | 544 "subl %1, %0 \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
545 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
546 : |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
547 : "r" (src), "r" (stride) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
548 : "%eax", "%ebx" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
549 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
550 #else |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
551 const int l1= stride; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
552 const int l2= stride + l1; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
553 const int l3= stride + l2; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
554 const int l4= stride + l3; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
555 const int l5= stride + l4; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
556 const int l6= stride + l5; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
557 const int l7= stride + l6; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
558 const int l8= stride + l7; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
559 const int l9= stride + l8; |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
560 int x; |
2246 | 561 src+= stride*3; |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
562 for(x=0; x<BLOCK_SIZE; x++) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
563 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
564 const int first= ABS(src[0] - src[l1]) < QP ? src[0] : src[l1]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
565 const int last= ABS(src[l8] - src[l9]) < QP ? src[l9] : src[l8]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
566 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
567 int sums[9]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
568 sums[0] = first + src[l1]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
569 sums[1] = src[l1] + src[l2]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
570 sums[2] = src[l2] + src[l3]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
571 sums[3] = src[l3] + src[l4]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
572 sums[4] = src[l4] + src[l5]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
573 sums[5] = src[l5] + src[l6]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
574 sums[6] = src[l6] + src[l7]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
575 sums[7] = src[l7] + src[l8]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
576 sums[8] = src[l8] + last; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
577 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
578 src[l1]= ((sums[0]<<2) + ((first + sums[2])<<1) + sums[4] + 8)>>4; |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
579 src[l2]= ((src[l2]<<2) + ((first + sums[0] + sums[3])<<1) + sums[5] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
580 src[l3]= ((src[l3]<<2) + ((first + sums[1] + sums[4])<<1) + sums[6] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
581 src[l4]= ((src[l4]<<2) + ((sums[2] + sums[5])<<1) + sums[0] + sums[7] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
582 src[l5]= ((src[l5]<<2) + ((sums[3] + sums[6])<<1) + sums[1] + sums[8] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
583 src[l6]= ((src[l6]<<2) + ((last + sums[7] + sums[4])<<1) + sums[2] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
584 src[l7]= (((last + src[l7])<<2) + ((src[l8] + sums[5])<<1) + sums[3] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
585 src[l8]= ((sums[8]<<2) + ((last + sums[6])<<1) + sums[4] + 8)>>4; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
586 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
587 src++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
588 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
589 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
590 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
591 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
592 |
2159 | 593 /** |
594 * Experimental implementation of the filter (Algorithm 1) described in a paper from Ramkishor & Karandikar | |
595 * values are correctly clipped (MMX2) | |
596 * values are wraparound (C) | |
597 * conclusion: its fast, but introduces ugly horizontal patterns if there is a continious gradient | |
598 0 8 16 24 | |
599 x = 8 | |
600 x/2 = 4 | |
601 x/8 = 1 | |
602 1 12 12 23 | |
603 */ | |
2179 | 604 static inline void vertRK1Filter(uint8_t *src, int stride, int QP) |
2159 | 605 { |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
606 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
2246 | 607 src+= stride*3; |
2159 | 608 // FIXME rounding |
609 asm volatile( | |
610 "pxor %%mm7, %%mm7 \n\t" // 0 | |
611 "movq b80, %%mm6 \n\t" // MIN_SIGNED_BYTE | |
612 "leal (%0, %1), %%eax \n\t" | |
613 "leal (%%eax, %1, 4), %%ebx \n\t" | |
614 // 0 1 2 3 4 5 6 7 8 9 | |
615 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 | |
616 "movq pQPb, %%mm0 \n\t" // QP,..., QP | |
617 "movq %%mm0, %%mm1 \n\t" // QP,..., QP | |
618 "paddusb b02, %%mm0 \n\t" | |
619 "psrlw $2, %%mm0 \n\t" | |
620 "pand b3F, %%mm0 \n\t" // QP/4,..., QP/4 | |
621 "paddusb %%mm1, %%mm0 \n\t" // QP*1.25 ... | |
622 "movq (%0, %1, 4), %%mm2 \n\t" // line 4 | |
623 "movq (%%ebx), %%mm3 \n\t" // line 5 | |
624 "movq %%mm2, %%mm4 \n\t" // line 4 | |
625 "pcmpeqb %%mm5, %%mm5 \n\t" // -1 | |
626 "pxor %%mm2, %%mm5 \n\t" // -line 4 - 1 | |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
627 PAVGB(%%mm3, %%mm5) |
2159 | 628 "paddb %%mm6, %%mm5 \n\t" // (l5-l4)/2 |
629 "psubusb %%mm3, %%mm4 \n\t" | |
630 "psubusb %%mm2, %%mm3 \n\t" | |
631 "por %%mm3, %%mm4 \n\t" // |l4 - l5| | |
632 "psubusb %%mm0, %%mm4 \n\t" | |
633 "pcmpeqb %%mm7, %%mm4 \n\t" | |
634 "pand %%mm4, %%mm5 \n\t" // d/2 | |
635 | |
636 // "paddb %%mm6, %%mm2 \n\t" // line 4 + 0x80 | |
637 "paddb %%mm5, %%mm2 \n\t" | |
638 // "psubb %%mm6, %%mm2 \n\t" | |
639 "movq %%mm2, (%0,%1, 4) \n\t" | |
640 | |
641 "movq (%%ebx), %%mm2 \n\t" | |
642 // "paddb %%mm6, %%mm2 \n\t" // line 5 + 0x80 | |
643 "psubb %%mm5, %%mm2 \n\t" | |
644 // "psubb %%mm6, %%mm2 \n\t" | |
645 "movq %%mm2, (%%ebx) \n\t" | |
646 | |
647 "paddb %%mm6, %%mm5 \n\t" | |
648 "psrlw $2, %%mm5 \n\t" | |
649 "pand b3F, %%mm5 \n\t" | |
650 "psubb b20, %%mm5 \n\t" // (l5-l4)/8 | |
651 | |
652 "movq (%%eax, %1, 2), %%mm2 \n\t" | |
653 "paddb %%mm6, %%mm2 \n\t" // line 3 + 0x80 | |
654 "paddsb %%mm5, %%mm2 \n\t" | |
655 "psubb %%mm6, %%mm2 \n\t" | |
656 "movq %%mm2, (%%eax, %1, 2) \n\t" | |
657 | |
658 "movq (%%ebx, %1), %%mm2 \n\t" | |
659 "paddb %%mm6, %%mm2 \n\t" // line 6 + 0x80 | |
660 "psubsb %%mm5, %%mm2 \n\t" | |
661 "psubb %%mm6, %%mm2 \n\t" | |
662 "movq %%mm2, (%%ebx, %1) \n\t" | |
663 | |
664 : | |
665 : "r" (src), "r" (stride) | |
666 : "%eax", "%ebx" | |
667 ); | |
668 #else | |
669 const int l1= stride; | |
670 const int l2= stride + l1; | |
671 const int l3= stride + l2; | |
672 const int l4= stride + l3; | |
673 const int l5= stride + l4; | |
674 const int l6= stride + l5; | |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
675 // const int l7= stride + l6; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
676 // const int l8= stride + l7; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
677 // const int l9= stride + l8; |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
678 int x; |
2586 | 679 const int QP15= QP + (QP>>2); |
2246 | 680 src+= stride*3; |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
681 for(x=0; x<BLOCK_SIZE; x++) |
2159 | 682 { |
2586 | 683 const int v = (src[x+l5] - src[x+l4]); |
684 if(ABS(v) < QP15) | |
2159 | 685 { |
2586 | 686 src[x+l3] +=v>>3; |
687 src[x+l4] +=v>>1; | |
688 src[x+l5] -=v>>1; | |
689 src[x+l6] -=v>>3; | |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
690 |
2159 | 691 } |
692 } | |
693 | |
694 #endif | |
695 } | |
696 | |
697 /** | |
698 * Experimental Filter 1 | |
2179 | 699 * will not damage linear gradients |
700 * Flat blocks should look like they where passed through the (1,1,2,2,4,2,2,1,1) 9-Tap filter | |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
701 * can only smooth blocks at the expected locations (it cant smooth them if they did move) |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
702 * MMX2 version does correct clipping C version doesnt |
2159 | 703 */ |
704 static inline void vertX1Filter(uint8_t *src, int stride, int QP) | |
705 { | |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
706 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
2246 | 707 src+= stride*3; |
708 | |
2159 | 709 asm volatile( |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
710 "pxor %%mm7, %%mm7 \n\t" // 0 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
711 // "movq b80, %%mm6 \n\t" // MIN_SIGNED_BYTE |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
712 "leal (%0, %1), %%eax \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
713 "leal (%%eax, %1, 4), %%ebx \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
714 // 0 1 2 3 4 5 6 7 8 9 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
715 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
716 "movq (%%eax, %1, 2), %%mm0 \n\t" // line 3 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
717 "movq (%0, %1, 4), %%mm1 \n\t" // line 4 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
718 "movq %%mm1, %%mm2 \n\t" // line 4 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
719 "psubusb %%mm0, %%mm1 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
720 "psubusb %%mm2, %%mm0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
721 "por %%mm1, %%mm0 \n\t" // |l2 - l3| |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
722 "movq (%%ebx), %%mm3 \n\t" // line 5 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
723 "movq (%%ebx, %1), %%mm4 \n\t" // line 6 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
724 "movq %%mm3, %%mm5 \n\t" // line 5 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
725 "psubusb %%mm4, %%mm3 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
726 "psubusb %%mm5, %%mm4 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
727 "por %%mm4, %%mm3 \n\t" // |l5 - l6| |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
728 PAVGB(%%mm3, %%mm0) // (|l2 - l3| + |l5 - l6|)/2 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
729 "movq %%mm2, %%mm1 \n\t" // line 4 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
730 "psubusb %%mm5, %%mm2 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
731 "movq %%mm2, %%mm4 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
732 "pcmpeqb %%mm7, %%mm2 \n\t" // (l4 - l5) <= 0 ? -1 : 0 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
733 "psubusb %%mm1, %%mm5 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
734 "por %%mm5, %%mm4 \n\t" // |l4 - l5| |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
735 "psubusb %%mm0, %%mm4 \n\t" //d = MAX(0, |l4-l5| - (|l2-l3| + |l5-l6|)/2) |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
736 "movq %%mm4, %%mm3 \n\t" // d |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
737 "psubusb pQPb, %%mm4 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
738 "pcmpeqb %%mm7, %%mm4 \n\t" // d <= QP ? -1 : 0 |
2179 | 739 "psubusb b01, %%mm3 \n\t" |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
740 "pand %%mm4, %%mm3 \n\t" // d <= QP ? d : 0 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
741 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
742 PAVGB(%%mm7, %%mm3) // d/2 |
2179 | 743 "movq %%mm3, %%mm1 \n\t" // d/2 |
744 PAVGB(%%mm7, %%mm3) // d/4 | |
745 PAVGB(%%mm1, %%mm3) // 3*d/8 | |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
746 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
747 "movq (%0, %1, 4), %%mm0 \n\t" // line 4 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
748 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l4-1 : l4 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
749 "psubusb %%mm3, %%mm0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
750 "pxor %%mm2, %%mm0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
751 "movq %%mm0, (%0, %1, 4) \n\t" // line 4 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
752 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
753 "movq (%%ebx), %%mm0 \n\t" // line 5 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
754 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l5-1 : l5 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
755 "paddusb %%mm3, %%mm0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
756 "pxor %%mm2, %%mm0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
757 "movq %%mm0, (%%ebx) \n\t" // line 5 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
758 |
2179 | 759 PAVGB(%%mm7, %%mm1) // d/4 |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
760 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
761 "movq (%%eax, %1, 2), %%mm0 \n\t" // line 3 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
762 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l4-1 : l4 |
2179 | 763 "psubusb %%mm1, %%mm0 \n\t" |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
764 "pxor %%mm2, %%mm0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
765 "movq %%mm0, (%%eax, %1, 2) \n\t" // line 3 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
766 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
767 "movq (%%ebx, %1), %%mm0 \n\t" // line 6 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
768 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l5-1 : l5 |
2179 | 769 "paddusb %%mm1, %%mm0 \n\t" |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
770 "pxor %%mm2, %%mm0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
771 "movq %%mm0, (%%ebx, %1) \n\t" // line 6 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
772 |
2179 | 773 PAVGB(%%mm7, %%mm1) // d/8 |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
774 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
775 "movq (%%eax, %1), %%mm0 \n\t" // line 2 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
776 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l2-1 : l2 |
2179 | 777 "psubusb %%mm1, %%mm0 \n\t" |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
778 "pxor %%mm2, %%mm0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
779 "movq %%mm0, (%%eax, %1) \n\t" // line 2 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
780 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
781 "movq (%%ebx, %1, 2), %%mm0 \n\t" // line 7 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
782 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l7-1 : l7 |
2179 | 783 "paddusb %%mm1, %%mm0 \n\t" |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
784 "pxor %%mm2, %%mm0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
785 "movq %%mm0, (%%ebx, %1, 2) \n\t" // line 7 |
2159 | 786 |
787 : | |
788 : "r" (src), "r" (stride) | |
789 : "%eax", "%ebx" | |
790 ); | |
791 #else | |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
792 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
793 const int l1= stride; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
794 const int l2= stride + l1; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
795 const int l3= stride + l2; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
796 const int l4= stride + l3; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
797 const int l5= stride + l4; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
798 const int l6= stride + l5; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
799 const int l7= stride + l6; |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
800 // const int l8= stride + l7; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
801 // const int l9= stride + l8; |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
802 int x; |
2246 | 803 |
804 src+= stride*3; | |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
805 for(x=0; x<BLOCK_SIZE; x++) |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
806 { |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
807 int a= src[l3] - src[l4]; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
808 int b= src[l4] - src[l5]; |
2179 | 809 int c= src[l5] - src[l6]; |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
810 |
2586 | 811 int d= ABS(b) - ((ABS(a) + ABS(c))>>1); |
812 d= MAX(d, 0); | |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
813 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
814 if(d < QP) |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
815 { |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
816 int v = d * SIGN(-b); |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
817 |
2586 | 818 src[l2] +=v>>3; |
819 src[l3] +=v>>2; | |
820 src[l4] +=(3*v)>>3; | |
821 src[l5] -=(3*v)>>3; | |
822 src[l6] -=v>>2; | |
823 src[l7] -=v>>3; | |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
824 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
825 } |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
826 src++; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
827 } |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
828 /* |
2159 | 829 const int l1= stride; |
830 const int l2= stride + l1; | |
831 const int l3= stride + l2; | |
832 const int l4= stride + l3; | |
833 const int l5= stride + l4; | |
834 const int l6= stride + l5; | |
835 const int l7= stride + l6; | |
836 const int l8= stride + l7; | |
837 const int l9= stride + l8; | |
838 for(int x=0; x<BLOCK_SIZE; x++) | |
839 { | |
840 int v2= src[l2]; | |
841 int v3= src[l3]; | |
842 int v4= src[l4]; | |
843 int v5= src[l5]; | |
844 int v6= src[l6]; | |
845 int v7= src[l7]; | |
846 | |
847 if(ABS(v4-v5)<QP && ABS(v4-v5) - (ABS(v3-v4) + ABS(v5-v6))>0 ) | |
848 { | |
849 src[l3] = (6*v2 + 4*v3 + 3*v4 + 2*v5 + v6 )/16; | |
850 src[l4] = (3*v2 + 3*v3 + 4*v4 + 3*v5 + 2*v6 + v7 )/16; | |
851 src[l5] = (1*v2 + 2*v3 + 3*v4 + 4*v5 + 3*v6 + 3*v7)/16; | |
852 src[l6] = ( 1*v3 + 2*v4 + 3*v5 + 4*v6 + 6*v7)/16; | |
853 } | |
854 src++; | |
855 } | |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
856 */ |
2159 | 857 #endif |
858 } | |
859 | |
2179 | 860 /** |
861 * Experimental Filter 1 (Horizontal) | |
862 * will not damage linear gradients | |
863 * Flat blocks should look like they where passed through the (1,1,2,2,4,2,2,1,1) 9-Tap filter | |
864 * can only smooth blocks at the expected locations (it cant smooth them if they did move) | |
865 * MMX2 version does correct clipping C version doesnt | |
866 * not identical with the vertical one | |
867 */ | |
868 static inline void horizX1Filter(uint8_t *src, int stride, int QP) | |
869 { | |
870 int y; | |
871 static uint64_t *lut= NULL; | |
872 if(lut==NULL) | |
873 { | |
874 int i; | |
875 lut= (uint64_t*)memalign(8, 256*8); | |
876 for(i=0; i<256; i++) | |
877 { | |
878 int v= i < 128 ? 2*i : 2*(i-256); | |
879 /* | |
880 //Simulate 112242211 9-Tap filter | |
881 uint64_t a= (v/16) & 0xFF; | |
882 uint64_t b= (v/8) & 0xFF; | |
883 uint64_t c= (v/4) & 0xFF; | |
884 uint64_t d= (3*v/8) & 0xFF; | |
885 */ | |
886 //Simulate piecewise linear interpolation | |
887 uint64_t a= (v/16) & 0xFF; | |
888 uint64_t b= (v*3/16) & 0xFF; | |
889 uint64_t c= (v*5/16) & 0xFF; | |
890 uint64_t d= (7*v/16) & 0xFF; | |
891 uint64_t A= (0x100 - a)&0xFF; | |
892 uint64_t B= (0x100 - b)&0xFF; | |
893 uint64_t C= (0x100 - c)&0xFF; | |
894 uint64_t D= (0x100 - c)&0xFF; | |
895 | |
896 lut[i] = (a<<56) | (b<<48) | (c<<40) | (d<<32) | | |
897 (D<<24) | (C<<16) | (B<<8) | (A); | |
898 //lut[i] = (v<<32) | (v<<24); | |
899 } | |
900 } | |
901 | |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
902 #if 0 |
2179 | 903 asm volatile( |
904 "pxor %%mm7, %%mm7 \n\t" // 0 | |
905 // "movq b80, %%mm6 \n\t" // MIN_SIGNED_BYTE | |
906 "leal (%0, %1), %%eax \n\t" | |
907 "leal (%%eax, %1, 4), %%ebx \n\t" | |
908 | |
909 "movq b80, %%mm6 \n\t" | |
2180 | 910 "movd pQPb, %%mm5 \n\t" // QP |
2179 | 911 "movq %%mm5, %%mm4 \n\t" |
912 "paddusb %%mm5, %%mm5 \n\t" // 2QP | |
913 "paddusb %%mm5, %%mm4 \n\t" // 3QP | |
914 "pxor %%mm5, %%mm5 \n\t" // 0 | |
915 "psubb %%mm4, %%mm5 \n\t" // -3QP | |
916 "por bm11111110, %%mm5 \n\t" // ...,FF,FF,-3QP | |
917 "psllq $24, %%mm5 \n\t" | |
918 | |
919 // 0 1 2 3 4 5 6 7 8 9 | |
920 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 | |
921 | |
922 #define HX1old(a) \ | |
923 "movd " #a ", %%mm0 \n\t"\ | |
924 "movd 4" #a ", %%mm1 \n\t"\ | |
925 "punpckldq %%mm1, %%mm0 \n\t"\ | |
926 "movq %%mm0, %%mm1 \n\t"\ | |
927 "movq %%mm0, %%mm2 \n\t"\ | |
928 "psrlq $8, %%mm1 \n\t"\ | |
929 "psubusb %%mm1, %%mm2 \n\t"\ | |
930 "psubusb %%mm0, %%mm1 \n\t"\ | |
931 "por %%mm2, %%mm1 \n\t" /* p´x = |px - p(x+1)| */\ | |
932 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\ | |
933 "pshufw $0x00, %%mm1, %%mm3 \n\t" /* p´5 = |p1 - p2| */\ | |
934 PAVGB(%%mm1, %%mm3) /* p´5 = (|p2-p1| + |p6-p5|)/2 */\ | |
935 "psrlq $16, %%mm3 \n\t" /* p´3 = (|p2-p1| + |p6-p5|)/2 */\ | |
936 "psubusb %%mm3, %%mm1 \n\t" /* |p3-p4|-(|p2-p1| + |p6-p5|)/2 */\ | |
937 "paddb %%mm5, %%mm1 \n\t"\ | |
938 "psubusb %%mm5, %%mm1 \n\t"\ | |
939 PAVGB(%%mm7, %%mm1)\ | |
940 "pxor %%mm2, %%mm1 \n\t"\ | |
941 "psubb %%mm2, %%mm1 \n\t"\ | |
942 "psrlq $24, %%mm1 \n\t"\ | |
943 "movd %%mm1, %%ecx \n\t"\ | |
944 "paddb %%mm6, %%mm0 \n\t"\ | |
945 "paddsb (%3, %%ecx, 8), %%mm0 \n\t"\ | |
946 "paddb %%mm6, %%mm0 \n\t"\ | |
947 "movq %%mm0, " #a " \n\t"\ | |
948 | |
949 /* | |
950 HX1old((%0)) | |
951 HX1old((%%eax)) | |
952 HX1old((%%eax, %1)) | |
953 HX1old((%%eax, %1, 2)) | |
954 HX1old((%0, %1, 4)) | |
955 HX1old((%%ebx)) | |
956 HX1old((%%ebx, %1)) | |
957 HX1old((%%ebx, %1, 2)) | |
958 */ | |
959 | |
960 //FIXME add some comments, its unreadable ... | |
961 #define HX1b(a, c, b, d) \ | |
962 "movd " #a ", %%mm0 \n\t"\ | |
963 "movd 4" #a ", %%mm1 \n\t"\ | |
964 "punpckldq %%mm1, %%mm0 \n\t"\ | |
965 "movd " #b ", %%mm4 \n\t"\ | |
966 "movq %%mm0, %%mm1 \n\t"\ | |
967 "movq %%mm0, %%mm2 \n\t"\ | |
968 "psrlq $8, %%mm1 \n\t"\ | |
969 "movd 4" #b ", %%mm3 \n\t"\ | |
970 "psubusb %%mm1, %%mm2 \n\t"\ | |
971 "psubusb %%mm0, %%mm1 \n\t"\ | |
972 "por %%mm2, %%mm1 \n\t" /* p´x = |px - p(x+1)| */\ | |
973 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\ | |
974 "punpckldq %%mm3, %%mm4 \n\t"\ | |
975 "movq %%mm1, %%mm3 \n\t"\ | |
976 "psllq $32, %%mm3 \n\t" /* p´5 = |p1 - p2| */\ | |
977 PAVGB(%%mm1, %%mm3) /* p´5 = (|p2-p1| + |p6-p5|)/2 */\ | |
978 "paddb %%mm6, %%mm0 \n\t"\ | |
979 "psrlq $16, %%mm3 \n\t" /* p´3 = (|p2-p1| + |p6-p5|)/2 */\ | |
980 "psubusb %%mm3, %%mm1 \n\t" /* |p3-p4|-(|p2-p1| + |p6-p5|)/2 */\ | |
981 "movq %%mm4, %%mm3 \n\t"\ | |
982 "paddb %%mm5, %%mm1 \n\t"\ | |
983 "psubusb %%mm5, %%mm1 \n\t"\ | |
984 "psrlq $8, %%mm3 \n\t"\ | |
985 PAVGB(%%mm7, %%mm1)\ | |
986 "pxor %%mm2, %%mm1 \n\t"\ | |
987 "psubb %%mm2, %%mm1 \n\t"\ | |
988 "movq %%mm4, %%mm2 \n\t"\ | |
989 "psrlq $24, %%mm1 \n\t"\ | |
990 "psubusb %%mm3, %%mm2 \n\t"\ | |
991 "movd %%mm1, %%ecx \n\t"\ | |
992 "psubusb %%mm4, %%mm3 \n\t"\ | |
2180 | 993 "paddsb (%2, %%ecx, 8), %%mm0 \n\t"\ |
2179 | 994 "por %%mm2, %%mm3 \n\t" /* p´x = |px - p(x+1)| */\ |
995 "paddb %%mm6, %%mm0 \n\t"\ | |
996 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\ | |
997 "movq %%mm3, %%mm1 \n\t"\ | |
998 "psllq $32, %%mm1 \n\t" /* p´5 = |p1 - p2| */\ | |
999 "movq %%mm0, " #a " \n\t"\ | |
1000 PAVGB(%%mm3, %%mm1) /* p´5 = (|p2-p1| + |p6-p5|)/2 */\ | |
1001 "paddb %%mm6, %%mm4 \n\t"\ | |
1002 "psrlq $16, %%mm1 \n\t" /* p´3 = (|p2-p1| + |p6-p5|)/2 */\ | |
1003 "psubusb %%mm1, %%mm3 \n\t" /* |p3-p4|-(|p2-p1| + |p6-p5|)/2 */\ | |
1004 "paddb %%mm5, %%mm3 \n\t"\ | |
1005 "psubusb %%mm5, %%mm3 \n\t"\ | |
1006 PAVGB(%%mm7, %%mm3)\ | |
1007 "pxor %%mm2, %%mm3 \n\t"\ | |
1008 "psubb %%mm2, %%mm3 \n\t"\ | |
1009 "psrlq $24, %%mm3 \n\t"\ | |
1010 "movd " #c ", %%mm0 \n\t"\ | |
1011 "movd 4" #c ", %%mm1 \n\t"\ | |
1012 "punpckldq %%mm1, %%mm0 \n\t"\ | |
1013 "paddb %%mm6, %%mm0 \n\t"\ | |
2180 | 1014 "paddsb (%2, %%ecx, 8), %%mm0 \n\t"\ |
2179 | 1015 "paddb %%mm6, %%mm0 \n\t"\ |
1016 "movq %%mm0, " #c " \n\t"\ | |
1017 "movd %%mm3, %%ecx \n\t"\ | |
1018 "movd " #d ", %%mm0 \n\t"\ | |
2180 | 1019 "paddsb (%2, %%ecx, 8), %%mm4 \n\t"\ |
2179 | 1020 "movd 4" #d ", %%mm1 \n\t"\ |
1021 "paddb %%mm6, %%mm4 \n\t"\ | |
1022 "punpckldq %%mm1, %%mm0 \n\t"\ | |
1023 "movq %%mm4, " #b " \n\t"\ | |
1024 "paddb %%mm6, %%mm0 \n\t"\ | |
2180 | 1025 "paddsb (%2, %%ecx, 8), %%mm0 \n\t"\ |
2179 | 1026 "paddb %%mm6, %%mm0 \n\t"\ |
1027 "movq %%mm0, " #d " \n\t"\ | |
1028 | |
1029 HX1b((%0),(%%eax),(%%eax, %1),(%%eax, %1, 2)) | |
1030 HX1b((%0, %1, 4),(%%ebx),(%%ebx, %1),(%%ebx, %1, 2)) | |
1031 | |
1032 | |
1033 : | |
2180 | 1034 : "r" (src), "r" (stride), "r" (lut) |
2179 | 1035 : "%eax", "%ebx", "%ecx" |
1036 ); | |
1037 #else | |
1038 | |
1039 //FIXME (has little in common with the mmx2 version) | |
1040 for(y=0; y<BLOCK_SIZE; y++) | |
1041 { | |
1042 int a= src[1] - src[2]; | |
1043 int b= src[3] - src[4]; | |
1044 int c= src[5] - src[6]; | |
1045 | |
1046 int d= MAX(ABS(b) - (ABS(a) + ABS(c))/2, 0); | |
1047 | |
1048 if(d < QP) | |
1049 { | |
1050 int v = d * SIGN(-b); | |
1051 | |
1052 src[1] +=v/8; | |
1053 src[2] +=v/4; | |
1054 src[3] +=3*v/8; | |
1055 src[4] -=3*v/8; | |
1056 src[5] -=v/4; | |
1057 src[6] -=v/8; | |
1058 | |
1059 } | |
1060 src+=stride; | |
1061 } | |
1062 #endif | |
1063 } | |
1064 | |
2159 | 1065 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1066 static inline void doVertDefFilter(uint8_t src[], int stride, int QP) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1067 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1068 #ifdef HAVE_MMX |
2246 | 1069 src+= stride*4; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1070 //FIXME try pmul for *5 stuff |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1071 // src[0]=0; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1072 asm volatile( |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1073 "pxor %%mm7, %%mm7 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1074 "leal (%0, %1), %%eax \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1075 "leal (%%eax, %1, 4), %%ebx \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1076 // 0 1 2 3 4 5 6 7 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1077 // %0 %0+%1 %0+2%1 eax+2%1 %0+4%1 eax+4%1 ebx+%1 ebx+2%1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1078 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1079 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1080 "movq (%0), %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1081 "movq %%mm0, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1082 "punpcklbw %%mm7, %%mm0 \n\t" // low part of line 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1083 "punpckhbw %%mm7, %%mm1 \n\t" // high part of line 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1084 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1085 "movq (%%eax), %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1086 "movq %%mm2, %%mm3 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1087 "punpcklbw %%mm7, %%mm2 \n\t" // low part of line 1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1088 "punpckhbw %%mm7, %%mm3 \n\t" // high part of line 1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1089 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1090 "movq (%%eax, %1), %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1091 "movq %%mm4, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1092 "punpcklbw %%mm7, %%mm4 \n\t" // low part of line 2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1093 "punpckhbw %%mm7, %%mm5 \n\t" // high part of line 2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1094 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1095 "paddw %%mm0, %%mm0 \n\t" // 2L0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1096 "paddw %%mm1, %%mm1 \n\t" // 2H0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1097 "psubw %%mm4, %%mm2 \n\t" // L1 - L2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1098 "psubw %%mm5, %%mm3 \n\t" // H1 - H2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1099 "psubw %%mm2, %%mm0 \n\t" // 2L0 - L1 + L2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1100 "psubw %%mm3, %%mm1 \n\t" // 2H0 - H1 + H2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1101 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1102 "psllw $2, %%mm2 \n\t" // 4L1 - 4L2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1103 "psllw $2, %%mm3 \n\t" // 4H1 - 4H2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1104 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1105 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1106 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1107 "movq (%%eax, %1, 2), %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1108 "movq %%mm2, %%mm3 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1109 "punpcklbw %%mm7, %%mm2 \n\t" // L3 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1110 "punpckhbw %%mm7, %%mm3 \n\t" // H3 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1111 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1112 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2 - L3 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1113 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2 - H3 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1114 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2 - 2L3 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1115 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2 - 2H3 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1116 "movq %%mm0, temp0 \n\t" // 2L0 - 5L1 + 5L2 - 2L3 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1117 "movq %%mm1, temp1 \n\t" // 2H0 - 5H1 + 5H2 - 2H3 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1118 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1119 "movq (%0, %1, 4), %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1120 "movq %%mm0, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1121 "punpcklbw %%mm7, %%mm0 \n\t" // L4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1122 "punpckhbw %%mm7, %%mm1 \n\t" // H4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1123 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1124 "psubw %%mm0, %%mm2 \n\t" // L3 - L4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1125 "psubw %%mm1, %%mm3 \n\t" // H3 - H4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1126 "movq %%mm2, temp2 \n\t" // L3 - L4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1127 "movq %%mm3, temp3 \n\t" // H3 - H4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1128 "paddw %%mm4, %%mm4 \n\t" // 2L2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1129 "paddw %%mm5, %%mm5 \n\t" // 2H2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1130 "psubw %%mm2, %%mm4 \n\t" // 2L2 - L3 + L4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1131 "psubw %%mm3, %%mm5 \n\t" // 2H2 - H3 + H4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1132 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1133 "psllw $2, %%mm2 \n\t" // 4L3 - 4L4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1134 "psllw $2, %%mm3 \n\t" // 4H3 - 4H4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1135 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1136 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1137 //50 opcodes so far |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1138 "movq (%%ebx), %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1139 "movq %%mm2, %%mm3 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1140 "punpcklbw %%mm7, %%mm2 \n\t" // L5 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1141 "punpckhbw %%mm7, %%mm3 \n\t" // H5 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1142 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4 - L5 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1143 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4 - H5 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1144 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4 - 2L5 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1145 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4 - 2H5 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1146 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1147 "movq (%%ebx, %1), %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1148 "punpcklbw %%mm7, %%mm6 \n\t" // L6 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1149 "psubw %%mm6, %%mm2 \n\t" // L5 - L6 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1150 "movq (%%ebx, %1), %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1151 "punpckhbw %%mm7, %%mm6 \n\t" // H6 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1152 "psubw %%mm6, %%mm3 \n\t" // H5 - H6 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1153 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1154 "paddw %%mm0, %%mm0 \n\t" // 2L4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1155 "paddw %%mm1, %%mm1 \n\t" // 2H4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1156 "psubw %%mm2, %%mm0 \n\t" // 2L4 - L5 + L6 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1157 "psubw %%mm3, %%mm1 \n\t" // 2H4 - H5 + H6 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1158 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1159 "psllw $2, %%mm2 \n\t" // 4L5 - 4L6 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1160 "psllw $2, %%mm3 \n\t" // 4H5 - 4H6 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1161 "psubw %%mm2, %%mm0 \n\t" // 2L4 - 5L5 + 5L6 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1162 "psubw %%mm3, %%mm1 \n\t" // 2H4 - 5H5 + 5H6 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1163 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1164 "movq (%%ebx, %1, 2), %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1165 "movq %%mm2, %%mm3 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1166 "punpcklbw %%mm7, %%mm2 \n\t" // L7 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1167 "punpckhbw %%mm7, %%mm3 \n\t" // H7 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1168 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1169 "paddw %%mm2, %%mm2 \n\t" // 2L7 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1170 "paddw %%mm3, %%mm3 \n\t" // 2H7 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1171 "psubw %%mm2, %%mm0 \n\t" // 2L4 - 5L5 + 5L6 - 2L7 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1172 "psubw %%mm3, %%mm1 \n\t" // 2H4 - 5H5 + 5H6 - 2H7 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1173 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1174 "movq temp0, %%mm2 \n\t" // 2L0 - 5L1 + 5L2 - 2L3 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1175 "movq temp1, %%mm3 \n\t" // 2H0 - 5H1 + 5H2 - 2H3 |
2570 | 1176 |
1177 #ifdef HAVE_MMX2 | |
1178 "movq %%mm7, %%mm6 \n\t" // 0 | |
1179 "psubw %%mm0, %%mm6 \n\t" | |
1180 "pmaxsw %%mm6, %%mm0 \n\t" // |2L4 - 5L5 + 5L6 - 2L7| | |
1181 "movq %%mm7, %%mm6 \n\t" // 0 | |
1182 "psubw %%mm1, %%mm6 \n\t" | |
1183 "pmaxsw %%mm6, %%mm1 \n\t" // |2H4 - 5H5 + 5H6 - 2H7| | |
1184 "movq %%mm7, %%mm6 \n\t" // 0 | |
1185 "psubw %%mm2, %%mm6 \n\t" | |
1186 "pmaxsw %%mm6, %%mm2 \n\t" // |2L0 - 5L1 + 5L2 - 2L3| | |
1187 "movq %%mm7, %%mm6 \n\t" // 0 | |
1188 "psubw %%mm3, %%mm6 \n\t" | |
1189 "pmaxsw %%mm6, %%mm3 \n\t" // |2H0 - 5H1 + 5H2 - 2H3| | |
1190 #else | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1191 "movq %%mm7, %%mm6 \n\t" // 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1192 "pcmpgtw %%mm0, %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1193 "pxor %%mm6, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1194 "psubw %%mm6, %%mm0 \n\t" // |2L4 - 5L5 + 5L6 - 2L7| |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1195 "movq %%mm7, %%mm6 \n\t" // 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1196 "pcmpgtw %%mm1, %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1197 "pxor %%mm6, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1198 "psubw %%mm6, %%mm1 \n\t" // |2H4 - 5H5 + 5H6 - 2H7| |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1199 "movq %%mm7, %%mm6 \n\t" // 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1200 "pcmpgtw %%mm2, %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1201 "pxor %%mm6, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1202 "psubw %%mm6, %%mm2 \n\t" // |2L0 - 5L1 + 5L2 - 2L3| |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1203 "movq %%mm7, %%mm6 \n\t" // 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1204 "pcmpgtw %%mm3, %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1205 "pxor %%mm6, %%mm3 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1206 "psubw %%mm6, %%mm3 \n\t" // |2H0 - 5H1 + 5H2 - 2H3| |
2570 | 1207 #endif |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1208 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1209 #ifdef HAVE_MMX2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1210 "pminsw %%mm2, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1211 "pminsw %%mm3, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1212 #else |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1213 "movq %%mm0, %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1214 "psubusw %%mm2, %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1215 "psubw %%mm6, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1216 "movq %%mm1, %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1217 "psubusw %%mm3, %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1218 "psubw %%mm6, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1219 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1220 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1221 "movq %%mm7, %%mm6 \n\t" // 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1222 "pcmpgtw %%mm4, %%mm6 \n\t" // sign(2L2 - 5L3 + 5L4 - 2L5) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1223 "pxor %%mm6, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1224 "psubw %%mm6, %%mm4 \n\t" // |2L2 - 5L3 + 5L4 - 2L5| |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1225 "pcmpgtw %%mm5, %%mm7 \n\t" // sign(2H2 - 5H3 + 5H4 - 2H5) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1226 "pxor %%mm7, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1227 "psubw %%mm7, %%mm5 \n\t" // |2H2 - 5H3 + 5H4 - 2H5| |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1228 // 100 opcodes |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1229 "movd %2, %%mm2 \n\t" // QP |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1230 "punpcklwd %%mm2, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1231 "punpcklwd %%mm2, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1232 "psllw $3, %%mm2 \n\t" // 8QP |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1233 "movq %%mm2, %%mm3 \n\t" // 8QP |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1234 "pcmpgtw %%mm4, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1235 "pcmpgtw %%mm5, %%mm3 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1236 "pand %%mm2, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1237 "pand %%mm3, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1238 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1239 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1240 "psubusw %%mm0, %%mm4 \n\t" // hd |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1241 "psubusw %%mm1, %%mm5 \n\t" // ld |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1242 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1243 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1244 "movq w05, %%mm2 \n\t" // 5 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1245 "pmullw %%mm2, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1246 "pmullw %%mm2, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1247 "movq w20, %%mm2 \n\t" // 32 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1248 "paddw %%mm2, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1249 "paddw %%mm2, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1250 "psrlw $6, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1251 "psrlw $6, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1252 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1253 /* |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1254 "movq w06, %%mm2 \n\t" // 6 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1255 "paddw %%mm2, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1256 "paddw %%mm2, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1257 "movq w1400, %%mm2 \n\t" // 1400h = 5120 = 5/64*2^16 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1258 //FIXME if *5/64 is supposed to be /13 then we should use 5041 instead of 5120 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1259 "pmulhw %%mm2, %%mm4 \n\t" // hd/13 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1260 "pmulhw %%mm2, %%mm5 \n\t" // ld/13 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1261 */ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1262 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1263 "movq temp2, %%mm0 \n\t" // L3 - L4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1264 "movq temp3, %%mm1 \n\t" // H3 - H4 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1265 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1266 "pxor %%mm2, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1267 "pxor %%mm3, %%mm3 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1268 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1269 "pcmpgtw %%mm0, %%mm2 \n\t" // sign (L3-L4) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1270 "pcmpgtw %%mm1, %%mm3 \n\t" // sign (H3-H4) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1271 "pxor %%mm2, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1272 "pxor %%mm3, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1273 "psubw %%mm2, %%mm0 \n\t" // |L3-L4| |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1274 "psubw %%mm3, %%mm1 \n\t" // |H3-H4| |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1275 "psrlw $1, %%mm0 \n\t" // |L3 - L4|/2 |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1276 "psrlw $1, %%mm1 \n\t" // |H3 - H4|/2 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1277 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1278 "pxor %%mm6, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1279 "pxor %%mm7, %%mm3 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1280 "pand %%mm2, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1281 "pand %%mm3, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1282 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1283 #ifdef HAVE_MMX2 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1284 "pminsw %%mm0, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1285 "pminsw %%mm1, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1286 #else |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1287 "movq %%mm4, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1288 "psubusw %%mm0, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1289 "psubw %%mm2, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1290 "movq %%mm5, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1291 "psubusw %%mm1, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1292 "psubw %%mm2, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1293 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1294 "pxor %%mm6, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1295 "pxor %%mm7, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1296 "psubw %%mm6, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1297 "psubw %%mm7, %%mm5 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1298 "packsswb %%mm5, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1299 "movq (%%eax, %1, 2), %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1300 "paddb %%mm4, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1301 "movq %%mm0, (%%eax, %1, 2) \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1302 "movq (%0, %1, 4), %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1303 "psubb %%mm4, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1304 "movq %%mm0, (%0, %1, 4) \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1305 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1306 : |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1307 : "r" (src), "r" (stride), "r" (QP) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1308 : "%eax", "%ebx" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1309 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1310 #else |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1311 const int l1= stride; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1312 const int l2= stride + l1; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1313 const int l3= stride + l2; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1314 const int l4= stride + l3; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1315 const int l5= stride + l4; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1316 const int l6= stride + l5; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1317 const int l7= stride + l6; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1318 const int l8= stride + l7; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1319 // const int l9= stride + l8; |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
1320 int x; |
2246 | 1321 src+= stride*3; |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
1322 for(x=0; x<BLOCK_SIZE; x++) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1323 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1324 const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1325 if(ABS(middleEnergy) < 8*QP) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1326 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1327 const int q=(src[l4] - src[l5])/2; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1328 const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1329 const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1330 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1331 int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1332 d= MAX(d, 0); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1333 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1334 d= (5*d + 32) >> 6; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1335 d*= SIGN(-middleEnergy); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1336 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1337 if(q>0) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1338 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1339 d= d<0 ? 0 : d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1340 d= d>q ? q : d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1341 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1342 else |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1343 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1344 d= d>0 ? 0 : d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1345 d= d<q ? q : d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1346 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1347 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1348 src[l4]-= d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1349 src[l5]+= d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1350 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1351 src++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1352 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1353 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1354 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1355 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1356 //FIXME? |255-0| = 1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1357 /** |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1358 * Check if the given 8x8 Block is mostly "flat" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1359 */ |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1360 static inline int isHorizDC(uint8_t src[], int stride) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1361 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1362 // src++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1363 int numEq= 0; |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1364 #if 0 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1365 asm volatile ( |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1366 // "int $3 \n\t" |
2416 | 1367 "leal (%1, %2), %%ecx \n\t" |
1368 "leal (%%ecx, %2, 4), %%ebx \n\t" | |
1369 // 0 1 2 3 4 5 6 7 8 9 | |
1370 // %1 ecx ecx+%2 ecx+2%2 %1+4%2 ebx ebx+%2 ebx+2%2 %1+8%2 ebx+4%2 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1371 "movq b7E, %%mm7 \n\t" // mm7 = 0x7F |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1372 "movq b7C, %%mm6 \n\t" // mm6 = 0x7D |
2416 | 1373 "pxor %%mm0, %%mm0 \n\t" |
1374 "movl %1, %%eax \n\t" | |
1375 "andl $0x1F, %%eax \n\t" | |
1376 "cmpl $24, %%eax \n\t" | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1377 "leal tempBlock, %%eax \n\t" |
2416 | 1378 "jb 1f \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1379 |
2416 | 1380 #define HDC_CHECK_AND_CPY(src, dst) \ |
1381 "movd " #src ", %%mm2 \n\t"\ | |
1382 "punpckldq 4" #src ", %%mm2 \n\t" /* (%1) */\ | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1383 "movq %%mm2, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1384 "psrlq $8, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1385 "psubb %%mm1, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1386 "paddb %%mm7, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1387 "pcmpgtb %%mm6, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1388 "paddb %%mm2, %%mm0 \n\t"\ |
2416 | 1389 "movq %%mm1," #dst "(%%eax) \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1390 |
2416 | 1391 HDC_CHECK_AND_CPY((%1),0) |
1392 HDC_CHECK_AND_CPY((%%ecx),8) | |
1393 HDC_CHECK_AND_CPY((%%ecx, %2),16) | |
1394 HDC_CHECK_AND_CPY((%%ecx, %2, 2),24) | |
1395 HDC_CHECK_AND_CPY((%1, %2, 4),32) | |
1396 HDC_CHECK_AND_CPY((%%ebx),40) | |
1397 HDC_CHECK_AND_CPY((%%ebx, %2),48) | |
1398 HDC_CHECK_AND_CPY((%%ebx, %2, 2),56) | |
1399 "jmp 2f \n\t" | |
1400 "1: \n\t" | |
1401 // src does not cross a 32 byte cache line so dont waste time with alignment | |
1402 #define HDC_CHECK_AND_CPY2(src, dst) \ | |
1403 "movq " #src ", %%mm2 \n\t"\ | |
1404 "movq " #src ", %%mm1 \n\t"\ | |
1405 "psrlq $8, %%mm2 \n\t"\ | |
1406 "psubb %%mm1, %%mm2 \n\t"\ | |
1407 "paddb %%mm7, %%mm2 \n\t"\ | |
1408 "pcmpgtb %%mm6, %%mm2 \n\t"\ | |
1409 "paddb %%mm2, %%mm0 \n\t"\ | |
1410 "movq %%mm1," #dst "(%%eax) \n\t" | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1411 |
2416 | 1412 HDC_CHECK_AND_CPY2((%1),0) |
1413 HDC_CHECK_AND_CPY2((%%ecx),8) | |
1414 HDC_CHECK_AND_CPY2((%%ecx, %2),16) | |
1415 HDC_CHECK_AND_CPY2((%%ecx, %2, 2),24) | |
1416 HDC_CHECK_AND_CPY2((%1, %2, 4),32) | |
1417 HDC_CHECK_AND_CPY2((%%ebx),40) | |
1418 HDC_CHECK_AND_CPY2((%%ebx, %2),48) | |
1419 HDC_CHECK_AND_CPY2((%%ebx, %2, 2),56) | |
1420 "2: \n\t" | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1421 "psllq $8, %%mm0 \n\t" // remove dummy value |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1422 "movq %%mm0, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1423 "psrlw $8, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1424 "paddb %%mm1, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1425 "movq %%mm0, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1426 "psrlq $16, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1427 "paddb %%mm1, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1428 "movq %%mm0, %%mm1 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1429 "psrlq $32, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1430 "paddb %%mm1, %%mm0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1431 "movd %%mm0, %0 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1432 : "=r" (numEq) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1433 : "r" (src), "r" (stride) |
2416 | 1434 : "%eax", "%ebx", "%ecx" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1435 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1436 // printf("%d\n", numEq); |
2416 | 1437 numEq= (256 - numEq) &0xFF; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1438 #else |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
1439 int y; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
1440 for(y=0; y<BLOCK_SIZE; y++) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1441 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1442 if(((src[0] - src[1] + 1) & 0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1443 if(((src[1] - src[2] + 1) & 0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1444 if(((src[2] - src[3] + 1) & 0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1445 if(((src[3] - src[4] + 1) & 0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1446 if(((src[4] - src[5] + 1) & 0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1447 if(((src[5] - src[6] + 1) & 0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1448 if(((src[6] - src[7] + 1) & 0xFFFF) < 3) numEq++; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1449 src+= stride; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1450 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1451 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1452 /* if(abs(numEq - asmEq) > 0) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1453 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1454 // printf("\nasm:%d c:%d\n", asmEq, numEq); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1455 for(int y=0; y<8; y++) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1456 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1457 for(int x=0; x<8; x++) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1458 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1459 printf("%d ", src[x + y*stride]); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1460 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1461 printf("\n"); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1462 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1463 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1464 */ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1465 // printf("%d\n", numEq); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1466 return numEq > hFlatnessThreshold; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1467 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1468 |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
1469 static inline int isHorizMinMaxOk(uint8_t src[], int stride, int QP) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1470 { |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
1471 if(abs(src[0] - src[7]) > 2*QP) return 0; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1472 |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
1473 return 1; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1474 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1475 |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1476 static inline void doHorizDefFilter(uint8_t dst[], int stride, int QP) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1477 { |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1478 #if 0 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1479 asm volatile( |
2428 | 1480 "leal (%0, %1), %%ecx \n\t" |
1481 "leal (%%ecx, %1, 4), %%ebx \n\t" | |
1482 // 0 1 2 3 4 5 6 7 8 9 | |
1483 // %0 ecx ecx+%1 ecx+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1484 "pxor %%mm7, %%mm7 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1485 "movq bm00001000, %%mm6 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1486 "movd %2, %%mm5 \n\t" // QP |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1487 "movq %%mm5, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1488 "paddusb %%mm5, %%mm5 \n\t" // 2QP |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1489 "paddusb %%mm5, %%mm4 \n\t" // 3QP |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1490 "psllq $24, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1491 "pxor %%mm5, %%mm5 \n\t" // 0 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1492 "psubb %%mm4, %%mm5 \n\t" // -QP |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1493 "leal tempBlock, %%eax \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1494 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1495 //FIXME? "unroll by 2" and mix |
2159 | 1496 #ifdef HAVE_MMX2 |
2428 | 1497 #define HDF(src, dst) \ |
1498 "movq " #src "(%%eax), %%mm0 \n\t"\ | |
1499 "movq " #src "(%%eax), %%mm1 \n\t"\ | |
1500 "movq " #src "(%%eax), %%mm2 \n\t"\ | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1501 "psrlq $8, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1502 "psubusb %%mm1, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1503 "psubusb %%mm0, %%mm1 \n\t"\ |
2159 | 1504 "por %%mm2, %%mm1 \n\t" /* p´x = |px - p(x+1)| */\ |
1505 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\ | |
1506 "pshufw $0x00, %%mm1, %%mm3 \n\t" /* p´5 = |p1 - p2| */\ | |
1507 "pminub %%mm1, %%mm3 \n\t" /* p´5 = min(|p2-p1|, |p6-p5|)*/\ | |
1508 "psrlq $16, %%mm3 \n\t" /* p´3 = min(|p2-p1|, |p6-p5|)*/\ | |
1509 "psubusb %%mm3, %%mm1 \n\t" /* |p3-p4|-min(|p1-p2|,|p5-p6|) */\ | |
1510 "paddb %%mm5, %%mm1 \n\t"\ | |
1511 "psubusb %%mm5, %%mm1 \n\t"\ | |
1512 "psrlw $2, %%mm1 \n\t"\ | |
1513 "pxor %%mm2, %%mm1 \n\t"\ | |
1514 "psubb %%mm2, %%mm1 \n\t"\ | |
1515 "pand %%mm6, %%mm1 \n\t"\ | |
1516 "psubb %%mm1, %%mm0 \n\t"\ | |
1517 "psllq $8, %%mm1 \n\t"\ | |
1518 "paddb %%mm1, %%mm0 \n\t"\ | |
2428 | 1519 "movd %%mm0, " #dst" \n\t"\ |
2159 | 1520 "psrlq $32, %%mm0 \n\t"\ |
2428 | 1521 "movd %%mm0, 4" #dst" \n\t" |
2159 | 1522 #else |
2428 | 1523 #define HDF(src, dst)\ |
1524 "movq " #src "(%%eax), %%mm0 \n\t"\ | |
2159 | 1525 "movq %%mm0, %%mm1 \n\t"\ |
1526 "movq %%mm0, %%mm2 \n\t"\ | |
1527 "psrlq $8, %%mm1 \n\t"\ | |
1528 "psubusb %%mm1, %%mm2 \n\t"\ | |
1529 "psubusb %%mm0, %%mm1 \n\t"\ | |
1530 "por %%mm2, %%mm1 \n\t" /* p´x = |px - p(x+1)| */\ | |
1531 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\ | |
1532 "movq %%mm1, %%mm3 \n\t"\ | |
1533 "psllq $32, %%mm3 \n\t"\ | |
1534 "movq %%mm3, %%mm4 \n\t"\ | |
1535 "psubusb %%mm1, %%mm4 \n\t"\ | |
1536 "psubb %%mm4, %%mm3 \n\t"\ | |
1537 "psrlq $16, %%mm3 \n\t" /* p´3 = min(|p2-p1|, |p6-p5|)*/\ | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1538 "psubusb %%mm3, %%mm1 \n\t" /* |p3-p4|-min(|p1-p2|,|p5,ü6|) */\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1539 "paddb %%mm5, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1540 "psubusb %%mm5, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1541 "psrlw $2, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1542 "pxor %%mm2, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1543 "psubb %%mm2, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1544 "pand %%mm6, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1545 "psubb %%mm1, %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1546 "psllq $8, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1547 "paddb %%mm1, %%mm0 \n\t"\ |
2428 | 1548 "movd %%mm0, " #dst " \n\t"\ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1549 "psrlq $32, %%mm0 \n\t"\ |
2428 | 1550 "movd %%mm0, 4" #dst " \n\t" |
2159 | 1551 #endif |
2428 | 1552 HDF(0,(%0)) |
1553 HDF(8,(%%ecx)) | |
1554 HDF(16,(%%ecx, %1)) | |
1555 HDF(24,(%%ecx, %1, 2)) | |
1556 HDF(32,(%0, %1, 4)) | |
1557 HDF(40,(%%ebx)) | |
1558 HDF(48,(%%ebx, %1)) | |
1559 HDF(56,(%%ebx, %1, 2)) | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1560 : |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1561 : "r" (dst), "r" (stride), "r" (QP) |
2428 | 1562 : "%eax", "%ebx", "%ecx" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1563 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1564 #else |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
1565 int y; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
1566 for(y=0; y<BLOCK_SIZE; y++) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1567 { |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1568 const int middleEnergy= 5*(dst[4] - dst[5]) + 2*(dst[2] - dst[5]); |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1569 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1570 if(ABS(middleEnergy) < 8*QP) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1571 { |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1572 const int q=(dst[3] - dst[4])/2; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1573 const int leftEnergy= 5*(dst[2] - dst[1]) + 2*(dst[0] - dst[3]); |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1574 const int rightEnergy= 5*(dst[6] - dst[5]) + 2*(dst[4] - dst[7]); |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1575 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1576 int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1577 d= MAX(d, 0); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1578 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1579 d= (5*d + 32) >> 6; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1580 d*= SIGN(-middleEnergy); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1581 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1582 if(q>0) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1583 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1584 d= d<0 ? 0 : d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1585 d= d>q ? q : d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1586 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1587 else |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1588 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1589 d= d>0 ? 0 : d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1590 d= d<q ? q : d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1591 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1592 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1593 dst[3]-= d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1594 dst[4]+= d; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1595 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1596 dst+= stride; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1597 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1598 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1599 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1600 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1601 /** |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1602 * Do a horizontal low pass filter on the 10x8 block (dst points to middle 8x8 Block) |
2221 | 1603 * using the 9-Tap Filter (1,1,2,2,4,2,2,1,1)/16 (C version) |
1604 * using the 7-Tap Filter (2,2,2,4,2,2,2)/16 (MMX2/3DNOW version) | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1605 */ |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1606 static inline void doHorizLowPass(uint8_t dst[], int stride, int QP) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1607 { |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1608 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1609 #if 0 |
2428 | 1610 asm volatile( |
1611 "leal (%0, %1), %%ecx \n\t" | |
1612 "leal (%%ecx, %1, 4), %%ebx \n\t" | |
1613 // 0 1 2 3 4 5 6 7 8 9 | |
1614 // %0 ecx ecx+%1 ecx+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1615 "pxor %%mm7, %%mm7 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1616 "leal tempBlock, %%eax \n\t" |
2159 | 1617 /* |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1618 #define HLP1 "movq (%0), %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1619 "movq %%mm0, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1620 "psllq $8, %%mm0 \n\t"\ |
2159 | 1621 PAVGB(%%mm1, %%mm0)\ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1622 "psrlw $8, %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1623 "pxor %%mm1, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1624 "packuswb %%mm1, %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1625 "movq %%mm0, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1626 "movq %%mm0, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1627 "psllq $32, %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1628 "paddb %%mm0, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1629 "psllq $16, %%mm2 \n\t"\ |
2159 | 1630 PAVGB(%%mm2, %%mm0)\ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1631 "movq %%mm0, %%mm3 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1632 "pand bm11001100, %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1633 "paddusb %%mm0, %%mm3 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1634 "psrlq $8, %%mm3 \n\t"\ |
2159 | 1635 PAVGB(%%mm1, %%mm4)\ |
1636 PAVGB(%%mm3, %%mm2)\ | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1637 "psrlq $16, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1638 "punpcklbw %%mm2, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1639 "movq %%mm2, (%0) \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1640 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1641 #define HLP2 "movq (%0), %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1642 "movq %%mm0, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1643 "psllq $8, %%mm0 \n\t"\ |
2159 | 1644 PAVGB(%%mm1, %%mm0)\ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1645 "psrlw $8, %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1646 "pxor %%mm1, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1647 "packuswb %%mm1, %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1648 "movq %%mm0, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1649 "psllq $32, %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1650 "psllq $16, %%mm2 \n\t"\ |
2159 | 1651 PAVGB(%%mm2, %%mm0)\ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1652 "movq %%mm0, %%mm3 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1653 "pand bm11001100, %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1654 "paddusb %%mm0, %%mm3 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1655 "psrlq $8, %%mm3 \n\t"\ |
2159 | 1656 PAVGB(%%mm3, %%mm2)\ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1657 "psrlq $16, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1658 "punpcklbw %%mm2, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1659 "movq %%mm2, (%0) \n\t"\ |
2159 | 1660 */ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1661 // approximately a 7-Tap Filter with Vector (1,2,3,4,3,2,1)/16 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1662 /* |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1663 Implemented Exact 7-Tap |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1664 9421 A321 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1665 36421 64321 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1666 334321 = |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1667 1234321 = |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1668 1234321 = |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1669 123433 = |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1670 12463 12346 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1671 1249 123A |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1672 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1673 */ |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1674 |
2159 | 1675 #ifdef HAVE_MMX2 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1676 #define HLP3(i) "movq " #i "(%%eax), %%mm0 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1677 "movq %%mm0, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1678 "movq %%mm0, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1679 "movq %%mm0, %%mm3 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1680 "movq %%mm0, %%mm4 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1681 "psllq $8, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1682 "psrlq $8, %%mm2 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1683 "pand bm00000001, %%mm3 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1684 "pand bm10000000, %%mm4 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1685 "por %%mm3, %%mm1 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1686 "por %%mm4, %%mm2 \n\t"\ |
2159 | 1687 PAVGB(%%mm2, %%mm1)\ |
1688 PAVGB(%%mm1, %%mm0)\ | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1689 \ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1690 "pshufw $0xF9, %%mm0, %%mm3 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1691 "pshufw $0x90, %%mm0, %%mm4 \n\t"\ |
2159 | 1692 PAVGB(%%mm3, %%mm4)\ |
1693 PAVGB(%%mm4, %%mm0)\ | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1694 "movd %%mm0, (%0) \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1695 "psrlq $32, %%mm0 \n\t"\ |
2159 | 1696 "movd %%mm0, 4(%0) \n\t" |
1697 #else | |
1698 #define HLP3(i) "movq " #i "(%%eax), %%mm0 \n\t"\ | |
1699 "movq %%mm0, %%mm1 \n\t"\ | |
1700 "movq %%mm0, %%mm2 \n\t"\ | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1701 "movd -4(%0), %%mm3 \n\t" /*0001000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1702 "movd 8(%0), %%mm4 \n\t" /*0001000*/\ |
2159 | 1703 "psllq $8, %%mm1 \n\t"\ |
1704 "psrlq $8, %%mm2 \n\t"\ | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1705 "psrlq $24, %%mm3 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1706 "psllq $56, %%mm4 \n\t"\ |
2159 | 1707 "por %%mm3, %%mm1 \n\t"\ |
1708 "por %%mm4, %%mm2 \n\t"\ | |
1709 PAVGB(%%mm2, %%mm1)\ | |
1710 PAVGB(%%mm1, %%mm0)\ | |
1711 \ | |
1712 "movq %%mm0, %%mm3 \n\t"\ | |
1713 "movq %%mm0, %%mm4 \n\t"\ | |
1714 "movq %%mm0, %%mm5 \n\t"\ | |
1715 "psrlq $16, %%mm3 \n\t"\ | |
1716 "psllq $16, %%mm4 \n\t"\ | |
1717 "pand bm11000000, %%mm5 \n\t"\ | |
1718 "por %%mm5, %%mm3 \n\t"\ | |
1719 "movq %%mm0, %%mm5 \n\t"\ | |
1720 "pand bm00000011, %%mm5 \n\t"\ | |
1721 "por %%mm5, %%mm4 \n\t"\ | |
1722 PAVGB(%%mm3, %%mm4)\ | |
1723 PAVGB(%%mm4, %%mm0)\ | |
1724 "movd %%mm0, (%0) \n\t"\ | |
1725 "psrlq $32, %%mm0 \n\t"\ | |
1726 "movd %%mm0, 4(%0) \n\t" | |
1727 #endif | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1728 |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1729 /* uses the 7-Tap Filter: 1112111 */ |
2428 | 1730 #define NEW_HLP(src, dst)\ |
1731 "movq " #src "(%%eax), %%mm1 \n\t"\ | |
1732 "movq " #src "(%%eax), %%mm2 \n\t"\ | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1733 "psllq $8, %%mm1 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1734 "psrlq $8, %%mm2 \n\t"\ |
2428 | 1735 "movd -4" #dst ", %%mm3 \n\t" /*0001000*/\ |
1736 "movd 8" #dst ", %%mm4 \n\t" /*0001000*/\ | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1737 "psrlq $24, %%mm3 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1738 "psllq $56, %%mm4 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1739 "por %%mm3, %%mm1 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1740 "por %%mm4, %%mm2 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1741 "movq %%mm1, %%mm5 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1742 PAVGB(%%mm2, %%mm1)\ |
2428 | 1743 "movq " #src "(%%eax), %%mm0 \n\t"\ |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1744 PAVGB(%%mm1, %%mm0)\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1745 "psllq $8, %%mm5 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1746 "psrlq $8, %%mm2 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1747 "por %%mm3, %%mm5 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1748 "por %%mm4, %%mm2 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1749 "movq %%mm5, %%mm1 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1750 PAVGB(%%mm2, %%mm5)\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1751 "psllq $8, %%mm1 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1752 "psrlq $8, %%mm2 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1753 "por %%mm3, %%mm1 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1754 "por %%mm4, %%mm2 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1755 PAVGB(%%mm2, %%mm1)\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1756 PAVGB(%%mm1, %%mm5)\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1757 PAVGB(%%mm5, %%mm0)\ |
2428 | 1758 "movd %%mm0, " #dst " \n\t"\ |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1759 "psrlq $32, %%mm0 \n\t"\ |
2428 | 1760 "movd %%mm0, 4" #dst " \n\t" |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1761 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1762 /* uses the 9-Tap Filter: 112242211 */ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1763 #define NEW_HLP2(i)\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1764 "movq " #i "(%%eax), %%mm0 \n\t" /*0001000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1765 "movq %%mm0, %%mm1 \n\t" /*0001000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1766 "movq %%mm0, %%mm2 \n\t" /*0001000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1767 "movd -4(%0), %%mm3 \n\t" /*0001000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1768 "movd 8(%0), %%mm4 \n\t" /*0001000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1769 "psllq $8, %%mm1 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1770 "psrlq $8, %%mm2 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1771 "psrlq $24, %%mm3 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1772 "psllq $56, %%mm4 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1773 "por %%mm3, %%mm1 \n\t" /*0010000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1774 "por %%mm4, %%mm2 \n\t" /*0000100*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1775 "movq %%mm1, %%mm5 \n\t" /*0010000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1776 PAVGB(%%mm2, %%mm1) /*0010100*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1777 PAVGB(%%mm1, %%mm0) /*0012100*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1778 "psllq $8, %%mm5 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1779 "psrlq $8, %%mm2 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1780 "por %%mm3, %%mm5 \n\t" /*0100000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1781 "por %%mm4, %%mm2 \n\t" /*0000010*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1782 "movq %%mm5, %%mm1 \n\t" /*0100000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1783 PAVGB(%%mm2, %%mm5) /*0100010*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1784 "psllq $8, %%mm1 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1785 "psrlq $8, %%mm2 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1786 "por %%mm3, %%mm1 \n\t" /*1000000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1787 "por %%mm4, %%mm2 \n\t" /*0000001*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1788 "movq %%mm1, %%mm6 \n\t" /*1000000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1789 PAVGB(%%mm2, %%mm1) /*1000001*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1790 "psllq $8, %%mm6 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1791 "psrlq $8, %%mm2 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1792 "por %%mm3, %%mm6 \n\t"/*100000000*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1793 "por %%mm4, %%mm2 \n\t"/*000000001*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1794 PAVGB(%%mm2, %%mm6) /*100000001*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1795 PAVGB(%%mm6, %%mm1) /*110000011*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1796 PAVGB(%%mm1, %%mm5) /*112000211*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1797 PAVGB(%%mm5, %%mm0) /*112242211*/\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1798 "movd %%mm0, (%0) \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1799 "psrlq $32, %%mm0 \n\t"\ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1800 "movd %%mm0, 4(%0) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
1801 |
2428 | 1802 #define HLP(src, dst) NEW_HLP(src, dst) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1803 |
2428 | 1804 HLP(0, (%0)) |
1805 HLP(8, (%%ecx)) | |
1806 HLP(16, (%%ecx, %1)) | |
1807 HLP(24, (%%ecx, %1, 2)) | |
1808 HLP(32, (%0, %1, 4)) | |
1809 HLP(40, (%%ebx)) | |
1810 HLP(48, (%%ebx, %1)) | |
1811 HLP(56, (%%ebx, %1, 2)) | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1812 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1813 : |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1814 : "r" (dst), "r" (stride) |
2428 | 1815 : "%eax", "%ebx", "%ecx" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1816 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1817 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1818 #else |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
1819 int y; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
1820 for(y=0; y<BLOCK_SIZE; y++) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1821 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1822 const int first= ABS(dst[-1] - dst[0]) < QP ? dst[-1] : dst[0]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1823 const int last= ABS(dst[8] - dst[7]) < QP ? dst[8] : dst[7]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1824 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1825 int sums[9]; |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1826 sums[0] = first + dst[0]; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1827 sums[1] = dst[0] + dst[1]; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1828 sums[2] = dst[1] + dst[2]; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1829 sums[3] = dst[2] + dst[3]; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1830 sums[4] = dst[3] + dst[4]; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1831 sums[5] = dst[4] + dst[5]; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1832 sums[6] = dst[5] + dst[6]; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1833 sums[7] = dst[6] + dst[7]; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
1834 sums[8] = dst[7] + last; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1835 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1836 dst[0]= ((sums[0]<<2) + ((first + sums[2])<<1) + sums[4] + 8)>>4; |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1837 dst[1]= ((dst[1]<<2) + ((first + sums[0] + sums[3])<<1) + sums[5] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1838 dst[2]= ((dst[2]<<2) + ((first + sums[1] + sums[4])<<1) + sums[6] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1839 dst[3]= ((dst[3]<<2) + ((sums[2] + sums[5])<<1) + sums[0] + sums[7] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1840 dst[4]= ((dst[4]<<2) + ((sums[3] + sums[6])<<1) + sums[1] + sums[8] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1841 dst[5]= ((dst[5]<<2) + ((last + sums[7] + sums[4])<<1) + sums[2] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1842 dst[6]= (((last + dst[6])<<2) + ((dst[7] + sums[5])<<1) + sums[3] + 8)>>4; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1843 dst[7]= ((sums[8]<<2) + ((last + sums[6])<<1) + sums[4] + 8)>>4; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1844 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1845 dst+= stride; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1846 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1847 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1848 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1849 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1850 static inline void dering(uint8_t src[], int stride, int QP) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1851 { |
2475 | 1852 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1853 asm volatile( |
2473 | 1854 "movq pQPb, %%mm0 \n\t" |
1855 "paddusb %%mm0, %%mm0 \n\t" | |
1856 "movq %%mm0, pQPb2 \n\t" | |
1857 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1858 "leal (%0, %1), %%eax \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1859 "leal (%%eax, %1, 4), %%ebx \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1860 // 0 1 2 3 4 5 6 7 8 9 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1861 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1862 |
2473 | 1863 "pcmpeqb %%mm6, %%mm6 \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1864 "pxor %%mm7, %%mm7 \n\t" |
2475 | 1865 #ifdef HAVE_MMX2 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1866 #define FIND_MIN_MAX(addr)\ |
2473 | 1867 "movq " #addr ", %%mm0 \n\t"\ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1868 "pminub %%mm0, %%mm6 \n\t"\ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1869 "pmaxub %%mm0, %%mm7 \n\t" |
2475 | 1870 #else |
1871 #define FIND_MIN_MAX(addr)\ | |
1872 "movq " #addr ", %%mm0 \n\t"\ | |
1873 "movq %%mm6, %%mm1 \n\t"\ | |
1874 "psubusb %%mm0, %%mm7 \n\t"\ | |
1875 "paddb %%mm0, %%mm7 \n\t"\ | |
1876 "psubusb %%mm0, %%mm1 \n\t"\ | |
1877 "psubb %%mm1, %%mm6 \n\t" | |
1878 #endif | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1879 |
2473 | 1880 FIND_MIN_MAX((%%eax)) |
1881 FIND_MIN_MAX((%%eax, %1)) | |
1882 FIND_MIN_MAX((%%eax, %1, 2)) | |
1883 FIND_MIN_MAX((%0, %1, 4)) | |
1884 FIND_MIN_MAX((%%ebx)) | |
1885 FIND_MIN_MAX((%%ebx, %1)) | |
1886 FIND_MIN_MAX((%%ebx, %1, 2)) | |
1887 FIND_MIN_MAX((%0, %1, 8)) | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1888 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1889 "movq %%mm6, %%mm4 \n\t" |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1890 "psrlq $8, %%mm6 \n\t" |
2475 | 1891 #ifdef HAVE_MMX2 |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1892 "pminub %%mm4, %%mm6 \n\t" // min of pixels |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1893 "pshufw $0xF9, %%mm6, %%mm4 \n\t" |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1894 "pminub %%mm4, %%mm6 \n\t" // min of pixels |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1895 "pshufw $0xFE, %%mm6, %%mm4 \n\t" |
2475 | 1896 "pminub %%mm4, %%mm6 \n\t" |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1897 #else |
2475 | 1898 "movq %%mm6, %%mm1 \n\t" |
1899 "psubusb %%mm4, %%mm1 \n\t" | |
1900 "psubb %%mm1, %%mm6 \n\t" | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1901 "movq %%mm6, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1902 "psrlq $16, %%mm6 \n\t" |
2475 | 1903 "movq %%mm6, %%mm1 \n\t" |
1904 "psubusb %%mm4, %%mm1 \n\t" | |
1905 "psubb %%mm1, %%mm6 \n\t" | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1906 "movq %%mm6, %%mm4 \n\t" |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1907 "psrlq $32, %%mm6 \n\t" |
2475 | 1908 "movq %%mm6, %%mm1 \n\t" |
1909 "psubusb %%mm4, %%mm1 \n\t" | |
1910 "psubb %%mm1, %%mm6 \n\t" | |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1911 #endif |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1912 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1913 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1914 "movq %%mm7, %%mm4 \n\t" |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1915 "psrlq $8, %%mm7 \n\t" |
2475 | 1916 #ifdef HAVE_MMX2 |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1917 "pmaxub %%mm4, %%mm7 \n\t" // max of pixels |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1918 "pshufw $0xF9, %%mm7, %%mm4 \n\t" |
2475 | 1919 "pmaxub %%mm4, %%mm7 \n\t" |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1920 "pshufw $0xFE, %%mm7, %%mm4 \n\t" |
2475 | 1921 "pmaxub %%mm4, %%mm7 \n\t" |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1922 #else |
2475 | 1923 "psubusb %%mm4, %%mm7 \n\t" |
1924 "paddb %%mm4, %%mm7 \n\t" | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1925 "movq %%mm7, %%mm4 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1926 "psrlq $16, %%mm7 \n\t" |
2475 | 1927 "psubusb %%mm4, %%mm7 \n\t" |
1928 "paddb %%mm4, %%mm7 \n\t" | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
1929 "movq %%mm7, %%mm4 \n\t" |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1930 "psrlq $32, %%mm7 \n\t" |
2475 | 1931 "psubusb %%mm4, %%mm7 \n\t" |
1932 "paddb %%mm4, %%mm7 \n\t" | |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1933 #endif |
2473 | 1934 PAVGB(%%mm6, %%mm7) // a=(max + min)/2 |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1935 "punpcklbw %%mm7, %%mm7 \n\t" |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1936 "punpcklbw %%mm7, %%mm7 \n\t" |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
1937 "punpcklbw %%mm7, %%mm7 \n\t" |
2473 | 1938 "movq %%mm7, temp0 \n\t" |
1939 | |
1940 "movq (%0), %%mm0 \n\t" // L10 | |
1941 "movq %%mm0, %%mm1 \n\t" // L10 | |
1942 "movq %%mm0, %%mm2 \n\t" // L10 | |
1943 "psllq $8, %%mm1 \n\t" | |
1944 "psrlq $8, %%mm2 \n\t" | |
1945 "movd -4(%0), %%mm3 \n\t" | |
1946 "movd 8(%0), %%mm4 \n\t" | |
1947 "psrlq $24, %%mm3 \n\t" | |
1948 "psllq $56, %%mm4 \n\t" | |
1949 "por %%mm3, %%mm1 \n\t" // L00 | |
1950 "por %%mm4, %%mm2 \n\t" // L20 | |
1951 "movq %%mm1, %%mm3 \n\t" // L00 | |
1952 PAVGB(%%mm2, %%mm1) // (L20 + L00)/2 | |
1953 PAVGB(%%mm0, %%mm1) // (L20 + L00 + 2L10)/4 | |
1954 "psubusb %%mm7, %%mm0 \n\t" | |
1955 "psubusb %%mm7, %%mm2 \n\t" | |
1956 "psubusb %%mm7, %%mm3 \n\t" | |
1957 "pcmpeqb b00, %%mm0 \n\t" // L10 > a ? 0 : -1 | |
1958 "pcmpeqb b00, %%mm2 \n\t" // L20 > a ? 0 : -1 | |
1959 "pcmpeqb b00, %%mm3 \n\t" // L00 > a ? 0 : -1 | |
1960 "paddb %%mm2, %%mm0 \n\t" | |
1961 "paddb %%mm3, %%mm0 \n\t" | |
1962 | |
1963 "movq (%%eax), %%mm2 \n\t" // L11 | |
1964 "movq %%mm2, %%mm3 \n\t" // L11 | |
1965 "movq %%mm2, %%mm4 \n\t" // L11 | |
1966 "psllq $8, %%mm3 \n\t" | |
1967 "psrlq $8, %%mm4 \n\t" | |
1968 "movd -4(%%eax), %%mm5 \n\t" | |
1969 "movd 8(%%eax), %%mm6 \n\t" | |
1970 "psrlq $24, %%mm5 \n\t" | |
1971 "psllq $56, %%mm6 \n\t" | |
1972 "por %%mm5, %%mm3 \n\t" // L01 | |
1973 "por %%mm6, %%mm4 \n\t" // L21 | |
1974 "movq %%mm3, %%mm5 \n\t" // L01 | |
1975 PAVGB(%%mm4, %%mm3) // (L21 + L01)/2 | |
1976 PAVGB(%%mm2, %%mm3) // (L21 + L01 + 2L11)/4 | |
1977 "psubusb %%mm7, %%mm2 \n\t" | |
1978 "psubusb %%mm7, %%mm4 \n\t" | |
1979 "psubusb %%mm7, %%mm5 \n\t" | |
1980 "pcmpeqb b00, %%mm2 \n\t" // L11 > a ? 0 : -1 | |
1981 "pcmpeqb b00, %%mm4 \n\t" // L21 > a ? 0 : -1 | |
1982 "pcmpeqb b00, %%mm5 \n\t" // L01 > a ? 0 : -1 | |
1983 "paddb %%mm4, %%mm2 \n\t" | |
1984 "paddb %%mm5, %%mm2 \n\t" | |
1985 // 0, 2, 3, 1 | |
1986 #define DERING_CORE(dst,src,ppsx,psx,sx,pplx,plx,lx,t0,t1) \ | |
1987 "movq " #src ", " #sx " \n\t" /* src[0] */\ | |
1988 "movq " #sx ", " #lx " \n\t" /* src[0] */\ | |
1989 "movq " #sx ", " #t0 " \n\t" /* src[0] */\ | |
1990 "psllq $8, " #lx " \n\t"\ | |
1991 "psrlq $8, " #t0 " \n\t"\ | |
1992 "movd -4" #src ", " #t1 " \n\t"\ | |
1993 "psrlq $24, " #t1 " \n\t"\ | |
1994 "por " #t1 ", " #lx " \n\t" /* src[-1] */\ | |
1995 "movd 8" #src ", " #t1 " \n\t"\ | |
1996 "psllq $56, " #t1 " \n\t"\ | |
1997 "por " #t1 ", " #t0 " \n\t" /* src[+1] */\ | |
1998 "movq " #lx ", " #t1 " \n\t" /* src[-1] */\ | |
1999 PAVGB(t0, lx) /* (src[-1] + src[+1])/2 */\ | |
2000 PAVGB(sx, lx) /* (src[-1] + 2src[0] + src[+1])/4 */\ | |
2478 | 2001 PAVGB(lx, pplx) \ |
2002 "movq " #lx ", temp1 \n\t"\ | |
2003 "movq temp0, " #lx " \n\t"\ | |
2570 | 2004 "psubusb " #lx ", " #t1 " \n\t"\ |
2005 "psubusb " #lx ", " #t0 " \n\t"\ | |
2006 "psubusb " #lx ", " #sx " \n\t"\ | |
2478 | 2007 "movq b00, " #lx " \n\t"\ |
2570 | 2008 "pcmpeqb " #lx ", " #t1 " \n\t" /* src[-1] > a ? 0 : -1*/\ |
2009 "pcmpeqb " #lx ", " #t0 " \n\t" /* src[+1] > a ? 0 : -1*/\ | |
2010 "pcmpeqb " #lx ", " #sx " \n\t" /* src[0] > a ? 0 : -1*/\ | |
2473 | 2011 "paddb " #t1 ", " #t0 " \n\t"\ |
2012 "paddb " #t0 ", " #sx " \n\t"\ | |
2013 \ | |
2014 PAVGB(plx, pplx) /* filtered */\ | |
2015 "movq " #dst ", " #t0 " \n\t" /* dst */\ | |
2477 | 2016 "movq " #t0 ", " #t1 " \n\t" /* dst */\ |
2017 "psubusb pQPb2, " #t0 " \n\t"\ | |
2018 "paddusb pQPb2, " #t1 " \n\t"\ | |
2019 PMAXUB(t0, pplx)\ | |
2020 PMINUB(t1, pplx, t0)\ | |
2473 | 2021 "paddb " #sx ", " #ppsx " \n\t"\ |
2022 "paddb " #psx ", " #ppsx " \n\t"\ | |
2023 "#paddb b02, " #ppsx " \n\t"\ | |
2024 "pand b08, " #ppsx " \n\t"\ | |
2570 | 2025 "pcmpeqb " #lx ", " #ppsx " \n\t"\ |
2477 | 2026 "pand " #ppsx ", " #pplx " \n\t"\ |
2473 | 2027 "pandn " #dst ", " #ppsx " \n\t"\ |
2570 | 2028 "por " #pplx ", " #ppsx " \n\t"\ |
2478 | 2029 "movq " #ppsx ", " #dst " \n\t"\ |
2030 "movq temp1, " #lx " \n\t" | |
2477 | 2031 |
2473 | 2032 /* |
2033 0000000 | |
2034 1111111 | |
2035 | |
2036 1111110 | |
2037 1111101 | |
2038 1111100 | |
2039 1111011 | |
2040 1111010 | |
2041 1111001 | |
2042 | |
2043 1111000 | |
2044 1110111 | |
2045 | |
2046 */ | |
2047 //DERING_CORE(dst,src ,ppsx ,psx ,sx ,pplx ,plx ,lx ,t0 ,t1) | |
2048 DERING_CORE((%%eax),(%%eax, %1) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7) | |
2049 DERING_CORE((%%eax, %1),(%%eax, %1, 2) ,%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7) | |
2050 DERING_CORE((%%eax, %1, 2),(%0, %1, 4) ,%%mm4,%%mm0,%%mm2,%%mm5,%%mm1,%%mm3,%%mm6,%%mm7) | |
2051 DERING_CORE((%0, %1, 4),(%%ebx) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7) | |
2052 DERING_CORE((%%ebx),(%%ebx, %1) ,%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7) | |
2053 DERING_CORE((%%ebx, %1), (%%ebx, %1, 2),%%mm4,%%mm0,%%mm2,%%mm5,%%mm1,%%mm3,%%mm6,%%mm7) | |
2054 DERING_CORE((%%ebx, %1, 2),(%0, %1, 8) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7) | |
2055 DERING_CORE((%0, %1, 8),(%%ebx, %1, 4) ,%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7) | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2056 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2057 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2058 : : "r" (src), "r" (stride), "r" (QP) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2059 : "%eax", "%ebx" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2060 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2061 #else |
2477 | 2062 int y; |
2063 int min=255; | |
2064 int max=0; | |
2065 int avg; | |
2066 uint8_t *p; | |
2067 int s[10]; | |
2068 | |
2069 for(y=1; y<9; y++) | |
2070 { | |
2071 int x; | |
2072 p= src + stride*y; | |
2073 for(x=1; x<9; x++) | |
2074 { | |
2075 p++; | |
2076 if(*p > max) max= *p; | |
2077 if(*p < min) min= *p; | |
2078 } | |
2079 } | |
2080 avg= (min + max + 1)/2; | |
2081 | |
2082 for(y=0; y<10; y++) | |
2083 { | |
2084 int x; | |
2085 int t = 0; | |
2086 p= src + stride*y; | |
2087 for(x=0; x<10; x++) | |
2088 { | |
2089 if(*p > avg) t |= (1<<x); | |
2090 p++; | |
2091 } | |
2092 t |= (~t)<<16; | |
2093 t &= (t<<1) & (t>>1); | |
2094 s[y] = t; | |
2095 } | |
2096 | |
2097 for(y=1; y<9; y++) | |
2098 { | |
2099 int x; | |
2100 int t = s[y-1] & s[y] & s[y+1]; | |
2101 t|= t>>16; | |
2102 | |
2103 p= src + stride*y; | |
2104 for(x=1; x<9; x++) | |
2105 { | |
2106 p++; | |
2107 if(t & (1<<x)) | |
2108 { | |
2109 int f= (*(p-stride-1)) + 2*(*(p-stride)) + (*(p-stride+1)) | |
2110 +2*(*(p -1)) + 4*(*p ) + 2*(*(p +1)) | |
2111 +(*(p+stride-1)) + 2*(*(p+stride)) + (*(p+stride+1)); | |
2112 f= (f + 8)>>4; | |
2113 | |
2114 if (*p + 2*QP < f) *p= *p + 2*QP; | |
2115 else if(*p - 2*QP > f) *p= *p - 2*QP; | |
2116 else *p=f; | |
2117 } | |
2118 } | |
2119 } | |
2120 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2121 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2122 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2123 |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2124 /** |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2125 * Deinterlaces the given block |
2595 | 2126 * will be called for every 8x8 block and can read & write from line 4-15 |
2127 * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too | |
2128 * lines 4-12 will be read into the deblocking filter and should be deinterlaced | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2129 */ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2130 static inline void deInterlaceInterpolateLinear(uint8_t src[], int stride) |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2131 { |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2132 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
2595 | 2133 src+= 4*stride; |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2134 asm volatile( |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2135 "leal (%0, %1), %%eax \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2136 "leal (%%eax, %1, 4), %%ebx \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2137 // 0 1 2 3 4 5 6 7 8 9 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2138 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2139 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2140 "movq (%0), %%mm0 \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2141 "movq (%%eax, %1), %%mm1 \n\t" |
2246 | 2142 PAVGB(%%mm1, %%mm0) |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2143 "movq %%mm0, (%%eax) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2144 "movq (%0, %1, 4), %%mm0 \n\t" |
2246 | 2145 PAVGB(%%mm0, %%mm1) |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2146 "movq %%mm1, (%%eax, %1, 2) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2147 "movq (%%ebx, %1), %%mm1 \n\t" |
2246 | 2148 PAVGB(%%mm1, %%mm0) |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2149 "movq %%mm0, (%%ebx) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2150 "movq (%0, %1, 8), %%mm0 \n\t" |
2246 | 2151 PAVGB(%%mm0, %%mm1) |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2152 "movq %%mm1, (%%ebx, %1, 2) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2153 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2154 : : "r" (src), "r" (stride) |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2155 : "%eax", "%ebx" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2156 ); |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2157 #else |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2158 int x; |
2595 | 2159 src+= 4*stride; |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2160 for(x=0; x<8; x++) |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2161 { |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2162 src[stride] = (src[0] + src[stride*2])>>1; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2163 src[stride*3] = (src[stride*2] + src[stride*4])>>1; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2164 src[stride*5] = (src[stride*4] + src[stride*6])>>1; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2165 src[stride*7] = (src[stride*6] + src[stride*8])>>1; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2166 src++; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2167 } |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2168 #endif |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2169 } |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2170 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2171 /** |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2172 * Deinterlaces the given block |
2595 | 2173 * will be called for every 8x8 block and can read & write from line 4-15 |
2174 * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too | |
2175 * lines 4-12 will be read into the deblocking filter and should be deinterlaced | |
2176 * this filter will read lines 3-15 and write 7-13 | |
2246 | 2177 * no cliping in C version |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2178 */ |
2246 | 2179 static inline void deInterlaceInterpolateCubic(uint8_t src[], int stride) |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2180 { |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2181 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
2595 | 2182 src+= stride*3; |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2183 asm volatile( |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2184 "leal (%0, %1), %%eax \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2185 "leal (%%eax, %1, 4), %%ebx \n\t" |
2246 | 2186 "leal (%%ebx, %1, 4), %%ecx \n\t" |
2187 "addl %1, %%ecx \n\t" | |
2188 "pxor %%mm7, %%mm7 \n\t" | |
2189 // 0 1 2 3 4 5 6 7 8 9 10 | |
2190 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 ecx | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2191 |
2246 | 2192 #define DEINT_CUBIC(a,b,c,d,e)\ |
2193 "movq " #a ", %%mm0 \n\t"\ | |
2194 "movq " #b ", %%mm1 \n\t"\ | |
2195 "movq " #d ", %%mm2 \n\t"\ | |
2196 "movq " #e ", %%mm3 \n\t"\ | |
2197 PAVGB(%%mm2, %%mm1) /* (b+d) /2 */\ | |
2198 PAVGB(%%mm3, %%mm0) /* a(a+e) /2 */\ | |
2199 "movq %%mm0, %%mm2 \n\t"\ | |
2200 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
2201 "punpckhbw %%mm7, %%mm2 \n\t"\ | |
2202 "movq %%mm1, %%mm3 \n\t"\ | |
2203 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
2204 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
2205 "psubw %%mm1, %%mm0 \n\t" /* L(a+e - (b+d))/2 */\ | |
2206 "psubw %%mm3, %%mm2 \n\t" /* H(a+e - (b+d))/2 */\ | |
2207 "psraw $3, %%mm0 \n\t" /* L(a+e - (b+d))/16 */\ | |
2208 "psraw $3, %%mm2 \n\t" /* H(a+e - (b+d))/16 */\ | |
2209 "psubw %%mm0, %%mm1 \n\t" /* L(9b + 9d - a - e)/16 */\ | |
2210 "psubw %%mm2, %%mm3 \n\t" /* H(9b + 9d - a - e)/16 */\ | |
2211 "packuswb %%mm3, %%mm1 \n\t"\ | |
2212 "movq %%mm1, " #c " \n\t" | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2213 |
2246 | 2214 DEINT_CUBIC((%0), (%%eax, %1), (%%eax, %1, 2), (%0, %1, 4), (%%ebx, %1)) |
2215 DEINT_CUBIC((%%eax, %1), (%0, %1, 4), (%%ebx), (%%ebx, %1), (%0, %1, 8)) | |
2216 DEINT_CUBIC((%0, %1, 4), (%%ebx, %1), (%%ebx, %1, 2), (%0, %1, 8), (%%ecx)) | |
2217 DEINT_CUBIC((%%ebx, %1), (%0, %1, 8), (%%ebx, %1, 4), (%%ecx), (%%ecx, %1, 2)) | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2218 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2219 : : "r" (src), "r" (stride) |
2246 | 2220 : "%eax", "%ebx", "ecx" |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2221 ); |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2222 #else |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2223 int x; |
2595 | 2224 src+= stride*3; |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2225 for(x=0; x<8; x++) |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2226 { |
2246 | 2227 src[stride*3] = (-src[0] + 9*src[stride*2] + 9*src[stride*4] - src[stride*6])>>4; |
2228 src[stride*5] = (-src[stride*2] + 9*src[stride*4] + 9*src[stride*6] - src[stride*8])>>4; | |
2229 src[stride*7] = (-src[stride*4] + 9*src[stride*6] + 9*src[stride*8] - src[stride*10])>>4; | |
2230 src[stride*9] = (-src[stride*6] + 9*src[stride*8] + 9*src[stride*10] - src[stride*12])>>4; | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2231 src++; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2232 } |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2233 #endif |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2234 } |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2235 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2236 /** |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2237 * Deinterlaces the given block |
2595 | 2238 * will be called for every 8x8 block and can read & write from line 4-15 |
2239 * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too | |
2240 * lines 4-12 will be read into the deblocking filter and should be deinterlaced | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2241 * will shift the image up by 1 line (FIXME if this is a problem) |
2595 | 2242 * this filter will read lines 4-13 and write 4-11 |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2243 */ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2244 static inline void deInterlaceBlendLinear(uint8_t src[], int stride) |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2245 { |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2246 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
2595 | 2247 src+= 4*stride; |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2248 asm volatile( |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2249 "leal (%0, %1), %%eax \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2250 "leal (%%eax, %1, 4), %%ebx \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2251 // 0 1 2 3 4 5 6 7 8 9 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2252 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2253 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2254 "movq (%0), %%mm0 \n\t" // L0 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2255 "movq (%%eax, %1), %%mm1 \n\t" // L2 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2256 PAVGB(%%mm1, %%mm0) // L0+L2 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2257 "movq (%%eax), %%mm2 \n\t" // L1 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2258 PAVGB(%%mm2, %%mm0) |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2259 "movq %%mm0, (%0) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2260 "movq (%%eax, %1, 2), %%mm0 \n\t" // L3 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2261 PAVGB(%%mm0, %%mm2) // L1+L3 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2262 PAVGB(%%mm1, %%mm2) // 2L2 + L1 + L3 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2263 "movq %%mm2, (%%eax) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2264 "movq (%0, %1, 4), %%mm2 \n\t" // L4 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2265 PAVGB(%%mm2, %%mm1) // L2+L4 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2266 PAVGB(%%mm0, %%mm1) // 2L3 + L2 + L4 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2267 "movq %%mm1, (%%eax, %1) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2268 "movq (%%ebx), %%mm1 \n\t" // L5 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2269 PAVGB(%%mm1, %%mm0) // L3+L5 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2270 PAVGB(%%mm2, %%mm0) // 2L4 + L3 + L5 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2271 "movq %%mm0, (%%eax, %1, 2) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2272 "movq (%%ebx, %1), %%mm0 \n\t" // L6 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2273 PAVGB(%%mm0, %%mm2) // L4+L6 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2274 PAVGB(%%mm1, %%mm2) // 2L5 + L4 + L6 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2275 "movq %%mm2, (%0, %1, 4) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2276 "movq (%%ebx, %1, 2), %%mm2 \n\t" // L7 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2277 PAVGB(%%mm2, %%mm1) // L5+L7 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2278 PAVGB(%%mm0, %%mm1) // 2L6 + L5 + L7 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2279 "movq %%mm1, (%%ebx) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2280 "movq (%0, %1, 8), %%mm1 \n\t" // L8 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2281 PAVGB(%%mm1, %%mm0) // L6+L8 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2282 PAVGB(%%mm2, %%mm0) // 2L7 + L6 + L8 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2283 "movq %%mm0, (%%ebx, %1) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2284 "movq (%%ebx, %1, 4), %%mm0 \n\t" // L9 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2285 PAVGB(%%mm0, %%mm2) // L7+L9 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2286 PAVGB(%%mm1, %%mm2) // 2L8 + L7 + L9 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2287 "movq %%mm2, (%%ebx, %1, 2) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2288 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2289 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2290 : : "r" (src), "r" (stride) |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2291 : "%eax", "%ebx" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2292 ); |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2293 #else |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2294 int x; |
2595 | 2295 src+= 4*stride; |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2296 for(x=0; x<8; x++) |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2297 { |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2298 src[0 ] = (src[0 ] + 2*src[stride ] + src[stride*2])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2299 src[stride ] = (src[stride ] + 2*src[stride*2] + src[stride*3])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2300 src[stride*2] = (src[stride*2] + 2*src[stride*3] + src[stride*4])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2301 src[stride*3] = (src[stride*3] + 2*src[stride*4] + src[stride*5])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2302 src[stride*4] = (src[stride*4] + 2*src[stride*5] + src[stride*6])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2303 src[stride*5] = (src[stride*5] + 2*src[stride*6] + src[stride*7])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2304 src[stride*6] = (src[stride*6] + 2*src[stride*7] + src[stride*8])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2305 src[stride*7] = (src[stride*7] + 2*src[stride*8] + src[stride*9])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2306 src++; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2307 } |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2308 #endif |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2309 } |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2310 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2311 /** |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2312 * Deinterlaces the given block |
2595 | 2313 * will be called for every 8x8 block and can read & write from line 4-15, |
2314 * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too | |
2315 * lines 4-12 will be read into the deblocking filter and should be deinterlaced | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2316 */ |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2317 static inline void deInterlaceMedian(uint8_t src[], int stride) |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2318 { |
2221 | 2319 #ifdef HAVE_MMX |
2595 | 2320 src+= 4*stride; |
2221 | 2321 #ifdef HAVE_MMX2 |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2322 asm volatile( |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2323 "leal (%0, %1), %%eax \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2324 "leal (%%eax, %1, 4), %%ebx \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2325 // 0 1 2 3 4 5 6 7 8 9 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2326 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2327 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2328 "movq (%0), %%mm0 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2329 "movq (%%eax, %1), %%mm2 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2330 "movq (%%eax), %%mm1 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2331 "movq %%mm0, %%mm3 \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2332 "pmaxub %%mm1, %%mm0 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2333 "pminub %%mm3, %%mm1 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2334 "pmaxub %%mm2, %%mm1 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2335 "pminub %%mm1, %%mm0 \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2336 "movq %%mm0, (%%eax) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2337 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2338 "movq (%0, %1, 4), %%mm0 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2339 "movq (%%eax, %1, 2), %%mm1 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2340 "movq %%mm2, %%mm3 \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2341 "pmaxub %%mm1, %%mm2 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2342 "pminub %%mm3, %%mm1 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2343 "pmaxub %%mm0, %%mm1 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2344 "pminub %%mm1, %%mm2 \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2345 "movq %%mm2, (%%eax, %1, 2) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2346 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2347 "movq (%%ebx), %%mm2 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2348 "movq (%%ebx, %1), %%mm1 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2349 "movq %%mm2, %%mm3 \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2350 "pmaxub %%mm0, %%mm2 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2351 "pminub %%mm3, %%mm0 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2352 "pmaxub %%mm1, %%mm0 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2353 "pminub %%mm0, %%mm2 \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2354 "movq %%mm2, (%%ebx) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2355 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2356 "movq (%%ebx, %1, 2), %%mm2 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2357 "movq (%0, %1, 8), %%mm0 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2358 "movq %%mm2, %%mm3 \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2359 "pmaxub %%mm0, %%mm2 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2360 "pminub %%mm3, %%mm0 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2361 "pmaxub %%mm1, %%mm0 \n\t" // |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2362 "pminub %%mm0, %%mm2 \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2363 "movq %%mm2, (%%ebx, %1, 2) \n\t" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2364 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2365 |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2366 : : "r" (src), "r" (stride) |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2367 : "%eax", "%ebx" |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2368 ); |
2221 | 2369 |
2370 #else // MMX without MMX2 | |
2371 asm volatile( | |
2372 "leal (%0, %1), %%eax \n\t" | |
2373 "leal (%%eax, %1, 4), %%ebx \n\t" | |
2374 // 0 1 2 3 4 5 6 7 8 9 | |
2375 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 | |
2376 "pxor %%mm7, %%mm7 \n\t" | |
2377 | |
2378 #define MEDIAN(a,b,c)\ | |
2379 "movq " #a ", %%mm0 \n\t"\ | |
2380 "movq " #b ", %%mm2 \n\t"\ | |
2381 "movq " #c ", %%mm1 \n\t"\ | |
2382 "movq %%mm0, %%mm3 \n\t"\ | |
2383 "movq %%mm1, %%mm4 \n\t"\ | |
2384 "movq %%mm2, %%mm5 \n\t"\ | |
2385 "psubusb %%mm1, %%mm3 \n\t"\ | |
2386 "psubusb %%mm2, %%mm4 \n\t"\ | |
2387 "psubusb %%mm0, %%mm5 \n\t"\ | |
2388 "pcmpeqb %%mm7, %%mm3 \n\t"\ | |
2389 "pcmpeqb %%mm7, %%mm4 \n\t"\ | |
2390 "pcmpeqb %%mm7, %%mm5 \n\t"\ | |
2391 "movq %%mm3, %%mm6 \n\t"\ | |
2392 "pxor %%mm4, %%mm3 \n\t"\ | |
2393 "pxor %%mm5, %%mm4 \n\t"\ | |
2394 "pxor %%mm6, %%mm5 \n\t"\ | |
2395 "por %%mm3, %%mm1 \n\t"\ | |
2396 "por %%mm4, %%mm2 \n\t"\ | |
2397 "por %%mm5, %%mm0 \n\t"\ | |
2398 "pand %%mm2, %%mm0 \n\t"\ | |
2399 "pand %%mm1, %%mm0 \n\t"\ | |
2400 "movq %%mm0, " #b " \n\t" | |
2401 | |
2402 MEDIAN((%0), (%%eax), (%%eax, %1)) | |
2403 MEDIAN((%%eax, %1), (%%eax, %1, 2), (%0, %1, 4)) | |
2404 MEDIAN((%0, %1, 4), (%%ebx), (%%ebx, %1)) | |
2405 MEDIAN((%%ebx, %1), (%%ebx, %1, 2), (%0, %1, 8)) | |
2406 | |
2407 : : "r" (src), "r" (stride) | |
2408 : "%eax", "%ebx" | |
2409 ); | |
2410 #endif // MMX | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2411 #else |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2412 //FIXME |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2413 int x; |
2595 | 2414 src+= 4*stride; |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2415 for(x=0; x<8; x++) |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2416 { |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2417 src[0 ] = (src[0 ] + 2*src[stride ] + src[stride*2])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2418 src[stride ] = (src[stride ] + 2*src[stride*2] + src[stride*3])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2419 src[stride*2] = (src[stride*2] + 2*src[stride*3] + src[stride*4])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2420 src[stride*3] = (src[stride*3] + 2*src[stride*4] + src[stride*5])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2421 src[stride*4] = (src[stride*4] + 2*src[stride*5] + src[stride*6])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2422 src[stride*5] = (src[stride*5] + 2*src[stride*6] + src[stride*7])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2423 src[stride*6] = (src[stride*6] + 2*src[stride*7] + src[stride*8])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2424 src[stride*7] = (src[stride*7] + 2*src[stride*8] + src[stride*9])>>2; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2425 src++; |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2426 } |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2427 #endif |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2428 } |
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
2429 |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
2430 #ifdef HAVE_MMX |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2431 /** |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2432 * transposes and shift the given 8x8 Block into dst1 and dst2 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2433 */ |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2434 static inline void transpose1(uint8_t *dst1, uint8_t *dst2, uint8_t *src, int srcStride) |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2435 { |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2436 asm( |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2437 "leal (%0, %1), %%eax \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2438 "leal (%%eax, %1, 4), %%ebx \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2439 // 0 1 2 3 4 5 6 7 8 9 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2440 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2441 "movq (%0), %%mm0 \n\t" // 12345678 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2442 "movq (%%eax), %%mm1 \n\t" // abcdefgh |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2443 "movq %%mm0, %%mm2 \n\t" // 12345678 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2444 "punpcklbw %%mm1, %%mm0 \n\t" // 1a2b3c4d |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2445 "punpckhbw %%mm1, %%mm2 \n\t" // 5e6f7g8h |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2446 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2447 "movq (%%eax, %1), %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2448 "movq (%%eax, %1, 2), %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2449 "movq %%mm1, %%mm4 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2450 "punpcklbw %%mm3, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2451 "punpckhbw %%mm3, %%mm4 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2452 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2453 "movq %%mm0, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2454 "punpcklwd %%mm1, %%mm0 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2455 "punpckhwd %%mm1, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2456 "movq %%mm2, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2457 "punpcklwd %%mm4, %%mm2 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2458 "punpckhwd %%mm4, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2459 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2460 "movd %%mm0, 128(%2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2461 "psrlq $32, %%mm0 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2462 "movd %%mm0, 144(%2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2463 "movd %%mm3, 160(%2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2464 "psrlq $32, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2465 "movd %%mm3, 176(%2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2466 "movd %%mm3, 48(%3) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2467 "movd %%mm2, 192(%2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2468 "movd %%mm2, 64(%3) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2469 "psrlq $32, %%mm2 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2470 "movd %%mm2, 80(%3) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2471 "movd %%mm1, 96(%3) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2472 "psrlq $32, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2473 "movd %%mm1, 112(%3) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2474 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2475 "movq (%0, %1, 4), %%mm0 \n\t" // 12345678 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2476 "movq (%%ebx), %%mm1 \n\t" // abcdefgh |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2477 "movq %%mm0, %%mm2 \n\t" // 12345678 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2478 "punpcklbw %%mm1, %%mm0 \n\t" // 1a2b3c4d |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2479 "punpckhbw %%mm1, %%mm2 \n\t" // 5e6f7g8h |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2480 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2481 "movq (%%ebx, %1), %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2482 "movq (%%ebx, %1, 2), %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2483 "movq %%mm1, %%mm4 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2484 "punpcklbw %%mm3, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2485 "punpckhbw %%mm3, %%mm4 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2486 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2487 "movq %%mm0, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2488 "punpcklwd %%mm1, %%mm0 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2489 "punpckhwd %%mm1, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2490 "movq %%mm2, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2491 "punpcklwd %%mm4, %%mm2 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2492 "punpckhwd %%mm4, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2493 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2494 "movd %%mm0, 132(%2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2495 "psrlq $32, %%mm0 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2496 "movd %%mm0, 148(%2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2497 "movd %%mm3, 164(%2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2498 "psrlq $32, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2499 "movd %%mm3, 180(%2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2500 "movd %%mm3, 52(%3) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2501 "movd %%mm2, 196(%2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2502 "movd %%mm2, 68(%3) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2503 "psrlq $32, %%mm2 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2504 "movd %%mm2, 84(%3) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2505 "movd %%mm1, 100(%3) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2506 "psrlq $32, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2507 "movd %%mm1, 116(%3) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2508 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2509 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2510 :: "r" (src), "r" (srcStride), "r" (dst1), "r" (dst2) |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2511 : "%eax", "%ebx" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2512 ); |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2513 } |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2514 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2515 /** |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2516 * transposes the given 8x8 block |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2517 */ |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2518 static inline void transpose2(uint8_t *dst, int dstStride, uint8_t *src) |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2519 { |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2520 asm( |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2521 "leal (%0, %1), %%eax \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2522 "leal (%%eax, %1, 4), %%ebx \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2523 // 0 1 2 3 4 5 6 7 8 9 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2524 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2525 "movq (%2), %%mm0 \n\t" // 12345678 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2526 "movq 16(%2), %%mm1 \n\t" // abcdefgh |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2527 "movq %%mm0, %%mm2 \n\t" // 12345678 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2528 "punpcklbw %%mm1, %%mm0 \n\t" // 1a2b3c4d |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2529 "punpckhbw %%mm1, %%mm2 \n\t" // 5e6f7g8h |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2530 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2531 "movq 32(%2), %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2532 "movq 48(%2), %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2533 "movq %%mm1, %%mm4 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2534 "punpcklbw %%mm3, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2535 "punpckhbw %%mm3, %%mm4 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2536 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2537 "movq %%mm0, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2538 "punpcklwd %%mm1, %%mm0 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2539 "punpckhwd %%mm1, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2540 "movq %%mm2, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2541 "punpcklwd %%mm4, %%mm2 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2542 "punpckhwd %%mm4, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2543 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2544 "movd %%mm0, (%0) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2545 "psrlq $32, %%mm0 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2546 "movd %%mm0, (%%eax) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2547 "movd %%mm3, (%%eax, %1) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2548 "psrlq $32, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2549 "movd %%mm3, (%%eax, %1, 2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2550 "movd %%mm2, (%0, %1, 4) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2551 "psrlq $32, %%mm2 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2552 "movd %%mm2, (%%ebx) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2553 "movd %%mm1, (%%ebx, %1) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2554 "psrlq $32, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2555 "movd %%mm1, (%%ebx, %1, 2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2556 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2557 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2558 "movq 64(%2), %%mm0 \n\t" // 12345678 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2559 "movq 80(%2), %%mm1 \n\t" // abcdefgh |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2560 "movq %%mm0, %%mm2 \n\t" // 12345678 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2561 "punpcklbw %%mm1, %%mm0 \n\t" // 1a2b3c4d |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2562 "punpckhbw %%mm1, %%mm2 \n\t" // 5e6f7g8h |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2563 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2564 "movq 96(%2), %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2565 "movq 112(%2), %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2566 "movq %%mm1, %%mm4 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2567 "punpcklbw %%mm3, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2568 "punpckhbw %%mm3, %%mm4 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2569 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2570 "movq %%mm0, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2571 "punpcklwd %%mm1, %%mm0 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2572 "punpckhwd %%mm1, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2573 "movq %%mm2, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2574 "punpcklwd %%mm4, %%mm2 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2575 "punpckhwd %%mm4, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2576 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2577 "movd %%mm0, 4(%0) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2578 "psrlq $32, %%mm0 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2579 "movd %%mm0, 4(%%eax) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2580 "movd %%mm3, 4(%%eax, %1) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2581 "psrlq $32, %%mm3 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2582 "movd %%mm3, 4(%%eax, %1, 2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2583 "movd %%mm2, 4(%0, %1, 4) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2584 "psrlq $32, %%mm2 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2585 "movd %%mm2, 4(%%ebx) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2586 "movd %%mm1, 4(%%ebx, %1) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2587 "psrlq $32, %%mm1 \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2588 "movd %%mm1, 4(%%ebx, %1, 2) \n\t" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2589 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2590 :: "r" (dst), "r" (dstStride), "r" (src) |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2591 : "%eax", "%ebx" |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2592 ); |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2593 } |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
2594 #endif |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
2595 |
2860 | 2596 static void inline tempNoiseReducer(uint8_t *src, int stride, |
2597 uint8_t *tempBlured, int *maxNoise) | |
2598 { | |
2599 int y; | |
2600 int d=0; | |
2601 int sysd=0; | |
2602 | |
2603 for(y=0; y<8; y++) | |
2604 { | |
2605 int x; | |
2606 for(x=0; x<8; x++) | |
2607 { | |
2608 int ref= tempBlured[ x + y*stride ]; | |
2609 int cur= src[ x + y*stride ]; | |
2610 int d1=ref - cur; | |
2611 d+= ABS(d1); //d1*d1; | |
2612 sysd+= d1; | |
2613 } | |
2614 } | |
2615 //printf("%d %d %d\n", maxNoise[0], maxNoise[1], maxNoise[2]); | |
2616 /* | |
2617 Switch between | |
2618 1 0 0 0 0 0 0 (0) | |
2619 64 32 16 8 4 2 1 (1) | |
2620 64 48 36 27 20 15 11 (33) (approx) | |
2621 64 56 49 43 37 33 29 (200) (approx) | |
2622 */ | |
2623 if(d > maxNoise[1]) | |
2624 { | |
2625 if(d < maxNoise[2]) | |
2626 { | |
2627 for(y=0; y<8; y++) | |
2628 { | |
2629 int x; | |
2630 for(x=0; x<8; x++) | |
2631 { | |
2632 int ref= tempBlured[ x + y*stride ]; | |
2633 int cur= src[ x + y*stride ]; | |
2634 tempBlured[ x + y*stride ]= | |
2635 src[ x + y*stride ]= | |
2636 (ref + cur + 1)>>1; | |
2637 } | |
2638 } | |
2639 } | |
2640 else | |
2641 { | |
2642 for(y=0; y<8; y++) | |
2643 { | |
2644 int x; | |
2645 for(x=0; x<8; x++) | |
2646 { | |
2647 tempBlured[ x + y*stride ]= src[ x + y*stride ]; | |
2648 } | |
2649 } | |
2650 } | |
2651 } | |
2652 else | |
2653 { | |
2654 if(d < maxNoise[0]) | |
2655 { | |
2656 for(y=0; y<8; y++) | |
2657 { | |
2658 int x; | |
2659 for(x=0; x<8; x++) | |
2660 { | |
2661 int ref= tempBlured[ x + y*stride ]; | |
2662 int cur= src[ x + y*stride ]; | |
2663 tempBlured[ x + y*stride ]= | |
2664 src[ x + y*stride ]= | |
2665 (ref*7 + cur + 4)>>3; | |
2666 } | |
2667 } | |
2668 } | |
2669 else | |
2670 { | |
2671 for(y=0; y<8; y++) | |
2672 { | |
2673 int x; | |
2674 for(x=0; x<8; x++) | |
2675 { | |
2676 int ref= tempBlured[ x + y*stride ]; | |
2677 int cur= src[ x + y*stride ]; | |
2678 tempBlured[ x + y*stride ]= | |
2679 src[ x + y*stride ]= | |
2680 (ref*3 + cur + 2)>>2; | |
2681 } | |
2682 } | |
2683 } | |
2684 } | |
2685 } | |
2686 | |
2185 | 2687 #ifdef HAVE_ODIVX_POSTPROCESS |
2688 #include "../opendivx/postprocess.h" | |
2689 int use_old_pp=0; | |
2690 #endif | |
2159 | 2691 |
2185 | 2692 static void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, |
2860 | 2693 QP_STORE_T QPs[], int QPStride, int isColor, struct PPMode *ppMode); |
2159 | 2694 |
2389 | 2695 /* -pp Command line Help |
2696 NOTE/FIXME: put this at an appropriate place (--help, html docs, man mplayer)? | |
2697 | |
2698 -pp <filterName>[:<option>[:<option>...]][,[-]<filterName>[:<option>...]]... | |
2699 | |
2700 long form example: | |
2701 -pp vdeblock:autoq,hdeblock:autoq,linblenddeint -pp default,-vdeblock | |
2702 short form example: | |
2703 -pp vb:a,hb:a,lb -pp de,-vb | |
2860 | 2704 more examples: |
2705 -pp tn:64:128:256 | |
2389 | 2706 |
2707 Filters Options | |
2708 short long name short long option Description | |
2709 * * a autoq cpu power dependant enabler | |
2710 c chrom chrominance filtring enabled | |
2711 y nochrom chrominance filtring disabled | |
2712 hb hdeblock horizontal deblocking filter | |
2713 vb vdeblock vertical deblocking filter | |
2714 vr rkvdeblock | |
2715 h1 x1hdeblock Experimental horizontal deblock filter 1 | |
2716 v1 x1vdeblock Experimental vertical deblock filter 1 | |
2717 dr dering not implemented yet | |
2718 al autolevels automatic brightness / contrast fixer | |
2719 f fullyrange stretch luminance range to (0..255) | |
2720 lb linblenddeint linear blend deinterlacer | |
2721 li linipoldeint linear interpolating deinterlacer | |
2722 ci cubicipoldeint cubic interpolating deinterlacer | |
2723 md mediandeint median deinterlacer | |
2724 de default hdeblock:a,vdeblock:a,dering:a,autolevels | |
2725 fa fast x1hdeblock:a,x1vdeblock:a,dering:a,autolevels | |
2860 | 2726 tn tmpnoise (3 Thresholds) Temporal Noise Reducer |
2389 | 2727 */ |
2728 | |
2729 /** | |
2730 * returns a PPMode struct which will have a non 0 error variable if an error occured | |
2731 * name is the string after "-pp" on the command line | |
2732 * quality is a number from 0 to GET_PP_QUALITY_MAX | |
2733 */ | |
2734 struct PPMode getPPModeByNameAndQuality(char *name, int quality) | |
2735 { | |
2736 char temp[GET_MODE_BUFFER_SIZE]; | |
2737 char *p= temp; | |
2738 char *filterDelimiters= ","; | |
2739 char *optionDelimiters= ":"; | |
2860 | 2740 struct PPMode ppMode= {0,0,0,0,0,0,{150,200,400}}; |
2389 | 2741 char *filterToken; |
2742 | |
2743 strncpy(temp, name, GET_MODE_BUFFER_SIZE); | |
2744 | |
2860 | 2745 printf("%s\n", name); |
2746 | |
2389 | 2747 for(;;){ |
2748 char *filterName; | |
2860 | 2749 int q= 1000000; //GET_PP_QUALITY_MAX; |
2389 | 2750 int chrom=-1; |
2751 char *option; | |
2752 char *options[OPTIONS_ARRAY_SIZE]; | |
2753 int i; | |
2754 int filterNameOk=0; | |
2755 int numOfUnknownOptions=0; | |
2756 int enable=1; //does the user want us to enabled or disabled the filter | |
2757 | |
2758 filterToken= strtok(p, filterDelimiters); | |
2759 if(filterToken == NULL) break; | |
2860 | 2760 p+= strlen(filterToken) + 1; // p points to next filterToken |
2389 | 2761 filterName= strtok(filterToken, optionDelimiters); |
2762 printf("%s::%s\n", filterToken, filterName); | |
2763 | |
2764 if(*filterName == '-') | |
2765 { | |
2766 enable=0; | |
2767 filterName++; | |
2768 } | |
2860 | 2769 |
2389 | 2770 for(;;){ //for all options |
2771 option= strtok(NULL, optionDelimiters); | |
2772 if(option == NULL) break; | |
2773 | |
2774 printf("%s\n", option); | |
2775 if(!strcmp("autoq", option) || !strcmp("a", option)) q= quality; | |
2776 else if(!strcmp("nochrom", option) || !strcmp("y", option)) chrom=0; | |
2777 else if(!strcmp("chrom", option) || !strcmp("c", option)) chrom=1; | |
2778 else | |
2779 { | |
2780 options[numOfUnknownOptions] = option; | |
2781 numOfUnknownOptions++; | |
2782 } | |
2783 if(numOfUnknownOptions >= OPTIONS_ARRAY_SIZE-1) break; | |
2784 } | |
2860 | 2785 options[numOfUnknownOptions] = NULL; |
2389 | 2786 |
2787 /* replace stuff from the replace Table */ | |
2788 for(i=0; replaceTable[2*i]!=NULL; i++) | |
2789 { | |
2790 if(!strcmp(replaceTable[2*i], filterName)) | |
2791 { | |
2792 int newlen= strlen(replaceTable[2*i + 1]); | |
2793 int plen; | |
2794 int spaceLeft; | |
2795 | |
2796 if(p==NULL) p= temp, *p=0; //last filter | |
2797 else p--, *p=','; //not last filter | |
2798 | |
2799 plen= strlen(p); | |
2800 spaceLeft= (int)p - (int)temp + plen; | |
2801 if(spaceLeft + newlen >= GET_MODE_BUFFER_SIZE) | |
2802 { | |
2803 ppMode.error++; | |
2804 break; | |
2805 } | |
2806 memmove(p + newlen, p, plen+1); | |
2807 memcpy(p, replaceTable[2*i + 1], newlen); | |
2808 filterNameOk=1; | |
2809 } | |
2810 } | |
2811 | |
2812 for(i=0; filters[i].shortName!=NULL; i++) | |
2813 { | |
2860 | 2814 // printf("Compareing %s, %s, %s\n", filters[i].shortName,filters[i].longName, filterName); |
2389 | 2815 if( !strcmp(filters[i].longName, filterName) |
2816 || !strcmp(filters[i].shortName, filterName)) | |
2817 { | |
2818 ppMode.lumMode &= ~filters[i].mask; | |
2819 ppMode.chromMode &= ~filters[i].mask; | |
2820 | |
2821 filterNameOk=1; | |
2822 if(!enable) break; // user wants to disable it | |
2823 | |
2824 if(q >= filters[i].minLumQuality) | |
2825 ppMode.lumMode|= filters[i].mask; | |
2826 if(chrom==1 || (chrom==-1 && filters[i].chromDefault)) | |
2827 if(q >= filters[i].minChromQuality) | |
2828 ppMode.chromMode|= filters[i].mask; | |
2829 | |
2830 if(filters[i].mask == LEVEL_FIX) | |
2831 { | |
2832 int o; | |
2833 ppMode.minAllowedY= 16; | |
2834 ppMode.maxAllowedY= 234; | |
2835 for(o=0; options[o]!=NULL; o++) | |
2836 if( !strcmp(options[o],"fullyrange") | |
2837 ||!strcmp(options[o],"f")) | |
2838 { | |
2839 ppMode.minAllowedY= 0; | |
2840 ppMode.maxAllowedY= 255; | |
2841 numOfUnknownOptions--; | |
2842 } | |
2843 } | |
2860 | 2844 else if(filters[i].mask == TEMP_NOISE_FILTER) |
2845 { | |
2846 int o; | |
2847 int numOfNoises=0; | |
2848 ppMode.maxTmpNoise[0]= 150; | |
2849 ppMode.maxTmpNoise[1]= 200; | |
2850 ppMode.maxTmpNoise[2]= 400; | |
2851 | |
2852 for(o=0; options[o]!=NULL; o++) | |
2853 { | |
2854 char *tail; | |
2855 ppMode.maxTmpNoise[numOfNoises]= | |
2856 strtol(options[o], &tail, 0); | |
2857 if(tail!=options[o]) | |
2858 { | |
2859 numOfNoises++; | |
2860 numOfUnknownOptions--; | |
2861 if(numOfNoises >= 3) break; | |
2862 } | |
2863 } | |
2864 } | |
2389 | 2865 } |
2866 } | |
2867 if(!filterNameOk) ppMode.error++; | |
2868 ppMode.error += numOfUnknownOptions; | |
2869 } | |
2870 | |
2808 | 2871 #ifdef HAVE_ODIVX_POSTPROCESS |
2389 | 2872 if(ppMode.lumMode & H_DEBLOCK) ppMode.oldMode |= PP_DEBLOCK_Y_H; |
2873 if(ppMode.lumMode & V_DEBLOCK) ppMode.oldMode |= PP_DEBLOCK_Y_V; | |
2874 if(ppMode.chromMode & H_DEBLOCK) ppMode.oldMode |= PP_DEBLOCK_C_H; | |
2875 if(ppMode.chromMode & V_DEBLOCK) ppMode.oldMode |= PP_DEBLOCK_C_V; | |
2876 if(ppMode.lumMode & DERING) ppMode.oldMode |= PP_DERING_Y; | |
2877 if(ppMode.chromMode & DERING) ppMode.oldMode |= PP_DERING_C; | |
2808 | 2878 #endif |
2389 | 2879 |
2880 return ppMode; | |
2881 } | |
2882 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2883 /** |
2860 | 2884 * Obsolete, dont use it, use postprocess2() instead |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2885 */ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2886 void postprocess(unsigned char * src[], int src_stride, |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2887 unsigned char * dst[], int dst_stride, |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2888 int horizontal_size, int vertical_size, |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2889 QP_STORE_T *QP_store, int QP_stride, |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2890 int mode) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2891 { |
2860 | 2892 struct PPMode ppMode; |
2893 static QP_STORE_T zeroArray[2048/8]; | |
2389 | 2894 /* |
2895 static int qual=0; | |
2896 | |
2860 | 2897 ppMode= getPPModeByNameAndQuality("fast,default,-hdeblock,-vdeblock,tmpnoise:150:200:300", qual); |
2898 printf("OK\n"); | |
2389 | 2899 qual++; |
2900 qual%=7; | |
2860 | 2901 printf("\n%X %X %X %X :%d: %d %d %d\n", ppMode.lumMode, ppMode.chromMode, ppMode.oldMode, ppMode.error, |
2902 qual, ppMode.maxTmpNoise[0], ppMode.maxTmpNoise[1], ppMode.maxTmpNoise[2]); | |
2389 | 2903 postprocess2(src, src_stride, dst, dst_stride, |
2904 horizontal_size, vertical_size, QP_store, QP_stride, &ppMode); | |
2905 | |
2906 return; | |
2907 */ | |
2808 | 2908 if(QP_store==NULL) |
2909 { | |
2910 QP_store= zeroArray; | |
2911 QP_stride= 0; | |
2912 } | |
2159 | 2913 |
2860 | 2914 ppMode.lumMode= mode; |
2915 mode= ((mode&0xFF)>>4) | (mode&0xFFFFFF00); | |
2916 ppMode.chromMode= mode; | |
2917 ppMode.maxTmpNoise[0]= 150; | |
2918 ppMode.maxTmpNoise[1]= 200; | |
2919 ppMode.maxTmpNoise[2]= 400; | |
2920 | |
2185 | 2921 #ifdef HAVE_ODIVX_POSTPROCESS |
2922 // Note: I could make this shit outside of this file, but it would mean one | |
2923 // more function call... | |
2924 if(use_old_pp){ | |
2925 odivx_postprocess(src,src_stride,dst,dst_stride,horizontal_size,vertical_size,QP_store,QP_stride,mode); | |
2926 return; | |
2927 } | |
2928 #endif | |
2929 | |
2159 | 2930 postProcess(src[0], src_stride, dst[0], dst_stride, |
2860 | 2931 horizontal_size, vertical_size, QP_store, QP_stride, 0, &ppMode); |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2932 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2933 horizontal_size >>= 1; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2934 vertical_size >>= 1; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2935 src_stride >>= 1; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2936 dst_stride >>= 1; |
2595 | 2937 // mode&= ~(LINEAR_IPOL_DEINT_FILTER | LINEAR_BLEND_DEINT_FILTER | |
2938 // MEDIAN_DEINT_FILTER | CUBIC_IPOL_DEINT_FILTER); | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2939 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2940 if(1) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2941 { |
2159 | 2942 postProcess(src[1], src_stride, dst[1], dst_stride, |
2860 | 2943 horizontal_size, vertical_size, QP_store, QP_stride, 1, &ppMode); |
2159 | 2944 postProcess(src[2], src_stride, dst[2], dst_stride, |
2860 | 2945 horizontal_size, vertical_size, QP_store, QP_stride, 2, &ppMode); |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2946 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2947 else |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2948 { |
2860 | 2949 memset(dst[1], 128, dst_stride*vertical_size); |
2950 memset(dst[2], 128, dst_stride*vertical_size); | |
2951 // memcpy(dst[1], src[1], src_stride*horizontal_size); | |
2952 // memcpy(dst[2], src[2], src_stride*horizontal_size); | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2953 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
2954 } |
2185 | 2955 |
2389 | 2956 void postprocess2(unsigned char * src[], int src_stride, |
2957 unsigned char * dst[], int dst_stride, | |
2958 int horizontal_size, int vertical_size, | |
2959 QP_STORE_T *QP_store, int QP_stride, | |
2960 struct PPMode *mode) | |
2961 { | |
2962 | |
2808 | 2963 static QP_STORE_T zeroArray[2048/8]; |
2964 if(QP_store==NULL) | |
2965 { | |
2966 QP_store= zeroArray; | |
2967 QP_stride= 0; | |
2968 } | |
2969 | |
2389 | 2970 #ifdef HAVE_ODIVX_POSTPROCESS |
2971 // Note: I could make this shit outside of this file, but it would mean one | |
2972 // more function call... | |
2973 if(use_old_pp){ | |
2974 odivx_postprocess(src,src_stride,dst,dst_stride,horizontal_size,vertical_size,QP_store,QP_stride, | |
2975 mode->oldMode); | |
2976 return; | |
2977 } | |
2978 #endif | |
2979 | |
2980 postProcess(src[0], src_stride, dst[0], dst_stride, | |
2860 | 2981 horizontal_size, vertical_size, QP_store, QP_stride, 0, mode); |
2389 | 2982 |
2983 horizontal_size >>= 1; | |
2984 vertical_size >>= 1; | |
2985 src_stride >>= 1; | |
2986 dst_stride >>= 1; | |
2987 | |
2988 postProcess(src[1], src_stride, dst[1], dst_stride, | |
2860 | 2989 horizontal_size, vertical_size, QP_store, QP_stride, 1, mode); |
2389 | 2990 postProcess(src[2], src_stride, dst[2], dst_stride, |
2860 | 2991 horizontal_size, vertical_size, QP_store, QP_stride, 2, mode); |
2389 | 2992 } |
2993 | |
2994 | |
2159 | 2995 /** |
2996 * gets the mode flags for a given quality (larger values mean slower but better postprocessing) | |
2185 | 2997 * 0 <= quality <= 6 |
2159 | 2998 */ |
2185 | 2999 int getPpModeForQuality(int quality){ |
3000 int modes[1+GET_PP_QUALITY_MAX]= { | |
3001 0, | |
3002 #if 1 | |
3003 // horizontal filters first | |
3004 LUM_H_DEBLOCK, | |
3005 LUM_H_DEBLOCK | LUM_V_DEBLOCK, | |
3006 LUM_H_DEBLOCK | LUM_V_DEBLOCK | CHROM_H_DEBLOCK, | |
3007 LUM_H_DEBLOCK | LUM_V_DEBLOCK | CHROM_H_DEBLOCK | CHROM_V_DEBLOCK, | |
3008 LUM_H_DEBLOCK | LUM_V_DEBLOCK | CHROM_H_DEBLOCK | CHROM_V_DEBLOCK | LUM_DERING, | |
3009 LUM_H_DEBLOCK | LUM_V_DEBLOCK | CHROM_H_DEBLOCK | CHROM_V_DEBLOCK | LUM_DERING | CHROM_DERING | |
3010 #else | |
3011 // vertical filters first | |
2159 | 3012 LUM_V_DEBLOCK, |
3013 LUM_V_DEBLOCK | LUM_H_DEBLOCK, | |
3014 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK, | |
3015 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK, | |
3016 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK | LUM_DERING, | |
3017 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK | LUM_DERING | CHROM_DERING | |
2185 | 3018 #endif |
3019 }; | |
2159 | 3020 |
2185 | 3021 #ifdef HAVE_ODIVX_POSTPROCESS |
3022 int odivx_modes[1+GET_PP_QUALITY_MAX]= { | |
3023 0, | |
3024 PP_DEBLOCK_Y_H, | |
3025 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V, | |
3026 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H, | |
3027 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H|PP_DEBLOCK_C_V, | |
3028 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H|PP_DEBLOCK_C_V|PP_DERING_Y, | |
3029 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H|PP_DEBLOCK_C_V|PP_DERING_Y|PP_DERING_C | |
3030 }; | |
3031 if(use_old_pp) return odivx_modes[quality]; | |
3032 #endif | |
3033 return modes[quality]; | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3034 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3035 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3036 /** |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3037 * Copies a block from src to dst and fixes the blacklevel |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3038 * numLines must be a multiple of 4 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3039 * levelFix == 0 -> dont touch the brighness & contrast |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3040 */ |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3041 static inline void blockCopy(uint8_t dst[], int dstStride, uint8_t src[], int srcStride, |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3042 int numLines, int levelFix) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3043 { |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
3044 #ifndef HAVE_MMX |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3045 int i; |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
3046 #endif |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3047 if(levelFix) |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3048 { |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3049 #ifdef HAVE_MMX |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3050 asm volatile( |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3051 "leal (%2,%2), %%eax \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3052 "leal (%3,%3), %%ebx \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3053 "movq packedYOffset, %%mm2 \n\t" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3054 "movq packedYScale, %%mm3 \n\t" |
2181
d90f8fc7ead6
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:
2180
diff
changeset
|
3055 "pxor %%mm4, %%mm4 \n\t" |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3056 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3057 #define SCALED_CPY \ |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3058 "movq (%0), %%mm0 \n\t"\ |
2401
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3059 "movq (%0), %%mm5 \n\t"\ |
2181
d90f8fc7ead6
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:
2180
diff
changeset
|
3060 "punpcklbw %%mm4, %%mm0 \n\t"\ |
d90f8fc7ead6
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:
2180
diff
changeset
|
3061 "punpckhbw %%mm4, %%mm5 \n\t"\ |
2394 | 3062 "psubw %%mm2, %%mm0 \n\t"\ |
3063 "psubw %%mm2, %%mm5 \n\t"\ | |
2401
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3064 "movq (%0,%2), %%mm1 \n\t"\ |
2394 | 3065 "psllw $6, %%mm0 \n\t"\ |
3066 "psllw $6, %%mm5 \n\t"\ | |
2181
d90f8fc7ead6
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:
2180
diff
changeset
|
3067 "pmulhw %%mm3, %%mm0 \n\t"\ |
2401
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3068 "movq (%0,%2), %%mm6 \n\t"\ |
2181
d90f8fc7ead6
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:
2180
diff
changeset
|
3069 "pmulhw %%mm3, %%mm5 \n\t"\ |
d90f8fc7ead6
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:
2180
diff
changeset
|
3070 "punpcklbw %%mm4, %%mm1 \n\t"\ |
2401
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3071 "punpckhbw %%mm4, %%mm6 \n\t"\ |
2394 | 3072 "psubw %%mm2, %%mm1 \n\t"\ |
2401
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3073 "psubw %%mm2, %%mm6 \n\t"\ |
2394 | 3074 "psllw $6, %%mm1 \n\t"\ |
2401
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3075 "psllw $6, %%mm6 \n\t"\ |
2181
d90f8fc7ead6
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:
2180
diff
changeset
|
3076 "pmulhw %%mm3, %%mm1 \n\t"\ |
2401
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3077 "pmulhw %%mm3, %%mm6 \n\t"\ |
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3078 "addl %%eax, %0 \n\t"\ |
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3079 "packuswb %%mm5, %%mm0 \n\t"\ |
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3080 "packuswb %%mm6, %%mm1 \n\t"\ |
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3081 "movq %%mm0, (%1) \n\t"\ |
2181
d90f8fc7ead6
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:
2180
diff
changeset
|
3082 "movq %%mm1, (%1, %3) \n\t"\ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3083 |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3084 SCALED_CPY |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3085 "addl %%ebx, %1 \n\t" |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3086 SCALED_CPY |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3087 "addl %%ebx, %1 \n\t" |
2401
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3088 SCALED_CPY |
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3089 "addl %%ebx, %1 \n\t" |
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3090 SCALED_CPY |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3091 |
2413 | 3092 : "+r"(src), |
3093 "+r"(dst) | |
3094 :"r" (srcStride), | |
2401
bc69d7c0e1dc
brightness / contrast fix/copy optimizations +2% speedup
michael
parents:
2394
diff
changeset
|
3095 "r" (dstStride) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3096 : "%eax", "%ebx" |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3097 ); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3098 #else |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3099 for(i=0; i<numLines; i++) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3100 memcpy( &(dst[dstStride*i]), |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3101 &(src[srcStride*i]), BLOCK_SIZE); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3102 #endif |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3103 } |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3104 else |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3105 { |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3106 #ifdef HAVE_MMX |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3107 asm volatile( |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3108 "movl %4, %%eax \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3109 "movl %%eax, temp0\n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3110 "pushl %0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3111 "pushl %1 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3112 "leal (%2,%2), %%eax \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3113 "leal (%3,%3), %%ebx \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3114 "movq packedYOffset, %%mm2 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3115 "movq packedYScale, %%mm3 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3116 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3117 #define SIMPLE_CPY \ |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3118 "movq (%0), %%mm0 \n\t"\ |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3119 "movq (%0,%2), %%mm1 \n\t"\ |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3120 "movq %%mm0, (%1) \n\t"\ |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3121 "movq %%mm1, (%1, %3) \n\t"\ |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3122 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3123 "1: \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3124 SIMPLE_CPY |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3125 "addl %%eax, %0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3126 "addl %%ebx, %1 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3127 SIMPLE_CPY |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3128 "addl %%eax, %0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3129 "addl %%ebx, %1 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3130 "decl temp0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3131 "jnz 1b \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3132 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3133 "popl %1 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3134 "popl %0 \n\t" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3135 : : "r" (src), |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3136 "r" (dst), |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3137 "r" (srcStride), |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3138 "r" (dstStride), |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3139 "m" (numLines>>2) |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3140 : "%eax", "%ebx" |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3141 ); |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3142 #else |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3143 for(i=0; i<numLines; i++) |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3144 memcpy( &(dst[dstStride*i]), |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3145 &(src[srcStride*i]), BLOCK_SIZE); |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3146 #endif |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3147 } |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3148 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3149 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3150 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3151 /** |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3152 * Filters array of bytes (Y or U or V values) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3153 */ |
2185 | 3154 static void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, |
2860 | 3155 QP_STORE_T QPs[], int QPStride, int isColor, struct PPMode *ppMode) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3156 { |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3157 int x,y; |
2860 | 3158 const int mode= isColor ? ppMode->chromMode : ppMode->lumMode; |
3159 | |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3160 /* we need 64bit here otherwise we´ll going to have a problem |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3161 after watching a black picture for 5 hours*/ |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3162 static uint64_t *yHistogram= NULL; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3163 int black=0, white=255; // blackest black and whitest white in the picture |
2437 | 3164 int QPCorrecture= 256; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3165 |
2246 | 3166 /* Temporary buffers for handling the last row(s) */ |
3167 static uint8_t *tempDst= NULL; | |
3168 static uint8_t *tempSrc= NULL; | |
3169 | |
2285 | 3170 /* Temporary buffers for handling the last block */ |
3171 static uint8_t *tempDstBlock= NULL; | |
3172 static uint8_t *tempSrcBlock= NULL; | |
3173 | |
2860 | 3174 /* Temporal noise reducing buffers */ |
3175 static uint8_t *tempBlured[3]= {NULL,NULL,NULL}; | |
3176 | |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
3177 #ifdef PP_FUNNY_STRIDE |
2285 | 3178 uint8_t *dstBlockPtrBackup; |
3179 uint8_t *srcBlockPtrBackup; | |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
3180 #endif |
2285 | 3181 |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
3182 #ifdef MORE_TIMING |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
3183 long long T0, T1, diffTime=0; |
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
3184 #endif |
2221 | 3185 #ifdef TIMING |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
3186 long long memcpyTime=0, vertTime=0, horizTime=0, sumTime; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3187 sumTime= rdtsc(); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3188 #endif |
2570 | 3189 //mode= 0x7F; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3190 |
2246 | 3191 if(tempDst==NULL) |
3192 { | |
3193 tempDst= (uint8_t*)memalign(8, 1024*24); | |
3194 tempSrc= (uint8_t*)memalign(8, 1024*24); | |
2285 | 3195 tempDstBlock= (uint8_t*)memalign(8, 1024*24); |
3196 tempSrcBlock= (uint8_t*)memalign(8, 1024*24); | |
2246 | 3197 } |
3198 | |
2860 | 3199 if(tempBlured[isColor]==NULL && (mode & TEMP_NOISE_FILTER)) |
3200 { | |
3201 // printf("%d %d %d\n", isColor, dstStride, height); | |
3202 //FIXME works only as long as the size doesnt increase | |
3203 //Note:the +17*1024 is just there so i dont have to worry about r/w over te end | |
3204 tempBlured[isColor]= (uint8_t*)memalign(8, dstStride*((height+7)&(~7)) + 17*1024); | |
3205 | |
3206 memset(tempBlured[isColor], 0, dstStride*((height+7)&(~7)) + 17*1024); | |
3207 } | |
3208 | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3209 if(!yHistogram) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3210 { |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3211 int i; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3212 yHistogram= (uint64_t*)malloc(8*256); |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3213 for(i=0; i<256; i++) yHistogram[i]= width*height/64*15/256; |
2285 | 3214 |
3215 if(mode & FULL_Y_RANGE) | |
3216 { | |
3217 maxAllowedY=255; | |
3218 minAllowedY=0; | |
3219 } | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3220 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3221 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3222 if(!isColor) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3223 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3224 uint64_t sum= 0; |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3225 int i; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3226 static int framenum= -1; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3227 uint64_t maxClipped; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3228 uint64_t clipped; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3229 double scale; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3230 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3231 framenum++; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3232 if(framenum == 1) yHistogram[0]= width*height/64*15/256; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3233 |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3234 for(i=0; i<256; i++) |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3235 { |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3236 sum+= yHistogram[i]; |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3237 // printf("%d ", yHistogram[i]); |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3238 } |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3239 // printf("\n\n"); |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3240 |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3241 /* we allways get a completly black picture first */ |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3242 maxClipped= (uint64_t)(sum * maxClippedThreshold); |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3243 |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3244 clipped= sum; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3245 for(black=255; black>0; black--) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3246 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3247 if(clipped < maxClipped) break; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3248 clipped-= yHistogram[black]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3249 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3250 |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3251 clipped= sum; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3252 for(white=0; white<256; white++) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3253 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3254 if(clipped < maxClipped) break; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3255 clipped-= yHistogram[white]; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3256 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3257 |
2394 | 3258 packedYOffset= (black - minAllowedY) & 0xFFFF; |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3259 packedYOffset|= packedYOffset<<32; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3260 packedYOffset|= packedYOffset<<16; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3261 |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3262 scale= (double)(maxAllowedY - minAllowedY) / (double)(white-black); |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3263 |
2394 | 3264 packedYScale= (uint16_t)(scale*1024.0 + 0.5); |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3265 packedYScale|= packedYScale<<32; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3266 packedYScale|= packedYScale<<16; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3267 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3268 else |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3269 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3270 packedYScale= 0x0100010001000100LL; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3271 packedYOffset= 0; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3272 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3273 |
2437 | 3274 if(mode & LEVEL_FIX) QPCorrecture= packedYScale &0xFFFF; |
3275 else QPCorrecture= 256; | |
3276 | |
2742
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
3277 /* copy & deinterlace first row of blocks */ |
2595 | 3278 y=-BLOCK_SIZE; |
3279 { | |
3280 //1% speedup if these are here instead of the inner loop | |
3281 uint8_t *srcBlock= &(src[y*srcStride]); | |
3282 uint8_t *dstBlock= &(dst[y*dstStride]); | |
3283 | |
3284 dstBlock= tempDst + dstStride; | |
3285 | |
3286 // From this point on it is guranteed that we can read and write 16 lines downward | |
3287 // finish 1 block before the next otherwise we´ll might have a problem | |
3288 // with the L1 Cache of the P4 ... or only a few blocks at a time or soemthing | |
3289 for(x=0; x<width; x+=BLOCK_SIZE) | |
3290 { | |
3291 | |
3292 #ifdef HAVE_MMX2 | |
3293 /* | |
3294 prefetchnta(srcBlock + (((x>>3)&3) + 5)*srcStride + 32); | |
3295 prefetchnta(srcBlock + (((x>>3)&3) + 9)*srcStride + 32); | |
3296 prefetcht0(dstBlock + (((x>>3)&3) + 5)*dstStride + 32); | |
3297 prefetcht0(dstBlock + (((x>>3)&3) + 9)*dstStride + 32); | |
3298 */ | |
3299 /* | |
3300 prefetchnta(srcBlock + (((x>>2)&6) + 5)*srcStride + 32); | |
3301 prefetchnta(srcBlock + (((x>>2)&6) + 6)*srcStride + 32); | |
3302 prefetcht0(dstBlock + (((x>>2)&6) + 5)*dstStride + 32); | |
3303 prefetcht0(dstBlock + (((x>>2)&6) + 6)*dstStride + 32); | |
3304 */ | |
3305 | |
3306 asm( | |
3307 "movl %4, %%eax \n\t" | |
3308 "shrl $2, %%eax \n\t" | |
3309 "andl $6, %%eax \n\t" | |
3310 "addl $8, %%eax \n\t" | |
3311 "movl %%eax, %%ebx \n\t" | |
3312 "imul %1, %%eax \n\t" | |
3313 "imul %3, %%ebx \n\t" | |
3314 "prefetchnta 32(%%eax, %0) \n\t" | |
3315 "prefetcht0 32(%%ebx, %2) \n\t" | |
3316 "addl %1, %%eax \n\t" | |
3317 "addl %3, %%ebx \n\t" | |
3318 "prefetchnta 32(%%eax, %0) \n\t" | |
3319 "prefetcht0 32(%%ebx, %2) \n\t" | |
3320 :: "r" (srcBlock), "r" (srcStride), "r" (dstBlock), "r" (dstStride), | |
3321 "m" (x) | |
3322 : "%eax", "%ebx" | |
3323 ); | |
3324 | |
3325 #elif defined(HAVE_3DNOW) | |
3326 //FIXME check if this is faster on an 3dnow chip or if its faster without the prefetch or ... | |
3327 /* prefetch(srcBlock + (((x>>3)&3) + 5)*srcStride + 32); | |
3328 prefetch(srcBlock + (((x>>3)&3) + 9)*srcStride + 32); | |
3329 prefetchw(dstBlock + (((x>>3)&3) + 5)*dstStride + 32); | |
3330 prefetchw(dstBlock + (((x>>3)&3) + 9)*dstStride + 32); | |
3331 */ | |
3332 #endif | |
3333 | |
3334 blockCopy(dstBlock + dstStride*8, dstStride, | |
3335 srcBlock + srcStride*8, srcStride, 8, mode & LEVEL_FIX); | |
3336 | |
3337 if(mode & LINEAR_IPOL_DEINT_FILTER) | |
3338 deInterlaceInterpolateLinear(dstBlock, dstStride); | |
3339 else if(mode & LINEAR_BLEND_DEINT_FILTER) | |
3340 deInterlaceBlendLinear(dstBlock, dstStride); | |
3341 else if(mode & MEDIAN_DEINT_FILTER) | |
3342 deInterlaceMedian(dstBlock, dstStride); | |
3343 else if(mode & CUBIC_IPOL_DEINT_FILTER) | |
3344 deInterlaceInterpolateCubic(dstBlock, dstStride); | |
3345 /* else if(mode & CUBIC_BLEND_DEINT_FILTER) | |
3346 deInterlaceBlendCubic(dstBlock, dstStride); | |
3347 */ | |
3348 dstBlock+=8; | |
3349 srcBlock+=8; | |
3350 } | |
3351 memcpy(&(dst[y*dstStride]) + 8*dstStride, tempDst + 9*dstStride, 8*dstStride ); | |
3352 } | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3353 |
2246 | 3354 for(y=0; y<height; y+=BLOCK_SIZE) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3355 { |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3356 //1% speedup if these are here instead of the inner loop |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3357 uint8_t *srcBlock= &(src[y*srcStride]); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3358 uint8_t *dstBlock= &(dst[y*dstStride]); |
2437 | 3359 #ifdef ARCH_X86 |
3360 int *QPptr= isColor ? &QPs[(y>>3)*QPStride] :&QPs[(y>>4)*QPStride]; | |
3361 int QPDelta= isColor ? 1<<(32-3) : 1<<(32-4); | |
3362 int QPFrac= QPDelta; | |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3363 uint8_t *tempBlock1= tempBlocks; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3364 uint8_t *tempBlock2= tempBlocks + 8; |
2437 | 3365 #endif |
2860 | 3366 int QP=0; |
2473 | 3367 /* can we mess with a 8x16 block from srcBlock/dstBlock downwards and 1 line upwards |
3368 if not than use a temporary buffer */ | |
2246 | 3369 if(y+15 >= height) |
3370 { | |
2860 | 3371 int i; |
2595 | 3372 /* copy from line 8 to 15 of src, these will be copied with |
2246 | 3373 blockcopy to dst later */ |
2595 | 3374 memcpy(tempSrc + srcStride*8, srcBlock + srcStride*8, |
3375 srcStride*MAX(height-y-8, 0) ); | |
3376 | |
2860 | 3377 /* duplicate last line of src to fill the void upto line 15 */ |
3378 for(i=MAX(height-y, 8); i<=15; i++) | |
3379 memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), srcStride); | |
3380 | |
3381 /* copy up to 9 lines of dst (line -1 to 7)*/ | |
2595 | 3382 memcpy(tempDst, dstBlock - dstStride, dstStride*MIN(height-y+1, 9) ); |
2860 | 3383 |
3384 /* duplicate last line of dst to fill the void upto line 8 */ | |
3385 for(i=height-y+1; i<=8; i++) | |
3386 memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), dstStride); | |
3387 | |
2473 | 3388 dstBlock= tempDst + dstStride; |
2246 | 3389 srcBlock= tempSrc; |
3390 } | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3391 |
2285 | 3392 // From this point on it is guranteed that we can read and write 16 lines downward |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3393 // finish 1 block before the next otherwise we´ll might have a problem |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3394 // with the L1 Cache of the P4 ... or only a few blocks at a time or soemthing |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3395 for(x=0; x<width; x+=BLOCK_SIZE) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3396 { |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3397 const int stride= dstStride; |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3398 uint8_t *tmpXchg; |
2437 | 3399 #ifdef ARCH_X86 |
2860 | 3400 QP= *QPptr; |
2437 | 3401 asm volatile( |
3402 "addl %2, %1 \n\t" | |
3403 "sbbl %%eax, %%eax \n\t" | |
3404 "shll $2, %%eax \n\t" | |
3405 "subl %%eax, %0 \n\t" | |
3406 : "+r" (QPptr), "+m" (QPFrac) | |
3407 : "r" (QPDelta) | |
3408 : "%eax" | |
3409 ); | |
3410 #else | |
2860 | 3411 QP= isColor ? |
2437 | 3412 QPs[(y>>3)*QPStride + (x>>3)]: |
3413 QPs[(y>>4)*QPStride + (x>>4)]; | |
3414 #endif | |
3415 if(!isColor) | |
2428 | 3416 { |
2437 | 3417 QP= (QP* QPCorrecture)>>8; |
2742
d5636499cafd
minor changes (fixed some warnings, added attribute aligned(8) stuff)
michael
parents:
2595
diff
changeset
|
3418 yHistogram[ srcBlock[srcStride*12 + 4] ]++; |
2428 | 3419 } |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3420 #ifdef HAVE_MMX |
2246 | 3421 asm volatile( |
3422 "movd %0, %%mm7 \n\t" | |
3423 "packuswb %%mm7, %%mm7 \n\t" // 0, 0, 0, QP, 0, 0, 0, QP | |
3424 "packuswb %%mm7, %%mm7 \n\t" // 0,QP, 0, QP, 0,QP, 0, QP | |
3425 "packuswb %%mm7, %%mm7 \n\t" // QP,..., QP | |
3426 "movq %%mm7, pQPb \n\t" | |
3427 : : "r" (QP) | |
3428 ); | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3429 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3430 |
2221 | 3431 #ifdef MORE_TIMING |
2246 | 3432 T0= rdtsc(); |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3433 #endif |
2159 | 3434 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3435 #ifdef HAVE_MMX2 |
2437 | 3436 /* |
2246 | 3437 prefetchnta(srcBlock + (((x>>3)&3) + 5)*srcStride + 32); |
3438 prefetchnta(srcBlock + (((x>>3)&3) + 9)*srcStride + 32); | |
3439 prefetcht0(dstBlock + (((x>>3)&3) + 5)*dstStride + 32); | |
3440 prefetcht0(dstBlock + (((x>>3)&3) + 9)*dstStride + 32); | |
2437 | 3441 */ |
3442 /* | |
3443 prefetchnta(srcBlock + (((x>>2)&6) + 5)*srcStride + 32); | |
3444 prefetchnta(srcBlock + (((x>>2)&6) + 6)*srcStride + 32); | |
3445 prefetcht0(dstBlock + (((x>>2)&6) + 5)*dstStride + 32); | |
3446 prefetcht0(dstBlock + (((x>>2)&6) + 6)*dstStride + 32); | |
3447 */ | |
3448 | |
3449 asm( | |
3450 "movl %4, %%eax \n\t" | |
3451 "shrl $2, %%eax \n\t" | |
3452 "andl $6, %%eax \n\t" | |
2595 | 3453 "addl $8, %%eax \n\t" |
2437 | 3454 "movl %%eax, %%ebx \n\t" |
3455 "imul %1, %%eax \n\t" | |
3456 "imul %3, %%ebx \n\t" | |
3457 "prefetchnta 32(%%eax, %0) \n\t" | |
3458 "prefetcht0 32(%%ebx, %2) \n\t" | |
3459 "addl %1, %%eax \n\t" | |
3460 "addl %3, %%ebx \n\t" | |
3461 "prefetchnta 32(%%eax, %0) \n\t" | |
3462 "prefetcht0 32(%%ebx, %2) \n\t" | |
3463 :: "r" (srcBlock), "r" (srcStride), "r" (dstBlock), "r" (dstStride), | |
3464 "m" (x) | |
3465 : "%eax", "%ebx" | |
3466 ); | |
3467 | |
2159 | 3468 #elif defined(HAVE_3DNOW) |
3469 //FIXME check if this is faster on an 3dnow chip or if its faster without the prefetch or ... | |
2246 | 3470 /* prefetch(srcBlock + (((x>>3)&3) + 5)*srcStride + 32); |
3471 prefetch(srcBlock + (((x>>3)&3) + 9)*srcStride + 32); | |
3472 prefetchw(dstBlock + (((x>>3)&3) + 5)*dstStride + 32); | |
3473 prefetchw(dstBlock + (((x>>3)&3) + 9)*dstStride + 32); | |
2159 | 3474 */ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3475 #endif |
2246 | 3476 |
2286 | 3477 #ifdef PP_FUNNY_STRIDE |
2285 | 3478 //can we mess with a 8x16 block, if not use a temp buffer, yes again |
3479 if(x+7 >= width) | |
3480 { | |
3481 int i; | |
3482 dstBlockPtrBackup= dstBlock; | |
3483 srcBlockPtrBackup= srcBlock; | |
3484 | |
3485 for(i=0;i<BLOCK_SIZE*2; i++) | |
3486 { | |
3487 memcpy(tempSrcBlock+i*srcStride, srcBlock+i*srcStride, width-x); | |
3488 memcpy(tempDstBlock+i*dstStride, dstBlock+i*dstStride, width-x); | |
3489 } | |
3490 | |
3491 dstBlock= tempDstBlock; | |
3492 srcBlock= tempSrcBlock; | |
3493 } | |
2286 | 3494 #endif |
2285 | 3495 |
2595 | 3496 blockCopy(dstBlock + dstStride*8, dstStride, |
3497 srcBlock + srcStride*8, srcStride, 8, mode & LEVEL_FIX); | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3498 |
2246 | 3499 if(mode & LINEAR_IPOL_DEINT_FILTER) |
3500 deInterlaceInterpolateLinear(dstBlock, dstStride); | |
3501 else if(mode & LINEAR_BLEND_DEINT_FILTER) | |
3502 deInterlaceBlendLinear(dstBlock, dstStride); | |
3503 else if(mode & MEDIAN_DEINT_FILTER) | |
3504 deInterlaceMedian(dstBlock, dstStride); | |
3505 else if(mode & CUBIC_IPOL_DEINT_FILTER) | |
3506 deInterlaceInterpolateCubic(dstBlock, dstStride); | |
3507 /* else if(mode & CUBIC_BLEND_DEINT_FILTER) | |
3508 deInterlaceBlendCubic(dstBlock, dstStride); | |
2203
f90b6e259dc8
rewrote the horizontal lowpass filter to fix a bug which caused a blocky look
michael
parents:
2195
diff
changeset
|
3509 */ |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3510 |
2246 | 3511 /* only deblock if we have 2 blocks */ |
3512 if(y + 8 < height) | |
3513 { | |
2221 | 3514 #ifdef MORE_TIMING |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3515 T1= rdtsc(); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3516 memcpyTime+= T1-T0; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3517 T0=T1; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3518 #endif |
2300
e10f7dc4938f
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:
2286
diff
changeset
|
3519 if(mode & V_RK1_FILTER) |
e10f7dc4938f
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:
2286
diff
changeset
|
3520 vertRK1Filter(dstBlock, stride, QP); |
e10f7dc4938f
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:
2286
diff
changeset
|
3521 else if(mode & V_X1_FILTER) |
e10f7dc4938f
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:
2286
diff
changeset
|
3522 vertX1Filter(dstBlock, stride, QP); |
e10f7dc4938f
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:
2286
diff
changeset
|
3523 else if(mode & V_DEBLOCK) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3524 { |
2300
e10f7dc4938f
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:
2286
diff
changeset
|
3525 if( isVertDC(dstBlock, stride)) |
2159 | 3526 { |
2300
e10f7dc4938f
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:
2286
diff
changeset
|
3527 if(isVertMinMaxOk(dstBlock, stride, QP)) |
e10f7dc4938f
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:
2286
diff
changeset
|
3528 doVertLowPass(dstBlock, stride, QP); |
2159 | 3529 } |
2300
e10f7dc4938f
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:
2286
diff
changeset
|
3530 else |
e10f7dc4938f
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:
2286
diff
changeset
|
3531 doVertDefFilter(dstBlock, stride, QP); |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3532 } |
2221 | 3533 #ifdef MORE_TIMING |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3534 T1= rdtsc(); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3535 vertTime+= T1-T0; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3536 T0=T1; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3537 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3538 } |
2473 | 3539 |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3540 #ifdef HAVE_MMX |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3541 transpose1(tempBlock1, tempBlock2, dstBlock, dstStride); |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3542 #endif |
2246 | 3543 /* check if we have a previous block to deblock it with dstBlock */ |
2285 | 3544 if(x - 8 >= 0) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3545 { |
2221 | 3546 #ifdef MORE_TIMING |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3547 T0= rdtsc(); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3548 #endif |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3549 #ifdef HAVE_MMX |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3550 if(mode & H_RK1_FILTER) |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3551 vertRK1Filter(tempBlock1, 16, QP); |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3552 else if(mode & H_X1_FILTER) |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3553 vertX1Filter(tempBlock1, 16, QP); |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3554 else if(mode & H_DEBLOCK) |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3555 { |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3556 if( isVertDC(tempBlock1, 16)) |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3557 { |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3558 if(isVertMinMaxOk(tempBlock1, 16, QP)) |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3559 doVertLowPass(tempBlock1, 16, QP); |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3560 } |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3561 else |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3562 doVertDefFilter(tempBlock1, 16, QP); |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3563 } |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3564 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3565 transpose2(dstBlock-4, dstStride, tempBlock1 + 4*16); |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3566 |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3567 #else |
2300
e10f7dc4938f
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:
2286
diff
changeset
|
3568 if(mode & H_X1_FILTER) |
e10f7dc4938f
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:
2286
diff
changeset
|
3569 horizX1Filter(dstBlock-4, stride, QP); |
e10f7dc4938f
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:
2286
diff
changeset
|
3570 else if(mode & H_DEBLOCK) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3571 { |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3572 if( isHorizDC(dstBlock-4, stride)) |
2159 | 3573 { |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3574 if(isHorizMinMaxOk(dstBlock-4, stride, QP)) |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3575 doHorizLowPass(dstBlock-4, stride, QP); |
2159 | 3576 } |
2300
e10f7dc4938f
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:
2286
diff
changeset
|
3577 else |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3578 doHorizDefFilter(dstBlock-4, stride, QP); |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3579 } |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3580 #endif |
2221 | 3581 #ifdef MORE_TIMING |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3582 T1= rdtsc(); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3583 horizTime+= T1-T0; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3584 T0=T1; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3585 #endif |
2473 | 3586 if(mode & DERING) |
3587 { | |
3588 //FIXME filter first line | |
3589 if(y>0) dering(dstBlock - stride - 8, stride, QP); | |
3590 } | |
2860 | 3591 |
3592 if(mode & TEMP_NOISE_FILTER) | |
3593 { | |
3594 tempNoiseReducer(dstBlock-8, stride, | |
3595 tempBlured[isColor] + y*dstStride + x, | |
3596 ppMode->maxTmpNoise); | |
3597 } | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3598 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3599 |
2286 | 3600 #ifdef PP_FUNNY_STRIDE |
2285 | 3601 /* did we use a tmp-block buffer */ |
3602 if(x+7 >= width) | |
3603 { | |
3604 int i; | |
3605 dstBlock= dstBlockPtrBackup; | |
3606 srcBlock= srcBlockPtrBackup; | |
3607 | |
3608 for(i=0;i<BLOCK_SIZE*2; i++) | |
3609 { | |
3610 memcpy(dstBlock+i*dstStride, tempDstBlock+i*dstStride, width-x); | |
3611 } | |
3612 } | |
2286 | 3613 #endif |
2285 | 3614 |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3615 dstBlock+=8; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3616 srcBlock+=8; |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3617 |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
3618 #ifdef HAVE_MMX |
2454
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3619 tmpXchg= tempBlock1; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3620 tempBlock1= tempBlock2; |
b74c2a08eac9
much better horizontal filters (transpose & use the vertical ones) :)
michael
parents:
2437
diff
changeset
|
3621 tempBlock2 = tmpXchg; |
2461
60f16575bece
fixed difference with -vo md5 between doVertDefFilter() C and MMX / MMX2 versions
michael
parents:
2454
diff
changeset
|
3622 #endif |
2246 | 3623 } |
3624 | |
2860 | 3625 if(mode & DERING) |
3626 { | |
3627 if(y > 0) dering(dstBlock - dstStride - 8, dstStride, QP); | |
3628 } | |
3629 | |
3630 if((mode & TEMP_NOISE_FILTER)) | |
3631 { | |
3632 tempNoiseReducer(dstBlock-8, dstStride, | |
3633 tempBlured[isColor] + y*dstStride + x, | |
3634 ppMode->maxTmpNoise); | |
3635 } | |
3636 | |
2595 | 3637 /* did we use a tmp buffer for the last lines*/ |
2285 | 3638 if(y+15 >= height) |
2246 | 3639 { |
3640 uint8_t *dstBlock= &(dst[y*dstStride]); | |
2473 | 3641 memcpy(dstBlock, tempDst + dstStride, dstStride*(height-y) ); |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3642 } |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3643 } |
2159 | 3644 #ifdef HAVE_3DNOW |
3645 asm volatile("femms"); | |
3646 #elif defined (HAVE_MMX) | |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3647 asm volatile("emms"); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3648 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3649 |
2221 | 3650 #ifdef TIMING |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3651 // FIXME diff is mostly the time spent for rdtsc (should subtract that but ...) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3652 sumTime= rdtsc() - sumTime; |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3653 if(!isColor) |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3654 printf("cpy:%4dk, vert:%4dk, horiz:%4dk, sum:%4dk, diff:%4dk, color: %d/%d \r", |
2168
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3655 (int)(memcpyTime/1000), (int)(vertTime/1000), (int)(horizTime/1000), |
21a8f158d19f
bugfixes: last 3 lines not brightness/contrast corrected
michael
parents:
2159
diff
changeset
|
3656 (int)(sumTime/1000), (int)((sumTime-memcpyTime-vertTime-horizTime)/1000) |
2158
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3657 , black, white); |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3658 #endif |
508468a75be0
new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff
changeset
|
3659 } |