~ubuntu-branches/ubuntu/feisty/kdetv/feisty

« back to all changes in this revision

Viewing changes to kdetv/plugins/filter/tomsmocomp/SearchLoopTop.inc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-09-17 23:25:16 UTC
  • Revision ID: james.westby@ubuntu.com-20050917232516-9wdsn3ckagbqieh8
Tags: upstream-0.8.8
ImportĀ upstreamĀ versionĀ 0.8.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
 
 
3
unsigned char* pDest;
 
4
const unsigned char* pSrcP;
 
5
const unsigned char* pSrc;
 
6
const unsigned char* pBob;
 
7
const unsigned char* pBobP;
 
8
 
 
9
int64_t Max_Mov   = 0x0404040404040404ull; 
 
10
int64_t DiffThres = 0x0f0f0f0f0f0f0f0full; 
 
11
int64_t YMask     = 0x00ff00ff00ff00ffull; // keeps only luma
 
12
int64_t UVMask    = 0xff00ff00ff00ff00ull; // keeps only chroma
 
13
int64_t TENS      = 0x0a0a0a0a0a0a0a0aull; 
 
14
int64_t FOURS     = 0x0404040404040404ull; 
 
15
int64_t ONES      = 0x0101010101010101ull; 
 
16
int64_t Min_Vals  = 0x0000000000000000ull;
 
17
int64_t Max_Vals  = 0x0000000000000000ull;
 
18
int64_t ShiftMask = 0xfefffefffefffeffull;
 
19
 
 
20
// long is int32 on ARCH_368, int64 on ARCH_AMD64. Declaring it this way
 
21
// saves a lot of xor's to delete 64bit garbage.
 
22
 
 
23
#if defined(DBL_RESIZE) || defined(USE_FOR_DSCALER)
 
24
long        src_pitch2 = src_pitch;                     // even & odd lines are not longerleaved in DScaler
 
25
#else
 
26
long        src_pitch2 = 2 * src_pitch;         // even & odd lines are longerleaved in Avisynth
 
27
#endif
 
28
 
 
29
long        dst_pitch2 = 2 * dst_pitch;
 
30
long     y;
 
31
 
 
32
#ifdef IS_SSE2
 
33
long     Last8 = (rowsize-16);                  // ofs to last 16 bytes in row for SSE2
 
34
#else
 
35
long     Last8 = (rowsize-8);                   // ofs to last 8 bytes in row
 
36
#endif
 
37
 
 
38
long            dst_pitchw = dst_pitch; // local stor so asm can ref
 
39
        pSrc  = pWeaveSrc;                      // polongs 1 weave line above
 
40
        pSrcP = pWeaveSrcP;                     // " 
 
41
 
 
42
#ifdef DBL_RESIZE
 
43
                
 
44
#ifdef USE_VERTICAL_FILTER
 
45
        pDest = pWeaveDest + dst_pitch2;
 
46
#else
 
47
        pDest = pWeaveDest + 3*dst_pitch;
 
48
#endif
 
49
 
 
50
#else
 
51
 
 
52
#ifdef USE_VERTICAL_FILTER
 
53
        pDest = pWeaveDest + dst_pitch;
 
54
#else
 
55
        pDest = pWeaveDest + dst_pitch2;
 
56
#endif
 
57
 
 
58
#endif
 
59
 
 
60
        if (TopFirst)
 
61
        {
 
62
                pBob = pCopySrc + src_pitch2;      // remember one weave line just copied previously
 
63
                pBobP = pCopySrcP + src_pitch2;
 
64
        }
 
65
        else
 
66
        {
 
67
                pBob =  pCopySrc;
 
68
                pBobP =  pCopySrcP;
 
69
        }
 
70
 
 
71
#ifndef _pBob
 
72
#define _pBob       "%0"
 
73
#define _src_pitch2 "%1"
 
74
#define _ShiftMask  "%2"
 
75
#define _pDest      "%3"
 
76
#define _dst_pitchw "%4"
 
77
#define _Last8      "%5"
 
78
#define _pSrc       "%6"
 
79
#define _pSrcP      "%7"
 
80
#define _pBobP      "%8"
 
81
#define _DiffThres  "%9"
 
82
#define _Min_Vals   "%10"
 
83
#define _Max_Vals   "%11"
 
84
#define _FOURS      "%12"
 
85
#define _TENS       "%13"
 
86
#define _ONES       "%14"
 
87
#define _UVMask     "%15"
 
88
#define _Max_Mov    "%16"
 
89
#define _YMask      "%17"
 
90
#define _oldbx      "%18"
 
91
#endif
 
92
 
 
93
        long oldbx;
 
94
 
 
95
        for (y=1; y < FldHeight-1; y++) 
 
96
        {
 
97
                // pretend it's indented -->>
 
98
        __asm__ __volatile__
 
99
            (
 
100
             // Loop general reg usage
 
101
             //
 
102
             // XAX - pBobP, then pDest 
 
103
             // XBX - pBob
 
104
             // XCX - src_pitch2
 
105
             // XDX - current offset
 
106
             // XDI - prev weave pixels, 1 line up
 
107
             // XSI - next weave pixels, 1 line up
 
108
 
 
109
             // Save "XBX" (-fPIC)
 
110
             MOVX" %%"XBX", "_oldbx"\n\t"
 
111
             
 
112
#ifdef IS_SSE2
 
113
             
 
114
             // sse2 code deleted for now
 
115
 
 
116
#else
 
117
             // simple bob first 8 bytes
 
118
             MOVX"      "_pBob",        %%"XBX"\n\t"
 
119
             MOVX"      "_src_pitch2",  %%"XCX"\n\t"
 
120
 
 
121
#ifdef USE_VERTICAL_FILTER
 
122
             "movq          (%%"XBX"),        %%mm0\n\t"
 
123
             "movq          (%%"XBX", %%"XCX"), %%mm1\n\t" //, qword ptr["XBX"+"XCX"]
 
124
             "movq          %%mm0,          %%mm2\n\t"
 
125
             V_PAVGB ("%%mm2", "%%mm1", "%%mm3", _ShiftMask)            // halfway between
 
126
             V_PAVGB ("%%mm0", "%%mm2", "%%mm3", _ShiftMask)            // 1/4 way
 
127
             V_PAVGB ("%%mm1", "%%mm2", "%%mm3", _ShiftMask)            // 3/4 way
 
128
             MOVX"              "_pDest",       %%"XDI"\n\t"
 
129
             MOVX"              "_dst_pitchw",  %%"XAX"\n\t"
 
130
             V_MOVNTQ   ("(%%"XDI")", "%%mm0")
 
131
             V_MOVNTQ   ("(%%"XDI", %%"XAX")", "%%mm1") // qword ptr["XDI"+"XAX"], mm1
 
132
 
 
133
             // simple bob last 8 bytes
 
134
             MOVX"              "_Last8", %%"XDX"\n\t"
 
135
             LEAX"              (%%"XBX", %%"XDX"), %%"XSI"\n\t"  // ["XBX"+"XDX"]
 
136
             "movq          (%%"XSI"), %%mm0\n\t"
 
137
             "movq          (%%"XSI", %%"XCX"), %%mm1\n\t"    // qword ptr["XSI"+"XCX"]
 
138
             "movq          %%mm0, %%mm2\n\t"
 
139
             V_PAVGB ("%%mm2", "%%mm1", "%%mm3", _ShiftMask)            // halfway between
 
140
             V_PAVGB ("%%mm0", "%%mm2", "%%mm3", _ShiftMask)            // 1/4 way
 
141
             V_PAVGB ("%%mm1", "%%mm2", "%%mm3", _ShiftMask)            // 3/4 way
 
142
             ADDX"              %%"XDX", %%"XDI"\n\t"                                           // last 8 bytes of dest
 
143
             V_MOVNTQ   ("%%"XDI"", "%%mm0")
 
144
             V_MOVNTQ   ("(%%"XDI", %%"XAX")", "%%mm1") // qword ptr["XDI"+"XAX"], mm1)
 
145
 
 
146
#else
 
147
             "movq      (%%"XBX"), %%mm0\n\t"
 
148
             //         pavgb   mm0, qword ptr["XBX"+"XCX"]
 
149
             V_PAVGB ("%%mm0", "(%%"XBX", %%"XCX")", "%%mm2", _ShiftMask) // qword ptr["XBX"+"XCX"], mm2, ShiftMask)
 
150
             MOVX"              "_pDest", %%"XDI"\n\t"
 
151
             V_MOVNTQ   ("(%%"XDI")", "%%mm0")
 
152
 
 
153
             // simple bob last 8 bytes
 
154
             MOVX"              "_Last8", %%"XDX"\n\t"
 
155
             LEAX"              (%%"XBX", %%"XDX"), %%"XSI"\n\t" //"XSI", ["XBX"+"XDX"]
 
156
             "movq          (%%"XSI"), %%mm0\n\t"
 
157
             //         pavgb   mm0, qword ptr["XSI"+"XCX"]
 
158
             V_PAVGB    ("%%mm0", "(%%"XSI", %%"XCX")", "%%mm2", _ShiftMask) // qword ptr["XSI"+"XCX"], mm2, ShiftMask)
 
159
             V_MOVNTQ   ("(%%"XDI", %%"XDX")", "%%mm0") // qword ptr["XDI"+"XDX"], mm0)
 
160
#endif
 
161
             // now loop and get the middle qwords
 
162
             MOVX"              "_pSrc", %%"XSI"\n\t"
 
163
             MOVX"              "_pSrcP", %%"XDI"\n\t"
 
164
             MOVX"              $8, %%"XDX"\n\t"                                // curr offset longo all lines
 
165
 
 
166
             "1:\n\t"   
 
167
             MOVX"              "_pBobP", %%"XAX"\n\t"
 
168
             ADDX"              $8, %%"XDI"\n\t"
 
169
             ADDX"              $8, %%"XSI"\n\t"
 
170
             ADDX"              $8, %%"XBX"\n\t"
 
171
             ADDX"              %%"XDX", %%"XAX"\n\t"
 
172
 
 
173
#ifdef USE_STRANGE_BOB
 
174
#include "StrangeBob.inc"
 
175
#else
 
176
#include "WierdBob.inc"
 
177
#endif
 
178
 
 
179
             // For non-SSE2:
 
180
             // through out most of the rest of this loop we will malongain
 
181
             // mm4             our min bob value
 
182
             // mm5             best weave pixels so far
 
183
             // mm6             our max Bob value 
 
184
             // mm7             best weighted pixel ratings so far
 
185
             
 
186
             // We will keep a slight bias to using the weave pixels
 
187
             // from the current location, by rating them by the min distance
 
188
             // from the Bob value instead of the avg distance from that value.
 
189
             // our best and only rating so far
 
190
             "pcmpeqb   %%mm7, %%mm7\n\t"                       // ffff, say we didn't find anything good yet
 
191
 
 
192
#endif