annotate postproc/postprocess_template.c @ 2180:c76bfc70a28c

minor QP scaling & auto-contrast bugfix fixed compilation problem without -fomit-frame-pointer
author michael
date Sat, 13 Oct 2001 09:30:07 +0000
parents 2d8d14b882cc
children d90f8fc7ead6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 /*
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
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
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
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
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
26 isHorizMinMaxOk a
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
27 doHorizLowPass E a a*
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
28 doHorizDefFilter E ac ac
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
29 deRing
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
30 Vertical RKAlgo1 E a a*
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
31 Vertical X1 a E E*
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
32 Horizontal X1 a E E*
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
33
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
34
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
35 * i dont have a 3dnow CPU -> its untested
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
36 E = Exact implementation
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
37 e = allmost exact implementation
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
38 a = alternative / approximate impl
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
39 c = checked against the other implementations (-vo md5)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
40 */
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
41
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
42 /*
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
43 TODO:
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
44 verify that everything workes as it should (how?)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
45 reduce the time wasted on the mem transfer
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
46 implement dering
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
47 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
48 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
49 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
50 move YScale thing to the end instead of fixing QP
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
51 write a faster and higher quality deblocking filter :)
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
52 do something about the speed of the horizontal filters
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
53 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
54 (the if/else stuff per block is slowing things down)
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
55 compare the quality & speed of all filters
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
56 implement a few simple deinterlacing filters
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
57 split this huge file
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
58 ...
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
59
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
60 Notes:
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
61
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
62 */
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
63
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
64 /*
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
65 Changelog: use the CVS log
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
66 0.1.3
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
67 bugfixes: last 3 lines not brightness/contrast corrected
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
68 brightness statistics messed up with initial black pic
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
69 changed initial values of the brightness statistics
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
70 C++ -> C conversation
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
71 QP range question solved (very likely 1<=QP<=32 according to arpi)
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
72 new experimental vertical deblocking filter
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
73 RK filter has 3dNow support now (untested)
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
74 0.1.2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
75 fixed a bug in the horizontal default filter
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
76 3dnow version of the Horizontal & Vertical Lowpass filters
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
77 mmx version of the Horizontal Default filter
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
78 mmx2 & C versions of a simple filter described in a paper from ramkishor & karandikar
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
79 added mode flags & quality2mode function
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
80 0.1.1
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
81 */
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
82
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
83
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
84 #include <inttypes.h>
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
85 #include <stdio.h>
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
86 #include <stdlib.h>
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
87 #include "../config.h"
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
88 //#undef HAVE_MMX2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
89 //#define HAVE_3DNOW
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
90 //#undef HAVE_MMX
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
91 #include "postprocess.h"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
92
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
93
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
94 static uint64_t packedYOffset= 0x0000000000000000LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
95 static uint64_t packedYScale= 0x0100010001000100LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
96 static uint64_t w05= 0x0005000500050005LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
97 static uint64_t w20= 0x0020002000200020LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
98 static uint64_t w1400= 0x1400140014001400LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
99 static uint64_t bm00000001= 0x00000000000000FFLL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
100 static uint64_t bm00010000= 0x000000FF00000000LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
101 static uint64_t bm00001000= 0x00000000FF000000LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
102 static uint64_t bm10000000= 0xFF00000000000000LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
103 static uint64_t bm10000001= 0xFF000000000000FFLL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
104 static uint64_t bm11000011= 0xFFFF00000000FFFFLL;
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
105 static uint64_t bm00000011= 0x000000000000FFFFLL;
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
106 static uint64_t bm11111110= 0xFFFFFFFFFFFFFF00LL;
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
107 static uint64_t bm11000000= 0xFFFF000000000000LL;
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
108 static uint64_t bm00011000= 0x000000FFFF000000LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
109 static uint64_t bm00110011= 0x0000FFFF0000FFFFLL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
110 static uint64_t bm11001100= 0xFFFF0000FFFF0000LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
111 static uint64_t b00= 0x0000000000000000LL;
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
112 static uint64_t b01= 0x0101010101010101LL;
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
113 static uint64_t b02= 0x0202020202020202LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
114 static uint64_t b0F= 0x0F0F0F0F0F0F0F0FLL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
115 static uint64_t bFF= 0xFFFFFFFFFFFFFFFFLL;
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
116 static uint64_t b20= 0x2020202020202020LL;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
117 static uint64_t b80= 0x8080808080808080LL;
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
118 static uint64_t b7E= 0x7E7E7E7E7E7E7E7ELL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
119 static uint64_t b7C= 0x7C7C7C7C7C7C7C7CLL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
120 static uint64_t b3F= 0x3F3F3F3F3F3F3F3FLL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
121 static uint64_t temp0=0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
122 static uint64_t temp1=0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
123 static uint64_t temp2=0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
124 static uint64_t temp3=0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
125 static uint64_t temp4=0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
126 static uint64_t temp5=0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
127 static uint64_t pQPb=0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
128 static uint8_t tempBlock[16*16];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
129
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
130 int hFlatnessThreshold= 56 - 16;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
131 int vFlatnessThreshold= 56 - 16;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
132
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
133 //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
134 double maxClippedThreshold= 0.01;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
135
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
136 int maxAllowedY=255;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
137 //FIXME can never make a movie´s black brighter (anyone needs that?)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
138 int minAllowedY=0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
139
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
140
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
141 static inline long long rdtsc()
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
142 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
143 long long l;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
144 asm volatile( "rdtsc\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
145 : "=A" (l)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
146 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
147 // printf("%d\n", int(l/1000));
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
148 return l;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
149 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
150
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
151 static inline void prefetchnta(void *p)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
152 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
153 asm volatile( "prefetchnta (%0)\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
154 : : "r" (p)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
155 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
156 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
157
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
158 static inline void prefetcht0(void *p)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
159 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
160 asm volatile( "prefetcht0 (%0)\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
161 : : "r" (p)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
162 );
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
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
165 static inline void prefetcht1(void *p)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
166 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
167 asm volatile( "prefetcht1 (%0)\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
168 : : "r" (p)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
169 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
170 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
171
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
172 static inline void prefetcht2(void *p)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
173 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
174 asm volatile( "prefetcht2 (%0)\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
175 : : "r" (p)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
176 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
177 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
178
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
179 //FIXME? |255-0| = 1 (shouldnt be a problem ...)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
180 /**
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
181 * Check if the middle 8x8 Block in the given 8x10 block is flat
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
182 */
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
183 static inline int isVertDC(uint8_t src[], int stride){
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
184 // return true;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
185 int numEq= 0;
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
186 int y;
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
187 src+= stride; // src points to begin of the 8x8 Block
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
188 #ifdef HAVE_MMX
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
189 asm volatile(
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
190 // "int $3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
191 "pushl %1\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
192 "movq b7E, %%mm7 \n\t" // mm7 = 0x7F
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
193 "movq b7C, %%mm6 \n\t" // mm6 = 0x7D
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
194 "movq (%1), %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
195 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
196 "movq (%1), %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
197 "psubb %%mm1, %%mm0 \n\t" // mm0 = differnece
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
198 "paddb %%mm7, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
199 "pcmpgtb %%mm6, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
200
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
201 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
202 "movq (%1), %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
203 "psubb %%mm2, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
204 "paddb %%mm7, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
205 "pcmpgtb %%mm6, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
206 "paddb %%mm1, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
207
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
208 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
209 "movq (%1), %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
210 "psubb %%mm1, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
211 "paddb %%mm7, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
212 "pcmpgtb %%mm6, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
213 "paddb %%mm2, %%mm0 \n\t"
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 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
216 "movq (%1), %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
217 "psubb %%mm2, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
218 "paddb %%mm7, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
219 "pcmpgtb %%mm6, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
220 "paddb %%mm1, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
221
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
222 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
223 "movq (%1), %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
224 "psubb %%mm1, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
225 "paddb %%mm7, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
226 "pcmpgtb %%mm6, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
227 "paddb %%mm2, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
228
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
229 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
230 "movq (%1), %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
231 "psubb %%mm2, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
232 "paddb %%mm7, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
233 "pcmpgtb %%mm6, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
234 "paddb %%mm1, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
235
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
236 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
237 "movq (%1), %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
238 "psubb %%mm1, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
239 "paddb %%mm7, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
240 "pcmpgtb %%mm6, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
241 "paddb %%mm2, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
242
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
243 " \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
244 "movq %%mm0, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
245 "psrlw $8, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
246 "paddb %%mm1, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
247 "movq %%mm0, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
248 "psrlq $16, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
249 "paddb %%mm1, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
250 "movq %%mm0, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
251 "psrlq $32, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
252 "paddb %%mm1, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
253 "popl %1\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
254 "movd %%mm0, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
255 : "=r" (numEq)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
256 : "r" (src), "r" (stride)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
257 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
258 // printf("%d\n", numEq);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
259 numEq= (256 - (numEq & 0xFF)) &0xFF;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
260
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
261 // int asmEq= numEq;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
262 // numEq=0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
263 // uint8_t *temp= src;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
264
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
265 #else
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
266 for(y=0; y<BLOCK_SIZE-1; y++)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
267 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
268 if(((src[0] - src[0+stride] + 1)&0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
269 if(((src[1] - src[1+stride] + 1)&0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
270 if(((src[2] - src[2+stride] + 1)&0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
271 if(((src[3] - src[3+stride] + 1)&0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
272 if(((src[4] - src[4+stride] + 1)&0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
273 if(((src[5] - src[5+stride] + 1)&0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
274 if(((src[6] - src[6+stride] + 1)&0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
275 if(((src[7] - src[7+stride] + 1)&0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
276 src+= stride;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
277 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
278 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
279 /* if(abs(numEq - asmEq) > 0)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
280 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
281 printf("\nasm:%d c:%d\n", asmEq, numEq);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
282 for(int y=0; y<8; y++)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
283 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
284 for(int x=0; x<8; x++)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
285 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
286 printf("%d ", temp[x + y*stride]);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
287 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
288 printf("\n");
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
289 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
290 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
291 */
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
292 // 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
293 return (numEq > vFlatnessThreshold) ? 1 : 0;
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
294 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
295
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
296 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
297 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
298 #ifdef HAVE_MMX
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
299 int isOk;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
300 asm volatile(
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
301 // "int $3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
302 "movq (%1, %2), %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
303 "movq (%1, %2, 8), %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
304 "movq %%mm0, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
305 "psubusb %%mm1, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
306 "psubusb %%mm2, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
307 "por %%mm1, %%mm0 \n\t" // ABS Diff
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
308
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
309 "movq pQPb, %%mm7 \n\t" // QP,..., QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
310 "paddusb %%mm7, %%mm7 \n\t" // 2QP ... 2QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
311 "psubusb %%mm7, %%mm0 \n\t" // Diff <= 2QP -> 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
312 "pcmpeqd b00, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
313 "psrlq $16, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
314 "pcmpeqd bFF, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
315 // "movd %%mm0, (%1, %2, 4)\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
316 "movd %%mm0, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
317 : "=r" (isOk)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
318 : "r" (src), "r" (stride)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
319 );
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
320 return isOk ? 1 : 0;
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
321 #else
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
322
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
323 int isOk2= 1;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
324 int x;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
325 for(x=0; x<BLOCK_SIZE; x++)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
326 {
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
327 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
328 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
329 /* if(isOk && !isOk2 || !isOk && isOk2)
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 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
332 for(int y=0; y<9; y++)
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 for(int x=0; x<8; x++)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
335 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
336 printf("%d ", src[x + y*stride]);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
337 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
338 printf("\n");
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
339 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
340 } */
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
341
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
342 return isOk2;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
343 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
344
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
345 }
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 /**
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
348 * Do a vertical low pass filter on the 8x10 block (only write to the 8x8 block in the middle)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
349 * useing the 9-Tap Filter (1,1,2,2,4,2,2,1,1)/16
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
350 */
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
351 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
352 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
353 // QP= 64;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
354
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
355 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
356 //#ifdef HAVE_MMX2
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
357 asm volatile( //"movv %0 %1 %2\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
358 "pushl %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
359 "movq pQPb, %%mm0 \n\t" // QP,..., QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
360 // "movq bFF , %%mm0 \n\t" // QP,..., QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
361
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
362 "movq (%0), %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
363 "movq (%0, %1), %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
364 "movq %%mm5, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
365 "movq %%mm6, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
366 "psubusb %%mm6, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
367 "psubusb %%mm1, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
368 "por %%mm5, %%mm2 \n\t" // ABS Diff of lines
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
369 "psubusb %%mm0, %%mm2 \n\t" // diff <= QP -> 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
370 "pcmpeqb b00, %%mm2 \n\t" // diff <= QP -> FF
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
371
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
372 "pand %%mm2, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
373 "pandn %%mm1, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
374 "por %%mm2, %%mm6 \n\t"// First Line to Filter
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
375
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
376 "movq (%0, %1, 8), %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
377 "leal (%0, %1, 4), %%eax \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
378 "leal (%0, %1, 8), %%ebx \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
379 "subl %1, %%ebx \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
380 "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
381 "movq (%0, %1, 8), %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
382 "movq %%mm5, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
383 "movq %%mm7, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
384 "psubusb %%mm7, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
385 "psubusb %%mm1, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
386 "por %%mm5, %%mm2 \n\t" // ABS Diff of lines
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
387 "psubusb %%mm0, %%mm2 \n\t" // diff <= QP -> 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
388 "pcmpeqb b00, %%mm2 \n\t" // diff <= QP -> FF
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
389
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
390 "pand %%mm2, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
391 "pandn %%mm1, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
392 "por %%mm2, %%mm7 \n\t" // First Line to Filter
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
393
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
394
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
395 // 1 2 3 4 5 6 7 8
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
396 // %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
397 // 6 4 2 2 1 1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
398 // 6 4 4 2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
399 // 6 8 2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
400 /*
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
401 "movq %%mm6, %%mm2 \n\t" //1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
402 "movq %%mm6, %%mm3 \n\t" //1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
403 "paddusb b02, %%mm3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
404 "psrlw $2, %%mm3 \n\t" //1 /4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
405 "pand b3F, %%mm3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
406 "psubb %%mm3, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
407 "movq (%0, %1), %%mm0 \n\t" // 1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
408 "movq %%mm0, %%mm1 \n\t" // 1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
409 "paddusb b02, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
410 "psrlw $2, %%mm0 \n\t" // 1 /4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
411 "pand b3F, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
412 "paddusb %%mm2, %%mm0 \n\t" //3 1 /4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
413 */
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
414 "movq (%0, %1), %%mm0 \n\t" // 1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
415 "movq %%mm0, %%mm1 \n\t" // 1
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
416 PAVGB(%%mm6, %%mm0) //1 1 /2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
417 PAVGB(%%mm6, %%mm0) //3 1 /4
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
418
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
419 "movq (%0, %1, 4), %%mm2 \n\t" // 1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
420 "movq %%mm2, %%mm5 \n\t" // 1
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
421 PAVGB((%%eax), %%mm2) // 11 /2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
422 PAVGB((%0, %1, 2), %%mm2) // 211 /4
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
423 "movq %%mm2, %%mm3 \n\t" // 211 /4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
424 "movq (%0), %%mm4 \n\t" // 1
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
425 PAVGB(%%mm4, %%mm3) // 4 211 /8
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
426 PAVGB(%%mm0, %%mm3) //642211 /16
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
427 "movq %%mm3, (%0) \n\t" // X
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
428 // 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
429 "movq %%mm1, %%mm0 \n\t" // 1
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
430 PAVGB(%%mm6, %%mm0) //1 1 /2
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
431 "movq %%mm4, %%mm3 \n\t" // 1
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
432 PAVGB((%0,%1,2), %%mm3) // 1 1 /2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
433 PAVGB((%%eax,%1,2), %%mm5) // 11 /2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
434 PAVGB((%%eax), %%mm5) // 211 /4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
435 PAVGB(%%mm5, %%mm3) // 2 2211 /8
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
436 PAVGB(%%mm0, %%mm3) //4242211 /16
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
437 "movq %%mm3, (%0,%1) \n\t" // X
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
438 // mm1=2 mm2=3(211) mm4=1 mm5=4(211) mm6=0 mm7=9
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
439 PAVGB(%%mm4, %%mm6) //11 /2
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
440 "movq (%%ebx), %%mm0 \n\t" // 1
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
441 PAVGB((%%eax, %1, 2), %%mm0) // 11/2
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
442 "movq %%mm0, %%mm3 \n\t" // 11/2
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
443 PAVGB(%%mm1, %%mm0) // 2 11/4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
444 PAVGB(%%mm6, %%mm0) //222 11/8
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
445 PAVGB(%%mm2, %%mm0) //22242211/16
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
446 "movq (%0, %1, 2), %%mm2 \n\t" // 1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
447 "movq %%mm0, (%0, %1, 2) \n\t" // X
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
448 // 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
449 "movq (%%eax, %1, 4), %%mm0 \n\t" // 1
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
450 PAVGB((%%ebx), %%mm0) // 11 /2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
451 PAVGB(%%mm0, %%mm6) //11 11 /4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
452 PAVGB(%%mm1, %%mm4) // 11 /2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
453 PAVGB(%%mm2, %%mm1) // 11 /2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
454 PAVGB(%%mm1, %%mm6) //1122 11 /8
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
455 PAVGB(%%mm5, %%mm6) //112242211 /16
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
456 "movq (%%eax), %%mm5 \n\t" // 1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
457 "movq %%mm6, (%%eax) \n\t" // X
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
458 // 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
459 "movq (%%eax, %1, 4), %%mm6 \n\t" // 1
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
460 PAVGB(%%mm7, %%mm6) // 11 /2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
461 PAVGB(%%mm4, %%mm6) // 11 11 /4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
462 PAVGB(%%mm3, %%mm6) // 11 2211 /8
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
463 PAVGB(%%mm5, %%mm2) // 11 /2
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
464 "movq (%0, %1, 4), %%mm4 \n\t" // 1
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
465 PAVGB(%%mm4, %%mm2) // 112 /4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
466 PAVGB(%%mm2, %%mm6) // 112242211 /16
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
467 "movq %%mm6, (%0, %1, 4) \n\t" // X
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
468 // mm0=7(11) mm1=2(11) mm2=3(112) mm3=6(11) mm4=5 mm5=4 mm7=9
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
469 PAVGB(%%mm7, %%mm1) // 11 2 /4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
470 PAVGB(%%mm4, %%mm5) // 11 /2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
471 PAVGB(%%mm5, %%mm0) // 11 11 /4
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
472 "movq (%%eax, %1, 2), %%mm6 \n\t" // 1
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
473 PAVGB(%%mm6, %%mm1) // 11 4 2 /8
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
474 PAVGB(%%mm0, %%mm1) // 11224222 /16
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
475 // "pxor %%mm1, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
476 "movq %%mm1, (%%eax, %1, 2) \n\t" // X
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
477 // mm2=3(112) mm3=6(11) mm4=5 mm5=4(11) mm6=6 mm7=9
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
478 PAVGB((%%ebx), %%mm2) // 112 4 /8
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
479 "movq (%%eax, %1, 4), %%mm0 \n\t" // 1
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
480 PAVGB(%%mm0, %%mm6) // 1 1 /2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
481 PAVGB(%%mm7, %%mm6) // 1 12 /4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
482 PAVGB(%%mm2, %%mm6) // 1122424 /4
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
483 // "pxor %%mm6, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
484 "movq %%mm6, (%%ebx) \n\t" // X
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
485 // mm0=8 mm3=6(11) mm4=5 mm5=4(11) mm7=9
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
486 PAVGB(%%mm7, %%mm5) // 11 2 /4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
487 PAVGB(%%mm7, %%mm5) // 11 6 /8
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
488
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
489 PAVGB(%%mm3, %%mm0) // 112 /4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
490 PAVGB(%%mm0, %%mm5) // 112246 /16
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
491 // "pxor %%mm5, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
492 // "movq pQPb, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
493 "movq %%mm5, (%%eax, %1, 4) \n\t" // X
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
494 "popl %0\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
495
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
496 :
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
497 : "r" (src), "r" (stride)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
498 : "%eax", "%ebx"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
499 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
500 #else
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
501 const int l1= stride;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
502 const int l2= stride + l1;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
503 const int l3= stride + l2;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
504 const int l4= stride + l3;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
505 const int l5= stride + l4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
506 const int l6= stride + l5;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
507 const int l7= stride + l6;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
508 const int l8= stride + l7;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
509 const int l9= stride + l8;
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
510 int x;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
511 for(x=0; x<BLOCK_SIZE; x++)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
512 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
513 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
514 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
515
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
516 int sums[9];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
517 sums[0] = first + src[l1];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
518 sums[1] = src[l1] + src[l2];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
519 sums[2] = src[l2] + src[l3];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
520 sums[3] = src[l3] + src[l4];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
521 sums[4] = src[l4] + src[l5];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
522 sums[5] = src[l5] + src[l6];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
523 sums[6] = src[l6] + src[l7];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
524 sums[7] = src[l7] + src[l8];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
525 sums[8] = src[l8] + last;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
526
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
527 src[l1]= ((sums[0]<<2) + ((first + sums[2])<<1) + sums[4] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
528 src[l2]= ((src[l2]<<2) + (first + sums[0] + sums[3]<<1) + sums[5] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
529 src[l3]= ((src[l3]<<2) + (first + sums[1] + sums[4]<<1) + sums[6] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
530 src[l4]= ((src[l4]<<2) + (sums[2] + sums[5]<<1) + sums[0] + sums[7] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
531 src[l5]= ((src[l5]<<2) + (sums[3] + sums[6]<<1) + sums[1] + sums[8] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
532 src[l6]= ((src[l6]<<2) + (last + sums[7] + sums[4]<<1) + sums[2] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
533 src[l7]= ((last + src[l7]<<2) + (src[l8] + sums[5]<<1) + sums[3] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
534 src[l8]= ((sums[8]<<2) + (last + sums[6]<<1) + sums[4] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
535
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
536 src++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
537 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
538
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
539 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
540 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
541
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
542 /**
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
543 * Experimental implementation of the filter (Algorithm 1) described in a paper from Ramkishor & Karandikar
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
544 * values are correctly clipped (MMX2)
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
545 * values are wraparound (C)
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
546 * conclusion: its fast, but introduces ugly horizontal patterns if there is a continious gradient
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
547 0 8 16 24
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
548 x = 8
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
549 x/2 = 4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
550 x/8 = 1
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
551 1 12 12 23
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
552 */
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
553 static inline void vertRK1Filter(uint8_t *src, int stride, int QP)
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
554 {
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
555 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
556 // FIXME rounding
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
557 asm volatile(
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
558 "pxor %%mm7, %%mm7 \n\t" // 0
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
559 "movq b80, %%mm6 \n\t" // MIN_SIGNED_BYTE
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
560 "leal (%0, %1), %%eax \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
561 "leal (%%eax, %1, 4), %%ebx \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
562 // 0 1 2 3 4 5 6 7 8 9
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
563 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
564 "movq pQPb, %%mm0 \n\t" // QP,..., QP
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
565 "movq %%mm0, %%mm1 \n\t" // QP,..., QP
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
566 "paddusb b02, %%mm0 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
567 "psrlw $2, %%mm0 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
568 "pand b3F, %%mm0 \n\t" // QP/4,..., QP/4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
569 "paddusb %%mm1, %%mm0 \n\t" // QP*1.25 ...
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
570 "movq (%0, %1, 4), %%mm2 \n\t" // line 4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
571 "movq (%%ebx), %%mm3 \n\t" // line 5
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
572 "movq %%mm2, %%mm4 \n\t" // line 4
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
573 "pcmpeqb %%mm5, %%mm5 \n\t" // -1
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
574 "pxor %%mm2, %%mm5 \n\t" // -line 4 - 1
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
575 PAVGB(%%mm3, %%mm5)
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
576 "paddb %%mm6, %%mm5 \n\t" // (l5-l4)/2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
577 "psubusb %%mm3, %%mm4 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
578 "psubusb %%mm2, %%mm3 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
579 "por %%mm3, %%mm4 \n\t" // |l4 - l5|
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
580 "psubusb %%mm0, %%mm4 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
581 "pcmpeqb %%mm7, %%mm4 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
582 "pand %%mm4, %%mm5 \n\t" // d/2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
583
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
584 // "paddb %%mm6, %%mm2 \n\t" // line 4 + 0x80
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
585 "paddb %%mm5, %%mm2 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
586 // "psubb %%mm6, %%mm2 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
587 "movq %%mm2, (%0,%1, 4) \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
588
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
589 "movq (%%ebx), %%mm2 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
590 // "paddb %%mm6, %%mm2 \n\t" // line 5 + 0x80
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
591 "psubb %%mm5, %%mm2 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
592 // "psubb %%mm6, %%mm2 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
593 "movq %%mm2, (%%ebx) \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
594
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
595 "paddb %%mm6, %%mm5 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
596 "psrlw $2, %%mm5 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
597 "pand b3F, %%mm5 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
598 "psubb b20, %%mm5 \n\t" // (l5-l4)/8
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
599
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
600 "movq (%%eax, %1, 2), %%mm2 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
601 "paddb %%mm6, %%mm2 \n\t" // line 3 + 0x80
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
602 "paddsb %%mm5, %%mm2 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
603 "psubb %%mm6, %%mm2 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
604 "movq %%mm2, (%%eax, %1, 2) \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
605
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
606 "movq (%%ebx, %1), %%mm2 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
607 "paddb %%mm6, %%mm2 \n\t" // line 6 + 0x80
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
608 "psubsb %%mm5, %%mm2 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
609 "psubb %%mm6, %%mm2 \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
610 "movq %%mm2, (%%ebx, %1) \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
611
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
612 :
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
613 : "r" (src), "r" (stride)
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
614 : "%eax", "%ebx"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
615 );
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
616 #else
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
617 const int l1= stride;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
618 const int l2= stride + l1;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
619 const int l3= stride + l2;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
620 const int l4= stride + l3;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
621 const int l5= stride + l4;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
622 const int l6= stride + l5;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
623 const int l7= stride + l6;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
624 const int l8= stride + l7;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
625 const int l9= stride + l8;
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
626 int x;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
627 for(x=0; x<BLOCK_SIZE; x++)
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
628 {
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
629 if(ABS(src[l4]-src[l5]) < QP + QP/4)
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
630 {
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
631 int v = (src[l5] - src[l4]);
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
632
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
633 src[l3] +=v/8;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
634 src[l4] +=v/2;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
635 src[l5] -=v/2;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
636 src[l6] -=v/8;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
637
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
638 }
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
639 src++;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
640 }
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
641
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
642 #endif
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
643 }
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
644
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
645 /**
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
646 * Experimental Filter 1
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
647 * will not damage linear gradients
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
648 * 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
649 * 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
650 * MMX2 version does correct clipping C version doesnt
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
651 */
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
652 static inline void vertX1Filter(uint8_t *src, int stride, int QP)
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
653 {
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
654 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
655 asm volatile(
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
656 "pxor %%mm7, %%mm7 \n\t" // 0
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
657 // "movq b80, %%mm6 \n\t" // MIN_SIGNED_BYTE
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
658 "leal (%0, %1), %%eax \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
659 "leal (%%eax, %1, 4), %%ebx \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
660 // 0 1 2 3 4 5 6 7 8 9
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
661 // %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
662 "movq (%%eax, %1, 2), %%mm0 \n\t" // line 3
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
663 "movq (%0, %1, 4), %%mm1 \n\t" // line 4
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
664 "movq %%mm1, %%mm2 \n\t" // line 4
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
665 "psubusb %%mm0, %%mm1 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
666 "psubusb %%mm2, %%mm0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
667 "por %%mm1, %%mm0 \n\t" // |l2 - l3|
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
668 "movq (%%ebx), %%mm3 \n\t" // line 5
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
669 "movq (%%ebx, %1), %%mm4 \n\t" // line 6
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
670 "movq %%mm3, %%mm5 \n\t" // line 5
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
671 "psubusb %%mm4, %%mm3 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
672 "psubusb %%mm5, %%mm4 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
673 "por %%mm4, %%mm3 \n\t" // |l5 - l6|
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
674 PAVGB(%%mm3, %%mm0) // (|l2 - l3| + |l5 - l6|)/2
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
675 "movq %%mm2, %%mm1 \n\t" // line 4
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
676 "psubusb %%mm5, %%mm2 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
677 "movq %%mm2, %%mm4 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
678 "pcmpeqb %%mm7, %%mm2 \n\t" // (l4 - l5) <= 0 ? -1 : 0
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
679 "psubusb %%mm1, %%mm5 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
680 "por %%mm5, %%mm4 \n\t" // |l4 - l5|
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
681 "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
682 "movq %%mm4, %%mm3 \n\t" // d
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
683 "psubusb pQPb, %%mm4 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
684 "pcmpeqb %%mm7, %%mm4 \n\t" // d <= QP ? -1 : 0
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
685 "psubusb b01, %%mm3 \n\t"
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
686 "pand %%mm4, %%mm3 \n\t" // d <= QP ? d : 0
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
687
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
688 PAVGB(%%mm7, %%mm3) // d/2
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
689 "movq %%mm3, %%mm1 \n\t" // d/2
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
690 PAVGB(%%mm7, %%mm3) // d/4
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
691 PAVGB(%%mm1, %%mm3) // 3*d/8
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
692
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
693 "movq (%0, %1, 4), %%mm0 \n\t" // line 4
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
694 "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
695 "psubusb %%mm3, %%mm0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
696 "pxor %%mm2, %%mm0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
697 "movq %%mm0, (%0, %1, 4) \n\t" // line 4
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
698
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
699 "movq (%%ebx), %%mm0 \n\t" // line 5
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
700 "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
701 "paddusb %%mm3, %%mm0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
702 "pxor %%mm2, %%mm0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
703 "movq %%mm0, (%%ebx) \n\t" // line 5
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
704
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
705 PAVGB(%%mm7, %%mm1) // d/4
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
706
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
707 "movq (%%eax, %1, 2), %%mm0 \n\t" // line 3
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
708 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l4-1 : l4
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
709 "psubusb %%mm1, %%mm0 \n\t"
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
710 "pxor %%mm2, %%mm0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
711 "movq %%mm0, (%%eax, %1, 2) \n\t" // line 3
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
712
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
713 "movq (%%ebx, %1), %%mm0 \n\t" // line 6
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
714 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l5-1 : l5
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
715 "paddusb %%mm1, %%mm0 \n\t"
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
716 "pxor %%mm2, %%mm0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
717 "movq %%mm0, (%%ebx, %1) \n\t" // line 6
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
718
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
719 PAVGB(%%mm7, %%mm1) // d/8
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
720
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
721 "movq (%%eax, %1), %%mm0 \n\t" // line 2
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
722 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l2-1 : l2
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
723 "psubusb %%mm1, %%mm0 \n\t"
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
724 "pxor %%mm2, %%mm0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
725 "movq %%mm0, (%%eax, %1) \n\t" // line 2
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
726
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
727 "movq (%%ebx, %1, 2), %%mm0 \n\t" // line 7
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
728 "pxor %%mm2, %%mm0 \n\t" //(l4 - l5) <= 0 ? -l7-1 : l7
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
729 "paddusb %%mm1, %%mm0 \n\t"
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
730 "pxor %%mm2, %%mm0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
731 "movq %%mm0, (%%ebx, %1, 2) \n\t" // line 7
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
732
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
733 :
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
734 : "r" (src), "r" (stride)
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
735 : "%eax", "%ebx"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
736 );
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
737 #else
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
738
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
739 const int l1= stride;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
740 const int l2= stride + l1;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
741 const int l3= stride + l2;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
742 const int l4= stride + l3;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
743 const int l5= stride + l4;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
744 const int l6= stride + l5;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
745 const int l7= stride + l6;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
746 const int l8= stride + l7;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
747 const int l9= stride + l8;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
748 int x;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
749 for(x=0; x<BLOCK_SIZE; x++)
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
750 {
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
751 int a= src[l3] - src[l4];
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
752 int b= src[l4] - src[l5];
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
753 int c= src[l5] - src[l6];
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
754
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
755 int d= MAX(ABS(b) - (ABS(a) + ABS(c))/2, 0);
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
756
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
757 if(d < QP)
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
758 {
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
759 int v = d * SIGN(-b);
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 src[l2] +=v/8;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
762 src[l3] +=v/4;
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
763 src[l4] +=3*v/8;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
764 src[l5] -=3*v/8;
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
765 src[l6] -=v/4;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
766 src[l7] -=v/8;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
767
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
768 }
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
769 src++;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
770 }
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
771 /*
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
772 const int l1= stride;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
773 const int l2= stride + l1;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
774 const int l3= stride + l2;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
775 const int l4= stride + l3;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
776 const int l5= stride + l4;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
777 const int l6= stride + l5;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
778 const int l7= stride + l6;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
779 const int l8= stride + l7;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
780 const int l9= stride + l8;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
781 for(int x=0; x<BLOCK_SIZE; x++)
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
782 {
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
783 int v2= src[l2];
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
784 int v3= src[l3];
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
785 int v4= src[l4];
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
786 int v5= src[l5];
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
787 int v6= src[l6];
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
788 int v7= src[l7];
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
789
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
790 if(ABS(v4-v5)<QP && ABS(v4-v5) - (ABS(v3-v4) + ABS(v5-v6))>0 )
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
791 {
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
792 src[l3] = (6*v2 + 4*v3 + 3*v4 + 2*v5 + v6 )/16;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
793 src[l4] = (3*v2 + 3*v3 + 4*v4 + 3*v5 + 2*v6 + v7 )/16;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
794 src[l5] = (1*v2 + 2*v3 + 3*v4 + 4*v5 + 3*v6 + 3*v7)/16;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
795 src[l6] = ( 1*v3 + 2*v4 + 3*v5 + 4*v6 + 6*v7)/16;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
796 }
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
797 src++;
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
798 }
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
799 */
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
800 #endif
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
801 }
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
802
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
803 /**
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
804 * Experimental Filter 1 (Horizontal)
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
805 * will not damage linear gradients
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
806 * Flat blocks should look like they where passed through the (1,1,2,2,4,2,2,1,1) 9-Tap filter
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
807 * can only smooth blocks at the expected locations (it cant smooth them if they did move)
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
808 * MMX2 version does correct clipping C version doesnt
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
809 * not identical with the vertical one
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
810 */
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
811 static inline void horizX1Filter(uint8_t *src, int stride, int QP)
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
812 {
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
813 int y;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
814 static uint64_t *lut= NULL;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
815 if(lut==NULL)
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
816 {
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
817 int i;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
818 lut= (uint64_t*)memalign(8, 256*8);
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
819 for(i=0; i<256; i++)
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
820 {
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
821 int v= i < 128 ? 2*i : 2*(i-256);
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
822 /*
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
823 //Simulate 112242211 9-Tap filter
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
824 uint64_t a= (v/16) & 0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
825 uint64_t b= (v/8) & 0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
826 uint64_t c= (v/4) & 0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
827 uint64_t d= (3*v/8) & 0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
828 */
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
829 //Simulate piecewise linear interpolation
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
830 uint64_t a= (v/16) & 0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
831 uint64_t b= (v*3/16) & 0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
832 uint64_t c= (v*5/16) & 0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
833 uint64_t d= (7*v/16) & 0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
834 uint64_t A= (0x100 - a)&0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
835 uint64_t B= (0x100 - b)&0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
836 uint64_t C= (0x100 - c)&0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
837 uint64_t D= (0x100 - c)&0xFF;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
838
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
839 lut[i] = (a<<56) | (b<<48) | (c<<40) | (d<<32) |
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
840 (D<<24) | (C<<16) | (B<<8) | (A);
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
841 //lut[i] = (v<<32) | (v<<24);
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
842 }
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
843 }
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
844
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
845 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
846 asm volatile(
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
847 "pxor %%mm7, %%mm7 \n\t" // 0
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
848 // "movq b80, %%mm6 \n\t" // MIN_SIGNED_BYTE
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
849 "leal (%0, %1), %%eax \n\t"
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
850 "leal (%%eax, %1, 4), %%ebx \n\t"
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
851
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
852 "movq b80, %%mm6 \n\t"
2180
c76bfc70a28c minor QP scaling & auto-contrast bugfix
michael
parents: 2179
diff changeset
853 "movd pQPb, %%mm5 \n\t" // QP
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
854 "movq %%mm5, %%mm4 \n\t"
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
855 "paddusb %%mm5, %%mm5 \n\t" // 2QP
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
856 "paddusb %%mm5, %%mm4 \n\t" // 3QP
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
857 "pxor %%mm5, %%mm5 \n\t" // 0
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
858 "psubb %%mm4, %%mm5 \n\t" // -3QP
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
859 "por bm11111110, %%mm5 \n\t" // ...,FF,FF,-3QP
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
860 "psllq $24, %%mm5 \n\t"
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
861
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
862 // 0 1 2 3 4 5 6 7 8 9
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
863 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
864
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
865 #define HX1old(a) \
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
866 "movd " #a ", %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
867 "movd 4" #a ", %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
868 "punpckldq %%mm1, %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
869 "movq %%mm0, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
870 "movq %%mm0, %%mm2 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
871 "psrlq $8, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
872 "psubusb %%mm1, %%mm2 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
873 "psubusb %%mm0, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
874 "por %%mm2, %%mm1 \n\t" /* p´x = |px - p(x+1)| */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
875 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
876 "pshufw $0x00, %%mm1, %%mm3 \n\t" /* p´5 = |p1 - p2| */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
877 PAVGB(%%mm1, %%mm3) /* p´5 = (|p2-p1| + |p6-p5|)/2 */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
878 "psrlq $16, %%mm3 \n\t" /* p´3 = (|p2-p1| + |p6-p5|)/2 */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
879 "psubusb %%mm3, %%mm1 \n\t" /* |p3-p4|-(|p2-p1| + |p6-p5|)/2 */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
880 "paddb %%mm5, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
881 "psubusb %%mm5, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
882 PAVGB(%%mm7, %%mm1)\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
883 "pxor %%mm2, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
884 "psubb %%mm2, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
885 "psrlq $24, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
886 "movd %%mm1, %%ecx \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
887 "paddb %%mm6, %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
888 "paddsb (%3, %%ecx, 8), %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
889 "paddb %%mm6, %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
890 "movq %%mm0, " #a " \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
891
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
892 /*
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
893 HX1old((%0))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
894 HX1old((%%eax))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
895 HX1old((%%eax, %1))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
896 HX1old((%%eax, %1, 2))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
897 HX1old((%0, %1, 4))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
898 HX1old((%%ebx))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
899 HX1old((%%ebx, %1))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
900 HX1old((%%ebx, %1, 2))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
901 */
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
902
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
903 //FIXME add some comments, its unreadable ...
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
904 #define HX1b(a, c, b, d) \
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
905 "movd " #a ", %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
906 "movd 4" #a ", %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
907 "punpckldq %%mm1, %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
908 "movd " #b ", %%mm4 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
909 "movq %%mm0, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
910 "movq %%mm0, %%mm2 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
911 "psrlq $8, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
912 "movd 4" #b ", %%mm3 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
913 "psubusb %%mm1, %%mm2 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
914 "psubusb %%mm0, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
915 "por %%mm2, %%mm1 \n\t" /* p´x = |px - p(x+1)| */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
916 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
917 "punpckldq %%mm3, %%mm4 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
918 "movq %%mm1, %%mm3 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
919 "psllq $32, %%mm3 \n\t" /* p´5 = |p1 - p2| */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
920 PAVGB(%%mm1, %%mm3) /* p´5 = (|p2-p1| + |p6-p5|)/2 */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
921 "paddb %%mm6, %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
922 "psrlq $16, %%mm3 \n\t" /* p´3 = (|p2-p1| + |p6-p5|)/2 */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
923 "psubusb %%mm3, %%mm1 \n\t" /* |p3-p4|-(|p2-p1| + |p6-p5|)/2 */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
924 "movq %%mm4, %%mm3 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
925 "paddb %%mm5, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
926 "psubusb %%mm5, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
927 "psrlq $8, %%mm3 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
928 PAVGB(%%mm7, %%mm1)\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
929 "pxor %%mm2, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
930 "psubb %%mm2, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
931 "movq %%mm4, %%mm2 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
932 "psrlq $24, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
933 "psubusb %%mm3, %%mm2 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
934 "movd %%mm1, %%ecx \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
935 "psubusb %%mm4, %%mm3 \n\t"\
2180
c76bfc70a28c minor QP scaling & auto-contrast bugfix
michael
parents: 2179
diff changeset
936 "paddsb (%2, %%ecx, 8), %%mm0 \n\t"\
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
937 "por %%mm2, %%mm3 \n\t" /* p´x = |px - p(x+1)| */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
938 "paddb %%mm6, %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
939 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
940 "movq %%mm3, %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
941 "psllq $32, %%mm1 \n\t" /* p´5 = |p1 - p2| */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
942 "movq %%mm0, " #a " \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
943 PAVGB(%%mm3, %%mm1) /* p´5 = (|p2-p1| + |p6-p5|)/2 */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
944 "paddb %%mm6, %%mm4 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
945 "psrlq $16, %%mm1 \n\t" /* p´3 = (|p2-p1| + |p6-p5|)/2 */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
946 "psubusb %%mm1, %%mm3 \n\t" /* |p3-p4|-(|p2-p1| + |p6-p5|)/2 */\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
947 "paddb %%mm5, %%mm3 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
948 "psubusb %%mm5, %%mm3 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
949 PAVGB(%%mm7, %%mm3)\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
950 "pxor %%mm2, %%mm3 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
951 "psubb %%mm2, %%mm3 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
952 "psrlq $24, %%mm3 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
953 "movd " #c ", %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
954 "movd 4" #c ", %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
955 "punpckldq %%mm1, %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
956 "paddb %%mm6, %%mm0 \n\t"\
2180
c76bfc70a28c minor QP scaling & auto-contrast bugfix
michael
parents: 2179
diff changeset
957 "paddsb (%2, %%ecx, 8), %%mm0 \n\t"\
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
958 "paddb %%mm6, %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
959 "movq %%mm0, " #c " \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
960 "movd %%mm3, %%ecx \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
961 "movd " #d ", %%mm0 \n\t"\
2180
c76bfc70a28c minor QP scaling & auto-contrast bugfix
michael
parents: 2179
diff changeset
962 "paddsb (%2, %%ecx, 8), %%mm4 \n\t"\
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
963 "movd 4" #d ", %%mm1 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
964 "paddb %%mm6, %%mm4 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
965 "punpckldq %%mm1, %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
966 "movq %%mm4, " #b " \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
967 "paddb %%mm6, %%mm0 \n\t"\
2180
c76bfc70a28c minor QP scaling & auto-contrast bugfix
michael
parents: 2179
diff changeset
968 "paddsb (%2, %%ecx, 8), %%mm0 \n\t"\
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
969 "paddb %%mm6, %%mm0 \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
970 "movq %%mm0, " #d " \n\t"\
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
971
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
972 HX1b((%0),(%%eax),(%%eax, %1),(%%eax, %1, 2))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
973 HX1b((%0, %1, 4),(%%ebx),(%%ebx, %1),(%%ebx, %1, 2))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
974
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
975
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
976 :
2180
c76bfc70a28c minor QP scaling & auto-contrast bugfix
michael
parents: 2179
diff changeset
977 : "r" (src), "r" (stride), "r" (lut)
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
978 : "%eax", "%ebx", "%ecx"
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
979 );
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
980 #else
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
981
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
982 //FIXME (has little in common with the mmx2 version)
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
983 for(y=0; y<BLOCK_SIZE; y++)
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
984 {
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
985 int a= src[1] - src[2];
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
986 int b= src[3] - src[4];
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
987 int c= src[5] - src[6];
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
988
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
989 int d= MAX(ABS(b) - (ABS(a) + ABS(c))/2, 0);
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
990
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
991 if(d < QP)
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
992 {
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
993 int v = d * SIGN(-b);
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
994
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
995 src[1] +=v/8;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
996 src[2] +=v/4;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
997 src[3] +=3*v/8;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
998 src[4] -=3*v/8;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
999 src[5] -=v/4;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
1000 src[6] -=v/8;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
1001
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
1002 }
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
1003 src+=stride;
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
1004 }
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
1005 #endif
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
1006 }
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
1007
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1008
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1009 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
1010 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1011 #ifdef HAVE_MMX
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1012 src+= stride;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1013 //FIXME try pmul for *5 stuff
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1014 // src[0]=0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1015 asm volatile(
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1016 "pxor %%mm7, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1017 "leal (%0, %1), %%eax \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1018 "leal (%%eax, %1, 4), %%ebx \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1019 // 0 1 2 3 4 5 6 7
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1020 // %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
1021 // %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
1022
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1023 "movq (%0), %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1024 "movq %%mm0, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1025 "punpcklbw %%mm7, %%mm0 \n\t" // low part of line 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1026 "punpckhbw %%mm7, %%mm1 \n\t" // high part of line 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1027
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1028 "movq (%%eax), %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1029 "movq %%mm2, %%mm3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1030 "punpcklbw %%mm7, %%mm2 \n\t" // low part of line 1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1031 "punpckhbw %%mm7, %%mm3 \n\t" // high part of line 1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1032
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1033 "movq (%%eax, %1), %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1034 "movq %%mm4, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1035 "punpcklbw %%mm7, %%mm4 \n\t" // low part of line 2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1036 "punpckhbw %%mm7, %%mm5 \n\t" // high part of line 2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1037
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1038 "paddw %%mm0, %%mm0 \n\t" // 2L0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1039 "paddw %%mm1, %%mm1 \n\t" // 2H0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1040 "psubw %%mm4, %%mm2 \n\t" // L1 - L2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1041 "psubw %%mm5, %%mm3 \n\t" // H1 - H2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1042 "psubw %%mm2, %%mm0 \n\t" // 2L0 - L1 + L2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1043 "psubw %%mm3, %%mm1 \n\t" // 2H0 - H1 + H2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1044
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1045 "psllw $2, %%mm2 \n\t" // 4L1 - 4L2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1046 "psllw $2, %%mm3 \n\t" // 4H1 - 4H2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1047 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1048 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1049
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1050 "movq (%%eax, %1, 2), %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1051 "movq %%mm2, %%mm3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1052 "punpcklbw %%mm7, %%mm2 \n\t" // L3
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1053 "punpckhbw %%mm7, %%mm3 \n\t" // H3
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1054
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1055 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2 - L3
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1056 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2 - H3
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1057 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2 - 2L3
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1058 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2 - 2H3
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1059 "movq %%mm0, temp0 \n\t" // 2L0 - 5L1 + 5L2 - 2L3
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1060 "movq %%mm1, temp1 \n\t" // 2H0 - 5H1 + 5H2 - 2H3
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1061
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1062 "movq (%0, %1, 4), %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1063 "movq %%mm0, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1064 "punpcklbw %%mm7, %%mm0 \n\t" // L4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1065 "punpckhbw %%mm7, %%mm1 \n\t" // H4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1066
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1067 "psubw %%mm0, %%mm2 \n\t" // L3 - L4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1068 "psubw %%mm1, %%mm3 \n\t" // H3 - H4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1069 "movq %%mm2, temp2 \n\t" // L3 - L4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1070 "movq %%mm3, temp3 \n\t" // H3 - H4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1071 "paddw %%mm4, %%mm4 \n\t" // 2L2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1072 "paddw %%mm5, %%mm5 \n\t" // 2H2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1073 "psubw %%mm2, %%mm4 \n\t" // 2L2 - L3 + L4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1074 "psubw %%mm3, %%mm5 \n\t" // 2H2 - H3 + H4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1075
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1076 "psllw $2, %%mm2 \n\t" // 4L3 - 4L4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1077 "psllw $2, %%mm3 \n\t" // 4H3 - 4H4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1078 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1079 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1080 //50 opcodes so far
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1081 "movq (%%ebx), %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1082 "movq %%mm2, %%mm3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1083 "punpcklbw %%mm7, %%mm2 \n\t" // L5
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1084 "punpckhbw %%mm7, %%mm3 \n\t" // H5
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1085 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4 - L5
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1086 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4 - H5
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1087 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4 - 2L5
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1088 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4 - 2H5
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 (%%ebx, %1), %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1091 "punpcklbw %%mm7, %%mm6 \n\t" // L6
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1092 "psubw %%mm6, %%mm2 \n\t" // L5 - L6
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1093 "movq (%%ebx, %1), %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1094 "punpckhbw %%mm7, %%mm6 \n\t" // H6
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1095 "psubw %%mm6, %%mm3 \n\t" // H5 - H6
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1096
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1097 "paddw %%mm0, %%mm0 \n\t" // 2L4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1098 "paddw %%mm1, %%mm1 \n\t" // 2H4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1099 "psubw %%mm2, %%mm0 \n\t" // 2L4 - L5 + L6
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1100 "psubw %%mm3, %%mm1 \n\t" // 2H4 - H5 + H6
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" // 4L5 - 4L6
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1103 "psllw $2, %%mm3 \n\t" // 4H5 - 4H6
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1104 "psubw %%mm2, %%mm0 \n\t" // 2L4 - 5L5 + 5L6
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1105 "psubw %%mm3, %%mm1 \n\t" // 2H4 - 5H5 + 5H6
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 (%%ebx, %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" // L7
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1110 "punpckhbw %%mm7, %%mm3 \n\t" // H7
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 "paddw %%mm2, %%mm2 \n\t" // 2L7
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1113 "paddw %%mm3, %%mm3 \n\t" // 2H7
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1114 "psubw %%mm2, %%mm0 \n\t" // 2L4 - 5L5 + 5L6 - 2L7
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1115 "psubw %%mm3, %%mm1 \n\t" // 2H4 - 5H5 + 5H6 - 2H7
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1116
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1117 "movq temp0, %%mm2 \n\t" // 2L0 - 5L1 + 5L2 - 2L3
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1118 "movq temp1, %%mm3 \n\t" // 2H0 - 5H1 + 5H2 - 2H3
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1119 //FIXME pxor, psubw, pmax for abs
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1120 "movq %%mm7, %%mm6 \n\t" // 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1121 "pcmpgtw %%mm0, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1122 "pxor %%mm6, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1123 "psubw %%mm6, %%mm0 \n\t" // |2L4 - 5L5 + 5L6 - 2L7|
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1124 "movq %%mm7, %%mm6 \n\t" // 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1125 "pcmpgtw %%mm1, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1126 "pxor %%mm6, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1127 "psubw %%mm6, %%mm1 \n\t" // |2H4 - 5H5 + 5H6 - 2H7|
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1128
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1129 "movq %%mm7, %%mm6 \n\t" // 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1130 "pcmpgtw %%mm2, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1131 "pxor %%mm6, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1132 "psubw %%mm6, %%mm2 \n\t" // |2L0 - 5L1 + 5L2 - 2L3|
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1133 "movq %%mm7, %%mm6 \n\t" // 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1134 "pcmpgtw %%mm3, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1135 "pxor %%mm6, %%mm3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1136 "psubw %%mm6, %%mm3 \n\t" // |2H0 - 5H1 + 5H2 - 2H3|
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1137
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1138 #ifdef HAVE_MMX2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1139 "pminsw %%mm2, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1140 "pminsw %%mm3, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1141 #else
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1142 "movq %%mm0, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1143 "psubusw %%mm2, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1144 "psubw %%mm6, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1145 "movq %%mm1, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1146 "psubusw %%mm3, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1147 "psubw %%mm6, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1148 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1149
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1150 "movq %%mm7, %%mm6 \n\t" // 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1151 "pcmpgtw %%mm4, %%mm6 \n\t" // sign(2L2 - 5L3 + 5L4 - 2L5)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1152 "pxor %%mm6, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1153 "psubw %%mm6, %%mm4 \n\t" // |2L2 - 5L3 + 5L4 - 2L5|
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1154 "pcmpgtw %%mm5, %%mm7 \n\t" // sign(2H2 - 5H3 + 5H4 - 2H5)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1155 "pxor %%mm7, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1156 "psubw %%mm7, %%mm5 \n\t" // |2H2 - 5H3 + 5H4 - 2H5|
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1157 // 100 opcodes
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1158 "movd %2, %%mm2 \n\t" // QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1159 //"pcmpeqb %%mm2, %%mm2\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1160 "punpcklwd %%mm2, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1161 "punpcklwd %%mm2, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1162 "psllw $3, %%mm2 \n\t" // 8QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1163 "movq %%mm2, %%mm3 \n\t" // 8QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1164 "pcmpgtw %%mm4, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1165 "pcmpgtw %%mm5, %%mm3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1166 "pand %%mm2, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1167 "pand %%mm3, %%mm5 \n\t"
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
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1170 "psubusw %%mm0, %%mm4 \n\t" // hd
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1171 "psubusw %%mm1, %%mm5 \n\t" // ld
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1172
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 w05, %%mm2 \n\t" // 5
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1175 "pmullw %%mm2, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1176 "pmullw %%mm2, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1177 "movq w20, %%mm2 \n\t" // 32
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1178 "paddw %%mm2, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1179 "paddw %%mm2, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1180 "psrlw $6, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1181 "psrlw $6, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1182
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1183 /*
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1184 "movq w06, %%mm2 \n\t" // 6
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1185 "paddw %%mm2, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1186 "paddw %%mm2, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1187 "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
1188 //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
1189 "pmulhw %%mm2, %%mm4 \n\t" // hd/13
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1190 "pmulhw %%mm2, %%mm5 \n\t" // ld/13
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1191 */
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1192
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1193 "movq temp2, %%mm0 \n\t" // L3 - L4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1194 "movq temp3, %%mm1 \n\t" // H3 - H4
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1195
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1196 "pxor %%mm2, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1197 "pxor %%mm3, %%mm3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1198
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1199 // FIXME rounding error
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1200 "psraw $1, %%mm0 \n\t" // (L3 - L4)/2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1201 "psraw $1, %%mm1 \n\t" // (H3 - H4)/2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1202 "pcmpgtw %%mm0, %%mm2 \n\t" // sign (L3-L4)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1203 "pcmpgtw %%mm1, %%mm3 \n\t" // sign (H3-H4)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1204 "pxor %%mm2, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1205 "pxor %%mm3, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1206 "psubw %%mm2, %%mm0 \n\t" // |L3-L4|
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1207 "psubw %%mm3, %%mm1 \n\t" // |H3-H4|
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1208 // "psrlw $1, %%mm0 \n\t" // |L3 - L4|/2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1209 // "psrlw $1, %%mm1 \n\t" // |H3 - H4|/2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1210
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1211 "pxor %%mm6, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1212 "pxor %%mm7, %%mm3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1213 "pand %%mm2, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1214 "pand %%mm3, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1215
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1216 #ifdef HAVE_MMX2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1217 "pminsw %%mm0, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1218 "pminsw %%mm1, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1219 #else
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1220 "movq %%mm4, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1221 "psubusw %%mm0, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1222 "psubw %%mm2, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1223 "movq %%mm5, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1224 "psubusw %%mm1, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1225 "psubw %%mm2, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1226 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1227 "pxor %%mm6, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1228 "pxor %%mm7, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1229 "psubw %%mm6, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1230 "psubw %%mm7, %%mm5 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1231 "packsswb %%mm5, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1232 "movq (%%eax, %1, 2), %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1233 "paddb %%mm4, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1234 "movq %%mm0, (%%eax, %1, 2) \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1235 "movq (%0, %1, 4), %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1236 "psubb %%mm4, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1237 // "pxor %%mm0, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1238 "movq %%mm0, (%0, %1, 4) \n\t"
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 :
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1241 : "r" (src), "r" (stride), "r" (QP)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1242 : "%eax", "%ebx"
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 #else
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1245 const int l1= stride;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1246 const int l2= stride + l1;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1247 const int l3= stride + l2;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1248 const int l4= stride + l3;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1249 const int l5= stride + l4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1250 const int l6= stride + l5;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1251 const int l7= stride + l6;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1252 const int l8= stride + l7;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1253 // const int l9= stride + l8;
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1254 int x;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1255 for(x=0; x<BLOCK_SIZE; x++)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1256 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1257 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
1258 if(ABS(middleEnergy) < 8*QP)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1259 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1260 const int q=(src[l4] - src[l5])/2;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1261 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
1262 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
1263
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1264 int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1265 d= MAX(d, 0);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1266
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1267 d= (5*d + 32) >> 6;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1268 d*= SIGN(-middleEnergy);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1269
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1270 if(q>0)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1271 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1272 d= d<0 ? 0 : d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1273 d= d>q ? q : d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1274 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1275 else
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1276 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1277 d= d>0 ? 0 : d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1278 d= d<q ? q : d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1279 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1280
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1281 src[l4]-= d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1282 src[l5]+= d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1283 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1284 src++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1285 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1286 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1287 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1288
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1289 //FIXME? |255-0| = 1
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1290 /**
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1291 * Check if the given 8x8 Block is mostly "flat" and copy the unaliged data into tempBlock.
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1292 */
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1293 static inline int isHorizDCAndCopy2Temp(uint8_t src[], int stride)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1294 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1295 // src++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1296 int numEq= 0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1297 #ifdef HAVE_MMX
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1298 asm volatile (
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1299 // "int $3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1300 "pushl %1\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1301 "movq b7E, %%mm7 \n\t" // mm7 = 0x7F
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1302 "movq b7C, %%mm6 \n\t" // mm6 = 0x7D
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1303 "leal tempBlock, %%eax \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1304 "pxor %%mm0, %%mm0 \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 #define HDC_CHECK_AND_CPY(i) \
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1307 "movq -4(%1), %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1308 "psrlq $32, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1309 "punpckldq 4(%1), %%mm2 \n\t" /* (%1) */\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1310 "movq %%mm2, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1311 "psrlq $8, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1312 "psubb %%mm1, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1313 "paddb %%mm7, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1314 "pcmpgtb %%mm6, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1315 "paddb %%mm2, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1316 "movq %%mm1," #i "(%%eax) \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1317
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1318 HDC_CHECK_AND_CPY(0)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1319 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1320 HDC_CHECK_AND_CPY(8)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1321 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1322 HDC_CHECK_AND_CPY(16)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1323 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1324 HDC_CHECK_AND_CPY(24)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1325 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1326 HDC_CHECK_AND_CPY(32)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1327 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1328 HDC_CHECK_AND_CPY(40)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1329 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1330 HDC_CHECK_AND_CPY(48)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1331 "addl %2, %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1332 HDC_CHECK_AND_CPY(56)
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 "psllq $8, %%mm0 \n\t" // remove dummy value
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1335 "movq %%mm0, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1336 "psrlw $8, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1337 "paddb %%mm1, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1338 "movq %%mm0, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1339 "psrlq $16, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1340 "paddb %%mm1, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1341 "movq %%mm0, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1342 "psrlq $32, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1343 "paddb %%mm1, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1344 "popl %1\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1345 "movd %%mm0, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1346 : "=r" (numEq)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1347 : "r" (src), "r" (stride)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1348 : "%eax"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1349 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1350 // printf("%d\n", numEq);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1351 numEq= (256 - (numEq & 0xFF)) &0xFF;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1352 #else
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1353 int y;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1354 for(y=0; y<BLOCK_SIZE; y++)
2158
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 if(((src[0] - src[1] + 1) & 0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1357 if(((src[1] - src[2] + 1) & 0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1358 if(((src[2] - src[3] + 1) & 0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1359 if(((src[3] - src[4] + 1) & 0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1360 if(((src[4] - src[5] + 1) & 0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1361 if(((src[5] - src[6] + 1) & 0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1362 if(((src[6] - src[7] + 1) & 0xFFFF) < 3) numEq++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1363 tempBlock[0 + y*TEMP_STRIDE] = src[0];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1364 tempBlock[1 + y*TEMP_STRIDE] = src[1];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1365 tempBlock[2 + y*TEMP_STRIDE] = src[2];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1366 tempBlock[3 + y*TEMP_STRIDE] = src[3];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1367 tempBlock[4 + y*TEMP_STRIDE] = src[4];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1368 tempBlock[5 + y*TEMP_STRIDE] = src[5];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1369 tempBlock[6 + y*TEMP_STRIDE] = src[6];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1370 tempBlock[7 + y*TEMP_STRIDE] = src[7];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1371 src+= stride;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1372 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1373 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1374 /* if(abs(numEq - asmEq) > 0)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1375 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1376 // printf("\nasm:%d c:%d\n", asmEq, numEq);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1377 for(int y=0; y<8; y++)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1378 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1379 for(int x=0; x<8; x++)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1380 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1381 printf("%d ", src[x + y*stride]);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1382 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1383 printf("\n");
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1384 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1385 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1386 */
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1387 // printf("%d\n", numEq);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1388 return numEq > hFlatnessThreshold;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1389 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1390
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1391 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
1392 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1393 #ifdef MMX_FIXME
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1394 FIXME
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1395 int isOk;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1396 asm volatile(
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1397 // "int $3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1398 "movq (%1, %2), %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1399 "movq (%1, %2, 8), %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1400 "movq %%mm0, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1401 "psubusb %%mm1, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1402 "psubusb %%mm2, %%mm1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1403 "por %%mm1, %%mm0 \n\t" // ABS Diff
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1404
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1405 "movq pQPb, %%mm7 \n\t" // QP,..., QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1406 "paddusb %%mm7, %%mm7 \n\t" // 2QP ... 2QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1407 "psubusb %%mm7, %%mm0 \n\t" // Diff <= 2QP -> 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1408 "pcmpeqd b00, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1409 "psrlq $16, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1410 "pcmpeqd bFF, %%mm0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1411 // "movd %%mm0, (%1, %2, 4)\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1412 "movd %%mm0, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1413 : "=r" (isOk)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1414 : "r" (src), "r" (stride)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1415 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1416 return isOk;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1417 #else
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1418 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
1419
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1420 return 1;
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1421 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1422 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1423
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1424 static inline void doHorizDefFilterAndCopyBack(uint8_t dst[], int stride, int QP)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1425 {
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1426 #ifdef HAVE_MMX
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1427 asm volatile(
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1428 "pushl %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1429 "pxor %%mm7, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1430 "movq bm00001000, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1431 "movd %2, %%mm5 \n\t" // QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1432 "movq %%mm5, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1433 "paddusb %%mm5, %%mm5 \n\t" // 2QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1434 "paddusb %%mm5, %%mm4 \n\t" // 3QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1435 "psllq $24, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1436 "pxor %%mm5, %%mm5 \n\t" // 0
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1437 "psubb %%mm4, %%mm5 \n\t" // -QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1438 "leal tempBlock, %%eax \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1439
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1440 //FIXME? "unroll by 2" and mix
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1441 #ifdef HAVE_MMX2
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1442 #define HDF(i) \
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1443 "movq " #i "(%%eax), %%mm0 \n\t"\
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1444 "movq %%mm0, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1445 "movq %%mm0, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1446 "psrlq $8, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1447 "psubusb %%mm1, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1448 "psubusb %%mm0, %%mm1 \n\t"\
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1449 "por %%mm2, %%mm1 \n\t" /* p´x = |px - p(x+1)| */\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1450 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1451 "pshufw $0x00, %%mm1, %%mm3 \n\t" /* p´5 = |p1 - p2| */\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1452 "pminub %%mm1, %%mm3 \n\t" /* p´5 = min(|p2-p1|, |p6-p5|)*/\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1453 "psrlq $16, %%mm3 \n\t" /* p´3 = min(|p2-p1|, |p6-p5|)*/\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1454 "psubusb %%mm3, %%mm1 \n\t" /* |p3-p4|-min(|p1-p2|,|p5-p6|) */\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1455 "paddb %%mm5, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1456 "psubusb %%mm5, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1457 "psrlw $2, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1458 "pxor %%mm2, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1459 "psubb %%mm2, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1460 "pand %%mm6, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1461 "psubb %%mm1, %%mm0 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1462 "psllq $8, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1463 "paddb %%mm1, %%mm0 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1464 "movd %%mm0, (%0) \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1465 "psrlq $32, %%mm0 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1466 "movd %%mm0, 4(%0) \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1467 #else
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1468 #define HDF(i)\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1469 "movq " #i "(%%eax), %%mm0 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1470 "movq %%mm0, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1471 "movq %%mm0, %%mm2 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1472 "psrlq $8, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1473 "psubusb %%mm1, %%mm2 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1474 "psubusb %%mm0, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1475 "por %%mm2, %%mm1 \n\t" /* p´x = |px - p(x+1)| */\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1476 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1477 "movq %%mm1, %%mm3 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1478 "psllq $32, %%mm3 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1479 "movq %%mm3, %%mm4 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1480 "psubusb %%mm1, %%mm4 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1481 "psubb %%mm4, %%mm3 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1482 "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
1483 "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
1484 "paddb %%mm5, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1485 "psubusb %%mm5, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1486 "psrlw $2, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1487 "pxor %%mm2, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1488 "psubb %%mm2, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1489 "pand %%mm6, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1490 "psubb %%mm1, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1491 "psllq $8, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1492 "paddb %%mm1, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1493 "movd %%mm0, (%0) \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1494 "psrlq $32, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1495 "movd %%mm0, 4(%0) \n\t"
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1496 #endif
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1497 HDF(0)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1498 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1499 HDF(8)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1500 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1501 HDF(16)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1502 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1503 HDF(24)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1504 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1505 HDF(32)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1506 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1507 HDF(40)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1508 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1509 HDF(48)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1510 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1511 HDF(56)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1512 "popl %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1513 :
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1514 : "r" (dst), "r" (stride), "r" (QP)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1515 : "%eax"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1516 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1517 #else
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1518 uint8_t *src= tempBlock;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1519
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1520 int y;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1521 for(y=0; y<BLOCK_SIZE; y++)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1522 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1523 dst[0] = src[0];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1524 dst[1] = src[1];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1525 dst[2] = src[2];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1526 dst[3] = src[3];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1527 dst[4] = src[4];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1528 dst[5] = src[5];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1529 dst[6] = src[6];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1530 dst[7] = src[7];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1531
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1532 const int middleEnergy= 5*(src[4] - src[5]) + 2*(src[2] - src[5]);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1533 if(ABS(middleEnergy) < 8*QP)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1534 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1535 const int q=(src[3] - src[4])/2;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1536 const int leftEnergy= 5*(src[2] - src[1]) + 2*(src[0] - src[3]);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1537 const int rightEnergy= 5*(src[6] - src[5]) + 2*(src[4] - src[7]);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1538
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1539 int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1540 d= MAX(d, 0);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1541
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1542 d= (5*d + 32) >> 6;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1543 d*= SIGN(-middleEnergy);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1544
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1545 if(q>0)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1546 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1547 d= d<0 ? 0 : d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1548 d= d>q ? q : d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1549 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1550 else
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1551 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1552 d= d>0 ? 0 : d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1553 d= d<q ? q : d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1554 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1555
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1556 dst[3]-= d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1557 dst[4]+= d;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1558 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1559 dst+= stride;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1560 src+= TEMP_STRIDE;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1561 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1562 #endif
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
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1565 /**
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1566 * Do a horizontal low pass filter on the 8x8 block
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1567 * useing the 9-Tap Filter (1,1,2,2,4,2,2,1,1)/16 (C version)
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1568 * useing approximately the 7-Tap Filter (1,2,3,4,3,2,1)/16 (MMX2/3DNOW version)
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 static inline void doHorizLowPassAndCopyBack(uint8_t dst[], int stride, int QP)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1571 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1572 //return;
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1573 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1574 asm volatile( //"movv %0 %1 %2\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1575 "pushl %0\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1576 "pxor %%mm7, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1577 "leal tempBlock, %%eax \n\t"
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1578 /*
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1579 #define HLP1 "movq (%0), %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1580 "movq %%mm0, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1581 "psllq $8, %%mm0 \n\t"\
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1582 PAVGB(%%mm1, %%mm0)\
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1583 "psrlw $8, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1584 "pxor %%mm1, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1585 "packuswb %%mm1, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1586 "movq %%mm0, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1587 "movq %%mm0, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1588 "psllq $32, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1589 "paddb %%mm0, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1590 "psllq $16, %%mm2 \n\t"\
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1591 PAVGB(%%mm2, %%mm0)\
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1592 "movq %%mm0, %%mm3 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1593 "pand bm11001100, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1594 "paddusb %%mm0, %%mm3 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1595 "psrlq $8, %%mm3 \n\t"\
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1596 PAVGB(%%mm1, %%mm4)\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1597 PAVGB(%%mm3, %%mm2)\
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1598 "psrlq $16, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1599 "punpcklbw %%mm2, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1600 "movq %%mm2, (%0) \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1601
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1602 #define HLP2 "movq (%0), %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1603 "movq %%mm0, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1604 "psllq $8, %%mm0 \n\t"\
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1605 PAVGB(%%mm1, %%mm0)\
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1606 "psrlw $8, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1607 "pxor %%mm1, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1608 "packuswb %%mm1, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1609 "movq %%mm0, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1610 "psllq $32, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1611 "psllq $16, %%mm2 \n\t"\
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1612 PAVGB(%%mm2, %%mm0)\
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1613 "movq %%mm0, %%mm3 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1614 "pand bm11001100, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1615 "paddusb %%mm0, %%mm3 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1616 "psrlq $8, %%mm3 \n\t"\
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1617 PAVGB(%%mm3, %%mm2)\
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1618 "psrlq $16, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1619 "punpcklbw %%mm2, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1620 "movq %%mm2, (%0) \n\t"\
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1621 */
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1622 // 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
1623 /*
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1624 31
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1625 121
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1626 121
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1627 121
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1628 121
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1629 121
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1630 121
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1631 13
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1632 Implemented Exact 7-Tap
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1633 9421 A321
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1634 36421 64321
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1635 334321 =
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1636 1234321 =
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1637 1234321 =
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1638 123433 =
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1639 12463 12346
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1640 1249 123A
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1641
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1642 */
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1643 #ifdef HAVE_MMX2
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1644 #define HLP3(i) "movq " #i "(%%eax), %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1645 "movq %%mm0, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1646 "movq %%mm0, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1647 "movq %%mm0, %%mm3 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1648 "movq %%mm0, %%mm4 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1649 "psllq $8, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1650 "psrlq $8, %%mm2 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1651 "pand bm00000001, %%mm3 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1652 "pand bm10000000, %%mm4 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1653 "por %%mm3, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1654 "por %%mm4, %%mm2 \n\t"\
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1655 PAVGB(%%mm2, %%mm1)\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1656 PAVGB(%%mm1, %%mm0)\
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1657 \
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1658 "pshufw $0xF9, %%mm0, %%mm3 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1659 "pshufw $0x90, %%mm0, %%mm4 \n\t"\
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1660 PAVGB(%%mm3, %%mm4)\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1661 PAVGB(%%mm4, %%mm0)\
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1662 "movd %%mm0, (%0) \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1663 "psrlq $32, %%mm0 \n\t"\
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1664 "movd %%mm0, 4(%0) \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1665 #else
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1666 #define HLP3(i) "movq " #i "(%%eax), %%mm0 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1667 "movq %%mm0, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1668 "movq %%mm0, %%mm2 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1669 "movq %%mm0, %%mm3 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1670 "movq %%mm0, %%mm4 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1671 "psllq $8, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1672 "psrlq $8, %%mm2 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1673 "pand bm00000001, %%mm3 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1674 "pand bm10000000, %%mm4 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1675 "por %%mm3, %%mm1 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1676 "por %%mm4, %%mm2 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1677 PAVGB(%%mm2, %%mm1)\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1678 PAVGB(%%mm1, %%mm0)\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1679 \
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1680 "movq %%mm0, %%mm3 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1681 "movq %%mm0, %%mm4 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1682 "movq %%mm0, %%mm5 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1683 "psrlq $16, %%mm3 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1684 "psllq $16, %%mm4 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1685 "pand bm11000000, %%mm5 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1686 "por %%mm5, %%mm3 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1687 "movq %%mm0, %%mm5 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1688 "pand bm00000011, %%mm5 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1689 "por %%mm5, %%mm4 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1690 PAVGB(%%mm3, %%mm4)\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1691 PAVGB(%%mm4, %%mm0)\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1692 "movd %%mm0, (%0) \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1693 "psrlq $32, %%mm0 \n\t"\
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1694 "movd %%mm0, 4(%0) \n\t"
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1695 #endif
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1696
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1697 #define HLP(i) HLP3(i)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1698
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1699 HLP(0)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1700 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1701 HLP(8)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1702 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1703 HLP(16)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1704 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1705 HLP(24)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1706 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1707 HLP(32)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1708 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1709 HLP(40)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1710 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1711 HLP(48)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1712 "addl %1, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1713 HLP(56)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1714
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1715 "popl %0\n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1716 :
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1717 : "r" (dst), "r" (stride)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1718 : "%eax", "%ebx"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1719 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1720
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1721 #else
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1722 uint8_t *temp= tempBlock;
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1723 int y;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1724 for(y=0; y<BLOCK_SIZE; y++)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1725 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1726 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
1727 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
1728
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1729 int sums[9];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1730 sums[0] = first + temp[0];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1731 sums[1] = temp[0] + temp[1];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1732 sums[2] = temp[1] + temp[2];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1733 sums[3] = temp[2] + temp[3];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1734 sums[4] = temp[3] + temp[4];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1735 sums[5] = temp[4] + temp[5];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1736 sums[6] = temp[5] + temp[6];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1737 sums[7] = temp[6] + temp[7];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1738 sums[8] = temp[7] + last;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1739
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1740 dst[0]= ((sums[0]<<2) + ((first + sums[2])<<1) + sums[4] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1741 dst[1]= ((dst[1]<<2) + (first + sums[0] + sums[3]<<1) + sums[5] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1742 dst[2]= ((dst[2]<<2) + (first + sums[1] + sums[4]<<1) + sums[6] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1743 dst[3]= ((dst[3]<<2) + (sums[2] + sums[5]<<1) + sums[0] + sums[7] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1744 dst[4]= ((dst[4]<<2) + (sums[3] + sums[6]<<1) + sums[1] + sums[8] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1745 dst[5]= ((dst[5]<<2) + (last + sums[7] + sums[4]<<1) + sums[2] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1746 dst[6]= ((last + dst[6]<<2) + (dst[7] + sums[5]<<1) + sums[3] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1747 dst[7]= ((sums[8]<<2) + (last + sums[6]<<1) + sums[4] + 8)>>4;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1748
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1749 dst+= stride;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1750 temp+= TEMP_STRIDE;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1751 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1752 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1753 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1754
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1755
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1756 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
1757 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1758 //FIXME
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1759
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1760 #ifdef HAVE_MMX2X
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1761 asm volatile(
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1762 "leal (%0, %1), %%eax \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1763 "leal (%%eax, %1, 4), %%ebx \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1764 // 0 1 2 3 4 5 6 7 8 9
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1765 // %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
1766
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1767 "pcmpeq %%mm6, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1768 "pxor %%mm7, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1769
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1770 #define FIND_MIN_MAX(addr)\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1771 "movq (" #addr "), %%mm0, \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1772 "pminub %%mm0, %%mm6 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1773 "pmaxub %%mm0, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1774
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1775 FIND_MIN_MAX(%0)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1776 FIND_MIN_MAX(%%eax)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1777 FIND_MIN_MAX(%%eax, %1)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1778 FIND_MIN_MAX(%%eax, %1, 2)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1779 FIND_MIN_MAX(%0, %1, 4)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1780 FIND_MIN_MAX(%%ebx)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1781 FIND_MIN_MAX(%%ebx, %1)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1782 FIND_MIN_MAX(%%ebx, %1, 2)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1783 FIND_MIN_MAX(%0, %1, 8)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1784 FIND_MIN_MAX(%%ebx, %1, 2)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1785
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1786 "movq %%mm6, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1787 "psrlq $32, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1788 "pminub %%mm4, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1789 "movq %%mm6, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1790 "psrlq $16, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1791 "pminub %%mm4, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1792 "movq %%mm6, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1793 "psrlq $8, %%mm6 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1794 "pminub %%mm4, %%mm6 \n\t" // min of pixels
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1795
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1796 "movq %%mm7, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1797 "psrlq $32, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1798 "pmaxub %%mm4, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1799 "movq %%mm7, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1800 "psrlq $16, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1801 "pmaxub %%mm4, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1802 "movq %%mm7, %%mm4 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1803 "psrlq $8, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1804 "pmaxub %%mm4, %%mm7 \n\t" // max of pixels
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1805 PAVGB(%%mm6, %%mm7) // (max + min)/2
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1806
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1807
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1808 : : "r" (src), "r" (stride), "r" (QP)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1809 : "%eax", "%ebx"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1810 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1811 #else
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 //FIXME
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1814 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1815 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1816
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1817
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1818
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1819
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1820 /**
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1821 * ...
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1822 * the mode value is interpreted as a quality value if its negative, its range is then (-1 ... -63)
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1823 * -63 is best quality -1 is worst
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1824 */
2169
a284336bfecf final changes to convert to C
michael
parents: 2168
diff changeset
1825 //extern "C"{
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1826 void postprocess(unsigned char * src[], int src_stride,
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1827 unsigned char * dst[], int dst_stride,
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1828 int horizontal_size, int vertical_size,
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1829 QP_STORE_T *QP_store, int QP_stride,
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1830 int mode)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1831 {
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1832
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1833 if(mode<0) mode= getModeForQuality(-mode);
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1834
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 long long T= rdtsc();
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1837 for(int y=vertical_size-1; y>=0 ; y--)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1838 memcpy(dst[0] + y*src_stride, src[0] + y*src_stride,src_stride);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1839 // memcpy(dst[0], src[0],src_stride*vertical_size);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1840 printf("%4dk\r", (rdtsc()-T)/1000);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1841
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1842 return;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1843 */
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 long long T= rdtsc();
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1846 while( (rdtsc() - T)/1000 < 4000);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1847
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1848 return;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1849 */
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1850 postProcess(src[0], src_stride, dst[0], dst_stride,
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1851 horizontal_size, vertical_size, QP_store, QP_stride, 0, mode);
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1852
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1853 horizontal_size >>= 1;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1854 vertical_size >>= 1;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1855 src_stride >>= 1;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1856 dst_stride >>= 1;
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
1857 mode= ((mode&0xFF)>>4) | (mode&0xFFFFFF00);
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1858
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1859 if(1)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1860 {
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1861 postProcess(src[1], src_stride, dst[1], dst_stride,
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
1862 horizontal_size, vertical_size, QP_store, QP_stride, 1, mode);
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1863 postProcess(src[2], src_stride, dst[2], dst_stride,
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
1864 horizontal_size, vertical_size, QP_store, QP_stride, 1, mode);
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1865 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1866 else
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1867 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1868 memcpy(dst[1], src[1], src_stride*horizontal_size);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1869 memcpy(dst[2], src[2], src_stride*horizontal_size);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1870 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1871 }
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1872 /**
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1873 * gets the mode flags for a given quality (larger values mean slower but better postprocessing)
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1874 * 0 <= quality < 64
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1875 */
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1876 int getModeForQuality(int quality){
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1877 int modes[6]= {
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1878 LUM_V_DEBLOCK,
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1879 LUM_V_DEBLOCK | LUM_H_DEBLOCK,
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1880 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK,
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1881 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK,
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1882 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK | LUM_DERING,
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1883 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK | LUM_DERING | CHROM_DERING
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1884 };
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1885
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1886 return modes[ (quality*6) >>6 ];
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1887 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1888
2169
a284336bfecf final changes to convert to C
michael
parents: 2168
diff changeset
1889 //} // extern "C"
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
1890
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1891 /**
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1892 * 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
1893 * numLines must be a multiple of 4
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1894 * levelFix == 0 -> dont touch the brighness & contrast
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1895 */
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1896 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
1897 int numLines, int levelFix)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1898 {
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1899 int i;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1900 if(levelFix)
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1901 {
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1902 #ifdef HAVE_MMX
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1903 asm volatile(
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1904 "movl %4, %%eax \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1905 "movl %%eax, temp0\n\t"
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1906 "pushl %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1907 "pushl %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1908 "leal (%2,%2), %%eax \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1909 "leal (%3,%3), %%ebx \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1910 "movq packedYOffset, %%mm2 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1911 "movq packedYScale, %%mm3 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1912
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1913 #define SCALED_CPY \
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1914 "movq (%0), %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1915 "movq (%0,%2), %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1916 "psubusb %%mm2, %%mm0 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1917 "psubusb %%mm2, %%mm1 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1918 "pxor %%mm4, %%mm4 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1919 "pxor %%mm5, %%mm5 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1920 "punpcklbw %%mm0, %%mm4 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1921 "punpckhbw %%mm0, %%mm5 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1922 "pmulhuw %%mm3, %%mm4 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1923 "pmulhuw %%mm3, %%mm5 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1924 "packuswb %%mm5, %%mm4 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1925 "movq %%mm4, (%1) \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1926 "pxor %%mm4, %%mm4 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1927 "pxor %%mm5, %%mm5 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1928 "punpcklbw %%mm1, %%mm4 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1929 "punpckhbw %%mm1, %%mm5 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1930 "pmulhuw %%mm3, %%mm4 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1931 "pmulhuw %%mm3, %%mm5 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1932 "packuswb %%mm5, %%mm4 \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1933 "movq %%mm4, (%1, %3) \n\t"\
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1934
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1935 "1: \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1936 SCALED_CPY
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1937 "addl %%eax, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1938 "addl %%ebx, %1 \n\t"
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1939 SCALED_CPY
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1940 "addl %%eax, %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1941 "addl %%ebx, %1 \n\t"
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1942 "decl temp0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1943 "jnz 1b \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1944
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1945 "popl %1 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1946 "popl %0 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1947 : : "r" (src),
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1948 "r" (dst),
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1949 "r" (srcStride),
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1950 "r" (dstStride),
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1951 "m" (numLines>>2)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1952 : "%eax", "%ebx"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1953 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1954 #else
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1955 for(i=0; i<numLines; i++)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1956 memcpy( &(dst[dstStride*i]),
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1957 &(src[srcStride*i]), BLOCK_SIZE);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1958 #endif
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1959 }
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1960 else
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1961 {
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1962 #ifdef HAVE_MMX
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1963 asm volatile(
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1964 "movl %4, %%eax \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1965 "movl %%eax, temp0\n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1966 "pushl %0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1967 "pushl %1 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1968 "leal (%2,%2), %%eax \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1969 "leal (%3,%3), %%ebx \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1970 "movq packedYOffset, %%mm2 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1971 "movq packedYScale, %%mm3 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1972
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1973 #define SIMPLE_CPY \
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1974 "movq (%0), %%mm0 \n\t"\
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1975 "movq (%0,%2), %%mm1 \n\t"\
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1976 "movq %%mm0, (%1) \n\t"\
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1977 "movq %%mm1, (%1, %3) \n\t"\
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1978
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1979 "1: \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1980 SIMPLE_CPY
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1981 "addl %%eax, %0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1982 "addl %%ebx, %1 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1983 SIMPLE_CPY
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1984 "addl %%eax, %0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1985 "addl %%ebx, %1 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1986 "decl temp0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1987 "jnz 1b \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1988
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1989 "popl %1 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1990 "popl %0 \n\t"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1991 : : "r" (src),
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1992 "r" (dst),
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1993 "r" (srcStride),
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1994 "r" (dstStride),
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1995 "m" (numLines>>2)
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1996 : "%eax", "%ebx"
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1997 );
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1998 #else
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
1999 for(i=0; i<numLines; i++)
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2000 memcpy( &(dst[dstStride*i]),
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2001 &(src[srcStride*i]), BLOCK_SIZE);
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2002 #endif
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2003 }
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2004 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2005
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2006
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2007 /**
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2008 * Filters array of bytes (Y or U or V values)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2009 */
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2010 void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2011 QP_STORE_T QPs[], int QPStride, int isColor, int mode)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2012 {
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2013 int x,y;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2014 /* 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
2015 after watching a black picture for 5 hours*/
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2016 static uint64_t *yHistogram= NULL;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2017 int black=0, white=255; // blackest black and whitest white in the picture
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2018
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2019 #ifdef TIMEING
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2020 long long T0, T1, memcpyTime=0, vertTime=0, horizTime=0, sumTime, diffTime=0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2021 sumTime= rdtsc();
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2022 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2023
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2024 if(!yHistogram)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2025 {
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2026 int i;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2027 yHistogram= (uint64_t*)malloc(8*256);
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2028 for(i=0; i<256; i++) yHistogram[i]= width*height/64*15/256;
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2029 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2030
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2031 if(!isColor)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2032 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2033 uint64_t sum= 0;
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2034 int i;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2035 static int framenum= -1;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2036 uint64_t maxClipped;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2037 uint64_t clipped;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2038 double scale;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2039
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2040 framenum++;
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2041 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
2042
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2043 for(i=0; i<256; i++)
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2044 {
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2045 sum+= yHistogram[i];
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2046 // printf("%d ", yHistogram[i]);
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2047 }
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2048 // printf("\n\n");
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2049
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2050 /* we allways get a completly black picture first */
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2051
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2052 maxClipped= (uint64_t)(sum * maxClippedThreshold);
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2053
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2054 clipped= sum;
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2055 for(black=255; black>0; black--)
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 if(clipped < maxClipped) break;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2058 clipped-= yHistogram[black];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2059 }
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 clipped= sum;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2062 for(white=0; white<256; white++)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2063 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2064 if(clipped < maxClipped) break;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2065 clipped-= yHistogram[white];
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2066 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2067
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2068 // we cant handle negative correctures
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2069 packedYOffset= MAX(black - minAllowedY, 0);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2070 packedYOffset|= packedYOffset<<32;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2071 packedYOffset|= packedYOffset<<16;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2072 packedYOffset|= packedYOffset<<8;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2073
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2074 scale= (double)(maxAllowedY - minAllowedY) / (double)(white-black);
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2075
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2076 packedYScale= (uint16_t)(scale*256.0 + 0.5);
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2077 packedYScale|= packedYScale<<32;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2078 packedYScale|= packedYScale<<16;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2079 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2080 else
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2081 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2082 packedYScale= 0x0100010001000100LL;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2083 packedYOffset= 0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2084 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2085
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2086 for(x=0; x<width; x+=BLOCK_SIZE)
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2087 blockCopy(dst + x, dstStride, src + x, srcStride, 8, mode & LEVEL_FIX);
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2088
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2089 for(y=0; y<height; y+=BLOCK_SIZE)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2090 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2091 //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
2092 uint8_t *srcBlock= &(src[y*srcStride]);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2093 uint8_t *dstBlock= &(dst[y*dstStride]);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2094 uint8_t *vertSrcBlock= &(srcBlock[srcStride*3]); // Blocks are 10x8 -> *3 to start
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2095 uint8_t *vertBlock= &(dstBlock[dstStride*3]);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2096
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2097 // 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
2098 // 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
2099 for(x=0; x<width; x+=BLOCK_SIZE)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2100 {
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2101 const int stride= dstStride;
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2102 int QP= isColor ?
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2103 QPs[(y>>3)*QPStride + (x>>3)]:
2180
c76bfc70a28c minor QP scaling & auto-contrast bugfix
michael
parents: 2179
diff changeset
2104 QPs[(y>>4)*QPStride + (x>>4)];
c76bfc70a28c minor QP scaling & auto-contrast bugfix
michael
parents: 2179
diff changeset
2105 if(!isColor && (mode & LEVEL_FIX)) QP= (QP* (packedYScale &0xFFFF))>>8;
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2106 #ifdef HAVE_MMX
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2107 asm volatile(
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2108 "movd %0, %%mm7 \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2109 "packuswb %%mm7, %%mm7 \n\t" // 0, 0, 0, QP, 0, 0, 0, QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2110 "packuswb %%mm7, %%mm7 \n\t" // 0,QP, 0, QP, 0,QP, 0, QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2111 "packuswb %%mm7, %%mm7 \n\t" // QP,..., QP
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2112 "movq %%mm7, pQPb \n\t"
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2113 : : "r" (QP)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2114 );
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2115 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2116
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2117
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2118 if(y + 12 < height)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2119 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2120 #ifdef MORE_TIMEING
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2121 T0= rdtsc();
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2122 #endif
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2123
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2124 #ifdef HAVE_MMX2
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2125 prefetchnta(vertSrcBlock + (((x>>3)&3) + 2)*srcStride + 32);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2126 prefetchnta(vertSrcBlock + (((x>>3)&3) + 6)*srcStride + 32);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2127 prefetcht0(vertBlock + (((x>>3)&3) + 2)*dstStride + 32);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2128 prefetcht0(vertBlock + (((x>>3)&3) + 6)*dstStride + 32);
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2129 #elif defined(HAVE_3DNOW)
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2130 //FIXME check if this is faster on an 3dnow chip or if its faster without the prefetch or ...
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2131 /* prefetch(vertSrcBlock + (((x>>3)&3) + 2)*srcStride + 32);
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2132 prefetch(vertSrcBlock + (((x>>3)&3) + 6)*srcStride + 32);
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2133 prefetchw(vertBlock + (((x>>3)&3) + 2)*dstStride + 32);
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2134 prefetchw(vertBlock + (((x>>3)&3) + 6)*dstStride + 32);
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2135 */
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2136 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2137 if(!isColor) yHistogram[ srcBlock[0] ]++;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2138
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2139 blockCopy(vertBlock + dstStride*2, dstStride,
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2140 vertSrcBlock + srcStride*2, srcStride, 8, mode & LEVEL_FIX);
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2141
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2142
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2143 #ifdef MORE_TIMEING
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2144 T1= rdtsc();
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2145 memcpyTime+= T1-T0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2146 T0=T1;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2147 #endif
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2148 if(mode & V_DEBLOCK)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2149 {
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2150 if(mode & V_RK1_FILTER)
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2151 vertRK1Filter(vertBlock, stride, QP);
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2152 else if(mode & V_X1_FILTER)
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2153 vertX1Filter(vertBlock, stride, QP);
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2154 else
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2155 {
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2156 if( isVertDC(vertBlock, stride))
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2157 {
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2158 if(isVertMinMaxOk(vertBlock, stride, QP))
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2159 doVertLowPass(vertBlock, stride, QP);
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2160 }
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2161 else
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2162 doVertDefFilter(vertBlock, stride, QP);
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2163 }
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2164 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2165 #ifdef MORE_TIMEING
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2166 T1= rdtsc();
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2167 vertTime+= T1-T0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2168 T0=T1;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2169 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2170 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2171 else
2168
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2172 blockCopy(vertBlock + dstStride*1, dstStride,
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2173 vertSrcBlock + srcStride*1, srcStride, 4, mode & LEVEL_FIX);
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2174
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2175
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2176 if(x - 8 >= 0 && x<width)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2177 {
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2178 #ifdef MORE_TIMEING
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2179 T0= rdtsc();
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2180 #endif
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2181 if(mode & H_DEBLOCK)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2182 {
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2183 if(mode & H_X1_FILTER)
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2184 horizX1Filter(dstBlock-4, stride, QP);
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2185 else
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2186 {
2179
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2187 if( isHorizDCAndCopy2Temp(dstBlock-4, stride))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2188 {
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2189 if(isHorizMinMaxOk(tempBlock, TEMP_STRIDE, QP))
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2190 doHorizLowPassAndCopyBack(dstBlock-4, stride, QP);
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2191 }
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2192 else
2d8d14b882cc fixed a rounding bug thing in the X1 Filter
michael
parents: 2169
diff changeset
2193 doHorizDefFilterAndCopyBack(dstBlock-4, stride, QP);
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2194 }
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2195 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2196 #ifdef MORE_TIMEING
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2197 T1= rdtsc();
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2198 horizTime+= T1-T0;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2199 T0=T1;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2200 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2201 dering(dstBlock - 9 - stride, stride, QP);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2202 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2203 else if(y!=0)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2204 dering(dstBlock - stride*9 + width-9, stride, QP);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2205 //FIXME dering filter will not be applied to last block (bottom right)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2206
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2207
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2208 dstBlock+=8;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2209 srcBlock+=8;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2210 vertBlock+=8;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2211 vertSrcBlock+=8;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2212 }
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2213 }
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2214 #ifdef HAVE_3DNOW
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2215 asm volatile("femms");
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2216 #elif defined (HAVE_MMX)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2217 asm volatile("emms");
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2218 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2219
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2220 #ifdef TIMEING
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2221 // 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
2222 sumTime= rdtsc() - sumTime;
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2223 if(!isColor)
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2224 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
2225 (int)(memcpyTime/1000), (int)(vertTime/1000), (int)(horizTime/1000),
21a8f158d19f bugfixes: last 3 lines not brightness/contrast corrected
michael
parents: 2159
diff changeset
2226 (int)(sumTime/1000), (int)((sumTime-memcpyTime-vertTime-horizTime)/1000)
2158
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2227 , black, white);
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2228 #endif
508468a75be0 new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2229 }
2159
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2230
795f3d022657 fixed a bug in the horizontal default filter
arpi
parents: 2158
diff changeset
2231