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