3 * Copyright (c) 2002 Tom Barry All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * Relicensed for GStreamer from GPL to LGPL with permit from Tom Barry.
23 * See: http://bugzilla.gnome.org/show_bug.cgi?id=163578
28 #define TopFirst IsOdd
35 #if defined(IS_MMXEXT)
36 #define SEFUNC(x) Search_Effort_MMXEXT_##x(int src_pitch, int dst_pitch, int rowsize, const unsigned char *pWeaveSrc, const unsigned char *pWeaveSrcP, unsigned char *pWeaveDest, int IsOdd, const unsigned char *pCopySrc, const unsigned char *pCopySrcP, int FldHeight)
37 #elif defined(IS_3DNOW)
38 #define SEFUNC(x) Search_Effort_3DNOW_##x(int src_pitch, int dst_pitch, int rowsize, const unsigned char *pWeaveSrc, const unsigned char *pWeaveSrcP, unsigned char *pWeaveDest, int IsOdd, const unsigned char *pCopySrc, const unsigned char *pCopySrcP, int FldHeight)
40 #define SEFUNC(x) Search_Effort_MMX_##x(int src_pitch, int dst_pitch, int rowsize, const unsigned char *pWeaveSrc, const unsigned char *pWeaveSrcP, unsigned char *pWeaveDest, int IsOdd, const unsigned char *pCopySrc, const unsigned char *pCopySrcP, int FldHeight)
42 #define SEFUNC(x) Search_Effort_C_##x(int src_pitch, int dst_pitch, int rowsize, const unsigned char *pWeaveSrc, const unsigned char *pWeaveSrcP, unsigned char *pWeaveDest, int IsOdd, const unsigned char *pCopySrc, const unsigned char *pCopySrcP, int FldHeight)
45 #include "TomsMoCompAll2.inc"
47 #define USE_STRANGE_BOB
49 #include "TomsMoCompAll2.inc"
51 #undef USE_STRANGE_BOB
54 #if defined(IS_MMXEXT)
55 #define SEFUNC(x) Search_Effort_MMXEXT_##x(src_pitch, dst_pitch, rowsize, pWeaveSrc, pWeaveSrcP, pWeaveDest, IsOdd, pCopySrc, pCopySrcP, FldHeight)
56 #elif defined(IS_3DNOW)
57 #define SEFUNC(x) Search_Effort_3DNOW_##x(src_pitch, dst_pitch, rowsize, pWeaveSrc, pWeaveSrcP, pWeaveDest, IsOdd, pCopySrc, pCopySrcP, FldHeight)
59 #define SEFUNC(x) Search_Effort_MMX_##x(src_pitch, dst_pitch, rowsize, pWeaveSrc, pWeaveSrcP, pWeaveDest, IsOdd, pCopySrc, pCopySrcP, FldHeight)
61 #define SEFUNC(x) Search_Effort_C_##x(src_pitch, dst_pitch, rowsize, pWeaveSrc, pWeaveSrcP, pWeaveDest, IsOdd, pCopySrc, pCopySrcP, FldHeight)
64 static void FUNCT_NAME(GstDeinterlaceMethod *d_method,
65 const GstDeinterlaceField* history, guint history_count,
66 GstBuffer *outbuf, int cur_field_idx)
68 GstDeinterlaceMethodTomsMoComp *self = GST_DEINTERLACE_METHOD_TOMSMOCOMP (d_method);
69 glong SearchEffort = self->search_effort;
70 gint UseStrangeBob = self->strange_bob;
72 const guint8 *pWeaveSrc;
73 const guint8 *pWeaveSrcP;
75 const guint8 *pCopySrc;
76 const guint8 *pCopySrcP;
83 if (cur_field_idx + 2 > history_count || cur_field_idx < 1) {
84 GstDeinterlaceMethod *backup_method;
86 backup_method = g_object_new (gst_deinterlace_method_linear_get_type(),
89 gst_deinterlace_method_setup (backup_method, d_method->format,
90 d_method->frame_width, d_method->frame_height);
91 gst_deinterlace_method_deinterlace_frame (backup_method,
92 history, history_count, outbuf, cur_field_idx);
94 g_object_unref (backup_method);
98 /* double stride do address just every odd/even scanline */
99 src_pitch = self->parent.row_stride[0]*2;
100 dst_pitch = self->parent.row_stride[0];
101 rowsize = self->parent.row_stride[0];
102 FldHeight = self->parent.frame_height / 2;
104 pCopySrc = GST_BUFFER_DATA(history[history_count-1].buf);
105 if (history[history_count - 1].flags & PICTURE_INTERLACED_BOTTOM)
107 pCopySrcP = GST_BUFFER_DATA(history[history_count-3].buf);
108 if (history[history_count - 3].flags & PICTURE_INTERLACED_BOTTOM)
109 pCopySrcP += rowsize;
110 pWeaveSrc = GST_BUFFER_DATA(history[history_count-2].buf);
111 if (history[history_count - 2].flags & PICTURE_INTERLACED_BOTTOM)
112 pWeaveSrc += rowsize;
113 pWeaveSrcP = GST_BUFFER_DATA(history[history_count-4].buf);
114 if (history[history_count - 4].flags & PICTURE_INTERLACED_BOTTOM)
115 pWeaveSrcP += rowsize;
117 /* use bottom field and interlace top field */
118 if (history[history_count-2].flags == PICTURE_INTERLACED_BOTTOM) {
121 // if we have an odd field we copy an even field and weave an odd field
122 pCopyDest = GST_BUFFER_DATA(outbuf);
123 pWeaveDest = pCopyDest + dst_pitch;
125 /* do it vice verca */
129 // if we have an even field we copy an odd field and weave an even field
130 pCopyDest = GST_BUFFER_DATA(outbuf) + dst_pitch;
131 pWeaveDest = GST_BUFFER_DATA(outbuf);
135 // copy 1st and last weave lines
136 Fieldcopy(pWeaveDest, pCopySrc, rowsize,
137 1, dst_pitch*2, src_pitch);
138 Fieldcopy(pWeaveDest+(FldHeight-1)*dst_pitch*2,
139 pCopySrc+(FldHeight-1)*src_pitch, rowsize,
140 1, dst_pitch*2, src_pitch);
142 #ifdef USE_VERTICAL_FILTER
143 // Vertical Filter currently not implemented for DScaler !!
144 // copy 1st and last lines the copy field
145 Fieldcopy(pCopyDest, pCopySrc, rowsize,
146 1, dst_pitch*2, src_pitch);
147 Fieldcopy(pCopyDest+(FldHeight-1)*dst_pitch*2,
148 pCopySrc+(FldHeight-1)*src_pitch, rowsize,
149 1, dst_pitch*2, src_pitch);
152 // copy all of the copy field
153 Fieldcopy(pCopyDest, pCopySrc, rowsize,
154 FldHeight, dst_pitch*2, src_pitch);
156 // then go fill in the hard part, being variously lazy depending upon
160 if (SearchEffort == 0)
164 else if (SearchEffort <= 1)
168 /* else if (SearchEffort <= 2)
173 else if (SearchEffort <= 3)
177 else if (SearchEffort <= 5)
181 else if (SearchEffort <= 9)
185 else if (SearchEffort <= 11)
189 else if (SearchEffort <= 13)
193 else if (SearchEffort <= 15)
197 else if (SearchEffort <= 19)
201 else if (SearchEffort <= 21)
212 if (SearchEffort == 0)
216 else if (SearchEffort <= 1)
220 /* else if (SearchEffort <= 2)
225 else if (SearchEffort <= 3)
229 else if (SearchEffort <= 5)
233 else if (SearchEffort <= 9)
237 else if (SearchEffort <= 11)
241 else if (SearchEffort <= 13)
245 else if (SearchEffort <= 15)
249 else if (SearchEffort <= 19)
253 else if (SearchEffort <= 21)
263 #if defined(BUILD_X86_ASM) && !defined(IS_C)
264 __asm__ __volatile__("emms");