summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2009-02-16 16:06:02 +0100
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2009-02-16 16:07:29 +0100
commit4fe032d97ec142130bc367a33853c34339bf26f8 (patch)
treefdf83b60708c5ffcb34c77bff710751f532ac5de /ext
parenta6320f13f13fa603c0728e5a70ecaa4327abdca3 (diff)
downloadgst-plugins-bad-4fe032d97ec142130bc367a33853c34339bf26f8.tar.gz
gst-plugins-bad-4fe032d97ec142130bc367a33853c34339bf26f8.tar.bz2
gst-plugins-bad-4fe032d97ec142130bc367a33853c34339bf26f8.zip
bpmdetect: Save one memory allocation per stereo buffer
Diffstat (limited to 'ext')
-rw-r--r--ext/soundtouch/gstbpmdetect.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/ext/soundtouch/gstbpmdetect.cc b/ext/soundtouch/gstbpmdetect.cc
index 04f26bb8..8a5618b4 100644
--- a/ext/soundtouch/gstbpmdetect.cc
+++ b/ext/soundtouch/gstbpmdetect.cc
@@ -215,17 +215,18 @@ gst_bpm_detect_transform_ip (GstBaseTransform * trans, GstBuffer * in)
inbuf += 2048;
}
} else {
- gfloat *data, *inbuf;
+ gfloat *inbuf, *intmp, data[2*2048];
- data = inbuf =
- (gfloat *) g_memdup (GST_BUFFER_DATA (in), GST_BUFFER_SIZE (in));
+ inbuf = (gfloat *) GST_BUFFER_DATA (in);
+ intmp = data;
while (nsamples > 0) {
- bpm_detect->priv->detect->inputSamples (inbuf, MIN (nsamples, 2048));
+ memcpy (intmp, inbuf, sizeof (gfloat) * 2 * MIN (nsamples, 2048));
+ bpm_detect->priv->detect->inputSamples (intmp, MIN (nsamples, 2048));
nsamples -= 2048;
inbuf += 2048 * 2;
+ intmp += 2048 * 2;
}
- g_free (data);
}
bpm = bpm_detect->priv->detect->getBpm ();