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

« back to all changes in this revision

Viewing changes to plugins/deinterlace/DI_MoComp2/MoComp2.h

  • 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: MoComp2.h,v 1.2 2005/01/20 01:38:34 mschimek Exp $
 
3
/////////////////////////////////////////////////////////////////////////////
 
4
// Copyright (c) 2003 Tom Barry & John Adcock.  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
//  (From Tom Barry)
 
19
//  Also, this program is "Philanthropy-Ware".  That is, if you like it and 
 
20
//  feel the need to reward or inspire the author then please feel free (but
 
21
//  not obligated) to consider joining or donating to the Electronic Frontier
 
22
//  Foundation. This will help keep cyber space free of barbed wire and bullsh*t.  
 
23
//  See www.eff.org for details
 
24
/////////////////////////////////////////////////////////////////////////////
 
25
// CVS Log
 
26
//
 
27
// $Log: MoComp2.h,v $
 
28
// Revision 1.2  2005/01/20 01:38:34  mschimek
 
29
// *** empty log message ***
 
30
//
 
31
// Revision 1.1  2005/01/08 14:54:24  mschimek
 
32
// *** empty log message ***
 
33
//
 
34
// Revision 1.3  2003/05/26 15:54:36  adcockj
 
35
// Improved Performance of motion detection
 
36
// Fixed bug with pBobP
 
37
//
 
38
// Revision 1.2  2003/02/11 15:40:50  adcockj
 
39
// New implementation of StrangeBob based off paper
 
40
// Tidy up sources
 
41
//
 
42
// Revision 1.1  2003/01/02 13:15:01  adcockj
 
43
// Added new plug-ins ready for developement by copying TomsMoComp and Gamma
 
44
//
 
45
/////////////////////////////////////////////////////////////////////////////
 
46
 
 
47
//Z #include <malloc.h>
 
48
#include <string.h>
 
49
//Z #include <math.h>
 
50
//Z #include <malloc.h>
 
51
 
 
52
#define BOOL unsigned int
 
53
#define BYTE unsigned char
 
54
 
 
55
BOOL DeinterlaceMoComp2_SSE(TDeinterlaceInfo* pInfo);
 
56
BOOL DeinterlaceMoComp2_MMX(TDeinterlaceInfo* pInfo);
 
57
BOOL DeinterlaceMoComp2_3DNOW(TDeinterlaceInfo* pInfo);
 
58
#define MyMemCopy pMyMemcpy
 
59
extern long SearchEffort;
 
60
 
 
61
static int  Fieldcopy(void *dest, const void *src, size_t count, 
 
62
                        int rows, int dst_pitch, int src_pitch);
 
63
static void  DoMoComp2_SimpleWeave();
 
64
 
 
65
//Z static __int64 Save1; 
 
66
//Z static __int64 Save2; 
 
67
 
 
68
static const __int64 MOVE  = 0x0f0f0f0f0f0f0f0fLL; 
 
69
 
 
70
static const __int64 YMask = 0x00ff00ff00ff00ffLL; // keeps only luma
 
71
static const __int64 UVMask =  0xff00ff00ff00ff00LL; // keeps only chroma
 
72
 
 
73
static const __int64 ShiftMask = 0xfefffefffefffeffLL;  // to avoid shifting chroma to luma
 
74
 
 
75
 
 
76
// Define a few macros for CPU dependent instructions. 
 
77
// I suspect I don't really understand how the C macro preprocessor works but
 
78
// this seems to get the job done.          // TRB 7/01
 
79
 
 
80
// BEFORE USING THESE YOU MUST SET:
 
81
 
 
82
// #define SSE_TYPE SSE            (or MMX or 3DNOW)
 
83
 
 
84
// some macros for pavgb instruction
 
85
//      V_PAVGB(mmr1, mmr2, mmr work register, smask) mmr2 may = mmrw if you can trash it
 
86
 
 
87
 
 
88
#define V_PAVGB_MMX(mmr1,mmr2,mmrw,smask) \
 
89
"       movq " #mmrw "," #mmr2 "\n" \
 
90
"       pand " #mmrw "," #smask "\n" \
 
91
"       psrlw " #mmrw ",1\n" \
 
92
"       pand " #mmr1 "," #smask "\n" \
 
93
"       psrlw " #mmr1 ",1\n" \
 
94
"       paddusb " #mmr1 "," #mmrw "\n"
 
95
 
 
96
#define V_PAVGB_SSE(mmr1,mmr2,mmrw,smask) " pavgb " #mmr1 "," #mmr2 "\n"
 
97
#define V_PAVGB_3DNOW(mmr1,mmr2,mmrw,smask) " pavgusb " #mmr1 "," #mmr2 "\n"
 
98
#define V_PAVGB(mmr1,mmr2,mmrw,smask) V_PAVGB2(mmr1,mmr2,mmrw,smask,SSE_TYPE) 
 
99
#define V_PAVGB2(mmr1,mmr2,mmrw,smask,ssetyp) V_PAVGB3(mmr1,mmr2,mmrw,smask,ssetyp) 
 
100
#define V_PAVGB3(mmr1,mmr2,mmrw,smask,ssetyp) V_PAVGB_##ssetyp(mmr1,mmr2,mmrw,smask) 
 
101
 
 
102
// some macros for pmaxub instruction
 
103
//      V_PMAXUB(mmr1, mmr2)    
 
104
#define V_PMAXUB_MMX(mmr1,mmr2) \
 
105
"    psubusb " #mmr1 "," #mmr2 "\n" \
 
106
"    paddusb " #mmr1 "," #mmr2 "\n"
 
107
 
 
108
#define V_PMAXUB_SSE(mmr1,mmr2) " pmaxub " #mmr1 "," #mmr2 "\n"
 
109
#define V_PMAXUB_3DNOW(mmr1,mmr2) V_PMAXUB_MMX(mmr1,mmr2)  // use MMX version
 
110
#define V_PMAXUB(mmr1,mmr2) V_PMAXUB2(mmr1,mmr2,SSE_TYPE) 
 
111
#define V_PMAXUB2(mmr1,mmr2,ssetyp) V_PMAXUB3(mmr1,mmr2,ssetyp) 
 
112
#define V_PMAXUB3(mmr1,mmr2,ssetyp) V_PMAXUB_##ssetyp(mmr1,mmr2) 
 
113
 
 
114
// some macros for pminub instruction
 
115
//      V_PMINUB(mmr1, mmr2, mmr work register)     mmr2 may NOT = mmrw
 
116
#define V_PMINUB_MMX(mmr1,mmr2,mmrw) \
 
117
"    pcmpeqb " #mmrw "," #mmrw "\n" \
 
118
"    psubusb " #mmrw "," #mmr2 "\n" \
 
119
"    paddusb " #mmr1 "," #mmrw "\n" \
 
120
"    psubusb " #mmr1 "," #mmrw "\n"
 
121
 
 
122
#define V_PMINUB_SSE(mmr1,mmr2,mmrw) " pminub " #mmr1 "," #mmr2 "\n"
 
123
#define V_PMINUB_3DNOW(mmr1,mmr2,mmrw) V_PMINUB_MMX(mmr1,mmr2,mmrw)  // use MMX version
 
124
#define V_PMINUB(mmr1,mmr2,mmrw) V_PMINUB2(mmr1,mmr2,mmrw,SSE_TYPE) 
 
125
#define V_PMINUB2(mmr1,mmr2,mmrw,ssetyp) V_PMINUB3(mmr1,mmr2,mmrw,ssetyp) 
 
126
#define V_PMINUB3(mmr1,mmr2,mmrw,ssetyp) V_PMINUB_##ssetyp(mmr1,mmr2,mmrw) 
 
127
 
 
128
// some macros for movntq instruction
 
129
//      V_MOVNTQ(mmr1, mmr2) 
 
130
#define V_MOVNTQ_MMX(mmr1,mmr2) " movq " #mmr1 "," #mmr2 "\n"
 
131
#define V_MOVNTQ_3DNOW(mmr1,mmr2) " movq " #mmr1 "," #mmr2 "\n"
 
132
#define V_MOVNTQ_SSE(mmr1,mmr2) " movntq " #mmr1 "," #mmr2 "\n"
 
133
#define V_MOVNTQ(mmr1,mmr2) V_MOVNTQ2(mmr1,mmr2,SSE_TYPE) 
 
134
#define V_MOVNTQ2(mmr1,mmr2,ssetyp) V_MOVNTQ3(mmr1,mmr2,ssetyp) 
 
135
#define V_MOVNTQ3(mmr1,mmr2,ssetyp) V_MOVNTQ_##ssetyp(mmr1,mmr2)
 
136
 
 
137
// end of macros
 
138
 
 
139
// macro load a field from this object
 
140
#if 0
 
141
#define thisLoad(reg, intfield) \
 
142
                __asm { \
 
143
                __asm mov       reg, this \
 
144
                __asm mov   reg, dword ptr [reg].intfield \
 
145
                }
 
146
#endif
 
147
 
 
148
// sorts registers a & b
 
149
#define SORT(a,b,temp1) \
 
150
"   movq " #temp1 "," #a "\n" \
 
151
"   pminub " #a "," #b "\n" \
 
152
"   pmaxub " #b "," #temp1 "\n"
 
153
 
 
154
#define PABS(a,b,temp1) \
 
155
"   movq " #temp1 "," #b "\n" \
 
156
"   psubusb " #temp1 "," #a "\n" \
 
157
"   psubusb " #a "," #b "\n" \
 
158
"   por " #a "," #temp1 "\n"
 
159
 
 
160
// a = a where mask, b otherwise; mask = -1
 
161
#define COMBINE(a,b,mask) \
 
162
"       pand " #a "," #mask "\n" \
 
163
"       pandn " #mask "," #b "\n" \
 
164
"       por " #a "," #mask "\n"