| 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 | #include <gst/video/video-prelude.h> |
| 25 | |
| 26 | G_BEGIN_DECLS |
| 27 | |
| 28 | typedef struct _GstVideoResampler GstVideoResampler; |
| 29 | |
| 30 | /** |
| 31 | * GstVideoResamplerMethod: |
| 32 | * @GST_VIDEO_RESAMPLER_METHOD_NEAREST: Duplicates the samples when |
| 33 | * upsampling and drops when downsampling |
| 34 | * @GST_VIDEO_RESAMPLER_METHOD_LINEAR: Uses linear interpolation to reconstruct |
| 35 | * missing samples and averaging to downsample |
| 36 | * @GST_VIDEO_RESAMPLER_METHOD_CUBIC: Uses cubic interpolation |
| 37 | * @GST_VIDEO_RESAMPLER_METHOD_SINC: Uses sinc interpolation |
| 38 | * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS: Uses lanczos interpolation |
| 39 | * |
| 40 | * Different subsampling and upsampling methods |
| 41 | * |
| 42 | * Since: 1.6 |
| 43 | */ |
| 44 | typedef enum { |
| 45 | GST_VIDEO_RESAMPLER_METHOD_NEAREST, |
| 46 | GST_VIDEO_RESAMPLER_METHOD_LINEAR, |
| 47 | GST_VIDEO_RESAMPLER_METHOD_CUBIC, |
| 48 | GST_VIDEO_RESAMPLER_METHOD_SINC, |
| 49 | GST_VIDEO_RESAMPLER_METHOD_LANCZOS |
| 50 | } GstVideoResamplerMethod; |
| 51 | |
| 52 | /** |
| 53 | * GST_VIDEO_RESAMPLER_OPT_CUBIC_B: |
| 54 | * |
| 55 | * G_TYPE_DOUBLE, B parameter of the cubic filter. The B |
| 56 | * parameter controls the bluriness. Values between 0.0 and |
| 57 | * 2.0 are accepted. 1/3 is the default. |
| 58 | * |
| 59 | * Below are some values of popular filters: |
| 60 | * B C |
| 61 | * Hermite 0.0 0.0 |
| 62 | * Spline 1.0 0.0 |
| 63 | * Catmull-Rom 0.0 1/2 |
| 64 | * Mitchell 1/3 1/3 |
| 65 | * Robidoux 0.3782 0.3109 |
| 66 | * Robidoux |
| 67 | * Sharp 0.2620 0.3690 |
| 68 | * Robidoux |
| 69 | * Soft 0.6796 0.1602 |
| 70 | */ |
| 71 | #define GST_VIDEO_RESAMPLER_OPT_CUBIC_B "GstVideoResampler.cubic-b" |
| 72 | /** |
| 73 | * GST_VIDEO_RESAMPLER_OPT_CUBIC_C: |
| 74 | * |
| 75 | * G_TYPE_DOUBLE, C parameter of the cubic filter. The C |
| 76 | * parameter controls the Keys alpha value. Values between 0.0 and |
| 77 | * 2.0 are accepted. 1/3 is the default. |
| 78 | * |
| 79 | * See #GST_VIDEO_RESAMPLER_OPT_CUBIC_B for some more common values |
| 80 | */ |
| 81 | #define GST_VIDEO_RESAMPLER_OPT_CUBIC_C "GstVideoResampler.cubic-c" |
| 82 | |
| 83 | /** |
| 84 | * GST_VIDEO_RESAMPLER_OPT_ENVELOPE: |
| 85 | * |
| 86 | * G_TYPE_DOUBLE, specifies the size of filter envelope for |
| 87 | * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS. values are clamped between |
| 88 | * 1.0 and 5.0. 2.0 is the default. |
| 89 | */ |
| 90 | #define GST_VIDEO_RESAMPLER_OPT_ENVELOPE "GstVideoResampler.envelope" |
| 91 | |
| 92 | /** |
| 93 | * GST_VIDEO_RESAMPLER_OPT_SHARPNESS: |
| 94 | * |
| 95 | * G_TYPE_DOUBLE, specifies sharpness of the filter for |
| 96 | * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS. values are clamped between |
| 97 | * 0.5 and 1.5. 1.0 is the default. |
| 98 | */ |
| 99 | #define GST_VIDEO_RESAMPLER_OPT_SHARPNESS "GstVideoResampler.sharpness" |
| 100 | |
| 101 | /** |
| 102 | * GST_VIDEO_RESAMPLER_OPT_SHARPEN: |
| 103 | * |
| 104 | * G_TYPE_DOUBLE, specifies sharpening of the filter for |
| 105 | * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS. values are clamped between |
| 106 | * 0.0 and 1.0. 0.0 is the default. |
| 107 | */ |
| 108 | #define GST_VIDEO_RESAMPLER_OPT_SHARPEN "GstVideoResampler.sharpen" |
| 109 | /** |
| 110 | * GST_VIDEO_RESAMPLER_OPT_MAX_TAPS: |
| 111 | * |
| 112 | * G_TYPE_INT, limits the maximum number of taps to use. |
| 113 | * 16 is the default. |
| 114 | */ |
| 115 | #define GST_VIDEO_RESAMPLER_OPT_MAX_TAPS "GstVideoResampler.max-taps" |
| 116 | |
| 117 | /** |
| 118 | * GstVideoResamplerFlags: |
| 119 | * @GST_VIDEO_RESAMPLER_FLAG_NONE: no flags |
| 120 | * @GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS: when no taps are given, half the |
| 121 | * number of calculated taps. This can be used when making scalers |
| 122 | * for the different fields of an interlaced picture. Since: 1.10 |
| 123 | * |
| 124 | * Different resampler flags. |
| 125 | * |
| 126 | * Since: 1.6 |
| 127 | */ |
| 128 | typedef enum { |
| 129 | GST_VIDEO_RESAMPLER_FLAG_NONE = (0), |
| 130 | GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS = (1 << 0), |
| 131 | } GstVideoResamplerFlags; |
| 132 | |
| 133 | /** |
| 134 | * GstVideoResampler: |
| 135 | * @in_size: the input size |
| 136 | * @out_size: the output size |
| 137 | * @max_taps: the maximum number of taps |
| 138 | * @n_phases: the number of phases |
| 139 | * @offset: array with the source offset for each output element |
| 140 | * @phase: array with the phase to use for each output element |
| 141 | * @n_taps: array with new number of taps for each phase |
| 142 | * @taps: the taps for all phases |
| 143 | * |
| 144 | * A structure holding resampler information. |
| 145 | * |
| 146 | * Since: 1.6 |
| 147 | */ |
| 148 | struct _GstVideoResampler |
| 149 | { |
| 150 | gint in_size; |
| 151 | gint out_size; |
| 152 | guint max_taps; |
| 153 | guint n_phases; |
| 154 | guint32 *offset; |
| 155 | guint32 *phase; |
| 156 | guint32 *n_taps; |
| 157 | gdouble *taps; |
| 158 | |
| 159 | /*< private >*/ |
| 160 | gpointer _gst_reserved[GST_PADDING]; |
| 161 | }; |
| 162 | |
| 163 | |
| 164 | GST_VIDEO_API |
| 165 | gboolean gst_video_resampler_init (GstVideoResampler *resampler, |
| 166 | GstVideoResamplerMethod method, |
| 167 | GstVideoResamplerFlags flags, |
| 168 | guint n_phases, guint n_taps, |
| 169 | gdouble shift, |
| 170 | guint in_size, guint out_size, |
| 171 | GstStructure *options); |
| 172 | |
| 173 | GST_VIDEO_API |
| 174 | void gst_video_resampler_clear (GstVideoResampler *resampler); |
| 175 | |
| 176 | G_END_DECLS |
| 177 | |
| 178 | #endif /* __GST_VIDEO_RESAMPLER_H__ */ |
| 179 | |