Improve arguments handling when using tools to compress to MP3.

Do not give a maximum bitrate to lame when encoding to ABR MP3 since the lame documentation says "this is NOT RECOMMENDED". Also use a different variable for ABR target bitrate and VBR minimum bitrate and make sure the VBR minimum bitrate is a multiple of 8 since this is required by lame. The ABR target bitrate however does not need to be a multiple of 8.
Also fix incorrect use of %d in the compression tool help.

svn-id: r48849
This commit is contained in:
Thierry Crozat
2010-04-28 23:22:32 +00:00
parent 302c4acf67
commit d1848190b0
3 changed files with 32 additions and 17 deletions
+11 -9
View File
@@ -2,18 +2,20 @@ For a more comprehensive changelog for the latest experimental SVN code, see:
http://scummvm.svn.sourceforge.net/viewvc/scummvm/tools/trunk/?view=log
1.2.0 (????-??-??)
- Fix bug #2984225: "Tools: configure should check if libwxgtk2.8-dev is installed"
- Add version information to tools
- Respect $BINDIR when installing (similar to ScummVM)
- Fix bug #2983010: GUI Tools builds even if optioned out
- Fix bug #2984225: "Tools: configure should check if libwxgtk2.8-dev is installed".
- Add version information to tools.
- Respect $BINDIR when installing (similar to ScummVM).
- Fix bug #2983010: GUI Tools builds even if optioned out.
- Do not give a maximum bitrate to lame when encoding to ABR MP3 since the lame
documentation says "this is NOT RECOMMENDED".
1.1.1 (????-??-??)
First tools version to contain a NEWS file.
- Improve the way the images are loaded for the tools GUI. It increases the chances of success.
- Fix bug #2984217: "Tools: The media directory is not intalled"
- Fix bug #2905473: "GUI Tools: cannot use lame with compress_scumm_sou"
- Patch #2982306: "set MP3 ABR bit rate in GUI Tools"
- Patch #2982090: "Tools: include unistd.h for unlink"
- Fix bug #2984217: "Tools: The media directory is not intalled".
- Fix bug #2905473: "GUI Tools: cannot use lame with compress_scumm_sou".
- Patch #2982306: "set MP3 ABR bit rate in GUI Tools".
- Patch #2982090: "Tools: include unistd.h for unlink".
- Patch #2982091: "Tools: use $(INSTALL) instead of install".
- Fix endian problem in create_sjisfnt
- Fix endian problem in create_sjisfnt.
+20 -8
View File
@@ -45,6 +45,7 @@
struct lameparams {
uint32 minBitr;
uint32 maxBitr;
uint32 targetBitr;
bool abr;
uint32 algqual;
uint32 vbrqual;
@@ -72,7 +73,7 @@ struct rawtype {
uint8 bitsPerSample;
};
lameparams encparms = { minBitrDef, maxBitrDef, false, algqualDef, vbrqualDef, 0, "lame" };
lameparams encparms = { minBitrDef, maxBitrDef, targetBitrDef, false, algqualDef, vbrqualDef, 0, "lame" };
oggencparams oggparms = { -1, -1, -1, (float)oggqualDef, 0 };
flaccparams flacparms = { flacCompressDef, flacBlocksizeDef, false, false };
rawtype rawAudioType = { false, false, 8 };
@@ -141,9 +142,11 @@ void CompressionTool::encodeAudio(const char *inname, bool rawInput, int rawSamp
}
if (encparms.abr)
tmp += sprintf(tmp, "--abr %d ", encparms.minBitr);
else
tmp += sprintf(tmp, "--abr %d ", encparms.targetBitr);
else {
tmp += sprintf(tmp, "--vbr-new -b %d ", encparms.minBitr);
tmp += sprintf(tmp, "-B %d ", encparms.maxBitr);
}
/* Explicitly specify a target sample rate, to work around a bug (?)
* in newer lame versions (>= 3.95) which causes it to malfunction
@@ -162,7 +165,7 @@ void CompressionTool::encodeAudio(const char *inname, bool rawInput, int rawSamp
tmp += sprintf(tmp, "-q %d ", encparms.algqual);
tmp += sprintf(tmp, "-V %d ", encparms.vbrqual);
tmp += sprintf(tmp, "-B %d ", encparms.maxBitr);
tmp += sprintf(tmp, "\"%s\" \"%s\" ", inname, outname);
err = spawnSubprocess(fbuf) != 0;
@@ -794,7 +797,13 @@ void CompressionTool::setMp3MpegQuality(const std::string& arg) {
}
void CompressionTool::setMp3ABRBitrate(const std::string& arg) {
setMp3VBRMinBitrate(arg);
encparms.minBitr = atoi(arg.c_str());
if (encparms.targetBitr == 0 && arg != "0")
throw ToolException("Minimum bitrate (-b) must be a number.");
if (encparms.targetBitr < 8 || encparms.targetBitr > 160)
throw ToolException("Minimum bitrate out of bounds (-b), must be between 8 and 160.");
}
void CompressionTool::setMp3VBRMinBitrate(const std::string& arg) {
@@ -802,6 +811,9 @@ void CompressionTool::setMp3VBRMinBitrate(const std::string& arg) {
if (encparms.minBitr == 0 && arg != "0")
throw ToolException("Minimum bitrate (-b) must be a number.");
if ((encparms.minBitr % 8) != 0)
encparms.maxBitr -= encparms.minBitr % 8;
if (encparms.minBitr < 8 || encparms.minBitr > 160)
throw ToolException("Minimum bitrate out of bounds (-b), must be between 8 and 160.");
@@ -1114,11 +1126,11 @@ std::string CompressionTool::getHelp() const {
if (_supportedFormats & AUDIO_MP3) {
os << "\nMP3 mode params:\n";
os << " --lame-path <path> Path to the lame excutable to use (default: lame)\n";
os << " -b <rate> <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:" << minBitrDef << "%d)\n";
os << " -B <rate> <rate> is the maximum VBR/ABR bitrate (default:%" << maxBitrDef << ")\n";
os << " -b <rate> <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:" << targetBitrDef << " for ABR and " << minBitrDef << " for VBR)\n";
os << " -B <rate> <rate> is the maximum VBR bitrate (default:" << maxBitrDef << ")\n";
os << " --vbr LAME uses the VBR mode (default)\n";
os << " --abr LAME uses the ABR mode\n";
os << " -V <value> specifies the value (0 - 9) of VBR quality (0=best) (default:" << vbrqualDef << "%d)\n";
os << " -V <value> specifies the value (0 - 9) of VBR quality (0=best) (default:" << vbrqualDef << ")\n";
os << " -q <value> specifies the MPEG algorithm quality (0-9; 0=best) (default:" << algqualDef << ")\n";
os << " --silent the output of LAME is hidden (default:disabled)\n";
}
+1
View File
@@ -30,6 +30,7 @@ enum {
/* These are the defaults parameters for the Lame invocation */
minBitrDef = 24,
maxBitrDef = 64,
targetBitrDef = 32,
algqualDef = 2,
vbrqualDef = 4,