ファイル
YMM4-ProxyForge/ProxyForge/Plugin/ProxyForgeVideoSourceWithScale.cs
T
routersys 5ef1222518 ZeroDiskProxyからProxyForgeへのプロジェクト全体のリブランディング
プロジェクト名をZeroDiskProxyからProxyForgeへ全面的にリブランディングしました。
2026-03-25 19:58:39 +09:00

42 行
1.3 KiB
C#

using System.Numerics;
using Vortice.Direct2D1;
using Vortice.Direct2D1.Effects;
using YukkuriMovieMaker.Commons;
using YukkuriMovieMaker.Plugin.FileSource;
namespace ProxyForge.Plugin;
internal sealed class ProxyForgeVideoSourceWithScale : IVideoFileSource
{
private readonly IVideoFileSource _inner;
private readonly AffineTransform2D _scaleEffect;
private readonly ID2D1Image _output;
private int _disposed;
public TimeSpan Duration => _inner.Duration;
public ID2D1Image Output => _output;
internal ProxyForgeVideoSourceWithScale(IVideoFileSource inner, IGraphicsDevicesAndContext devices, float proxyScale)
{
_inner = inner;
_scaleEffect = new AffineTransform2D(devices.DeviceContext);
_scaleEffect.SetInput(0, inner.Output, true);
_scaleEffect.TransformMatrix = Matrix3x2.CreateScale(1f / proxyScale);
_output = _scaleEffect.Output;
}
public void Update(TimeSpan time) => _inner.Update(time);
public int GetFrameIndex(TimeSpan time) => _inner.GetFrameIndex(time);
public void Dispose()
{
if (Interlocked.Exchange(ref _disposed, 1) != 0)
return;
_output.Dispose();
_scaleEffect.SetInput(0, null, true);
_scaleEffect.Dispose();
_inner.Dispose();
GC.SuppressFinalize(this);
}
}