1 /**
2 * Copyright (c) 2000 John Adcock, Tom Barry, Steve Grimm All rights reserved.
3 * port copyright (c) 2003 Miguel Freitas
4 *
5 * This code is ported from DScaler: http://deinterlace.sf.net/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA.
20 */
21
22 #ifdef HAVE_CONFIG_H
23 # include "config.h"
24 #endif
25
26 #include <stdio.h>
27
28 #if HAVE_INTTYPES_H
29 #include <inttypes.h>
30 #else
31 #include <stdint.h>
32 #endif
33
34 #include <xine/attributes.h>
35 #include <xine/xineutils.h>
36 #include "xine_mmx.h"
37 #include "deinterlace.h"
38 #include "speedtools.h"
39 #include "speedy.h"
40 #include "plugins.h"
41
42 // debugging feature
43 // output the value of mm4 at this point which is pink where we will weave
44 // and green were we are going to bob
45 // uncomment next line to see this
46 //#define CHECK_BOBWEAVE
47
48 #define GREEDYTWOFRAMETHRESHOLD 4
49 #define GREEDYTWOFRAMETHRESHOLD2 8
50
51 #if defined(ARCH_X86)
52 #define IS_MMXEXT 1
53 #include "greedy2frame_template.c"
54 #undef IS_MMXEXT
55
56 #include "greedy2frame_template_sse2.c"
57 #endif /* ARCH_X86 */
58
DeinterlaceGreedy2Frame(uint8_t * output,int outstride,deinterlace_frame_data_t * data,int bottom_field,int second_field,int width,int height)59 static void DeinterlaceGreedy2Frame(uint8_t *output, int outstride,
60 deinterlace_frame_data_t *data,
61 int bottom_field, int second_field, int width, int height )
62
63 {
64 #if defined(ARCH_X86)
65
66 if (xine_mm_accel() & MM_ACCEL_X86_SSE2) {
67 if (((uintptr_t)output & 15) || (outstride & 15) ||
68 width & 7 ||
69 ((uintptr_t)data->f0 & 15) || ((uintptr_t)data->f1 & 15)) {
70 /*
71 * instead of using an unaligned sse2 version just fall back to mmx
72 * which has no alignment restriction (though might be slow unaliged,
73 * but shouldn't hit this hopefully anyway). Plus in my experiments this
74 * was at least as fast as a naive unaligned sse2 version anyway (due to
75 * the inability to use streaming stores).
76 */
77 DeinterlaceGreedy2Frame_MMXEXT(output, outstride, data,
78 bottom_field, second_field, width, height );
79 } else {
80 DeinterlaceGreedy2Frame_SSE2(output, outstride, data,
81 bottom_field, second_field, width, height );
82 }
83 }
84 else {
85 DeinterlaceGreedy2Frame_MMXEXT(output, outstride, data,
86 bottom_field, second_field, width, height );
87 /* could fall back to 3dnow/mmx here too */
88 }
89 #endif /*ARCH_X86 */
90 }
91
92
93 static const deinterlace_method_t greedy2framemethod =
94 {
95 "Greedy 2-frame (DScaler)",
96 "Greedy2Frame",
97 4,
98 MM_ACCEL_X86_MMXEXT,
99 0,
100 0,
101 0,
102 0,
103 DeinterlaceGreedy2Frame,
104 1,
105 NULL
106 };
107
greedy2frame_get_method(void)108 const deinterlace_method_t *greedy2frame_get_method( void )
109 {
110 return &greedy2framemethod;
111 }
112
113