From 0b52663815b94da0f72d1d64c97dee87a894b392 Mon Sep 17 00:00:00 2001 From: Colin Kinloch Date: Fri, 17 Feb 2023 19:16:33 +0000 Subject: [PATCH] fpsdisplaysink: Skip reporting on frame counter reset When the QoS stats are reset (e.g. changing the source) the counters for dropped + rendered frames are reset to zero which result in negative values for their difference. This results in max-fps getting pegged at an extremely high value. ``` fpsdisplaysink.c:373:display_current_fps: Updated max-fps to 36840705952231460864.000000 ``` Part-of: --- .../gst-plugins-bad/gst/debugutils/fpsdisplaysink.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/subprojects/gst-plugins-bad/gst/debugutils/fpsdisplaysink.c b/subprojects/gst-plugins-bad/gst/debugutils/fpsdisplaysink.c index e3da09275e..1ca8b6654d 100644 --- a/subprojects/gst-plugins-bad/gst/debugutils/fpsdisplaysink.c +++ b/subprojects/gst-plugins-bad/gst/debugutils/fpsdisplaysink.c @@ -360,6 +360,13 @@ display_current_fps (gpointer data) return TRUE; } + if (frames_rendered < self->last_frames_rendered || + frames_dropped < self->last_frames_dropped) { + /* avoid negative drop rates on reset */ + GST_DEBUG_OBJECT (self, "Frame counters have been reset, skipping update"); + goto update_last_values; + } + time_diff = (gdouble) (current_ts - self->last_ts) / GST_SECOND; time_elapsed = (gdouble) (current_ts - self->start_ts) / GST_SECOND; @@ -418,6 +425,7 @@ display_current_fps (gpointer data) g_object_notify_by_pspec ((GObject *) self, pspec_last_message); } +update_last_values: self->last_frames_rendered = frames_rendered; self->last_frames_dropped = frames_dropped; self->last_ts = current_ts;