コミットを比較

..
6 コミット
作成者 SHA1 メッセージ 日付
routersys 876f05d277 バージョンをv1.3.2へ更新
リリース / build-and-release (workflow_dispatch) Actions がタグ v1.3.2 のコミットから作成しました
2026-06-27 17:31:39 +09:00
routersys 227af2c75c READMEにLuaJIT等のサードパーティ表記を追記 2026-06-27 17:26:53 +09:00
routersys 5cbd5ae8ff 同梱ライブラリのライセンスを追加しリリースに同梱 2026-06-27 17:26:50 +09:00
routersys bb97610454 luajitの残留プロセスをジョブで道連れ終了 2026-06-27 17:26:37 +09:00
routersys 968180c459 バージョンをv1.3.1へ更新
リリース / build-and-release (workflow_dispatch) Actions がタグ v1.3.1 のコミットから作成しました
2026-06-27 13:10:59 +09:00
routersys d9ad3692f2 プラグイン情報を追加 2026-06-27 13:06:29 +09:00
11個のファイルの変更、303行の追加、57行の削除

検索条件に一致するファイルはありません

+29 -54
ファイルの表示
@@ -1,73 +1,48 @@
# v1.3.0 - Lua スクリプト for YMM4
# v1.3.2 - Lua スクリプト for YMM4
ピクセル操作スクリプトを**大幅に高速化**したリリースです。
`obj.getpixel` / `obj.setpixel` / `obj.getpixeldata` を使うスクリプトは、同梱した高速
ランタイム(LuaJIT)で自動的に実行されるようになり、内部計測では**最大で数十倍**
(例:1920×1080 のフルフレーム加工で約 41 倍、小さめの画像では 70 倍前後)の
高速化を確認しています。
ピクセル操作スクリプトの実行に使う**高速ランタイム(LuaJIT)のプロセスが残留する
不具合を解消**したリリースです。YMM4 本体が異常終了・強制終了した場合でも、
ネイティブ実行用の `luajit.exe` が取り残されることはなくなりました。
あわせて、同梱ライブラリのライセンス表記を整備しました。
---
## 新機能・改善
## 修正・改善
### 1. ピクセル操作スクリプトの自動高速化
### 1. ネイティブ実行プロセスの残留を解消
ピクセル操作 API(`obj.getpixel` / `obj.setpixel` / `obj.getpixeldata`)を含むスクリプトは、
**特別な記述なしで自動的に高速ランタイム(ネイティブ実行)へ振り分け**られます。
変形のみ(座標・回転・拡縮・不透明度)のスクリプトは従来どおりの実行系で動作します
(変形のみの処理は元々十分高速なため、速度差はありません)。
これまで、ピクセル操作スクリプトを一度でも実行した後に YMM4 本体がクラッシュや
強制終了で落ちると、ネイティブ実行用の `luajit.exe` がプロセスとして残り続ける
ことがありました。本リリースでは、子プロセスを **Windows のジョブオブジェクト**へ
割り当て、本体プロセスの終了と同時に `luajit.exe` も終了するようにしました。
ネイティブ実行は**専用の別プロセス**で行われ、ピクセルバッファは共有メモリ経由で
受け渡されます。スクリプトが無限ループに陥っても、**5 秒のタイムアウトで強制終了**
され、本体が固まることはありません(終了後は自動的に復帰します)。
本体が正常終了したかクラッシュしたかにかかわらず、OS がジョブを閉じた時点で
ネイティブワーカーは確実に終了します。タスクマネージャーに `luajit.exe` が
取り残されることはありません。スクリプトの実行結果や速度に変化はありません。
### 2. 実行エンジンを指定するディレクティブ
### 2. 同梱ライブラリのライセンスを整備
スクリプトの先頭行に次のディレクティブを書くことで、実行エンジンを明示指定できます。
- `--!native` … 高速ランタイム(LuaJIT)で実行
- `--!moonsharp` … 従来エンジン(MoonSharp)で実行
- 記述なし … ピクセル操作を含む場合は自動的にネイティブ、それ以外は従来エンジン
### 3. bit32 の Lua 5.2 準拠化(ネイティブ実行時)
ネイティブ実行時の `bit32` ライブラリは、正しい Lua 5.2 の挙動になりました。
実用域(0〜2^31 未満の値、0〜31 のシフト量)では従来と完全に一致するため、
通常のスクリプトの見た目は変わりません。`bit32.lshift(1, 32)` のような範囲外の
特殊なケースのみ結果が変わります(ネイティブ=正しい 0、従来=1)。
### 4. 変形処理のアロケーション削減
毎フレームの実行で発生していた一時オブジェクトの確保を削減し、シーンオブジェクトの
解決を遅延化しました。長時間の出力における GC 負荷を軽減します。
---
## 注意事項(ネイティブ実行時の制約)
- **`obj.getobject` はネイティブ実行では使用できません**(常に `nil` を返します)。
他オブジェクトの参照を行うスクリプトには `--!native` を付けないでください
(ピクセル操作と併用する場合は `--!moonsharp` を明示してください)。
- `math.random` は両エンジンとも「フレーム番号でシードし直す決定論的乱数」ですが、
乱数列の実装が異なるため、エンジンをまたぐと同じシードでも値が変わります。
エンジンに依存しない乱数が必要な場合は `anim.rand(min, max, seed)` を使用してください。
- ネイティブ実行は最初のピクセルアクセス前から GPU→CPU の画像転送を行います。
プラグインが同梱する **LuaJIT** と **MoonSharp** のライセンス全文を収録しました。
配布パッケージのルートに `LICENSE` フォルダーを設け、各ライセンスファイルを
配置しています。LuaJIT のライセンスには、LuaJIT 本体が内包する Lua 5.1/5.2 と
dlmalloc の権利表記も含まれます。
---
## 内部実装
- 同梱した LuaJIT を別プロセスで常駐させ、名前付き共有メモリとイベントで往復します。
タイムアウト時はプロセスを強制終了し、自動的に再起動します。
- ネイティブ側に `bit32`(正しい 5.2)・`rawlen`・`anim.*`(`rand` / `noise` を含む)・
`obj.getpixel` / `setpixel` / `getpixeldata` を実装し、従来エンジンとの**出力一致を
自動テストで検証**しています(2800 件超のクロスエンジン等価テストを追加)。
- ユーザースクリプトはサンドボックス環境で実行され、`io` / `os` / `ffi` / `require`
などは従来どおり利用できません。
- 子プロセス起動時に、`JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE` を設定したプロセス
単位のジョブオブジェクトへ `luajit.exe` を割り当てます。本体プロセスの終了で
ジョブハンドルが閉じられると、ジョブ内の全プロセスがカーネルによって終了します。
- 従来の正常終了時のシャットダウン処理はそのまま残しており、ジョブオブジェクトは
異常終了時の安全網として機能します。
- 収録した各ライセンスファイルは、配布元の原本から逐語的に取得しています。
---
## 同梱物
- 本プラグインには高速ランタイム(`luajit.exe` / `lua51.dll`)と実行スクリプトを同梱して
おり、プラグイン本体と同じ `native` フォルダーに配置されます(手動インストールは不要)。
- `LICENSE` フォルダーに `LuaJIT.txt` / `Lua.txt` / `MoonSharp.txt` を同梱し、
リリースワークフローで配布パッケージへ自動的に含めます。
- 高速ランタイム(`luajit.exe` / `lua51.dll`)と実行スクリプトは従来どおり、
プラグイン本体と同じ `native` フォルダーに配置されます。
+32
ファイルの表示
@@ -0,0 +1,32 @@
Lua License
-----------
Lua is licensed under the terms of the MIT license reproduced below. This means
that Lua is free software and can be used for both academic and commercial
purposes at absolutely no cost.
For details and rationale, see https://www.lua.org/license.html .
===============================================================================
Copyright (C) 1994-2025 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================================================
+56
ファイルの表示
@@ -0,0 +1,56 @@
===============================================================================
LuaJIT -- a Just-In-Time Compiler for Lua. https://luajit.org/
Copyright (C) 2005-2026 Mike Pall. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
[ MIT license: https://www.opensource.org/licenses/mit-license.php ]
===============================================================================
[ LuaJIT includes code from Lua 5.1/5.2, which has this license statement: ]
Copyright (C) 1994-2012 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================================================
[ LuaJIT includes code from dlmalloc, which has this license statement: ]
This is a version (aka dlmalloc) of malloc/free/realloc written by
Doug Lea and released to the public domain, as explained at
https://creativecommons.org/licenses/publicdomain
===============================================================================
+38
ファイルの表示
@@ -0,0 +1,38 @@
Copyright (c) 2014-2016, Marco Mastropaolo
All rights reserved.
Parts of the string library are based on the KopiLua project (https://github.com/NLua/KopiLua)
Copyright (c) 2012 LoDC
Visual Studio Code debugger code is based on code from Microsoft vscode-mono-debug project (https://github.com/Microsoft/vscode-mono-debug).
Copyright (c) Microsoft Corporation - released under MIT license.
Remote Debugger icons are from the Eclipse project (https://www.eclipse.org/).
Copyright of The Eclipse Foundation
The MoonSharp icon is (c) Isaac, 2014-2015
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+1 -1
ファイルの表示
@@ -1,5 +1,5 @@
========================================
Luaスクリプト for YMM4 v1.2.0
Luaスクリプト for YMM4 v1.3.2
========================================
YukkuriMovieMaker4(YMM4)上で動作する、Luaスクリプトで映像エフェクトのパラメータや
ピクセルを直接制御できるプラグインです。
+2
ファイルの表示
@@ -70,6 +70,7 @@ jobs:
New-Item -ItemType Directory -Path "$stageRoot/docs" -Force | Out-Null
New-Item -ItemType Directory -Path "$stageRoot/native" -Force | Out-Null
New-Item -ItemType Directory -Path "$stageRoot/LICENSE" -Force | Out-Null
Copy-Item "$outDir/LuaScript.dll" "$stageRoot/"
Copy-Item "$outDir/MoonSharp.Interpreter.dll" "$stageRoot/"
@@ -87,6 +88,7 @@ jobs:
}
Copy-Item "LuaScript/docs/LuaScript.*.txt" "$stageRoot/docs/"
Copy-Item ".github/LICENSE/*.txt" "$stageRoot/LICENSE/"
Copy-Item ".github/Plugin_Readme.txt" "$stageRoot/Readme.txt"
Compress-Archive -Path "stage/*" -DestinationPath $pkgName -CompressionLevel Optimal
+2
ファイルの表示
@@ -139,6 +139,8 @@ namespace LuaScript.Engine
psi.ArgumentList.Add(_shimScript);
_process = Process.Start(psi);
if (_process is not null)
ProcessJobObject.Assign(_process.Handle);
_alive = _process is not null;
}
+103
ファイルの表示
@@ -0,0 +1,103 @@
using System;
using System.Runtime.InteropServices;
namespace LuaScript.Engine
{
internal static class ProcessJobObject
{
private const uint JobObjectExtendedLimitInformation = 9;
private const uint JobObjectLimitKillOnJobClose = 0x2000;
private static readonly nint Handle = Create();
public static void Assign(nint processHandle)
{
if (Handle != nint.Zero && processHandle != nint.Zero)
AssignProcessToJobObject(Handle, processHandle);
}
private static nint Create()
{
nint job = CreateJobObject(nint.Zero, null);
if (job == nint.Zero)
return nint.Zero;
var information = new JobObjectExtendedLimitInformationData
{
BasicLimitInformation = new JobObjectBasicLimitInformationData
{
LimitFlags = JobObjectLimitKillOnJobClose
}
};
int length = Marshal.SizeOf<JobObjectExtendedLimitInformationData>();
nint buffer = Marshal.AllocHGlobal(length);
try
{
Marshal.StructureToPtr(information, buffer, false);
if (!SetInformationJobObject(job, JobObjectExtendedLimitInformation, buffer, (uint)length))
{
CloseHandle(job);
return nint.Zero;
}
}
finally
{
Marshal.FreeHGlobal(buffer);
}
return job;
}
[StructLayout(LayoutKind.Sequential)]
private struct JobObjectBasicLimitInformationData
{
public long PerProcessUserTimeLimit;
public long PerJobUserTimeLimit;
public uint LimitFlags;
public nuint MinimumWorkingSetSize;
public nuint MaximumWorkingSetSize;
public uint ActiveProcessLimit;
public nuint Affinity;
public uint PriorityClass;
public uint SchedulingClass;
}
[StructLayout(LayoutKind.Sequential)]
private struct IoCountersData
{
public ulong ReadOperationCount;
public ulong WriteOperationCount;
public ulong OtherOperationCount;
public ulong ReadTransferCount;
public ulong WriteTransferCount;
public ulong OtherTransferCount;
}
[StructLayout(LayoutKind.Sequential)]
private struct JobObjectExtendedLimitInformationData
{
public JobObjectBasicLimitInformationData BasicLimitInformation;
public IoCountersData IoInfo;
public nuint ProcessMemoryLimit;
public nuint JobMemoryLimit;
public nuint PeakProcessMemoryUsed;
public nuint PeakJobMemoryUsed;
}
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern nint CreateJobObject(nint lpJobAttributes, string? lpName);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetInformationJobObject(nint hJob, uint jobObjectInformationClass, nint lpJobObjectInformation, uint cbJobObjectInformationLength);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool AssignProcessToJobObject(nint hJob, nint hProcess);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool CloseHandle(nint hObject);
}
}
+1 -1
ファイルの表示
@@ -4,7 +4,7 @@
<TargetFramework>net10.0-windows10.0.19041.0</TargetFramework>
<UseWPF>true</UseWPF>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.3.0</Version>
<Version>1.3.2</Version>
<Platforms>AnyCPU;x64</Platforms>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+3
ファイルの表示
@@ -4,10 +4,13 @@ using YukkuriMovieMaker.Commons;
using YukkuriMovieMaker.Controls;
using YukkuriMovieMaker.Exo;
using YukkuriMovieMaker.Player.Video;
using YukkuriMovieMaker.Plugin;
using YukkuriMovieMaker.Plugin.Effects;
namespace LuaScript
{
[PluginDetails(AuthorName = "routersys", ContentId = "nc487743")]
[VideoEffect(nameof(Texts.LuaScript), [VideoEffectCategories.Filtering], ["lua", "script", "スクリプト", "lua script", "アニメーション効果", "animation"], IsAviUtlSupported = false, ResourceType = typeof(Texts))]
internal class LuaScriptEffect : VideoEffectBase, IScriptProvider
{
+36 -1
ファイルの表示
@@ -344,7 +344,14 @@ obj.alpha = anim.ease_out(t) * 255
## サードパーティライセンス
本プラグインは、Luaスクリプトの実行エンジンとして [MoonSharp](https://github.com/moonsharp-devs/moonsharp)(3-Clause BSD License)を使用しています。
本プラグインは以下のサードパーティソフトウェアを同梱・使用しています。各ライセンスの全文は、配布パッケージ(`.ymme`)内の `LICENSE` フォルダーおよびリポジトリの [`.github/LICENSE`](.github/LICENSE) に収録しています。
| ソフトウェア | 用途 | ライセンス |
|---|---|---|
| [MoonSharp](https://github.com/moonsharp-devs/moonsharp) | 標準のLua実行エンジン(Lua 5.2 互換) | 3-Clause BSD License |
| [LuaJIT](https://github.com/LuaJIT/LuaJIT) | ピクセル操作向け高速ランタイム(`native/luajit.exe`・`lua51.dll`) | MIT License |
### MoonSharp(3-Clause BSD License)
```
Copyright (c) 2014-2016, Marco Mastropaolo
@@ -377,6 +384,34 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```
### LuaJIT(MIT License)
同梱の高速ランタイム(`native/luajit.exe`・`native/lua51.dll`)は LuaJIT v2.1 です。LuaJIT 本体は MIT License で配布されており、その中に Lua 5.1/5.2(Copyright © 1994-2012 Lua.org, PUC-Rio、MIT License)および dlmalloc(パブリックドメイン)のコードを含みます。以下は LuaJIT 本体の著作権表示です(Lua・dlmalloc を含む全文は `LICENSE/LuaJIT.txt` を参照)。
```
LuaJIT -- a Just-In-Time Compiler for Lua. https://luajit.org/
Copyright (C) 2005-2026 Mike Pall. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```
---
## ライセンス