annotate libpostproc/postprocess_template.c @ 96:29ac11dc53d3 libavcodec

fixed a bug in the horizontal default filter 3dnow version of the Horizontal & Vertical Lowpass filters mmx version of the Horizontal Default filter mmx2 & C versions of a simple filter described in a paper from ramkishor & karan added mode flags & quality2mode function
author arpi
date Wed, 10 Oct 2001 22:21:19 +0000
parents 8bce253b537c
children e57b1d38d71f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1 /*
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
2 Copyright (C) 2001 Michael Niedermayer (michaelni@gmx.at)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
3
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
6 the Free Software Foundation; either version 2 of the License, or
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
7 (at your option) any later version.
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
8
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
12 GNU General Public License for more details.
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
13
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
15 along with this program; if not, write to the Free Software
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
17 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
18
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
19 /*
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
20 C MMX MMX2 3DNow*
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
21 isVertDC Ec Ec
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
22 isVertMinMaxOk Ec Ec
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
23 doVertLowPass E e e*
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
24 doVertDefFilter Ec Ec Ec
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
25 isHorizDC Ec Ec
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
26 isHorizMinMaxOk a
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
27 doHorizLowPass E a a*
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
28 doHorizDefFilter E ac ac
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
29 deRing
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
30
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
31 * i dont have a 3dnow CPU -> its untested
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
32 E = Exact implementation
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
33 e = allmost exact implementation
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
34 a = alternative / approximate impl
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
35 c = checked against the other implementations (-vo md5)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
36 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
37
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
38 /*
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
39 TODO:
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
40 verify that everything workes as it should
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
41 reduce the time wasted on the mem transfer
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
42 implement dering
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
43 implement everything in C at least (done at the moment but ...)
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
44 figure range of QP out (assuming <256 for now)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
45 unroll stuff if instructions depend too much on the prior one
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
46 we use 8x8 blocks for the horizontal filters, opendivx seems to use 8x4?
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
47 move YScale thing to the end instead of fixing QP
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
48 write a faster and higher quality deblocking filter :)
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
49 ...
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
50
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
51 Notes:
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
52
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
53 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
54
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
55 /*
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
56 Changelog:
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
57 0.1.2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
58 fixed a bug in the horizontal default filter
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
59 3dnow version of the Horizontal & Vertical Lowpass filters
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
60 mmx version of the Horizontal Default filter
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
61 mmx2 & C versions of a simple filter described in a paper from ramkishor & karandikar
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
62 added mode flags & quality2mode function
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
63 0.1.1
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
64 */
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
65
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
66
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
67 #include <inttypes.h>
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
68 #include <stdio.h>
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
69 #include "../config.h"
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
70 //#undef HAVE_MMX2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
71 //#define HAVE_3DNOW
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
72 //#undef HAVE_MMX
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
73 #include "postprocess.h"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
74
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
75
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
76 static uint64_t packedYOffset= 0x0000000000000000LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
77 static uint64_t packedYScale= 0x0100010001000100LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
78 static uint64_t w05= 0x0005000500050005LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
79 static uint64_t w20= 0x0020002000200020LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
80 static uint64_t w1400= 0x1400140014001400LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
81 static uint64_t bm00000001= 0x00000000000000FFLL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
82 static uint64_t bm00010000= 0x000000FF00000000LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
83 static uint64_t bm00001000= 0x00000000FF000000LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
84 static uint64_t bm10000000= 0xFF00000000000000LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
85 static uint64_t bm10000001= 0xFF000000000000FFLL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
86 static uint64_t bm11000011= 0xFFFF00000000FFFFLL;
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
87 static uint64_t bm00000011= 0x000000000000FFFFLL;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
88 static uint64_t bm11000000= 0xFFFF000000000000LL;
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
89 static uint64_t bm00011000= 0x000000FFFF000000LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
90 static uint64_t bm00110011= 0x0000FFFF0000FFFFLL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
91 static uint64_t bm11001100= 0xFFFF0000FFFF0000LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
92 static uint64_t b00= 0x0000000000000000LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
93 static uint64_t b02= 0x0202020202020202LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
94 static uint64_t b0F= 0x0F0F0F0F0F0F0F0FLL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
95 static uint64_t bFF= 0xFFFFFFFFFFFFFFFFLL;
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
96 static uint64_t b20= 0x2020202020202020LL;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
97 static uint64_t b80= 0x8080808080808080LL;
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
98 static uint64_t b7E= 0x7E7E7E7E7E7E7E7ELL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
99 static uint64_t b7C= 0x7C7C7C7C7C7C7C7CLL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
100 static uint64_t b3F= 0x3F3F3F3F3F3F3F3FLL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
101 static uint64_t temp0=0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
102 static uint64_t temp1=0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
103 static uint64_t temp2=0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
104 static uint64_t temp3=0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
105 static uint64_t temp4=0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
106 static uint64_t temp5=0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
107 static uint64_t pQPb=0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
108 static uint8_t tempBlock[16*16];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
109
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
110 int hFlatnessThreshold= 56 - 16;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
111 int vFlatnessThreshold= 56 - 16;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
112
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
113 //amount of "black" u r willing to loose to get a brightness corrected picture
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
114 double maxClippedThreshold= 0.01;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
115
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
116 int maxAllowedY=255;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
117 //FIXME can never make a movie´s black brighter (anyone needs that?)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
118 int minAllowedY=0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
119
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
120
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
121 static inline long long rdtsc()
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
122 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
123 long long l;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
124 asm volatile( "rdtsc\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
125 : "=A" (l)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
126 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
127 // printf("%d\n", int(l/1000));
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
128 return l;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
129 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
130
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
131 static inline void prefetchnta(void *p)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
132 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
133 asm volatile( "prefetchnta (%0)\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
134 : : "r" (p)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
135 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
136 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
137
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
138 static inline void prefetcht0(void *p)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
139 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
140 asm volatile( "prefetcht0 (%0)\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
141 : : "r" (p)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
142 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
143 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
144
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
145 static inline void prefetcht1(void *p)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
146 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
147 asm volatile( "prefetcht1 (%0)\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
148 : : "r" (p)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
149 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
150 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
151
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
152 static inline void prefetcht2(void *p)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
153 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
154 asm volatile( "prefetcht2 (%0)\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
155 : : "r" (p)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
156 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
157 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
158
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
159 //FIXME? |255-0| = 1 (shouldnt be a problem ...)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
160 /**
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
161 * Check if the middle 8x8 Block in the given 8x10 block is flat
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
162 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
163 static inline bool isVertDC(uint8_t src[], int stride){
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
164 // return true;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
165 int numEq= 0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
166 src+= stride; // src points to begin of the 8x8 Block
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
167 #ifdef HAVE_MMX
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
168 asm volatile(
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
169 // "int $3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
170 "pushl %1\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
171 "movq b7E, %%mm7 \n\t" // mm7 = 0x7F
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
172 "movq b7C, %%mm6 \n\t" // mm6 = 0x7D
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
173 "movq (%1), %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
174 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
175 "movq (%1), %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
176 "psubb %%mm1, %%mm0 \n\t" // mm0 = differnece
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
177 "paddb %%mm7, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
178 "pcmpgtb %%mm6, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
179
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
180 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
181 "movq (%1), %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
182 "psubb %%mm2, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
183 "paddb %%mm7, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
184 "pcmpgtb %%mm6, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
185 "paddb %%mm1, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
186
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
187 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
188 "movq (%1), %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
189 "psubb %%mm1, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
190 "paddb %%mm7, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
191 "pcmpgtb %%mm6, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
192 "paddb %%mm2, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
193
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
194 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
195 "movq (%1), %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
196 "psubb %%mm2, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
197 "paddb %%mm7, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
198 "pcmpgtb %%mm6, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
199 "paddb %%mm1, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
200
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
201 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
202 "movq (%1), %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
203 "psubb %%mm1, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
204 "paddb %%mm7, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
205 "pcmpgtb %%mm6, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
206 "paddb %%mm2, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
207
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
208 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
209 "movq (%1), %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
210 "psubb %%mm2, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
211 "paddb %%mm7, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
212 "pcmpgtb %%mm6, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
213 "paddb %%mm1, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
214
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
215 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
216 "movq (%1), %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
217 "psubb %%mm1, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
218 "paddb %%mm7, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
219 "pcmpgtb %%mm6, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
220 "paddb %%mm2, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
221
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
222 " \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
223 "movq %%mm0, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
224 "psrlw $8, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
225 "paddb %%mm1, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
226 "movq %%mm0, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
227 "psrlq $16, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
228 "paddb %%mm1, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
229 "movq %%mm0, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
230 "psrlq $32, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
231 "paddb %%mm1, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
232 "popl %1\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
233 "movd %%mm0, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
234 : "=r" (numEq)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
235 : "r" (src), "r" (stride)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
236 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
237 // printf("%d\n", numEq);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
238 numEq= (256 - (numEq & 0xFF)) &0xFF;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
239
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
240 // int asmEq= numEq;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
241 // numEq=0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
242 // uint8_t *temp= src;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
243
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
244 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
245 for(int y=0; y<BLOCK_SIZE-1; y++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
246 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
247 if(((src[0] - src[0+stride] + 1)&0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
248 if(((src[1] - src[1+stride] + 1)&0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
249 if(((src[2] - src[2+stride] + 1)&0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
250 if(((src[3] - src[3+stride] + 1)&0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
251 if(((src[4] - src[4+stride] + 1)&0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
252 if(((src[5] - src[5+stride] + 1)&0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
253 if(((src[6] - src[6+stride] + 1)&0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
254 if(((src[7] - src[7+stride] + 1)&0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
255 src+= stride;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
256 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
257 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
258 /* if(abs(numEq - asmEq) > 0)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
259 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
260 printf("\nasm:%d c:%d\n", asmEq, numEq);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
261 for(int y=0; y<8; y++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
262 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
263 for(int x=0; x<8; x++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
264 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
265 printf("%d ", temp[x + y*stride]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
266 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
267 printf("\n");
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
268 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
269 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
270 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
271 return numEq > vFlatnessThreshold;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
272 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
273
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
274 static inline bool isVertMinMaxOk(uint8_t src[], int stride, int QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
275 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
276 #ifdef HAVE_MMX
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
277 int isOk;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
278 asm volatile(
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
279 // "int $3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
280 "movq (%1, %2), %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
281 "movq (%1, %2, 8), %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
282 "movq %%mm0, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
283 "psubusb %%mm1, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
284 "psubusb %%mm2, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
285 "por %%mm1, %%mm0 \n\t" // ABS Diff
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
286
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
287 "movq pQPb, %%mm7 \n\t" // QP,..., QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
288 "paddusb %%mm7, %%mm7 \n\t" // 2QP ... 2QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
289 "psubusb %%mm7, %%mm0 \n\t" // Diff <= 2QP -> 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
290 "pcmpeqd b00, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
291 "psrlq $16, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
292 "pcmpeqd bFF, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
293 // "movd %%mm0, (%1, %2, 4)\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
294 "movd %%mm0, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
295 : "=r" (isOk)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
296 : "r" (src), "r" (stride)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
297 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
298 return isOk;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
299 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
300
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
301 int isOk2= true;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
302 for(int x=0; x<BLOCK_SIZE; x++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
303 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
304 if(abs((int)src[x + stride] - (int)src[x + (stride<<3)]) > 2*QP) isOk2=false;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
305 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
306 /* if(isOk && !isOk2 || !isOk && isOk2)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
307 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
308 printf("\nasm:%d c:%d QP:%d\n", isOk, isOk2, QP);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
309 for(int y=0; y<9; y++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
310 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
311 for(int x=0; x<8; x++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
312 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
313 printf("%d ", src[x + y*stride]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
314 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
315 printf("\n");
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
316 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
317 } */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
318
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
319 return isOk2;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
320 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
321
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
322 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
323
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
324 /**
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
325 * Do a vertical low pass filter on the 8x10 block (only write to the 8x8 block in the middle)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
326 * useing the 9-Tap Filter (1,1,2,2,4,2,2,1,1)/16
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
327 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
328 static inline void doVertLowPass(uint8_t *src, int stride, int QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
329 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
330 // QP= 64;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
331
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
332 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
333 //#ifdef HAVE_MMX2
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
334 asm volatile( //"movv %0 %1 %2\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
335 "pushl %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
336 "movq pQPb, %%mm0 \n\t" // QP,..., QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
337 // "movq bFF , %%mm0 \n\t" // QP,..., QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
338
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
339 "movq (%0), %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
340 "movq (%0, %1), %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
341 "movq %%mm5, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
342 "movq %%mm6, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
343 "psubusb %%mm6, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
344 "psubusb %%mm1, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
345 "por %%mm5, %%mm2 \n\t" // ABS Diff of lines
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
346 "psubusb %%mm0, %%mm2 \n\t" // diff <= QP -> 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
347 "pcmpeqb b00, %%mm2 \n\t" // diff <= QP -> FF
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
348
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
349 "pand %%mm2, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
350 "pandn %%mm1, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
351 "por %%mm2, %%mm6 \n\t"// First Line to Filter
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
352
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
353 "movq (%0, %1, 8), %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
354 "leal (%0, %1, 4), %%eax \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
355 "leal (%0, %1, 8), %%ebx \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
356 "subl %1, %%ebx \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
357 "addl %1, %0 \n\t" // %0 points to line 1 not 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
358 "movq (%0, %1, 8), %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
359 "movq %%mm5, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
360 "movq %%mm7, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
361 "psubusb %%mm7, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
362 "psubusb %%mm1, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
363 "por %%mm5, %%mm2 \n\t" // ABS Diff of lines
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
364 "psubusb %%mm0, %%mm2 \n\t" // diff <= QP -> 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
365 "pcmpeqb b00, %%mm2 \n\t" // diff <= QP -> FF
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
366
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
367 "pand %%mm2, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
368 "pandn %%mm1, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
369 "por %%mm2, %%mm7 \n\t" // First Line to Filter
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
370
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
371
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
372 // 1 2 3 4 5 6 7 8
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
373 // %0 %0+%1 %0+2%1 eax %0+4%1 eax+2%1 ebx eax+4%1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
374 // 6 4 2 2 1 1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
375 // 6 4 4 2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
376 // 6 8 2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
377 /*
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
378 "movq %%mm6, %%mm2 \n\t" //1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
379 "movq %%mm6, %%mm3 \n\t" //1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
380 "paddusb b02, %%mm3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
381 "psrlw $2, %%mm3 \n\t" //1 /4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
382 "pand b3F, %%mm3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
383 "psubb %%mm3, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
384 "movq (%0, %1), %%mm0 \n\t" // 1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
385 "movq %%mm0, %%mm1 \n\t" // 1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
386 "paddusb b02, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
387 "psrlw $2, %%mm0 \n\t" // 1 /4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
388 "pand b3F, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
389 "paddusb %%mm2, %%mm0 \n\t" //3 1 /4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
390 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
391 "movq (%0, %1), %%mm0 \n\t" // 1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
392 "movq %%mm0, %%mm1 \n\t" // 1
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
393 PAVGB(%%mm6, %%mm0) //1 1 /2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
394 PAVGB(%%mm6, %%mm0) //3 1 /4
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
395
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
396 "movq (%0, %1, 4), %%mm2 \n\t" // 1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
397 "movq %%mm2, %%mm5 \n\t" // 1
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
398 PAVGB((%%eax), %%mm2) // 11 /2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
399 PAVGB((%0, %1, 2), %%mm2) // 211 /4
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
400 "movq %%mm2, %%mm3 \n\t" // 211 /4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
401 "movq (%0), %%mm4 \n\t" // 1
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
402 PAVGB(%%mm4, %%mm3) // 4 211 /8
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
403 PAVGB(%%mm0, %%mm3) //642211 /16
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
404 "movq %%mm3, (%0) \n\t" // X
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
405 // mm1=2 mm2=3(211) mm4=1 mm5=5 mm6=0 mm7=9
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
406 "movq %%mm1, %%mm0 \n\t" // 1
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
407 PAVGB(%%mm6, %%mm0) //1 1 /2
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
408 "movq %%mm4, %%mm3 \n\t" // 1
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
409 PAVGB((%0,%1,2), %%mm3) // 1 1 /2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
410 PAVGB((%%eax,%1,2), %%mm5) // 11 /2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
411 PAVGB((%%eax), %%mm5) // 211 /4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
412 PAVGB(%%mm5, %%mm3) // 2 2211 /8
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
413 PAVGB(%%mm0, %%mm3) //4242211 /16
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
414 "movq %%mm3, (%0,%1) \n\t" // X
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
415 // mm1=2 mm2=3(211) mm4=1 mm5=4(211) mm6=0 mm7=9
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
416 PAVGB(%%mm4, %%mm6) //11 /2
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
417 "movq (%%ebx), %%mm0 \n\t" // 1
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
418 PAVGB((%%eax, %1, 2), %%mm0) // 11/2
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
419 "movq %%mm0, %%mm3 \n\t" // 11/2
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
420 PAVGB(%%mm1, %%mm0) // 2 11/4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
421 PAVGB(%%mm6, %%mm0) //222 11/8
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
422 PAVGB(%%mm2, %%mm0) //22242211/16
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
423 "movq (%0, %1, 2), %%mm2 \n\t" // 1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
424 "movq %%mm0, (%0, %1, 2) \n\t" // X
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
425 // mm1=2 mm2=3 mm3=6(11) mm4=1 mm5=4(211) mm6=0(11) mm7=9
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
426 "movq (%%eax, %1, 4), %%mm0 \n\t" // 1
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
427 PAVGB((%%ebx), %%mm0) // 11 /2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
428 PAVGB(%%mm0, %%mm6) //11 11 /4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
429 PAVGB(%%mm1, %%mm4) // 11 /2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
430 PAVGB(%%mm2, %%mm1) // 11 /2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
431 PAVGB(%%mm1, %%mm6) //1122 11 /8
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
432 PAVGB(%%mm5, %%mm6) //112242211 /16
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
433 "movq (%%eax), %%mm5 \n\t" // 1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
434 "movq %%mm6, (%%eax) \n\t" // X
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
435 // mm0=7(11) mm1=2(11) mm2=3 mm3=6(11) mm4=1(11) mm5=4 mm7=9
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
436 "movq (%%eax, %1, 4), %%mm6 \n\t" // 1
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
437 PAVGB(%%mm7, %%mm6) // 11 /2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
438 PAVGB(%%mm4, %%mm6) // 11 11 /4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
439 PAVGB(%%mm3, %%mm6) // 11 2211 /8
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
440 PAVGB(%%mm5, %%mm2) // 11 /2
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
441 "movq (%0, %1, 4), %%mm4 \n\t" // 1
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
442 PAVGB(%%mm4, %%mm2) // 112 /4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
443 PAVGB(%%mm2, %%mm6) // 112242211 /16
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
444 "movq %%mm6, (%0, %1, 4) \n\t" // X
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
445 // mm0=7(11) mm1=2(11) mm2=3(112) mm3=6(11) mm4=5 mm5=4 mm7=9
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
446 PAVGB(%%mm7, %%mm1) // 11 2 /4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
447 PAVGB(%%mm4, %%mm5) // 11 /2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
448 PAVGB(%%mm5, %%mm0) // 11 11 /4
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
449 "movq (%%eax, %1, 2), %%mm6 \n\t" // 1
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
450 PAVGB(%%mm6, %%mm1) // 11 4 2 /8
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
451 PAVGB(%%mm0, %%mm1) // 11224222 /16
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
452 // "pxor %%mm1, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
453 "movq %%mm1, (%%eax, %1, 2) \n\t" // X
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
454 // mm2=3(112) mm3=6(11) mm4=5 mm5=4(11) mm6=6 mm7=9
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
455 PAVGB((%%ebx), %%mm2) // 112 4 /8
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
456 "movq (%%eax, %1, 4), %%mm0 \n\t" // 1
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
457 PAVGB(%%mm0, %%mm6) // 1 1 /2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
458 PAVGB(%%mm7, %%mm6) // 1 12 /4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
459 PAVGB(%%mm2, %%mm6) // 1122424 /4
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
460 // "pxor %%mm6, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
461 "movq %%mm6, (%%ebx) \n\t" // X
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
462 // mm0=8 mm3=6(11) mm4=5 mm5=4(11) mm7=9
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
463 PAVGB(%%mm7, %%mm5) // 11 2 /4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
464 PAVGB(%%mm7, %%mm5) // 11 6 /8
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
465
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
466 PAVGB(%%mm3, %%mm0) // 112 /4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
467 PAVGB(%%mm0, %%mm5) // 112246 /16
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
468 // "pxor %%mm5, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
469 // "movq pQPb, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
470 "movq %%mm5, (%%eax, %1, 4) \n\t" // X
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
471 "popl %0\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
472
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
473 :
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
474 : "r" (src), "r" (stride)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
475 : "%eax", "%ebx"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
476 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
477 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
478 const int l1= stride;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
479 const int l2= stride + l1;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
480 const int l3= stride + l2;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
481 const int l4= stride + l3;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
482 const int l5= stride + l4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
483 const int l6= stride + l5;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
484 const int l7= stride + l6;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
485 const int l8= stride + l7;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
486 const int l9= stride + l8;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
487
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
488 for(int x=0; x<BLOCK_SIZE; x++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
489 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
490 const int first= ABS(src[0] - src[l1]) < QP ? src[0] : src[l1];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
491 const int last= ABS(src[l8] - src[l9]) < QP ? src[l9] : src[l8];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
492
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
493 int sums[9];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
494 sums[0] = first + src[l1];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
495 sums[1] = src[l1] + src[l2];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
496 sums[2] = src[l2] + src[l3];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
497 sums[3] = src[l3] + src[l4];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
498 sums[4] = src[l4] + src[l5];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
499 sums[5] = src[l5] + src[l6];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
500 sums[6] = src[l6] + src[l7];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
501 sums[7] = src[l7] + src[l8];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
502 sums[8] = src[l8] + last;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
503
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
504 src[l1]= ((sums[0]<<2) + ((first + sums[2])<<1) + sums[4] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
505 src[l2]= ((src[l2]<<2) + (first + sums[0] + sums[3]<<1) + sums[5] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
506 src[l3]= ((src[l3]<<2) + (first + sums[1] + sums[4]<<1) + sums[6] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
507 src[l4]= ((src[l4]<<2) + (sums[2] + sums[5]<<1) + sums[0] + sums[7] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
508 src[l5]= ((src[l5]<<2) + (sums[3] + sums[6]<<1) + sums[1] + sums[8] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
509 src[l6]= ((src[l6]<<2) + (last + sums[7] + sums[4]<<1) + sums[2] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
510 src[l7]= ((last + src[l7]<<2) + (src[l8] + sums[5]<<1) + sums[3] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
511 src[l8]= ((sums[8]<<2) + (last + sums[6]<<1) + sums[4] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
512
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
513 src++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
514 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
515
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
516 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
517 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
518
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
519 /**
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
520 * Experimental implementation of the filter (Algorithm 1) described in a paper from Ramkishor & Karandikar
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
521 * values are correctly clipped (MMX2)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
522 * values are wraparound (C)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
523 * conclusion: its fast, but introduces ugly horizontal patterns if there is a continious gradient
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
524 0 8 16 24
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
525 x = 8
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
526 x/2 = 4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
527 x/8 = 1
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
528 1 12 12 23
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
529 */
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
530 static inline void vertRKFilter(uint8_t *src, int stride, int QP)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
531 {
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
532 #ifdef HAVE_MMX2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
533 // FIXME rounding
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
534 asm volatile(
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
535 "pxor %%mm7, %%mm7 \n\t" // 0
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
536 "movq b80, %%mm6 \n\t" // MIN_SIGNED_BYTE
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
537 "leal (%0, %1), %%eax \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
538 "leal (%%eax, %1, 4), %%ebx \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
539 // 0 1 2 3 4 5 6 7 8 9
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
540 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
541 "movq pQPb, %%mm0 \n\t" // QP,..., QP
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
542 "movq %%mm0, %%mm1 \n\t" // QP,..., QP
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
543 "paddusb b02, %%mm0 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
544 "psrlw $2, %%mm0 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
545 "pand b3F, %%mm0 \n\t" // QP/4,..., QP/4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
546 "paddusb %%mm1, %%mm0 \n\t" // QP*1.25 ...
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
547 "movq (%0, %1, 4), %%mm2 \n\t" // line 4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
548 "movq (%%ebx), %%mm3 \n\t" // line 5
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
549 "movq %%mm2, %%mm4 \n\t" // line 4
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
550 "pcmpeqb %%mm5, %%mm5 \n\t" // -1
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
551 "pxor %%mm2, %%mm5 \n\t" // -line 4 - 1
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
552 "pavgb %%mm3, %%mm5 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
553 "paddb %%mm6, %%mm5 \n\t" // (l5-l4)/2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
554 "psubusb %%mm3, %%mm4 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
555 "psubusb %%mm2, %%mm3 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
556 "por %%mm3, %%mm4 \n\t" // |l4 - l5|
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
557 "psubusb %%mm0, %%mm4 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
558 "pcmpeqb %%mm7, %%mm4 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
559 "pand %%mm4, %%mm5 \n\t" // d/2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
560
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
561 // "paddb %%mm6, %%mm2 \n\t" // line 4 + 0x80
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
562 "paddb %%mm5, %%mm2 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
563 // "psubb %%mm6, %%mm2 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
564 "movq %%mm2, (%0,%1, 4) \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
565
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
566 "movq (%%ebx), %%mm2 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
567 // "paddb %%mm6, %%mm2 \n\t" // line 5 + 0x80
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
568 "psubb %%mm5, %%mm2 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
569 // "psubb %%mm6, %%mm2 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
570 "movq %%mm2, (%%ebx) \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
571
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
572 "paddb %%mm6, %%mm5 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
573 "psrlw $2, %%mm5 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
574 "pand b3F, %%mm5 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
575 "psubb b20, %%mm5 \n\t" // (l5-l4)/8
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
576
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
577 "movq (%%eax, %1, 2), %%mm2 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
578 "paddb %%mm6, %%mm2 \n\t" // line 3 + 0x80
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
579 "paddsb %%mm5, %%mm2 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
580 "psubb %%mm6, %%mm2 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
581 "movq %%mm2, (%%eax, %1, 2) \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
582
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
583 "movq (%%ebx, %1), %%mm2 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
584 "paddb %%mm6, %%mm2 \n\t" // line 6 + 0x80
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
585 "psubsb %%mm5, %%mm2 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
586 "psubb %%mm6, %%mm2 \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
587 "movq %%mm2, (%%ebx, %1) \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
588
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
589 :
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
590 : "r" (src), "r" (stride)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
591 : "%eax", "%ebx"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
592 );
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
593 #else
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
594 const int l1= stride;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
595 const int l2= stride + l1;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
596 const int l3= stride + l2;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
597 const int l4= stride + l3;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
598 const int l5= stride + l4;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
599 const int l6= stride + l5;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
600 const int l7= stride + l6;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
601 const int l8= stride + l7;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
602 const int l9= stride + l8;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
603 for(int x=0; x<BLOCK_SIZE; x++)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
604 {
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
605 if(ABS(src[l4]-src[l5]) < QP + QP/4)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
606 {
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
607 int x = src[l5] - src[l4];
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
608
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
609 src[l3] +=x/8;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
610 src[l4] +=x/2;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
611 src[l5] -=x/2;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
612 src[l6] -=x/8;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
613 }
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
614 src++;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
615 }
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
616
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
617 #endif
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
618 }
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
619
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
620 /**
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
621 * Experimental Filter 1
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
622 */
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
623 static inline void vertX1Filter(uint8_t *src, int stride, int QP)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
624 {
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
625 #ifdef HAVE_MMX2X
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
626 // FIXME
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
627 asm volatile(
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
628
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
629 :
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
630 : "r" (src), "r" (stride)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
631 : "%eax", "%ebx"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
632 );
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
633 #else
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
634 const int l1= stride;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
635 const int l2= stride + l1;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
636 const int l3= stride + l2;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
637 const int l4= stride + l3;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
638 const int l5= stride + l4;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
639 const int l6= stride + l5;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
640 const int l7= stride + l6;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
641 const int l8= stride + l7;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
642 const int l9= stride + l8;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
643 for(int x=0; x<BLOCK_SIZE; x++)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
644 {
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
645 int v2= src[l2];
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
646 int v3= src[l3];
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
647 int v4= src[l4];
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
648 int v5= src[l5];
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
649 int v6= src[l6];
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
650 int v7= src[l7];
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
651
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
652 if(ABS(v4-v5)<QP && ABS(v4-v5) - (ABS(v3-v4) + ABS(v5-v6))>0 )
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
653 {
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
654 src[l3] = (6*v2 + 4*v3 + 3*v4 + 2*v5 + v6 )/16;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
655 src[l4] = (3*v2 + 3*v3 + 4*v4 + 3*v5 + 2*v6 + v7 )/16;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
656 src[l5] = (1*v2 + 2*v3 + 3*v4 + 4*v5 + 3*v6 + 3*v7)/16;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
657 src[l6] = ( 1*v3 + 2*v4 + 3*v5 + 4*v6 + 6*v7)/16;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
658 }
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
659 src++;
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
660 }
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
661
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
662 #endif
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
663 }
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
664
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
665
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
666 static inline void doVertDefFilter(uint8_t src[], int stride, int QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
667 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
668 #ifdef HAVE_MMX
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
669 src+= stride;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
670 //FIXME try pmul for *5 stuff
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
671 // src[0]=0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
672 asm volatile(
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
673 "pxor %%mm7, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
674 "leal (%0, %1), %%eax \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
675 "leal (%%eax, %1, 4), %%ebx \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
676 // 0 1 2 3 4 5 6 7
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
677 // %0 %0+%1 %0+2%1 eax+2%1 %0+4%1 eax+4%1 ebx+%1 ebx+2%1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
678 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
679
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
680 "movq (%0), %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
681 "movq %%mm0, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
682 "punpcklbw %%mm7, %%mm0 \n\t" // low part of line 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
683 "punpckhbw %%mm7, %%mm1 \n\t" // high part of line 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
684
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
685 "movq (%%eax), %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
686 "movq %%mm2, %%mm3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
687 "punpcklbw %%mm7, %%mm2 \n\t" // low part of line 1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
688 "punpckhbw %%mm7, %%mm3 \n\t" // high part of line 1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
689
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
690 "movq (%%eax, %1), %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
691 "movq %%mm4, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
692 "punpcklbw %%mm7, %%mm4 \n\t" // low part of line 2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
693 "punpckhbw %%mm7, %%mm5 \n\t" // high part of line 2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
694
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
695 "paddw %%mm0, %%mm0 \n\t" // 2L0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
696 "paddw %%mm1, %%mm1 \n\t" // 2H0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
697 "psubw %%mm4, %%mm2 \n\t" // L1 - L2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
698 "psubw %%mm5, %%mm3 \n\t" // H1 - H2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
699 "psubw %%mm2, %%mm0 \n\t" // 2L0 - L1 + L2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
700 "psubw %%mm3, %%mm1 \n\t" // 2H0 - H1 + H2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
701
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
702 "psllw $2, %%mm2 \n\t" // 4L1 - 4L2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
703 "psllw $2, %%mm3 \n\t" // 4H1 - 4H2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
704 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
705 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
706
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
707 "movq (%%eax, %1, 2), %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
708 "movq %%mm2, %%mm3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
709 "punpcklbw %%mm7, %%mm2 \n\t" // L3
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
710 "punpckhbw %%mm7, %%mm3 \n\t" // H3
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
711
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
712 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2 - L3
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
713 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2 - H3
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
714 "psubw %%mm2, %%mm0 \n\t" // 2L0 - 5L1 + 5L2 - 2L3
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
715 "psubw %%mm3, %%mm1 \n\t" // 2H0 - 5H1 + 5H2 - 2H3
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
716 "movq %%mm0, temp0 \n\t" // 2L0 - 5L1 + 5L2 - 2L3
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
717 "movq %%mm1, temp1 \n\t" // 2H0 - 5H1 + 5H2 - 2H3
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
718
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
719 "movq (%0, %1, 4), %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
720 "movq %%mm0, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
721 "punpcklbw %%mm7, %%mm0 \n\t" // L4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
722 "punpckhbw %%mm7, %%mm1 \n\t" // H4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
723
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
724 "psubw %%mm0, %%mm2 \n\t" // L3 - L4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
725 "psubw %%mm1, %%mm3 \n\t" // H3 - H4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
726 "movq %%mm2, temp2 \n\t" // L3 - L4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
727 "movq %%mm3, temp3 \n\t" // H3 - H4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
728 "paddw %%mm4, %%mm4 \n\t" // 2L2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
729 "paddw %%mm5, %%mm5 \n\t" // 2H2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
730 "psubw %%mm2, %%mm4 \n\t" // 2L2 - L3 + L4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
731 "psubw %%mm3, %%mm5 \n\t" // 2H2 - H3 + H4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
732
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
733 "psllw $2, %%mm2 \n\t" // 4L3 - 4L4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
734 "psllw $2, %%mm3 \n\t" // 4H3 - 4H4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
735 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
736 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
737 //50 opcodes so far
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
738 "movq (%%ebx), %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
739 "movq %%mm2, %%mm3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
740 "punpcklbw %%mm7, %%mm2 \n\t" // L5
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
741 "punpckhbw %%mm7, %%mm3 \n\t" // H5
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
742 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4 - L5
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
743 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4 - H5
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
744 "psubw %%mm2, %%mm4 \n\t" // 2L2 - 5L3 + 5L4 - 2L5
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
745 "psubw %%mm3, %%mm5 \n\t" // 2H2 - 5H3 + 5H4 - 2H5
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
746
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
747 "movq (%%ebx, %1), %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
748 "punpcklbw %%mm7, %%mm6 \n\t" // L6
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
749 "psubw %%mm6, %%mm2 \n\t" // L5 - L6
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
750 "movq (%%ebx, %1), %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
751 "punpckhbw %%mm7, %%mm6 \n\t" // H6
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
752 "psubw %%mm6, %%mm3 \n\t" // H5 - H6
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
753
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
754 "paddw %%mm0, %%mm0 \n\t" // 2L4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
755 "paddw %%mm1, %%mm1 \n\t" // 2H4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
756 "psubw %%mm2, %%mm0 \n\t" // 2L4 - L5 + L6
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
757 "psubw %%mm3, %%mm1 \n\t" // 2H4 - H5 + H6
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
758
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
759 "psllw $2, %%mm2 \n\t" // 4L5 - 4L6
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
760 "psllw $2, %%mm3 \n\t" // 4H5 - 4H6
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
761 "psubw %%mm2, %%mm0 \n\t" // 2L4 - 5L5 + 5L6
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
762 "psubw %%mm3, %%mm1 \n\t" // 2H4 - 5H5 + 5H6
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
763
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
764 "movq (%%ebx, %1, 2), %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
765 "movq %%mm2, %%mm3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
766 "punpcklbw %%mm7, %%mm2 \n\t" // L7
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
767 "punpckhbw %%mm7, %%mm3 \n\t" // H7
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
768
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
769 "paddw %%mm2, %%mm2 \n\t" // 2L7
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
770 "paddw %%mm3, %%mm3 \n\t" // 2H7
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
771 "psubw %%mm2, %%mm0 \n\t" // 2L4 - 5L5 + 5L6 - 2L7
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
772 "psubw %%mm3, %%mm1 \n\t" // 2H4 - 5H5 + 5H6 - 2H7
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
773
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
774 "movq temp0, %%mm2 \n\t" // 2L0 - 5L1 + 5L2 - 2L3
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
775 "movq temp1, %%mm3 \n\t" // 2H0 - 5H1 + 5H2 - 2H3
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
776 //FIXME pxor, psubw, pmax for abs
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
777 "movq %%mm7, %%mm6 \n\t" // 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
778 "pcmpgtw %%mm0, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
779 "pxor %%mm6, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
780 "psubw %%mm6, %%mm0 \n\t" // |2L4 - 5L5 + 5L6 - 2L7|
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
781 "movq %%mm7, %%mm6 \n\t" // 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
782 "pcmpgtw %%mm1, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
783 "pxor %%mm6, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
784 "psubw %%mm6, %%mm1 \n\t" // |2H4 - 5H5 + 5H6 - 2H7|
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
785
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
786 "movq %%mm7, %%mm6 \n\t" // 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
787 "pcmpgtw %%mm2, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
788 "pxor %%mm6, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
789 "psubw %%mm6, %%mm2 \n\t" // |2L0 - 5L1 + 5L2 - 2L3|
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
790 "movq %%mm7, %%mm6 \n\t" // 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
791 "pcmpgtw %%mm3, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
792 "pxor %%mm6, %%mm3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
793 "psubw %%mm6, %%mm3 \n\t" // |2H0 - 5H1 + 5H2 - 2H3|
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
794
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
795 #ifdef HAVE_MMX2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
796 "pminsw %%mm2, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
797 "pminsw %%mm3, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
798 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
799 "movq %%mm0, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
800 "psubusw %%mm2, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
801 "psubw %%mm6, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
802 "movq %%mm1, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
803 "psubusw %%mm3, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
804 "psubw %%mm6, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
805 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
806
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
807 "movq %%mm7, %%mm6 \n\t" // 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
808 "pcmpgtw %%mm4, %%mm6 \n\t" // sign(2L2 - 5L3 + 5L4 - 2L5)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
809 "pxor %%mm6, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
810 "psubw %%mm6, %%mm4 \n\t" // |2L2 - 5L3 + 5L4 - 2L5|
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
811 "pcmpgtw %%mm5, %%mm7 \n\t" // sign(2H2 - 5H3 + 5H4 - 2H5)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
812 "pxor %%mm7, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
813 "psubw %%mm7, %%mm5 \n\t" // |2H2 - 5H3 + 5H4 - 2H5|
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
814 // 100 opcodes
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
815 "movd %2, %%mm2 \n\t" // QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
816 //"pcmpeqb %%mm2, %%mm2\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
817 "punpcklwd %%mm2, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
818 "punpcklwd %%mm2, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
819 "psllw $3, %%mm2 \n\t" // 8QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
820 "movq %%mm2, %%mm3 \n\t" // 8QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
821 "pcmpgtw %%mm4, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
822 "pcmpgtw %%mm5, %%mm3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
823 "pand %%mm2, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
824 "pand %%mm3, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
825
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
826
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
827 "psubusw %%mm0, %%mm4 \n\t" // hd
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
828 "psubusw %%mm1, %%mm5 \n\t" // ld
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
829
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
830
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
831 "movq w05, %%mm2 \n\t" // 5
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
832 "pmullw %%mm2, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
833 "pmullw %%mm2, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
834 "movq w20, %%mm2 \n\t" // 32
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
835 "paddw %%mm2, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
836 "paddw %%mm2, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
837 "psrlw $6, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
838 "psrlw $6, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
839
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
840 /*
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
841 "movq w06, %%mm2 \n\t" // 6
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
842 "paddw %%mm2, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
843 "paddw %%mm2, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
844 "movq w1400, %%mm2 \n\t" // 1400h = 5120 = 5/64*2^16
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
845 //FIXME if *5/64 is supposed to be /13 then we should use 5041 instead of 5120
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
846 "pmulhw %%mm2, %%mm4 \n\t" // hd/13
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
847 "pmulhw %%mm2, %%mm5 \n\t" // ld/13
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
848 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
849
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
850 "movq temp2, %%mm0 \n\t" // L3 - L4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
851 "movq temp3, %%mm1 \n\t" // H3 - H4
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
852
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
853 "pxor %%mm2, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
854 "pxor %%mm3, %%mm3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
855
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
856 // FIXME rounding error
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
857 "psraw $1, %%mm0 \n\t" // (L3 - L4)/2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
858 "psraw $1, %%mm1 \n\t" // (H3 - H4)/2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
859 "pcmpgtw %%mm0, %%mm2 \n\t" // sign (L3-L4)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
860 "pcmpgtw %%mm1, %%mm3 \n\t" // sign (H3-H4)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
861 "pxor %%mm2, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
862 "pxor %%mm3, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
863 "psubw %%mm2, %%mm0 \n\t" // |L3-L4|
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
864 "psubw %%mm3, %%mm1 \n\t" // |H3-H4|
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
865 // "psrlw $1, %%mm0 \n\t" // |L3 - L4|/2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
866 // "psrlw $1, %%mm1 \n\t" // |H3 - H4|/2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
867
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
868 "pxor %%mm6, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
869 "pxor %%mm7, %%mm3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
870 "pand %%mm2, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
871 "pand %%mm3, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
872
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
873 #ifdef HAVE_MMX2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
874 "pminsw %%mm0, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
875 "pminsw %%mm1, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
876 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
877 "movq %%mm4, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
878 "psubusw %%mm0, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
879 "psubw %%mm2, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
880 "movq %%mm5, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
881 "psubusw %%mm1, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
882 "psubw %%mm2, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
883 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
884 "pxor %%mm6, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
885 "pxor %%mm7, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
886 "psubw %%mm6, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
887 "psubw %%mm7, %%mm5 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
888 "packsswb %%mm5, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
889 "movq (%%eax, %1, 2), %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
890 "paddb %%mm4, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
891 "movq %%mm0, (%%eax, %1, 2) \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
892 "movq (%0, %1, 4), %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
893 "psubb %%mm4, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
894 // "pxor %%mm0, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
895 "movq %%mm0, (%0, %1, 4) \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
896
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
897 :
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
898 : "r" (src), "r" (stride), "r" (QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
899 : "%eax", "%ebx"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
900 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
901 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
902 const int l1= stride;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
903 const int l2= stride + l1;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
904 const int l3= stride + l2;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
905 const int l4= stride + l3;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
906 const int l5= stride + l4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
907 const int l6= stride + l5;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
908 const int l7= stride + l6;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
909 const int l8= stride + l7;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
910 // const int l9= stride + l8;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
911
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
912 for(int x=0; x<BLOCK_SIZE; x++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
913 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
914 const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
915 if(ABS(middleEnergy) < 8*QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
916 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
917 const int q=(src[l4] - src[l5])/2;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
918 const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
919 const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
920
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
921 int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
922 d= MAX(d, 0);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
923
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
924 d= (5*d + 32) >> 6;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
925 d*= SIGN(-middleEnergy);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
926
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
927 if(q>0)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
928 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
929 d= d<0 ? 0 : d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
930 d= d>q ? q : d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
931 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
932 else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
933 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
934 d= d>0 ? 0 : d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
935 d= d<q ? q : d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
936 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
937
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
938 src[l4]-= d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
939 src[l5]+= d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
940 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
941 src++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
942 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
943 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
944 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
945
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
946 //FIXME? |255-0| = 1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
947 /**
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
948 * Check if the given 8x8 Block is mostly "flat" and copy the unaliged data into tempBlock.
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
949 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
950 static inline bool isHorizDCAndCopy2Temp(uint8_t src[], int stride)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
951 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
952 // src++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
953 int numEq= 0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
954 #ifdef HAVE_MMX
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
955 asm volatile (
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
956 // "int $3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
957 "pushl %1\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
958 "movq b7E, %%mm7 \n\t" // mm7 = 0x7F
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
959 "movq b7C, %%mm6 \n\t" // mm6 = 0x7D
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
960 "leal tempBlock, %%eax \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
961 "pxor %%mm0, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
962
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
963 #define HDC_CHECK_AND_CPY(i) \
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
964 "movq -4(%1), %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
965 "psrlq $32, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
966 "punpckldq 4(%1), %%mm2 \n\t" /* (%1) */\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
967 "movq %%mm2, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
968 "psrlq $8, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
969 "psubb %%mm1, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
970 "paddb %%mm7, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
971 "pcmpgtb %%mm6, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
972 "paddb %%mm2, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
973 "movq %%mm1," #i "(%%eax) \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
974
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
975 HDC_CHECK_AND_CPY(0)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
976 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
977 HDC_CHECK_AND_CPY(8)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
978 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
979 HDC_CHECK_AND_CPY(16)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
980 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
981 HDC_CHECK_AND_CPY(24)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
982 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
983 HDC_CHECK_AND_CPY(32)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
984 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
985 HDC_CHECK_AND_CPY(40)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
986 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
987 HDC_CHECK_AND_CPY(48)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
988 "addl %2, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
989 HDC_CHECK_AND_CPY(56)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
990
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
991 "psllq $8, %%mm0 \n\t" // remove dummy value
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
992 "movq %%mm0, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
993 "psrlw $8, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
994 "paddb %%mm1, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
995 "movq %%mm0, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
996 "psrlq $16, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
997 "paddb %%mm1, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
998 "movq %%mm0, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
999 "psrlq $32, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1000 "paddb %%mm1, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1001 "popl %1\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1002 "movd %%mm0, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1003 : "=r" (numEq)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1004 : "r" (src), "r" (stride)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1005 : "%eax"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1006 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1007 // printf("%d\n", numEq);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1008 numEq= (256 - (numEq & 0xFF)) &0xFF;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1009 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1010 for(int y=0; y<BLOCK_SIZE; y++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1011 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1012 if(((src[0] - src[1] + 1) & 0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1013 if(((src[1] - src[2] + 1) & 0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1014 if(((src[2] - src[3] + 1) & 0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1015 if(((src[3] - src[4] + 1) & 0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1016 if(((src[4] - src[5] + 1) & 0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1017 if(((src[5] - src[6] + 1) & 0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1018 if(((src[6] - src[7] + 1) & 0xFFFF) < 3) numEq++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1019 tempBlock[0 + y*TEMP_STRIDE] = src[0];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1020 tempBlock[1 + y*TEMP_STRIDE] = src[1];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1021 tempBlock[2 + y*TEMP_STRIDE] = src[2];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1022 tempBlock[3 + y*TEMP_STRIDE] = src[3];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1023 tempBlock[4 + y*TEMP_STRIDE] = src[4];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1024 tempBlock[5 + y*TEMP_STRIDE] = src[5];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1025 tempBlock[6 + y*TEMP_STRIDE] = src[6];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1026 tempBlock[7 + y*TEMP_STRIDE] = src[7];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1027 src+= stride;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1028 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1029 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1030 /* if(abs(numEq - asmEq) > 0)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1031 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1032 // printf("\nasm:%d c:%d\n", asmEq, numEq);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1033 for(int y=0; y<8; y++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1034 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1035 for(int x=0; x<8; x++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1036 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1037 printf("%d ", src[x + y*stride]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1038 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1039 printf("\n");
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1040 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1041 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1042 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1043 // printf("%d\n", numEq);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1044 return numEq > hFlatnessThreshold;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1045 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1046
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1047 static inline bool isHorizMinMaxOk(uint8_t src[], int stride, int QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1048 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1049 #ifdef MMX_FIXME
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1050 FIXME
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1051 int isOk;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1052 asm volatile(
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1053 // "int $3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1054 "movq (%1, %2), %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1055 "movq (%1, %2, 8), %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1056 "movq %%mm0, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1057 "psubusb %%mm1, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1058 "psubusb %%mm2, %%mm1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1059 "por %%mm1, %%mm0 \n\t" // ABS Diff
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1060
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1061 "movq pQPb, %%mm7 \n\t" // QP,..., QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1062 "paddusb %%mm7, %%mm7 \n\t" // 2QP ... 2QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1063 "psubusb %%mm7, %%mm0 \n\t" // Diff <= 2QP -> 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1064 "pcmpeqd b00, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1065 "psrlq $16, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1066 "pcmpeqd bFF, %%mm0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1067 // "movd %%mm0, (%1, %2, 4)\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1068 "movd %%mm0, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1069 : "=r" (isOk)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1070 : "r" (src), "r" (stride)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1071 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1072 return isOk;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1073 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1074 if(abs(src[0] - src[7]) > 2*QP) return false;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1075
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1076 return true;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1077 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1078 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1079
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1080 static inline void doHorizDefFilterAndCopyBack(uint8_t dst[], int stride, int QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1081 {
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1082 #ifdef HAVE_MMX
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1083 asm volatile(
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1084 "pushl %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1085 "pxor %%mm7, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1086 "movq bm00001000, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1087 "movd %2, %%mm5 \n\t" // QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1088 "movq %%mm5, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1089 "paddusb %%mm5, %%mm5 \n\t" // 2QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1090 "paddusb %%mm5, %%mm4 \n\t" // 3QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1091 "psllq $24, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1092 "pxor %%mm5, %%mm5 \n\t" // 0
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1093 "psubb %%mm4, %%mm5 \n\t" // -QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1094 "leal tempBlock, %%eax \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1095
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1096 //FIXME? "unroll by 2" and mix
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1097 #ifdef HAVE_MMX2
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1098 #define HDF(i) \
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1099 "movq " #i "(%%eax), %%mm0 \n\t"\
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1100 "movq %%mm0, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1101 "movq %%mm0, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1102 "psrlq $8, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1103 "psubusb %%mm1, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1104 "psubusb %%mm0, %%mm1 \n\t"\
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1105 "por %%mm2, %%mm1 \n\t" /* p´x = |px - p(x+1)| */\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1106 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1107 "pshufw $0x00, %%mm1, %%mm3 \n\t" /* p´5 = |p1 - p2| */\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1108 "pminub %%mm1, %%mm3 \n\t" /* p´5 = min(|p2-p1|, |p6-p5|)*/\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1109 "psrlq $16, %%mm3 \n\t" /* p´3 = min(|p2-p1|, |p6-p5|)*/\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1110 "psubusb %%mm3, %%mm1 \n\t" /* |p3-p4|-min(|p1-p2|,|p5-p6|) */\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1111 "paddb %%mm5, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1112 "psubusb %%mm5, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1113 "psrlw $2, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1114 "pxor %%mm2, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1115 "psubb %%mm2, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1116 "pand %%mm6, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1117 "psubb %%mm1, %%mm0 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1118 "psllq $8, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1119 "paddb %%mm1, %%mm0 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1120 "movd %%mm0, (%0) \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1121 "psrlq $32, %%mm0 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1122 "movd %%mm0, 4(%0) \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1123 #else
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1124 #define HDF(i)\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1125 "movq " #i "(%%eax), %%mm0 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1126 "movq %%mm0, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1127 "movq %%mm0, %%mm2 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1128 "psrlq $8, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1129 "psubusb %%mm1, %%mm2 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1130 "psubusb %%mm0, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1131 "por %%mm2, %%mm1 \n\t" /* p´x = |px - p(x+1)| */\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1132 "pcmpeqb %%mm7, %%mm2 \n\t" /* p´x = sgn[px - p(x+1)] */\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1133 "movq %%mm1, %%mm3 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1134 "psllq $32, %%mm3 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1135 "movq %%mm3, %%mm4 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1136 "psubusb %%mm1, %%mm4 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1137 "psubb %%mm4, %%mm3 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1138 "psrlq $16, %%mm3 \n\t" /* p´3 = min(|p2-p1|, |p6-p5|)*/\
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1139 "psubusb %%mm3, %%mm1 \n\t" /* |p3-p4|-min(|p1-p2|,|p5,ü6|) */\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1140 "paddb %%mm5, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1141 "psubusb %%mm5, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1142 "psrlw $2, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1143 "pxor %%mm2, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1144 "psubb %%mm2, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1145 "pand %%mm6, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1146 "psubb %%mm1, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1147 "psllq $8, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1148 "paddb %%mm1, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1149 "movd %%mm0, (%0) \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1150 "psrlq $32, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1151 "movd %%mm0, 4(%0) \n\t"
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1152 #endif
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1153 HDF(0)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1154 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1155 HDF(8)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1156 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1157 HDF(16)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1158 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1159 HDF(24)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1160 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1161 HDF(32)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1162 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1163 HDF(40)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1164 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1165 HDF(48)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1166 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1167 HDF(56)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1168 "popl %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1169 :
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1170 : "r" (dst), "r" (stride), "r" (QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1171 : "%eax"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1172 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1173 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1174 uint8_t *src= tempBlock;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1175
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1176 for(int y=0; y<BLOCK_SIZE; y++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1177 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1178 dst[0] = src[0];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1179 dst[1] = src[1];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1180 dst[2] = src[2];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1181 dst[3] = src[3];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1182 dst[4] = src[4];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1183 dst[5] = src[5];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1184 dst[6] = src[6];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1185 dst[7] = src[7];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1186
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1187 const int middleEnergy= 5*(src[4] - src[5]) + 2*(src[2] - src[5]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1188 if(ABS(middleEnergy) < 8*QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1189 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1190 const int q=(src[3] - src[4])/2;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1191 const int leftEnergy= 5*(src[2] - src[1]) + 2*(src[0] - src[3]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1192 const int rightEnergy= 5*(src[6] - src[5]) + 2*(src[4] - src[7]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1193
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1194 int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1195 d= MAX(d, 0);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1196
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1197 d= (5*d + 32) >> 6;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1198 d*= SIGN(-middleEnergy);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1199
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1200 if(q>0)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1201 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1202 d= d<0 ? 0 : d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1203 d= d>q ? q : d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1204 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1205 else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1206 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1207 d= d>0 ? 0 : d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1208 d= d<q ? q : d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1209 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1210
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1211 dst[3]-= d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1212 dst[4]+= d;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1213 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1214 dst+= stride;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1215 src+= TEMP_STRIDE;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1216 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1217 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1218 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1219
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1220 /**
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1221 * Do a horizontal low pass filter on the 8x8 block
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1222 * useing the 9-Tap Filter (1,1,2,2,4,2,2,1,1)/16 (C version)
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1223 * useing approximately the 7-Tap Filter (1,2,3,4,3,2,1)/16 (MMX2/3DNOW version)
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1224 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1225 static inline void doHorizLowPassAndCopyBack(uint8_t dst[], int stride, int QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1226 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1227 //return;
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1228 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1229 asm volatile( //"movv %0 %1 %2\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1230 "pushl %0\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1231 "pxor %%mm7, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1232 "leal tempBlock, %%eax \n\t"
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1233 /*
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1234 #define HLP1 "movq (%0), %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1235 "movq %%mm0, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1236 "psllq $8, %%mm0 \n\t"\
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1237 PAVGB(%%mm1, %%mm0)\
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1238 "psrlw $8, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1239 "pxor %%mm1, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1240 "packuswb %%mm1, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1241 "movq %%mm0, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1242 "movq %%mm0, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1243 "psllq $32, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1244 "paddb %%mm0, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1245 "psllq $16, %%mm2 \n\t"\
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1246 PAVGB(%%mm2, %%mm0)\
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1247 "movq %%mm0, %%mm3 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1248 "pand bm11001100, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1249 "paddusb %%mm0, %%mm3 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1250 "psrlq $8, %%mm3 \n\t"\
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1251 PAVGB(%%mm1, %%mm4)\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1252 PAVGB(%%mm3, %%mm2)\
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1253 "psrlq $16, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1254 "punpcklbw %%mm2, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1255 "movq %%mm2, (%0) \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1256
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1257 #define HLP2 "movq (%0), %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1258 "movq %%mm0, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1259 "psllq $8, %%mm0 \n\t"\
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1260 PAVGB(%%mm1, %%mm0)\
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1261 "psrlw $8, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1262 "pxor %%mm1, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1263 "packuswb %%mm1, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1264 "movq %%mm0, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1265 "psllq $32, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1266 "psllq $16, %%mm2 \n\t"\
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1267 PAVGB(%%mm2, %%mm0)\
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1268 "movq %%mm0, %%mm3 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1269 "pand bm11001100, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1270 "paddusb %%mm0, %%mm3 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1271 "psrlq $8, %%mm3 \n\t"\
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1272 PAVGB(%%mm3, %%mm2)\
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1273 "psrlq $16, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1274 "punpcklbw %%mm2, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1275 "movq %%mm2, (%0) \n\t"\
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1276 */
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1277 // approximately a 7-Tap Filter with Vector (1,2,3,4,3,2,1)/16
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1278 /*
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1279 31
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1280 121
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1281 121
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1282 121
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1283 121
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1284 121
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1285 121
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1286 13
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1287 Implemented Exact 7-Tap
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1288 9421 A321
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1289 36421 64321
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1290 334321 =
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1291 1234321 =
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1292 1234321 =
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1293 123433 =
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1294 12463 12346
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1295 1249 123A
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1296
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1297 */
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1298 #ifdef HAVE_MMX2
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1299 #define HLP3(i) "movq " #i "(%%eax), %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1300 "movq %%mm0, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1301 "movq %%mm0, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1302 "movq %%mm0, %%mm3 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1303 "movq %%mm0, %%mm4 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1304 "psllq $8, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1305 "psrlq $8, %%mm2 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1306 "pand bm00000001, %%mm3 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1307 "pand bm10000000, %%mm4 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1308 "por %%mm3, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1309 "por %%mm4, %%mm2 \n\t"\
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1310 PAVGB(%%mm2, %%mm1)\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1311 PAVGB(%%mm1, %%mm0)\
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1312 \
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1313 "pshufw $0xF9, %%mm0, %%mm3 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1314 "pshufw $0x90, %%mm0, %%mm4 \n\t"\
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1315 PAVGB(%%mm3, %%mm4)\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1316 PAVGB(%%mm4, %%mm0)\
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1317 "movd %%mm0, (%0) \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1318 "psrlq $32, %%mm0 \n\t"\
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1319 "movd %%mm0, 4(%0) \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1320 #else
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1321 #define HLP3(i) "movq " #i "(%%eax), %%mm0 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1322 "movq %%mm0, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1323 "movq %%mm0, %%mm2 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1324 "movq %%mm0, %%mm3 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1325 "movq %%mm0, %%mm4 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1326 "psllq $8, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1327 "psrlq $8, %%mm2 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1328 "pand bm00000001, %%mm3 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1329 "pand bm10000000, %%mm4 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1330 "por %%mm3, %%mm1 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1331 "por %%mm4, %%mm2 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1332 PAVGB(%%mm2, %%mm1)\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1333 PAVGB(%%mm1, %%mm0)\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1334 \
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1335 "movq %%mm0, %%mm3 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1336 "movq %%mm0, %%mm4 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1337 "movq %%mm0, %%mm5 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1338 "psrlq $16, %%mm3 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1339 "psllq $16, %%mm4 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1340 "pand bm11000000, %%mm5 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1341 "por %%mm5, %%mm3 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1342 "movq %%mm0, %%mm5 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1343 "pand bm00000011, %%mm5 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1344 "por %%mm5, %%mm4 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1345 PAVGB(%%mm3, %%mm4)\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1346 PAVGB(%%mm4, %%mm0)\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1347 "movd %%mm0, (%0) \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1348 "psrlq $32, %%mm0 \n\t"\
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1349 "movd %%mm0, 4(%0) \n\t"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1350 #endif
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1351
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1352 #define HLP(i) HLP3(i)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1353
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1354 HLP(0)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1355 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1356 HLP(8)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1357 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1358 HLP(16)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1359 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1360 HLP(24)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1361 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1362 HLP(32)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1363 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1364 HLP(40)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1365 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1366 HLP(48)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1367 "addl %1, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1368 HLP(56)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1369
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1370 "popl %0\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1371 :
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1372 : "r" (dst), "r" (stride)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1373 : "%eax", "%ebx"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1374 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1375
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1376 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1377 uint8_t *temp= tempBlock;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1378 for(int y=0; y<BLOCK_SIZE; y++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1379 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1380 const int first= ABS(dst[-1] - dst[0]) < QP ? dst[-1] : dst[0];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1381 const int last= ABS(dst[8] - dst[7]) < QP ? dst[8] : dst[7];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1382
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1383 int sums[9];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1384 sums[0] = first + temp[0];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1385 sums[1] = temp[0] + temp[1];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1386 sums[2] = temp[1] + temp[2];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1387 sums[3] = temp[2] + temp[3];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1388 sums[4] = temp[3] + temp[4];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1389 sums[5] = temp[4] + temp[5];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1390 sums[6] = temp[5] + temp[6];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1391 sums[7] = temp[6] + temp[7];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1392 sums[8] = temp[7] + last;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1393
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1394 dst[0]= ((sums[0]<<2) + ((first + sums[2])<<1) + sums[4] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1395 dst[1]= ((dst[1]<<2) + (first + sums[0] + sums[3]<<1) + sums[5] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1396 dst[2]= ((dst[2]<<2) + (first + sums[1] + sums[4]<<1) + sums[6] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1397 dst[3]= ((dst[3]<<2) + (sums[2] + sums[5]<<1) + sums[0] + sums[7] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1398 dst[4]= ((dst[4]<<2) + (sums[3] + sums[6]<<1) + sums[1] + sums[8] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1399 dst[5]= ((dst[5]<<2) + (last + sums[7] + sums[4]<<1) + sums[2] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1400 dst[6]= ((last + dst[6]<<2) + (dst[7] + sums[5]<<1) + sums[3] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1401 dst[7]= ((sums[8]<<2) + (last + sums[6]<<1) + sums[4] + 8)>>4;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1402
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1403 dst+= stride;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1404 temp+= TEMP_STRIDE;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1405 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1406 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1407 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1408
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1409
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1410 static inline void dering(uint8_t src[], int stride, int QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1411 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1412 //FIXME
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1413
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1414 #ifdef HAVE_MMX2X
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1415 asm volatile(
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1416 "leal (%0, %1), %%eax \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1417 "leal (%%eax, %1, 4), %%ebx \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1418 // 0 1 2 3 4 5 6 7 8 9
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1419 // %0 eax eax+%1 eax+2%1 %0+4%1 ebx ebx+%1 ebx+2%1 %0+8%1 ebx+4%1
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1420
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1421 "pcmpeq %%mm6, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1422 "pxor %%mm7, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1423
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1424 #define FIND_MIN_MAX(addr)\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1425 "movq (" #addr "), %%mm0, \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1426 "pminub %%mm0, %%mm6 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1427 "pmaxub %%mm0, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1428
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1429 FIND_MIN_MAX(%0)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1430 FIND_MIN_MAX(%%eax)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1431 FIND_MIN_MAX(%%eax, %1)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1432 FIND_MIN_MAX(%%eax, %1, 2)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1433 FIND_MIN_MAX(%0, %1, 4)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1434 FIND_MIN_MAX(%%ebx)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1435 FIND_MIN_MAX(%%ebx, %1)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1436 FIND_MIN_MAX(%%ebx, %1, 2)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1437 FIND_MIN_MAX(%0, %1, 8)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1438 FIND_MIN_MAX(%%ebx, %1, 2)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1439
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1440 "movq %%mm6, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1441 "psrlq $32, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1442 "pminub %%mm4, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1443 "movq %%mm6, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1444 "psrlq $16, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1445 "pminub %%mm4, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1446 "movq %%mm6, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1447 "psrlq $8, %%mm6 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1448 "pminub %%mm4, %%mm6 \n\t" // min of pixels
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1449
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1450 "movq %%mm7, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1451 "psrlq $32, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1452 "pmaxub %%mm4, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1453 "movq %%mm7, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1454 "psrlq $16, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1455 "pmaxub %%mm4, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1456 "movq %%mm7, %%mm4 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1457 "psrlq $8, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1458 "pmaxub %%mm4, %%mm7 \n\t" // max of pixels
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1459 PAVGB(%%mm6, %%mm7) // (max + min)/2
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1460
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1461
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1462 : : "r" (src), "r" (stride), "r" (QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1463 : "%eax", "%ebx"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1464 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1465 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1466
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1467 //FIXME
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1468 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1469 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1470
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1471
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1472
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1473
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1474 /**
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1475 * ...
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1476 * the mode value is interpreted as a quality value if its negative, its range is then (-1 ... -63)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1477 * -63 is best quality -1 is worst
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1478 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1479 extern "C"{
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1480 void postprocess(unsigned char * src[], int src_stride,
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1481 unsigned char * dst[], int dst_stride,
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1482 int horizontal_size, int vertical_size,
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1483 QP_STORE_T *QP_store, int QP_stride,
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1484 int mode)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1485 {
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1486
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1487 if(mode<0) mode= getModeForQuality(-mode);
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1488
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1489 /*
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1490 long long T= rdtsc();
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1491 for(int y=vertical_size-1; y>=0 ; y--)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1492 memcpy(dst[0] + y*src_stride, src[0] + y*src_stride,src_stride);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1493 // memcpy(dst[0], src[0],src_stride*vertical_size);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1494 printf("%4dk\r", (rdtsc()-T)/1000);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1495
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1496 return;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1497 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1498 /*
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1499 long long T= rdtsc();
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1500 while( (rdtsc() - T)/1000 < 4000);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1501
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1502 return;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1503 */
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1504 postProcess(src[0], src_stride, dst[0], dst_stride,
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1505 horizontal_size, vertical_size, QP_store, QP_stride, false, mode);
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1506
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1507 horizontal_size >>= 1;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1508 vertical_size >>= 1;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1509 src_stride >>= 1;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1510 dst_stride >>= 1;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1511
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1512 if(1)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1513 {
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1514 postProcess(src[1], src_stride, dst[1], dst_stride,
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1515 horizontal_size, vertical_size, QP_store, QP_stride, true, mode >>4);
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1516 postProcess(src[2], src_stride, dst[2], dst_stride,
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1517 horizontal_size, vertical_size, QP_store, QP_stride, true, mode >>4);
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1518 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1519 else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1520 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1521 memcpy(dst[1], src[1], src_stride*horizontal_size);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1522 memcpy(dst[2], src[2], src_stride*horizontal_size);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1523 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1524 }
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1525 /**
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1526 * gets the mode flags for a given quality (larger values mean slower but better postprocessing)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1527 * 0 <= quality < 64
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1528 */
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1529 int getModeForQuality(int quality){
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1530 int modes[6]= {
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1531 LUM_V_DEBLOCK,
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1532 LUM_V_DEBLOCK | LUM_H_DEBLOCK,
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1533 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK,
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1534 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK,
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1535 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK | LUM_DERING,
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1536 LUM_V_DEBLOCK | LUM_H_DEBLOCK | CHROM_V_DEBLOCK | CHROM_H_DEBLOCK | LUM_DERING | CHROM_DERING
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1537 };
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1538
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1539 return modes[ (quality*6) >>6 ];
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1540 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1541
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1542 } // extern "C"
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1543
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1544 /**
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1545 * Copies a block from src to dst and fixes the blacklevel
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1546 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1547 static inline void blockCopy(uint8_t dst[], int dstStride, uint8_t src[], int srcStride)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1548 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1549 #ifdef HAVE_MMX
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1550 asm volatile(
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1551 "pushl %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1552 "pushl %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1553 "leal (%2,%2), %%eax \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1554 "leal (%3,%3), %%ebx \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1555 "movq packedYOffset, %%mm2 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1556 "movq packedYScale, %%mm3 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1557
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1558 #define SIMPLE_CPY \
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1559 "movq (%0), %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1560 "movq (%0,%2), %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1561 "psubusb %%mm2, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1562 "psubusb %%mm2, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1563 "movq %%mm0, (%1) \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1564 "movq %%mm1, (%1, %3) \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1565
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1566 #define SCALED_CPY \
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1567 "movq (%0), %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1568 "movq (%0,%2), %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1569 "psubusb %%mm2, %%mm0 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1570 "psubusb %%mm2, %%mm1 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1571 "pxor %%mm4, %%mm4 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1572 "pxor %%mm5, %%mm5 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1573 "punpcklbw %%mm0, %%mm4 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1574 "punpckhbw %%mm0, %%mm5 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1575 "pmulhuw %%mm3, %%mm4 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1576 "pmulhuw %%mm3, %%mm5 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1577 "packuswb %%mm5, %%mm4 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1578 "movq %%mm4, (%1) \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1579 "pxor %%mm4, %%mm4 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1580 "pxor %%mm5, %%mm5 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1581 "punpcklbw %%mm1, %%mm4 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1582 "punpckhbw %%mm1, %%mm5 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1583 "pmulhuw %%mm3, %%mm4 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1584 "pmulhuw %%mm3, %%mm5 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1585 "packuswb %%mm5, %%mm4 \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1586 "movq %%mm4, (%1, %3) \n\t"\
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1587
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1588
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1589 #define CPY SCALED_CPY
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1590 //#define CPY SIMPLE_CPY
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1591 // "prefetchnta 8(%0)\n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1592 CPY
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1593 "addl %%eax, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1594 "addl %%ebx, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1595 CPY
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1596 "addl %%eax, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1597 "addl %%ebx, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1598 CPY
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1599 "addl %%eax, %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1600 "addl %%ebx, %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1601 CPY
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1602 "popl %1 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1603 "popl %0 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1604 : : "r" (src),
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1605 "r" (dst),
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1606 "r" (srcStride),
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1607 "r" (dstStride)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1608 : "%eax", "%ebx"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1609 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1610 #else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1611 for(int i=0; i<BLOCK_SIZE; i++) // last 10x8 Block is copied allready so +2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1612 memcpy( &(dst[dstStride*i]),
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1613 &(src[srcStride*i]), BLOCK_SIZE);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1614 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1615 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1616
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1617
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1618 /**
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1619 * Filters array of bytes (Y or U or V values)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1620 */
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1621 void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1622 QP_STORE_T QPs[], int QPStride, bool isColor, int mode)
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1623 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1624
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1625 #ifdef TIMEING
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1626 long long T0, T1, memcpyTime=0, vertTime=0, horizTime=0, sumTime, diffTime=0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1627 sumTime= rdtsc();
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1628 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1629
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1630 /* we need 64bit here otherwise we´ll going to have a problem
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1631 after watching a black picture for 5 hours*/
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1632 static uint64_t *yHistogram= NULL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1633 if(!yHistogram)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1634 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1635 yHistogram= new uint64_t[256];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1636 for(int i=0; i<256; i++) yHistogram[i]= width*height/64/256;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1637 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1638
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1639 int black=0, white=255; // blackest black and whitest white in the picture
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1640 if(!isColor)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1641 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1642 uint64_t sum= 0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1643 for(int i=0; i<256; i++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1644 sum+= yHistogram[i];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1645
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1646 uint64_t maxClipped= (uint64_t)(sum * maxClippedThreshold);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1647
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1648 uint64_t clipped= sum;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1649 for(black=255; black>0; black--)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1650 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1651 if(clipped < maxClipped) break;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1652 clipped-= yHistogram[black];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1653 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1654
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1655 clipped= sum;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1656 for(white=0; white<256; white++)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1657 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1658 if(clipped < maxClipped) break;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1659 clipped-= yHistogram[white];
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1660 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1661
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1662 // we cant handle negative correctures
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1663 packedYOffset= MAX(black - minAllowedY, 0);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1664 packedYOffset|= packedYOffset<<32;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1665 packedYOffset|= packedYOffset<<16;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1666 packedYOffset|= packedYOffset<<8;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1667
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1668 double scale= (double)(maxAllowedY - minAllowedY) / (double)(white-black);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1669
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1670 packedYScale= uint16_t(scale*256.0 + 0.5);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1671 packedYScale|= packedYScale<<32;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1672 packedYScale|= packedYScale<<16;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1673 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1674 else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1675 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1676 packedYScale= 0x0100010001000100LL;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1677 packedYOffset= 0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1678 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1679
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1680 for(int x=0; x<width; x+=BLOCK_SIZE)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1681 blockCopy(dst + x, dstStride, src + x, srcStride);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1682
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1683 for(int y=0; y<height; y+=BLOCK_SIZE)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1684 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1685 //1% speedup if these are here instead of the inner loop
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1686 uint8_t *srcBlock= &(src[y*srcStride]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1687 uint8_t *dstBlock= &(dst[y*dstStride]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1688 uint8_t *vertSrcBlock= &(srcBlock[srcStride*3]); // Blocks are 10x8 -> *3 to start
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1689 uint8_t *vertBlock= &(dstBlock[dstStride*3]);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1690
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1691 // finish 1 block before the next otherwise we´ll might have a problem
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1692 // with the L1 Cache of the P4 ... or only a few blocks at a time or soemthing
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1693 for(int x=0; x<width; x+=BLOCK_SIZE)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1694 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1695 int QP= isColor ?
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1696 QPs[(y>>3)*QPStride + (x>>3)]:
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1697 (QPs[(y>>4)*QPStride + (x>>4)] * (packedYScale &0xFFFF))>>8;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1698 #ifdef HAVE_MMX
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1699 asm volatile(
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1700 "movd %0, %%mm7 \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1701 "packuswb %%mm7, %%mm7 \n\t" // 0, 0, 0, QP, 0, 0, 0, QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1702 "packuswb %%mm7, %%mm7 \n\t" // 0,QP, 0, QP, 0,QP, 0, QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1703 "packuswb %%mm7, %%mm7 \n\t" // QP,..., QP
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1704 "movq %%mm7, pQPb \n\t"
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1705 : : "r" (QP)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1706 );
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1707 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1708
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1709
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1710 const int stride= dstStride;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1711 if(y + 12 < height)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1712 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1713 #ifdef MORE_TIMEING
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1714 T0= rdtsc();
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1715 #endif
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1716
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1717 #ifdef HAVE_MMX2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1718 prefetchnta(vertSrcBlock + (((x>>3)&3) + 2)*srcStride + 32);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1719 prefetchnta(vertSrcBlock + (((x>>3)&3) + 6)*srcStride + 32);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1720 prefetcht0(vertBlock + (((x>>3)&3) + 2)*dstStride + 32);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1721 prefetcht0(vertBlock + (((x>>3)&3) + 6)*dstStride + 32);
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1722 #elif defined(HAVE_3DNOW)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1723 //FIXME check if this is faster on an 3dnow chip or if its faster without the prefetch or ...
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1724 /* prefetch(vertSrcBlock + (((x>>3)&3) + 2)*srcStride + 32);
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1725 prefetch(vertSrcBlock + (((x>>3)&3) + 6)*srcStride + 32);
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1726 prefetchw(vertBlock + (((x>>3)&3) + 2)*dstStride + 32);
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1727 prefetchw(vertBlock + (((x>>3)&3) + 6)*dstStride + 32);
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1728 */
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1729 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1730 if(!isColor) yHistogram[ srcBlock[0] ]++;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1731
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1732 blockCopy(vertBlock + dstStride*2, dstStride,
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1733 vertSrcBlock + srcStride*2, srcStride);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1734
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1735
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1736 #ifdef MORE_TIMEING
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1737 T1= rdtsc();
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1738 memcpyTime+= T1-T0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1739 T0=T1;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1740 #endif
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1741 if(mode & V_DEBLOCK)
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1742 {
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1743 if(mode & RK_FILTER)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1744 vertRKFilter(vertBlock, stride, QP);
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1745 else if(0)
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1746 vertX1Filter(vertBlock, stride, QP);
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1747 else
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1748 {
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1749 if( isVertDC(vertBlock, stride))
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1750 {
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1751 if(isVertMinMaxOk(vertBlock, stride, QP))
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1752 doVertLowPass(vertBlock, stride, QP);
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1753 }
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1754 else
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1755 doVertDefFilter(vertBlock, stride, QP);
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1756 }
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1757 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1758 #ifdef MORE_TIMEING
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1759 T1= rdtsc();
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1760 vertTime+= T1-T0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1761 T0=T1;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1762 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1763 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1764 else
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1765 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1766 for(int i=2; i<BLOCK_SIZE/2+1; i++) // last 10x8 Block is copied allready so +2
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1767 memcpy( &(vertBlock[dstStride*i]),
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1768 &(vertSrcBlock[srcStride*i]), BLOCK_SIZE);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1769
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1770 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1771
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1772 if(x - 8 >= 0 && x<width)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1773 {
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1774 #ifdef MORE_TIMEING
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1775 T0= rdtsc();
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1776 #endif
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1777 if(mode & H_DEBLOCK)
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1778 {
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1779 if( isHorizDCAndCopy2Temp(dstBlock-4, stride))
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1780 {
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1781 if(isHorizMinMaxOk(tempBlock, TEMP_STRIDE, QP))
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1782 doHorizLowPassAndCopyBack(dstBlock-4, stride, QP);
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1783 }
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1784 else
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1785 doHorizDefFilterAndCopyBack(dstBlock-4, stride, QP);
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1786 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1787 #ifdef MORE_TIMEING
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1788 T1= rdtsc();
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1789 horizTime+= T1-T0;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1790 T0=T1;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1791 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1792 dering(dstBlock - 9 - stride, stride, QP);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1793 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1794 else if(y!=0)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1795 dering(dstBlock - stride*9 + width-9, stride, QP);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1796 //FIXME dering filter will not be applied to last block (bottom right)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1797
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1798
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1799 dstBlock+=8;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1800 srcBlock+=8;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1801 vertBlock+=8;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1802 vertSrcBlock+=8;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1803 }
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1804 }
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1805 #ifdef HAVE_3DNOW
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1806 asm volatile("femms");
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1807 #elif defined (HAVE_MMX)
95
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1808 asm volatile("emms");
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1809 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1810
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1811 #ifdef TIMEING
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1812 // FIXME diff is mostly the time spent for rdtsc (should subtract that but ...)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1813 sumTime= rdtsc() - sumTime;
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1814 if(!isColor)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1815 printf("cpy:%4dk, vert:%4dk, horiz:%4dk, sum:%4dk, diff:%4dk, color: %d/%d \r",
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1816 int(memcpyTime/1000), int(vertTime/1000), int(horizTime/1000),
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1817 int(sumTime/1000), int((sumTime-memcpyTime-vertTime-horizTime)/1000)
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1818 , black, white);
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1819 #endif
8bce253b537c new postprocess code by Michael Niedermayer (michaelni@gmx.at)
arpi
parents:
diff changeset
1820 }
96
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1821
29ac11dc53d3 fixed a bug in the horizontal default filter
arpi
parents: 95
diff changeset
1822