Update pkgs with vulnerabilities, remove some unused code

This commit is contained in:
n00mkrad
2025-12-14 15:27:46 +01:00
parent 5b3550e62b
commit a57936c01c
7 changed files with 24 additions and 307 deletions

View File

@@ -32,6 +32,10 @@
<assemblyIdentity name="System.Drawing.Common" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Magick.NET.Core" publicKeyToken="2004825badfa91ec" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.10.0.0" newVersion="14.10.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

View File

@@ -122,11 +122,11 @@
<Reference Include="HTAlt.Standart, Version=0.1.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\HTAlt.Standart.0.1.6\lib\netstandard2.0\HTAlt.Standart.dll</HintPath>
</Reference>
<Reference Include="Magick.NET-Q8-x64, Version=13.10.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=AMD64">
<HintPath>packages\Magick.NET-Q8-x64.13.10.0\lib\netstandard20\Magick.NET-Q8-x64.dll</HintPath>
<Reference Include="Magick.NET-Q8-x64, Version=14.10.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=AMD64">
<HintPath>packages\Magick.NET-Q8-x64.14.10.0\lib\netstandard20\Magick.NET-Q8-x64.dll</HintPath>
</Reference>
<Reference Include="Magick.NET.Core, Version=13.10.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
<HintPath>packages\Magick.NET.Core.13.10.0\lib\netstandard20\Magick.NET.Core.dll</HintPath>
<Reference Include="Magick.NET.Core, Version=14.10.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
<HintPath>packages\Magick.NET.Core.14.10.0\lib\netstandard20\Magick.NET.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Build.Framework.15.9.20\lib\net46\Microsoft.Build.Framework.dll</HintPath>
@@ -154,7 +154,7 @@
<HintPath>packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NvAPIWrapper, Version=0.8.1.100, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL">
<HintPath>packages\NvAPIWrapper.Net.0.8.1.101\lib\net45\NvAPIWrapper.dll</HintPath>
@@ -473,7 +473,6 @@
<Compile Include="IO\Symlinks.cs" />
<Compile Include="Magick\Blend.cs" />
<Compile Include="Magick\MagickExtensions.cs" />
<Compile Include="Magick\SceneDetect.cs" />
<Compile Include="Main\AiModels.cs" />
<Compile Include="Main\AutoEncode.cs" />
<Compile Include="Main\AutoEncodeResume.cs" />
@@ -518,7 +517,6 @@
<Compile Include="IO\IoUtils.cs" />
<Compile Include="Data\Paths.cs" />
<Compile Include="IO\Logger.cs" />
<Compile Include="Magick\Converter.cs" />
<Compile Include="Magick\Dedupe.cs" />
<Compile Include="Os\AiProcessSuspend.cs" />
<Compile Include="Os\NvApi.cs" />
@@ -547,6 +545,7 @@
</EmbeddedResource>
<EmbeddedResource Include="Forms\BatchForm.resx">
<DependentUpon>BatchForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\BigPreviewForm.resx">
<DependentUpon>BigPreviewForm.cs</DependentUpon>
@@ -665,7 +664,7 @@
<Error Condition="!Exists('packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets'))" />
<Error Condition="!Exists('packages\ILRepack.2.0.34\build\ILRepack.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\ILRepack.2.0.34\build\ILRepack.props'))" />
<Error Condition="!Exists('packages\ILRepack.MSBuild.Task.2.0.13\build\ILRepack.MSBuild.Task.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\ILRepack.MSBuild.Task.2.0.13\build\ILRepack.MSBuild.Task.props'))" />
<Error Condition="!Exists('packages\Magick.NET-Q8-x64.13.10.0\build\netstandard20\Magick.NET-Q8-x64.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Magick.NET-Q8-x64.13.10.0\build\netstandard20\Magick.NET-Q8-x64.targets'))" />
<Error Condition="!Exists('packages\Magick.NET-Q8-x64.14.10.0\build\netstandard20\Magick.NET-Q8-x64.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Magick.NET-Q8-x64.14.10.0\build\netstandard20\Magick.NET-Q8-x64.targets'))" />
</Target>
<Target Name="ILRepack" AfterTargets="Build" Condition="'$(Configuration)' == 'ReleaseRepack'">
<PropertyGroup>
@@ -677,5 +676,5 @@
<ILRepack OutputType="$(OutputType)" MainAssembly="$(AssemblyName).exe" OutputAssembly="$(AssemblyName).exe" InputAssemblies="@(RepackAssemblies)" WilcardInputAssemblies="true" WorkingDirectory="$(WorkingDirectory)" />
</Target>
<Import Project="packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<Import Project="packages\Magick.NET-Q8-x64.13.10.0\build\netstandard20\Magick.NET-Q8-x64.targets" Condition="Exists('packages\Magick.NET-Q8-x64.13.10.0\build\netstandard20\Magick.NET-Q8-x64.targets')" />
<Import Project="packages\Magick.NET-Q8-x64.14.10.0\build\netstandard20\Magick.NET-Q8-x64.targets" Condition="Exists('packages\Magick.NET-Q8-x64.14.10.0\build\netstandard20\Magick.NET-Q8-x64.targets')" />
</Project>

View File

@@ -39,13 +39,18 @@ namespace Flowframes.IO
{
try
{
MagickImage img = new MagickImage(path);
Bitmap bitmap = img.ToBitmap();
if (log)
Logger.Log($"GetImage: Native image reading for '{Path.GetFileName(path)}' failed - Using Magick.NET fallback instead.", true);
return bitmap;
MagickImage img = new MagickImage(path);
// Bitmap bitmap = img.ToBitmap();
img.Format = MagickFormat.Bmp;
using (var memStream = new MemoryStream())
{
img.Write(memStream);
return new Bitmap(memStream);
}
}
catch (Exception e)
{

View File

@@ -1,145 +0,0 @@
using Flowframes;
using Flowframes.IO;
using Flowframes.Ui;
using ImageMagick;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Flowframes.Magick
{
class Converter
{
public static async Task Convert (string dir, MagickFormat format, int quality, string ext = "", bool print = true, bool setProgress = true)
{
var files = IoUtils.GetFilesSorted(dir);
if(print) Logger.Log($"Converting {files.Length} files in {dir}");
int counter = 0;
foreach (string file in files)
{
if (print) Logger.Log("Converting " + Path.GetFileName(file) + " to " + format.ToString().StripNumbers().Upper(), false, true);
MagickImage img = new MagickImage(file);
img.Format = format;
img.Quality = quality;
string outpath = file;
if (!string.IsNullOrWhiteSpace(ext)) outpath = Path.ChangeExtension(outpath, ext);
img.Write(outpath);
counter++;
if(setProgress)
Program.mainForm.SetProgress((int)Math.Round(((float)counter / files.Length) * 100f));
await Task.Delay(1);
}
}
public static async Task MakeBinary (string inputDir, string outputDir, bool print = true, bool setProgress = true)
{
try
{
var files = IoUtils.GetFilesSorted(inputDir);
if (print) Logger.Log($"Processing alpha channel...");
Directory.CreateDirectory(outputDir);
Stopwatch sw = new Stopwatch();
sw.Restart();
int counter = 0;
foreach (string file in files)
{
MagickImage img = new MagickImage(file);
img.Format = MagickFormat.Png24;
img.Quality = 10;
img.Threshold(new Percentage(75));
string outPath = Path.Combine(outputDir, Path.GetFileName(file));
img.Write(outPath);
counter++;
if (sw.ElapsedMilliseconds > 250)
{
if (setProgress)
Program.mainForm.SetProgress((int)Math.Round(((float)counter / files.Length) * 100f));
await Task.Delay(1);
sw.Restart();
}
}
}
catch (Exception e)
{
Logger.Log("MakeBinary Error: " + e.Message);
}
}
public static async Task ExtractAlpha (string inputDir, string outputDir, bool print = true, bool setProgress = true, bool removeInputAlpha = true)
{
try
{
var files = IoUtils.GetFilesSorted(inputDir);
if (print) Logger.Log($"Extracting alpha channel from images...");
Directory.CreateDirectory(outputDir);
Stopwatch sw = new Stopwatch();
sw.Restart();
int counter = 0;
foreach (string file in files)
{
MagickImage alphaImg = new MagickImage(file);
if (removeInputAlpha)
{
MagickImage rgbImg = alphaImg;
rgbImg.Format = MagickFormat.Png24;
rgbImg.Quality = 10;
MagickImage bg = new MagickImage(MagickColors.Black, rgbImg.Width, rgbImg.Height);
bg.Composite(rgbImg, CompositeOperator.Over);
rgbImg = bg;
rgbImg.Write(file);
}
alphaImg.Format = MagickFormat.Png24;
alphaImg.Quality = 10;
alphaImg.FloodFill(MagickColors.None, 0, 0); // Fill the image with a transparent background
alphaImg.InverseOpaque(MagickColors.None, MagickColors.White); // Change all the pixels that are not transparent to white.
alphaImg.ColorAlpha(MagickColors.Black); // Change the transparent pixels to black.
string outPath = Path.Combine(outputDir, Path.GetFileName(file));
alphaImg.Write(outPath);
counter++;
if (sw.ElapsedMilliseconds > 250)
{
if (setProgress)
Program.mainForm.SetProgress((int)Math.Round(((float)counter / files.Length) * 100f));
await Task.Delay(1);
sw.Restart();
}
}
}
catch (Exception e)
{
Logger.Log("ExtractAlpha Error: " + e.Message);
}
}
public static async Task Preprocess (string dir, bool setProgress = true)
{
var files = IoUtils.GetFilesSorted(dir);
Logger.Log($"Preprocessing {files} files in {dir}");
int counter = 0;
foreach (string file in files)
{
//Logger.Log("Converting " + Path.GetFileName(file) + " to " + format, false, true);
MagickImage img = new MagickImage(file);
//img.Format = MagickFormat.Bmp;
//img.Write(file);
//img = new MagickImage(file);
img.Format = MagickFormat.Png24;
img.Quality = 10;
counter++;
if (setProgress)
Program.mainForm.SetProgress((int)Math.Round(((float)counter / files.Length) * 100f));
await Task.Delay(1);
}
}
}
}

View File

@@ -30,58 +30,6 @@ namespace Flowframes.Magick
public static class MagickExtensions
{
[SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "False positive.")]
public static Bitmap ToBitmap(this MagickImage magickImg, BitmapDensity density)
{
string mapping = "BGR";
var format = PixelFormat.Format24bppRgb;
var image = magickImg;
try
{
if (image.ColorSpace != ColorSpace.sRGB)
{
image = (MagickImage)magickImg.Clone();
image.ColorSpace = ColorSpace.sRGB;
}
if (image.HasAlpha)
{
mapping = "BGRA";
format = PixelFormat.Format32bppArgb;
}
using (var pixels = image.GetPixelsUnsafe())
{
var bitmap = new Bitmap(image.Width, image.Height, format);
var data = bitmap.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, format);
var destination = data.Scan0;
for (int y = 0; y < image.Height; y++)
{
byte[] bytes = pixels.ToByteArray(0, y, image.Width, 1, mapping);
Marshal.Copy(bytes, 0, destination, bytes.Length);
destination = new IntPtr(destination.ToInt64() + data.Stride);
}
bitmap.UnlockBits(data);
SetBitmapDensity(magickImg, bitmap, density);
return bitmap;
}
}
finally
{
if (!ReferenceEquals(image, magickImg))
image.Dispose();
}
}
public static Bitmap ToBitmap(this MagickImage imageMagick) => ToBitmap(imageMagick, BitmapDensity.Ignore);
public static Bitmap ToBitmap(this MagickImage imageMagick, ImageFormat imageFormat) => ToBitmap(imageMagick, imageFormat, BitmapDensity.Ignore);
public static Bitmap ToBitmap(this MagickImage imageMagick, ImageFormat imageFormat, BitmapDensity bitmapDensity)
{
imageMagick.Format = InternalMagickFormatInfo.GetFormat(imageFormat);

View File

@@ -1,94 +0,0 @@
using Flowframes.IO;
using ImageMagick;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Flowframes.Magick
{
class SceneDetect
{
public static async Task RunSceneDetection (string path)
{
string outFolder = path + "-analyzed";
Directory.CreateDirectory(outFolder);
string ext = "png";
FileInfo[] frames = IoUtils.GetFileInfosSorted(path, false, "*." + ext);
for (int i = 1; i < frames.Length; i++)
{
FileInfo frame = frames[i];
FileInfo lastFrame = frames[i - 1];
Task.Run(() => ProcessFrame(frame, lastFrame, outFolder));
}
}
public static Dictionary<string, MagickImage> imageCache = new Dictionary<string, MagickImage>();
static MagickImage GetImage(string path, bool allowCaching = true)
{
if (!allowCaching)
return new MagickImage(path);
if (imageCache.Count >= 30)
ClearCache();
if (!imageCache.ContainsKey(path))
imageCache.Add(path, new MagickImage(path));
return imageCache[path];
}
public static void ClearCache()
{
imageCache.Clear();
}
static async Task ProcessFrame (FileInfo frame, FileInfo lastFrame, string outFolder)
{
MagickImage prevFrame = GetImage(lastFrame.FullName, false);
MagickImage currFrame = GetImage(frame.FullName, false);
Size originalSize = new Size(currFrame.Width, currFrame.Height);
int downscaleHeight = 144;
prevFrame.Scale(currFrame.Width / (currFrame.Height / downscaleHeight), downscaleHeight);
currFrame.Scale(currFrame.Width / (currFrame.Height / downscaleHeight), downscaleHeight);
double errNormalizedCrossCorrelation = currFrame.Compare(prevFrame, ErrorMetric.NormalizedCrossCorrelation);
double errRootMeanSquared = currFrame.Compare(prevFrame, ErrorMetric.RootMeanSquared);
string str = $"\nMetrics of {frame.Name.Split('.')[0]} against {lastFrame.Name.Split('.')[0]}:\n";
str += $"NormalizedCrossCorrelation: {errNormalizedCrossCorrelation.ToString("0.000")}\n";
str += $"RootMeanSquared: {errRootMeanSquared.ToString("0.000")}\n";
str += "\n\n";
bool nccTrigger = errNormalizedCrossCorrelation < 0.45f;
bool rMeanSqrTrigger = errRootMeanSquared > 0.18f;
bool rmsNccTrigger = errRootMeanSquared > 0.18f && errNormalizedCrossCorrelation < 0.6f;
bool nccRmsTrigger = errNormalizedCrossCorrelation < 0.45f && errRootMeanSquared > 0.11f;
if (rmsNccTrigger) str += "\n\nRMS -> NCC DOUBLE SCENE CHANGE TRIGGER!";
if (nccRmsTrigger) str += "\n\nNCC -> RMS DOUBLE SCENE CHANGE TRIGGER!";
currFrame.Scale(originalSize.Width / 2, originalSize.Height / 2);
new Drawables()
.FontPointSize(12)
.Font("Consolas", FontStyleType.Normal, FontWeight.Bold, FontStretch.Normal)
.FillColor(MagickColors.Red)
.TextAlignment(TextAlignment.Left)
.Text(1, 10, str)
.Draw(currFrame);
currFrame.Write(Path.Combine(outFolder, frame.Name));
prevFrame.Dispose();
currFrame.Dispose();
await Task.Delay(1);
}
}
}

View File

@@ -10,8 +10,8 @@
<package id="HTAlt.WinForms" version="0.1.6" targetFramework="net472" />
<package id="ILRepack" version="2.0.34" targetFramework="net472" developmentDependency="true" />
<package id="ILRepack.MSBuild.Task" version="2.0.13" targetFramework="net472" />
<package id="Magick.NET.Core" version="13.10.0" targetFramework="net472" />
<package id="Magick.NET-Q8-x64" version="13.10.0" targetFramework="net472" />
<package id="Magick.NET.Core" version="14.10.0" targetFramework="net472" />
<package id="Magick.NET-Q8-x64" version="14.10.0" targetFramework="net472" />
<package id="Microsoft.Build.Framework" version="15.9.20" targetFramework="net472" />
<package id="Microsoft.Build.Utilities.Core" version="15.9.20" targetFramework="net472" />
<package id="Microsoft.NETCore.Platforms" version="8.0.0-preview.7.23375.6" targetFramework="net472" />
@@ -21,7 +21,7 @@
<package id="Microsoft-WindowsAPICodePack-Shell" version="1.1.5" targetFramework="net472" />
<package id="NDesk.Options" version="0.2.1" targetFramework="net472" />
<package id="NETStandard.Library" version="2.0.3" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.4" targetFramework="net472" />
<package id="NvAPIWrapper.Net" version="0.8.1.101" targetFramework="net472" />
<package id="PagedControl" version="2.2.0" targetFramework="net472" />
<package id="System.AppContext" version="4.3.0" targetFramework="net472" />