mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 04:22:27 +00:00
Add util method for scaling a clocktime by a fraction. Useful implementation is left as an exercise for the reader.
Original commit message from CVS: * gst/gstutils.c: (gst_util_clocktime_scale): * gst/gstutils.h: * docs/gst/gstreamer-sections.txt: Add util method for scaling a clocktime by a fraction. Useful implementation is left as an exercise for the reader.
This commit is contained in:
parent
2e248d331c
commit
4a36e535e9
4 changed files with 28 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
|||
2005-11-22 Michael Smith <msmith@fluendo.com>
|
||||
|
||||
* gst/gstutils.c: (gst_util_clocktime_scale):
|
||||
* gst/gstutils.h:
|
||||
* docs/gst/gstreamer-sections.txt:
|
||||
Add util method for scaling a clocktime by a fraction. Useful
|
||||
implementation is left as an exercise for the reader.
|
||||
|
||||
2005-11-22 Jan Schmidt <thaytan@mad.scientist.com>
|
||||
|
||||
* gst/gstvalue.c: (gst_value_collect_fraction_range):
|
||||
|
|
|
@ -2060,6 +2060,7 @@ gst_guint64_to_gdouble
|
|||
gst_gdouble_to_guint64
|
||||
gst_util_dump_mem
|
||||
gst_util_uint64_scale
|
||||
gst_util_clocktime_scale
|
||||
gst_util_set_object_arg
|
||||
gst_util_set_value_from_string
|
||||
<SUBSECTION Private>
|
||||
|
|
|
@ -358,6 +358,23 @@ gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom)
|
|||
((gst_guint64_to_gdouble (num)) / gst_guint64_to_gdouble (denom)));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_util_clocktime_scale:
|
||||
* @val: GstClockTime to scale.
|
||||
* @num: numerator of the scale factor.
|
||||
* @denum: denominator of the scale factor.
|
||||
*
|
||||
* Scale a clocktime by a factor expressed as a fraction (num/denom), avoiding
|
||||
* overflows and loss of precision.
|
||||
*
|
||||
* Returns: @val * @num / @denom, avoiding overflow and loss of precision
|
||||
*/
|
||||
GstClockTime
|
||||
gst_util_clocktime_scale (GstClockTime val, gint num, gint denom)
|
||||
{
|
||||
return val * num / denom;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------
|
||||
*
|
||||
* The following code will be moved out of the main
|
||||
|
|
|
@ -43,6 +43,8 @@ gdouble gst_guint64_to_gdouble (guint64 value);
|
|||
|
||||
guint64 gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom);
|
||||
|
||||
GstClockTime gst_util_clocktime_scale (GstClockTime val, gint num, gint denom);
|
||||
|
||||
void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad);
|
||||
void gst_print_element_args (GString *buf, gint indent, GstElement *element);
|
||||
|
||||
|
|
Loading…
Reference in a new issue