Permalink
Browse files

VideoPlayer: add audiosetting for downmix clev

  • Loading branch information...
FernetMenta committed Aug 20, 2018
1 parent 50d4a65 commit 2fe7d9df6f7fde3350e9587a8b80320bc3d6cb44
@@ -21489,3 +21489,15 @@ msgstr ""
msgctxt "#39111"
msgid "original"
msgstr ""

#. Used for a setting which allows centre channel (voice/speech) volume to be adjusted when downmixing.
#: xbmc/video/dialogs/GUIDialogAudioSettings.cpp
msgctxt "#39112"
msgid "Downmix: Center Mix Level"
msgstr ""

#. Help text for 39112
#: xbmc/video/dialogs/GUIDialogAudioSettings.cpp
msgctxt "#39113"
msgid "Center Mix Level in dB relative to metadata or default (-3 dB)"
msgstr ""
@@ -420,6 +420,8 @@ bool CVideoPlayerAudio::ProcessDecoderOutput(DVDAudioFrame &audioframe)
{
if (audioframe.nb_frames <= audioframe.framesOut)
{
audioframe.hasDownmix = false;

m_pAudioCodec->GetData(audioframe);

if (audioframe.nb_frames == 0)
@@ -485,6 +487,12 @@ bool CVideoPlayerAudio::ProcessDecoderOutput(DVDAudioFrame &audioframe)
}

SetSyncType(audioframe.passthrough);

// downmix
double clev = audioframe.hasDownmix ? audioframe.centerMixLevel : M_SQRT1_2;
double curDB = 20 * log10(clev);
audioframe.centerMixLevel = pow(10, (curDB + m_processInfo.GetVideoSettings().m_CenterMixLevel) / 20);
audioframe.hasDownmix = true;
}


@@ -65,6 +65,7 @@ bool CVideoSettings::operator!=(const CVideoSettings &right) const
if (m_ToneMapMethod != right.m_ToneMapMethod) return true;
if (m_ToneMapParam != right.m_ToneMapParam) return true;
if (m_Orientation != right.m_Orientation) return true;
if (m_CenterMixLevel != right.m_CenterMixLevel) return true;
return false;
}

@@ -114,6 +114,7 @@ class CVideoSettings
int m_ToneMapMethod = VS_TONEMAPMETHOD_REINHARD;
float m_ToneMapParam = 1.0;
int m_Orientation = 0;
int m_CenterMixLevel = 0; // relative to metadata or default
};

class CCriticalSection;
@@ -92,7 +92,7 @@ void CVideoDatabase::CreateTables()
"VolumeAmplification float, AudioDelay float, ResumeTime integer,"
"Sharpness float, NoiseReduction float, NonLinStretch bool, PostProcess bool,"
"ScalingMethod integer, DeinterlaceMode integer, StereoMode integer, StereoInvert bool, VideoStream integer,"
"TonemapMethod integer, TonemapParam float, Orientation integer)\n");
"TonemapMethod integer, TonemapParam float, Orientation integer, CenterMixLevel integer)\n");

CLog::Log(LOGINFO, "create stacktimes table");
m_pDS->exec("CREATE TABLE stacktimes (idFile integer, times text)\n");
@@ -4326,6 +4326,7 @@ bool CVideoDatabase::GetVideoSettings(int idFile, CVideoSettings &settings)
settings.m_ToneMapMethod = m_pDS->fv("TonemapMethod").get_asInt();
settings.m_ToneMapParam = m_pDS->fv("TonemapParam").get_asFloat();
settings.m_Orientation = m_pDS->fv("Orientation").get_asInt();
settings.m_CenterMixLevel = m_pDS->fv("CenterMixLevel").get_asInt();
m_pDS->close();

if (settings.m_ToneMapParam == 0.0)
@@ -4390,15 +4391,15 @@ void CVideoDatabase::SetVideoSettings(int idFile, const CVideoSettings &setting)
"AudioStream,SubtitleStream,SubtitleDelay,SubtitlesOn,Brightness,"
"Contrast,Gamma,VolumeAmplification,AudioDelay,"
"ResumeTime,"
"Sharpness,NoiseReduction,NonLinStretch,PostProcess,ScalingMethod,StereoMode,StereoInvert,VideoStream,TonemapMethod,TonemapParam,Orientation) "
"Sharpness,NoiseReduction,NonLinStretch,PostProcess,ScalingMethod,StereoMode,StereoInvert,VideoStream,TonemapMethod,TonemapParam,Orientation,CenterMixLevel) "
"VALUES ";
strSQL += PrepareSQL("(%i,%i,%i,%f,%f,%f,%i,%i,%f,%i,%f,%f,%f,%f,%f,%i,%f,%f,%i,%i,%i,%i,%i,%i,%i,%f,%i)",
strSQL += PrepareSQL("(%i,%i,%i,%f,%f,%f,%i,%i,%f,%i,%f,%f,%f,%f,%f,%i,%f,%f,%i,%i,%i,%i,%i,%i,%i,%f,%i,%i)",
idFile, setting.m_InterlaceMethod, setting.m_ViewMode, setting.m_CustomZoomAmount, setting.m_CustomPixelRatio, setting.m_CustomVerticalShift,
setting.m_AudioStream, setting.m_SubtitleStream, setting.m_SubtitleDelay, setting.m_SubtitleOn, setting.m_Brightness,
setting.m_Contrast, setting.m_Gamma, setting.m_VolumeAmplification, setting.m_AudioDelay,
setting.m_ResumeTime,
setting.m_Sharpness, setting.m_NoiseReduction, setting.m_CustomNonLinStretch, setting.m_PostProcess, setting.m_ScalingMethod,
setting.m_StereoMode, setting.m_StereoInvert, setting.m_VideoStream, setting.m_ToneMapMethod, setting.m_ToneMapParam, setting.m_Orientation);
setting.m_StereoMode, setting.m_StereoInvert, setting.m_VideoStream, setting.m_ToneMapMethod, setting.m_ToneMapParam, setting.m_Orientation,setting.m_CenterMixLevel);
m_pDS->exec(strSQL);
}
}
@@ -5343,11 +5344,14 @@ void CVideoDatabase::UpdateTables(int iVersion)

if (iVersion < 111)
m_pDS->exec("ALTER TABLE settings ADD Orientation integer");

if (iVersion < 112)
m_pDS->exec("ALTER TABLE settings ADD CenterMixLevel integer");
}

int CVideoDatabase::GetSchemaVersion() const
{
return 111;
return 112;
}

bool CVideoDatabase::LookupByFolders(const std::string &path, bool shows)
@@ -41,6 +41,7 @@

#define SETTING_AUDIO_VOLUME "audio.volume"
#define SETTING_AUDIO_VOLUME_AMPLIFICATION "audio.volumeamplification"
#define SETTING_AUDIO_CENTERMIXLEVEL "audio.centermixlevel"
#define SETTING_AUDIO_DELAY "audio.delay"
#define SETTING_AUDIO_STREAM "audio.stream"
#define SETTING_AUDIO_PASSTHROUGH "audio.digitalanalog"
@@ -110,6 +111,12 @@ void CGUIDialogAudioSettings::OnSettingChanged(std::shared_ptr<const CSetting> s
float value = static_cast<float>(std::static_pointer_cast<const CSettingNumber>(setting)->GetValue());
g_application.GetAppPlayer().SetDynamicRangeCompression((long)(value * 100));
}
else if (settingId == SETTING_AUDIO_CENTERMIXLEVEL)
{
CVideoSettings vs = g_application.GetAppPlayer().GetVideoSettings();
vs.m_CenterMixLevel = std::static_pointer_cast<const CSettingInt>(setting)->GetValue();
g_application.GetAppPlayer().SetVideoSettings(vs);
}
else if (settingId == SETTING_AUDIO_DELAY)
{
float value = static_cast<float>(std::static_pointer_cast<const CSettingNumber>(setting)->GetValue());
@@ -242,6 +249,13 @@ void CGUIDialogAudioSettings::InitializeSettings()
settingAudioVolumeAmplification->SetDependencies(depsAudioOutputPassthroughDisabled);
}

// downmix: center mix level
{
AddSlider(groupAudio, SETTING_AUDIO_CENTERMIXLEVEL, 39112, SettingLevel::Basic,
videoSettings.m_CenterMixLevel, 14050, -10, 1, 30,
-1, false, false, true, 39113);
}

// audio delay setting
if (SupportsAudioFeature(IPC_AUD_OFFSET))
{

0 comments on commit 2fe7d9d

Please sign in to comment.