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

« back to all changes in this revision

Viewing changes to plugins/deinterlace/DI_Misc/DI_OldGame.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2005-11-08 11:07:34 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051108110734-ygvf6uljvgcjmca7
Tags: 0.9.6-1ubuntu1
* Resynchronise with Debian (Closes: #4022):
  - Fix desktop file to not use absolute path.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
/////////////////////////////////////////////////////////////////////////////
8
 
//
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.
14
 
//
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
 
/////////////////////////////////////////////////////////////////////////////
20
 
// CVS Log
21
 
//
22
 
// $Log: DI_OldGame.c,v $
23
 
// Revision 1.2  2005/02/05 22:19:34  mschimek
24
 
// Completed l18n.
25
 
//
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.
30
 
//
31
 
// Revision 1.2  2004/11/15 23:03:19  michael
32
 
// *** empty log message ***
33
 
//
34
 
// Revision 1.1  2004/11/14 15:35:14  michael
35
 
// *** empty log message ***
36
 
//
37
 
// Revision 1.6  2002/06/13 12:10:24  adcockj
38
 
// Move to new Setings dialog for filers, video deint and advanced settings
39
 
//
40
 
// Revision 1.5  2002/01/04 01:38:56  lindsey
41
 
// Turned off the debug flag
42
 
//
43
 
// Revision 1.4  2001/12/20 03:42:58  lindsey
44
 
// Corrected processor detection
45
 
// Miscellaneous reorganization
46
 
//
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.
50
 
//
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.
54
 
// Commented the code
55
 
// Reorganized and edited to follow the coding guidelines
56
 
// Most importantly: Added a silly quote
57
 
// (Changes made on behalf of Lindsey Dubb)
58
 
//
59
 
// Revision 1.1  2001/07/30 08:25:22  adcockj
60
 
// Added Lindsey Dubb's method
61
 
//
62
 
/////////////////////////////////////////////////////////////////////////////
63
 
 
64
 
#include "windows.h"
65
 
#include "DS_Deinterlace.h"
66
 
//Z #include "..\help\helpids.h"
67
 
 
68
 
//uncomment to turn on display of the comb factor
69
 
//#define OLDGAME_DEBUG
70
 
 
71
 
/////////////////////////////////////////////////////////////////////////////
72
 
/*
73
 
Up and down, up and down.  Pardon me, but my lunch wants to join the sea.
74
 
                                            - from Shining Force
75
 
 
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
78
 
other algorithms.
79
 
 
80
 
Specifically:
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.
87
 
 
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.
101
 
*/
102
 
/////////////////////////////////////////////////////////////////////////////
103
 
 
104
 
/////////////////////////////////////////////////////////////////////////////
105
 
// Function prototypes
106
 
/////////////////////////////////////////////////////////////////////////////
107
 
 
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);
113
 
 
114
 
#ifdef OLDGAME_DEBUG
115
 
void __cdecl OldGameDebugStart(long NumPlugIns, DEINTERLACE_METHOD** OtherPlugins,
116
 
                               DEINTERLACEPLUGINSETSTATUS* SetStatus);
117
 
#endif
118
 
 
119
 
 
120
 
/////////////////////////////////////////////////////////////////////////////
121
 
// Begin plugin globals
122
 
/////////////////////////////////////////////////////////////////////////////
123
 
 
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.
127
 
 
128
 
static long                         gMaxComb = 300;
129
 
 
130
 
// When using a composite connector, crosstalk is bad enough that it's
131
 
// (almost) always worth averaging.
132
 
 
133
 
static long                         gDisableMotionChecking = FALSE;
134
 
 
135
 
// This is used to put up the comb factor for testing purposes.
136
 
 
137
 
#ifdef OLDGAME_DEBUG
138
 
static DEINTERLACEPLUGINSETSTATUS*  gPfnSetStatus = NULL;
139
 
#endif
140
 
 
141
 
static DEINTERLACE_METHOD OldGameMethod;
142
 
 
143
 
 
144
 
static SETTING DI_OldGameSettings[DI_OLDGAME_SETTING_LASTONE] =
145
 
{
146
 
    {
147
 
        N_("Maximum motion"), SLIDER, 0, &gMaxComb,
148
 
        300, 1, 5000, 1, 1,
149
 
        NULL,
150
 
        "DI_OldGame", "maxComb", NULL,
151
 
    },
152
 
    {
153
 
        N_("Composite mode"), ONOFF, 0, &gDisableMotionChecking,
154
 
        FALSE, 0, 1, 1, 1,
155
 
        NULL,
156
 
        "DI_OldGame", "CompositeMode", NULL,
157
 
    }
158
 
};
159
 
 
160
 
 
161
 
static DEINTERLACE_METHOD OldGameMethod =
162
 
{
163
 
    sizeof(DEINTERLACE_METHOD),
164
 
    DEINTERLACE_CURRENT_VERSION,
165
 
    N_("Old Game"), 
166
 
    NULL,     // It could make sense to use this with a resolution sensing adaptive filter
167
 
    TRUE, 
168
 
    FALSE, 
169
 
    NULL, 
170
 
    50, 
171
 
    60,
172
 
    DI_OLDGAME_SETTING_LASTONE,
173
 
    DI_OldGameSettings,
174
 
    INDEX_OLD_GAME,
175
 
    NULL,
176
 
#ifdef OLDGAME_DEBUG
177
 
    OldGameDebugStart,
178
 
#else
179
 
    NULL,
180
 
#endif
181
 
    NULL,
182
 
    NULL,
183
 
    1,
184
 
    0,
185
 
    0,
186
 
    -1,
187
 
    NULL,
188
 
    0,
189
 
    FALSE,
190
 
    TRUE,
191
 
    IDH_OLD_GAME,
192
 
};
193
 
 
194
 
 
195
 
/////////////////////////////////////////////////////////////////////////////
196
 
// Main code (included from Dl_OldGame.asm)
197
 
/////////////////////////////////////////////////////////////////////////////
198
 
 
199
 
#define IS_SSE 1
200
 
#include "DI_OldGame.asm"
201
 
#undef IS_SSE
202
 
 
203
 
#define IS_3DNOW 1
204
 
#include "DI_OldGame.asm"
205
 
#undef IS_3DNOW
206
 
 
207
 
#define IS_MMX 1
208
 
#include "DI_OldGame.asm"
209
 
#undef IS_MMX
210
 
 
211
 
 
212
 
////////////////////////////////////////////////////////////////////////////
213
 
// Start of utility code
214
 
/////////////////////////////////////////////////////////////////////////////
215
 
 
216
 
#ifdef OLDGAME_DEBUG
217
 
void __cdecl OldGameDebugStart(long NumPlugIns, DEINTERLACE_METHOD** OtherPlugins, DEINTERLACEPLUGINSETSTATUS* SetStatus)
218
 
{
219
 
    gPfnSetStatus = SetStatus;
220
 
}
221
 
#endif  // OLDGAME_DEBUG
222
 
 
223
 
 
224
 
DEINTERLACE_METHOD* DI_OldGame_GetDeinterlacePluginInfo(long CpuFeatureFlags)
225
 
{
226
 
    if ((CpuFeatureFlags & FEATURE_SSE) || (CpuFeatureFlags & FEATURE_MMXEXT))
227
 
    {
228
 
        OldGameMethod.pfnAlgorithm = OldGameFilter_SSE;
229
 
    }
230
 
    else if (CpuFeatureFlags & FEATURE_3DNOW)
231
 
    {
232
 
        OldGameMethod.pfnAlgorithm = OldGameFilter_3DNOW;
233
 
    }
234
 
    else
235
 
    {
236
 
        OldGameMethod.pfnAlgorithm = OldGameFilter_MMX;
237
 
    }
238
 
    return &OldGameMethod;
239
 
}
240
 
 
241
 
 
242
 
#if 0
243
 
 
244
 
 
245
 
BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
246
 
{
247
 
    return TRUE;
248
 
}
249
 
 
250
 
#endif /* 0 */