encoder/lame: use lame_encode_buffer_interleaved()

Don't deinterleave manually, don't allocate memory.
This commit is contained in:
Max Kellermann 2013-08-06 09:10:30 +02:00
parent a32443c63b
commit 348bdcd7b7
1 changed files with 5 additions and 14 deletions

View File

@ -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,