gst-plugins-good: spectrum: avoid unneccesary extra fft runs

Stefan Kost ensonic at kemper.freedesktop.org
Thu Mar 10 05:49:12 PST 2011


Module: gst-plugins-good
Branch: master
Commit: 1a32265b5108a4c7c7cc46b52ae84f12f3241050
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=1a32265b5108a4c7c7cc46b52ae84f12f3241050

Author: Stefan Kost <ensonic at users.sf.net>
Date:   Thu Mar 10 14:15:42 2011 +0200

spectrum: avoid unneccesary extra fft runs

Before it was possible that we run an extra fft when the time for sending a new
message is due. Only do this if we have not run the fft for the interval at all.

---

 gst/spectrum/gstspectrum.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c
index d09fbbe..ab3a556 100644
--- a/gst/spectrum/gstspectrum.c
+++ b/gst/spectrum/gstspectrum.c
@@ -986,10 +986,9 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
           );
 
       /* If we have enough frames for an FFT or we have all frames required for
-       * the interval run an FFT. In the last case we probably take the
-       * FFT of frames that we already handled.
-       */
-      if ((spectrum->num_frames % nfft == 0) || have_full_interval) {
+       * the interval and we haven't run a FFT, then run an FFT */
+      if ((spectrum->num_frames % nfft == 0) ||
+          (have_full_interval && !spectrum->num_fft)) {
         gst_spectrum_run_fft (spectrum, cd, input_pos);
         spectrum->num_fft++;
       }
@@ -1050,10 +1049,9 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
           );
 
       /* If we have enough frames for an FFT or we have all frames required for
-       * the interval run an FFT. In the last case we probably take the
-       * FFT of frames that we already handled.
-       */
-      if ((spectrum->num_frames % nfft == 0) || have_full_interval) {
+       * the interval and we haven't run a FFT, then run an FFT */
+      if ((spectrum->num_frames % nfft == 0) ||
+          (have_full_interval && !spectrum->num_fft)) {
         for (c = 0; c < channels; c++) {
           cd = &spectrum->channel_data[c];
           gst_spectrum_run_fft (spectrum, cd, input_pos);



More information about the gstreamer-commits mailing list