48
73
// Revision 1.6 2001/07/13 16:13:33 adcockj
49
74
// Added CVS tags and removed tabs
51
/////////////////////////////////////////////////////////////////////////////
76
///////////////////////////////////////////////////////////////////////////*/
53
78
#include "windows.h"
54
79
#include "DS_Deinterlace.h"
55
//Z #include "..\help\helpids.h"
57
long GreedyTwoFrameThreshold = 4;
58
long GreedyTwoFrameThreshold2 = 8;
61
#include "DI_Greedy2Frame.asm"
65
#include "DI_Greedy2Frame.asm"
69
#include "DI_Greedy2Frame.asm"
72
////////////////////////////////////////////////////////////////////////////
81
extern int GreedyTwoFrameThreshold;
83
SIMD_FN_PROTOS (DEINTERLACE_FUNC, DeinterlaceGreedy2Frame);
85
#if SIMD & (CPU_FEATURE_MMX | CPU_FEATURE_3DNOW | \
86
CPU_FEATURE_SSE | CPU_FEATURE_SSE2 | CPU_FEATURE_ALTIVEC)
88
/*/////////////////////////////////////////////////////////////////////////////
89
// Field 1 | Field 2 | Field 3 | Field 4 |
96
output the value of mm4 at this point which is pink where we will weave
97
and green were we are going to bob */
98
#define CHECK_BOBWEAVE 0
100
static always_inline v32
108
// XXX emulates vcmpgtu8, AVEC has this instruction
109
t = vsr1u8 (vabsdiffu8 (a, b));
110
t = (vu8) vcmpgt8 ((v8) t, thresh);
112
t = vand (t, vsplatu8_127); // get rid of any sign bit
114
// XXX can be replaced by logic ops.
115
return vand ((v32) vcmpgt32 ((v32) t, vsplat32_1), c);
119
SIMD_NAME (DeinterlaceGreedy2Frame) (TDeinterlaceInfo *pInfo)
121
v8 qwGreedyTwoFrameThreshold;
127
unsigned int byte_width;
129
unsigned long dst_padding;
130
unsigned long src_padding;
131
unsigned long dst_bpl;
132
unsigned long src_bpl;
134
if (SIMD == CPU_FEATURE_SSE2) {
135
if (((unsigned long) pInfo->Overlay |
136
(unsigned long) pInfo->PictureHistory[0]->pData |
137
(unsigned long) pInfo->PictureHistory[1]->pData |
138
(unsigned long) pInfo->PictureHistory[2]->pData |
139
(unsigned long) pInfo->PictureHistory[3]->pData |
140
(unsigned long) pInfo->OverlayPitch |
141
(unsigned long) pInfo->InputPitch |
142
(unsigned long) pInfo->LineLength) & 15)
143
return DeinterlaceGreedy2Frame_SSE (pInfo);
146
qwGreedyTwoFrameThreshold = vsplat8 (GreedyTwoFrameThreshold);
148
byte_width = pInfo->LineLength;
150
dst_bpl = pInfo->OverlayPitch;
151
src_bpl = pInfo->InputPitch;
153
Dest = pInfo->Overlay;
155
M1 = pInfo->PictureHistory[0]->pData;
156
T1 = pInfo->PictureHistory[1]->pData;
157
M0 = pInfo->PictureHistory[2]->pData;
158
T0 = pInfo->PictureHistory[3]->pData;
160
if (!(pInfo->PictureHistory[0]->Flags & PICTURE_INTERLACED_ODD)) {
161
copy_line (Dest, M1, byte_width);
164
M1 = (const uint8_t *) pInfo->PictureHistory[0]->pData + src_bpl;
165
M0 = (const uint8_t *) pInfo->PictureHistory[2]->pData + src_bpl;
168
dst_padding = dst_bpl * 2 - byte_width;
169
src_padding = src_bpl - byte_width;
171
for (height = pInfo->FieldHeight - 1; height > 0; --height) {
174
for (count = byte_width / sizeof (vu8); count > 0; --count) {
175
vu8 m0, m1, t0, t1, b0, b1, avg, mm4;
179
b1 = vload (T1, src_bpl);
182
/* Always use the most recent data verbatim. By definition it's
183
correct (it'd be shown on an interlaced display) and our job is
184
to fill in the spaces between the new lines. */
185
vstorent (Dest, 0, t1);
187
avg = fast_vavgu8 (t1, b1);
194
/* if we have a good processor then make mm0 the average of M1
195
and M0 which should make weave look better when there is
196
small amounts of movement */
197
if (SIMD != CPU_FEATURE_MMX)
198
m1 = vavgu8 (m1, m0);
200
/* if |M1-M0| > Threshold we want dword worth of twos */
201
sum = thresh_cmp (m1, m0, qwGreedyTwoFrameThreshold, vsplat32_2);
203
/* if |T1-T0| > Threshold we want dword worth of ones */
205
sum = vadd32 (sum, thresh_cmp (t1, t0, qwGreedyTwoFrameThreshold,
208
/* if |B1-B0| > Threshold we want dword worth of ones */
209
b0 = vload (T0, src_bpl);
211
sum = vadd32 (sum, thresh_cmp (b1, b0, qwGreedyTwoFrameThreshold,
214
mm4 = (vu8) vcmpgt32 (sum, vsplat32_2);
217
output the value of mm4 at this point which is pink
218
where we will weave and green were we are going to bob */
220
vstorent (Dest, dst_bpl, mm4);
222
vstorent (Dest, dst_bpl, vsel (mm4, m1, avg));
224
Dest += sizeof (vu8);
234
if (pInfo->PictureHistory[0]->Flags & PICTURE_INTERLACED_ODD) {
235
copy_line (Dest, T1, byte_width);
237
copy_line (Dest, M1, byte_width);
239
copy_line (Dest, T1, byte_width);
249
int GreedyTwoFrameThreshold = 4;
252
/*//////////////////////////////////////////////////////////////////////////
73
253
// Start of Settings related code
74
/////////////////////////////////////////////////////////////////////////////
75
SETTING DI_Greedy2FrameSettings[DI_GREEDY2FRAME_SETTING_LASTONE] =
254
//////////////////////////////////////////////////////////////////////////*/
256
DI_Greedy2FrameSettings [] = {
78
N_("Greedy 2 Frame Luma Threshold"), SLIDER, 0, &GreedyTwoFrameThreshold,
258
N_("Greedy 2 Frame Luma Threshold"), SLIDER, 0,
259
&GreedyTwoFrameThreshold,
81
262
"Deinterlace", "GreedyTwoFrameThreshold", NULL,
84
N_("Greedy 2 Frame Chroma Threshold"), SLIDER, 0, &GreedyTwoFrameThreshold2,
87
"Deinterlace", "GreedyTwoFrameThreshold2", NULL,
92
DEINTERLACE_METHOD Greedy2FrameMethod =
94
sizeof(DEINTERLACE_METHOD),
266
static const DEINTERLACE_METHOD
267
Greedy2FrameMethod = {
268
sizeof (DEINTERLACE_METHOD),
95
269
DEINTERLACE_CURRENT_VERSION,
96
270
N_("Greedy 2 Frame"),
100
DeinterlaceGreedy2Frame_MMX,
274
/* pfnAlgorithm */ NULL,
103
DI_GREEDY2FRAME_SETTING_LASTONE,
277
N_ELEMENTS (DI_Greedy2FrameSettings),
104
278
DI_Greedy2FrameSettings,
105
279
INDEX_VIDEO_GREEDY2FRAME,