Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
VideoPlayer: add audiosetting for downmix clev
  • Loading branch information
FernetMenta committed Aug 20, 2018
1 parent 50d4a65 commit 2fe7d9d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
12 changes: 12 additions & 0 deletions addons/resource.language.en_gb/resources/strings.po
Expand Up @@ -21489,3 +21489,15 @@ msgstr ""
msgctxt "#39111" msgctxt "#39111"
msgid "original" msgid "original"
msgstr "" 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 ""
8 changes: 8 additions & 0 deletions xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp
Expand Up @@ -420,6 +420,8 @@ bool CVideoPlayerAudio::ProcessDecoderOutput(DVDAudioFrame &audioframe)
{ {
if (audioframe.nb_frames <= audioframe.framesOut) if (audioframe.nb_frames <= audioframe.framesOut)
{ {
audioframe.hasDownmix = false;

m_pAudioCodec->GetData(audioframe); m_pAudioCodec->GetData(audioframe);


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


SetSyncType(audioframe.passthrough); 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;
} }




Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoSettings.cpp
Expand Up @@ -65,6 +65,7 @@ bool CVideoSettings::operator!=(const CVideoSettings &right) const
if (m_ToneMapMethod != right.m_ToneMapMethod) return true; if (m_ToneMapMethod != right.m_ToneMapMethod) return true;
if (m_ToneMapParam != right.m_ToneMapParam) return true; if (m_ToneMapParam != right.m_ToneMapParam) return true;
if (m_Orientation != right.m_Orientation) return true; if (m_Orientation != right.m_Orientation) return true;
if (m_CenterMixLevel != right.m_CenterMixLevel) return true;
return false; return false;
} }


Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoSettings.h
Expand Up @@ -114,6 +114,7 @@ class CVideoSettings
int m_ToneMapMethod = VS_TONEMAPMETHOD_REINHARD; int m_ToneMapMethod = VS_TONEMAPMETHOD_REINHARD;
float m_ToneMapParam = 1.0; float m_ToneMapParam = 1.0;
int m_Orientation = 0; int m_Orientation = 0;
int m_CenterMixLevel = 0; // relative to metadata or default
}; };


class CCriticalSection; class CCriticalSection;
Expand Down
14 changes: 9 additions & 5 deletions xbmc/video/VideoDatabase.cpp
Expand Up @@ -92,7 +92,7 @@ void CVideoDatabase::CreateTables()
"VolumeAmplification float, AudioDelay float, ResumeTime integer," "VolumeAmplification float, AudioDelay float, ResumeTime integer,"
"Sharpness float, NoiseReduction float, NonLinStretch bool, PostProcess bool," "Sharpness float, NoiseReduction float, NonLinStretch bool, PostProcess bool,"
"ScalingMethod integer, DeinterlaceMode integer, StereoMode integer, StereoInvert bool, VideoStream integer," "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"); CLog::Log(LOGINFO, "create stacktimes table");
m_pDS->exec("CREATE TABLE stacktimes (idFile integer, times text)\n"); m_pDS->exec("CREATE TABLE stacktimes (idFile integer, times text)\n");
Expand Down Expand Up @@ -4326,6 +4326,7 @@ bool CVideoDatabase::GetVideoSettings(int idFile, CVideoSettings &settings)
settings.m_ToneMapMethod = m_pDS->fv("TonemapMethod").get_asInt(); settings.m_ToneMapMethod = m_pDS->fv("TonemapMethod").get_asInt();
settings.m_ToneMapParam = m_pDS->fv("TonemapParam").get_asFloat(); settings.m_ToneMapParam = m_pDS->fv("TonemapParam").get_asFloat();
settings.m_Orientation = m_pDS->fv("Orientation").get_asInt(); settings.m_Orientation = m_pDS->fv("Orientation").get_asInt();
settings.m_CenterMixLevel = m_pDS->fv("CenterMixLevel").get_asInt();
m_pDS->close(); m_pDS->close();


if (settings.m_ToneMapParam == 0.0) if (settings.m_ToneMapParam == 0.0)
Expand Down Expand Up @@ -4390,15 +4391,15 @@ void CVideoDatabase::SetVideoSettings(int idFile, const CVideoSettings &setting)
"AudioStream,SubtitleStream,SubtitleDelay,SubtitlesOn,Brightness," "AudioStream,SubtitleStream,SubtitleDelay,SubtitlesOn,Brightness,"
"Contrast,Gamma,VolumeAmplification,AudioDelay," "Contrast,Gamma,VolumeAmplification,AudioDelay,"
"ResumeTime," "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 "; "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, 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_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_Contrast, setting.m_Gamma, setting.m_VolumeAmplification, setting.m_AudioDelay,
setting.m_ResumeTime, setting.m_ResumeTime,
setting.m_Sharpness, setting.m_NoiseReduction, setting.m_CustomNonLinStretch, setting.m_PostProcess, setting.m_ScalingMethod, 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); m_pDS->exec(strSQL);
} }
} }
Expand Down Expand Up @@ -5343,11 +5344,14 @@ void CVideoDatabase::UpdateTables(int iVersion)


if (iVersion < 111) if (iVersion < 111)
m_pDS->exec("ALTER TABLE settings ADD Orientation integer"); 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 int CVideoDatabase::GetSchemaVersion() const
{ {
return 111; return 112;
} }


bool CVideoDatabase::LookupByFolders(const std::string &path, bool shows) bool CVideoDatabase::LookupByFolders(const std::string &path, bool shows)
Expand Down
14 changes: 14 additions & 0 deletions xbmc/video/dialogs/GUIDialogAudioSettings.cpp
Expand Up @@ -41,6 +41,7 @@


#define SETTING_AUDIO_VOLUME "audio.volume" #define SETTING_AUDIO_VOLUME "audio.volume"
#define SETTING_AUDIO_VOLUME_AMPLIFICATION "audio.volumeamplification" #define SETTING_AUDIO_VOLUME_AMPLIFICATION "audio.volumeamplification"
#define SETTING_AUDIO_CENTERMIXLEVEL "audio.centermixlevel"
#define SETTING_AUDIO_DELAY "audio.delay" #define SETTING_AUDIO_DELAY "audio.delay"
#define SETTING_AUDIO_STREAM "audio.stream" #define SETTING_AUDIO_STREAM "audio.stream"
#define SETTING_AUDIO_PASSTHROUGH "audio.digitalanalog" #define SETTING_AUDIO_PASSTHROUGH "audio.digitalanalog"
Expand Down Expand Up @@ -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()); float value = static_cast<float>(std::static_pointer_cast<const CSettingNumber>(setting)->GetValue());
g_application.GetAppPlayer().SetDynamicRangeCompression((long)(value * 100)); 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) else if (settingId == SETTING_AUDIO_DELAY)
{ {
float value = static_cast<float>(std::static_pointer_cast<const CSettingNumber>(setting)->GetValue()); float value = static_cast<float>(std::static_pointer_cast<const CSettingNumber>(setting)->GetValue());
Expand Down Expand Up @@ -242,6 +249,13 @@ void CGUIDialogAudioSettings::InitializeSettings()
settingAudioVolumeAmplification->SetDependencies(depsAudioOutputPassthroughDisabled); 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 // audio delay setting
if (SupportsAudioFeature(IPC_AUD_OFFSET)) if (SupportsAudioFeature(IPC_AUD_OFFSET))
{ {
Expand Down

0 comments on commit 2fe7d9d

Please sign in to comment.