video-resampler.h 5.2 KB

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