From 8b14d081150950152e680809553e0c1595665365 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 4 Jun 2008 04:24:27 +0000 Subject: [PATCH] gst/videoscale/gstvideoscale.c: Prefer the given format if it contains something stricter than [1,MAX] for height or ... Original commit message from CVS: * gst/videoscale/gstvideoscale.c: (gst_video_scale_transform_caps): Prefer the given format if it contains something stricter than [1,MAX] for height or width and only put a structure that requires rescaling as second. This makes it possible to use videoscale in pipelines where the source can actually produce the wanted height/width but usually selects a different one from the requested. --- ChangeLog | 9 +++++++++ gst/videoscale/gstvideoscale.c | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8fb020e..2110bd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-06-04 Sebastian Dröge + + * gst/videoscale/gstvideoscale.c: (gst_video_scale_transform_caps): + Prefer the given format if it contains something stricter than [1,MAX] + for height or width and only put a structure that requires rescaling + as second. This makes it possible to use videoscale in pipelines where + the source can actually produce the wanted height/width but usually + selects a different one from the requested. + 2008-06-03 Tim-Philipp Müller Based on patch by: John Millikin diff --git a/gst/videoscale/gstvideoscale.c b/gst/videoscale/gstvideoscale.c index aa19c8d..24302c9 100644 --- a/gst/videoscale/gstvideoscale.c +++ b/gst/videoscale/gstvideoscale.c @@ -139,6 +139,7 @@ static GType gst_video_scale_method_get_type (void) { static GType video_scale_method_type = 0; + static const GEnumValue video_scale_methods[] = { {GST_VIDEO_SCALE_NEAREST, "Nearest Neighbour", "nearest-neighbour"}, {GST_VIDEO_SCALE_BILINEAR, "Bilinear", "bilinear"}, @@ -187,9 +188,13 @@ gst_video_scale_sink_template_factory (void) static void gst_video_scale_base_init (gpointer g_class); + static void gst_video_scale_class_init (GstVideoScaleClass * klass); + static void gst_video_scale_init (GstVideoScale * videoscale); + static void gst_video_scale_finalize (GstVideoScale * videoscale); + static gboolean gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event); @@ -255,6 +260,7 @@ static void gst_video_scale_class_init (GstVideoScaleClass * klass) { GObjectClass *gobject_class; + GstBaseTransformClass *trans_class; gobject_class = (GObjectClass *) klass; @@ -341,9 +347,13 @@ gst_video_scale_transform_caps (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps) { GstVideoScale *videoscale; + GstCaps *ret; + GstStructure *structure; + const GValue *par; + gint method; /* this function is always called with a simple caps */ @@ -371,15 +381,19 @@ gst_video_scale_transform_caps (GstBaseTransform * trans, } ret = gst_caps_copy (caps); - structure = gst_caps_get_structure (ret, 0); + structure = gst_structure_copy (gst_caps_get_structure (ret, 0)); gst_structure_set (structure, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT, "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL); + gst_caps_merge_structure (ret, structure); + structure = gst_caps_get_structure (ret, 0); + /* if pixel aspect ratio, make a range of it */ if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio"))) { GstCaps *copy; + GstStructure *cstruct; /* copy input PAR first, this is the prefered PAR */ @@ -411,6 +425,7 @@ static int gst_video_scale_get_format (GstCaps * caps) { int i; + GstCaps *icaps, *scaps; for (i = 0; i < G_N_ELEMENTS (gst_video_scale_format_caps); i++) { @@ -505,6 +520,7 @@ static gboolean parse_caps (GstCaps * caps, gint * format, gint * width, gint * height) { gboolean ret; + GstStructure *structure; structure = gst_caps_get_structure (caps, 0); @@ -521,6 +537,7 @@ static gboolean gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out) { GstVideoScale *videoscale; + gboolean ret; videoscale = GST_VIDEO_SCALE (trans); @@ -562,7 +579,9 @@ gst_video_scale_get_unit_size (GstBaseTransform * trans, GstCaps * caps, guint * size) { GstVideoScale *videoscale; + gint format, width, height; + VSImage img; g_assert (size); @@ -584,6 +603,7 @@ gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction, GstCaps * caps, GstCaps * othercaps) { GstStructure *ins, *outs; + const GValue *from_par, *to_par; g_return_if_fail (gst_caps_is_fixed (caps)); @@ -600,7 +620,9 @@ gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction, /* we have both PAR but they might not be fixated */ if (from_par && to_par) { gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d; + gint count = 0, w = 0, h = 0; + guint num, den; /* from_par should be fixed */ @@ -729,13 +751,21 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out) { GstVideoScale *videoscale; + GstFlowReturn ret = GST_FLOW_OK; + VSImage *dest; + VSImage *src; + VSImage dest_u; + VSImage dest_v; + VSImage src_u; + VSImage src_v; + gint method; videoscale = GST_VIDEO_SCALE (trans); @@ -884,8 +914,11 @@ static gboolean gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event) { GstVideoScale *videoscale; + gboolean ret; + double a; + GstStructure *structure; videoscale = GST_VIDEO_SCALE (trans); -- 2.7.4