File: compress.h

package info (click to toggle)
scummvm-tools 1.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,808 kB
  • ctags: 6,358
  • sloc: cpp: 54,553; sh: 4,143; perl: 706; ansic: 646; python: 518; makefile: 271
file content (146 lines) | stat: -rw-r--r-- 4,047 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* ScummVM Tools
 *
 * ScummVM Tools is the legal property of its developers, whose
 * names are too numerous to list here. Please refer to the
 * COPYRIGHT file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef COMPRESS_H
#define COMPRESS_H

#include "tool.h"


enum {
	/* These are the defaults parameters for the Lame invocation */
	algqualDef	= 2,
	vbrqualDef	= 4,

	/* The default for oggenc invocation is to use the --quality option only */
	oggqualDef	= 3,

	/* These are the default parameters for the FLAC invocation */
	flacCompressDef		= 8,
	flacBlocksizeDef	= 1152
};

#define TEMP_WAV	"tempfile.wav"
#define TEMP_RAW	"tempfile.raw"
#define TEMP_MP3	"tempfile.mp3"
#define TEMP_OGG	"tempfile.ogg"
#define TEMP_FLAC	"tempfile.fla"



/**
 * Different audio formats.
 * You can bitwise them to represent several formats.
 */
enum AudioFormat {
	AUDIO_VORBIS = 1 << 0,
	AUDIO_FLAC   = 1 << 1,
	AUDIO_MP3    = 1 << 2,

	AUDIO_NONE = 0,
	AUDIO_ALL = AUDIO_VORBIS | AUDIO_FLAC | AUDIO_MP3
};

enum CompressionType {
	CBR,
	ABR,
	VBR
};

const char *audio_extensions(AudioFormat format);
int compression_format(AudioFormat format);


/**
 * A tool, which can compress to either MP3, Vorbis or FLAC formats.
 */
class CompressionTool : public Tool {
public:
	CompressionTool(const std::string &name, ToolType type);

	virtual std::string getHelp() const;

	void parseAudioArguments();

public:
	// FIXME: These vars should not be public, but the ToolGUI currently
	// accesses them directly. We should fix this.

	/** Formats supported by this tool. */
	AudioFormat _supportedFormats;

	AudioFormat _format;

	// Settings
	// These functions are used by the GUI Tools and by CLI argument parsing functions
	// mp3 settings
	void setMp3LamePath(const std::string&);
	void setMp3CompressionType(const std::string&);
	void setMp3CompressionType(CompressionType);
	void setMp3MpegQuality(const std::string&);
	void setMp3TargetBitrate(const std::string&);
	void setMp3MinBitrate(const std::string&);
	void setMp3MaxBitrate(const std::string&);
	void unsetMp3MinBitrate();
	void unsetMp3MaxBitrate();
	void setMp3VBRQuality(const std::string&);

	// flac
	void setFlacCompressionLevel(const std::string&);
	void setFlacBlockSize(const std::string&);

	// vorbis
	void setOggQuality(const std::string&);
	void setOggMinBitrate(const std::string&);
	void setOggAvgBitrate(const std::string&);
	void setOggMaxBitrate(const std::string&);
	void unsetOggMinBitrate();
	void unsetOggMaxBitrate();


public:
	bool processMp3Parms();
	bool processOggParms();
	bool processFlacParms();

	void setTempFileName();

	void extractAndEncodeVOC(const char *outName, Common::File &input, AudioFormat compMode);
	void extractAndEncodeWAV(const char *outName, Common::File &input, AudioFormat compMode);

	void extractAndEncodeAIFF(const char *inName, const char *outName, AudioFormat compMode);

	void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, AudioFormat compmode);
	void setRawAudioType(bool isLittleEndian, bool isStereo, uint8 bitsPerSample);

protected:

	void encodeRaw(const char *rawData, int length, int samplerate, const char *outname, AudioFormat compmode);
};

/*
 * Stuff which is in compress.cpp
 *
 * TODO: What is this? Document it?
 */
const extern char *tempEncoded;

#endif