1
/////////////////////////////////////////////////////////////////////////////
2
// $Id: DI_GreedyHM_V.c,v 1.1 2005/01/08 14:54:23 mschimek Exp $
3
/////////////////////////////////////////////////////////////////////////////
4
// Copyright (c) 2001 Tom Barry. All rights reserved.
5
/////////////////////////////////////////////////////////////////////////////
7
// This file is subject to the terms of the GNU General Public License as
8
// published by the Free Software Foundation. A copy of this license is
9
// included with this software distribution in the file COPYING. If you
10
// do not have a copy, you may obtain a copy by writing to the Free
11
// Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
13
// This software is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
// GNU General Public License for more details
18
/////////////////////////////////////////////////////////////////////////////
21
// Date Developer Changes
23
// 01 Jul 2001 Tom Barry Break out Greedy (High Motion) Deinterlace, w/Vert Filter
25
/////////////////////////////////////////////////////////////////////////////
28
// $Log: DI_GreedyHM_V.c,v $
29
// Revision 1.1 2005/01/08 14:54:23 mschimek
30
// *** empty log message ***
32
// Revision 1.5 2001/10/02 17:44:41 trbarry
33
// Changes to be compatible with the Avisynth filter version
35
// Revision 1.4 2001/08/17 19:30:55 trbarry
36
// Fix OBO error in GreedyH Vertical Filter
38
// Revision 1.3 2001/08/17 17:08:42 trbarry
39
// GreedyH performance enhancement:
41
// Unroll loop to support Write Combining in Vertical Filter
42
// (curiously this now peforms better than without V. Filter)
44
// Revision 1.2 2001/07/25 12:04:31 adcockj
45
// Moved Control stuff into DS_Control.h
46
// Added $Id and $Log to comment blocks as per standards
48
/////////////////////////////////////////////////////////////////////////////
50
// This version handles Greedy High Motion with Vertical Filtering
53
//>>>>>>>>>#include "DS_Deinterlace.h"
54
#include "DI_GreedyHM.h"
57
#undef USE_JAGGIE_REDUCTION
58
#undef USE_GREEDY_CHOICE
62
#define USE_JAGGIE_REDUCTION
63
#define USE_GREEDY_CHOICE
68
#define FUNCT_NAME DI_GreedyHM_V
72
#include "DI_GreedyHM2.h"
73
int line; // number of lines
74
int LoopCtr; // number of qwords in line - 1
75
int LoopCtrW; // number of qwords in line - 1
77
int L1; // offset to FieldStore elem holding top known pixels
78
int L3; // offset to FieldStore elem holding bottom known pxl
79
int L2; // offset to FieldStore elem holding newest weave pixels
80
int L2P; // offset to FieldStore elem holding prev weave pixels
81
__int64* pFieldStore; // ptr into FieldStore qwords
82
__int64* pFieldStoreEnd; // ptr to Last FieldStore qword
83
__int64* pL2; // ptr into FieldStore[L2]
84
BYTE* WeaveDest; // dest for weave pixel
85
BYTE* CopyDest; // other dest, copy or vertical filter
88
int DestIncr = 2 * OverlayPitch; // we go throug overlay buffer 2 lines per
89
__int64 LastAvg=0; //interp value from left qword
90
__int64 SaveQword1=0; // Temp Save pixels
91
__int64 SaveQword2=0; // Temp Save pixels
92
__int64 SaveQword3=0; // Temp Save pixels
96
// set up pointers, offsets
97
SetFsPtrs(&L1, &L2, &L2P, &L3, &CopySrc, &CopyDest, &WeaveDest);
98
L2 = __min(L2, L2P); // Subscript to 1st of 2 possible weave pixels, our base addr
99
L1 = (L1 - L2) * 8; // now is signed offset from L2
100
L3 = (L3 - L2) * 8; // now is signed offset from L2
101
pFieldStore = & FieldStore[0]; // starting ptr into FieldStore[L2]
102
pFieldStoreEnd = & FieldStore[FieldHeight * FSCOLCT]; // ending ptr into FieldStore[L2]
103
pL2 = & FieldStore[L2]; // starting ptr into FieldStore[L2]
104
LoopCtrW = LineLength / 32; // do 8 bytes at a time, adjusted
106
for (line = 0; line < (FieldHeight); ++line)
108
LoopCtr = LoopCtrW; // actually qword counter
109
if (WeaveDest == lpCurOverlay) // on first line may just copy first and last
111
FieldStoreCopy(lpCurOverlay, &FieldStore[CopySrc], LineLength);
112
WeaveDest += DestIncr; // bump for next, CopyDest already OK
113
pL2 = & FieldStore[L2 + FSCOLCT];
125
" mov edi, %[WeaveDest] ## get ptr to line ptrs \n"
126
" mov esi, %[pL2] ## addr of our 1st qword in FieldStore\n"
127
" mov eax, %[L1] ## offset to top \n"
128
" mov ebx, %[L3] ## offset to top comb \n"
129
" mov ecx, %[OverlayPitch] ## overlay pitch\n"
130
" mov %[LastAvg6], 0 ## init left avg lazy way\n"
132
" lea edx, [esi+eax] ## where L1 would point\n"
133
" cmp edx, %[pFieldStore] ## before begin of fieldstore?\n"
134
" jnb L1OK ## n, ok\n"
135
" mov eax, ebx ## else use this for top pixel vals\n"
137
" lea edx, [esi+ebx] ## where L2 would point\n"
138
" cmp edx, %[pFieldStoreEnd] ## after end of fieldstore?\n"
139
" jb L3OK ## n, ok\n"
140
" mov ebx, eax ## else use this bottom pixel vals\n"
143
" mov edx, %[CopyDest]\n"
149
#define FSOFFS 0 * FSCOLSIZE // following include needs an offset
150
#include "DI_GreedyDeLoop.asm"
152
" movntq qword ptr[edx], mm1 ## avg clipped best with above line\n"
154
" movq %[SaveQword1], mm3 ## avg clipped best with below line, save for later\n"
158
#define FSOFFS 1 * FSCOLSIZE // following include needs an offset
159
#include "DI_GreedyDeLoop.asm"
161
" movntq qword ptr[edx+8], mm1 ## avg clipped best with above line\n"
163
" movq %[SaveQword2], mm3 ## avg clipped best with below line, save for later\n"
166
#define FSOFFS 2 * FSCOLSIZE // following include needs an offset
167
#include "DI_GreedyDeLoop.asm"
169
" movntq qword ptr[edx+16], mm1 ## avg clipped best with above line\n"
171
" movq %[SaveQword3], mm3 ## avg clipped best with below line, save for later\n"
175
#define FSOFFS 3 * FSCOLSIZE // following include needs an offset
176
#include "DI_GreedyDeLoop.asm"
177
" movq mm5, %[SaveQword1] ## get saved pixels\n"
178
" movq mm6, %[SaveQword2] ## get saved pixels\n"
179
" movq mm7, %[SaveQword3] ## get saved pixels\n"
181
" movntq qword ptr[edx+24], mm1 ## avg clipped best with above line\n"
183
" movntq qword ptr[edi], mm5 ## store saved pixels\n"
184
" movntq qword ptr[edi+8], mm6 ## store saved pixels\n"
185
" movntq qword ptr[edi+16], mm7 ## store saved pixels\n"
186
" movntq qword ptr[edi+24], mm3 ## avg clipped best with below line\n"
188
" ## bump ptrs and loop for next 4 qword\n"
189
" lea edx,[edx+32] ## bump CopyDest\n"
190
" lea edi,[edi+32] ## bump WeaveDest\n"
191
" lea esi,[esi+4*" _strf(FSCOLSIZE) "] \n"
195
"## Ok, done with one line\n"
196
" mov esi, %[pL2] ## addr of our 1st qword in FieldStore\n"
197
" lea esi, [esi+" _strf(FSROWSIZE) "] ## bump to next row\n"
198
" mov %[pL2], esi ## addr of our 1st qword in FieldStore for line\n"
199
" mov edi, %[WeaveDest] ## ptr to curr overlay buff line start\n"
200
" add edi, %[DestIncr] ## but we want to skip 1\n"
201
" mov %[WeaveDest], edi ## update for next loop\n"
202
" mov edx, %[CopyDest] ## ptr to curr overlay buff line start\n"
203
" add edx, %[DestIncr] ## but we want to skip 1\n"
204
" mov %[CopyDest], edx ## update for next loop\n"
213
_m(WeaveDest), _m(pL2), _m(L1), _m(L3), _m(OverlayPitch), _m_nth(LastAvg, 6),
214
_m(pFieldStore), _m(pFieldStoreEnd), _m(CopyDest), _m(SaveQword1),
215
_m(SaveQword2), _m(SaveQword3), _m(LoopCtr), _m(DestIncr), _m(LastAvg),
216
_m(MaxCombW), _m(MotionThresholdW), _m(MotionSenseW), _m(QW256), _m(YMaskW),
218
} // should undent here but I can't read it