From 0d56cc4fafdfd6047798fd588de60b61c582c36a Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 12 Jan 2020 21:23:51 +0100 Subject: [PATCH 1/5] 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. --- Vocaluxe/Screens/CScreenSing.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index b5eb65ed..43223d3c 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -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 } } } -} \ No newline at end of file +} From 94aa28112d5a63aa44d65b1e2cea9ab8ef0dcdf6 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 12 Jan 2020 21:32:36 +0100 Subject: [PATCH 2/5] On LetterBox make a Pillarbox if aspect ratio is equal If background video and Vocaluxe have the same aspect ratio, switching to aspect ratio LetterBox would do a Pillarbox, so you can add 4:3 borders, if a video file has the wrong aspect ratio (maybe SAR value at 16:9, but a DAR value at 4:3). Without this change, LetterBox would do exactly the same as Crop in this special case. --- VocaluxeLib/CHelper.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/VocaluxeLib/CHelper.cs b/VocaluxeLib/CHelper.cs index 20efe943..fa5fb2f4 100644 --- a/VocaluxeLib/CHelper.cs +++ b/VocaluxeLib/CHelper.cs @@ -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 @@ -101,6 +101,7 @@ namespace VocaluxeLib switch (aspect) { + case EAspect.Automatic: case EAspect.Crop: if (boundsAspectRatio >= aspectRatio) { @@ -138,7 +139,12 @@ namespace VocaluxeLib } break; case EAspect.LetterBox: - if (boundsAspectRatio <= aspectRatio) + if (boundsAspectRatio == aspectRatio) // Pillarbox + { + scaledWidth = bounds.W * 0.77f; + scaledHeight = bounds.W / aspectRatio; + } + else if (boundsAspectRatio < aspectRatio) { scaledWidth = bounds.W; scaledHeight = bounds.W / aspectRatio; @@ -306,4 +312,4 @@ namespace VocaluxeLib return bmp; } } -} \ No newline at end of file +} From 0f504a101596720aa561defff0ed706acb9e75d7 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 12 Jan 2020 21:33:23 +0100 Subject: [PATCH 3/5] Added Automatic at EAspect --- VocaluxeLib/Enums.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VocaluxeLib/Enums.cs b/VocaluxeLib/Enums.cs index 8ba2a416..84252cfa 100644 --- a/VocaluxeLib/Enums.cs +++ b/VocaluxeLib/Enums.cs @@ -64,6 +64,7 @@ namespace VocaluxeLib #region Fonts public enum EAspect { + Automatic, Crop, LetterBox, Stretch, @@ -436,4 +437,4 @@ namespace VocaluxeLib TR_USERROLE_PROFILEEDITOR = 32 // ReSharper restore InconsistentNaming } -} \ No newline at end of file +} From b651d7df4d1a58f0a6adf2e6183ed3a9e0e1aa26 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 12 Jan 2020 21:36:09 +0100 Subject: [PATCH 4/5] VideoAspect default is now EAspect.Automatic --- VocaluxeLib/Songs/CSong.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index e6ddaf4d..063eb3a0 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -101,7 +101,7 @@ namespace VocaluxeLib.Songs public readonly List BackgroundFileNames = new List(); public string VideoFileName = String.Empty; - public EAspect VideoAspect = EAspect.Crop; + public EAspect VideoAspect = EAspect.Automatic; public bool NotesLoaded { get; private set; } @@ -518,4 +518,4 @@ namespace VocaluxeLib.Songs ShortEnd.Source = EDataSource.Calculated; } } -} \ No newline at end of file +} From 69a87842e9b9dcf964ec7704137cc5355a894a40 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 12 Jan 2020 21:40:24 +0100 Subject: [PATCH 5/5] 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. --- Vocaluxe/Screens/CScreenSing.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 43223d3c..df0648d2 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -804,11 +804,11 @@ namespace Vocaluxe.Screens if (background != null) { SRectF bounds = CSettings.RenderRect; - - if (_VideoAspect == EAspect.Automatic) + + 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); }