diff --git a/LuaScript/LuaScript.csproj b/LuaScript/LuaScript.csproj
index 83f2e82..7ed5b09 100644
--- a/LuaScript/LuaScript.csproj
+++ b/LuaScript/LuaScript.csproj
@@ -95,11 +95,13 @@
-
+
+
+
-
+
@@ -117,7 +119,7 @@
-
+
diff --git a/LuaScript/LuaScriptEffectProcessor.cs b/LuaScript/LuaScriptEffectProcessor.cs
index aa4d2a5..660994b 100644
--- a/LuaScript/LuaScriptEffectProcessor.cs
+++ b/LuaScript/LuaScriptEffectProcessor.cs
@@ -66,7 +66,7 @@ namespace LuaScript
private static string NativeDirectory =>
Path.Combine(Path.GetDirectoryName(typeof(LuaScriptEffectProcessor).Assembly.Location) ?? AppContext.BaseDirectory, "native");
- private readonly LuaScriptEngine _engine = new();
+ private readonly LuaScriptEngine _engine = new(static () => new MediaSourceLoader());
private readonly SemaphoreSlim _pixelLoaderSemaphore = new(1, 1);
private AviUtlScriptContext _context = new();
diff --git a/LuaScript/MediaSourceLoader.cs b/LuaScript/MediaSourceLoader.cs
new file mode 100644
index 0000000..733e820
--- /dev/null
+++ b/LuaScript/MediaSourceLoader.cs
@@ -0,0 +1,34 @@
+namespace LuaScript
+{
+ internal sealed class MediaSourceLoader : IMediaSourceLoader
+ {
+ private TextRenderer? _textRenderer;
+ private ImageDecoder? _imageDecoder;
+ private MovieDecoder? _movieDecoder;
+
+ public byte[] RenderText(string text, string fontFamily, double fontSize, bool bold, bool italic, int colorRgb, out int width, out int height)
+ {
+ _textRenderer ??= new TextRenderer();
+ return _textRenderer.Render(text, fontFamily, fontSize, bold, italic, colorRgb, out width, out height);
+ }
+
+ public byte[] DecodeImage(string path, out int width, out int height)
+ {
+ _imageDecoder ??= new ImageDecoder();
+ return _imageDecoder.Decode(path, out width, out height);
+ }
+
+ public byte[] DecodeMovie(string path, double time, out int width, out int height)
+ {
+ _movieDecoder ??= new MovieDecoder();
+ return _movieDecoder.Decode(path, time, out width, out height);
+ }
+
+ public void Dispose()
+ {
+ _textRenderer?.Dispose();
+ _imageDecoder?.Dispose();
+ _movieDecoder?.Dispose();
+ }
+ }
+}
diff --git a/LuaScript/SceneObjectResolver.cs b/LuaScript/SceneObjectResolver.cs
index a1b1f81..9ac23df 100644
--- a/LuaScript/SceneObjectResolver.cs
+++ b/LuaScript/SceneObjectResolver.cs
@@ -2,7 +2,7 @@ using YukkuriMovieMaker.Project.Items;
namespace LuaScript
{
- internal sealed class SceneObjectResolver
+ internal sealed class SceneObjectResolver : ISceneObjectResolver
{
internal readonly record struct Entry(string Tag, int Frame, int Length, int Layer, VisualItem Item);
@@ -15,7 +15,7 @@ namespace LuaScript
_fps = fps;
}
- internal bool TryResolve(string tag, int timelineFrame, out SceneObjectInfo info)
+ public bool TryResolve(string tag, int timelineFrame, out SceneObjectInfo info)
{
int fallback = -1;
for (int i = 0; i < _entries.Length; i++)