[Scummvm-cvs-logs] SF.net SVN: scummvm:[47537] tools/trunk/compress.cpp
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Mon Jan 25 02:00:53 CET 2010
Revision: 47537
http://scummvm.svn.sourceforge.net/scummvm/?rev=47537&view=rev
Author: lordhoto
Date: 2010-01-25 01:00:52 +0000 (Mon, 25 Jan 2010)
Log Message:
-----------
- Fix a memory leak upon throwing a ToolException.
- Some style fixes.
Modified Paths:
--------------
tools/trunk/compress.cpp
Modified: tools/trunk/compress.cpp
===================================================================
--- tools/trunk/compress.cpp 2010-01-25 00:58:03 UTC (rev 47536)
+++ tools/trunk/compress.cpp 2010-01-25 01:00:52 UTC (rev 47537)
@@ -432,7 +432,6 @@
}
while (!eos) {
- int i, j;
int numSamples = ((samplesLeft < 2048) ? samplesLeft : 2048);
float **buffer = vorbis_analysis_buffer(&vd, numSamples);
@@ -443,21 +442,21 @@
/* Adapted from oggenc 1.1.1 */
if (rawAudioType.bitsPerSample == 8) {
const byte *rawDataUnsigned = (const byte *)rawData;
- for (i = 0; i < numSamples; i++) {
- for (j = 0; j < numChannels; j++) {
+ for (int i = 0; i < numSamples; i++) {
+ for (int j = 0; j < numChannels; j++) {
buffer[j][i] = ((int)(rawDataUnsigned[i * numChannels + j]) - 128) / 128.0f;
}
}
} else if (rawAudioType.bitsPerSample == 16) {
if (rawAudioType.isLittleEndian) {
- for (i = 0; i < numSamples; i++) {
- for (j = 0; j < numChannels; j++) {
+ for (int i = 0; i < numSamples; i++) {
+ for (int j = 0; j < numChannels; j++) {
buffer[j][i] = ((rawData[(i * 2 * numChannels) + (2 * j) + 1] << 8) | (rawData[(i * 2 * numChannels) + (2 * j)] & 0xff)) / 32768.0f;
}
}
} else {
- for (i = 0; i < numSamples; i++) {
- for (j = 0; j < numChannels; j++) {
+ for (int i = 0; i < numSamples; i++) {
+ for (int j = 0; j < numChannels; j++) {
buffer[j][i] = ((rawData[(i * 2 * numChannels) + (2 * j)] << 8) | (rawData[(i * 2 * numChannels) + (2 * j) + 1] & 0xff)) / 32768.0f;
}
}
@@ -554,6 +553,7 @@
if (initStatus != FLAC__STREAM_ENCODER_INIT_STATUS_OK) {
char buf[2048];
sprintf(buf, "Error in FLAC encoder. (check the parameters)\nExact error was:%s\n", FLAC__StreamEncoderInitStatusString[initStatus]);
+ free(flacData);
throw ToolException(buf);
} else {
FLAC__stream_encoder_process_interleaved(encoder, flacData, samplesPerChannel);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list