1
/////////////////////////////////////////////////////////////////////////////
2
// $Id: DI_OldGame.c,v 1.2 2005/02/05 22:19:34 mschimek Exp $
3
/////////////////////////////////////////////////////////////////////////////
4
// Copyright (c) 2001 Lindsey Dubb. All rights reserved.
5
// based on OddOnly and Temporal Noise DScaler Plugins
6
// (c) John Adcock & Steve Grimm
7
/////////////////////////////////////////////////////////////////////////////
9
// This file is subject to the terms of the GNU General Public License as
10
// published by the Free Software Foundation. A copy of this license is
11
// included with this software distribution in the file COPYING. If you
12
// do not have a copy, you may obtain a copy by writing to the Free
13
// Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
15
// This software is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU General Public License for more details
19
/////////////////////////////////////////////////////////////////////////////
22
// $Log: DI_OldGame.c,v $
23
// Revision 1.2 2005/02/05 22:19:34 mschimek
26
// Revision 1.1 2005/01/08 14:34:43 mschimek
27
// TomsMoCompMethod, MoComp2Method, VideoWeaveMethod, VideoBobMethod,
28
// TwoFrameMethod, OldGameMethod, Greedy2FrameMethod, GreedyMethod,
29
// DI_GreedyHSettings: Localized.
31
// Revision 1.2 2004/11/15 23:03:19 michael
32
// *** empty log message ***
34
// Revision 1.1 2004/11/14 15:35:14 michael
35
// *** empty log message ***
37
// Revision 1.6 2002/06/13 12:10:24 adcockj
38
// Move to new Setings dialog for filers, video deint and advanced settings
40
// Revision 1.5 2002/01/04 01:38:56 lindsey
41
// Turned off the debug flag
43
// Revision 1.4 2001/12/20 03:42:58 lindsey
44
// Corrected processor detection
45
// Miscellaneous reorganization
47
// Revision 1.3 2001/11/21 15:21:40 adcockj
48
// Renamed DEINTERLACE_INFO to TDeinterlaceInfo in line with standards
49
// Changed TDeinterlaceInfo structure to have history of pictures.
51
// Revision 1.2 2001/08/30 10:03:52 adcockj
52
// Slightly improved the color averaging
53
// Added a "composite mode" switch to force averaging when crosstalk is more important than blur.
55
// Reorganized and edited to follow the coding guidelines
56
// Most importantly: Added a silly quote
57
// (Changes made on behalf of Lindsey Dubb)
59
// Revision 1.1 2001/07/30 08:25:22 adcockj
60
// Added Lindsey Dubb's method
62
/////////////////////////////////////////////////////////////////////////////
65
#include "DS_Deinterlace.h"
66
//Z #include "..\help\helpids.h"
68
//uncomment to turn on display of the comb factor
69
//#define OLDGAME_DEBUG
71
/////////////////////////////////////////////////////////////////////////////
73
Up and down, up and down. Pardon me, but my lunch wants to join the sea.
76
This is the Old Game "deinterlacing" method. More accurately, it's the Old
77
Game nondeinterlacing method, which circumvents the deinterlacing done in the
81
It assumes that the image is half vertical resolution and progressive, and
82
therefore shouldn't be deinterlaced. In addition, it averages when there
83
isn't any detected motion in order to clean up noise a bit. This works well
84
for games which run at less than a full 50 or 60 FPS. It's downright
85
necessary if the game is connected via composite, since video games tend
86
to have awful chroma/luma crosstalk.
88
Ways this filter could be improved:
89
- The Playstation, Super Nintendo, Saturn, and Nintendo 64 all can switch
90
between an interlaced and a progressive half vertical resolution mode.
91
It would be nice to be able to automatically detect this and forward the
92
deinterlacing on to a real deinterlacing algorithm. But this would
93
require DScaler to keep checking whether the vertical resolution has
94
changed, which it currently doesn't.
95
- Potentially, you could also try to infer the horizontal resolution,
96
deconvolve the image, and smooth it more optimally. I really doubt
97
it would be worth the effort.
98
- The difference between fields could be used in composite mode to infer
99
motion. But it often makes sense to average even when there is some
100
30 FPS motion, so this wouldn't be easy.
102
/////////////////////////////////////////////////////////////////////////////
104
/////////////////////////////////////////////////////////////////////////////
105
// Function prototypes
106
/////////////////////////////////////////////////////////////////////////////
108
__declspec(dllexport) DEINTERLACE_METHOD* GetDeinterlacePluginInfo(long CpuFeatureFlags);
109
BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved);
110
long OldGameFilter_SSE(TDeinterlaceInfo *pInfo);
111
long OldGameFilter_3DNOW(TDeinterlaceInfo *pInfo);
112
long OldGameFilter_MMX(TDeinterlaceInfo *pInfo);
115
void __cdecl OldGameDebugStart(long NumPlugIns, DEINTERLACE_METHOD** OtherPlugins,
116
DEINTERLACEPLUGINSETSTATUS* SetStatus);
120
/////////////////////////////////////////////////////////////////////////////
121
// Begin plugin globals
122
/////////////////////////////////////////////////////////////////////////////
124
// gMaxComb is compared to the comb factor to determine if the image has
125
// enough motion to force us to send the image to the screen unaltered
126
// instead of averaging witht he previous image.
128
static long gMaxComb = 300;
130
// When using a composite connector, crosstalk is bad enough that it's
131
// (almost) always worth averaging.
133
static long gDisableMotionChecking = FALSE;
135
// This is used to put up the comb factor for testing purposes.
138
static DEINTERLACEPLUGINSETSTATUS* gPfnSetStatus = NULL;
141
static DEINTERLACE_METHOD OldGameMethod;
144
static SETTING DI_OldGameSettings[DI_OLDGAME_SETTING_LASTONE] =
147
N_("Maximum motion"), SLIDER, 0, &gMaxComb,
150
"DI_OldGame", "maxComb", NULL,
153
N_("Composite mode"), ONOFF, 0, &gDisableMotionChecking,
156
"DI_OldGame", "CompositeMode", NULL,
161
static DEINTERLACE_METHOD OldGameMethod =
163
sizeof(DEINTERLACE_METHOD),
164
DEINTERLACE_CURRENT_VERSION,
166
NULL, // It could make sense to use this with a resolution sensing adaptive filter
172
DI_OLDGAME_SETTING_LASTONE,
195
/////////////////////////////////////////////////////////////////////////////
196
// Main code (included from Dl_OldGame.asm)
197
/////////////////////////////////////////////////////////////////////////////
200
#include "DI_OldGame.asm"
204
#include "DI_OldGame.asm"
208
#include "DI_OldGame.asm"
212
////////////////////////////////////////////////////////////////////////////
213
// Start of utility code
214
/////////////////////////////////////////////////////////////////////////////
217
void __cdecl OldGameDebugStart(long NumPlugIns, DEINTERLACE_METHOD** OtherPlugins, DEINTERLACEPLUGINSETSTATUS* SetStatus)
219
gPfnSetStatus = SetStatus;
221
#endif // OLDGAME_DEBUG
224
DEINTERLACE_METHOD* DI_OldGame_GetDeinterlacePluginInfo(long CpuFeatureFlags)
226
if ((CpuFeatureFlags & FEATURE_SSE) || (CpuFeatureFlags & FEATURE_MMXEXT))
228
OldGameMethod.pfnAlgorithm = OldGameFilter_SSE;
230
else if (CpuFeatureFlags & FEATURE_3DNOW)
232
OldGameMethod.pfnAlgorithm = OldGameFilter_3DNOW;
236
OldGameMethod.pfnAlgorithm = OldGameFilter_MMX;
238
return &OldGameMethod;
245
BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)