diff options
author | unknown <fernetmenta@online.de> | 2013-08-14 08:11:05 +0200 |
---|---|---|
committer | Rainer Hochecker <fernetmenta@online.de> | 2013-08-22 12:38:44 +0200 |
commit | e4ffe757f43074075749c59e8971f32649aa99a3 (patch) | |
tree | 63a98b74451e2725e94e01bb1efc74e0bfaba8ef | |
parent | 29aee74f0f8ce86495f8d7fb11296e0a4a1c4d84 (diff) |
AE: adapt limiter to planar formats
-rw-r--r-- | xbmc/cores/AudioEngine/Engines/SoftAE/SoftAEStream.h | 2 | ||||
-rw-r--r-- | xbmc/cores/AudioEngine/Utils/AELimiter.cpp | 19 | ||||
-rw-r--r-- | xbmc/cores/AudioEngine/Utils/AELimiter.h | 3 |
3 files changed, 18 insertions, 6 deletions
diff --git a/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAEStream.h b/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAEStream.h index 1475c836f8..07d7e3864a 100644 --- a/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAEStream.h +++ b/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAEStream.h @@ -71,7 +71,7 @@ public: virtual void SetReplayGain (float factor) { m_rgain = std::max( 0.0f, factor); } virtual void SetAmplification(float amplify){ m_limiter.SetAmplification(amplify); } - virtual float RunLimiter(float* frame, int channels) { return m_limiter.Run(frame, channels); } + virtual float RunLimiter(float* frame, int channels) { return m_limiter.Run(&frame, channels); } virtual const unsigned int GetFrameSize () const { return m_format.m_frameSize; } virtual const unsigned int GetChannelCount() const { return m_initChannelLayout.Count(); } diff --git a/xbmc/cores/AudioEngine/Utils/AELimiter.cpp b/xbmc/cores/AudioEngine/Utils/AELimiter.cpp index 77af320532..fc2e87943e 100644 --- a/xbmc/cores/AudioEngine/Utils/AELimiter.cpp +++ b/xbmc/cores/AudioEngine/Utils/AELimiter.cpp @@ -34,12 +34,23 @@ CAELimiter::CAELimiter() m_increase = 0.0f; } -float CAELimiter::Run(float* frame, int channels) +float CAELimiter::Run(float* frame[AE_CH_MAX], int channels, int offset /*= 0*/, bool planar /*= false*/) { - float* end = frame + channels; float highest = 0.0f; - while (frame != end) - highest = std::max(highest, fabsf(*(frame++))); + if (!planar) + { + for(int i=0; i<channels; i++) + { + highest = std::max(highest, fabsf(*(frame[0]+offset+i))); + } + } + else + { + for(int i=0; i<channels; i++) + { + highest = std::max(highest, fabsf(*(frame[i]+offset))); + } + } float sample = highest * m_amplify; if (sample * m_attenuation > 1.0f) diff --git a/xbmc/cores/AudioEngine/Utils/AELimiter.h b/xbmc/cores/AudioEngine/Utils/AELimiter.h index ef46d0cbb4..1331da6632 100644 --- a/xbmc/cores/AudioEngine/Utils/AELimiter.h +++ b/xbmc/cores/AudioEngine/Utils/AELimiter.h @@ -20,6 +20,7 @@ */ #include <algorithm> +#include "cores/AudioEngine/AEAudioFormat.h" class CAELimiter { @@ -48,5 +49,5 @@ class CAELimiter m_samplerate = (float)samplerate; } - float Run(float* frame, int channels); + float Run(float* frame[AE_CH_MAX], int channels, int offset = 0, bool planar = false); }; |