Skip to content

Commit

Permalink
Merge branch 'typo-polor'
Browse files Browse the repository at this point in the history
  • Loading branch information
ePi5131 committed Jul 6, 2023
2 parents 1e4c301 + 17081c0 commit 6531402
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 135 deletions.
47 changes: 24 additions & 23 deletions patch.aul.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,32 +230,32 @@ https://scrapbox.io/ePi5131/patch.aul
"warning_duplicate" : boolean, ; ファイル名が同じプラグインファイルが複数フォルダに存在するときに警告を出す (既定値: true)
"shared_cache" : boolean, ; 一部キャッシュは共有メモリ(システムの設定のキャッシュサイズの部分)を使用するように変更 (既定値: true)
"undo" : boolean, ; 元に戻す 関連のバグ修正 (既定値: true)
"undo.redo" : boolean, ; やり直す を追加 (既定値: true)
"undo.redo" : boolean, ; やり直す を追加 (既定値: true)
"console" : boolean, ; コンソール (既定値: true)
"console.escape" : boolean, ; エスケープシーケンス (既定値: true)
"console.input" : boolean, ; 標準入力を受け取るか (既定値: false)
"console.debug_string" : boolean, ; 拡張編集のOutputDebugStringの内容を表示する (既定値: true)
"console.debug_string.time" : boolean, ; 拡張編集のOutputDebugStringの内容の先頭に時刻を表示する (既定値: true)
"console.escape" : boolean, ; エスケープシーケンス (既定値: true)
"console.input" : boolean, ; 標準入力を受け取るか (既定値: false)
"console.debug_string" : boolean, ; 拡張編集のOutputDebugStringの内容を表示する (既定値: true)
"console.debug_string.time" : boolean, ; 拡張編集のOutputDebugStringの内容の先頭に時刻を表示する (既定値: true)
"lua" : boolean, ; lua.*配下のスイッチの主電源 (既定値: true)
"lua.env" : boolean, ; Luaの環境を統一する (既定値: false)
"lua.path" : boolean, ; package.path,cpathにパスを追加 (既定値: false)
"lua.getvalue" : boolean, ; getvalueで中心座標を取得できるように (既定値: true)
"lua.rand" : boolean, ; rand関数で例外になるパターンを潰す (既定値: true)
"lua.randex" : boolean, ; 正確な乱数を提供するrandexクラスの追加 (既定値: true)
"lua.env" : boolean, ; Luaの環境を統一する (既定値: false)
"lua.path" : boolean, ; package.path,cpathにパスを追加 (既定値: false)
"lua.getvalue" : boolean, ; getvalueで中心座標を取得できるように (既定値: true)
"lua.rand" : boolean, ; rand関数で例外になるパターンを潰す (既定値: true)
"lua.randex" : boolean, ; 正確な乱数を提供するrandexクラスの追加 (既定値: true)
"fast" : boolean, ; fast.*配下のスイッチの主電源 (既定値: true)
"fast.exeditwindow" : boolean, ; 拡張編集ウィンドウの描画の最適化 (既定値: true)
"fast.settingdialog" : boolean, ; 設定ダイアログの描画の最適化 (既定値: true)
"fast.text" : boolean, ; テキストの軽量化 (既定値: true)
"fast.create_figure" : boolean, ; 図形の高速化 (既定値: true)
"fast.border" : boolean, ; 縁取りの高速化/バグ修正 (既定値: true)
"fast.glow" : boolean, ; グローの高速化 (既定値: true)
"fast.cl" : boolean, ; fast.*でOpenCLが必要なオプションに必要なオプション (既定値: true)
"fast.radiationalblur" : boolean, ; fast.clが前提 放射ブラーの高速化 (既定値: true)
"fast.polortransform" : boolean, ; fast.clが前提 極座標変換の高速化 (既定値: true)
"fast.displacementmap" : boolean, ; fast.clが前提 ディスプレイスメントマップの高速化 (既定値: true)
"fast.flash" : true : boolean, ; fast.clが前提 閃光の高速化 (既定値: true)
"fast.directionalblur" : boolean, ; fast.clが前提 方向ブラーの高速化 (既定値: true)
"fast.lensblur" : boolean ; fast.clが前提 レンズブラーの高速化 (既定値: true)
"fast.exeditwindow" : boolean, ; 拡張編集ウィンドウの描画の最適化 (既定値: true)
"fast.settingdialog" : boolean, ; 設定ダイアログの描画の最適化 (既定値: true)
"fast.text" : boolean, ; テキストの軽量化 (既定値: true)
"fast.create_figure" : boolean, ; 図形の高速化 (既定値: true)
"fast.border" : boolean, ; 縁取りの高速化/バグ修正 (既定値: true)
"fast.glow" : boolean, ; グローの高速化 (既定値: true)
"fast.cl" : boolean, ; fast.*でOpenCLが必要なオプションに必要なオプション (既定値: true)
"fast.radiationalblur" : boolean, ; fast.clが前提 放射ブラーの高速化 (既定値: true)
"fast.polortransform" : boolean, ; fast.clが前提 極座標変換の高速化 (既定値: true)
"fast.displacementmap" : boolean, ; fast.clが前提 ディスプレイスメントマップの高速化 (既定値: true)
"fast.flash" : true : boolean, ; fast.clが前提 閃光の高速化 (既定値: true)
"fast.directionalblur" : boolean, ; fast.clが前提 方向ブラーの高速化 (既定値: true)
"fast.lensblur" : boolean ; fast.clが前提 レンズブラーの高速化 (既定値: true)
}

Lua追加要素詳細
Expand Down Expand Up @@ -482,3 +482,4 @@ Lua追加要素詳細
ドロップ処理で最終的に何も行われなかったときにメッセージを出力する
ファイル名が同じプラグインファイルが複数フォルダに存在するときに警告を出す
一部キャッシュは共有メモリ(システムの設定のキャッシュサイズの部分)を使用するように変更
極座標変換の高速化設定のキーのtypoを修正
2 changes: 1 addition & 1 deletion patch/clprogram.cl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

kernel void PolorTransform(global short* dst, global short* src, int obj_w, int obj_h, int obj_line,
kernel void PolarTransform(global short* dst, global short* src, int obj_w, int obj_h, int obj_line,
int center_length, int radius, float angle, float uzu, float uzu_a){
int x = get_global_id(0);
int y = get_global_id(1);
Expand Down
12 changes: 6 additions & 6 deletions patch/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ class Config2 {
patch::failed_sjis_msgbox.switch_load(cr);
#endif
#ifdef PATCH_SWITCH_FAILED_LONGER_PATH
patch::failed_longer_path.switch_load(cr);
patch::failed_longer_path.switch_load(cr);
#endif
#ifdef PATCH_SWITCH_FAILED_FILE_DROP
patch::failed_file_drop.switch_load(cr);
patch::failed_file_drop.switch_load(cr);
#endif
#ifdef PATCH_SWITCH_THEME_CC
patch::theme_cc.switch_load(cr);
Expand Down Expand Up @@ -253,8 +253,8 @@ class Config2 {
#ifdef PATCH_SWITCH_FAST_RADIATIONALBLUR
patch::fast::RadiationalBlur.switch_load(cr);
#endif
#ifdef PATCH_SWITCH_FAST_POLORTRANSFORM
patch::fast::PolorTransform.switch_load(cr);
#ifdef PATCH_SWITCH_FAST_POLARTRANSFORM
patch::fast::PolarTransform.switch_load(cr);
#endif
#ifdef PATCH_SWITCH_FAST_DISPLACEMENTMAP
patch::fast::DisplacementMap.switch_load(cr);
Expand Down Expand Up @@ -618,8 +618,8 @@ class Config2 {
#ifdef PATCH_SWITCH_FAST_RADIATIONALBLUR
patch::fast::RadiationalBlur.switch_store(switch_);
#endif
#ifdef PATCH_SWITCH_FAST_POLORTRANSFORM
patch::fast::PolorTransform.switch_store(switch_);
#ifdef PATCH_SWITCH_FAST_POLARTRANSFORM
patch::fast::PolarTransform.switch_store(switch_);
#endif
#ifdef PATCH_SWITCH_FAST_DISPLACEMENTMAP
patch::fast::DisplacementMap.switch_store(switch_);
Expand Down
4 changes: 2 additions & 2 deletions patch/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ void init_t::InitAtExeditLoad() {
#ifdef PATCH_SWITCH_CL
if (patch::fast::cl.init()) {
if (patch::fast::cl.is_enabled_i()) {
#ifdef PATCH_SWITCH_FAST_POLORTRANSFORM
patch::fast::PolorTransform.init();
#ifdef PATCH_SWITCH_FAST_POLARTRANSFORM
patch::fast::PolarTransform.init();
#endif
#ifdef PATCH_SWITCH_FAST_DISPLACEMENTMAP
patch::fast::DisplacementMap.init();
Expand Down
4 changes: 2 additions & 2 deletions patch/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

#define PATCH_SWITCH_CL cl
#ifdef PATCH_SWITCH_CL
#define PATCH_SWITCH_FAST_POLORTRANSFORM fast_polortransform
#define PATCH_SWITCH_FAST_POLARTRANSFORM fast_polartransform
#define PATCH_SWITCH_FAST_RADIATIONALBLUR fast_radiationalblur
#define PATCH_SWITCH_FAST_FLASH fast_flash

Expand Down Expand Up @@ -178,7 +178,7 @@

#define PATCH_SWITCH_CL cl
#ifdef PATCH_SWITCH_CL
#define PATCH_SWITCH_FAST_POLORTRANSFORM fast_polortransform
#define PATCH_SWITCH_FAST_POLARTRANSFORM fast_polartransform
#define PATCH_SWITCH_FAST_DISPLACEMENTMAP fast_displacementmap
#define PATCH_SWITCH_FAST_RADIATIONALBLUR fast_radiationalblur
#define PATCH_SWITCH_FAST_FLASH fast_flash
Expand Down
8 changes: 4 additions & 4 deletions patch/offset_address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ namespace OFS {
constexpr i32 efBorder_func_proc_ptr = 0x0515d0;
constexpr i32 efBorder_var_ptr = 0x1b1e30;
constexpr i32 efGlow_var_ptr = 0x1b2010;
constexpr i32 efPolorTransform_func_proc = 0x0748a0;
constexpr i32 efPolorTransform_func_proc_ptr = 0x0add30;
constexpr i32 efPolorTransform_mt_func_call = 0x074a62;
constexpr i32 efPolorTransform_var_ptr = 0x1e48c0;
constexpr i32 efPolarTransform_func_proc = 0x0748a0;
constexpr i32 efPolarTransform_func_proc_ptr = 0x0add30;
constexpr i32 efPolarTransform_mt_func_call = 0x074a62;
constexpr i32 efPolarTransform_var_ptr = 0x1e48c0;
constexpr i32 efDisplacementMap_mt_func_call = 0x01f154;
constexpr i32 efDisplacementMap_var_ptr = 0x11effc;
constexpr i32 efRadiationalBlur_func_proc = 0x00b310;
Expand Down
2 changes: 1 addition & 1 deletion patch/patch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "patch_setting_dialog_wndproc_override.hpp"
#include "patch_undo.hpp"
#include "patch_fast_getputpixeldata.hpp"
#include "patch_fast_polortransform.hpp"
#include "patch_fast_polartransform.hpp"
#include "patch_fast_displacementmap.hpp"
#include "patch_fast_radiationalblur.hpp"
#include "patch_fast_flash.hpp"
Expand Down
6 changes: 3 additions & 3 deletions patch/patch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<ClInclude Include="patch_fast_getputpixeldata.hpp" />
<ClInclude Include="patch_fast_glow.hpp" />
<ClInclude Include="patch_fast_lensblur.hpp" />
<ClInclude Include="patch_fast_polortransform.hpp" />
<ClInclude Include="patch_fast_polartransform.hpp" />
<ClInclude Include="patch_fast_radiationalblur.hpp" />
<ClInclude Include="patch_fast_setting_dialog.hpp" />
<ClInclude Include="patch_fast_text.hpp" />
Expand Down Expand Up @@ -146,7 +146,7 @@
<ClCompile Include="patch_fast_getputpixeldata.cpp" />
<ClCompile Include="patch_fast_glow.cpp" />
<ClCompile Include="patch_fast_lensblur.cpp" />
<ClCompile Include="patch_fast_polortransform.cpp" />
<ClCompile Include="patch_fast_polartransform.cpp" />
<ClCompile Include="patch_fast_radiationalblur.cpp" />
<ClCompile Include="patch_fast_setting_dialog.cpp" />
<ClCompile Include="patch_fast_text.cpp" />
Expand Down Expand Up @@ -346,4 +346,4 @@ copy /Y "$(SolutionDir)COPYING.LESSER" "$(SolutionDir)pack\COPYING.LESSER"</Comm
<Error Condition="!Exists('..\packages\boost.1.79.0\build\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost.1.79.0\build\boost.targets'))" />
<Error Condition="!Exists('..\packages\boost_system-vc143.1.79.0\build\boost_system-vc143.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost_system-vc143.1.79.0\build\boost_system-vc143.targets'))" />
</Target>
</Project>
</Project>
6 changes: 3 additions & 3 deletions patch/patch.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
<ClInclude Include="patch_fast_getputpixeldata.hpp">
<Filter>feature\fast</Filter>
</ClInclude>
<ClInclude Include="patch_fast_polortransform.hpp">
<ClInclude Include="patch_fast_polartransform.hpp">
<Filter>feature\fast</Filter>
</ClInclude>
<ClInclude Include="patch_fast_radiationalblur.hpp">
Expand Down Expand Up @@ -325,7 +325,7 @@
<ClCompile Include="patch_fast_getputpixeldata.cpp">
<Filter>feature\fast</Filter>
</ClCompile>
<ClCompile Include="patch_fast_polortransform.cpp">
<ClCompile Include="patch_fast_polartransform.cpp">
<Filter>feature\fast</Filter>
</ClCompile>
<ClCompile Include="patch_fast_radiationalblur.cpp">
Expand Down Expand Up @@ -420,4 +420,4 @@
<None Include=".editorconfig" />
<None Include="packages.config" />
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion patch/patch_fast_cl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace patch::fast {
inline class cl_t {
#pragma region clprogram
inline static auto program_str = make_cryptostring(R"(
kernel void PolorTransform(global short* dst, global short* src, int obj_w, int obj_h, int obj_line,
kernel void PolarTransform(global short* dst, global short* src, int obj_w, int obj_h, int obj_line,
int center_length, int radius, float angle, float uzu, float uzu_a){
int x = get_global_id(0);
int y = get_global_id(1);
Expand Down
73 changes: 73 additions & 0 deletions patch/patch_fast_polartransform.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once
#include "patch_fast_polartransform.hpp"
#ifdef PATCH_SWITCH_FAST_POLARTRANSFORM

#include <numbers>

#include "global.hpp"
#include "offset_address.hpp"
#include "util_int.hpp"
#include "patch_fast_cl.hpp"
#include "debug_log.hpp"

//#define PATCH_STOPWATCH
#include "stopwatch.hpp"
static stopwatch_mem sw;

namespace patch::fast {
BOOL PolarTransform_t::mt_func(AviUtl::MultiThreadFunc original_func_ptr, ExEdit::Filter* efp, ExEdit::FilterProcInfo* efpip) {
if (256 < efpip->obj_w * efpip->obj_h) {
sw.start();
try {
efPolarTransform_var& polar = *reinterpret_cast<efPolarTransform_var*>(GLOBAL::exedit_base + OFS::ExEdit::efPolarTransform_var_ptr);

const auto src_size = efpip->obj_line * polar.src_h * sizeof(ExEdit::PixelYCA);
cl::Buffer clmem_src(cl.context, CL_MEM_READ_ONLY, src_size);
cl.queue.enqueueWriteBuffer(clmem_src, CL_TRUE, 0, src_size, efpip->obj_edit);

const auto dst_size = efpip->obj_line * polar.output_size * 8;
cl::Buffer clmem_dst(cl.context, CL_MEM_WRITE_ONLY, dst_size);

auto kernel = cl.readyKernel(
"PolarTransform",
clmem_dst,
clmem_src,
polar.src_w,
polar.src_h,
efpip->obj_line,
polar.center_length,
polar.radius,
static_cast<float>(polar.angle),
static_cast<float>(polar.uzu),
static_cast<float>(polar.uzu_a)
);
cl.queue.enqueueNDRangeKernel(kernel, { 0,0 }, { (size_t)polar.output_size ,(size_t)polar.output_size });

cl.queue.enqueueReadBuffer(clmem_dst, CL_TRUE, 0, dst_size, efpip->obj_temp);
} catch (const cl::Error& err) {
debug_log("OpenCL Error\n({}) {}", err.err(), err.what());
return efp->aviutl_exfunc->exec_multi_thread_func(original_func_ptr, efp, efpip);
}
sw.stop();
return TRUE;
} else {
return efp->aviutl_exfunc->exec_multi_thread_func(original_func_ptr, efp, efpip);
}
}
}
#endif // ifdef PATCH_SWITCH_FAST_POLARTRANSFORM
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once
#include "macro.h"
#ifdef PATCH_SWITCH_FAST_POLORTRANSFORM
#ifdef PATCH_SWITCH_FAST_POLARTRANSFORM

#include <aviutl.hpp>
#include <exedit.hpp>
Expand All @@ -29,16 +29,16 @@
namespace patch::fast {
// init at exedit load
// 極座標変換の高速化
inline class PolorTransform_t {
inline class PolarTransform_t {
static BOOL mt_func(AviUtl::MultiThreadFunc original_func_ptr, ExEdit::Filter* efp, ExEdit::FilterProcInfo* efpip);

bool enabled = true;
bool enabled_i;
inline static const char key[] = "fast.polortransform";
inline static const char key[] = "fast.polartransform";

public:

struct efPolorTransform_var { // 1e48c0
struct efPolarTransform_var { // 1e48c0
int src_h;
int radius;
int src_w;
Expand All @@ -54,7 +54,7 @@ namespace patch::fast {
enabled_i = enabled;
if (!enabled_i)return;

OverWriteOnProtectHelper h(GLOBAL::exedit_base + OFS::ExEdit::efPolorTransform_mt_func_call, 6);
OverWriteOnProtectHelper h(GLOBAL::exedit_base + OFS::ExEdit::efPolarTransform_mt_func_call, 6);
h.store_i16(0, '\x90\xe8'); // nop; call (rel32)
h.replaceNearJmp(2, &mt_func);

Expand All @@ -75,6 +75,6 @@ namespace patch::fast {
cw.append(key, enabled);
}

} PolorTransform;
} PolarTransform;
} // namespace patch::fast
#endif // ifdef PATCH_SWITCH_FAST_POLORTRANSFORM
#endif // ifdef PATCH_SWITCH_FAST_POLARTRANSFORM
Loading

0 comments on commit 6531402

Please sign in to comment.