Permalink
Browse files

AE: re-add setting normalizelevels, formally inverted and known as bo…

…ost volume on downmix
  • Loading branch information...
1 parent bec842f commit b4523c9da1d4425a241bf0958bb027767a0fc14c @FernetMenta FernetMenta committed Nov 3, 2013
@@ -1434,7 +1434,7 @@ msgstr ""
#: system/settings/settings.xml
msgctxt "#346"
-msgid "Boost volume level on downmix"
+msgid "Normalize levels on downmix"
msgstr ""
#: system/settings/settings.xml
@@ -14660,7 +14660,12 @@ msgctxt "#36532"
msgid "Same as movie"
msgstr ""
-#empty strings from id 36533 to 36534
+#: settings/DisplaySettings.cpp
+msgctxt "#36533"
+msgid "Select how audio is downmixed, for example from 5.1 to 2.0: [Enabled] maintains the dynamic range of the original audio source when downmixed however volume will be lower [Disabled] maintains volume level of the original audio source however the dynamic range is compressed. Note - Dynamic range is the difference between the quietest and loudest sounds in a audio source."
+msgstr ""
+
+#empty strings from id 36534 to 36534
#: guilib/StereoscopicsManager.cpp
#: xbmc/video/dialogs/GUIDialogVideoSettings.cpp
@@ -2172,6 +2172,10 @@
</dependencies>
<control type="toggle" />
</setting>
+ <setting id="audiooutput.normalizelevels" type="boolean" label="346" help="36533">
+ <level>2</level>
+ <default>true</default>
+ </setting>
@spiralvoice
spiralvoice Nov 4, 2013

Hi, I think a line like this with brackets

control type="toggle" /

is missing here.

@FernetMenta
FernetMenta Nov 4, 2013 Team Kodi member

yes, this came with recent refactoring of settings and was merged shortly before this one. thanks.

<setting id="audiooutput.processquality" type="integer" label="13505" help="36169">
<requirement>HAS_AE_QUALITY_LEVELS</requirement>
<level>2</level>
@@ -1004,7 +1004,7 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
{
(*it)->m_resampleBuffers = new CActiveAEBufferPoolResample((*it)->m_inputBuffers->m_format, outputFormat, m_settings.resampleQuality);
(*it)->m_resampleBuffers->m_changeResampler = (*it)->m_forceResampler;
- (*it)->m_resampleBuffers->Create(MAX_CACHE_LEVEL*1000, false, m_settings.stereoupmix);
+ (*it)->m_resampleBuffers->Create(MAX_CACHE_LEVEL*1000, false, m_settings.stereoupmix, m_settings.normalizelevels);
}
if (m_mode == MODE_TRANSCODE || m_streams.size() > 1)
(*it)->m_resampleBuffers->m_fillPackets = true;
@@ -1240,14 +1240,22 @@ void CActiveAE::ChangeResamplers()
std::list<CActiveAEStream*>::iterator it;
for(it=m_streams.begin(); it!=m_streams.end(); ++it)
{
+ bool normalize = true;
+ if (((*it)->m_resampleBuffers->m_format.m_channelLayout.Count() <
+ (*it)->m_resampleBuffers->m_inputFormat.m_channelLayout.Count()) &&
+ !m_settings.normalizelevels)
+ normalize = false;
+
if ((*it)->m_resampleBuffers && (*it)->m_resampleBuffers->m_resampler &&
(((*it)->m_resampleBuffers->m_resampleQuality != m_settings.resampleQuality) ||
- ((*it)->m_resampleBuffers->m_stereoUpmix != m_settings.stereoupmix)))
+ (((*it)->m_resampleBuffers->m_stereoUpmix != m_settings.stereoupmix)) ||
+ ((*it)->m_resampleBuffers->m_normalize != normalize)))
{
(*it)->m_resampleBuffers->m_changeResampler = true;
}
(*it)->m_resampleBuffers->m_resampleQuality = m_settings.resampleQuality;
(*it)->m_resampleBuffers->m_stereoUpmix = m_settings.stereoupmix;
+ (*it)->m_resampleBuffers->m_normalize = normalize;
}
}
@@ -1634,8 +1642,9 @@ bool CActiveAE::RunStages()
fadingStep = delta / samples;
}
- // for stream amplification we need to run on a per sample basis
- if ((*it)->m_amplify != 1.0)
+ // for streams amplification of turned off downmix normalization
+ // we need to run on a per sample basis
+ if ((*it)->m_amplify != 1.0 || !(*it)->m_resampleBuffers->m_normalize)
{
nb_floats = out->pkt->config.channels / out->pkt->planes;
nb_loops = out->pkt->nb_samples;
@@ -1700,8 +1709,9 @@ bool CActiveAE::RunStages()
fadingStep = delta / samples;
}
- // for stream amplification we need to run on a per sample basis
- if ((*it)->m_amplify != 1.0)
+ // for streams amplification of turned off downmix normalization
+ // we need to run on a per sample basis
+ if ((*it)->m_amplify != 1.0 || !(*it)->m_resampleBuffers->m_normalize)
{
nb_floats = out->pkt->config.channels / out->pkt->planes;
nb_loops = out->pkt->nb_samples;
@@ -1981,6 +1991,7 @@ void CActiveAE::LoadSettings()
m_settings.samplerate = CSettings::Get().GetInt("audiooutput.samplerate");
m_settings.stereoupmix = CSettings::Get().GetBool("audiooutput.stereoupmix");
+ m_settings.normalizelevels = CSettings::Get().GetBool("audiooutput.normalizelevels");
m_settings.passthrough = m_settings.config == AE_CONFIG_FIXED ? false : CSettings::Get().GetBool("audiooutput.passthrough");
m_settings.ac3passthrough = CSettings::Get().GetBool("audiooutput.ac3passthrough");
@@ -2057,7 +2068,8 @@ void CActiveAE::OnSettingsChange(const std::string& setting)
setting == "audiooutput.streamsilence" ||
setting == "audiooutput.processquality" ||
setting == "audiooutput.passthrough" ||
- setting == "audiooutput.samplerate")
+ setting == "audiooutput.samplerate" ||
+ setting == "audiooutput.normalizelevels")
{
m_controlPort.SendOutMessage(CActiveAEControlProtocol::RECONFIGURE);
}
@@ -2438,6 +2450,7 @@ bool CActiveAE::ResampleSound(CActiveAESound *sound)
orig_config.fmt,
orig_config.bits_per_sample,
false,
+ true,
NULL,
AE_QUALITY_MID);
@@ -55,6 +55,7 @@ struct AudioSettings
bool truehdpassthrough;
bool dtshdpassthrough;
bool stereoupmix;
+ bool normalizelevels;
bool passthrough;
int config;
unsigned int samplerate;
@@ -146,17 +146,23 @@ CActiveAEBufferPoolResample::CActiveAEBufferPoolResample(AEAudioFormat inputForm
m_resampleQuality = quality;
m_changeResampler = false;
m_stereoUpmix = false;
+ m_normalize = true;
}
CActiveAEBufferPoolResample::~CActiveAEBufferPoolResample()
{
delete m_resampler;
}
-bool CActiveAEBufferPoolResample::Create(unsigned int totaltime, bool remap, bool upmix)
+bool CActiveAEBufferPoolResample::Create(unsigned int totaltime, bool remap, bool upmix, bool normalize)
{
CActiveAEBufferPool::Create(totaltime);
+ m_stereoUpmix = upmix;
+ m_normalize = true;
+ if ((m_format.m_channelLayout.Count() < m_inputFormat.m_channelLayout.Count() && !normalize))
+ m_normalize = false;
+
if (m_inputFormat.m_channelLayout != m_format.m_channelLayout ||
m_inputFormat.m_sampleRate != m_format.m_sampleRate ||
m_inputFormat.m_dataFormat != m_format.m_dataFormat ||
@@ -174,11 +180,11 @@ bool CActiveAEBufferPoolResample::Create(unsigned int totaltime, bool remap, boo
CActiveAEResample::GetAVSampleFormat(m_inputFormat.m_dataFormat),
CAEUtil::DataFormatToUsedBits(m_inputFormat.m_dataFormat),
upmix,
+ m_normalize,
remap ? &m_format.m_channelLayout : NULL,
m_resampleQuality);
}
- m_stereoUpmix = upmix;
m_changeResampler = false;
return true;
@@ -200,6 +206,7 @@ void CActiveAEBufferPoolResample::ChangeResampler()
CActiveAEResample::GetAVSampleFormat(m_inputFormat.m_dataFormat),
CAEUtil::DataFormatToUsedBits(m_inputFormat.m_dataFormat),
m_stereoUpmix,
+ m_normalize,
NULL,
m_resampleQuality);
@@ -90,7 +90,7 @@ class CActiveAEBufferPoolResample : public CActiveAEBufferPool
public:
CActiveAEBufferPoolResample(AEAudioFormat inputFormat, AEAudioFormat outputFormat, AEQuality quality);
virtual ~CActiveAEBufferPoolResample();
- virtual bool Create(unsigned int totaltime, bool remap, bool upmix);
+ virtual bool Create(unsigned int totaltime, bool remap, bool upmix, bool normalize = true);
void ChangeResampler();
bool ResampleBuffers(unsigned int timestamp = 0);
float GetDelay();
@@ -108,6 +108,7 @@ class CActiveAEBufferPoolResample : public CActiveAEBufferPool
double m_resampleRatio;
AEQuality m_resampleQuality;
bool m_stereoUpmix;
+ bool m_normalize;
};
}
@@ -36,7 +36,7 @@ CActiveAEResample::~CActiveAEResample()
m_dllSwResample.Unload();
}
-bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, int dst_bits, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, int src_bits, bool upmix, CAEChannelInfo *remapLayout, AEQuality quality)
+bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, int dst_bits, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, int src_bits, bool upmix, bool normalize, CAEChannelInfo *remapLayout, AEQuality quality)
{
if (!m_dllAvUtil.Load() || !m_dllSwResample.Load())
return false;
@@ -86,7 +86,7 @@ bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst
// not required for sink stage (remapLayout == true)
if ((m_dst_fmt == AV_SAMPLE_FMT_FLT || m_dst_fmt == AV_SAMPLE_FMT_FLTP) &&
(m_src_fmt == AV_SAMPLE_FMT_FLT || m_src_fmt == AV_SAMPLE_FMT_FLTP) &&
- !remapLayout)
+ !remapLayout && normalize)
{
m_dllAvUtil.av_opt_set_double(m_pContext, "rematrix_maxval", 1.0, 0);
}
@@ -34,7 +34,7 @@ class CActiveAEResample
public:
CActiveAEResample();
virtual ~CActiveAEResample();
- bool Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, int dst_bits, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, int src_bits, bool upmix, CAEChannelInfo *remapLayout, AEQuality quality);
+ bool Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, int dst_bits, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, int src_bits, bool upmix, bool normalize, CAEChannelInfo *remapLayout, AEQuality quality);
int Resample(uint8_t **dst_buffer, int dst_samples, uint8_t **src_buffer, int src_samples, double ratio);
int64_t GetDelay(int64_t base);
int GetBufferedSamples();
@@ -206,8 +206,7 @@ bool CAERemap::Initialize(CAEChannelInfo input, CAEChannelInfo output, bool fina
normalize = true;
else
{
- //FIXME: guisetting is reversed, change the setting name after frodo
- normalize = !CSettings::Get().GetBool("audiooutput.normalizelevels");
+ normalize = CSettings::Get().GetBool("audiooutput.normalizelevels");
CLog::Log(LOGDEBUG, "AERemap: Downmix normalization is %s", (normalize ? "enabled" : "disabled"));
}
@@ -364,7 +364,7 @@ void CPCMRemap::BuildMap()
m_outStride = m_inSampleSize * m_outChannels;
/* see if we need to normalize the levels */
- bool dontnormalize = CSettings::Get().GetBool("audiooutput.normalizelevels");
+ bool dontnormalize = !CSettings::Get().GetBool("audiooutput.normalizelevels");
CLog::Log(LOGDEBUG, "CPCMRemap: Downmix normalization is %s", (dontnormalize ? "disabled" : "enabled"));
ResolveChannels();
@@ -930,6 +930,7 @@ void CSettings::InitializeISettingCallbacks()
settingSet.insert("audiooutput.audiodevice");
settingSet.insert("audiooutput.passthroughdevice");
settingSet.insert("audiooutput.streamsilence");
+ settingSet.insert("audiooutput.normalizelevels");
settingSet.insert("lookandfeel.skin");
settingSet.insert("lookandfeel.skinsettings");
settingSet.insert("lookandfeel.font");

0 comments on commit b4523c9

Please sign in to comment.