Automatic switch of aspect ratio for background

If the orig aspect ratio (width / height) is below or equal to 1.5, switch to EAspect.LetterBox. If not, leave it at EAspect.Crop (like in Vocaluxe before).

Unfortunately the acinerella library, used by Vocaluxe, don't support reading of the DAR value of the video file. So the SAR value has to be correct in the video file, to see this automatic in action.
This commit is contained in:
Stefan authored and GitHub committed 2020-01-12 21:23:51 +01:00
1 parent 2de4cc4cf6
commit 0d56cc4faf
1 file changed
+9 -6
+9 -6
View File
@@ -1,4 +1,4 @@
#region license
#region license
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
@@ -112,7 +112,7 @@ namespace Vocaluxe.Screens
private float _Length = -1f;
private CVideoStream _CurrentVideo;
private EAspect _VideoAspect = EAspect.Crop;
private EAspect _VideoAspect = EAspect.Automatic;
private CTextureRef _CurrentWebcamFrameTexture;
private CTextureRef _Background;
@@ -794,18 +794,21 @@ namespace Vocaluxe.Screens
if (_CurrentVideo != null && CConfig.Config.Video.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam)
{
background = _CurrentVideo.Texture;
aspect = _VideoAspect;
}
else if (_Webcam)
{
background = _CurrentWebcamFrameTexture;
aspect = _VideoAspect;
}
else
background = _Background;
if (background != null)
{
SRectF bounds = CSettings.RenderRect;
if (_VideoAspect == EAspect.Automatic)
_VideoAspect = (background.OrigAspect <= 1.5 ? EAspect.LetterBox : EAspect.Crop);
aspect = _VideoAspect;
SRectF rect = CHelper.FitInBounds(bounds, background.OrigAspect, aspect);
CDraw.DrawTexture(background, rect, background.Color, bounds);
}
@@ -1087,7 +1090,7 @@ namespace Vocaluxe.Screens
{
_CurrentVideo = CVideo.Load(Path.Combine(song.Folder, song.VideoFileName));
CVideo.Skip(_CurrentVideo, song.Start, song.VideoGap);
_VideoAspect = song.VideoAspect;
_VideoAspect = EAspect.Automatic;
}
CDraw.RemoveTexture(ref _Background);
@@ -1828,4 +1831,4 @@ namespace Vocaluxe.Screens
}
}
}
}
}