Git init
[framework/multimedia/gst-plugins-good0.10.git] / gst / deinterlace / tvtime / weavetff.c
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., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, 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
49 deinterlace_scanline_weave_packed (GstDeinterlaceSimpleMethod * self,
50     guint8 * out, const GstDeinterlaceScanlineData * scanlines)
51 {
52   memcpy (out, scanlines->m1, self->parent.row_stride[0]);
53 }
54
55 static void
56 deinterlace_scanline_weave_planar_y (GstDeinterlaceSimpleMethod * self,
57     guint8 * out, const GstDeinterlaceScanlineData * scanlines)
58 {
59   memcpy (out, scanlines->m1, self->parent.row_stride[0]);
60 }
61
62 static void
63 deinterlace_scanline_weave_planar_u (GstDeinterlaceSimpleMethod * self,
64     guint8 * out, const GstDeinterlaceScanlineData * scanlines)
65 {
66   memcpy (out, scanlines->m1, self->parent.row_stride[1]);
67 }
68
69 static void
70 deinterlace_scanline_weave_planar_v (GstDeinterlaceSimpleMethod * self,
71     guint8 * out, const GstDeinterlaceScanlineData * scanlines)
72 {
73   memcpy (out, scanlines->m1, self->parent.row_stride[2]);
74 }
75
76 static void
77 copy_scanline_packed (GstDeinterlaceSimpleMethod * self,
78     guint8 * out, const GstDeinterlaceScanlineData * scanlines)
79 {
80   /* FIXME: original code used m2 and m0 but this looks really bad */
81   if (scanlines->bottom_field) {
82     memcpy (out, scanlines->bb0, self->parent.row_stride[0]);
83   } else {
84     memcpy (out, scanlines->bb2, self->parent.row_stride[0]);
85   }
86 }
87
88 static void
89 copy_scanline_planar_y (GstDeinterlaceSimpleMethod * self,
90     guint8 * out, const GstDeinterlaceScanlineData * scanlines)
91 {
92   /* FIXME: original code used m2 and m0 but this looks really bad */
93   if (scanlines->bottom_field) {
94     memcpy (out, scanlines->bb0, self->parent.row_stride[0]);
95   } else {
96     memcpy (out, scanlines->bb2, self->parent.row_stride[0]);
97   }
98 }
99
100 static void
101 copy_scanline_planar_u (GstDeinterlaceSimpleMethod * self,
102     guint8 * out, const GstDeinterlaceScanlineData * scanlines)
103 {
104   /* FIXME: original code used m2 and m0 but this looks really bad */
105   if (scanlines->bottom_field) {
106     memcpy (out, scanlines->bb0, self->parent.row_stride[1]);
107   } else {
108     memcpy (out, scanlines->bb2, self->parent.row_stride[1]);
109   }
110 }
111
112 static void
113 copy_scanline_planar_v (GstDeinterlaceSimpleMethod * self,
114     guint8 * out, const GstDeinterlaceScanlineData * scanlines)
115 {
116   /* FIXME: original code used m2 and m0 but this looks really bad */
117   if (scanlines->bottom_field) {
118     memcpy (out, scanlines->bb0, self->parent.row_stride[2]);
119   } else {
120     memcpy (out, scanlines->bb2, self->parent.row_stride[2]);
121   }
122 }
123
124 G_DEFINE_TYPE (GstDeinterlaceMethodWeaveTFF, gst_deinterlace_method_weave_tff,
125     GST_TYPE_DEINTERLACE_SIMPLE_METHOD);
126
127 static void
128 gst_deinterlace_method_weave_tff_class_init (GstDeinterlaceMethodWeaveTFFClass *
129     klass)
130 {
131   GstDeinterlaceMethodClass *dim_class = (GstDeinterlaceMethodClass *) klass;
132   GstDeinterlaceSimpleMethodClass *dism_class =
133       (GstDeinterlaceSimpleMethodClass *) klass;
134
135   dim_class->fields_required = 3;
136   dim_class->name = "Progressive: Top Field First";
137   dim_class->nick = "weavetff";
138   dim_class->latency = 0;
139
140   dism_class->interpolate_scanline_ayuv = deinterlace_scanline_weave_packed;
141   dism_class->interpolate_scanline_yuy2 = deinterlace_scanline_weave_packed;
142   dism_class->interpolate_scanline_yvyu = deinterlace_scanline_weave_packed;
143   dism_class->interpolate_scanline_uyvy = deinterlace_scanline_weave_packed;
144   dism_class->interpolate_scanline_nv12 = deinterlace_scanline_weave_packed;
145   dism_class->interpolate_scanline_nv21 = deinterlace_scanline_weave_packed;
146   dism_class->interpolate_scanline_argb = deinterlace_scanline_weave_packed;
147   dism_class->interpolate_scanline_abgr = deinterlace_scanline_weave_packed;
148   dism_class->interpolate_scanline_rgba = deinterlace_scanline_weave_packed;
149   dism_class->interpolate_scanline_bgra = deinterlace_scanline_weave_packed;
150   dism_class->interpolate_scanline_rgb = deinterlace_scanline_weave_packed;
151   dism_class->interpolate_scanline_bgr = deinterlace_scanline_weave_packed;
152   dism_class->interpolate_scanline_planar_y =
153       deinterlace_scanline_weave_planar_y;
154   dism_class->interpolate_scanline_planar_u =
155       deinterlace_scanline_weave_planar_u;
156   dism_class->interpolate_scanline_planar_v =
157       deinterlace_scanline_weave_planar_v;
158
159   dism_class->copy_scanline_ayuv = copy_scanline_packed;
160   dism_class->copy_scanline_yuy2 = copy_scanline_packed;
161   dism_class->copy_scanline_yvyu = copy_scanline_packed;
162   dism_class->copy_scanline_uyvy = copy_scanline_packed;
163   dism_class->copy_scanline_nv12 = copy_scanline_packed;
164   dism_class->copy_scanline_nv21 = copy_scanline_packed;
165   dism_class->copy_scanline_argb = copy_scanline_packed;
166   dism_class->copy_scanline_abgr = copy_scanline_packed;
167   dism_class->copy_scanline_rgba = copy_scanline_packed;
168   dism_class->copy_scanline_bgra = copy_scanline_packed;
169   dism_class->copy_scanline_rgb = copy_scanline_packed;
170   dism_class->copy_scanline_bgr = copy_scanline_packed;
171   dism_class->copy_scanline_planar_y = copy_scanline_planar_y;
172   dism_class->copy_scanline_planar_u = copy_scanline_planar_u;
173   dism_class->copy_scanline_planar_v = copy_scanline_planar_v;
174 }
175
176 static void
177 gst_deinterlace_method_weave_tff_init (GstDeinterlaceMethodWeaveTFF * self)
178 {
179 }