2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) 2005-2012 David Schleef <ds@schleef.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 * SECTION:element-videoscale
24 * @see_also: videorate, videoconvert
26 * This element resizes video frames. By default the element will try to
27 * negotiate to the same size on the source and sinkpad so that no scaling
28 * is needed. It is therefore safe to insert this element in a pipeline to
29 * get more robust behaviour without any cost if no scaling is needed.
31 * This element supports a wide range of color spaces including various YUV and
32 * RGB formats and is therefore generally able to operate anywhere in a
35 * ## Example pipelines
37 * gst-launch-1.0 -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoconvert ! videoscale ! autovideosink
39 * Decode an Ogg/Theora and display the video. If the video sink chosen
40 * cannot perform scaling, the video scaling will be performed by videoscale
41 * when you resize the video window.
42 * To create the test Ogg/Theora file refer to the documentation of theoraenc.
44 * gst-launch-1.0 -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoconvert ! videoscale ! video/x-raw,width=100 ! autovideosink
46 * Decode an Ogg/Theora and display the video with a width of 100.
51 * Formulas for PAR, DAR, width and height relations:
62 * w = h * ----- * -----
66 * h = w * ----- * -----
78 #include <gst/video/gstvideometa.h>
79 #include <gst/video/gstvideopool.h>
81 #include "gstvideoscale.h"
83 #define GST_CAT_DEFAULT video_scale_debug
84 GST_DEBUG_CATEGORY_STATIC (video_scale_debug);
85 GST_DEBUG_CATEGORY_STATIC (CAT_PERFORMANCE);
87 #define DEFAULT_PROP_METHOD GST_VIDEO_SCALE_BILINEAR
88 #define DEFAULT_PROP_ADD_BORDERS TRUE
89 #define DEFAULT_PROP_SHARPNESS 1.0
90 #define DEFAULT_PROP_SHARPEN 0.0
91 #define DEFAULT_PROP_DITHER FALSE
92 #define DEFAULT_PROP_SUBMETHOD 1
93 #define DEFAULT_PROP_ENVELOPE 2.0
94 #define DEFAULT_PROP_GAMMA_DECODE FALSE
95 #define DEFAULT_PROP_N_THREADS 1
111 #undef GST_VIDEO_SIZE_RANGE
112 #define GST_VIDEO_SIZE_RANGE "(int) [ 1, 32767]"
114 /* FIXME: add v210 support
115 * FIXME: add v216 support
116 * FIXME: add UYVP support
117 * FIXME: add A420 support
118 * FIXME: add YUV9 support
119 * FIXME: add YVU9 support
120 * FIXME: add IYU1 support
121 * FIXME: add r210 support
124 #define GST_VIDEO_FORMATS GST_VIDEO_FORMATS_ALL
126 static GstStaticCaps gst_video_scale_format_caps =
127 GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS) ";"
128 GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("ANY", GST_VIDEO_FORMATS));
133 #define GST_TYPE_VIDEO_SCALE_METHOD (gst_video_scale_method_get_type())
135 gst_video_scale_method_get_type (void)
137 static GType video_scale_method_type = 0;
139 static const GEnumValue video_scale_methods[] = {
140 {GST_VIDEO_SCALE_NEAREST, "Nearest Neighbour", "nearest-neighbour"},
141 {GST_VIDEO_SCALE_BILINEAR, "Bilinear (2-tap)", "bilinear"},
142 {GST_VIDEO_SCALE_4TAP, "4-tap Sinc", "4-tap"},
143 {GST_VIDEO_SCALE_LANCZOS, "Lanczos", "lanczos"},
144 {GST_VIDEO_SCALE_BILINEAR2, "Bilinear (multi-tap)", "bilinear2"},
145 {GST_VIDEO_SCALE_SINC, "Sinc (multi-tap)", "sinc"},
146 {GST_VIDEO_SCALE_HERMITE, "Hermite (multi-tap)", "hermite"},
147 {GST_VIDEO_SCALE_SPLINE, "Spline (multi-tap)", "spline"},
148 {GST_VIDEO_SCALE_CATROM, "Catmull-Rom (multi-tap)", "catrom"},
149 {GST_VIDEO_SCALE_MITCHELL, "Mitchell (multi-tap)", "mitchell"},
153 if (!video_scale_method_type) {
154 video_scale_method_type =
155 g_enum_register_static ("GstVideoScaleMethod", video_scale_methods);
157 return video_scale_method_type;
161 gst_video_scale_get_capslist (void)
163 static GstCaps *caps = NULL;
164 static volatile gsize inited = 0;
166 if (g_once_init_enter (&inited)) {
167 caps = gst_static_caps_get (&gst_video_scale_format_caps);
168 g_once_init_leave (&inited, 1);
173 static GstPadTemplate *
174 gst_video_scale_src_template_factory (void)
176 return gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
177 gst_video_scale_get_capslist ());
180 static GstPadTemplate *
181 gst_video_scale_sink_template_factory (void)
183 return gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
184 gst_video_scale_get_capslist ());
188 static void gst_video_scale_finalize (GstVideoScale * videoscale);
189 static gboolean gst_video_scale_src_event (GstBaseTransform * trans,
192 /* base transform vmethods */
193 static GstCaps *gst_video_scale_transform_caps (GstBaseTransform * trans,
194 GstPadDirection direction, GstCaps * caps, GstCaps * filter);
195 static GstCaps *gst_video_scale_fixate_caps (GstBaseTransform * base,
196 GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
197 static gboolean gst_video_scale_transform_meta (GstBaseTransform * trans,
198 GstBuffer * inbuf, GstMeta * meta, GstBuffer * outbuf);
200 static gboolean gst_video_scale_set_info (GstVideoFilter * filter,
201 GstCaps * in, GstVideoInfo * in_info, GstCaps * out,
202 GstVideoInfo * out_info);
203 static GstFlowReturn gst_video_scale_transform_frame (GstVideoFilter * filter,
204 GstVideoFrame * in, GstVideoFrame * out);
206 static void gst_video_scale_set_property (GObject * object, guint prop_id,
207 const GValue * value, GParamSpec * pspec);
208 static void gst_video_scale_get_property (GObject * object, guint prop_id,
209 GValue * value, GParamSpec * pspec);
211 #define gst_video_scale_parent_class parent_class
212 G_DEFINE_TYPE (GstVideoScale, gst_video_scale, GST_TYPE_VIDEO_FILTER);
215 gst_video_scale_class_init (GstVideoScaleClass * klass)
217 GObjectClass *gobject_class = (GObjectClass *) klass;
218 GstElementClass *element_class = (GstElementClass *) klass;
219 GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
220 GstVideoFilterClass *filter_class = (GstVideoFilterClass *) klass;
222 gobject_class->finalize = (GObjectFinalizeFunc) gst_video_scale_finalize;
223 gobject_class->set_property = gst_video_scale_set_property;
224 gobject_class->get_property = gst_video_scale_get_property;
226 g_object_class_install_property (gobject_class, PROP_METHOD,
227 g_param_spec_enum ("method", "method", "method",
228 GST_TYPE_VIDEO_SCALE_METHOD, DEFAULT_PROP_METHOD,
229 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
231 g_object_class_install_property (gobject_class, PROP_ADD_BORDERS,
232 g_param_spec_boolean ("add-borders", "Add Borders",
233 "Add black borders if necessary to keep the display aspect ratio",
234 DEFAULT_PROP_ADD_BORDERS,
235 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
237 g_object_class_install_property (gobject_class, PROP_SHARPNESS,
238 g_param_spec_double ("sharpness", "Sharpness",
239 "Sharpness of filter", 0.5, 1.5, DEFAULT_PROP_SHARPNESS,
240 G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
242 g_object_class_install_property (gobject_class, PROP_SHARPEN,
243 g_param_spec_double ("sharpen", "Sharpen",
244 "Sharpening", 0.0, 1.0, DEFAULT_PROP_SHARPEN,
245 G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
247 g_object_class_install_property (gobject_class, PROP_DITHER,
248 g_param_spec_boolean ("dither", "Dither",
249 "Add dither (only used for Lanczos method)",
251 G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
254 /* I am hiding submethod for now, since it's poorly named, poorly
255 * documented, and will probably just get people into trouble. */
256 g_object_class_install_property (gobject_class, PROP_SUBMETHOD,
257 g_param_spec_int ("submethod", "submethod",
258 "submethod", 0, 3, DEFAULT_PROP_SUBMETHOD,
259 G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
262 g_object_class_install_property (gobject_class, PROP_ENVELOPE,
263 g_param_spec_double ("envelope", "Envelope",
264 "Size of filter envelope", 1.0, 5.0, DEFAULT_PROP_ENVELOPE,
265 G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
267 g_object_class_install_property (gobject_class, PROP_GAMMA_DECODE,
268 g_param_spec_boolean ("gamma-decode", "Gamma Decode",
269 "Decode gamma before scaling", DEFAULT_PROP_GAMMA_DECODE,
270 G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
272 g_object_class_install_property (gobject_class, PROP_N_THREADS,
273 g_param_spec_uint ("n-threads", "Threads",
274 "Maximum number of threads to use", 0, G_MAXUINT,
275 DEFAULT_PROP_N_THREADS,
276 G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
278 gst_element_class_set_static_metadata (element_class,
279 "Video scaler", "Filter/Converter/Video/Scaler",
280 "Resizes video", "Wim Taymans <wim.taymans@gmail.com>");
282 gst_element_class_add_pad_template (element_class,
283 gst_video_scale_sink_template_factory ());
284 gst_element_class_add_pad_template (element_class,
285 gst_video_scale_src_template_factory ());
287 trans_class->transform_caps =
288 GST_DEBUG_FUNCPTR (gst_video_scale_transform_caps);
289 trans_class->fixate_caps = GST_DEBUG_FUNCPTR (gst_video_scale_fixate_caps);
290 trans_class->src_event = GST_DEBUG_FUNCPTR (gst_video_scale_src_event);
291 trans_class->transform_meta =
292 GST_DEBUG_FUNCPTR (gst_video_scale_transform_meta);
294 filter_class->set_info = GST_DEBUG_FUNCPTR (gst_video_scale_set_info);
295 filter_class->transform_frame =
296 GST_DEBUG_FUNCPTR (gst_video_scale_transform_frame);
298 _size_quark = g_quark_from_static_string (GST_META_TAG_VIDEO_SIZE_STR);
299 _scale_quark = gst_video_meta_transform_scale_get_quark ();
301 gst_type_mark_as_plugin_api (GST_TYPE_VIDEO_SCALE_METHOD, 0);
305 gst_video_scale_init (GstVideoScale * videoscale)
307 videoscale->method = DEFAULT_PROP_METHOD;
308 videoscale->add_borders = DEFAULT_PROP_ADD_BORDERS;
309 videoscale->submethod = DEFAULT_PROP_SUBMETHOD;
310 videoscale->sharpness = DEFAULT_PROP_SHARPNESS;
311 videoscale->sharpen = DEFAULT_PROP_SHARPEN;
312 videoscale->dither = DEFAULT_PROP_DITHER;
313 videoscale->envelope = DEFAULT_PROP_ENVELOPE;
314 videoscale->gamma_decode = DEFAULT_PROP_GAMMA_DECODE;
315 videoscale->n_threads = DEFAULT_PROP_N_THREADS;
319 gst_video_scale_finalize (GstVideoScale * videoscale)
321 if (videoscale->convert)
322 gst_video_converter_free (videoscale->convert);
324 G_OBJECT_CLASS (parent_class)->finalize (G_OBJECT (videoscale));
328 gst_video_scale_set_property (GObject * object, guint prop_id,
329 const GValue * value, GParamSpec * pspec)
331 GstVideoScale *vscale = GST_VIDEO_SCALE (object);
335 GST_OBJECT_LOCK (vscale);
336 vscale->method = g_value_get_enum (value);
337 GST_OBJECT_UNLOCK (vscale);
339 case PROP_ADD_BORDERS:
340 GST_OBJECT_LOCK (vscale);
341 vscale->add_borders = g_value_get_boolean (value);
342 GST_OBJECT_UNLOCK (vscale);
343 gst_base_transform_reconfigure_src (GST_BASE_TRANSFORM_CAST (vscale));
346 GST_OBJECT_LOCK (vscale);
347 vscale->sharpness = g_value_get_double (value);
348 GST_OBJECT_UNLOCK (vscale);
351 GST_OBJECT_LOCK (vscale);
352 vscale->sharpen = g_value_get_double (value);
353 GST_OBJECT_UNLOCK (vscale);
356 GST_OBJECT_LOCK (vscale);
357 vscale->dither = g_value_get_boolean (value);
358 GST_OBJECT_UNLOCK (vscale);
361 GST_OBJECT_LOCK (vscale);
362 vscale->submethod = g_value_get_int (value);
363 GST_OBJECT_UNLOCK (vscale);
366 GST_OBJECT_LOCK (vscale);
367 vscale->envelope = g_value_get_double (value);
368 GST_OBJECT_UNLOCK (vscale);
370 case PROP_GAMMA_DECODE:
371 GST_OBJECT_LOCK (vscale);
372 vscale->gamma_decode = g_value_get_boolean (value);
373 GST_OBJECT_UNLOCK (vscale);
376 GST_OBJECT_LOCK (vscale);
377 vscale->n_threads = g_value_get_uint (value);
378 GST_OBJECT_UNLOCK (vscale);
381 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
387 gst_video_scale_get_property (GObject * object, guint prop_id, GValue * value,
390 GstVideoScale *vscale = GST_VIDEO_SCALE (object);
394 GST_OBJECT_LOCK (vscale);
395 g_value_set_enum (value, vscale->method);
396 GST_OBJECT_UNLOCK (vscale);
398 case PROP_ADD_BORDERS:
399 GST_OBJECT_LOCK (vscale);
400 g_value_set_boolean (value, vscale->add_borders);
401 GST_OBJECT_UNLOCK (vscale);
404 GST_OBJECT_LOCK (vscale);
405 g_value_set_double (value, vscale->sharpness);
406 GST_OBJECT_UNLOCK (vscale);
409 GST_OBJECT_LOCK (vscale);
410 g_value_set_double (value, vscale->sharpen);
411 GST_OBJECT_UNLOCK (vscale);
414 GST_OBJECT_LOCK (vscale);
415 g_value_set_boolean (value, vscale->dither);
416 GST_OBJECT_UNLOCK (vscale);
419 GST_OBJECT_LOCK (vscale);
420 g_value_set_int (value, vscale->submethod);
421 GST_OBJECT_UNLOCK (vscale);
424 GST_OBJECT_LOCK (vscale);
425 g_value_set_double (value, vscale->envelope);
426 GST_OBJECT_UNLOCK (vscale);
428 case PROP_GAMMA_DECODE:
429 GST_OBJECT_LOCK (vscale);
430 g_value_set_boolean (value, vscale->gamma_decode);
431 GST_OBJECT_UNLOCK (vscale);
434 GST_OBJECT_LOCK (vscale);
435 g_value_set_uint (value, vscale->n_threads);
436 GST_OBJECT_UNLOCK (vscale);
439 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
445 gst_video_scale_transform_caps (GstBaseTransform * trans,
446 GstPadDirection direction, GstCaps * caps, GstCaps * filter)
449 GstStructure *structure;
450 GstCapsFeatures *features;
453 GST_DEBUG_OBJECT (trans,
454 "Transforming caps %" GST_PTR_FORMAT " in direction %s", caps,
455 (direction == GST_PAD_SINK) ? "sink" : "src");
457 ret = gst_caps_new_empty ();
458 n = gst_caps_get_size (caps);
459 for (i = 0; i < n; i++) {
460 structure = gst_caps_get_structure (caps, i);
461 features = gst_caps_get_features (caps, i);
463 /* If this is already expressed by the existing caps
464 * skip this structure */
465 if (i > 0 && gst_caps_is_subset_structure_full (ret, structure, features))
469 structure = gst_structure_copy (structure);
471 /* If the features are non-sysmem we can only do passthrough */
472 if (!gst_caps_features_is_any (features)
473 && gst_caps_features_is_equal (features,
474 GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY)) {
475 gst_structure_set (structure, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
476 "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
478 /* if pixel aspect ratio, make a range of it */
479 if (gst_structure_has_field (structure, "pixel-aspect-ratio")) {
480 gst_structure_set (structure, "pixel-aspect-ratio",
481 GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, NULL);
484 gst_caps_append_structure_full (ret, structure,
485 gst_caps_features_copy (features));
489 GstCaps *intersection;
492 gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST);
493 gst_caps_unref (ret);
497 GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret);
503 gst_video_scale_transform_meta (GstBaseTransform * trans, GstBuffer * inbuf,
504 GstMeta * meta, GstBuffer * outbuf)
506 GstVideoFilter *videofilter = GST_VIDEO_FILTER (trans);
507 const GstMetaInfo *info = meta->info;
508 const gchar *const *tags;
509 const gchar *const *curr = NULL;
510 gboolean should_copy = TRUE;
511 const gchar *const valid_tags[] = { GST_META_TAG_VIDEO_STR,
512 GST_META_TAG_VIDEO_COLORSPACE_STR,
513 GST_META_TAG_VIDEO_ORIENTATION_STR,
514 GST_META_TAG_VIDEO_SIZE_STR
517 tags = gst_meta_api_type_get_tags (info->api);
519 /* No specific tags, we are good to copy */
524 /* We are only changing size, we can preserve other metas tagged as
525 orientation and colorspace */
526 for (curr = tags; *curr; ++curr) {
528 /* We dont handle any other tag */
529 if (!g_strv_contains (valid_tags, *curr)) {
535 /* Cant handle the tags in this meta, let the parent class handle it */
537 return GST_BASE_TRANSFORM_CLASS (parent_class)->transform_meta (trans,
538 inbuf, meta, outbuf);
541 /* This meta is size sensitive, try to transform it accordingly */
542 if (gst_meta_api_type_has_tag (info->api, _size_quark)) {
543 GstVideoMetaTransform trans =
544 { &videofilter->in_info, &videofilter->out_info };
546 return info->transform_func (outbuf, meta, inbuf, _scale_quark, &trans);
549 /* No need to transform, we can safely copy this meta */
554 gst_video_scale_set_info (GstVideoFilter * filter, GstCaps * in,
555 GstVideoInfo * in_info, GstCaps * out, GstVideoInfo * out_info)
557 GstVideoScale *videoscale = GST_VIDEO_SCALE (filter);
558 gint from_dar_n, from_dar_d, to_dar_n, to_dar_d;
560 if (!gst_util_fraction_multiply (in_info->width,
561 in_info->height, in_info->par_n, in_info->par_d, &from_dar_n,
563 from_dar_n = from_dar_d = -1;
566 if (!gst_util_fraction_multiply (out_info->width,
567 out_info->height, out_info->par_n, out_info->par_d, &to_dar_n,
569 to_dar_n = to_dar_d = -1;
572 videoscale->borders_w = videoscale->borders_h = 0;
573 if (to_dar_n != from_dar_n || to_dar_d != from_dar_d) {
574 if (videoscale->add_borders) {
575 gint n, d, to_h, to_w;
577 if (from_dar_n != -1 && from_dar_d != -1
578 && gst_util_fraction_multiply (from_dar_n, from_dar_d,
579 out_info->par_d, out_info->par_n, &n, &d)) {
580 to_h = gst_util_uint64_scale_int (out_info->width, d, n);
581 if (to_h <= out_info->height) {
582 videoscale->borders_h = out_info->height - to_h;
583 videoscale->borders_w = 0;
585 to_w = gst_util_uint64_scale_int (out_info->height, n, d);
586 g_assert (to_w <= out_info->width);
587 videoscale->borders_h = 0;
588 videoscale->borders_w = out_info->width - to_w;
591 GST_WARNING_OBJECT (videoscale, "Can't calculate borders");
594 GST_WARNING_OBJECT (videoscale, "Can't keep DAR!");
598 if (in_info->width == out_info->width && in_info->height == out_info->height
599 && videoscale->borders_w == 0 && videoscale->borders_h == 0) {
600 gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), TRUE);
602 GstStructure *options;
603 GST_CAT_DEBUG_OBJECT (CAT_PERFORMANCE, filter, "setup videoscaling");
604 gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), FALSE);
606 options = gst_structure_new_empty ("videoscale");
608 switch (videoscale->method) {
609 case GST_VIDEO_SCALE_NEAREST:
610 gst_structure_set (options,
611 GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
612 GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_NEAREST,
615 case GST_VIDEO_SCALE_BILINEAR:
616 gst_structure_set (options,
617 GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
618 GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_LINEAR,
619 GST_VIDEO_RESAMPLER_OPT_MAX_TAPS, G_TYPE_INT, 2, NULL);
621 case GST_VIDEO_SCALE_4TAP:
622 gst_structure_set (options,
623 GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
624 GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_SINC,
625 GST_VIDEO_RESAMPLER_OPT_MAX_TAPS, G_TYPE_INT, 4, NULL);
627 case GST_VIDEO_SCALE_LANCZOS:
628 gst_structure_set (options,
629 GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
630 GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_LANCZOS,
633 case GST_VIDEO_SCALE_BILINEAR2:
634 gst_structure_set (options,
635 GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
636 GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_LINEAR,
639 case GST_VIDEO_SCALE_SINC:
640 gst_structure_set (options,
641 GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
642 GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_SINC,
645 case GST_VIDEO_SCALE_HERMITE:
646 gst_structure_set (options,
647 GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
648 GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_CUBIC,
649 GST_VIDEO_RESAMPLER_OPT_CUBIC_B, G_TYPE_DOUBLE, (gdouble) 0.0,
650 GST_VIDEO_RESAMPLER_OPT_CUBIC_C, G_TYPE_DOUBLE, (gdouble) 0.0,
653 case GST_VIDEO_SCALE_SPLINE:
654 gst_structure_set (options,
655 GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
656 GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_CUBIC,
657 GST_VIDEO_RESAMPLER_OPT_CUBIC_B, G_TYPE_DOUBLE, (gdouble) 1.0,
658 GST_VIDEO_RESAMPLER_OPT_CUBIC_C, G_TYPE_DOUBLE, (gdouble) 0.0,
661 case GST_VIDEO_SCALE_CATROM:
662 gst_structure_set (options,
663 GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
664 GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_CUBIC,
665 GST_VIDEO_RESAMPLER_OPT_CUBIC_B, G_TYPE_DOUBLE, (gdouble) 0.0,
666 GST_VIDEO_RESAMPLER_OPT_CUBIC_C, G_TYPE_DOUBLE, (gdouble) 0.5,
669 case GST_VIDEO_SCALE_MITCHELL:
670 gst_structure_set (options,
671 GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
672 GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_CUBIC,
673 GST_VIDEO_RESAMPLER_OPT_CUBIC_B, G_TYPE_DOUBLE, (gdouble) 1.0 / 3.0,
674 GST_VIDEO_RESAMPLER_OPT_CUBIC_C, G_TYPE_DOUBLE, (gdouble) 1.0 / 3.0,
678 gst_structure_set (options,
679 GST_VIDEO_RESAMPLER_OPT_ENVELOPE, G_TYPE_DOUBLE, videoscale->envelope,
680 GST_VIDEO_RESAMPLER_OPT_SHARPNESS, G_TYPE_DOUBLE, videoscale->sharpness,
681 GST_VIDEO_RESAMPLER_OPT_SHARPEN, G_TYPE_DOUBLE, videoscale->sharpen,
682 GST_VIDEO_CONVERTER_OPT_DEST_X, G_TYPE_INT, videoscale->borders_w / 2,
683 GST_VIDEO_CONVERTER_OPT_DEST_Y, G_TYPE_INT, videoscale->borders_h / 2,
684 GST_VIDEO_CONVERTER_OPT_DEST_WIDTH, G_TYPE_INT,
685 out_info->width - videoscale->borders_w,
686 GST_VIDEO_CONVERTER_OPT_DEST_HEIGHT, G_TYPE_INT,
687 out_info->height - videoscale->borders_h,
688 GST_VIDEO_CONVERTER_OPT_MATRIX_MODE, GST_TYPE_VIDEO_MATRIX_MODE,
689 GST_VIDEO_MATRIX_MODE_NONE, GST_VIDEO_CONVERTER_OPT_DITHER_METHOD,
690 GST_TYPE_VIDEO_DITHER_METHOD, GST_VIDEO_DITHER_NONE,
691 GST_VIDEO_CONVERTER_OPT_CHROMA_MODE, GST_TYPE_VIDEO_CHROMA_MODE,
692 GST_VIDEO_CHROMA_MODE_NONE,
693 GST_VIDEO_CONVERTER_OPT_THREADS, G_TYPE_UINT, videoscale->n_threads,
696 if (videoscale->gamma_decode) {
697 gst_structure_set (options,
698 GST_VIDEO_CONVERTER_OPT_GAMMA_MODE, GST_TYPE_VIDEO_GAMMA_MODE,
699 GST_VIDEO_GAMMA_MODE_REMAP, NULL);
702 if (videoscale->convert)
703 gst_video_converter_free (videoscale->convert);
704 videoscale->convert = gst_video_converter_new (in_info, out_info, options);
707 GST_DEBUG_OBJECT (videoscale, "from=%dx%d (par=%d/%d dar=%d/%d), size %"
708 G_GSIZE_FORMAT " -> to=%dx%d (par=%d/%d dar=%d/%d borders=%d:%d), "
709 "size %" G_GSIZE_FORMAT,
710 in_info->width, in_info->height, in_info->par_n, in_info->par_d,
711 from_dar_n, from_dar_d, in_info->size, out_info->width,
712 out_info->height, out_info->par_n, out_info->par_d, to_dar_n, to_dar_d,
713 videoscale->borders_w, videoscale->borders_h, out_info->size);
719 gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction,
720 GstCaps * caps, GstCaps * othercaps)
722 GstStructure *ins, *outs;
723 const GValue *from_par, *to_par;
724 GValue fpar = { 0, };
725 GValue tpar = { 0, };
727 othercaps = gst_caps_truncate (othercaps);
728 othercaps = gst_caps_make_writable (othercaps);
730 GST_DEBUG_OBJECT (base, "trying to fixate othercaps %" GST_PTR_FORMAT
731 " based on caps %" GST_PTR_FORMAT, othercaps, caps);
733 ins = gst_caps_get_structure (caps, 0);
734 outs = gst_caps_get_structure (othercaps, 0);
736 from_par = gst_structure_get_value (ins, "pixel-aspect-ratio");
737 to_par = gst_structure_get_value (outs, "pixel-aspect-ratio");
739 /* If we're fixating from the sinkpad we always set the PAR and
740 * assume that missing PAR on the sinkpad means 1/1 and
741 * missing PAR on the srcpad means undefined
743 if (direction == GST_PAD_SINK) {
745 g_value_init (&fpar, GST_TYPE_FRACTION);
746 gst_value_set_fraction (&fpar, 1, 1);
750 g_value_init (&tpar, GST_TYPE_FRACTION_RANGE);
751 gst_value_set_fraction_range_full (&tpar, 1, G_MAXINT, G_MAXINT, 1);
756 g_value_init (&tpar, GST_TYPE_FRACTION);
757 gst_value_set_fraction (&tpar, 1, 1);
760 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
764 g_value_init (&fpar, GST_TYPE_FRACTION);
765 gst_value_set_fraction (&fpar, 1, 1);
770 /* we have both PAR but they might not be fixated */
772 gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d;
774 gint from_dar_n, from_dar_d;
777 /* from_par should be fixed */
778 g_return_val_if_fail (gst_value_is_fixed (from_par), othercaps);
780 from_par_n = gst_value_get_fraction_numerator (from_par);
781 from_par_d = gst_value_get_fraction_denominator (from_par);
783 gst_structure_get_int (ins, "width", &from_w);
784 gst_structure_get_int (ins, "height", &from_h);
786 gst_structure_get_int (outs, "width", &w);
787 gst_structure_get_int (outs, "height", &h);
789 /* if both width and height are already fixed, we can't do anything
790 * about it anymore */
794 GST_DEBUG_OBJECT (base, "dimensions already set to %dx%d, not fixating",
796 if (!gst_value_is_fixed (to_par)) {
797 if (gst_video_calculate_display_ratio (&n, &d, from_w, from_h,
798 from_par_n, from_par_d, w, h)) {
799 GST_DEBUG_OBJECT (base, "fixating to_par to %dx%d", n, d);
800 if (gst_structure_has_field (outs, "pixel-aspect-ratio"))
801 gst_structure_fixate_field_nearest_fraction (outs,
802 "pixel-aspect-ratio", n, d);
804 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
811 /* Calculate input DAR */
812 if (!gst_util_fraction_multiply (from_w, from_h, from_par_n, from_par_d,
813 &from_dar_n, &from_dar_d)) {
814 GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
815 ("Error calculating the output scaled size - integer overflow"));
819 GST_DEBUG_OBJECT (base, "Input DAR is %d/%d", from_dar_n, from_dar_d);
821 /* If either width or height are fixed there's not much we
822 * can do either except choosing a height or width and PAR
823 * that matches the DAR as good as possible
827 gint set_w, set_par_n, set_par_d;
829 GST_DEBUG_OBJECT (base, "height is fixed (%d)", h);
831 /* If the PAR is fixed too, there's not much to do
832 * except choosing the width that is nearest to the
833 * width with the same DAR */
834 if (gst_value_is_fixed (to_par)) {
835 to_par_n = gst_value_get_fraction_numerator (to_par);
836 to_par_d = gst_value_get_fraction_denominator (to_par);
838 GST_DEBUG_OBJECT (base, "PAR is fixed %d/%d", to_par_n, to_par_d);
840 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_d,
841 to_par_n, &num, &den)) {
842 GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
843 ("Error calculating the output scaled size - integer overflow"));
847 w = (guint) gst_util_uint64_scale_int_round (h, num, den);
848 gst_structure_fixate_field_nearest_int (outs, "width", w);
853 /* The PAR is not fixed and it's quite likely that we can set
854 * an arbitrary PAR. */
856 /* Check if we can keep the input width */
857 tmp = gst_structure_copy (outs);
858 gst_structure_fixate_field_nearest_int (tmp, "width", from_w);
859 gst_structure_get_int (tmp, "width", &set_w);
861 /* Might have failed but try to keep the DAR nonetheless by
862 * adjusting the PAR */
863 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, h, set_w,
864 &to_par_n, &to_par_d)) {
865 GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
866 ("Error calculating the output scaled size - integer overflow"));
867 gst_structure_free (tmp);
871 if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
872 gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
873 gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
875 gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
877 gst_structure_free (tmp);
879 /* Check if the adjusted PAR is accepted */
880 if (set_par_n == to_par_n && set_par_d == to_par_d) {
881 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
882 set_par_n != set_par_d)
883 gst_structure_set (outs, "width", G_TYPE_INT, set_w,
884 "pixel-aspect-ratio", GST_TYPE_FRACTION, set_par_n, set_par_d,
889 /* Otherwise scale the width to the new PAR and check if the
890 * adjusted with is accepted. If all that fails we can't keep
892 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_par_d,
893 set_par_n, &num, &den)) {
894 GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
895 ("Error calculating the output scaled size - integer overflow"));
899 w = (guint) gst_util_uint64_scale_int_round (h, num, den);
900 gst_structure_fixate_field_nearest_int (outs, "width", w);
901 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
902 set_par_n != set_par_d)
903 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
904 set_par_n, set_par_d, NULL);
909 gint set_h, set_par_n, set_par_d;
911 GST_DEBUG_OBJECT (base, "width is fixed (%d)", w);
913 /* If the PAR is fixed too, there's not much to do
914 * except choosing the height that is nearest to the
915 * height with the same DAR */
916 if (gst_value_is_fixed (to_par)) {
917 to_par_n = gst_value_get_fraction_numerator (to_par);
918 to_par_d = gst_value_get_fraction_denominator (to_par);
920 GST_DEBUG_OBJECT (base, "PAR is fixed %d/%d", to_par_n, to_par_d);
922 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_d,
923 to_par_n, &num, &den)) {
924 GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
925 ("Error calculating the output scaled size - integer overflow"));
929 h = (guint) gst_util_uint64_scale_int_round (w, den, num);
930 gst_structure_fixate_field_nearest_int (outs, "height", h);
935 /* The PAR is not fixed and it's quite likely that we can set
936 * an arbitrary PAR. */
938 /* Check if we can keep the input height */
939 tmp = gst_structure_copy (outs);
940 gst_structure_fixate_field_nearest_int (tmp, "height", from_h);
941 gst_structure_get_int (tmp, "height", &set_h);
943 /* Might have failed but try to keep the DAR nonetheless by
944 * adjusting the PAR */
945 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_h, w,
946 &to_par_n, &to_par_d)) {
947 GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
948 ("Error calculating the output scaled size - integer overflow"));
949 gst_structure_free (tmp);
952 if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
953 gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
954 gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
956 gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
958 gst_structure_free (tmp);
960 /* Check if the adjusted PAR is accepted */
961 if (set_par_n == to_par_n && set_par_d == to_par_d) {
962 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
963 set_par_n != set_par_d)
964 gst_structure_set (outs, "height", G_TYPE_INT, set_h,
965 "pixel-aspect-ratio", GST_TYPE_FRACTION, set_par_n, set_par_d,
970 /* Otherwise scale the height to the new PAR and check if the
971 * adjusted with is accepted. If all that fails we can't keep
973 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_par_d,
974 set_par_n, &num, &den)) {
975 GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
976 ("Error calculating the output scaled size - integer overflow"));
980 h = (guint) gst_util_uint64_scale_int_round (w, den, num);
981 gst_structure_fixate_field_nearest_int (outs, "height", h);
982 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
983 set_par_n != set_par_d)
984 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
985 set_par_n, set_par_d, NULL);
988 } else if (gst_value_is_fixed (to_par)) {
990 gint set_h, set_w, f_h, f_w;
992 to_par_n = gst_value_get_fraction_numerator (to_par);
993 to_par_d = gst_value_get_fraction_denominator (to_par);
995 /* Calculate scale factor for the PAR change */
996 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_n,
997 to_par_d, &num, &den)) {
998 GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
999 ("Error calculating the output scaled size - integer overflow"));
1003 /* Try to keep the input height (because of interlacing) */
1004 tmp = gst_structure_copy (outs);
1005 gst_structure_fixate_field_nearest_int (tmp, "height", from_h);
1006 gst_structure_get_int (tmp, "height", &set_h);
1008 /* This might have failed but try to scale the width
1009 * to keep the DAR nonetheless */
1010 w = (guint) gst_util_uint64_scale_int_round (set_h, num, den);
1011 gst_structure_fixate_field_nearest_int (tmp, "width", w);
1012 gst_structure_get_int (tmp, "width", &set_w);
1013 gst_structure_free (tmp);
1015 /* We kept the DAR and the height is nearest to the original height */
1017 gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
1018 G_TYPE_INT, set_h, NULL);
1025 /* If the former failed, try to keep the input width at least */
1026 tmp = gst_structure_copy (outs);
1027 gst_structure_fixate_field_nearest_int (tmp, "width", from_w);
1028 gst_structure_get_int (tmp, "width", &set_w);
1030 /* This might have failed but try to scale the width
1031 * to keep the DAR nonetheless */
1032 h = (guint) gst_util_uint64_scale_int_round (set_w, den, num);
1033 gst_structure_fixate_field_nearest_int (tmp, "height", h);
1034 gst_structure_get_int (tmp, "height", &set_h);
1035 gst_structure_free (tmp);
1037 /* We kept the DAR and the width is nearest to the original width */
1039 gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
1040 G_TYPE_INT, set_h, NULL);
1044 /* If all this failed, keep the dimensions with the DAR that was closest
1045 * to the correct DAR. This changes the DAR but there's not much else to
1048 if (set_w * ABS (set_h - h) < ABS (f_w - w) * f_h) {
1052 gst_structure_set (outs, "width", G_TYPE_INT, f_w, "height", G_TYPE_INT,
1057 gint set_h, set_w, set_par_n, set_par_d, tmp2;
1059 /* width, height and PAR are not fixed but passthrough is not possible */
1061 /* First try to keep the height and width as good as possible
1063 tmp = gst_structure_copy (outs);
1064 gst_structure_fixate_field_nearest_int (tmp, "height", from_h);
1065 gst_structure_get_int (tmp, "height", &set_h);
1066 gst_structure_fixate_field_nearest_int (tmp, "width", from_w);
1067 gst_structure_get_int (tmp, "width", &set_w);
1069 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_h, set_w,
1070 &to_par_n, &to_par_d)) {
1071 GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
1072 ("Error calculating the output scaled size - integer overflow"));
1073 gst_structure_free (tmp);
1077 if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
1078 gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
1079 gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
1080 to_par_n, to_par_d);
1081 gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
1083 gst_structure_free (tmp);
1085 if (set_par_n == to_par_n && set_par_d == to_par_d) {
1086 gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
1087 G_TYPE_INT, set_h, NULL);
1089 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
1090 set_par_n != set_par_d)
1091 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
1092 set_par_n, set_par_d, NULL);
1096 /* Otherwise try to scale width to keep the DAR with the set
1098 if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_par_d,
1099 set_par_n, &num, &den)) {
1100 GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
1101 ("Error calculating the output scaled size - integer overflow"));
1105 w = (guint) gst_util_uint64_scale_int_round (set_h, num, den);
1106 tmp = gst_structure_copy (outs);
1107 gst_structure_fixate_field_nearest_int (tmp, "width", w);
1108 gst_structure_get_int (tmp, "width", &tmp2);
1109 gst_structure_free (tmp);
1112 gst_structure_set (outs, "width", G_TYPE_INT, tmp2, "height",
1113 G_TYPE_INT, set_h, NULL);
1114 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
1115 set_par_n != set_par_d)
1116 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
1117 set_par_n, set_par_d, NULL);
1121 /* ... or try the same with the height */
1122 h = (guint) gst_util_uint64_scale_int_round (set_w, den, num);
1123 tmp = gst_structure_copy (outs);
1124 gst_structure_fixate_field_nearest_int (tmp, "height", h);
1125 gst_structure_get_int (tmp, "height", &tmp2);
1126 gst_structure_free (tmp);
1129 gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
1130 G_TYPE_INT, tmp2, NULL);
1131 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
1132 set_par_n != set_par_d)
1133 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
1134 set_par_n, set_par_d, NULL);
1138 /* If all fails we can't keep the DAR and take the nearest values
1139 * for everything from the first try */
1140 gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
1141 G_TYPE_INT, set_h, NULL);
1142 if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
1143 set_par_n != set_par_d)
1144 gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
1145 set_par_n, set_par_d, NULL);
1150 GST_DEBUG_OBJECT (base, "fixated othercaps to %" GST_PTR_FORMAT, othercaps);
1152 if (from_par == &fpar)
1153 g_value_unset (&fpar);
1154 if (to_par == &tpar)
1155 g_value_unset (&tpar);
1160 #define GET_LINE(frame, line) \
1161 (gpointer)(((guint8*)(GST_VIDEO_FRAME_PLANE_DATA (frame, 0))) + \
1162 GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0) * (line))
1164 static GstFlowReturn
1165 gst_video_scale_transform_frame (GstVideoFilter * filter,
1166 GstVideoFrame * in_frame, GstVideoFrame * out_frame)
1168 GstVideoScale *videoscale = GST_VIDEO_SCALE_CAST (filter);
1169 GstFlowReturn ret = GST_FLOW_OK;
1171 GST_CAT_DEBUG_OBJECT (CAT_PERFORMANCE, filter, "doing video scaling");
1173 gst_video_converter_frame (videoscale->convert, in_frame, out_frame);
1179 gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event)
1181 GstVideoScale *videoscale = GST_VIDEO_SCALE_CAST (trans);
1182 GstVideoFilter *filter = GST_VIDEO_FILTER_CAST (trans);
1185 GstStructure *structure;
1187 GST_DEBUG_OBJECT (videoscale, "handling %s event",
1188 GST_EVENT_TYPE_NAME (event));
1190 switch (GST_EVENT_TYPE (event)) {
1191 case GST_EVENT_NAVIGATION:
1192 if (filter->in_info.width != filter->out_info.width ||
1193 filter->in_info.height != filter->out_info.height) {
1195 GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
1197 structure = (GstStructure *) gst_event_get_structure (event);
1198 if (gst_structure_get_double (structure, "pointer_x", &a)) {
1199 gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
1200 a * filter->in_info.width / filter->out_info.width, NULL);
1202 if (gst_structure_get_double (structure, "pointer_y", &a)) {
1203 gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
1204 a * filter->in_info.height / filter->out_info.height, NULL);
1212 ret = GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans, event);
1218 plugin_init (GstPlugin * plugin)
1220 if (!gst_element_register (plugin, "videoscale", GST_RANK_NONE,
1221 GST_TYPE_VIDEO_SCALE))
1224 GST_DEBUG_CATEGORY_INIT (video_scale_debug, "videoscale", 0,
1225 "videoscale element");
1226 GST_DEBUG_CATEGORY_GET (CAT_PERFORMANCE, "GST_PERFORMANCE");
1231 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
1234 "Resizes video", plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME,