• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Weave frames, top-field-first.
3  * Copyright (C) 2003 Billy Biggs <vektor@dumbterm.net>.
4  * Copyright (C) 2008,2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 /*
23  * Relicensed for GStreamer from GPL to LGPL with permit from Billy Biggs.
24  * See: http://bugzilla.gnome.org/show_bug.cgi?id=163578
25  */
26 
27 
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31 
32 #include "gstdeinterlacemethod.h"
33 #include <string.h>
34 
35 #define GST_TYPE_DEINTERLACE_METHOD_WEAVE_TFF	(gst_deinterlace_method_weave_tff_get_type ())
36 #define GST_IS_DEINTERLACE_METHOD_WEAVE_TFF(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_METHOD_WEAVE_TFF))
37 #define GST_IS_DEINTERLACE_METHOD_WEAVE_TFF_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_METHOD_WEAVE_TFF))
38 #define GST_DEINTERLACE_METHOD_WEAVE_TFF_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_METHOD_WEAVE_TFF, GstDeinterlaceMethodWeaveTFFClass))
39 #define GST_DEINTERLACE_METHOD_WEAVE_TFF(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_METHOD_WEAVE_TFF, GstDeinterlaceMethodWeaveTFF))
40 #define GST_DEINTERLACE_METHOD_WEAVE_TFF_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_METHOD_WEAVE_TFF, GstDeinterlaceMethodWeaveTFFClass))
41 #define GST_DEINTERLACE_METHOD_WEAVE_TFF_CAST(obj)	((GstDeinterlaceMethodWeaveTFF*)(obj))
42 
43 GType gst_deinterlace_method_weave_tff_get_type (void);
44 
45 typedef GstDeinterlaceSimpleMethod GstDeinterlaceMethodWeaveTFF;
46 typedef GstDeinterlaceSimpleMethodClass GstDeinterlaceMethodWeaveTFFClass;
47 
48 static void
deinterlace_scanline_weave_packed(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)49 deinterlace_scanline_weave_packed (GstDeinterlaceSimpleMethod * self,
50     guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
51 {
52   if (scanlines->m1 == NULL) {
53     memcpy (out, scanlines->t0, size);
54   } else {
55     memcpy (out, scanlines->m1, size);
56   }
57 }
58 
59 static void
deinterlace_scanline_weave_planar_y(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)60 deinterlace_scanline_weave_planar_y (GstDeinterlaceSimpleMethod * self,
61     guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
62 {
63   if (scanlines->m1 == NULL) {
64     memcpy (out, scanlines->t0, size);
65   } else {
66     memcpy (out, scanlines->m1, size);
67   }
68 }
69 
70 static void
deinterlace_scanline_weave_planar_u(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)71 deinterlace_scanline_weave_planar_u (GstDeinterlaceSimpleMethod * self,
72     guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
73 {
74   if (scanlines->m1 == NULL) {
75     memcpy (out, scanlines->t0, size);
76   } else {
77     memcpy (out, scanlines->m1, size);
78   }
79 }
80 
81 static void
deinterlace_scanline_weave_planar_v(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)82 deinterlace_scanline_weave_planar_v (GstDeinterlaceSimpleMethod * self,
83     guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
84 {
85   if (scanlines->m1 == NULL) {
86     memcpy (out, scanlines->t0, size);
87   } else {
88     memcpy (out, scanlines->m1, size);
89   }
90 }
91 
92 static void
copy_scanline_packed(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)93 copy_scanline_packed (GstDeinterlaceSimpleMethod * self,
94     guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
95 {
96   memcpy (out, scanlines->m0, size);
97 }
98 
99 static void
copy_scanline_planar_y(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)100 copy_scanline_planar_y (GstDeinterlaceSimpleMethod * self,
101     guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
102 {
103   memcpy (out, scanlines->m0, size);
104 }
105 
106 static void
copy_scanline_planar_u(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)107 copy_scanline_planar_u (GstDeinterlaceSimpleMethod * self,
108     guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
109 {
110   memcpy (out, scanlines->m0, size);
111 }
112 
113 static void
copy_scanline_planar_v(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)114 copy_scanline_planar_v (GstDeinterlaceSimpleMethod * self,
115     guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
116 {
117   memcpy (out, scanlines->m0, size);
118 }
119 
120 G_DEFINE_TYPE (GstDeinterlaceMethodWeaveTFF, gst_deinterlace_method_weave_tff,
121     GST_TYPE_DEINTERLACE_SIMPLE_METHOD);
122 
123 static void
gst_deinterlace_method_weave_tff_class_init(GstDeinterlaceMethodWeaveTFFClass * klass)124 gst_deinterlace_method_weave_tff_class_init (GstDeinterlaceMethodWeaveTFFClass *
125     klass)
126 {
127   GstDeinterlaceMethodClass *dim_class = (GstDeinterlaceMethodClass *) klass;
128   GstDeinterlaceSimpleMethodClass *dism_class =
129       (GstDeinterlaceSimpleMethodClass *) klass;
130 
131   dim_class->fields_required = 2;
132   dim_class->name = "Progressive: Top Field First";
133   dim_class->nick = "weavetff";
134   dim_class->latency = 1;
135 
136   dism_class->interpolate_scanline_ayuv = deinterlace_scanline_weave_packed;
137   dism_class->interpolate_scanline_yuy2 = deinterlace_scanline_weave_packed;
138   dism_class->interpolate_scanline_yvyu = deinterlace_scanline_weave_packed;
139   dism_class->interpolate_scanline_uyvy = deinterlace_scanline_weave_packed;
140   dism_class->interpolate_scanline_nv12 = deinterlace_scanline_weave_packed;
141   dism_class->interpolate_scanline_nv21 = deinterlace_scanline_weave_packed;
142   dism_class->interpolate_scanline_argb = deinterlace_scanline_weave_packed;
143   dism_class->interpolate_scanline_abgr = deinterlace_scanline_weave_packed;
144   dism_class->interpolate_scanline_rgba = deinterlace_scanline_weave_packed;
145   dism_class->interpolate_scanline_bgra = deinterlace_scanline_weave_packed;
146   dism_class->interpolate_scanline_rgb = deinterlace_scanline_weave_packed;
147   dism_class->interpolate_scanline_bgr = deinterlace_scanline_weave_packed;
148   dism_class->interpolate_scanline_planar_y =
149       deinterlace_scanline_weave_planar_y;
150   dism_class->interpolate_scanline_planar_u =
151       deinterlace_scanline_weave_planar_u;
152   dism_class->interpolate_scanline_planar_v =
153       deinterlace_scanline_weave_planar_v;
154 
155   dism_class->copy_scanline_ayuv = copy_scanline_packed;
156   dism_class->copy_scanline_yuy2 = copy_scanline_packed;
157   dism_class->copy_scanline_yvyu = copy_scanline_packed;
158   dism_class->copy_scanline_uyvy = copy_scanline_packed;
159   dism_class->copy_scanline_nv12 = copy_scanline_packed;
160   dism_class->copy_scanline_nv21 = copy_scanline_packed;
161   dism_class->copy_scanline_argb = copy_scanline_packed;
162   dism_class->copy_scanline_abgr = copy_scanline_packed;
163   dism_class->copy_scanline_rgba = copy_scanline_packed;
164   dism_class->copy_scanline_bgra = copy_scanline_packed;
165   dism_class->copy_scanline_rgb = copy_scanline_packed;
166   dism_class->copy_scanline_bgr = copy_scanline_packed;
167   dism_class->copy_scanline_planar_y = copy_scanline_planar_y;
168   dism_class->copy_scanline_planar_u = copy_scanline_planar_u;
169   dism_class->copy_scanline_planar_v = copy_scanline_planar_v;
170 }
171 
172 static void
gst_deinterlace_method_weave_tff_init(GstDeinterlaceMethodWeaveTFF * self)173 gst_deinterlace_method_weave_tff_init (GstDeinterlaceMethodWeaveTFF * self)
174 {
175 }
176