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),
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));
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
*/
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 {
}
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++;
}
}
- g_assert (GST_BUFFER_SIZE (buffer) == 0);
-
- gst_buffer_unref (buffer);
+ g_assert (size == 0);
return GST_FLOW_OK;
}