summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2010-05-13 08:05:09 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2010-05-13 11:16:02 +0200
commit30b67cda5d0441de6bce81a517fb3a6691c1d15e (patch)
tree49c67fe7748bc83463c6c26e426e1d30dbff35e8
parent303566654e254834c7ab21be790f31d4e3f6f8d5 (diff)
video: Use simple fraction multiplication functions instead of going through GValues
-rw-r--r--gst-libs/gst/video/video.c30
1 files changed, 5 insertions, 25 deletions
diff --git a/gst-libs/gst/video/video.c b/gst-libs/gst/video/video.c
index 3bb6f62ab..e5c2c8261 100644
--- a/gst-libs/gst/video/video.c
+++ b/gst-libs/gst/video/video.c
@@ -173,38 +173,21 @@ gst_video_calculate_display_ratio (guint * dar_n, guint * dar_d,
guint display_par_n, guint display_par_d)
{
gint num, den;
-
- GValue display_ratio = { 0, };
- GValue tmp = { 0, };
- GValue tmp2 = { 0, };
+ gint tmp_n, tmp_d;
g_return_val_if_fail (dar_n != NULL, FALSE);
g_return_val_if_fail (dar_d != NULL, FALSE);
- g_value_init (&display_ratio, GST_TYPE_FRACTION);
- g_value_init (&tmp, GST_TYPE_FRACTION);
- g_value_init (&tmp2, GST_TYPE_FRACTION);
-
/* Calculate (video_width * video_par_n * display_par_d) /
* (video_height * video_par_d * display_par_n) */
- gst_value_set_fraction (&display_ratio, video_width, video_height);
- gst_value_set_fraction (&tmp, video_par_n, video_par_d);
-
- if (!gst_value_fraction_multiply (&tmp2, &display_ratio, &tmp))
+ if (!gst_util_fraction_multiply (video_width, video_height, video_par_n,
+ video_par_d, &tmp_n, &tmp_d))
goto error_overflow;
- gst_value_set_fraction (&tmp, display_par_d, display_par_n);
-
- if (!gst_value_fraction_multiply (&display_ratio, &tmp2, &tmp))
+ if (!gst_util_fraction_multiply (tmp_n, tmp_d, display_par_d, display_par_n,
+ &num, &den))
goto error_overflow;
- num = gst_value_get_fraction_numerator (&display_ratio);
- den = gst_value_get_fraction_denominator (&display_ratio);
-
- g_value_unset (&display_ratio);
- g_value_unset (&tmp);
- g_value_unset (&tmp2);
-
g_return_val_if_fail (num > 0, FALSE);
g_return_val_if_fail (den > 0, FALSE);
@@ -213,9 +196,6 @@ gst_video_calculate_display_ratio (guint * dar_n, guint * dar_d,
return TRUE;
error_overflow:
- g_value_unset (&display_ratio);
- g_value_unset (&tmp);
- g_value_unset (&tmp2);
return FALSE;
}