video-converter.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /* Video conversion api function
  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_CONVERTER_H__
  20. #define __GST_VIDEO_CONVERTER_H__
  21. #include <gst/video/video.h>
  22. G_BEGIN_DECLS
  23. /**
  24. * GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD:
  25. *
  26. * #GST_TYPE_RESAMPLER_METHOD, The resampler method to use for
  27. * resampling. Other options for the resampler can be used, see
  28. * the #GstResampler. Default is #GST_RESAMPLER_METHOD_CUBIC
  29. */
  30. #define GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD "GstVideoConverter.resampler-method"
  31. /**
  32. * GST_VIDEO_CONVERTER_OPT_CHROMA_RESAMPLER_METHOD:
  33. *
  34. * #GST_TYPE_RESAMPLER_METHOD, The resampler method to use for
  35. * chroma resampling. Other options for the resampler can be used, see
  36. * the #GstResampler. Default is #GST_RESAMPLER_METHOD_LINEAR
  37. */
  38. #define GST_VIDEO_CONVERTER_OPT_CHROMA_RESAMPLER_METHOD "GstVideoConverter.chroma-resampler-method"
  39. /**
  40. * GST_VIDEO_CONVERTER_OPT_RESAMPLER_TAPS:
  41. *
  42. * #G_TYPE_UINT, The number of taps for the resampler.
  43. * Default is 0: let the resampler choose a good value.
  44. */
  45. #define GST_VIDEO_CONVERTER_OPT_RESAMPLER_TAPS "GstVideoConverter.resampler-taps"
  46. /**
  47. * GST_VIDEO_CONVERTER_OPT_DITHER_METHOD:
  48. *
  49. * #GST_TYPE_VIDEO_DITHER_METHOD, The dither method to use when
  50. * changing bit depth.
  51. * Default is #GST_VIDEO_DITHER_BAYER.
  52. */
  53. #define GST_VIDEO_CONVERTER_OPT_DITHER_METHOD "GstVideoConverter.dither-method"
  54. /**
  55. * GST_VIDEO_CONVERTER_OPT_DITHER_QUANTIZATION:
  56. *
  57. * #G_TYPE_UINT, The quantization amount to dither to. Components will be
  58. * quantized to multiples of this value.
  59. * Default is 1
  60. */
  61. #define GST_VIDEO_CONVERTER_OPT_DITHER_QUANTIZATION "GstVideoConverter.dither-quantization"
  62. /**
  63. * GST_VIDEO_CONVERTER_OPT_SRC_X:
  64. *
  65. * #G_TYPE_INT, source x position to start conversion, default 0
  66. */
  67. #define GST_VIDEO_CONVERTER_OPT_SRC_X "GstVideoConverter.src-x"
  68. /**
  69. * GST_VIDEO_CONVERTER_OPT_SRC_Y:
  70. *
  71. * #G_TYPE_INT, source y position to start conversion, default 0
  72. */
  73. #define GST_VIDEO_CONVERTER_OPT_SRC_Y "GstVideoConverter.src-y"
  74. /**
  75. * GST_VIDEO_CONVERTER_OPT_SRC_WIDTH:
  76. *
  77. * #G_TYPE_INT, source width to convert, default source width
  78. */
  79. #define GST_VIDEO_CONVERTER_OPT_SRC_WIDTH "GstVideoConverter.src-width"
  80. /**
  81. * GST_VIDEO_CONVERTER_OPT_SRC_HEIGHT:
  82. *
  83. * #G_TYPE_INT, source height to convert, default source height
  84. */
  85. #define GST_VIDEO_CONVERTER_OPT_SRC_HEIGHT "GstVideoConverter.src-height"
  86. /**
  87. * GST_VIDEO_CONVERTER_OPT_DEST_X:
  88. *
  89. * #G_TYPE_INT, x position in the destination frame, default 0
  90. */
  91. #define GST_VIDEO_CONVERTER_OPT_DEST_X "GstVideoConverter.dest-x"
  92. /**
  93. * GST_VIDEO_CONVERTER_OPT_DEST_Y:
  94. *
  95. * #G_TYPE_INT, y position in the destination frame, default 0
  96. */
  97. #define GST_VIDEO_CONVERTER_OPT_DEST_Y "GstVideoConverter.dest-y"
  98. /**
  99. * GST_VIDEO_CONVERTER_OPT_DEST_WIDTH:
  100. *
  101. * #G_TYPE_INT, width in the destination frame, default destination width
  102. */
  103. #define GST_VIDEO_CONVERTER_OPT_DEST_WIDTH "GstVideoConverter.dest-width"
  104. /**
  105. * GST_VIDEO_CONVERTER_OPT_DEST_HEIGHT:
  106. *
  107. * #G_TYPE_INT, height in the destination frame, default destination height
  108. */
  109. #define GST_VIDEO_CONVERTER_OPT_DEST_HEIGHT "GstVideoConverter.dest-height"
  110. /**
  111. * GST_VIDEO_CONVERTER_OPT_FILL_BORDER:
  112. *
  113. * #G_TYPE_BOOLEAN, if the destination rectangle does not fill the complete
  114. * destination image, render a border with
  115. * #GST_VIDEO_CONVERTER_OPT_BORDER_ARGB. Otherwise the unusded pixels in the
  116. * destination are untouched. Default %TRUE.
  117. */
  118. #define GST_VIDEO_CONVERTER_OPT_FILL_BORDER "GstVideoConverter.fill-border"
  119. /**
  120. * GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE:
  121. *
  122. * #G_TYPE_DOUBLE, the alpha color value to use.
  123. * Default to 1.0
  124. */
  125. #define GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE "GstVideoConverter.alpha-value"
  126. /**
  127. * GstVideoAlphaMode:
  128. * @GST_VIDEO_ALPHA_MODE_COPY: When input and output have alpha, it will be copied.
  129. * When the input has no alpha, alpha will be set to
  130. * #GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE
  131. * @GST_VIDEO_ALPHA_MODE_SET: set all alpha to
  132. * #GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE
  133. * @GST_VIDEO_ALPHA_MODE_MULT: multiply all alpha with
  134. * #GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE.
  135. * When the input format has no alpha but the output format has, the
  136. * alpha value will be set to #GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE
  137. *
  138. * Different alpha modes.
  139. *
  140. * Since: 1.6
  141. */
  142. typedef enum {
  143. GST_VIDEO_ALPHA_MODE_COPY,
  144. GST_VIDEO_ALPHA_MODE_SET,
  145. GST_VIDEO_ALPHA_MODE_MULT
  146. } GstVideoAlphaMode;
  147. /**
  148. * GST_VIDEO_CONVERTER_OPT_ALPHA_MODE:
  149. *
  150. * #GST_TYPE_VIDEO_ALPHA_MODE, the alpha mode to use.
  151. * Default is #GST_VIDEO_ALPHA_MODE_COPY.
  152. */
  153. #define GST_VIDEO_CONVERTER_OPT_ALPHA_MODE "GstVideoConverter.alpha-mode"
  154. /**
  155. * GST_VIDEO_CONVERTER_OPT_BORDER_ARGB:
  156. *
  157. * #G_TYPE_UINT, the border color to use if #GST_VIDEO_CONVERTER_OPT_FILL_BORDER
  158. * is set to %TRUE. The color is in ARGB format.
  159. * Default 0xff000000
  160. */
  161. #define GST_VIDEO_CONVERTER_OPT_BORDER_ARGB "GstVideoConverter.border-argb"
  162. /**
  163. * GstVideoChromaMode:
  164. * @GST_VIDEO_CHROMA_MODE_FULL: do full chroma up and down sampling
  165. * @GST_VIDEO_CHROMA_MODE_UPSAMPLE_ONLY: only perform chroma upsampling
  166. * @GST_VIDEO_CHROMA_MODE_DOWNSAMPLE_ONLY: only perform chroma downsampling
  167. * @GST_VIDEO_CHROMA_MODE_NONE: disable chroma resampling
  168. *
  169. * Different chroma downsampling and upsampling modes
  170. *
  171. * Since: 1.6
  172. */
  173. typedef enum {
  174. GST_VIDEO_CHROMA_MODE_FULL,
  175. GST_VIDEO_CHROMA_MODE_UPSAMPLE_ONLY,
  176. GST_VIDEO_CHROMA_MODE_DOWNSAMPLE_ONLY,
  177. GST_VIDEO_CHROMA_MODE_NONE
  178. } GstVideoChromaMode;
  179. /**
  180. * GST_VIDEO_CONVERTER_OPT_CHROMA_MODE:
  181. *
  182. * #GST_TYPE_VIDEO_CHROMA_MODE, set the chroma resample mode subsampled
  183. * formats. Default is #GST_VIDEO_CHROMA_MODE_FULL.
  184. */
  185. #define GST_VIDEO_CONVERTER_OPT_CHROMA_MODE "GstVideoConverter.chroma-mode"
  186. /**
  187. *GstVideoMatrixMode:
  188. * @GST_VIDEO_MATRIX_MODE_FULL: do conversion between color matrices
  189. * @GST_VIDEO_MATRIX_MODE_INPUT_ONLY: use the input color matrix to convert
  190. * to and from R'G'B
  191. * @GST_VIDEO_MATRIX_MODE_OUTPUT_ONLY: use the output color matrix to convert
  192. * to and from R'G'B
  193. * @GST_VIDEO_MATRIX_MODE_NONE: disable color matrix conversion.
  194. *
  195. * Different color matrix conversion modes
  196. *
  197. * Since: 1.6
  198. */
  199. typedef enum {
  200. GST_VIDEO_MATRIX_MODE_FULL,
  201. GST_VIDEO_MATRIX_MODE_INPUT_ONLY,
  202. GST_VIDEO_MATRIX_MODE_OUTPUT_ONLY,
  203. GST_VIDEO_MATRIX_MODE_NONE
  204. } GstVideoMatrixMode;
  205. /**
  206. * GST_VIDEO_CONVERTER_OPT_MATRIX_MODE:
  207. *
  208. * #GST_TYPE_VIDEO_MATRIX_MODE, set the color matrix conversion mode for
  209. * converting between Y'PbPr and non-linear RGB (R'G'B').
  210. * Default is #GST_VIDEO_MATRIX_MODE_FULL.
  211. */
  212. #define GST_VIDEO_CONVERTER_OPT_MATRIX_MODE "GstVideoConverter.matrix-mode"
  213. /**
  214. * GstVideoGammaMode:
  215. * @GST_VIDEO_GAMMA_MODE_NONE: disable gamma handling
  216. * @GST_VIDEO_GAMMA_MODE_REMAP: convert between input and output gamma
  217. * Different gamma conversion modes
  218. *
  219. * Since: 1.6
  220. */
  221. typedef enum {
  222. GST_VIDEO_GAMMA_MODE_NONE,
  223. GST_VIDEO_GAMMA_MODE_REMAP
  224. } GstVideoGammaMode;
  225. /**
  226. * GST_VIDEO_CONVERTER_OPT_GAMMA_MODE:
  227. *
  228. * #GST_TYPE_VIDEO_GAMMA_MODE, set the gamma mode.
  229. * Default is #GST_VIDEO_GAMMA_MODE_NONE.
  230. */
  231. #define GST_VIDEO_CONVERTER_OPT_GAMMA_MODE "GstVideoConverter.gamma-mode"
  232. /**
  233. * GstVideoPrimariesMode:
  234. * @GST_VIDEO_PRIMARIES_MODE_NONE: disable conversion between primaries
  235. * @GST_VIDEO_PRIMARIES_MODE_MERGE_ONLY: do conversion between primaries only
  236. * when it can be merged with color matrix conversion.
  237. * @GST_VIDEO_PRIMARIES_MODE_FAST: fast conversion between primaries
  238. *
  239. * Different primaries conversion modes
  240. *
  241. * Since: 1.6
  242. */
  243. typedef enum {
  244. GST_VIDEO_PRIMARIES_MODE_NONE,
  245. GST_VIDEO_PRIMARIES_MODE_MERGE_ONLY,
  246. GST_VIDEO_PRIMARIES_MODE_FAST
  247. } GstVideoPrimariesMode;
  248. /**
  249. * GST_VIDEO_CONVERTER_OPT_PRIMARIES_MODE:
  250. *
  251. * #GST_TYPE_VIDEO_PRIMARIES_MODE, set the primaries conversion mode.
  252. * Default is #GST_VIDEO_PRIMARIES_MODE_NONE.
  253. */
  254. #define GST_VIDEO_CONVERTER_OPT_PRIMARIES_MODE "GstVideoConverter.primaries-mode"
  255. typedef struct _GstVideoConverter GstVideoConverter;
  256. GstVideoConverter * gst_video_converter_new (GstVideoInfo *in_info,
  257. GstVideoInfo *out_info,
  258. GstStructure *config);
  259. void gst_video_converter_free (GstVideoConverter * convert);
  260. gboolean gst_video_converter_set_config (GstVideoConverter * convert, GstStructure *config);
  261. const GstStructure * gst_video_converter_get_config (GstVideoConverter * convert);
  262. void gst_video_converter_frame (GstVideoConverter * convert,
  263. const GstVideoFrame *src, GstVideoFrame *dest);
  264. G_END_DECLS
  265. #endif /* __GST_VIDEO_CONVERTER_H__ */