~ubuntu-branches/ubuntu/maverick/zapping/maverick

« back to all changes in this revision

Viewing changes to plugins/deinterlace/DI_GreedyH/DI_GreedyHM_V.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-03-08 23:19:08 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050308231908-oip7rfv6lcmo8c0e
Tags: 0.9.2-2ubuntu1
Rebuilt for Python transition (2.3 -> 2.4)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
/////////////////////////////////////////////////////////////////////////////
 
6
//
 
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.
 
12
//
 
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
 
17
//
 
18
/////////////////////////////////////////////////////////////////////////////
 
19
// Change Log
 
20
//
 
21
// Date          Developer             Changes
 
22
//
 
23
// 01 Jul 2001   Tom Barry                     Break out Greedy (High Motion) Deinterlace, w/Vert Filter
 
24
//
 
25
/////////////////////////////////////////////////////////////////////////////
 
26
// CVS Log
 
27
//
 
28
// $Log: DI_GreedyHM_V.c,v $
 
29
// Revision 1.1  2005/01/08 14:54:23  mschimek
 
30
// *** empty log message ***
 
31
//
 
32
// Revision 1.5  2001/10/02 17:44:41  trbarry
 
33
// Changes to be compatible with the Avisynth filter version
 
34
//
 
35
// Revision 1.4  2001/08/17 19:30:55  trbarry
 
36
// Fix OBO error in GreedyH Vertical Filter
 
37
//
 
38
// Revision 1.3  2001/08/17 17:08:42  trbarry
 
39
// GreedyH performance enhancement:
 
40
//
 
41
// Unroll loop to support Write Combining in Vertical Filter
 
42
// (curiously this now peforms better than without V. Filter)
 
43
//
 
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
 
47
//
 
48
/////////////////////////////////////////////////////////////////////////////
 
49
 
 
50
// This version handles Greedy High Motion with Vertical Filtering
 
51
 
 
52
#include "windows.h"
 
53
//>>>>>>>>>#include "DS_Deinterlace.h"
 
54
#include "DI_GreedyHM.h"
 
55
 
 
56
// debugging options
 
57
#undef USE_JAGGIE_REDUCTION
 
58
#undef USE_GREEDY_CHOICE
 
59
#undef USE_CLIP
 
60
#undef USE_BOB_BLEND
 
61
 
 
62
#define USE_JAGGIE_REDUCTION
 
63
#define USE_GREEDY_CHOICE
 
64
#define USE_CLIP
 
65
#define USE_BOB_BLEND
 
66
 
 
67
 
 
68
#define FUNCT_NAME DI_GreedyHM_V
 
69
 
 
70
BOOL FUNCT_NAME()
 
71
{
 
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
 
76
 
 
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
 
86
        int CopySrc;
 
87
 
 
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
 
93
 
 
94
 
 
95
 
 
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
 
105
 
 
106
        for (line = 0; line < (FieldHeight); ++line)
 
107
        {
 
108
                LoopCtr = LoopCtrW;                             // actually qword counter
 
109
                if (WeaveDest == lpCurOverlay)    // on first line may just copy first and last
 
110
                {
 
111
                        FieldStoreCopy(lpCurOverlay, &FieldStore[CopySrc], LineLength);
 
112
                        WeaveDest += DestIncr;          // bump for next, CopyDest already OK
 
113
                        pL2 = & FieldStore[L2 + FSCOLCT];
 
114
                }
 
115
                else
 
116
                {                       
 
117
_saved_regs;
 
118
 
 
119
_asm_begin
 
120
_save(eax)
 
121
_save(ecx)
 
122
_save(edx)
 
123
_save(esi)
 
124
_save(edi)
 
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"
 
131
"               \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"
 
136
"L1OK:\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"
 
141
"\n"
 
142
"L3OK:          \n"
 
143
"               mov             edx, %[CopyDest]\n"
 
144
"\n"
 
145
"               .align 8\n"
 
146
"QwordLoop:\n"
 
147
"\n"
 
148
"## 1st 4 qwords\n"
 
149
#define FSOFFS 0 * FSCOLSIZE                            // following include needs an offset
 
150
#include "DI_GreedyDeLoop.asm"
 
151
"               pavgb   mm1, mm4\n"
 
152
"               movntq  qword ptr[edx], mm1         ## avg clipped best with above line\n"
 
153
"               pavgb   mm3, mm4\n"
 
154
"               movq    %[SaveQword1], mm3                  ## avg clipped best with below line, save for later\n"
 
155
"\n"
 
156
"## 2nd 4 qwords\n"
 
157
#undef  FSOFFS
 
158
#define FSOFFS 1 * FSCOLSIZE                            // following include needs an offset
 
159
#include "DI_GreedyDeLoop.asm"
 
160
"               pavgb   mm1, mm4\n"
 
161
"               movntq  qword ptr[edx+8], mm1       ## avg clipped best with above line\n"
 
162
"               pavgb   mm3, mm4\n"
 
163
"               movq    %[SaveQword2], mm3                  ## avg clipped best with below line, save for later\n"
 
164
"## 3rd 4 qwords\n"
 
165
#undef  FSOFFS
 
166
#define FSOFFS 2 * FSCOLSIZE                            // following include needs an offset
 
167
#include "DI_GreedyDeLoop.asm"
 
168
"               pavgb   mm1, mm4\n"
 
169
"               movntq  qword ptr[edx+16], mm1      ## avg clipped best with above line\n"
 
170
"               pavgb   mm3, mm4\n"
 
171
"               movq    %[SaveQword3], mm3                  ## avg clipped best with below line, save for later\n"
 
172
"\n"
 
173
"## 4'th 4 qwords\n"
 
174
#undef  FSOFFS
 
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"
 
180
"        pavgb   mm1, mm4\n"
 
181
"               movntq  qword ptr[edx+24], mm1      ## avg clipped best with above line\n"
 
182
"               pavgb   mm3, mm4\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"
 
187
"\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"
 
192
"               dec             %[LoopCtr]\n"
 
193
"               jg              QwordLoop                       \n"
 
194
"\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"
 
205
"               sfence\n"
 
206
"               emms\n"
 
207
_restore(edi)
 
208
_restore(esi)
 
209
_restore(edx)
 
210
_restore(ecx)
 
211
_restore(eax)
 
212
_asm_end,
 
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),
 
217
_m(UVMask));
 
218
                }               // should undent here but I can't read it
 
219
        }
 
220
 
 
221
  return TRUE;
 
222
}       
 
223