Skip to content


More post-processing options: different post processing modes per video #258

wants to merge 1 commit into from

5 participants


2011.Oct.12 Updated for no conflicts with master.

Post-processing all videos with high quality pp filter combination 'ha:128:7,va,dr' makes videos too blurred. Not all videos need so much vertical/horizontal de-blocking. From experience with MPlayer's video filter settings I would suggest the following changes:

Introduce 3 PP Modes that can be switched in the GUI and saved per video:

  • Default: 'ha,va,dr' (this is accurate but not too aggressive and it is based on FFMpeg default that is 'hb:a,vb:a,dr:a', only changed horizontal/vertical deblocking to accurate and disabled auto switch-off flag). Because this is the mode that can be overridden in xml, advanced users with own pp settings won't be affected by this change.

  • Aggressive: 'ha:128:7,va,dr' (high quality but not suitable for all videos this is FFMpeg high quality pp filter combination 'ha:a:128:7,va:a,dr:a' without the ':a' flag)

  • Auto (slow CPU): 'hb:a,vb:a,dr:a' (FFMpeg's default setting that automatically switches the subfilters off if the CPU is too slow)


@elupus: libavfilter was put in place but the currently integrated version does not have a filter named 'mp' so we could use what we have now until ffmpeg will be updated.

@elupus elupus was assigned

idea itself seems great to me. any chance this gets implemented? BTW I am using external ffmpeg 1.0 and would like to move to the 1.1 as well. Would it work with them as well?

Team Kodi member

I updated the patch with polish translation and added additional post-processing settings which I personally like to use and tested it with external ffmpeg 1.0.3 and seems to work well with that combination.
One thing I didn't personally like in the original patch is naming one of the options SLOW_CPU as fast cpus might like this setting too for some videos hence the change to AUTO. BASIC or AUTO_BASIC would probably be more appropriate as well.

Team Kodi member

Translations must be handled through Transifex and should not be added directly. Only English strings

Please change:
ha:a:128:7,va:a:128:7,dr:a -> ha:a:128:7,va:a,dr:a

See man-page of mplayer:
"The horizontal and vertical deblocking filters share the difference and flatness values so you cannot set different horizontal and vertical thresholds."

Also do not use name "Auto" for the filter:

hb:a,vb:a,dr:a - this filter should be used only on slow CPU's

It's ok to name the filter Auto internally in the source but not as a setting to the user


I read mplayer manual filtering (pp) section back and forward several times and could not find information about thresholds, but then I typed "mplayer -pphelp" and it sure mentioned that setting it the same for H & V is required. Still I believe that mine should work too as I set same levels for both. It probably was just redundant, but I could be wrong. In either case definatly extra 128:7 should be removed.
That said is is possible to add INSANE/EXTREME/SLOWEST filter with levels od something like 255:3 for example? What is the limit there if any?
What about h1 & v1 filetrs. Are there any better than any of the below combinations or if somebody says so it is just a placebo?

Localy I already switch "Auto" to "Basic", but before I post it I consider changing it a bit to something like this. Please take a look if it makes sense

Highest = "ha:255:3,va,dr";
Higher = "ha:128:7,va,dr";
High = "ha:a:128:7,va:a,dr:a";
Normal [set to default] = "ha,va,dr";
Fast = "hb:a:128:7,vb:a,dr:a";
Faster = "hb,vb,dr";
Fastest = "hb:a,vb:a,dr:a";


This is the HTML version of the documentation:

About setting "ha:255:3,va,dr" – I don’t know the upper limit for difference and flatness the documentation says nothing about that. I think we could use ha:128:7,va,dr as the maximum. Other than that, 8 different settings for pp is just too much. And hb:a,vb:a,dr:a is not faster than hb,vb,dr, the difference is that some or all filters are switched of when computer is too slow. On a fast computer they are the same setting.

I think 3 settings are just fine let’s just take defaults from mplayer:

  • Default: "ha:a,va:a,dr:a" (mplayer de/default option)
  • Accurate: "ha:a:128:7,va:a,dr:a" (mplayer ac option)
  • Fast: "h1:a,v1:a,dr:a" (mplayer fa/fast option)

I must have missed notification about your post so hence only now the response. I agree having to many choices may not be what one desires, and sticking to those automatic once will be better choice for more users, but I would keep that ha:255:3 in there as I tested it with some very bad quality low res samples and it did in fact not only work but made them look better. With that said it would get it down to only 4.

Highest = "ha:a:255:3,va:a,dr:a";
High = "ha:a:128:7,va:a,dr:a";
Default = "ha:a,va:a,dr:a";
Fast = "h1:a,v1:a,dr:a";

Following is what I had used till now with FernetMenta tree which worked quite fine for me for the past month until recent changes in the settings directory. Another one is current WiP reflecting that change however I am not able to find reason why it would not compile for me with errors in MediaSettings.cpp and VideoDatabase.cpp

On the side note to further extend on the idea I believe a quite welcomed feature would be to add an ability for an users to pick different postprocessing method for different resolution/s. Once they enable PP if they do not take additional action then the default would be picked. Then they could enter as many resolutions as they want just like with "adjustrefreshrate" and then pick among those 4 above PP methods.
That way I could for instance set Highest for 576, High for 720, Default for 1080


Don’t really understand the Highest = "ha 255:3,va:a,dr:a"; setting but if you tested and works fine than I see no reason not to add it. About the "PP settings"/resolution, video quality is not related to resolution, you can have a 1080p video that was up-scaled from a very bad quality low-res video and then you want to let the user set the PP option for that video. Currently the user sees the video and decides what PP option to use (that's just fine). Personally I keep PP off until I play an SD quality video that looks awful, than I switch PP to an option I like. If you can somehow detect HD quality video (I think we do show icon for SD and HD) then you could add an option to turn off PP for HD and that would be more useful.

@CrHasher CrHasher closed this
@CrHasher CrHasher reopened this

Sorry for closing pull, my mistake :dancer:


I think this needs some work after all the FFMPEG changes....


At the time avfilter was introduced, post-processing filters were unavailable. We should add the new pp filter to our filter chain and remove the old code completely.
You can add the pp filter (with same options) to the filter chain in function:

unsigned int CDVDVideoCodecFFmpeg::SetFilters(unsigned int flags)

This function is called from:

void CDVDPlayerVideo::Process()
  • here you can see how other filter flags are set (deinterlace, rotate)
  • also mPostProcess and anything related should be removed from CDVDPlayerVideo
@CrHasher CrHasher closed this

@wmyrda: Please if you make changes submit a new pull request from your fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 12, 2011
  1. @CrHasher
4 language/English/strings.xml
@@ -1538,6 +1538,10 @@
<string id="16324">Software Blend</string>
<string id="16400">Post-processing</string>
+ <string id="16401">Post-processing Mode</string>
+ <string id="16402">Default</string>
+ <string id="16403">Aggressive</string>
+ <string id="16404">Auto (slow CPU)</string>
<string id="17500">Display sleep timeout</string>
22 xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
@@ -623,8 +623,26 @@ void CDVDPlayerVideo::Process()
if (!sPostProcessType.empty())
sPostProcessType += ",";
- // This is what mplayer uses for its "high-quality filter combination"
- sPostProcessType += g_advancedSettings.m_videoPPFFmpegPostProc;
+ switch (g_settings.m_currentVideoSettings.m_PostProcessingMode)
+ {
+ {
+ // this is the one that will be overwritten by settings in Advancedsettings.xml
+ sPostProcessType += g_advancedSettings.m_videoPPFFmpegPostProcDefault;
+ }
+ break;
+ {
+ sPostProcessType += g_advancedSettings.m_videoPPFFmpegPostProcAggressive;
+ }
+ break;
+ {
+ sPostProcessType += g_advancedSettings.m_videoPPFFmpegPostProcAutoQuality;
+ }
+ break;
+ }
if (!sPostProcessType.empty())
6 xbmc/settings/AdvancedSettings.cpp
@@ -82,7 +82,9 @@ void CAdvancedSettings::Initialize()
m_videoPercentSeekBackwardBig = -10;
m_videoBlackBarColour = 0;
m_videoPPFFmpegDeint = "linblenddeint";
- m_videoPPFFmpegPostProc = "ha:128:7,va,dr";
+ m_videoPPFFmpegPostProcDefault = "ha,va,dr"; // ha:32:39,va,dr
+ m_videoPPFFmpegPostProcAggressive = "ha:128:7,va,dr";
+ m_videoPPFFmpegPostProcAutoQuality = "hb:a,vb:a,dr:a"; // ":a"=automatically switch the subfilter off if the CPU is too slow
m_videoDefaultPlayer = "dvdplayer";
m_videoDefaultDVDPlayer = "dvdplayer";
m_videoIgnoreSecondsAtStart = 3*60;
@@ -449,7 +451,7 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file)
XMLUtils::GetString(pElement,"cleandatetime", m_videoCleanDateTimeRegExp);
- XMLUtils::GetString(pElement,"ppffmpegpostprocessing",m_videoPPFFmpegPostProc);
+ XMLUtils::GetString(pElement,"ppffmpegpostprocessing",m_videoPPFFmpegPostProcDefault);
XMLUtils::GetFloat(pElement, "nonlinearstretchratio", m_videoNonLinStretchRatio, 0.01f, 1.0f);
XMLUtils::GetBoolean(pElement,"enablehighqualityhwscalers", m_videoEnableHighQualityHwScalers);
4 xbmc/settings/AdvancedSettings.h
@@ -100,7 +100,9 @@ class CAdvancedSettings
int m_videoPercentSeekForwardBig;
int m_videoPercentSeekBackwardBig;
CStdString m_videoPPFFmpegDeint;
- CStdString m_videoPPFFmpegPostProc;
+ CStdString m_videoPPFFmpegPostProcDefault;
+ CStdString m_videoPPFFmpegPostProcAggressive;
+ CStdString m_videoPPFFmpegPostProcAutoQuality;
bool m_musicUseTimeSeeking;
int m_musicTimeSeekForward;
int m_musicTimeSeekBackward;
4 xbmc/settings/Settings.cpp
@@ -711,6 +711,9 @@ bool CSettings::LoadSettings(const CStdString& strSettingsFile)
GetFloat(pElement, "volumeamplification", m_defaultVideoSettings.m_VolumeAmplification, VOLUME_DRC_MINIMUM * 0.01f, VOLUME_DRC_MINIMUM * 0.01f, VOLUME_DRC_MAXIMUM * 0.01f);
GetFloat(pElement, "noisereduction", m_defaultVideoSettings.m_NoiseReduction, 0.0f, 0.0f, 1.0f);
XMLUtils::GetBoolean(pElement, "postprocess", m_defaultVideoSettings.m_PostProcess);
+ int postProcessingMode;
+ GetInteger(pElement, "postprocessingmode", postProcessingMode, VS_PPMODE_DEFAULT, VS_PPMODE_DEFAULT, VS_PPMODE_SLOW_CPU);
+ m_defaultVideoSettings.m_PostProcessingMode = (EPOSTPROCESSINGMODE)postProcessingMode;
GetFloat(pElement, "sharpness", m_defaultVideoSettings.m_Sharpness, 0.0f, -1.0f, 1.0f);
XMLUtils::GetBoolean(pElement, "outputtoallspeakers", m_defaultVideoSettings.m_OutputToAllSpeakers);
XMLUtils::GetBoolean(pElement, "showsubtitles", m_defaultVideoSettings.m_SubtitleOn);
@@ -878,6 +881,7 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo
XMLUtils::SetInt(pNode, "scalingmethod", m_defaultVideoSettings.m_ScalingMethod);
XMLUtils::SetFloat(pNode, "noisereduction", m_defaultVideoSettings.m_NoiseReduction);
XMLUtils::SetBoolean(pNode, "postprocess", m_defaultVideoSettings.m_PostProcess);
+ XMLUtils::SetInt(pNode, "postprocessingmode", m_defaultVideoSettings.m_PostProcessingMode);
XMLUtils::SetFloat(pNode, "sharpness", m_defaultVideoSettings.m_Sharpness);
XMLUtils::SetInt(pNode, "viewmode", m_defaultVideoSettings.m_ViewMode);
XMLUtils::SetFloat(pNode, "zoomamount", m_defaultVideoSettings.m_CustomZoomAmount);
2 xbmc/settings/VideoSettings.cpp
@@ -50,6 +50,7 @@ CVideoSettings::CVideoSettings()
m_Sharpness = 0.0f;
m_NoiseReduction = 0;
m_PostProcess = false;
+ m_PostProcessingMode = VS_PPMODE_DEFAULT;
m_VolumeAmplification = 0;
m_AudioDelay = 0.0f;
m_OutputToAllSpeakers = false;
@@ -82,6 +83,7 @@ bool CVideoSettings::operator!=(const CVideoSettings &right) const
if (m_Sharpness != right.m_Sharpness) return true;
if (m_NoiseReduction != right.m_NoiseReduction) return true;
if (m_PostProcess != right.m_PostProcess) return true;
+ if (m_PostProcessingMode != right.m_PostProcessingMode) return true;
if (m_VolumeAmplification != right.m_VolumeAmplification) return true;
if (m_AudioDelay != right.m_AudioDelay) return true;
if (m_OutputToAllSpeakers != right.m_OutputToAllSpeakers) return true;
8 xbmc/settings/VideoSettings.h
@@ -92,6 +92,13 @@ enum ESCALINGMETHOD
class CVideoSettings
@@ -120,6 +127,7 @@ class CVideoSettings
float m_Gamma;
float m_NoiseReduction;
bool m_PostProcess;
float m_Sharpness;
float m_AudioDelay;
int m_ResumeTime;
16 xbmc/video/VideoDatabase.cpp
@@ -101,7 +101,7 @@ bool CVideoDatabase::CreateTables()
"SubtitleDelay float, SubtitlesOn bool, Brightness float, Contrast float, Gamma float,"
"VolumeAmplification float, AudioDelay float, OutputToAllSpeakers bool, ResumeTime integer, Crop bool, CropLeft integer,"
"CropRight integer, CropTop integer, CropBottom integer, Sharpness float, NoiseReduction float, NonLinStretch bool, PostProcess bool,"
- "ScalingMethod integer, DeinterlaceMode integer)\n");
+ "ScalingMethod integer, DeinterlaceMode integer, PostProcessingMode integer)\n");
m_pDS->exec("CREATE UNIQUE INDEX ix_settings ON settings ( idFile )\n");
CLog::Log(LOGINFO, "create stacktimes table");
@@ -3015,6 +3015,7 @@ bool CVideoDatabase::GetVideoSettings(const CStdString &strFilenameAndPath, CVid
settings.m_CustomNonLinStretch = m_pDS->fv("NonLinStretch").get_asBool();
settings.m_NoiseReduction = m_pDS->fv("NoiseReduction").get_asFloat();
settings.m_PostProcess = m_pDS->fv("PostProcess").get_asBool();
+ settings.m_PostProcessingMode = (EPOSTPROCESSINGMODE)m_pDS->fv("PostProcessingMode").get_asInt();
settings.m_Sharpness = m_pDS->fv("Sharpness").get_asFloat();
settings.m_CustomZoomAmount = m_pDS->fv("ZoomAmount").get_asFloat();
settings.m_CustomVerticalShift = m_pDS->fv("VerticalShift").get_asFloat();
@@ -3067,12 +3068,12 @@ void CVideoDatabase::SetVideoSettings(const CStdString& strFilenameAndPath, cons
strSQL=PrepareSQL("update settings set Deinterlace=%i,ViewMode=%i,ZoomAmount=%f,PixelRatio=%f,VerticalShift=%f,"
- "DeinterlaceMode=%i,",
+ "DeinterlaceMode=%i,PostProcessingMode=%i,",
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_DeinterlaceMode);
+ setting.m_DeinterlaceMode,setting.m_PostProcessingMode);
CStdString strSQL2;
strSQL2=PrepareSQL("ResumeTime=%i,Crop=%i,CropLeft=%i,CropRight=%i,CropTop=%i,CropBottom=%i where idFile=%i\n", setting.m_ResumeTime, setting.m_Crop, setting.m_CropLeft, setting.m_CropRight, setting.m_CropTop, setting.m_CropBottom, idFile);
strSQL += strSQL2;
@@ -3086,7 +3087,7 @@ void CVideoDatabase::SetVideoSettings(const CStdString& strFilenameAndPath, cons
- "Sharpness,NoiseReduction,NonLinStretch,PostProcess,ScalingMethod,DeinterlaceMode) "
+ "Sharpness,NoiseReduction,NonLinStretch,PostProcess,ScalingMethod,DeinterlaceMode,PostProcessingMode) "
strSQL += PrepareSQL("(%i,%i,%i,%f,%f,%f,%i,%i,%f,%i,%f,%f,%f,%f,%f,%i,%i,%i,%i,%i,%i,%i,%f,%f,%i,%i,%i,%i)",
idFile, setting.m_InterlaceMethod, setting.m_ViewMode, setting.m_CustomZoomAmount, setting.m_CustomPixelRatio, setting.m_CustomVerticalShift,
@@ -3094,7 +3095,7 @@ void CVideoDatabase::SetVideoSettings(const CStdString& strFilenameAndPath, cons
setting.m_Contrast, setting.m_Gamma, setting.m_VolumeAmplification, setting.m_AudioDelay, setting.m_OutputToAllSpeakers,
setting.m_ResumeTime, setting.m_Crop, setting.m_CropLeft, setting.m_CropRight, setting.m_CropTop, setting.m_CropBottom,
setting.m_Sharpness, setting.m_NoiseReduction, setting.m_CustomNonLinStretch, setting.m_PostProcess, setting.m_ScalingMethod,
- setting.m_DeinterlaceMode);
+ setting.m_DeinterlaceMode,setting.m_PostProcessingMode);
@@ -3497,6 +3498,11 @@ bool CVideoDatabase::UpdateOldVersion(int iVersion)
+ if (iVersion < 57)
+ {
+ m_pDS->exec("ALTER table settings add PostProcessingMode integer");
+ m_pDS->exec(PrepareSQL("UPDATE settings set PostProcessingMode=%i", g_settings.m_defaultVideoSettings.m_PostProcessingMode));
+ }
catch (...)
2 xbmc/video/VideoDatabase.h
@@ -721,7 +721,7 @@ class CVideoDatabase : public CDatabase
bool LookupByFolders(const CStdString &path, bool shows = false);
- virtual int GetMinVersion() const { return 56; };
+ virtual int GetMinVersion() const { return 57; };
virtual int GetExportVersion() const { return 1; };
const char *GetBaseDBName() const { return "MyVideos"; };
13 xbmc/video/dialogs/GUIDialogVideoSettings.cpp
@@ -67,6 +67,7 @@ CGUIDialogVideoSettings::~CGUIDialogVideoSettings(void)
void CGUIDialogVideoSettings::CreateSettings()
@@ -164,7 +165,12 @@ void CGUIDialogVideoSettings::CreateSettings()
AddSlider(VIDEO_SETTINGS_VERTICAL_SHIFT, 225, &g_settings.m_currentVideoSettings.m_CustomVerticalShift, -2.0f, 0.01f, 2.0f, FormatFloat);
AddSlider(VIDEO_SETTINGS_PIXEL_RATIO, 217, &g_settings.m_currentVideoSettings.m_CustomPixelRatio, 0.5f, 0.01f, 2.0f, FormatFloat);
AddBool(VIDEO_SETTINGS_POSTPROCESS, 16400, &g_settings.m_currentVideoSettings.m_PostProcess);
+ {
+ const int entries[] = {16402, 16403, 16404};
+ AddSpin(VIDEO_SETTINGS_POSTPROCESS_MODE, 16401, (int*)&g_settings.m_currentVideoSettings.m_PostProcessingMode, 3, entries);
+ EnableSettings(VIDEO_SETTINGS_POSTPROCESS_MODE, g_settings.m_currentVideoSettings.m_PostProcess);
+ }
if (g_renderManager.Supports(RENDERFEATURE_BRIGHTNESS))
AddSlider(VIDEO_SETTINGS_BRIGHTNESS, 464, &g_settings.m_currentVideoSettings.m_Brightness, 0, 1, 100, FormatInteger);
@@ -241,6 +247,11 @@ void CGUIDialogVideoSettings::OnSettingChanged(SettingInfo &setting)
EnableSettings(VIDEO_SETTINGS_INTERLACEMETHOD, g_settings.m_currentVideoSettings.m_DeinterlaceMode != VS_DEINTERLACEMODE_OFF);
+ {
+ EnableSettings(VIDEO_SETTINGS_POSTPROCESS_MODE, g_settings.m_currentVideoSettings.m_PostProcess);
+ }
CStdString CGUIDialogVideoSettings::FormatInteger(float value, float minimum)
Something went wrong with that request. Please try again.