mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-09 00:45:56 +00:00
queue2: fix fill level arithmetic overflow with large values
Based on patch by: Aleksander Wabik <awabik@opera.com> https://bugzilla.gnome.org/show_bug.cgi?id=755971
This commit is contained in:
parent
ccec9e6b90
commit
6b5decf0e6
1 changed files with 18 additions and 1 deletions
|
@ -830,6 +830,22 @@ apply_buffer_list (GstQueue2 * queue, GstBufferList * buffer_list,
|
||||||
update_time_level (queue);
|
update_time_level (queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline gint
|
||||||
|
get_percent (guint64 cur_level, guint64 max_level, guint64 alt_max)
|
||||||
|
{
|
||||||
|
guint64 p;
|
||||||
|
|
||||||
|
if (max_level == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (alt_max > 0)
|
||||||
|
p = gst_util_uint64_scale (cur_level, 100, MIN (max_level, alt_max));
|
||||||
|
else
|
||||||
|
p = gst_util_uint64_scale (cur_level, 100, max_level);
|
||||||
|
|
||||||
|
return MIN (p, 100);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
get_buffering_percent (GstQueue2 * queue, gboolean * is_buffering,
|
get_buffering_percent (GstQueue2 * queue, gboolean * is_buffering,
|
||||||
gint * percent)
|
gint * percent)
|
||||||
|
@ -843,7 +859,8 @@ get_buffering_percent (GstQueue2 * queue, gboolean * is_buffering,
|
||||||
*is_buffering = FALSE;
|
*is_buffering = FALSE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#define GET_PERCENT(format,alt_max) ((queue->max_level.format) > 0 ? (queue->cur_level.format) * 100 / ((alt_max) > 0 ? MIN ((alt_max), (queue->max_level.format)) : (queue->max_level.format)) : 0)
|
#define GET_PERCENT(format,alt_max) \
|
||||||
|
get_percent(queue->cur_level.format,queue->max_level.format,(alt_max))
|
||||||
|
|
||||||
if (queue->is_eos) {
|
if (queue->is_eos) {
|
||||||
/* on EOS we are always 100% full, we set the var here so that it we can
|
/* on EOS we are always 100% full, we set the var here so that it we can
|
||||||
|
|
Loading…
Reference in a new issue