gst-plugins-good: spectrum: only scale the vectors that we are processing

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


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

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

spectrum: only scale the vectors that we are processing

Phase is not produced by default, so lets not scale it unconditionally to save a
few cycles.

---

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

diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c
index ecc8a29..d09fbbe 100644
--- a/gst/spectrum/gstspectrum.c
+++ b/gst/spectrum/gstspectrum.c
@@ -889,13 +889,17 @@ gst_spectrum_prepare_message_data (GstSpectrum * spectrum,
   guint i;
   guint bands = spectrum->bands;
   guint num_fft = spectrum->num_fft;
-  gfloat *spect_magnitude = cd->spect_magnitude;
-  gfloat *spect_phase = cd->spect_phase;
 
   /* Calculate average */
-  for (i = 0; i < bands; i++) {
-    spect_magnitude[i] /= num_fft;
-    spect_phase[i] /= num_fft;
+  if (spectrum->message_magnitude) {
+    gfloat *spect_magnitude = cd->spect_magnitude;
+    for (i = 0; i < bands; i++)
+      spect_magnitude[i] /= num_fft;
+  }
+  if (spectrum->message_phase) {
+    gfloat *spect_phase = cd->spect_phase;
+    for (i = 0; i < bands; i++)
+      spect_phase[i] /= num_fft;
   }
 }
 



More information about the gstreamer-commits mailing list