config option to allow using custom interp factor

This commit is contained in:
n00mkrad
2021-08-24 15:43:29 +02:00
parent 6db9a1b767
commit 08f6da55e7
4 changed files with 47 additions and 4 deletions

View File

@@ -322,6 +322,7 @@
this.interpFactorCombox.Size = new System.Drawing.Size(100, 23);
this.interpFactorCombox.TabIndex = 7;
this.interpFactorCombox.SelectedIndexChanged += new System.EventHandler(this.interpFactorCombox_SelectedIndexChanged);
this.interpFactorCombox.TextUpdate += new System.EventHandler(this.interpFactorCombox_SelectedIndexChanged);
//
// label4
//

View File

@@ -50,6 +50,7 @@ namespace Flowframes
NvApi.Init();
InitAis();
InterpolationProgress.preview = previewPicturebox;
UnlockInterpFactorIfEnabled();
RemovePreviewIfDisabled();
UpdateStepByStepControls();
Initialized();
@@ -120,6 +121,14 @@ namespace Flowframes
}
void UnlockInterpFactorIfEnabled ()
{
if (!Config.GetBool(Config.Key.allowCustomInterpFactor))
return;
interpFactorCombox.DropDownStyle = ComboBoxStyle.DropDown;
}
void RemovePreviewIfDisabled ()
{
if (!Config.GetBool(Config.Key.disablePreview))
@@ -300,6 +309,8 @@ namespace Flowframes
public void runBtn_Click(object sender, EventArgs e)
{
ValidateFactor();
if (!BatchProcessing.busy) // Don't load values from gui if batch processing is used
Interpolate.current = GetCurrentSettings();
@@ -342,7 +353,7 @@ namespace Flowframes
outModeCombox.SelectedIndex = targetIndex;
}
AI GetAi()
public AI GetAi()
{
return Implementations.networks[aiCombox.SelectedIndex];
}
@@ -392,15 +403,20 @@ namespace Flowframes
private void interpFactorCombox_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateUiFps();
int guiInterpFactor = interpFactorCombox.GetInt();
int guiFactor = interpFactorCombox.GetInt();
if (!initialized)
return;
string aiName = GetAi().aiName.Replace("_", "-");
if (!Program.busy && guiInterpFactor > 2 && GetAi().multiPass && Config.GetInt(Config.Key.autoEncMode) > 0 && !Logger.GetLastLine().Contains(aiName))
Logger.Log($"Warning: {aiName} doesn't natively support 4x/8x and will run multiple times for {guiInterpFactor}x. Auto-Encode will only work on the last run.");
if (!Program.busy && guiFactor > 2 && GetAi().multiPass && Config.GetInt(Config.Key.autoEncMode) > 0 && !Logger.GetLastLine().Contains(aiName))
Logger.Log($"Warning: {aiName} doesn't natively support 4x/8x and will run multiple times for {guiFactor}x. Auto-Encode will only work on the last run.");
}
public void ValidateFactor ()
{
interpFactorCombox.Text = $"x{MainUiFunctions.ValidateInterpFactor(interpFactorCombox.GetInt())}";
}
public void SetWorking(bool state, bool allowCancel = true)
@@ -542,6 +558,8 @@ namespace Flowframes
private void queueBtn_Click(object sender, EventArgs e)
{
ValidateFactor();
if (BatchProcessing.currentBatchForm != null)
{
BatchProcessing.currentBatchForm.WindowState = FormWindowState.Normal;

View File

@@ -306,6 +306,7 @@ namespace Flowframes.IO
aiCombox,
allowConsecutiveSceneChanges,
allowCustomInputRate,
allowCustomInterpFactor,
allowSymlinkEncoding,
allowSymlinkImport,
alwaysWaitForAutoEnc,

View File

@@ -123,5 +123,28 @@ namespace Flowframes.Ui
return null;
}
}
public static int ValidateInterpFactor (int factor)
{
AI ai = Program.mainForm.GetAi();
if (factor > 256)
return 256;
if (ai.aiName == Implementations.rifeCuda.aiName)
{
if (!IsPowerOfTwo(factor))
{
return Implementations.rifeCuda.supportedFactors.Last();
}
}
return factor;
}
static bool IsPowerOfTwo(int x)
{
return (x != 0) && ((x & (x - 1)) == 0);
}
}
}