Skip to content

Commit

Permalink
VDPAU: change scaling advanced option to integer level, enable vdpau …
Browse files Browse the repository at this point in the history
…scaling capability, fix double free bug for threelines
  • Loading branch information
TheSwissKnife authored and FernetMenta committed Jan 9, 2012
1 parent 67c0cf8 commit 81093ff
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 42 deletions.
154 changes: 116 additions & 38 deletions xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
Expand Up @@ -55,7 +55,6 @@ CVDPAU::Desc decoder_profiles[] = {
};
const size_t decoder_profile_count = sizeof(decoder_profiles)/sizeof(CVDPAU::Desc);

//// TODO: This matrix is for BT709 only and is probably slighly out - derive from first principles instead
//static float studioCSC[3][4] =
//{
// { 1.0f, 0.0f, 1.57480000f,-0.78740000f},
Expand Down Expand Up @@ -183,7 +182,6 @@ CVDPAU::CVDPAU() : CThread("CVDPAU")
m_allOutPic[i].vdp_flip_queue = VDP_INVALID_HANDLE;
}

// TODO: change setting to integer level setting all scaling options below it too
upScale = g_advancedSettings.m_videoVDPAUScaling;
}

Expand Down Expand Up @@ -355,7 +353,7 @@ void CVDPAU::SetWidthHeight(int width, int height)

//pick the smallest dimensions, so we downscale with vdpau and upscale with opengl when appropriate
//this requires the least amount of gpu memory bandwidth
if (g_graphicsContext.GetWidth() < width || g_graphicsContext.GetHeight() < height || upScale)
if (g_graphicsContext.GetWidth() < width || g_graphicsContext.GetHeight() < height || upScale >= 0)
{
//scale width to desktop size if the aspect ratio is the same or bigger than the desktop
if ((double)height * g_graphicsContext.GetWidth() / width <= (double)g_graphicsContext.GetHeight())
Expand All @@ -374,6 +372,7 @@ void CVDPAU::SetWidthHeight(int width, int height)
OutWidth = width;
OutHeight = height;
}
CLog::Log(LOGDEBUG, "CVDPAU::SetWidthHeight Setting OutWidth: %i OutHeight: %i vdpauMaxHeight: %i", OutWidth, OutHeight, vdpauMaxHeight);
}

bool CVDPAU::MakePixmap(int index, int width, int height)
Expand Down Expand Up @@ -654,8 +653,9 @@ void CVDPAU::CheckFeatures()
tmpContrast = 0;
tmpNoiseReduction = 0;
tmpSharpness = 0;
tmpPostProc = true;
tmpDeint = 0;
tmpUpScale = -1;
tmpPostProc = true;

VdpStatus vdp_st = VDP_STATUS_ERROR;
vdp_st = vdp_video_mixer_create(vdp_device,
Expand All @@ -666,10 +666,13 @@ void CVDPAU::CheckFeatures()
parameter_values,
&videoMixer);
CheckStatus(vdp_st, __LINE__);

//SetHWUpscaling();
}

if (tmpUpScale != upScale)
{
SetHWUpscaling();
tmpUpScale = upScale;
}
if (tmpBrightness != g_settings.m_currentVideoSettings.m_Brightness ||
tmpContrast != g_settings.m_currentVideoSettings.m_Contrast)
{
Expand Down Expand Up @@ -916,13 +919,79 @@ void CVDPAU::SetDeintSkipChroma()
void CVDPAU::SetHWUpscaling()
{
#ifdef VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1
if(!Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1) || !upScale)
return;
//if(!Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1) || upScale <= 0)
//return;

VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 };
VdpStatus vdp_st;
VdpBool enabled[]={1};
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
switch (upScale)
{
case 9:
if (Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9 };
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 8:
if (Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8 };
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 7:
if (Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7 };
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 6:
if (Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6 };
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 5:
if (Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5 };
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 4:
if (Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4 };
break;
}
case 3:
if (Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3 };
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 2:
if (Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2 };
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 1:
if (Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 };
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
break;
}
default:
DisableHQScaling();
return;
}
CheckStatus(vdp_st, __LINE__);
#endif
}
Expand Down Expand Up @@ -1010,39 +1079,13 @@ void CVDPAU::SetDeinterlacing()
SetDeintSkipChroma();
}

void CVDPAU::PostProcOff()
void CVDPAU::DisableHQScaling()
{
VdpStatus vdp_st;

if (videoMixer == VDP_INVALID_HANDLE)
return;

VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL,
VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL,
VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE};

VdpBool enabled[]={0,0,0};
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);

if(Supports(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION};

VdpBool enabled[]={0};
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}

if(Supports(VDP_VIDEO_MIXER_FEATURE_SHARPNESS))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_SHARPNESS};

VdpBool enabled[]={0};
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}

if(Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 };
Expand Down Expand Up @@ -1116,6 +1159,42 @@ void CVDPAU::PostProcOff()
}
}

void CVDPAU::PostProcOff()
{
VdpStatus vdp_st;

if (videoMixer == VDP_INVALID_HANDLE)
return;

VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL,
VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL,
VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE};

VdpBool enabled[]={0,0,0};
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);

if(Supports(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION};

VdpBool enabled[]={0};
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}

if(Supports(VDP_VIDEO_MIXER_FEATURE_SHARPNESS))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_SHARPNESS};

VdpBool enabled[]={0};
vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}

DisableHQScaling();
}


void CVDPAU::InitVDPAUProcs()
{
Expand Down Expand Up @@ -2199,7 +2278,6 @@ int CVDPAU::Decode(AVCodecContext *avctx, AVFrame *pFrame, bool bSoftDrain, bool
continue;
else if (bHardDrain)
{
// TODO: improve mixer drain logic so that it occurs if usedPics+msgs==0 for say 50ms and asked to drain throughout
if (usedPics == 0 && msgs == 0 && prevNotEmpty && iter > 100)
{
CSingleLock lock(m_mixerSec);
Expand Down
4 changes: 3 additions & 1 deletion xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h
Expand Up @@ -142,6 +142,7 @@ class CVDPAU
void SetSharpness();
void SetDeintSkipChroma();
void SetDeinterlacing();
void DisableHQScaling();
void PostProcOff();
EINTERLACEMETHOD GetDeinterlacingMethod(bool log = false);
void SetHWUpscaling();
Expand All @@ -150,11 +151,12 @@ class CVDPAU
pictureAge picAge;
vdpau_render_state *past[2], *current, *future[2];
int tmpDeintMode, tmpDeint;
int tmpUpScale;
bool tmpPostProc;
float tmpNoiseReduction, tmpSharpness;
float tmpBrightness, tmpContrast;
int OutWidth, OutHeight;
bool upScale;
int upScale;
bool m_preBindPixmapsDone;

VdpProcamp m_Procamp;
Expand Down
4 changes: 2 additions & 2 deletions xbmc/settings/AdvancedSettings.cpp
Expand Up @@ -88,7 +88,7 @@ void CAdvancedSettings::Initialize()
m_videoIgnoreSecondsAtStart = 3*60;
m_videoIgnorePercentAtEnd = 8.0f;
m_videoPlayCountMinimumPercent = 90.0f;
m_videoVDPAUScaling = false;
m_videoVDPAUScaling = -1;
m_videoNonLinStretchRatio = 0.5f;
m_videoEnableHighQualityHwScalers = false;
m_videoAutoScaleMaxFps = 30.0f;
Expand Down Expand Up @@ -469,7 +469,7 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file)
XMLUtils::GetString(pElement,"ppffmpegdeinterlacing",m_videoPPFFmpegDeint);
XMLUtils::GetInt(pElement,"ffmpeginterlacedflaglingerframes",m_videoFFmpegInterlacedFlagLingerFrames);
XMLUtils::GetString(pElement,"ppffmpegpostprocessing",m_videoPPFFmpegPostProc);
XMLUtils::GetBoolean(pElement,"vdpauscaling",m_videoVDPAUScaling);
XMLUtils::GetInt(pElement,"vdpauscaling",m_videoVDPAUScaling);
XMLUtils::GetFloat(pElement, "nonlinearstretchratio", m_videoNonLinStretchRatio, 0.01f, 1.0f);
XMLUtils::GetBoolean(pElement,"enablehighqualityhwscalers", m_videoEnableHighQualityHwScalers);
XMLUtils::GetFloat(pElement,"autoscalemaxfps",m_videoAutoScaleMaxFps, 0.0f, 1000.0f);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/settings/AdvancedSettings.h
Expand Up @@ -124,7 +124,7 @@ class CAdvancedSettings
CStdString m_audioHost;
bool m_audioApplyDrc;

bool m_videoVDPAUScaling;
int m_videoVDPAUScaling;
float m_videoNonLinStretchRatio;
bool m_videoEnableHighQualityHwScalers;
float m_videoAutoScaleMaxFps;
Expand Down

0 comments on commit 81093ff

Please sign in to comment.