From f00af192c92fa64e7078b5a3adc89f0784e2d32e Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Thu, 24 Mar 2011 14:14:09 +0200 Subject: [PATCH] spectrum: fix the error accumulation and frames_todo handling Even though we wrap around the accumulated second, we still need to add the error in the same cycle. Increase the todo in the same conditional as afterwards the accumulated error will be below one second. --- gst/spectrum/gstspectrum.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c index 272d9032c3..0bef4c15d7 100644 --- a/gst/spectrum/gstspectrum.c +++ b/gst/spectrum/gstspectrum.c @@ -1006,14 +1006,12 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer) spectrum->num_frames, spectrum->frames_per_interval, GST_TIME_ARGS (spectrum->accumulated_error)); - if (spectrum->accumulated_error >= GST_SECOND) - spectrum->accumulated_error -= GST_SECOND; - else - spectrum->accumulated_error += spectrum->error_per_interval; - spectrum->frames_todo = spectrum->frames_per_interval; - if (spectrum->accumulated_error >= GST_SECOND) + if (spectrum->accumulated_error >= GST_SECOND) { + spectrum->accumulated_error -= GST_SECOND; spectrum->frames_todo++; + } + spectrum->accumulated_error += spectrum->error_per_interval; if (spectrum->post_messages) { GstMessage *m; @@ -1072,14 +1070,12 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer) spectrum->num_frames, spectrum->frames_per_interval, GST_TIME_ARGS (spectrum->accumulated_error)); - if (spectrum->accumulated_error >= GST_SECOND) - spectrum->accumulated_error -= GST_SECOND; - else - spectrum->accumulated_error += spectrum->error_per_interval; - spectrum->frames_todo = spectrum->frames_per_interval; - if (spectrum->accumulated_error >= GST_SECOND) + if (spectrum->accumulated_error >= GST_SECOND) { + spectrum->accumulated_error -= GST_SECOND; spectrum->frames_todo++; + } + spectrum->accumulated_error += spectrum->error_per_interval; if (spectrum->post_messages) { GstMessage *m;