Blame gst-libs/gst/video/video-resampler.h

Packit 0652a1
/* GStreamer
Packit 0652a1
 * Copyright (C) <2014> Wim Taymans <wim.taymans@gmail.com>
Packit 0652a1
 *
Packit 0652a1
 * This library is free software; you can redistribute it and/or
Packit 0652a1
 * modify it under the terms of the GNU Library General Public
Packit 0652a1
 * License as published by the Free Software Foundation; either
Packit 0652a1
 * version 2 of the License, or (at your option) any later version.
Packit 0652a1
 *
Packit 0652a1
 * This library is distributed in the hope that it will be useful,
Packit 0652a1
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 0652a1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 0652a1
 * Library General Public License for more details.
Packit 0652a1
 *
Packit 0652a1
 * You should have received a copy of the GNU Library General Public
Packit 0652a1
 * License along with this library; if not, write to the
Packit 0652a1
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit 0652a1
 * Boston, MA 02110-1301, USA.
Packit 0652a1
 */
Packit 0652a1
Packit 0652a1
#ifndef __GST_VIDEO_RESAMPLER_H__
Packit 0652a1
#define __GST_VIDEO_RESAMPLER_H__
Packit 0652a1
Packit 0652a1
#include <gst/gst.h>
Packit 0652a1
#include <gst/video/video-prelude.h>
Packit 0652a1
Packit 0652a1
G_BEGIN_DECLS
Packit 0652a1
Packit 0652a1
typedef struct _GstVideoResampler GstVideoResampler;
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GstVideoResamplerMethod:
Packit 0652a1
 * @GST_VIDEO_RESAMPLER_METHOD_NEAREST: Duplicates the samples when
Packit 0652a1
 *    upsampling and drops when downsampling
Packit 0652a1
 * @GST_VIDEO_RESAMPLER_METHOD_LINEAR: Uses linear interpolation to reconstruct
Packit 0652a1
 *    missing samples and averaging to downsample
Packit 0652a1
 * @GST_VIDEO_RESAMPLER_METHOD_CUBIC: Uses cubic interpolation
Packit 0652a1
 * @GST_VIDEO_RESAMPLER_METHOD_SINC: Uses sinc interpolation
Packit 0652a1
 * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS: Uses lanczos interpolation
Packit 0652a1
 *
Packit 0652a1
 * Different subsampling and upsampling methods
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.6
Packit 0652a1
 */
Packit 0652a1
typedef enum {
Packit 0652a1
  GST_VIDEO_RESAMPLER_METHOD_NEAREST,
Packit 0652a1
  GST_VIDEO_RESAMPLER_METHOD_LINEAR,
Packit 0652a1
  GST_VIDEO_RESAMPLER_METHOD_CUBIC,
Packit 0652a1
  GST_VIDEO_RESAMPLER_METHOD_SINC,
Packit 0652a1
  GST_VIDEO_RESAMPLER_METHOD_LANCZOS
Packit 0652a1
} GstVideoResamplerMethod;
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GST_VIDEO_RESAMPLER_OPT_CUBIC_B:
Packit 0652a1
 *
Packit 0652a1
 * G_TYPE_DOUBLE, B parameter of the cubic filter. The B
Packit 0652a1
 * parameter controls the bluriness. Values between 0.0 and
Packit 0652a1
 * 2.0 are accepted. 1/3 is the default.
Packit 0652a1
 *
Packit 0652a1
 * Below are some values of popular filters:
Packit 0652a1
 *                    B       C
Packit 0652a1
 * Hermite           0.0     0.0
Packit 0652a1
 * Spline            1.0     0.0
Packit 0652a1
 * Catmull-Rom       0.0     1/2
Packit 0652a1
 * Mitchell          1/3     1/3
Packit 0652a1
 * Robidoux          0.3782  0.3109
Packit 0652a1
 * Robidoux
Packit 0652a1
 *  Sharp            0.2620  0.3690
Packit 0652a1
 * Robidoux
Packit 0652a1
 *  Soft             0.6796  0.1602
Packit 0652a1
 */
Packit 0652a1
#define GST_VIDEO_RESAMPLER_OPT_CUBIC_B      "GstVideoResampler.cubic-b"
Packit 0652a1
/**
Packit 0652a1
 * GST_VIDEO_RESAMPLER_OPT_CUBIC_C:
Packit 0652a1
 *
Packit 0652a1
 * G_TYPE_DOUBLE, C parameter of the cubic filter. The C
Packit 0652a1
 * parameter controls the Keys alpha value. Values between 0.0 and
Packit 0652a1
 * 2.0 are accepted. 1/3 is the default.
Packit 0652a1
 *
Packit 0652a1
 * See #GST_VIDEO_RESAMPLER_OPT_CUBIC_B for some more common values
Packit 0652a1
 */
Packit 0652a1
#define GST_VIDEO_RESAMPLER_OPT_CUBIC_C      "GstVideoResampler.cubic-c"
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GST_VIDEO_RESAMPLER_OPT_ENVELOPE:
Packit 0652a1
 *
Packit 0652a1
 * G_TYPE_DOUBLE, specifies the size of filter envelope for
Packit 0652a1
 * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS. values are clamped between
Packit 0652a1
 * 1.0 and 5.0. 2.0 is the default.
Packit 0652a1
 */
Packit 0652a1
#define GST_VIDEO_RESAMPLER_OPT_ENVELOPE      "GstVideoResampler.envelope"
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GST_VIDEO_RESAMPLER_OPT_SHARPNESS:
Packit 0652a1
 *
Packit 0652a1
 * G_TYPE_DOUBLE, specifies sharpness of the filter for
Packit 0652a1
 * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS. values are clamped between
Packit 0652a1
 * 0.5 and 1.5. 1.0 is the default.
Packit 0652a1
 */
Packit 0652a1
#define GST_VIDEO_RESAMPLER_OPT_SHARPNESS     "GstVideoResampler.sharpness"
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GST_VIDEO_RESAMPLER_OPT_SHARPEN:
Packit 0652a1
 *
Packit 0652a1
 * G_TYPE_DOUBLE, specifies sharpening of the filter for
Packit 0652a1
 * @GST_VIDEO_RESAMPLER_METHOD_LANCZOS. values are clamped between
Packit 0652a1
 * 0.0 and 1.0. 0.0 is the default.
Packit 0652a1
 */
Packit 0652a1
#define GST_VIDEO_RESAMPLER_OPT_SHARPEN      "GstVideoResampler.sharpen"
Packit 0652a1
/**
Packit 0652a1
 * GST_VIDEO_RESAMPLER_OPT_MAX_TAPS:
Packit 0652a1
 *
Packit 0652a1
 * G_TYPE_INT, limits the maximum number of taps to use.
Packit 0652a1
 * 16 is the default.
Packit 0652a1
 */
Packit 0652a1
#define GST_VIDEO_RESAMPLER_OPT_MAX_TAPS     "GstVideoResampler.max-taps"
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GstVideoResamplerFlags:
Packit 0652a1
 * @GST_VIDEO_RESAMPLER_FLAG_NONE: no flags
Packit 0652a1
 * @GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS: when no taps are given, half the
Packit 0652a1
 *              number of calculated taps. This can be used when making scalers
Packit 0652a1
 *              for the different fields of an interlaced picture. Since: 1.10
Packit 0652a1
 *
Packit 0652a1
 * Different resampler flags.
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.6
Packit 0652a1
 */
Packit 0652a1
typedef enum {
Packit 0652a1
  GST_VIDEO_RESAMPLER_FLAG_NONE                 = (0),
Packit 0652a1
  GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS            = (1 << 0),
Packit 0652a1
} GstVideoResamplerFlags;
Packit 0652a1
Packit 0652a1
/**
Packit 0652a1
 * GstVideoResampler:
Packit 0652a1
 * @in_size: the input size
Packit 0652a1
 * @out_size: the output size
Packit 0652a1
 * @max_taps: the maximum number of taps
Packit 0652a1
 * @n_phases: the number of phases
Packit 0652a1
 * @offset: array with the source offset for each output element
Packit 0652a1
 * @phase: array with the phase to use for each output element
Packit 0652a1
 * @n_taps: array with new number of taps for each phase
Packit 0652a1
 * @taps: the taps for all phases
Packit 0652a1
 *
Packit 0652a1
 * A structure holding resampler information.
Packit 0652a1
 *
Packit 0652a1
 * Since: 1.6
Packit 0652a1
 */
Packit 0652a1
struct _GstVideoResampler
Packit 0652a1
{
Packit 0652a1
  gint in_size;
Packit 0652a1
  gint out_size;
Packit 0652a1
  guint max_taps;
Packit 0652a1
  guint n_phases;
Packit 0652a1
  guint32 *offset;
Packit 0652a1
  guint32 *phase;
Packit 0652a1
  guint32 *n_taps;
Packit 0652a1
  gdouble *taps;
Packit 0652a1
Packit 0652a1
  /*< private >*/
Packit 0652a1
  gpointer _gst_reserved[GST_PADDING];
Packit 0652a1
};
Packit 0652a1
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
gboolean    gst_video_resampler_init      (GstVideoResampler *resampler,
Packit 0652a1
                                           GstVideoResamplerMethod method,
Packit 0652a1
                                           GstVideoResamplerFlags flags,
Packit 0652a1
                                           guint n_phases, guint n_taps,
Packit 0652a1
                                           gdouble shift,
Packit 0652a1
                                           guint in_size, guint out_size,
Packit 0652a1
                                           GstStructure *options);
Packit 0652a1
Packit 0652a1
GST_VIDEO_API
Packit 0652a1
void        gst_video_resampler_clear     (GstVideoResampler *resampler);
Packit 0652a1
Packit 0652a1
G_END_DECLS
Packit 0652a1
Packit 0652a1
#endif /* __GST_VIDEO_RESAMPLER_H__ */