4 * Copyright (c) 2000 Tom Barry All rights reserved.
5 * mmx.h port copyright (c) 2002 Billy Biggs <vektor@dumbterm.net>.
7 * Copyright (C) 2008,2010 Sebastian Dröge <slomo@collabora.co.uk>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
26 * Relicensed for GStreamer from GPL to LGPL with permit from Tom Barry
28 * See: http://bugzilla.gnome.org/show_bug.cgi?id=163578
35 #include "gstdeinterlacemethod.h"
40 #define GST_TYPE_DEINTERLACE_METHOD_GREEDY_L (gst_deinterlace_method_greedy_l_get_type ())
41 #define GST_IS_DEINTERLACE_METHOD_GREEDY_L(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_METHOD_GREEDY_L))
42 #define GST_IS_DEINTERLACE_METHOD_GREEDY_L_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_METHOD_GREEDY_L))
43 #define GST_DEINTERLACE_METHOD_GREEDY_L_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_METHOD_GREEDY_L, GstDeinterlaceMethodGreedyLClass))
44 #define GST_DEINTERLACE_METHOD_GREEDY_L(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_METHOD_GREEDY_L, GstDeinterlaceMethodGreedyL))
45 #define GST_DEINTERLACE_METHOD_GREEDY_L_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_METHOD_GREEDY_L, GstDeinterlaceMethodGreedyLClass))
46 #define GST_DEINTERLACE_METHOD_GREEDY_L_CAST(obj) ((GstDeinterlaceMethodGreedyL*)(obj))
48 GType gst_deinterlace_method_greedy_l_get_type (void);
52 GstDeinterlaceSimpleMethod parent;
55 } GstDeinterlaceMethodGreedyL;
57 typedef GstDeinterlaceSimpleMethodClass GstDeinterlaceMethodGreedyLClass;
59 // This is a simple lightweight DeInterlace method that uses little CPU time
60 // but gives very good results for low or intermedite motion.
61 // It defers frames by one field, but that does not seem to produce noticeable
64 // The method used is to take either the older or newer weave pixel depending
65 // upon which give the smaller comb factor, and then clip to avoid large damage
68 // I'd intended this to be part of a larger more elaborate method added to
69 // Blended Clip but this give too good results for the CPU to ignore here.
72 deinterlace_greedy_interpolate_scanline_orc (GstDeinterlaceSimpleMethod * self,
73 guint8 * out, const GstDeinterlaceScanlineData * scanlines)
75 /* FIXME - is this safe or just a hack? */
76 guint max_comb = GST_DEINTERLACE_METHOD_GREEDY_L (self)->max_comb;
78 deinterlace_line_greedy (out, scanlines->m3, scanlines->t2, scanlines->b2,
79 scanlines->m1, max_comb, self->parent.row_stride[0]);
83 deinterlace_greedy_interpolate_scanline_orc_planar_u (GstDeinterlaceSimpleMethod
84 * self, guint8 * out, const GstDeinterlaceScanlineData * scanlines)
86 /* FIXME - is this safe or just a hack? */
87 guint max_comb = GST_DEINTERLACE_METHOD_GREEDY_L (self)->max_comb;
89 deinterlace_line_greedy (out, scanlines->m3, scanlines->t2, scanlines->b2,
90 scanlines->m1, max_comb, self->parent.row_stride[1]);
94 deinterlace_greedy_interpolate_scanline_orc_planar_v (GstDeinterlaceSimpleMethod
95 * self, guint8 * out, const GstDeinterlaceScanlineData * scanlines)
97 /* FIXME - is this safe or just a hack? */
98 guint max_comb = GST_DEINTERLACE_METHOD_GREEDY_L (self)->max_comb;
100 deinterlace_line_greedy (out, scanlines->m3, scanlines->t2, scanlines->b2,
101 scanlines->m1, max_comb, self->parent.row_stride[2]);
105 deinterlace_greedy_copy_scanline (GstDeinterlaceSimpleMethod * self,
106 guint8 * out, const GstDeinterlaceScanlineData * scanlines)
108 memcpy (out, scanlines->m2, self->parent.row_stride[0]);
112 deinterlace_greedy_copy_scanline_planar_u (GstDeinterlaceSimpleMethod * self,
113 guint8 * out, const GstDeinterlaceScanlineData * scanlines)
115 memcpy (out, scanlines->m2, self->parent.row_stride[1]);
119 deinterlace_greedy_copy_scanline_planar_v (GstDeinterlaceSimpleMethod * self,
120 guint8 * out, const GstDeinterlaceScanlineData * scanlines)
122 memcpy (out, scanlines->m2, self->parent.row_stride[2]);
125 G_DEFINE_TYPE (GstDeinterlaceMethodGreedyL, gst_deinterlace_method_greedy_l,
126 GST_TYPE_DEINTERLACE_SIMPLE_METHOD);
135 gst_deinterlace_method_greedy_l_set_property (GObject * object, guint prop_id,
136 const GValue * value, GParamSpec * pspec)
138 GstDeinterlaceMethodGreedyL *self = GST_DEINTERLACE_METHOD_GREEDY_L (object);
142 self->max_comb = g_value_get_uint (value);
145 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
150 gst_deinterlace_method_greedy_l_get_property (GObject * object, guint prop_id,
151 GValue * value, GParamSpec * pspec)
153 GstDeinterlaceMethodGreedyL *self = GST_DEINTERLACE_METHOD_GREEDY_L (object);
157 g_value_set_uint (value, self->max_comb);
160 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
165 gst_deinterlace_method_greedy_l_class_init (GstDeinterlaceMethodGreedyLClass *
168 GstDeinterlaceMethodClass *dim_class = (GstDeinterlaceMethodClass *) klass;
169 GstDeinterlaceSimpleMethodClass *dism_class =
170 (GstDeinterlaceSimpleMethodClass *) klass;
171 GObjectClass *gobject_class = (GObjectClass *) klass;
173 gobject_class->set_property = gst_deinterlace_method_greedy_l_set_property;
174 gobject_class->get_property = gst_deinterlace_method_greedy_l_get_property;
176 g_object_class_install_property (gobject_class, PROP_MAX_COMB,
177 g_param_spec_uint ("max-comb",
179 "Max Comb", 0, 255, 15, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
182 dim_class->fields_required = 4;
183 dim_class->name = "Motion Adaptive: Simple Detection";
184 dim_class->nick = "greedyl";
185 dim_class->latency = 1;
187 dism_class->interpolate_scanline_ayuv =
188 deinterlace_greedy_interpolate_scanline_orc;
189 dism_class->interpolate_scanline_yuy2 =
190 deinterlace_greedy_interpolate_scanline_orc;
191 dism_class->interpolate_scanline_yvyu =
192 deinterlace_greedy_interpolate_scanline_orc;
193 dism_class->interpolate_scanline_uyvy =
194 deinterlace_greedy_interpolate_scanline_orc;
195 dism_class->interpolate_scanline_argb =
196 deinterlace_greedy_interpolate_scanline_orc;
197 dism_class->interpolate_scanline_abgr =
198 deinterlace_greedy_interpolate_scanline_orc;
199 dism_class->interpolate_scanline_rgba =
200 deinterlace_greedy_interpolate_scanline_orc;
201 dism_class->interpolate_scanline_bgra =
202 deinterlace_greedy_interpolate_scanline_orc;
203 dism_class->interpolate_scanline_rgb =
204 deinterlace_greedy_interpolate_scanline_orc;
205 dism_class->interpolate_scanline_bgr =
206 deinterlace_greedy_interpolate_scanline_orc;
207 dism_class->interpolate_scanline_planar_y =
208 deinterlace_greedy_interpolate_scanline_orc;
209 dism_class->interpolate_scanline_planar_u =
210 deinterlace_greedy_interpolate_scanline_orc_planar_u;
211 dism_class->interpolate_scanline_planar_v =
212 deinterlace_greedy_interpolate_scanline_orc_planar_v;
214 dism_class->copy_scanline_ayuv = deinterlace_greedy_copy_scanline;
215 dism_class->copy_scanline_yuy2 = deinterlace_greedy_copy_scanline;
216 dism_class->copy_scanline_yvyu = deinterlace_greedy_copy_scanline;
217 dism_class->copy_scanline_uyvy = deinterlace_greedy_copy_scanline;
218 dism_class->copy_scanline_argb = deinterlace_greedy_copy_scanline;
219 dism_class->copy_scanline_abgr = deinterlace_greedy_copy_scanline;
220 dism_class->copy_scanline_rgba = deinterlace_greedy_copy_scanline;
221 dism_class->copy_scanline_bgra = deinterlace_greedy_copy_scanline;
222 dism_class->copy_scanline_rgb = deinterlace_greedy_copy_scanline;
223 dism_class->copy_scanline_bgr = deinterlace_greedy_copy_scanline;
224 dism_class->copy_scanline_planar_y = deinterlace_greedy_copy_scanline;
225 dism_class->copy_scanline_planar_u =
226 deinterlace_greedy_copy_scanline_planar_u;
227 dism_class->copy_scanline_planar_v =
228 deinterlace_greedy_copy_scanline_planar_v;
232 gst_deinterlace_method_greedy_l_init (GstDeinterlaceMethodGreedyL * self)