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:<fpsdisplaysink0> Updated max-fps to 36840705952231460864.000000
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3989>
This commit is contained in:
Colin Kinloch 2023-02-17 19:16:33 +00:00 committed by GStreamer Marge Bot
parent 56cc2132da
commit 0b52663815

View file

@ -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;