diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2009-01-14 15:44:18 +0000 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2009-01-14 15:44:18 +0000 |
commit | f4b2d38c87331798d59296af2d4c6edeff047e66 (patch) | |
tree | fe66a073530b041740c78b0adee2a00fcd76e411 | |
parent | b1c6dec543d6445151631ea13825820f2ad3914d (diff) |
gst/spectrum/gstspectrum.*: Use correct types for frame/fft counters and some minor cleanup.
Original commit message from CVS:
* gst/spectrum/gstspectrum.c: (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Use correct types for frame/fft counters and some minor
cleanup.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | gst/spectrum/gstspectrum.c | 23 | ||||
-rw-r--r-- | gst/spectrum/gstspectrum.h | 4 |
3 files changed, 19 insertions, 15 deletions
@@ -1,5 +1,12 @@ 2009-01-14 Sebastian Dröge <sebastian.droege@collabora.co.uk> + * gst/spectrum/gstspectrum.c: (gst_spectrum_transform_ip): + * gst/spectrum/gstspectrum.h: + Use correct types for frame/fft counters and some minor + cleanup. + +2009-01-14 Sebastian Dröge <sebastian.droege@collabora.co.uk> + Patch by: Lennart Poettering <lennart at poettering dot net> * ext/pulse/pulseprobe.c: (gst_pulseprobe_new), diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c index cdad5b4f..2d90fd19 100644 --- a/gst/spectrum/gstspectrum.c +++ b/gst/spectrum/gstspectrum.c @@ -482,6 +482,8 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer) gfloat *spect_magnitude; gfloat *spect_phase; GstFFTF32 *fft_ctx; + const guint8 *data = GST_BUFFER_DATA (buffer); + guint size = GST_BUFFER_SIZE (buffer); GST_LOG_OBJECT (spectrum, "input size: %d bytes", GST_BUFFER_SIZE (buffer)); @@ -490,9 +492,6 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer) gst_spectrum_reset_state (spectrum); } - /* Create a subbuffer to allow us to overwrite the buffer metadata later */ - buffer = gst_buffer_create_sub (buffer, 0, GST_BUFFER_SIZE (buffer)); - /* If we don't have a FFT context yet get one and * allocate memory for everything */ @@ -521,26 +520,26 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer) spect_phase = spectrum->spect_phase; fft_ctx = spectrum->fft_ctx; - while (GST_BUFFER_SIZE (buffer) >= width * channels) { + while (size >= width * channels) { /* Move the current frame into our ringbuffer and * take the average of all channels */ spectrum->input[spectrum->input_pos] = 0.0; if (fp && width == 4) { - gfloat *in = (gfloat *) GST_BUFFER_DATA (buffer); + gfloat *in = (gfloat *) data; for (i = 0; i < channels; i++) spectrum->input[spectrum->input_pos] += in[i]; } else if (fp && width == 8) { - gdouble *in = (gdouble *) GST_BUFFER_DATA (buffer); + gdouble *in = (gdouble *) data; for (i = 0; i < channels; i++) spectrum->input[spectrum->input_pos] += in[i]; } else if (!fp && width == 4) { - gint32 *in = (gint32 *) GST_BUFFER_DATA (buffer); + gint32 *in = (gint32 *) data; for (i = 0; i < channels; i++) spectrum->input[spectrum->input_pos] += ((gfloat) in[i]) / G_MAXINT32; } else if (!fp && width == 2) { - gint16 *in = (gint16 *) GST_BUFFER_DATA (buffer); + gint16 *in = (gint16 *) data; for (i = 0; i < channels; i++) spectrum->input[spectrum->input_pos] += ((gfloat) in[i]) / G_MAXINT16; } else { @@ -548,8 +547,8 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer) } spectrum->input[spectrum->input_pos] /= channels; - GST_BUFFER_DATA (buffer) += width * channels; - GST_BUFFER_SIZE (buffer) -= width * channels; + data += width * channels; + size -= width * channels; spectrum->input_pos = (spectrum->input_pos + 1) % nfft; spectrum->num_frames++; @@ -612,9 +611,7 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer) } } - g_assert (GST_BUFFER_SIZE (buffer) == 0); - - gst_buffer_unref (buffer); + g_assert (size == 0); return GST_FLOW_OK; } diff --git a/gst/spectrum/gstspectrum.h b/gst/spectrum/gstspectrum.h index 8c5e533c..cd42360f 100644 --- a/gst/spectrum/gstspectrum.h +++ b/gst/spectrum/gstspectrum.h @@ -49,9 +49,9 @@ struct _GstSpectrum guint bands; /* number of spectrum bands */ gint threshold; /* energy level treshold */ - guint num_frames; /* frame count (1 sample per channel) + guint64 num_frames; /* frame count (1 sample per channel) * since last emit */ - guint num_fft; /* number of FFTs since last emit */ + guint64 num_fft; /* number of FFTs since last emit */ GstClockTime message_ts; /* starttime for next message */ /* <private> */ |