From 9f677090d52ce2761b6c0a59447f5f7f566b6539 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 10 May 2010 15:13:20 +0200 Subject: [PATCH] videoscale: Log PAR and DAR of input and output caps when setting caps --- gst/videoscale/gstvideoscale.c | 43 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/gst/videoscale/gstvideoscale.c b/gst/videoscale/gstvideoscale.c index f11873e..a6f1db8 100644 --- a/gst/videoscale/gstvideoscale.c +++ b/gst/videoscale/gstvideoscale.c @@ -488,6 +488,10 @@ gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out) { GstVideoScale *videoscale = GST_VIDEO_SCALE (trans); gboolean ret; + const GstStructure *ins, *outs; + gint from_dar_n, from_dar_d, to_dar_n, to_dar_d; + gint from_par_n, from_par_d, to_par_n, to_par_d; + gint gcd; ret = parse_caps (in, &videoscale->format, &videoscale->from_width, &videoscale->from_height, &videoscale->interlaced); @@ -515,10 +519,41 @@ gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out) videoscale->tmp_buf = g_malloc (videoscale->dest.stride * 4 * (videoscale->interlaced ? 2 : 1)); - /* FIXME: par */ - GST_DEBUG_OBJECT (videoscale, "from=%dx%d, size %d -> to=%dx%d, size %d", - videoscale->from_width, videoscale->from_height, videoscale->src_size, - videoscale->to_width, videoscale->to_height, videoscale->dest_size); + ins = gst_caps_get_structure (in, 0); + outs = gst_caps_get_structure (out, 0); + + if (!gst_structure_get_fraction (ins, "pixel-aspect-ratio", &from_par_n, + &from_par_d)) + from_par_n = from_par_d = 1; + if (!gst_structure_get_fraction (outs, "pixel-aspect-ratio", &to_par_n, + &to_par_d)) + to_par_n = to_par_d = 1; + + if (gst_util_fraction_multiply (videoscale->from_width, + videoscale->from_height, from_par_n, from_par_d, &from_dar_n, + &from_dar_d)) { + gcd = gst_util_greatest_common_divisor (from_dar_n, from_dar_d); + from_dar_n /= gcd; + from_dar_d /= gcd; + } else { + from_dar_n = from_dar_d = -1; + } + + if (gst_util_fraction_multiply (videoscale->to_width, videoscale->to_height, + to_par_n, to_par_d, &to_dar_n, &to_dar_d)) { + gcd = gst_util_greatest_common_divisor (to_dar_n, to_dar_d); + to_dar_n /= gcd; + to_dar_d /= gcd; + } else { + to_dar_n = to_dar_d = -1; + } + + GST_DEBUG_OBJECT (videoscale, "from=%dx%d (par=%d/%d dar=%d/%d), size %d " + "-> to=%dx%d (par=%d/%d dar=%d/%d), size %d", + videoscale->from_width, videoscale->from_height, from_par_n, from_par_d, + from_dar_n, from_dar_d, videoscale->src_size, videoscale->to_width, + videoscale->to_height, to_par_n, to_par_d, to_dar_n, to_dar_d, + videoscale->dest_size); done: return ret; -- 2.7.4