1bbfa7ad464eb46f13878e7a11ed07d5ab1b5137
[platform/upstream/gstreamer.git] / gst-libs / gst / video / video-resampler.h
1 /* GStreamer
2  * Copyright (C) <2014> Wim Taymans <wim.taymans@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef __GST_VIDEO_RESAMPLER_H__
21 #define __GST_VIDEO_RESAMPLER_H__
22
23 #include <gst/gst.h>
24
25 G_BEGIN_DECLS
26
27 typedef struct _GstVideoResampler GstVideoResampler;
28
29 /**
30  * GstVideoResamplerMethod:
31  * @GST_VIDEO_RESAMPLER_METHOD_NEAREST: Duplicates the samples when
32  *    upsampling and drops when downsampling
33  * @GST_VIDEO_RESAMPLER_METHOD_LINEAR: Uses linear interpolation to reconstruct
34  *    missing samples and averaging to downsample
35  * @GST_VIDEO_RESAMPLER_METHOD_CUBIC: Uses cubic interpolation
36  * @GST_VIDEO_RESAMPLER_METHOD_SINC: Uses sinc interpolation
37  * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS: Uses lanczos interpolation
38  *
39  * Different subsampling and upsampling methods
40  *
41  * Since: 1.6
42  */
43 typedef enum {
44   GST_VIDEO_RESAMPLER_METHOD_NEAREST,
45   GST_VIDEO_RESAMPLER_METHOD_LINEAR,
46   GST_VIDEO_RESAMPLER_METHOD_CUBIC,
47   GST_VIDEO_RESAMPLER_METHOD_SINC,
48   GST_VIDEO_RESAMPLER_METHOD_LANCZOS
49 } GstVideoResamplerMethod;
50
51 /**
52  * GST_VIDEO_RESAMPLER_OPT_CUBIC_B:
53  *
54  * G_TYPE_DOUBLE, B parameter of the cubic filter. The B
55  * parameter controls the bluriness. Values between 0.0 and
56  * 2.0 are accepted. 1/3 is the default.
57  *
58  * Below are some values of popular filters:
59  *                    B       C
60  * Hermite           0.0     0.0
61  * Spline            1.0     0.0
62  * Catmull-Rom       0.0     1/2
63  * Mitchell          1/3     1/3
64  * Robidoux          0.3782  0.3109
65  * Robidoux
66  *  Sharp            0.2620  0.3690
67  * Robidoux
68  *  Soft             0.6796  0.1602
69  */
70 #define GST_VIDEO_RESAMPLER_OPT_CUBIC_B      "GstVideoResampler.cubic-b"
71 /**
72  * GST_VIDEO_RESAMPLER_OPT_CUBIC_C:
73  *
74  * G_TYPE_DOUBLE, C parameter of the cubic filter. The C
75  * parameter controls the Keys alpha value. Values between 0.0 and
76  * 2.0 are accepted. 1/3 is the default.
77  *
78  * See #GST_VIDEO_RESAMPLER_OPT_CUBIC_B for some more common values
79  */
80 #define GST_VIDEO_RESAMPLER_OPT_CUBIC_C      "GstVideoResampler.cubic-c"
81
82 /**
83  * GST_VIDEO_RESAMPLER_OPT_ENVELOPE:
84  *
85  * G_TYPE_DOUBLE, specifies the size of filter envelope for
86  * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS. values are clamped between
87  * 1.0 and 5.0. 2.0 is the default.
88  */
89 #define GST_VIDEO_RESAMPLER_OPT_ENVELOPE      "GstVideoResampler.envelope"
90
91 /**
92  * GST_VIDEO_RESAMPLER_OPT_SHARPNESS:
93  *
94  * G_TYPE_DOUBLE, specifies sharpness of the filter for
95  * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS. values are clamped between
96  * 0.5 and 1.5. 1.0 is the default.
97  */
98 #define GST_VIDEO_RESAMPLER_OPT_SHARPNESS     "GstVideoResampler.sharpness"
99
100 /**
101  * GST_VIDEO_RESAMPLER_OPT_SHARPEN:
102  *
103  * G_TYPE_DOUBLE, specifies sharpening of the filter for
104  * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS. values are clamped between
105  * 0.0 and 1.0. 0.0 is the default.
106  */
107 #define GST_VIDEO_RESAMPLER_OPT_SHARPEN      "GstVideoResampler.sharpen"
108 /**
109  * GST_VIDEO_RESAMPLER_OPT_MAX_TAPS:
110  *
111  * G_TYPE_INT, limits the maximum number of taps to use.
112  * 16 is the default.
113  */
114 #define GST_VIDEO_RESAMPLER_OPT_MAX_TAPS     "GstVideoResampler.max-taps"
115
116 /**
117  * GstVideoResamplerFlags:
118  * @GST_VIDEO_RESAMPLER_FLAG_NONE: no flags
119  * @GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS: when no taps are given, half the
120  *              number of calculated taps. This can be used when making scalers
121  *              for the different fields of an interlaced picture. Since 1.10
122  *
123  * Different resampler flags.
124  *
125  * Since: 1.6
126  */
127 typedef enum {
128   GST_VIDEO_RESAMPLER_FLAG_NONE                 = (0),
129   GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS            = (1 << 0),
130 } GstVideoResamplerFlags;
131
132 /**
133  * GstVideoResampler:
134  * @in_size: the input size
135  * @out_size: the output size
136  * @max_taps: the maximum number of taps
137  * @n_phases: the number of phases
138  * @offset: array with the source offset for each output element
139  * @phase: array with the phase to use for each output element
140  * @n_taps: array with new number of taps for each phase
141  * @taps: the taps for all phases
142  *
143  * A structure holding resampler information.
144  *
145  * Since: 1.6
146  */
147 struct _GstVideoResampler
148 {
149   gint in_size;
150   gint out_size;
151   guint max_taps;
152   guint n_phases;
153   guint32 *offset;
154   guint32 *phase;
155   guint32 *n_taps;
156   gdouble *taps;
157
158   /*< private >*/
159   gpointer _gst_reserved[GST_PADDING];
160 };
161
162
163 GST_EXPORT
164 gboolean    gst_video_resampler_init      (GstVideoResampler *resampler,
165                                            GstVideoResamplerMethod method,
166                                            GstVideoResamplerFlags flags,
167                                            guint n_phases, guint n_taps,
168                                            gdouble shift,
169                                            guint in_size, guint out_size,
170                                            GstStructure *options);
171
172 GST_EXPORT
173 void        gst_video_resampler_clear     (GstVideoResampler *resampler);
174
175 G_END_DECLS
176
177 #endif /* __GST_VIDEO_RESAMPLER_H__ */