4
* Copyright (C) 2004 Billy Biggs <vektor@dumbterm.net>
5
* Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
6
* Copyright (C) 2008 Sebastian Dröge <slomo@collabora.co.uk>
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Library General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Library General Public License for more details.
18
* You should have received a copy of the GNU Library General Public
19
* License along with this library; if not, write to the
20
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21
* Boston, MA 02111-1307, USA.
25
* This file contains code from ffmpeg, see http://ffmpeg.org/ (LGPL)
26
* and modifications by Billy Biggs.
28
* Relicensed for GStreamer from GPL to LGPL with permit from Billy Biggs.
29
* See: http://bugzilla.gnome.org/show_bug.cgi?id=163578
37
#include "gstdeinterlace2.h"
40
#define GST_TYPE_DEINTERLACE_METHOD_VFIR (gst_deinterlace_method_vfir_get_type ())
41
#define GST_IS_DEINTERLACE_METHOD_VFIR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_METHOD_VFIR))
42
#define GST_IS_DEINTERLACE_METHOD_VFIR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_METHOD_VFIR))
43
#define GST_DEINTERLACE_METHOD_VFIR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_METHOD_VFIR, GstDeinterlaceMethodVFIRClass))
44
#define GST_DEINTERLACE_METHOD_VFIR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_METHOD_VFIR, GstDeinterlaceMethodVFIR))
45
#define GST_DEINTERLACE_METHOD_VFIR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_METHOD_VFIR, GstDeinterlaceMethodVFIRClass))
46
#define GST_DEINTERLACE_METHOD_VFIR_CAST(obj) ((GstDeinterlaceMethodVFIR*)(obj))
48
GType gst_deinterlace_method_vfir_get_type (void);
50
typedef GstDeinterlaceSimpleMethod GstDeinterlaceMethodVFIR;
52
typedef GstDeinterlaceSimpleMethodClass GstDeinterlaceMethodVFIRClass;
55
* The MPEG2 spec uses a slightly harsher filter, they specify
56
* [-1 8 2 8 -1]. ffmpeg uses a similar filter but with more of
57
* a tendancy to blur than to use the local information. The
58
* filter taps here are: [-1 4 2 4 -1].
65
deinterlace_line_c (GstDeinterlaceMethod * self, GstDeinterlace2 * parent,
66
guint8 * dst, GstDeinterlaceScanlineData * scanlines, gint width)
69
guint8 *lum_m4 = scanlines->tt1;
70
guint8 *lum_m3 = scanlines->t0;
71
guint8 *lum_m2 = scanlines->m1;
72
guint8 *lum_m1 = scanlines->b0;
73
guint8 *lum = scanlines->bb1;
74
gint size = width * 2;
76
for (; size >= 0; size--) {
78
sum += lum_m3[0] << 2;
79
sum += lum_m2[0] << 1;
80
sum += lum_m1[0] << 2;
82
dst[0] = (sum + 4) >> 3; // This needs to be clipped at 0 and 255: cm[(sum + 4) >> 3];
95
deinterlace_line_mmx (GstDeinterlaceMethod * self, GstDeinterlace2 * parent,
96
guint8 * dst, GstDeinterlaceScanlineData * scanlines, gint width)
99
guint8 *lum_m4 = scanlines->tt1;
100
guint8 *lum_m3 = scanlines->t0;
101
guint8 *lum_m2 = scanlines->m1;
102
guint8 *lum_m1 = scanlines->b0;
103
guint8 *lum = scanlines->bb1;
110
movq_m2r (rounder, mm6);
112
for (; width > 1; width -= 2) {
113
movd_m2r (*lum_m4, mm0);
114
movd_m2r (*lum_m3, mm1);
115
movd_m2r (*lum_m2, mm2);
116
movd_m2r (*lum_m1, mm3);
117
movd_m2r (*lum, mm4);
118
punpcklbw_r2r (mm7, mm0);
119
punpcklbw_r2r (mm7, mm1);
120
punpcklbw_r2r (mm7, mm2);
121
punpcklbw_r2r (mm7, mm3);
122
punpcklbw_r2r (mm7, mm4);
123
paddw_r2r (mm3, mm1);
125
paddw_r2r (mm4, mm0);
126
psllw_i2r (2, mm1); // 2
127
paddw_r2r (mm6, mm2);
128
paddw_r2r (mm2, mm1);
129
psubusw_r2r (mm0, mm1);
130
psrlw_i2r (3, mm1); // 3
131
packuswb_r2r (mm7, mm1);
132
movd_r2m (mm1, *dst);
142
/* Handle odd widths */
144
scanlines->tt1 = lum_m4;
145
scanlines->t0 = lum_m3;
146
scanlines->m1 = lum_m2;
147
scanlines->b0 = lum_m1;
148
scanlines->bb1 = lum;
150
deinterlace_line_c (self, parent, dst, scanlines, width);
155
G_DEFINE_TYPE (GstDeinterlaceMethodVFIR, gst_deinterlace_method_vfir,
156
GST_TYPE_DEINTERLACE_SIMPLE_METHOD);
159
gst_deinterlace_method_vfir_class_init (GstDeinterlaceMethodVFIRClass * klass)
161
GstDeinterlaceMethodClass *dim_class = (GstDeinterlaceMethodClass *) klass;
162
GstDeinterlaceSimpleMethodClass *dism_class =
163
(GstDeinterlaceSimpleMethodClass *) klass;
165
guint cpu_flags = oil_cpu_get_flags ();
168
dim_class->fields_required = 2;
169
dim_class->name = "Blur Vertical";
170
dim_class->nick = "vfir";
171
dim_class->latency = 0;
174
if (cpu_flags & OIL_IMPL_FLAG_MMX) {
175
dism_class->interpolate_scanline = deinterlace_line_mmx;
177
dism_class->interpolate_scanline = deinterlace_line_c;
180
dism_class->interpolate_scanline = deinterlace_line_c;
185
gst_deinterlace_method_vfir_init (GstDeinterlaceMethodVFIR * self)