aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-06 09:10:30 +0200
committerMax Kellermann <max@duempel.org>2013-08-06 09:10:30 +0200
commit348bdcd7b7d23e3bd54e6b80e12f1dc38d2990b9 (patch)
tree88241a7485e97e914f78a420076eef2661e00e02
parenta32443c63b611a526008886dc61b1930599bb1d2 (diff)
downloadmpd-348bdcd7b7d23e3bd54e6b80e12f1dc38d2990b9.tar.gz
mpd-348bdcd7b7d23e3bd54e6b80e12f1dc38d2990b9.tar.xz
mpd-348bdcd7b7d23e3bd54e6b80e12f1dc38d2990b9.zip
encoder/lame: use lame_encode_buffer_interleaved()
Don't deinterleave manually, don't allocate memory.
Diffstat (limited to '')
-rw-r--r--src/encoder/LameEncoderPlugin.cxx19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/encoder/LameEncoderPlugin.cxx b/src/encoder/LameEncoderPlugin.cxx
index 2411d3624..9a87d87ff 100644
--- a/src/encoder/LameEncoderPlugin.cxx
+++ b/src/encoder/LameEncoderPlugin.cxx
@@ -236,23 +236,14 @@ lame_encoder_write(Encoder *_encoder,
const unsigned num_frames =
length / encoder->audio_format.GetFrameSize();
- float *left = g_new(float, num_frames);
- float *right = g_new(float, num_frames);
/* this is for only 16-bit audio */
- for (unsigned i = 0; i < num_frames; i++) {
- left[i] = *src++;
- right[i] = *src++;
- }
-
- int bytes_out = lame_encode_buffer_float(encoder->gfp, left, right,
- num_frames,
- encoder->output_buffer,
- sizeof(encoder->output_buffer));
-
- g_free(left);
- g_free(right);
+ int bytes_out = lame_encode_buffer_interleaved(encoder->gfp,
+ const_cast<short *>(src),
+ num_frames,
+ encoder->output_buffer,
+ sizeof(encoder->output_buffer));
if (bytes_out < 0) {
g_set_error(error, lame_encoder_quark(), 0,