GUI TOOLS: Some cleanup (e.g. move compression specific stuff to compress.h, where it belongs)

svn-id: r46359
This commit is contained in:
Max Horn
2009-12-13 19:49:49 +00:00
parent b4e339a51c
commit 138a720019
6 changed files with 85 additions and 86 deletions
+33
View File
@@ -882,10 +882,14 @@ bool CompressionTool::processFlacParms(){
// The old code can be removed once all tools have been converted
CompressionTool::CompressionTool(const std::string &name, ToolType type) : Tool(name, type) {
_supportedFormats = AUDIO_ALL;
_format = AUDIO_MP3;
}
void CompressionTool::parseAudioArguments() {
if (_supportedFormats == AUDIO_NONE)
return;
_format = AUDIO_MP3;
if (_arguments.front() == "--mp3")
@@ -978,3 +982,32 @@ std::string CompressionTool::getHelp() const {
return os.str();
}
const char *audio_extensions(AudioFormat format) {
switch(format) {
case AUDIO_MP3:
return ".mp3";
case AUDIO_VORBIS:
return ".ogg";
case AUDIO_FLAC:
return ".fla";
case AUDIO_NONE:
default:
return ".unk";
}
}
CompressionFormat compression_format(AudioFormat format) {
switch(format) {
case AUDIO_MP3:
return COMPRESSION_MP3;
case AUDIO_VORBIS:
return COMPRESSION_OGG;
case AUDIO_FLAC:
return COMPRESSION_FLAC;
case AUDIO_NONE:
default:
throw ToolException("Unknown compression format");
}
}
+49 -20
View File
@@ -33,23 +33,20 @@
#include <FLAC/stream_encoder.h>
#endif
/* We use string constants here, so we can insert the
* constants directly into literals
* These are given integer definitions below
*/
enum {
/* These are the defaults parameters for the Lame invocation */
minBitrDef = 24,
maxBitrDef = 64,
algqualDef = 2,
vbrqualDef = 4,
/* These are the defaults parameters for the Lame invocation */
#define minBitrDef 24
#define maxBitrDef 64
#define algqualDef 2
#define vbrqualDef 4
/* The default for oggenc invocation is to use the --quality option only */
oggqualDef = 3,
/* The default for oggenc invocation is to use the --quality option only */
#define oggqualDef 3
/* These are the default parameters for the FLAC invocation */
#define flacCompressDef 8
#define flacBlocksizeDef 1152
/* These are the default parameters for the FLAC invocation */
flacCompressDef = 8,
flacBlocksizeDef = 1152
};
#define TEMP_WAV "tempfile.wav"
#define TEMP_RAW "tempfile.raw"
@@ -59,9 +56,35 @@
/**
* Different audio formats.
* You can bitwise them to represent several formats.
*/
enum AudioFormat {
AUDIO_NONE = 0,
AUDIO_VORBIS = 1,
AUDIO_FLAC = 2,
AUDIO_MP3 = 4,
AUDIO_ALL = AUDIO_VORBIS | AUDIO_FLAC | AUDIO_MP3
};
/**
* Compression tool
* A tool, which can compress to either MP3, Vorbis or FLAC formats
* Another enum, which cannot be ORed.
* These are the values written to the output files.
*/
enum CompressionFormat {
COMPRESSION_NONE = 0,
COMPRESSION_MP3 = 1,
COMPRESSION_OGG = 2,
COMPRESSION_FLAC = 3
};
const char *audio_extensions(AudioFormat format);
CompressionFormat compression_format(AudioFormat format);
/**
* A tool, which can compress to either MP3, Vorbis or FLAC formats.
*/
class CompressionTool : public Tool {
public:
@@ -70,7 +93,11 @@ public:
virtual std::string getHelp() const;
void parseAudioArguments();
public:
protected:
/** Formats supported by this tool. */
AudioFormat _supportedFormats;
AudioFormat _format;
// Settings
@@ -85,13 +112,13 @@ public:
// flac
std::string _flacCompressionLevel;
std::string _flacBlockSize;
// vorbis
std::string _oggQuality;
std::string _oggMinBitrate;
std::string _oggAvgBitrate;
std::string _oggMaxBitrate;
public:
bool processMp3Parms();
bool processOggParms();
@@ -107,6 +134,8 @@ public:
/*
* Stuff which is in compress.cpp
*
* TODO: What is this? Document it?
*/
const extern char *tempEncoded;
+1 -3
View File
@@ -33,7 +33,6 @@ Tool::Tool(const std::string &name, ToolType type) {
_type = type;
_outputToDirectory = true;
_supportedFormats = AUDIO_ALL;
_supportsProgressBar = false;
_internalPrint = standardPrint;
@@ -67,8 +66,7 @@ int Tool::run(const std::deque<std::string> &args) {
}
// Read standard arguments
if (_supportedFormats != AUDIO_NONE)
parseAudioArguments();
parseAudioArguments();
parseOutputArguments();
// Read tool specific arguments
parseExtraArguments();
-2
View File
@@ -210,8 +210,6 @@ protected:
/** If this tools outputs to a directory, not a file. */
bool _outputToDirectory;
/** Formats supported by this tool. */
AudioFormat _supportedFormats;
/** If this tool can display output progress in % */
bool _supportsProgressBar;
-28
View File
@@ -28,34 +28,6 @@
#define vsnprintf _vsnprintf
#endif
const char *audio_extensions(AudioFormat format) {
switch(format) {
case AUDIO_MP3:
return ".mp3";
case AUDIO_VORBIS:
return ".ogg";
case AUDIO_FLAC:
return ".fla";
case AUDIO_NONE:
default:
return ".unk";
}
}
CompressionFormat compression_format(AudioFormat format) {
switch(format) {
case AUDIO_MP3:
return COMPRESSION_MP3;
case AUDIO_VORBIS:
return COMPRESSION_OGG;
case AUDIO_FLAC:
return COMPRESSION_FLAC;
case AUDIO_NONE:
default:
throw ToolException("Unknown compression format");
}
}
void error(const char *s, ...) {
char buf[1024];
va_list va;
+2 -33
View File
@@ -43,17 +43,13 @@
#include <string>
#include <stdexcept>
/*
* GCC specific stuff
*/
#if defined(__GNUC__)
#define GCC_PACK __attribute__((packed))
#define NORETURN __attribute__((__noreturn__))
#define GCC_PRINTF(x,y) __attribute__((format(printf, x, y)))
#define GCC_PACK __attribute__((packed))
#else
#define GCC_PACK
#define GCC_PRINTF(x,y)
#define GCC_PACK
#endif
#ifndef ARRAYSIZE
@@ -143,31 +139,4 @@ void warning(const char *s, ...);
void debug(int level, const char *s, ...);
void notice(const char *s, ...);
/**
* Different audio formats
* You can bitwise them to represent several formats
*/
enum AudioFormat {
AUDIO_NONE = 0,
AUDIO_VORBIS = 1,
AUDIO_FLAC = 2,
AUDIO_MP3 = 4,
AUDIO_ALL = AUDIO_VORBIS | AUDIO_FLAC | AUDIO_MP3
};
/**
* Another enum, which cannot be ORed
* These are the values written to the output files
*/
enum CompressionFormat {
COMPRESSION_NONE = 0,
COMPRESSION_MP3 = 1,
COMPRESSION_OGG = 2,
COMPRESSION_FLAC = 3
};
const char *audio_extensions(AudioFormat format);
CompressionFormat compression_format(AudioFormat format);
#endif