slomo gst-plugins-good: gst-plugins-good/ gst-plugins-good/gst/spectrum/

[email protected] Mon, 19 Jan 2009 02:14:07 -0800 (PST)
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
--===============3564913555357388806==

CVS Root:       /cvs/gstreamer
Module:         gst-plugins-good
Changes by:     slomo
Date:           Mon Jan 19 2009  10:14:07 UTC

Log message:
* gst/spectrum/gstspectrum.c: (gst_spectrum_reset_state),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Implement a simple compensation algorithm for rounding errors.
This makes sure that a spectrum message is posted on the bus
every interval nanoseconds. Fixes bug #567955.

Modified files:
    .               : ChangeLog
    gst/spectrum    : gstspectrum.c gstspectrum.h

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3902&r2=1.3903
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/spectrum/gstspectrum.c.diff?r1=1.53&r2=1.54
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/spectrum/gstspectrum.h.diff?r1=1.16&r2=1.17

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v
retrieving revision 1.3902
retrieving revision 1.3903
diff -u -d -r1.3902 -r1.3903
--- ChangeLog	15 Jan 2009 21:16:43 -0000	1.3902
+++ ChangeLog	19 Jan 2009 10:13:51 -0000	1.3903
@@ -1,3 +1,12 @@
+2009-01-19  Sebastian Dröge  <[email protected]>
+
+	* gst/spectrum/gstspectrum.c: (gst_spectrum_reset_state),
+	(gst_spectrum_transform_ip):
+	* gst/spectrum/gstspectrum.h:
+	Implement a simple compensation algorithm for rounding errors.
+	This makes sure that a spectrum message is posted on the bus
+	every interval nanoseconds. Fixes bug #567955.
 2009-01-15  Michael Smith <[email protected]>
 
 	* sys/osxaudio/Makefile.am:
Index: gstspectrum.c
RCS file: /cvs/gstreamer/gst-plugins-good/gst/spectrum/gstspectrum.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- gstspectrum.c	15 Jan 2009 11:40:23 -0000	1.53
+++ gstspectrum.c	19 Jan 2009 10:13:53 -0000	1.54
@@ -278,6 +278,8 @@
   spectrum->num_frames = 0;
   spectrum->num_fft = 0;
+  spectrum->accumulated_error = 0;
 }
 static void
@@ -505,10 +507,12 @@
     spectrum->fft_ctx = gst_fft_f32_new (nfft, FALSE);
     spectrum->frames_per_interval =
         gst_util_uint64_scale (spectrum->interval, rate, GST_SECOND);
+    spectrum->error_per_interval = (spectrum->interval * rate) % GST_SECOND;
     if (spectrum->frames_per_interval == 0)
       spectrum->frames_per_interval = 1;
     spectrum->num_frames = 0;
     spectrum->num_fft = 0;
+    spectrum->accumulated_error = 0;
   }
   if (spectrum->num_frames == 0)
@@ -559,7 +563,12 @@
      * FFT of frames that we already handled.
      */
     if (spectrum->num_frames % nfft == 0 ||
-        spectrum->num_frames == spectrum->frames_per_interval) {
+        ((spectrum->accumulated_error < GST_SECOND
+                && spectrum->num_frames == spectrum->frames_per_interval)
+            || (spectrum->accumulated_error >= GST_SECOND
+                && spectrum->num_frames - 1 ==
+                spectrum->frames_per_interval))) {
       for (i = 0; i < nfft; i++)
         input_tmp[i] = input[(spectrum->input_pos + i) % nfft];
@@ -586,7 +595,16 @@
     }
     /* Do we have the FFTs for one interval? */
-    if (spectrum->num_frames == spectrum->frames_per_interval) {
+    if ((spectrum->accumulated_error < GST_SECOND
+            && spectrum->num_frames == spectrum->frames_per_interval)
+        || (spectrum->accumulated_error >= GST_SECOND
+            && spectrum->num_frames - 1 == spectrum->frames_per_interval)) {
+      if (spectrum->accumulated_error >= GST_SECOND)
+        spectrum->accumulated_error -= GST_SECOND;
+      else
+        spectrum->accumulated_error += spectrum->error_per_interval;
       if (spectrum->message) {
         GstMessage *m;
Index: gstspectrum.h
RCS file: /cvs/gstreamer/gst-plugins-good/gst/spectrum/gstspectrum.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- gstspectrum.h	14 Jan 2009 15:44:18 -0000	1.16
+++ gstspectrum.h	19 Jan 2009 10:13:53 -0000	1.17
@@ -62,6 +62,9 @@
   gfloat *spect_magnitude;
   gfloat *spect_phase;
   GstFFTF32 *fft_ctx;
+  guint64 error_per_interval;
+  guint64 accumulated_error;
 };
 struct _GstSpectrumClass


--===============3564913555357388806==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
--===============3564913555357388806==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
gstreamer-cvs-verbose mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs-verbose

--===============3564913555357388806==--