aboutsummaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authorTorbjörn Andersson2019-01-18 19:19:25 +0100
committerFilippos Karapetis2019-02-10 16:32:02 +0200
commit9785d5007a7754ab988b51a8780d6a3dcc80dce4 (patch)
treec5c3b28c5846c7b65e9ceb0d24b667e9a2641540 /audio
parent82a1859ad1105b2ae2cc3b15bfc3a92e3bc8736f (diff)
downloadscummvm-rg350-9785d5007a7754ab988b51a8780d6a3dcc80dce4.tar.gz
scummvm-rg350-9785d5007a7754ab988b51a8780d6a3dcc80dce4.tar.bz2
scummvm-rg350-9785d5007a7754ab988b51a8780d6a3dcc80dce4.zip
ZVISION: Boost volume for MPEG cutscenes
The high-resolution videos play back at much lower volume than the original ones. This adds hard-coded values for how much to amplify each cutscene. It's all done by ear, and it does introduce some clipping, but I think it should be acceptable. Of course, it could also be a problem with the audio decoder, so this may be the wrong approach entirely.
Diffstat (limited to 'audio')
-rw-r--r--audio/decoders/ac3.cpp20
-rw-r--r--audio/decoders/ac3.h2
2 files changed, 14 insertions, 8 deletions
diff --git a/audio/decoders/ac3.cpp b/audio/decoders/ac3.cpp
index c569179996..1b2a3bff76 100644
--- a/audio/decoders/ac3.cpp
+++ b/audio/decoders/ac3.cpp
@@ -24,6 +24,7 @@
#include "common/ptr.h"
#include "common/stream.h"
#include "common/textconsole.h"
+#include "common/util.h"
#include "audio/audiostream.h"
#include "audio/decoders/ac3.h"
@@ -37,7 +38,7 @@ namespace Audio {
class AC3Stream : public PacketizedAudioStream {
public:
- AC3Stream();
+ AC3Stream(double decibel);
~AC3Stream();
bool init(Common::SeekableReadStream &firstPacket);
@@ -62,9 +63,14 @@ private:
byte *_inBufPtr;
int _flags;
int _sampleRate;
+ double _audioGain;
};
-AC3Stream::AC3Stream() : _a52State(0), _frameSize(0), _inBufPtr(0), _flags(0), _sampleRate(0) {
+AC3Stream::AC3Stream(double decibel = 0.0) : _a52State(0), _frameSize(0), _inBufPtr(0), _flags(0), _sampleRate(0) {
+ if (decibel != 0.0)
+ _audioGain = pow(2, decibel / 6);
+ else
+ _audioGain = 1.0;
}
AC3Stream::~AC3Stream() {
@@ -153,7 +159,7 @@ void AC3Stream::queuePacket(Common::SeekableReadStream *data) {
} else {
// TODO: Eventually support more than just stereo max
int flags = A52_STEREO | A52_ADJUST_LEVEL;
- sample_t level = 32767;
+ sample_t level = 32767 * _audioGain;
if (a52_frame(_a52State, _inBuf, &flags, &level, 0) != 0)
error("Frame fail");
@@ -165,8 +171,8 @@ void AC3Stream::queuePacket(Common::SeekableReadStream *data) {
if (a52_block(_a52State) == 0) {
sample_t *samples = a52_samples(_a52State);
for (int j = 0; j < 256; j++) {
- *outputPtr++ = (int16)samples[j];
- *outputPtr++ = (int16)samples[j + 256];
+ *outputPtr++ = (int16)CLIP<sample_t>(samples[j], -32768, 32767);
+ *outputPtr++ = (int16)CLIP<sample_t>(samples[j + 256], -32768, 32767);
}
outputLength += 1024;
@@ -189,8 +195,8 @@ void AC3Stream::queuePacket(Common::SeekableReadStream *data) {
}
}
-PacketizedAudioStream *makeAC3Stream(Common::SeekableReadStream &firstPacket) {
- Common::ScopedPtr<AC3Stream> stream(new AC3Stream());
+PacketizedAudioStream *makeAC3Stream(Common::SeekableReadStream &firstPacket, double decibel) {
+ Common::ScopedPtr<AC3Stream> stream(new AC3Stream(decibel));
if (!stream->init(firstPacket))
return 0;
diff --git a/audio/decoders/ac3.h b/audio/decoders/ac3.h
index a51107a410..249d1dcfa2 100644
--- a/audio/decoders/ac3.h
+++ b/audio/decoders/ac3.h
@@ -41,7 +41,7 @@ class PacketizedAudioStream;
* @param firstPacket The stream containing the first packet of data
* @return A new PacketizedAudioStream, or NULL on error
*/
-PacketizedAudioStream *makeAC3Stream(Common::SeekableReadStream &firstPacket);
+PacketizedAudioStream *makeAC3Stream(Common::SeekableReadStream &firstPacket, double decibel = 0.0);
} // End of namespace Audio