1// -*- c++ -*-
2
3// Version for non-SSE2
4
5#ifndef IS_C
6
7#ifdef SKIP_SEARCH
8            "movq    %%mm6, %%mm0\n\t"            // just use the results of our wierd bob
9#else
10
11
12            // JA 9/Dec/2002
13            // failed experiment
14            // but leave in placeholder for me to play about
15#ifdef DONT_USE_STRANGE_BOB
16            // Use the best weave if diffs less than 10 as that
17            // means the image is still or moving cleanly
18            // if there is motion we will clip which will catch anything
19            "psubusb "_FOURS", %%mm7\n\t"          // sets bits to zero if weave diff < 4
20            "pxor    %%mm0, %%mm0\n\t"
21            "pcmpeqb %%mm0, %%mm7\n\t"            // all ff where weave better, else 00
22            "pcmpeqb %%mm7, %%mm0\n\t"            // all ff where bob better, else 00
23            "pand    %%mm6, %%mm0\n\t"            // use bob for these pixel values
24            "pand    %%mm5, %%mm7\n\t"            // use weave for these
25            "por     %%mm7, %%mm0\n\t"            // combine both
26#else
27            // Use the better of bob or weave
28            //      pminub  mm4, TENS           // the most we care about
29            V_PMINUB ("%%mm4", _TENS, "%%mm0")   // the most we care about
30
31            "psubusb %%mm4, %%mm7\n\t"            // foregive that much from weave est?
32            "psubusb "_FOURS", %%mm7\n\t"       // bias it a bit toward weave
33            "pxor    %%mm0, %%mm0\n\t"
34            "pcmpeqb %%mm0, %%mm7\n\t"            // all ff where weave better, else 00
35            "pcmpeqb %%mm7, %%mm0\n\t"            // all ff where bob better, else 00
36            "pand    %%mm6, %%mm0\n\t"            // use bob for these pixel values
37            "pand    %%mm5, %%mm7\n\t"            // use weave for these
38            "por     %%mm7, %%mm0\n\t"            // combine both
39#endif
40
41
42                //      pminub  mm0, Max_Vals       // but clip to catch the stray error
43                V_PMINUB ("%%mm0", _Max_Vals, "%%mm1") // but clip to catch the stray error
44                //      pmaxub  mm0, Min_Vals
45                V_PMAXUB ("%%mm0", _Min_Vals)
46
47#endif
48
49
50            MOVX"     "_pDest", %%"XAX"\n\t"
51
52#ifdef USE_VERTICAL_FILTER
53            "movq    %%mm0, %%mm1\n\t"
54            //      pavgb   mm0, qword ptr["XBX"]
55            V_PAVGB ("%%mm0", "(%%"XBX")", "%%mm2", _ShiftMask)
56            //      movntq  qword ptr["XAX"+"XDX"], mm0
57            V_MOVNTQ ("(%"XAX", %%"XDX")", "%%mm0")
58            //      pavgb   mm1, qword ptr["XBX"+"XCX"]
59            V_PAVGB ("%%mm1", "(%%"XBX", %%"XCX")", "%%mm2", _ShiftMask)
60	    //FIXME: XDX or XAX!!
61            "addq   "_dst_pitchw", %%"XBX
62            //      movntq  qword ptr["XAX"+"XDX"], mm1
63            V_MOVNTQ ("(%%"XAX", %%"XDX")", "%%mm1")
64#else
65
66            //      movntq  qword ptr["XAX"+"XDX"], mm0
67                V_MOVNTQ ("(%%"XAX", %%"XDX")", "%%mm0")
68#endif
69
70           LEAX"    8(%%"XDX"), %%"XDX"\n\t"       // bump offset pointer
71           CMPX"    "_Last8", %%"XDX"\n\t"       // done with line?
72           "jb      1b\n\t"                    // y
73
74           MOVX" "_oldbx", %%"XBX"\n\t"
75
76        : /* no outputs */
77
78        : "m"(pBob),
79          "m"(src_pitch2),
80          "m"(ShiftMask),
81          "m"(pDest),
82          "m"(dst_pitchw),
83          "m"(Last8),
84          "m"(pSrc),
85          "m"(pSrcP),
86          "m"(pBobP),
87          "m"(DiffThres),
88          "m"(Min_Vals),
89          "m"(Max_Vals),
90          "m"(FOURS),
91          "m"(TENS),
92          "m"(ONES),
93          "m"(UVMask),
94          "m"(Max_Mov),
95          "m"(YMask),
96          "m"(oldbx)
97
98        : XAX, XCX, XDX, XSI, XDI,
99          "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)",
100#ifdef __MMX__
101          "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7",
102#endif
103          "memory", "cc"
104        );
105
106        // adjust for next line
107        pSrc  += src_pitch2;
108        pSrcP += src_pitch2;
109        pDest += dst_pitch2;
110        pBob  += src_pitch2;
111        pBobP += src_pitch2;
112    }
113
114    return 0;
115#else
116#ifdef SKIP_SEARCH
117            out[0] = best[0];            // just use the results of our wierd bob
118	    out[1] = best[1];
119#else
120            diff[0] = diff[0] - MIN (diff[0], 10) - 4;
121	    diff[1] = diff[1] - MIN (diff[1] - 10) - 4;
122	    if (diff[0] < 0)
123	      out[0] = weave[0];
124	    else
125	      out[0] = best[0];
126
127	    if (diff[1] < 0)
128	      out[1] = weave[1];
129	    else
130	      out[1] = best[1];
131
132
133	    out[0] = CLAMP (out[0], MinVals[0], MaxVals[0]);
134	    out[1] = CLAMP (out[1], MinVals[1], MaxVals[1]);
135#endif
136
137#ifdef USE_VERTICAL_FILTER
138            pDest[x] = (out[0] + pBob[0]) / 2;
139	    pDest[x + dst_pitchw] = (pBob[src_pitch2] + out[0]) / 2;
140            pDest[x + 1] = (out[1] + pBob[1]) / 2;
141	    pDest[x + 1 + dst_pitchw] = (pBob[src_pitch2 + 1] + out[1]) / 2;
142#else
143            pDest[x] = out[0];
144	    pDest[x+1] = out[1];
145#endif
146            pBob += 2;
147            pBobP += 2;
148            pSrc += 2;
149            pSrcP += 2;
150	}
151        // adjust for next line
152        pSrc  = src_pitch2 * (y+1) + pWeaveSrc;
153        pSrcP = src_pitch2 * (y+1) + pWeaveSrcP;
154        pDest = dst_pitch2 * (y+1) + pWeaveDest + dst_pitch2;
155
156
157	if (TopFirst)
158	{
159		pBob = pCopySrc + src_pitch2;
160		pBobP = pCopySrcP + src_pitch2;
161	}
162	else
163	{
164		pBob =  pCopySrc;
165		pBobP =  pCopySrcP;
166	}
167
168        pBob  += src_pitch2 * (y+1);
169        pBobP += src_pitch2 * (y+1);
170    }
171
172    return 0;
173
174#endif
175