1 /*
2 * Weave frames, bottom-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 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include "gstdeinterlacemethod.h"
32 #include <string.h>
33
34 #define GST_TYPE_DEINTERLACE_METHOD_WEAVE_BFF (gst_deinterlace_method_weave_bff_get_type ())
35 #define GST_IS_DEINTERLACE_METHOD_WEAVE_BFF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_METHOD_WEAVE_BFF))
36 #define GST_IS_DEINTERLACE_METHOD_WEAVE_BFF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_METHOD_WEAVE_BFF))
37 #define GST_DEINTERLACE_METHOD_WEAVE_BFF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_METHOD_WEAVE_BFF, GstDeinterlaceMethodWeaveBFFClass))
38 #define GST_DEINTERLACE_METHOD_WEAVE_BFF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_METHOD_WEAVE_BFF, GstDeinterlaceMethodWeaveBFF))
39 #define GST_DEINTERLACE_METHOD_WEAVE_BFF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_METHOD_WEAVE_BFF, GstDeinterlaceMethodWeaveBFFClass))
40 #define GST_DEINTERLACE_METHOD_WEAVE_BFF_CAST(obj) ((GstDeinterlaceMethodWeaveBFF*)(obj))
41
42 GType gst_deinterlace_method_weave_bff_get_type (void);
43
44 typedef GstDeinterlaceSimpleMethod GstDeinterlaceMethodWeaveBFF;
45 typedef GstDeinterlaceSimpleMethodClass GstDeinterlaceMethodWeaveBFFClass;
46
47 static void
deinterlace_scanline_weave_packed(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)48 deinterlace_scanline_weave_packed (GstDeinterlaceSimpleMethod * self,
49 guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
50 {
51 if (scanlines->m1 == NULL) {
52 memcpy (out, scanlines->b0, size);
53 } else {
54 memcpy (out, scanlines->m1, size);
55 }
56 }
57
58 static void
deinterlace_scanline_weave_planar_y(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)59 deinterlace_scanline_weave_planar_y (GstDeinterlaceSimpleMethod * self,
60 guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
61 {
62 if (scanlines->m1 == NULL) {
63 memcpy (out, scanlines->b0, size);
64 } else {
65 memcpy (out, scanlines->m1, size);
66 }
67 }
68
69 static void
deinterlace_scanline_weave_planar_u(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)70 deinterlace_scanline_weave_planar_u (GstDeinterlaceSimpleMethod * self,
71 guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
72 {
73 if (scanlines->m1 == NULL) {
74 memcpy (out, scanlines->b0, size);
75 } else {
76 memcpy (out, scanlines->m1, size);
77 }
78 }
79
80 static void
deinterlace_scanline_weave_planar_v(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)81 deinterlace_scanline_weave_planar_v (GstDeinterlaceSimpleMethod * self,
82 guint8 * out, const GstDeinterlaceScanlineData * scanlines, guint size)
83 {
84 if (scanlines->m1 == NULL) {
85 memcpy (out, scanlines->b0, size);
86 } else {
87 memcpy (out, scanlines->m1, size);
88 }
89 }
90
91 static void
copy_scanline_packed(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)92 copy_scanline_packed (GstDeinterlaceSimpleMethod * self, guint8 * out,
93 const GstDeinterlaceScanlineData * scanlines, guint size)
94 {
95 memcpy (out, scanlines->m0, size);
96 }
97
98 static void
copy_scanline_planar_y(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)99 copy_scanline_planar_y (GstDeinterlaceSimpleMethod * self, guint8 * out,
100 const GstDeinterlaceScanlineData * scanlines, guint size)
101 {
102 memcpy (out, scanlines->m0, size);
103 }
104
105 static void
copy_scanline_planar_u(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)106 copy_scanline_planar_u (GstDeinterlaceSimpleMethod * self, guint8 * out,
107 const GstDeinterlaceScanlineData * scanlines, guint size)
108 {
109 memcpy (out, scanlines->m0, size);
110 }
111
112 static void
copy_scanline_planar_v(GstDeinterlaceSimpleMethod * self,guint8 * out,const GstDeinterlaceScanlineData * scanlines,guint size)113 copy_scanline_planar_v (GstDeinterlaceSimpleMethod * self, guint8 * out,
114 const GstDeinterlaceScanlineData * scanlines, guint size)
115 {
116 memcpy (out, scanlines->m0, size);
117 }
118
119 G_DEFINE_TYPE (GstDeinterlaceMethodWeaveBFF, gst_deinterlace_method_weave_bff,
120 GST_TYPE_DEINTERLACE_SIMPLE_METHOD);
121
122 static void
gst_deinterlace_method_weave_bff_class_init(GstDeinterlaceMethodWeaveBFFClass * klass)123 gst_deinterlace_method_weave_bff_class_init (GstDeinterlaceMethodWeaveBFFClass *
124 klass)
125 {
126 GstDeinterlaceMethodClass *dim_class = (GstDeinterlaceMethodClass *) klass;
127 GstDeinterlaceSimpleMethodClass *dism_class =
128 (GstDeinterlaceSimpleMethodClass *) klass;
129
130 dim_class->fields_required = 2;
131 dim_class->name = "Progressive: Bottom Field First";
132 dim_class->nick = "weavebff";
133 dim_class->latency = 1;
134
135 dism_class->interpolate_scanline_ayuv = deinterlace_scanline_weave_packed;
136 dism_class->interpolate_scanline_yuy2 = deinterlace_scanline_weave_packed;
137 dism_class->interpolate_scanline_yvyu = deinterlace_scanline_weave_packed;
138 dism_class->interpolate_scanline_uyvy = deinterlace_scanline_weave_packed;
139 dism_class->interpolate_scanline_nv12 = deinterlace_scanline_weave_packed;
140 dism_class->interpolate_scanline_nv21 = deinterlace_scanline_weave_packed;
141 dism_class->interpolate_scanline_argb = deinterlace_scanline_weave_packed;
142 dism_class->interpolate_scanline_abgr = deinterlace_scanline_weave_packed;
143 dism_class->interpolate_scanline_rgba = deinterlace_scanline_weave_packed;
144 dism_class->interpolate_scanline_bgra = deinterlace_scanline_weave_packed;
145 dism_class->interpolate_scanline_rgb = deinterlace_scanline_weave_packed;
146 dism_class->interpolate_scanline_bgr = deinterlace_scanline_weave_packed;
147 dism_class->interpolate_scanline_planar_y =
148 deinterlace_scanline_weave_planar_y;
149 dism_class->interpolate_scanline_planar_u =
150 deinterlace_scanline_weave_planar_u;
151 dism_class->interpolate_scanline_planar_v =
152 deinterlace_scanline_weave_planar_v;
153
154 dism_class->copy_scanline_ayuv = copy_scanline_packed;
155 dism_class->copy_scanline_yuy2 = copy_scanline_packed;
156 dism_class->copy_scanline_yvyu = copy_scanline_packed;
157 dism_class->copy_scanline_uyvy = copy_scanline_packed;
158 dism_class->copy_scanline_nv12 = copy_scanline_packed;
159 dism_class->copy_scanline_nv21 = copy_scanline_packed;
160 dism_class->copy_scanline_argb = copy_scanline_packed;
161 dism_class->copy_scanline_abgr = copy_scanline_packed;
162 dism_class->copy_scanline_rgba = copy_scanline_packed;
163 dism_class->copy_scanline_bgra = copy_scanline_packed;
164 dism_class->copy_scanline_rgb = copy_scanline_packed;
165 dism_class->copy_scanline_bgr = copy_scanline_packed;
166 dism_class->copy_scanline_planar_y = copy_scanline_planar_y;
167 dism_class->copy_scanline_planar_u = copy_scanline_planar_u;
168 dism_class->copy_scanline_planar_v = copy_scanline_planar_v;
169 }
170
171 static void
gst_deinterlace_method_weave_bff_init(GstDeinterlaceMethodWeaveBFF * self)172 gst_deinterlace_method_weave_bff_init (GstDeinterlaceMethodWeaveBFF * self)
173 {
174 }
175