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, const GstDeinterlaceField* history, guint history_count, GstBuffer *outbuf)
66 GstDeinterlaceMethodTomsMoComp *self = GST_DEINTERLACE_METHOD_TOMSMOCOMP (d_method);
67 glong SearchEffort = self->search_effort;
68 gint UseStrangeBob = self->strange_bob;
70 const guint8 *pWeaveSrc;
71 const guint8 *pWeaveSrcP;
73 const guint8 *pCopySrc;
74 const guint8 *pCopySrcP;
81 /* double stride do address just every odd/even scanline */
82 src_pitch = self->parent.row_stride[0]*2;
83 dst_pitch = self->parent.row_stride[0];
84 rowsize = self->parent.row_stride[0];
85 FldHeight = self->parent.frame_height / 2;
87 pCopySrc = GST_BUFFER_DATA(history[history_count-1].buf);
88 if (history[history_count - 1].flags & PICTURE_INTERLACED_BOTTOM)
90 pCopySrcP = GST_BUFFER_DATA(history[history_count-3].buf);
91 if (history[history_count - 3].flags & PICTURE_INTERLACED_BOTTOM)
93 pWeaveSrc = GST_BUFFER_DATA(history[history_count-2].buf);
94 if (history[history_count - 2].flags & PICTURE_INTERLACED_BOTTOM)
96 pWeaveSrcP = GST_BUFFER_DATA(history[history_count-4].buf);
97 if (history[history_count - 4].flags & PICTURE_INTERLACED_BOTTOM)
98 pWeaveSrcP += rowsize;
100 /* use bottom field and interlace top field */
101 if (history[history_count-2].flags == PICTURE_INTERLACED_BOTTOM) {
104 // if we have an odd field we copy an even field and weave an odd field
105 pCopyDest = GST_BUFFER_DATA(outbuf);
106 pWeaveDest = pCopyDest + dst_pitch;
108 /* do it vice verca */
112 // if we have an even field we copy an odd field and weave an even field
113 pCopyDest = GST_BUFFER_DATA(outbuf) + dst_pitch;
114 pWeaveDest = GST_BUFFER_DATA(outbuf);
118 // copy 1st and last weave lines
119 Fieldcopy(pWeaveDest, pCopySrc, rowsize,
120 1, dst_pitch*2, src_pitch);
121 Fieldcopy(pWeaveDest+(FldHeight-1)*dst_pitch*2,
122 pCopySrc+(FldHeight-1)*src_pitch, rowsize,
123 1, dst_pitch*2, src_pitch);
125 #ifdef USE_VERTICAL_FILTER
126 // Vertical Filter currently not implemented for DScaler !!
127 // copy 1st and last lines the copy field
128 Fieldcopy(pCopyDest, pCopySrc, rowsize,
129 1, dst_pitch*2, src_pitch);
130 Fieldcopy(pCopyDest+(FldHeight-1)*dst_pitch*2,
131 pCopySrc+(FldHeight-1)*src_pitch, rowsize,
132 1, dst_pitch*2, src_pitch);
135 // copy all of the copy field
136 Fieldcopy(pCopyDest, pCopySrc, rowsize,
137 FldHeight, dst_pitch*2, src_pitch);
139 // then go fill in the hard part, being variously lazy depending upon
143 if (SearchEffort == 0)
147 else if (SearchEffort <= 1)
151 /* else if (SearchEffort <= 2)
156 else if (SearchEffort <= 3)
160 else if (SearchEffort <= 5)
164 else if (SearchEffort <= 9)
168 else if (SearchEffort <= 11)
172 else if (SearchEffort <= 13)
176 else if (SearchEffort <= 15)
180 else if (SearchEffort <= 19)
184 else if (SearchEffort <= 21)
195 if (SearchEffort == 0)
199 else if (SearchEffort <= 1)
203 /* else if (SearchEffort <= 2)
208 else if (SearchEffort <= 3)
212 else if (SearchEffort <= 5)
216 else if (SearchEffort <= 9)
220 else if (SearchEffort <= 11)
224 else if (SearchEffort <= 13)
228 else if (SearchEffort <= 15)
232 else if (SearchEffort <= 19)
236 else if (SearchEffort <= 21)
246 #if defined(BUILD_X86_ASM) && !defined(IS_C)
247 __asm__ __volatile__("emms");