├── .github └── workflows │ └── build_releases.yml ├── .gitignore ├── .gitmodules ├── Build.md ├── NVVfxLinker ├── NVVfxLinker.vcxproj └── NVVfxLinker.vcxproj.filters ├── Readme.md ├── clRNG.vcxproj ├── clRNG.vcxproj.filters ├── clcufilters.sln ├── clcufilters ├── clcufilters.cpp ├── clcufilters.def ├── clcufilters.h ├── clcufilters.rc ├── clcufilters.vcxproj ├── clcufilters.vcxproj.filters ├── clcufilters_add_res.cpp ├── clcufilters_auf.cpp ├── clcufilters_auf.h ├── clcufilters_control.h └── filter.h ├── clcufilters_common ├── clcufilters_chain.cpp ├── clcufilters_chain.h ├── clcufilters_chain_prm.cpp ├── clcufilters_chain_prm.h ├── clcufilters_common.vcxproj ├── clcufilters_common.vcxproj.filters ├── clcufilters_exe.cpp ├── clcufilters_exe.h ├── clcufilters_exe_cmd.cpp ├── clcufilters_exe_cmd.h ├── clcufilters_shared.h └── clcufilters_version.h ├── clfilters └── clcufilters_auf.cpp ├── clfilters_common ├── clfilters_common.vcxproj ├── clfilters_common.vcxproj.filters ├── rgy_filter.cl ├── rgy_filter_cl.cpp ├── rgy_filter_cl.h ├── rgy_filter_colorspace.cpp ├── rgy_filter_colorspace.h ├── rgy_filter_colorspace_func.h ├── rgy_filter_convolution3d.cl ├── rgy_filter_convolution3d.cpp ├── rgy_filter_convolution3d.h ├── rgy_filter_crop.cpp ├── rgy_filter_deband.cl ├── rgy_filter_deband.cpp ├── rgy_filter_deband.h ├── rgy_filter_deband_gen_rand.cl ├── rgy_filter_denoise_dct.cl ├── rgy_filter_denoise_dct.cpp ├── rgy_filter_denoise_dct.h ├── rgy_filter_denoise_knn.cl ├── rgy_filter_denoise_knn.cpp ├── rgy_filter_denoise_knn.h ├── rgy_filter_denoise_nlmeans.cl ├── rgy_filter_denoise_nlmeans.cpp ├── rgy_filter_denoise_nlmeans.h ├── rgy_filter_denoise_pmd.cl ├── rgy_filter_denoise_pmd.cpp ├── rgy_filter_denoise_pmd.h ├── rgy_filter_edgelevel.cl ├── rgy_filter_edgelevel.cpp ├── rgy_filter_edgelevel.h ├── rgy_filter_libplacebo.cpp ├── rgy_filter_libplacebo.h ├── rgy_filter_nnedi.cpp ├── rgy_filter_nnedi.h ├── rgy_filter_nnedi_common.cl ├── rgy_filter_nnedi_k0.cl ├── rgy_filter_nnedi_k1.cl ├── rgy_filter_pad.cl ├── rgy_filter_pad.cpp ├── rgy_filter_resize.cl ├── rgy_filter_resize.cpp ├── rgy_filter_resize.h ├── rgy_filter_smooth.cl ├── rgy_filter_smooth.cpp ├── rgy_filter_smooth.h ├── rgy_filter_transform.cl ├── rgy_filter_transform.cpp ├── rgy_filter_transform.h ├── rgy_filter_tweak.cl ├── rgy_filter_tweak.cpp ├── rgy_filter_tweak.h ├── rgy_filter_unsharp.cl ├── rgy_filter_unsharp.cpp ├── rgy_filter_unsharp.h ├── rgy_filter_warpsharp.cl ├── rgy_filter_warpsharp.cpp ├── rgy_filter_warpsharp.h ├── rgy_opencl.cpp └── rgy_opencl.h ├── clfilters_exe ├── clfilters_chain.cpp ├── clfilters_chain.h ├── clfilters_exe.cpp ├── clfilters_exe.h ├── clfilters_exe.rc ├── clfilters_exe.vcxproj └── clfilters_exe.vcxproj.filters ├── cudaver.props ├── cufilters_common ├── NVEncFilter.cpp ├── NVEncFilter.h ├── NVEncFilterColorspace.cpp ├── NVEncFilterColorspace.h ├── NVEncFilterColorspaceFunc.h ├── NVEncFilterConvolution3d.cu ├── NVEncFilterConvolution3d.h ├── NVEncFilterCrop.cu ├── NVEncFilterCustom.cpp ├── NVEncFilterCustom.h ├── NVEncFilterD3D11.cpp ├── NVEncFilterD3D11.h ├── NVEncFilterDeband.cu ├── NVEncFilterDeband.h ├── NVEncFilterDenoiseDct.cu ├── NVEncFilterDenoiseDct.h ├── NVEncFilterDenoiseGauss.cpp ├── NVEncFilterDenoiseKnn.cu ├── NVEncFilterDenoiseKnn.h ├── NVEncFilterDenoiseNLMeans.cu ├── NVEncFilterDenoiseNLMeans.h ├── NVEncFilterDenoisePmd.cu ├── NVEncFilterDenoisePmd.h ├── NVEncFilterEdgelevel.cu ├── NVEncFilterEdgelevel.h ├── NVEncFilterLibplacebo.cpp ├── NVEncFilterLibplacebo.h ├── NVEncFilterNGX.cpp ├── NVEncFilterNGX.h ├── NVEncFilterNnedi.cu ├── NVEncFilterNnedi.h ├── NVEncFilterNvvfx.cpp ├── NVEncFilterNvvfx.h ├── NVEncFilterResize.cu ├── NVEncFilterSmooth.cu ├── NVEncFilterSmooth.h ├── NVEncFilterTweak.cu ├── NVEncFilterTweak.h ├── NVEncFilterUnsharp.cu ├── NVEncFilterUnsharp.h ├── NVEncFilterVulkan.cpp ├── NVEncFilterVulkan.h ├── NVEncFilterWarpsharp.cu ├── NVEncFilterWarpsharp.h ├── NVEncNVSDKNGX.h ├── NVEncUtil.cpp ├── NVEncUtil.h ├── cufilters_common.cpp ├── cufilters_common.vcxproj ├── cufilters_common.vcxproj.filters ├── rgy_cuda_util.h ├── rgy_cuda_util_kernel.h ├── rgy_nvrtc.cpp └── rgy_nvrtc.h ├── cufilters_exe ├── cufilters_chain.cpp ├── cufilters_chain.h ├── cufilters_exe.cpp ├── cufilters_exe.h ├── cufilters_exe.rc ├── cufilters_exe.vcxproj └── cufilters_exe.vcxproj.filters ├── data ├── clcufilters_image.webp ├── clcufilters_install.webp ├── clcufilters_params.png ├── clcufilters_select_device.png ├── clfilters_filter_order.png ├── gpuz_opencl_check.png └── powered-by-nvidia-broadcast-lockup-rgb-blk-for-screen.png ├── filter_core ├── NVEncFilterParam.cpp ├── NVEncFilterParam.h ├── convert_const.h ├── convert_csp.cpp ├── convert_csp.h ├── convert_csp_avx.cpp ├── convert_csp_avx2.cpp ├── convert_csp_func.cpp ├── convert_csp_func.h ├── convert_csp_simd.h ├── convert_csp_sse2.cpp ├── convert_csp_sse41.cpp ├── convert_csp_ssse3.cpp ├── cpu_info.cpp ├── cpu_info.h ├── filter_core.vcxproj ├── filter_core.vcxproj.filters ├── gpu_info.cpp ├── gpu_info.h ├── gpuz_info.cpp ├── gpuz_info.h ├── rgy_arch.h ├── rgy_avutil.h ├── rgy_bitstream.cpp ├── rgy_bitstream.h ├── rgy_bitstream_avx2.cpp ├── rgy_bitstream_avx512bw.cpp ├── rgy_caption.h ├── rgy_cmd.cpp ├── rgy_cmd.h ├── rgy_codepage.cpp ├── rgy_codepage.h ├── rgy_def.cpp ├── rgy_def.h ├── rgy_device.cpp ├── rgy_device.h ├── rgy_device_vulkan.cpp ├── rgy_device_vulkan.h ├── rgy_env.cpp ├── rgy_env.h ├── rgy_err.cpp ├── rgy_err.h ├── rgy_event.cpp ├── rgy_event.h ├── rgy_filesystem.cpp ├── rgy_filesystem.h ├── rgy_filter.cpp ├── rgy_filter.h ├── rgy_frame.cpp ├── rgy_frame.h ├── rgy_frame_info.cpp ├── rgy_frame_info.h ├── rgy_hdr10plus.cpp ├── rgy_hdr10plus.h ├── rgy_ini.cpp ├── rgy_ini.h ├── rgy_language.cpp ├── rgy_language.h ├── rgy_libdovi.cpp ├── rgy_libdovi.h ├── rgy_libplacebo.cpp ├── rgy_libplacebo.h ├── rgy_log.cpp ├── rgy_log.h ├── rgy_memmem.cpp ├── rgy_memmem.h ├── rgy_memmem_avx2.cpp ├── rgy_memmem_avx512bw.cpp ├── rgy_osdep.h ├── rgy_perf_counter.cpp ├── rgy_perf_counter.h ├── rgy_perf_monitor.cpp ├── rgy_perf_monitor.h ├── rgy_pipe.cpp ├── rgy_pipe.h ├── rgy_prm.cpp ├── rgy_prm.h ├── rgy_resource.cpp ├── rgy_resource.h ├── rgy_shared_mem.h ├── rgy_simd.cpp ├── rgy_simd.h ├── rgy_status.cpp ├── rgy_status.h ├── rgy_tchar.h ├── rgy_thread_affinity.cpp ├── rgy_thread_affinity.h ├── rgy_util.cpp ├── rgy_util.h ├── rgy_version.cpp └── rgy_version.h ├── jitify └── jitify.hpp ├── opencl_load_error.md └── resource └── nnedi3_weights.bin /.gitignore: -------------------------------------------------------------------------------- 1 | ffmpeg_lgpl/ 2 | 3 | ## Ignore Visual Studio temporary files, build results, and 4 | ## files generated by popular Visual Studio add-ons. 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.sln.docstates 10 | 11 | # Build results 12 | 13 | [Dd]ebug/ 14 | [Rr]elease/ 15 | RelStatic/ 16 | x64/ 17 | build/ 18 | [Bb]in/ 19 | [Oo]bj/ 20 | Win32/ 21 | 22 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 23 | !packages/*/build/ 24 | 25 | # MSTest test Results 26 | [Tt]est[Rr]esult*/ 27 | [Bb]uild[Ll]og.* 28 | 29 | *_i.c 30 | *_p.c 31 | *.ilk 32 | *.meta 33 | *.obj 34 | *.opendb 35 | *.pch 36 | *.pdb 37 | *.pgc 38 | *.pgd 39 | *.rsp 40 | *.sbr 41 | *.tlb 42 | *.tli 43 | *.tlh 44 | *.tmp 45 | *.tmp_proj 46 | *.log 47 | *.vspscc 48 | *.vssscc 49 | .builds 50 | .vscode 51 | *.pidb 52 | *.log 53 | *.scc 54 | *.VC.db 55 | *.tlog 56 | 57 | # Visual C++ cache files 58 | .vs/ 59 | ipch/ 60 | *.aps 61 | *.ncb 62 | *.opensdf 63 | *.sdf 64 | *.cachefile 65 | 66 | # Visual Studio profiler 67 | *.psess 68 | *.vsp 69 | *.vspx 70 | VTune*/ 71 | 72 | # Guidance Automation Toolkit 73 | *.gpState 74 | 75 | # ReSharper is a .NET coding add-in 76 | _ReSharper*/ 77 | *.[Rr]e[Ss]harper 78 | 79 | # TeamCity is a build add-in 80 | _TeamCity* 81 | 82 | # DotCover is a Code Coverage Tool 83 | *.dotCover 84 | 85 | # NCrunch 86 | *.ncrunch* 87 | .*crunch*.local.xml 88 | 89 | # Installshield output folder 90 | [Ee]xpress/ 91 | 92 | # DocProject is a documentation generator add-in 93 | DocProject/buildhelp/ 94 | DocProject/Help/*.HxT 95 | DocProject/Help/*.HxC 96 | DocProject/Help/*.hhc 97 | DocProject/Help/*.hhk 98 | DocProject/Help/*.hhp 99 | DocProject/Help/Html2 100 | DocProject/Help/html 101 | 102 | # Click-Once directory 103 | publish/ 104 | 105 | # Publish Web Output 106 | *.Publish.xml 107 | 108 | # NuGet Packages Directory 109 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 110 | #packages/ 111 | 112 | # Windows Azure Build Output 113 | csx 114 | *.build.csdef 115 | 116 | # Windows Store app package directory 117 | AppPackages/ 118 | 119 | # Others 120 | sql/ 121 | *.Cache 122 | ClientBin/ 123 | [Ss]tyle[Cc]op.* 124 | ~$* 125 | *~ 126 | *.dbmdl 127 | *.[Pp]ublish.xml 128 | *.pfx 129 | *.publishsettings 130 | 131 | # RIA/Silverlight projects 132 | Generated_Code/ 133 | 134 | # Backup & report files from converting an old project file to a newer 135 | # Visual Studio version. Backup files are not needed, because we have git ;-) 136 | _UpgradeReport_Files/ 137 | Backup*/ 138 | UpgradeLog*.XML 139 | UpgradeLog*.htm 140 | 141 | # SQL Server files 142 | App_Data/*.mdf 143 | App_Data/*.ldf 144 | 145 | 146 | #LightSwitch generated files 147 | GeneratedArtifacts/ 148 | _Pvt_Extensions/ 149 | ModelManifest.xml 150 | 151 | # ========================= 152 | # Windows detritus 153 | # ========================= 154 | 155 | # Windows image file caches 156 | Thumbs.db 157 | ehthumbs.db 158 | 159 | # Folder config file 160 | Desktop.ini 161 | 162 | # Recycle Bin used on file shares 163 | $RECYCLE.BIN/ 164 | 165 | # Mac desktop service store files 166 | .DS_Store 167 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "clRNG"] 2 | path = clRNG 3 | url = https://github.com/clMathLibraries/clRNG.git 4 | [submodule "MAXINE-VFX-SDK"] 5 | path = MAXINE-VFX-SDK 6 | url = https://github.com/NVIDIA/MAXINE-VFX-SDK.git 7 | -------------------------------------------------------------------------------- /Build.md: -------------------------------------------------------------------------------- 1 | ## clcufiltersのビルド方法 2 | 3 | ### 0. ビルドに必要なもの 4 | ビルドには、下記のものが必要です。 5 | 6 | - Visual Studio 2019/2022 7 | - CUDA 11.0 - 12.3 8 | - [OpenCL Headers](https://github.com/KhronosGroup/OpenCL-Headers) 9 | 10 | ### 1. 環境準備 11 | 12 | Visual Studioをインストール後、CUDAをインストールします。 13 | 14 | その後、ビルドに必要なOpenCLのヘッダをダウンロードし、環境変数 ```OPENCL_HEADERS``` にその場所を設定します。 15 | 16 | ```Batchfile 17 | git clone https://github.com/KhronosGroup/OpenCL-Headers.git 18 | setx OPENCL_HEADERS 19 | ``` 20 | 21 | ### 2. ソースのダウンロード 22 | 23 | submoduleのダウンロードも必要なため、gitコマンドで```--recursive```付きでダウンロードします。 24 | 25 | ```Batchfile 26 | git clone https://github.com/rigaya/Aviutl-clcufilters --recursive 27 | ``` 28 | 29 | ### 3. clcufilters.auf / clfilters.exe / cufilters.exe のビルド 30 | 31 | clcufilters.slnを開き、ビルドします。 32 | 33 | ビルドしたいものに合わせて、構成を選択してください。 34 | 35 | | |Debug用構成 |Release用構成| 36 | |:---------------------|:------|:--------| 37 | | clcufilters.auf | Debug (Win32) | Release (Win32) | 38 | | clfilters.exe | Debug (x64) | Release (x64) | 39 | | cufilters.exe | DebugCU (x64) | ReleaseCU (x64) | -------------------------------------------------------------------------------- /NVVfxLinker/NVVfxLinker.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | ソース ファイル 20 | 21 | 22 | ソース ファイル 23 | 24 | 25 | -------------------------------------------------------------------------------- /clRNG.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 6 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 7 | 8 | 9 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 10 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 11 | 12 | 13 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 14 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 15 | 16 | 17 | 18 | 19 | ソース ファイル 20 | 21 | 22 | ソース ファイル 23 | 24 | 25 | 26 | 27 | ヘッダー ファイル 28 | 29 | 30 | ヘッダー ファイル 31 | 32 | 33 | -------------------------------------------------------------------------------- /clcufilters/clcufilters.def: -------------------------------------------------------------------------------- 1 | LIBRARY clcufilters.auf 2 | 3 | EXPORTS 4 | GetFilterTable @1 5 | 6 | -------------------------------------------------------------------------------- /clcufilters/clcufilters.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // clfilters by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2022 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #ifndef __CLCUFILTERS_H__ 30 | #define __CLCUFILTERS_H__ 31 | 32 | #define ID_TX_RESIZE_RES_ADD 40020 33 | 34 | BOOL CALLBACK add_res_dlg(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam); 35 | 36 | #endif //__CLCUFILTERS_H__ 37 | -------------------------------------------------------------------------------- /clcufilters/clcufilters.rc: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // clfilters by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2022 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #include 30 | #include "clcufilters_version.h" 31 | #include "clcufilters.h" 32 | 33 | // 文字列表示ダイアログ 34 | // 35 | ADD_RES_DLG DIALOG 0, 0, 175, 52 36 | CAPTION "clcufilter リサイズ 解像度追加" 37 | STYLE WS_VISIBLE | WS_POPUP | WS_CAPTION | DS_MODALFRAME | WS_SYSMENU 38 | FONT 9, "MS Pゴシック" 39 | { 40 | LTEXT "x", IDC_STATIC, 4, 4, 80, 10 41 | EDITTEXT ID_TX_RESIZE_RES_ADD, 4, 18, 167, 14, ES_LEFT 42 | 43 | DEFPUSHBUTTON "OK", IDOK, 80, 36, 40, 14, BS_CENTER|BS_VCENTER 44 | PUSHBUTTON "Cancel", IDCANCEL, 127, 36, 40, 14, BS_CENTER|BS_VCENTER 45 | } 46 | 47 | 48 | // 49 | // Version Information 50 | // 51 | 52 | 53 | VS_VERSION_INFO VERSIONINFO 54 | FILEVERSION VER_FILEVERSION 55 | PRODUCTVERSION VER_PRODUCTVERSION 56 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 57 | FILEFLAGS ( VER_DEBUG | VER_PRIVATE ) 58 | FILEOS VOS_NT_WINDOWS32 59 | FILETYPE VFT_DLL 60 | FILESUBTYPE VFT_APP 61 | BEGIN 62 | BLOCK "VarFileInfo" 63 | BEGIN 64 | VALUE "Translation", 0x411, 1200 65 | END 66 | 67 | BLOCK "StringFileInfo" 68 | BEGIN 69 | BLOCK "041104b0" 70 | BEGIN 71 | VALUE "Comments", VER_STR_COMMENTS 72 | VALUE "CompanyName", VER_STR_COMPANYNAME 73 | VALUE "FileDescription", VER_STR_FILEDESCRIPTION 74 | VALUE "FileVersion", VER_STR_FILEVERSION 75 | VALUE "InternalName", VER_STR_INTERNALNAME 76 | VALUE "OriginalFileName", VER_STR_ORIGINALFILENAME 77 | VALUE "LegalCopyright", VER_STR_LEGALCOPYRIGHT 78 | VALUE "ProductName", VER_STR_PRODUCTNAME 79 | VALUE "ProductVersion", VER_STR_PRODUCTVERSION 80 | END 81 | END 82 | END 83 | -------------------------------------------------------------------------------- /clcufilters/clcufilters.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | ソース ファイル 20 | 21 | 22 | ソース ファイル 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | 29 | 30 | ソース ファイル 31 | 32 | 33 | 34 | 35 | ヘッダー ファイル 36 | 37 | 38 | ヘッダー ファイル 39 | 40 | 41 | ヘッダー ファイル 42 | 43 | 44 | 45 | 46 | リソース ファイル 47 | 48 | 49 | -------------------------------------------------------------------------------- /clcufilters/clcufilters_add_res.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // clfilters by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2022 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #include "rgy_osdep.h" 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #define DEFINE_GLOBAL 37 | #include "filter.h" 38 | #include "rgy_prm.h" 39 | #include "clcufilters_version.h" 40 | #include "clcufilters.h" 41 | 42 | 43 | /*==================================================================== 44 | * add_res_dlg() コールバックプロシージャ 45 | *===================================================================*/ 46 | BOOL CALLBACK add_res_dlg(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) { 47 | #if !CLFILTERS_EN 48 | static const char *DLG_CAPTION = "cufilter リサイズ 解像度追加"; 49 | #else 50 | static const char *DLG_CAPTION = "cufilter resize add resolution"; 51 | #endif 52 | switch (msg) { 53 | case WM_INITDIALOG: 54 | SetDlgItemText(hdlg, ID_TX_RESIZE_RES_ADD, (const char*)""); 55 | SendMessage(hdlg, WM_SETTEXT, 0, (LPARAM)DLG_CAPTION); 56 | return TRUE; 57 | case WM_COMMAND: 58 | switch (LOWORD(wParam)) { 59 | case IDOK: { 60 | char str[128] = { 0 }; 61 | uint32_t w = 0, h = 0; 62 | GetDlgItemText(hdlg, ID_TX_RESIZE_RES_ADD, str, sizeof(str)); 63 | if (2 != sscanf_s(str, "%dx%d", &w, &h)) { 64 | #if !CLFILTERS_EN 65 | MessageBox(hdlg, "誤った書式で指定されています。\n1280x720など、<幅>x<高さ>の書式で指定してください。", MB_OK, MB_ICONEXCLAMATION); 66 | #else 67 | MessageBox(hdlg, "Please set in format x, such as 1920x1080.", MB_OK, MB_ICONEXCLAMATION); 68 | #endif 69 | return FALSE; 70 | } 71 | if (w >= (1<<15) || (h >= (1<<15))) { 72 | #if !CLFILTERS_EN 73 | MessageBox(hdlg, "解像度が大きすぎます。32767以下の値で指定してください。", MB_OK, MB_ICONEXCLAMATION); 74 | #else 75 | MessageBox(hdlg, "Too large width or height, should be below 32767.", MB_OK, MB_ICONEXCLAMATION); 76 | #endif 77 | return FALSE; 78 | } 79 | EndDialog(hdlg, ((w & 0xffff) << 16) | (h & 0xffff)); 80 | return TRUE; 81 | } 82 | case IDCANCEL: 83 | EndDialog(hdlg, 0); 84 | return TRUE; 85 | } 86 | break; 87 | } 88 | 89 | return FALSE; 90 | } 91 | -------------------------------------------------------------------------------- /clcufilters/clcufilters_control.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigaya/Aviutl-clcufilters/e59336bd97c20a501feb7ec6aa77a0039efc73aa/clcufilters/clcufilters_control.h -------------------------------------------------------------------------------- /clcufilters_common/clcufilters_common.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | ソース ファイル 20 | 21 | 22 | ソース ファイル 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル 29 | 30 | 31 | 32 | 33 | ヘッダー ファイル 34 | 35 | 36 | ヘッダー ファイル 37 | 38 | 39 | ヘッダー ファイル 40 | 41 | 42 | ヘッダー ファイル 43 | 44 | 45 | ヘッダー ファイル 46 | 47 | 48 | ヘッダー ファイル 49 | 50 | 51 | -------------------------------------------------------------------------------- /clcufilters_common/clcufilters_exe_cmd.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // The MIT License 4 | // 5 | // Copyright (c) 2024 rigaya 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | // ------------------------------------------------------------------------------------------ 26 | 27 | #ifndef __CLCUFILTERS_EXE_CMD_H__ 28 | #define __CLCUFILTERS_EXE_CMD_H__ 29 | 30 | #include "clcufilters_chain_prm.h" 31 | 32 | int parse_cmd(AviutlAufExeParams& prms, const bool ignore_parse_err, const int nArgNum, const TCHAR** strInput); 33 | 34 | #endif //__CLCUFILTERS_EXE_CMD_H__ 35 | -------------------------------------------------------------------------------- /clcufilters_common/clcufilters_version.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // clfilters by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2022-2024 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | 30 | #pragma once 31 | #ifndef __CLCUFILTERS_VERSION_H__ 32 | #define __CLCUFILTERS_VERSION_H__ 33 | 34 | #include "rgy_version.h" 35 | 36 | #define AUF_VERSION VER_FILEVERSION 37 | #define AUF_VERSION_STR VER_STR_FILEVERSION 38 | #define AUF_NAME "clcufilters.auf" 39 | #define AUF_FULL_NAME "clcufilters" 40 | #define AUF_VERSION_NAME "clcufilters " VER_STR_FILEVERSION 41 | #define AUF_VERSION_INFO AUF_VERSION_NAME 42 | 43 | #ifdef DEBUG 44 | #define VER_DEBUG VS_FF_DEBUG 45 | #define VER_PRIVATE VS_FF_PRIVATEBUILD 46 | #else 47 | #define VER_DEBUG 0 48 | #define VER_PRIVATE 0 49 | #endif 50 | 51 | #define VER_STR_COMMENTS AUF_FULL_NAME 52 | #define VER_STR_COMPANYNAME "" 53 | #define VER_STR_FILEDESCRIPTION AUF_FULL_NAME 54 | #define VER_STR_INTERNALNAME AUF_FULL_NAME 55 | #define VER_STR_ORIGINALFILENAME AUF_NAME 56 | #define VER_STR_LEGALCOPYRIGHT AUF_FULL_NAME 57 | #define VER_STR_PRODUCTNAME "clcufilters" 58 | #define VER_PRODUCTVERSION VER_FILEVERSION 59 | #define VER_STR_PRODUCTVERSION VER_STR_FILEVERSION 60 | 61 | #endif //__CLCUFILTERS_VERSION_H__ 62 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_convolution3d.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #ifndef __RGY_FILTER_CONVOLUTION3D_H__ 30 | #define __RGY_FILTER_CONVOLUTION3D_H__ 31 | 32 | #include "rgy_filter_cl.h" 33 | #include "rgy_prm.h" 34 | #include 35 | 36 | class RGYFilterParamConvolution3D : public RGYFilterParam { 37 | public: 38 | VppConvolution3d convolution3d; 39 | RGYFilterParamConvolution3D() : convolution3d() {}; 40 | virtual ~RGYFilterParamConvolution3D() {}; 41 | virtual tstring print() const override { return convolution3d.print(); }; 42 | }; 43 | 44 | class RGYFilterConvolution3D : public RGYFilter { 45 | public: 46 | RGYFilterConvolution3D(shared_ptr context); 47 | virtual ~RGYFilterConvolution3D(); 48 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 49 | protected: 50 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 51 | virtual void close() override; 52 | 53 | virtual RGY_ERR denoisePlane(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pPrevPlane, const RGYFrameInfo *pInputPlane, const RGYFrameInfo *pNextPlane, const float threshold_spatial, const float threshold_temporal, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 54 | virtual RGY_ERR denoiseFrame(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pPrevFrame, const RGYFrameInfo *pInputFrame, const RGYFrameInfo *pNextFrame, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 55 | 56 | bool m_bInterlacedWarn; 57 | RGYOpenCLProgramAsync m_convolution3d; 58 | std::array, 2> m_prevFrames; 59 | int m_cacheIdx; 60 | int m_frameOut; 61 | }; 62 | 63 | #endif //__RGY_FILTER_CONVOLUTION3D_H__ 64 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_deband.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #include "rgy_filter_cl.h" 30 | #include "rgy_prm.h" 31 | #include 32 | 33 | struct clrngStreamDeleter { 34 | void operator()(void *ptr) const; 35 | }; 36 | 37 | class RGYFilterParamDeband : public RGYFilterParam { 38 | public: 39 | VppDeband deband; 40 | RGYFilterParamDeband() : deband() {}; 41 | virtual ~RGYFilterParamDeband() {}; 42 | virtual tstring print() const override { return deband.print(); }; 43 | }; 44 | 45 | class RGYFilterDeband : public RGYFilter { 46 | public: 47 | RGYFilterDeband(shared_ptr context); 48 | virtual ~RGYFilterDeband(); 49 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 50 | protected: 51 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 52 | virtual void close() override; 53 | 54 | virtual RGY_ERR initRand(); 55 | virtual RGY_ERR genRand(RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 56 | virtual RGY_ERR procPlane(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, const RGYFrameInfo *pRandPlane, 57 | const int range_plane, const float dither_range, const float threshold_float, const int field_mask, const RGY_PLANE plane, 58 | RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 59 | virtual RGY_ERR procFrame(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 60 | 61 | bool m_bInterlacedWarn; 62 | bool m_randInitialized; 63 | RGYOpenCLProgramAsync m_deband; 64 | RGYOpenCLProgramAsync m_debandGenRand; 65 | std::unique_ptr m_rngStream; 66 | std::unique_ptr m_randStreamBuf; 67 | std::unique_ptr m_randBufY; 68 | std::unique_ptr m_randBufUV; 69 | RGYCLFramePool m_srcImagePool; 70 | }; 71 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_denoise_dct.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #ifndef __RGY_FILTER_DENOISE_DCT_H__ 30 | #define __RGY_FILTER_DENOISE_DCT_H__ 31 | 32 | #include "rgy_filter_cl.h" 33 | #include "rgy_prm.h" 34 | 35 | class RGYFilterParamDenoiseDct : public RGYFilterParam { 36 | public: 37 | VppDenoiseDct dct; 38 | RGYFilterParamDenoiseDct() : dct() {}; 39 | virtual ~RGYFilterParamDenoiseDct() {}; 40 | virtual tstring print() const; 41 | }; 42 | 43 | class RGYFilterDenoiseDct : public RGYFilter { 44 | public: 45 | RGYFilterDenoiseDct(shared_ptr context); 46 | virtual ~RGYFilterDenoiseDct(); 47 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 48 | protected: 49 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 50 | virtual void close() override; 51 | 52 | RGY_ERR checkParam(const RGYFilterParamDenoiseDct *prm); 53 | 54 | RGY_ERR colorDecorrelation(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, RGYOpenCLQueue &queue); 55 | RGY_ERR colorCorrelation(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, RGYOpenCLQueue &queue); 56 | RGY_ERR denoiseDct(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, RGYOpenCLQueue &queue); 57 | RGY_ERR denoise(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 58 | 59 | int m_step; 60 | float m_threshold; 61 | std::unique_ptr m_srcCrop; 62 | std::unique_ptr m_dstCrop; 63 | std::array, 2> m_bufImg; 64 | RGYOpenCLProgramAsync m_dct; 65 | }; 66 | 67 | #endif //__RGY_FILTER_DENOISE_DCT_H__ 68 | 69 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_denoise_knn.cl: -------------------------------------------------------------------------------- 1 |  2 | // Type 3 | // bit_depth 4 | // knn_radius 5 | 6 | #ifndef clamp 7 | #define clamp(x, low, high) (((x) <= (high)) ? (((x) >= (low)) ? (x) : (low)) : (high)) 8 | #endif 9 | 10 | float lerpf(float v0, float v1, float t) { 11 | float tmp = (1.0f-t)*v0; 12 | return tmp + t*v1; 13 | } 14 | 15 | __kernel void kernel_denoise_knn( 16 | __global uchar *restrict pDst, 17 | const int dstPitch, const int dstWidth, const int dstHeight, 18 | __read_only image2d_t src, 19 | const float strength, const float lerpC, const float weight_threshold, const float lerp_threshold) { 20 | const float knn_window_area = (float)((2 * knn_radius + 1) * (2 * knn_radius + 1)); 21 | const float inv_knn_window_area = 1.0f / knn_window_area; 22 | const int ix = get_global_id(0); 23 | const int iy = get_global_id(1); 24 | const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | CLK_FILTER_NEAREST; 25 | if (ix < dstWidth && iy < dstHeight) { 26 | float fCount = 0.0f; 27 | float sumWeights = 0.0f; 28 | float sum = 0.0f; 29 | float center = (float)read_imagef(src, sampler, (int2)(ix, iy)).x; 30 | 31 | #pragma unroll 32 | for (int i = -knn_radius; i <= knn_radius; i++) { 33 | const int loadix = clamp(ix, 0, dstWidth-1); 34 | #pragma unroll 35 | for (int j = -knn_radius; j <= knn_radius; j++) { 36 | const int loadiy = clamp(iy, 0, dstHeight-1); 37 | float clrIJ = (float)read_imagef(src, sampler, (int2)(loadix, loadiy)).x; 38 | float distanceIJ = (center - clrIJ) * (center - clrIJ); 39 | 40 | float weightIJ = native_exp(-(distanceIJ * strength + (i * i + j * j) * inv_knn_window_area)); 41 | 42 | sum += clrIJ * weightIJ; 43 | 44 | sumWeights += weightIJ; 45 | 46 | fCount += (weightIJ > weight_threshold) ? inv_knn_window_area : 0; 47 | } 48 | } 49 | float lerpQ = (fCount > lerp_threshold) ? lerpC : 1.0f - lerpC; 50 | 51 | __global Type *ptr = (__global Type *)(pDst + iy * dstPitch + ix * sizeof(Type)); 52 | ptr[0] = (Type)clamp(lerpf(sum * native_recip(sumWeights), center, lerpQ) * (float)((1< 35 | 36 | class RGYFilterParamDenoiseKnn : public RGYFilterParam { 37 | public: 38 | VppKnn knn; 39 | RGYFilterParamDenoiseKnn() : knn() {}; 40 | virtual ~RGYFilterParamDenoiseKnn() {}; 41 | virtual tstring print() const override { return knn.print(); }; 42 | }; 43 | 44 | class RGYFilterDenoiseKnn : public RGYFilter { 45 | public: 46 | RGYFilterDenoiseKnn(shared_ptr context); 47 | virtual ~RGYFilterDenoiseKnn(); 48 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 49 | protected: 50 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 51 | virtual void close() override; 52 | 53 | virtual RGY_ERR denoisePlane(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 54 | virtual RGY_ERR denoiseFrame(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 55 | 56 | bool m_bInterlacedWarn; 57 | RGYOpenCLProgramAsync m_knn; 58 | RGYCLFramePool m_srcImagePool; 59 | }; 60 | 61 | #endif //__RGY_FILTER_DENOISE_KNN_H__ 62 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_denoise_nlmeans.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #ifndef __RGY_FILTER_DENOISE_NLMEANS_H__ 30 | #define __RGY_FILTER_DENOISE_NLMEANS_H__ 31 | 32 | #include "rgy_filter_cl.h" 33 | #include "rgy_prm.h" 34 | #include 35 | 36 | // dxdyのペアを何並列で同時計算するか 37 | static const int RGY_NLMEANS_DXDY_STEP = 8; 38 | 39 | class RGYFilterParamDenoiseNLMeans : public RGYFilterParam { 40 | public: 41 | VppNLMeans nlmeans; 42 | RGYFilterParamDenoiseNLMeans() : nlmeans() {}; 43 | virtual ~RGYFilterParamDenoiseNLMeans() {}; 44 | virtual tstring print() const override { return nlmeans.print(); }; 45 | }; 46 | 47 | class RGYFilterDenoiseNLMeans : public RGYFilter { 48 | public: 49 | RGYFilterDenoiseNLMeans(shared_ptr context); 50 | virtual ~RGYFilterDenoiseNLMeans(); 51 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 52 | protected: 53 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 54 | virtual void close() override; 55 | 56 | virtual RGY_ERR denoisePlane( 57 | RGYFrameInfo *pOutputPlane, 58 | RGYFrameInfo *pTmpUPlane, RGYFrameInfo *pTmpVPlane, 59 | RGYFrameInfo *pTmpIWPlane, 60 | const RGYFrameInfo *pInputPlane, 61 | RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 62 | virtual RGY_ERR denoiseFrame(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 63 | 64 | std::unordered_map> m_nlmeans; 65 | std::array, 2 + 1 + RGY_NLMEANS_DXDY_STEP> m_tmpBuf; 66 | }; 67 | 68 | #endif //__RGY_FILTER_DENOISE_KNN_H__ 69 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_denoise_pmd.cl: -------------------------------------------------------------------------------- 1 |  2 | // Type 3 | // bit_depth 4 | // useExp 5 | 6 | #ifndef clamp 7 | #define clamp(x, low, high) (((x) <= (high)) ? (((x) >= (low)) ? (x) : (low)) : (high)) 8 | #endif 9 | 10 | float pmd_exp(float x, float strength2, float inv_threshold2) { 11 | return strength2 * native_exp(-x*x * inv_threshold2); 12 | } 13 | 14 | float pmd(float x, float strength2, float inv_threshold2) { 15 | return strength2 * native_recip(1.0f + (x*x * inv_threshold2)); 16 | } 17 | 18 | __kernel void kernel_denoise_pmd_gauss( 19 | __global uchar *restrict pDst, 20 | const int dstPitch, const int dstWidth, const int dstHeight, 21 | __read_only image2d_t tSrc) { 22 | const float weight[5] = { 1.0f / 16.0f, 4.0f / 16.0f, 6.0f / 16.0f, 4.0f / 16.0f, 1.0f / 16.0f }; 23 | const int ix = get_global_id(0); 24 | const int iy = get_global_id(1); 25 | const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; 26 | if (ix < dstWidth && iy < dstHeight) { 27 | float sum = 0.0f; 28 | for (int j = 0; j < 5; j++) { 29 | float sum_line = 0.0f; 30 | #pragma unroll 31 | for (int i = 0; i < 5; i++) { 32 | sum_line += (float)read_imagef(tSrc, sampler, (int2)(ix-2+i, iy-2+j)).x * weight[i]; 33 | } 34 | sum += sum_line * weight[j]; 35 | } 36 | __global Type *ptr = (__global Type *)(pDst + iy * dstPitch + ix * sizeof(Type)); 37 | ptr[0] = (Type)(sum * (float)((1< 32 | 33 | class RGYFilterParamDenoisePmd : public RGYFilterParam { 34 | public: 35 | VppPmd pmd; 36 | RGYFilterParamDenoisePmd() : pmd() {}; 37 | virtual ~RGYFilterParamDenoisePmd() {}; 38 | virtual tstring print() const override { return pmd.print(); }; 39 | }; 40 | 41 | class RGYFilterDenoisePmd : public RGYFilter { 42 | public: 43 | RGYFilterDenoisePmd(shared_ptr context); 44 | virtual ~RGYFilterDenoisePmd(); 45 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 46 | protected: 47 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 48 | virtual void close() override; 49 | 50 | virtual RGY_ERR runGaussPlane(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 51 | virtual RGY_ERR runGaussFrame(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 52 | virtual RGY_ERR runPmdPlane(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, const RGYFrameInfo *pGaussPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 53 | virtual RGY_ERR runPmdFrame(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, const RGYFrameInfo *pGaussFrame, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 54 | virtual RGY_ERR denoiseFrame(RGYFrameInfo *pOutputPlane[2], const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 55 | 56 | bool m_bInterlacedWarn; 57 | int m_frameIdx; 58 | RGYOpenCLProgramAsync m_pmd; 59 | std::unique_ptr m_gauss; 60 | RGYCLFramePool m_srcImagePool; 61 | RGYCLFramePool m_gaussImagePool; 62 | }; 63 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_edgelevel.cl: -------------------------------------------------------------------------------- 1 | // Type 2 | // bit_depth 3 | 4 | #ifndef clamp 5 | #define clamp(x, low, high) (((x) <= (high)) ? (((x) >= (low)) ? (x) : (low)) : (high)) 6 | #endif 7 | 8 | void check_min_max(float *vmin, float *vmax, float value) { 9 | *vmax = max(*vmax, value); 10 | *vmin = min(*vmin, value); 11 | } 12 | 13 | __kernel void kernel_edgelevel( 14 | __global uchar *restrict pDst, 15 | const int dstPitch, const int dstWidth, const int dstHeight, 16 | __read_only image2d_t src, 17 | const float strength, const float threshold, const float black, const float white) { 18 | const int ix = get_global_id(0); 19 | const int iy = get_global_id(1); 20 | const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; 21 | 22 | if (ix < dstWidth && iy < dstHeight) { 23 | float center = (float)read_imagef(src, sampler, (int2)(ix, iy)).x; 24 | float hmin = center; 25 | float vmin = center; 26 | float hmax = center; 27 | float vmax = center; 28 | 29 | check_min_max(&hmin, &hmax, (float)read_imagef(src, sampler, (int2)(ix - 2, iy)).x); 30 | check_min_max(&vmin, &vmax, (float)read_imagef(src, sampler, (int2)(ix, iy - 2)).x); 31 | check_min_max(&hmin, &hmax, (float)read_imagef(src, sampler, (int2)(ix - 1, iy)).x); 32 | check_min_max(&vmin, &vmax, (float)read_imagef(src, sampler, (int2)(ix, iy - 1)).x); 33 | check_min_max(&hmin, &hmax, (float)read_imagef(src, sampler, (int2)(ix + 1, iy)).x); 34 | check_min_max(&vmin, &vmax, (float)read_imagef(src, sampler, (int2)(ix, iy + 1)).x); 35 | check_min_max(&hmin, &hmax, (float)read_imagef(src, sampler, (int2)(ix + 2, iy)).x); 36 | check_min_max(&vmin, &vmax, (float)read_imagef(src, sampler, (int2)(ix, iy + 2)).x); 37 | 38 | if (hmax - hmin < vmax - vmin) { 39 | hmax = vmax, hmin = vmin; 40 | } 41 | 42 | if (hmax - hmin > threshold) { 43 | float avg = (hmin + hmax) * 0.5f; 44 | if (center == hmin) 45 | hmin -= black; 46 | hmin -= black; 47 | if (center == hmax) 48 | hmax += white; 49 | hmax += white; 50 | 51 | center = min(max((center + ((center - avg) * strength)), hmin), hmax); 52 | } 53 | 54 | __global Type *ptr = (__global Type *)(pDst + iy * dstPitch + ix * sizeof(Type)); 55 | ptr[0] = (Type)(clamp(center, 0.0f, 1.0f - 1e-6f) * ((1 << (bit_depth))-1)); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_edgelevel.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #include "rgy_filter_cl.h" 30 | #include "rgy_prm.h" 31 | #include 32 | 33 | class RGYFilterParamEdgelevel : public RGYFilterParam { 34 | public: 35 | VppEdgelevel edgelevel; 36 | RGYFilterParamEdgelevel() : edgelevel() {}; 37 | virtual ~RGYFilterParamEdgelevel() {}; 38 | virtual tstring print() const override { return edgelevel.print(); }; 39 | }; 40 | 41 | class RGYFilterEdgelevel : public RGYFilter { 42 | public: 43 | RGYFilterEdgelevel(shared_ptr context); 44 | virtual ~RGYFilterEdgelevel(); 45 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 46 | protected: 47 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 48 | virtual void close() override; 49 | 50 | virtual RGY_ERR procPlane(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 51 | virtual RGY_ERR procFrame(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 52 | 53 | bool m_bInterlacedWarn; 54 | RGYOpenCLProgramAsync m_edgelevel; 55 | RGYCLFramePool m_srcImagePool; 56 | }; 57 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_pad.cl: -------------------------------------------------------------------------------- 1 | // Type 2 | 3 | __kernel void kernel_pad( 4 | __global uchar *__restrict__ ptrDst, 5 | const int dstPitch, const int dstWidth, const int dstHeight, 6 | const __global uchar *__restrict__ ptrSrc, 7 | const int srcPitch, const int srcWidth, const int srcHeight, 8 | const int pad_left, const int pad_up, 9 | const int pad_color) { 10 | const int ox = get_global_id(0); 11 | const int oy = get_global_id(1); 12 | 13 | if (ox < dstWidth && oy < dstHeight) { 14 | const int ix = ox - pad_left; 15 | const int iy = oy - pad_up; 16 | 17 | Type out_color = (Type)pad_color; 18 | if (0 <= ix && ix < srcWidth && 0 <= iy && iy < srcHeight) { 19 | const __global Type *ptrSrcPix = (const __global Type *)(ptrSrc + iy * srcPitch + ix * sizeof(Type)); 20 | out_color = ptrSrcPix[0]; 21 | } 22 | 23 | __global Type *ptrDstPix = (__global Type *)(ptrDst + oy * dstPitch + ox * sizeof(Type)); 24 | ptrDstPix[0] = out_color; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_resize.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/VCEEnc/rkmppenc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2019-2021 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // IABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // ------------------------------------------------------------------------------------------ 27 | 28 | #pragma once 29 | #ifndef __RGY_FILTER_RESIZE_H__ 30 | #define __RGY_FILTER_RESIZE_H__ 31 | 32 | #include "rgy_filter_cl.h" 33 | 34 | class RGYFilterParamLibplaceboResample; 35 | 36 | class RGYFilterParamResize : public RGYFilterParam { 37 | public: 38 | RGY_VPP_RESIZE_ALGO interp; 39 | std::shared_ptr libplaceboResample; 40 | RGYFilterParamResize() : interp(RGY_VPP_RESIZE_AUTO), libplaceboResample() {}; 41 | virtual ~RGYFilterParamResize() {}; 42 | }; 43 | 44 | class RGYFilterLibplaceboResample; 45 | 46 | class RGYFilterResize : public RGYFilter { 47 | public: 48 | RGYFilterResize(shared_ptr context); 49 | virtual ~RGYFilterResize(); 50 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 51 | protected: 52 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 53 | virtual void close() override; 54 | 55 | virtual RGY_ERR resizePlane(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 56 | virtual RGY_ERR resizeFrame(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 57 | 58 | bool m_bInterlacedWarn; 59 | std::unique_ptr m_weightSpline; 60 | std::unique_ptr m_libplaceboResample; 61 | RGYOpenCLProgramAsync m_resize; 62 | RGYCLFramePool m_srcImagePool; 63 | }; 64 | 65 | #endif //__RGY_FILTER_RESIZE_H__ 66 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_smooth.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #include "rgy_filter_cl.h" 30 | #include "rgy_prm.h" 31 | #include "rgy_frame.h" 32 | #include 33 | 34 | static const int VPP_SMOOTH_MAX_QUALITY_LEVEL = 6; 35 | 36 | class RGYFilterParamSmooth : public RGYFilterParam { 37 | public: 38 | VppSmooth smooth; 39 | RGYListRef *qpTableRef; 40 | 41 | RGYFilterParamSmooth() : smooth(), qpTableRef(nullptr) {}; 42 | virtual ~RGYFilterParamSmooth() {}; 43 | virtual tstring print() const override { return smooth.print(); }; 44 | }; 45 | 46 | class RGYFilterSmooth : public RGYFilter { 47 | public: 48 | RGYFilterSmooth(shared_ptr context); 49 | virtual ~RGYFilterSmooth(); 50 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 51 | protected: 52 | int qp_size(int res) { return divCeil(res + 15, 16); } 53 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 54 | virtual void close() override; 55 | 56 | virtual RGY_ERR procPlane(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, const RGYFrameInfo *targetQPTable, const int qpBlockShift, const float qpMul, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 57 | virtual RGY_ERR procFrame(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, const RGYFrameInfo *targetQPTable, const float qpMul, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 58 | virtual RGY_ERR setQP(RGYCLFrame *targetQPTable, const int qp, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 59 | float getQPMul(int qp_scale); 60 | 61 | RGYOpenCLProgramAsync m_smooth; 62 | unique_ptr m_qp; 63 | std::shared_ptr m_qpSrc; 64 | std::shared_ptr m_qpSrcB; 65 | RGYListRef *m_qpTableRef; 66 | int m_qpTableErrCount; 67 | RGYCLFramePool m_srcImagePool; 68 | }; 69 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_transform.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #include "rgy_filter_cl.h" 30 | #include "rgy_prm.h" 31 | #include 32 | 33 | class RGYFilterParamTransform : public RGYFilterParam { 34 | public: 35 | VppTransform trans; 36 | RGYFilterParamTransform() : trans() {}; 37 | virtual ~RGYFilterParamTransform() {}; 38 | virtual tstring print() const override { return trans.print(); }; 39 | }; 40 | 41 | class RGYFilterTransform : public RGYFilter { 42 | public: 43 | RGYFilterTransform(shared_ptr context); 44 | virtual ~RGYFilterTransform(); 45 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 46 | protected: 47 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 48 | virtual void close() override; 49 | 50 | virtual RGY_ERR procPlane(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 51 | virtual RGY_ERR procFrame(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 52 | 53 | bool m_bInterlacedWarn; 54 | RGYOpenCLProgramAsync m_transform; 55 | }; 56 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_tweak.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #include "rgy_filter_cl.h" 30 | #include "rgy_prm.h" 31 | #include 32 | 33 | class RGYFilterParamTweak : public RGYFilterParam { 34 | public: 35 | VppTweak tweak; 36 | VideoVUIInfo vui; 37 | RGYFilterParamTweak() : tweak(), vui() {}; 38 | virtual ~RGYFilterParamTweak() {}; 39 | virtual tstring print() const override { return tweak.print(); }; 40 | }; 41 | 42 | class RGYFilterTweak : public RGYFilter { 43 | public: 44 | RGYFilterTweak(shared_ptr context); 45 | virtual ~RGYFilterTweak(); 46 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 47 | protected: 48 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 49 | virtual void close() override; 50 | 51 | virtual RGY_ERR procFrame(RGYFrameInfo *pFrame, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 52 | virtual RGY_ERR procFrameRGB(RGYFrameInfo *pFrame, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 53 | 54 | bool m_bInterlacedWarn; 55 | RGYOpenCLProgramAsync m_tweak; 56 | RGYOpenCLProgramAsync m_tweakRGB; 57 | RGY_CSP m_tweakCSP; 58 | RGY_CSP m_tweakRGBCSP; 59 | std::unique_ptr m_convA; 60 | std::unique_ptr m_convB; 61 | std::unique_ptr m_convC; 62 | }; 63 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_unsharp.cl: -------------------------------------------------------------------------------- 1 | // Type 2 | // radius 3 | // bit_depth 4 | 5 | #ifndef clamp 6 | #define clamp(x, low, high) (((x) <= (high)) ? (((x) >= (low)) ? (x) : (low)) : (high)) 7 | #endif 8 | 9 | #define SHARED_SIZE ((2 * radius + 1) * (2 * radius + 1)) 10 | 11 | #define RGY_FLT_EPS (1e-6f) 12 | 13 | __kernel void kernel_unsharp( 14 | __global uchar *__restrict__ pDst, 15 | const int dstPitch, const int dstWidth, const int dstHeight, 16 | __read_only image2d_t texSrc, 17 | const __global float *__restrict__ pGaussWeight, 18 | const float weight, const float threshold) { 19 | const int ix = get_global_id(0); 20 | const int iy = get_global_id(1); 21 | const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; 22 | 23 | const int local_id = get_local_id(1) * get_local_size(0) + get_local_id(0); 24 | __local float shared[SHARED_SIZE]; 25 | if (local_id < SHARED_SIZE) { 26 | shared[local_id] = pGaussWeight[local_id]; 27 | } 28 | barrier(CLK_LOCAL_MEM_FENCE); 29 | 30 | if (ix < dstWidth && iy < dstHeight) { 31 | float sum = 0.0f; 32 | float center = (float)read_imagef(texSrc, sampler, (int2)(ix, iy)).x; 33 | __local float *ptr_weight = shared; 34 | 35 | for (int j = -radius; j <= radius; j++) { 36 | #pragma unroll 37 | for (int i = -radius; i <= radius; i++) { 38 | sum += (float)read_imagef(texSrc, sampler, (int2)(ix+i, iy+j)).x * ptr_weight[0]; 39 | ptr_weight++; 40 | } 41 | } 42 | 43 | const float diff = center - sum; 44 | if (fabs(diff) >= threshold) { 45 | center += weight * diff; 46 | } 47 | 48 | __global Type *ptr = (__global Type *)(pDst + iy * dstPitch + ix * sizeof(Type)); 49 | ptr[0] = (Type)(clamp(center, 0.0f, 1.0f - RGY_FLT_EPS) * (1 << (bit_depth))); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_unsharp.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #include "rgy_filter_cl.h" 30 | #include "rgy_prm.h" 31 | #include 32 | 33 | class RGYFilterParamUnsharp : public RGYFilterParam { 34 | public: 35 | VppUnsharp unsharp; 36 | RGYFilterParamUnsharp() : unsharp() {}; 37 | virtual ~RGYFilterParamUnsharp() {}; 38 | virtual tstring print() const override { return unsharp.print(); }; 39 | }; 40 | 41 | class RGYFilterUnsharp : public RGYFilter { 42 | public: 43 | RGYFilterUnsharp(shared_ptr context); 44 | virtual ~RGYFilterUnsharp(); 45 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 46 | protected: 47 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 48 | virtual void close() override; 49 | 50 | virtual RGY_ERR setWeight(unique_ptr &pGaussWeightBuf, int radius, float sigma); 51 | virtual RGY_ERR procPlane(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, const RGYCLBuf *gaussWeightBuf, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 52 | virtual RGY_ERR procFrame(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 53 | 54 | bool m_bInterlacedWarn; 55 | RGYOpenCLProgramAsync m_unsharp; 56 | unique_ptr m_pGaussWeightBufY; 57 | unique_ptr m_pGaussWeightBufUV; 58 | RGYCLFramePool m_srcImagePool; 59 | }; 60 | -------------------------------------------------------------------------------- /clfilters_common/rgy_filter_warpsharp.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #include "rgy_filter_cl.h" 30 | #include "rgy_prm.h" 31 | #include 32 | 33 | class RGYFilterParamWarpsharp : public RGYFilterParam { 34 | public: 35 | VppWarpsharp warpsharp; 36 | RGYFilterParamWarpsharp() : warpsharp() {}; 37 | virtual ~RGYFilterParamWarpsharp() {}; 38 | virtual tstring print() const override { return warpsharp.print(); }; 39 | }; 40 | 41 | class RGYFilterWarpsharp : public RGYFilter { 42 | public: 43 | RGYFilterWarpsharp(shared_ptr context); 44 | virtual ~RGYFilterWarpsharp(); 45 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 46 | protected: 47 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event) override; 48 | virtual void close() override; 49 | 50 | RGY_ERR checkParam(const std::shared_ptr prm); 51 | 52 | RGY_ERR procPlaneSobel(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, const float threshold, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 53 | RGY_ERR procPlaneBlur(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 54 | RGY_ERR procPlaneWarp(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputMask, const RGYFrameInfo *pInputPlaneImg, const float depth, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 55 | RGY_ERR procPlaneDowscale(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 56 | virtual RGY_ERR procPlane(RGYFrameInfo *pOutputPlane, RGYFrameInfo *pMaskPlane0, RGYFrameInfo *pMaskPlane1, const RGYFrameInfo *pInputPlane, const RGYFrameInfo *pInputPlaneImg, const float threshold, const float depth, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 57 | virtual RGY_ERR procFrame(RGYFrameInfo *pOutputPlane, const RGYFrameInfo *pInputPlane, RGYOpenCLQueue &queue, const std::vector &wait_events, RGYOpenCLEvent *event); 58 | 59 | bool m_bInterlacedWarn; 60 | RGYOpenCLProgramAsync m_warpsharp; 61 | std::array, 2> m_mask; 62 | RGYCLFramePool m_srcImagePool; 63 | }; 64 | -------------------------------------------------------------------------------- /clfilters_exe/clfilters_chain.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // clfilters by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2022 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #ifndef __CLFILTERS_CHAIN_H__ 30 | #define __CLFILTERS_CHAIN_H__ 31 | 32 | #include "clcufilters_chain.h" 33 | #include "rgy_filter_cl.h" 34 | 35 | class clFilterFrameBuffer : public clcuFilterFrameBuffer { 36 | public: 37 | clFilterFrameBuffer(std::shared_ptr cl); 38 | virtual ~clFilterFrameBuffer(); 39 | 40 | virtual std::unique_ptr allocateFrame(const int width, const int height) override; 41 | virtual void resetMappedFrame(RGYFrame *frame) override; 42 | protected: 43 | std::shared_ptr m_cl; 44 | }; 45 | 46 | class clFilterDeviceParam : public clcuFilterDeviceParam { 47 | public: 48 | int platformID; 49 | cl_device_type deviceType; 50 | bool noNVCL; 51 | 52 | clFilterDeviceParam() : platformID(0), deviceType(CL_DEVICE_TYPE_GPU), noNVCL(true) {}; 53 | virtual ~clFilterDeviceParam() {}; 54 | }; 55 | 56 | class DeviceDX11; 57 | 58 | class clFilterChain : public clcuFilterChain { 59 | public: 60 | clFilterChain(); 61 | virtual ~clFilterChain(); 62 | 63 | virtual RGY_ERR sendInFrame(const RGYFrameInfo *pInputFrame) override; 64 | virtual RGY_ERR proc(const int frameID, const clFilterChainParam& prm) override; 65 | virtual RGY_ERR getOutFrame(RGYFrameInfo *pOutputFrame) override; 66 | 67 | virtual int platformID() const override { return m_platformID; } 68 | protected: 69 | virtual RGY_ERR initDevice(const clcuFilterDeviceParam *param) override; 70 | virtual void close() override; 71 | virtual RGY_ERR configureOneFilter(std::unique_ptr& filter, RGYFrameInfo& inputFrame, const VppType filterType, const int resizeWidth, const int resizeHeight) override; 72 | 73 | std::shared_ptr m_cl; 74 | std::unique_ptr m_dx11; 75 | int m_platformID; 76 | RGYOpenCLQueue m_queueSendIn; 77 | }; 78 | 79 | #endif //__CLFILTERS_CHAIN_H__ 80 | -------------------------------------------------------------------------------- /clfilters_exe/clfilters_exe.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // clfilters by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2024 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #ifndef __CLFILTERS_EXE_H__ 30 | #define __CLFILTERS_EXE_H__ 31 | 32 | #include "clcufilters_exe.h" 33 | #include "rgy_opencl.h" 34 | 35 | class clFiltersExe : public clcuFiltersExe { 36 | public: 37 | clFiltersExe(bool noNVCL); 38 | virtual ~clFiltersExe(); 39 | virtual RGY_ERR initDevices() override; 40 | virtual std::string checkDevices() override; 41 | virtual bool isCUDA() const override { return false; } 42 | protected: 43 | std::string checkClPlatforms(); 44 | virtual RGY_ERR initDevice(const clfitersSharedPrms *sharedPrms, clFilterChainParam& prm) override; 45 | std::vector> m_clplatforms; 46 | bool m_noNVCL; 47 | }; 48 | 49 | #endif // !__CLFILTERS_EXE_H__ 50 | -------------------------------------------------------------------------------- /clfilters_exe/clfilters_exe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | ソース ファイル 20 | 21 | 22 | ソース ファイル 23 | 24 | 25 | 26 | 27 | リソース ファイル 28 | 29 | 30 | 31 | 32 | ヘッダー ファイル 33 | 34 | 35 | ヘッダー ファイル 36 | 37 | 38 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterConvolution3d.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include "NVEncFilter.h" 32 | #include "rgy_prm.h" 33 | 34 | class NVEncFilterParamConvolution3d : public NVEncFilterParam { 35 | public: 36 | VppConvolution3d convolution3d; 37 | 38 | NVEncFilterParamConvolution3d() : convolution3d() { 39 | 40 | }; 41 | virtual ~NVEncFilterParamConvolution3d() {}; 42 | virtual tstring print() const override; 43 | }; 44 | 45 | class NVEncFilterConvolution3d : public NVEncFilter { 46 | public: 47 | NVEncFilterConvolution3d(); 48 | virtual ~NVEncFilterConvolution3d(); 49 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 50 | protected: 51 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 52 | virtual void close() override; 53 | bool m_bInterlacedWarn; 54 | std::array, 2> m_prevFrames; 55 | int m_cacheIdx; 56 | }; 57 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterCustom.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include 32 | #include "NVEncFilter.h" 33 | #include "NVEncFilterParam.h" 34 | 35 | #if ENABLE_NVRTC 36 | #pragma warning (push) 37 | #pragma warning (disable: 4819) 38 | #pragma warning (disable: 4117) 39 | #pragma warning (disable: 4100) 40 | #pragma warning (disable: 4456) 41 | #pragma warning (disable: 4267) 42 | #pragma warning (disable: 4706) 43 | #pragma warning (disable: 4091) 44 | #define JITIFY_PRINT_INSTANTIATION 0 45 | #define JITIFY_PRINT_SOURCE 1 46 | #define JITIFY_PRINT_LOG 1 47 | #define JITIFY_PRINT_PTX 1 48 | #define JITIFY_PRINT_LAUNCH 0 49 | #define DISABLE_DLFCN 1 50 | #ifndef _CRT_SECURE_NO_WARNINGS 51 | #define DEF_CRT_SECURE_NO_WARNINGS 1 52 | #define _CRT_SECURE_NO_WARNINGS 1 53 | #else 54 | #define DEF_CRT_SECURE_NO_WARNINGS 0 55 | #endif 56 | #include "jitify.hpp" 57 | #if DEF_CRT_SECURE_NO_WARNINGS 58 | #undef _CRT_SECURE_NO_WARNINGS 59 | #endif 60 | #pragma warning (pop) 61 | #endif //#if ENABLE_NVRTC 62 | 63 | 64 | class NVEncFilterParamCustom : public NVEncFilterParam { 65 | public: 66 | VppCustom custom; 67 | 68 | NVEncFilterParamCustom() : custom() { 69 | 70 | }; 71 | virtual ~NVEncFilterParamCustom() {}; 72 | virtual tstring print() const override; 73 | }; 74 | 75 | class NVEncFilterCustom : public NVEncFilter { 76 | public: 77 | static const char *KERNEL_NAME; 78 | NVEncFilterCustom(); 79 | virtual ~NVEncFilterCustom(); 80 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 81 | protected: 82 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 83 | virtual void close() override; 84 | virtual RGY_ERR check_param(shared_ptr prm); 85 | virtual RGY_ERR run_per_plane(RGYFrameInfo *ppOutputFrames, const RGYFrameInfo *pInputFrame, RGY_PLANE plane, cudaStream_t stream); 86 | virtual RGY_ERR run_per_plane(RGYFrameInfo *ppOutputFrames, const RGYFrameInfo *pInputFrame, cudaStream_t stream); 87 | virtual RGY_ERR run_planes(RGYFrameInfo *ppOutputFrames, const RGYFrameInfo *pInputFrame, cudaStream_t stream); 88 | 89 | #if ENABLE_NVRTC 90 | jitify::JitCache m_kernel_cache; 91 | unique_ptr m_program; 92 | #endif //#if ENABLE_NVRTC 93 | }; 94 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterD3D11.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #ifndef __NVENC_FILTER_D3D11_H__ 30 | #define __NVENC_FILTER_D3D11_H__ 31 | 32 | #include 33 | #include "rgy_version.h" 34 | #include "convert_csp.h" 35 | 36 | class DeviceDX11; 37 | struct ID3D11Texture2D; 38 | struct ID3D11ShaderResourceView; 39 | 40 | #if ENABLE_D3D11 41 | enum DXGI_FORMAT; 42 | 43 | class CUDADX11Texture { 44 | public: 45 | CUDADX11Texture(); 46 | ~CUDADX11Texture(); 47 | RGY_ERR create(DeviceDX11 *dx11, const int width, const int height, const DXGI_FORMAT format); 48 | RGY_ERR registerTexture(); 49 | RGY_ERR map(); 50 | RGY_ERR unmap(); 51 | cudaArray *getMappedArray(); 52 | RGY_ERR unregisterTexture(); 53 | 54 | RGY_ERR release(); 55 | int width() const { return m_width; } 56 | int height() const { return m_height; } 57 | int pitch() const { return m_pitch; } 58 | int offsetInShader() const { return m_offsetInShader; } 59 | ID3D11Texture2D *texture() const { return m_pTexture; } 60 | 61 | DXGI_FORMAT getTextureDXGIFormat() const; 62 | int getTextureBytePerPix() const; 63 | protected: 64 | ID3D11Texture2D *m_pTexture; 65 | ID3D11ShaderResourceView *m_pSRView; 66 | cudaGraphicsResource *m_cudaResource; 67 | cudaArray *m_cuArray; 68 | int m_width; 69 | int m_height; 70 | int m_pitch; 71 | DXGI_FORMAT m_dxgiFormat; 72 | int m_offsetInShader; 73 | }; 74 | 75 | #endif //#if ENABLE_D3D11 76 | 77 | #endif //#ifndef __NVENC_FILTER_D3D11_H__ -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterDeband.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include "NVEncFilter.h" 32 | #include "rgy_prm.h" 33 | 34 | class NVEncFilterParamDeband : public NVEncFilterParam { 35 | public: 36 | VppDeband deband; 37 | 38 | NVEncFilterParamDeband() : deband() { 39 | 40 | }; 41 | virtual ~NVEncFilterParamDeband() {}; 42 | virtual tstring print() const override; 43 | }; 44 | 45 | class NVEncFilterDeband : public NVEncFilter { 46 | public: 47 | NVEncFilterDeband(); 48 | virtual ~NVEncFilterDeband(); 49 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 50 | protected: 51 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 52 | virtual void close() override; 53 | 54 | RGY_ERR deband(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, cudaStream_t stream); 55 | 56 | CUFrameBuf m_RandY; 57 | CUFrameBuf m_RandUV; 58 | CUMemBuf m_RandState; 59 | }; 60 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterDenoiseDct.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include "NVEncFilter.h" 32 | #include "rgy_prm.h" 33 | 34 | class NVEncFilterParamDenoiseDct : public NVEncFilterParam { 35 | public: 36 | VppDenoiseDct dct; 37 | 38 | NVEncFilterParamDenoiseDct() : dct() { 39 | 40 | }; 41 | virtual ~NVEncFilterParamDenoiseDct() {}; 42 | virtual tstring print() const override; 43 | }; 44 | 45 | class NVEncFilterDenoiseDct : public NVEncFilter { 46 | public: 47 | NVEncFilterDenoiseDct(); 48 | virtual ~NVEncFilterDenoiseDct(); 49 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 50 | protected: 51 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 52 | virtual void close() override; 53 | RGY_ERR checkParam(const NVEncFilterParamDenoiseDct *prm); 54 | 55 | RGY_ERR denoise(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, cudaStream_t stream); 56 | RGY_ERR colorCorrelation(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, cudaStream_t stream); 57 | RGY_ERR colorDecorrelation(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, cudaStream_t stream); 58 | 59 | 60 | bool m_bInterlacedWarn; 61 | float m_threshold; 62 | int m_step; 63 | 64 | std::unique_ptr m_srcCrop; 65 | std::unique_ptr m_dstCrop; 66 | std::array, 2> m_bufImg; 67 | }; 68 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterDenoiseKnn.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include "NVEncFilter.h" 32 | #include "rgy_prm.h" 33 | 34 | class NVEncFilterParamDenoiseKnn : public NVEncFilterParam { 35 | public: 36 | VppKnn knn; 37 | 38 | NVEncFilterParamDenoiseKnn() : knn() { 39 | 40 | }; 41 | virtual ~NVEncFilterParamDenoiseKnn() {}; 42 | virtual tstring print() const override; 43 | }; 44 | 45 | class NVEncFilterDenoiseKnn : public NVEncFilter { 46 | public: 47 | NVEncFilterDenoiseKnn(); 48 | virtual ~NVEncFilterDenoiseKnn(); 49 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 50 | protected: 51 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 52 | virtual void close() override; 53 | bool m_bInterlacedWarn; 54 | }; 55 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterDenoiseNLMeans.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include "NVEncFilter.h" 32 | #include "rgy_prm.h" 33 | #include 34 | 35 | #if (defined(WIN32) || defined(WIN64)) && defined(_M_IX86) 36 | #define ENABLE_VPP_NLMEANS 0 37 | #else 38 | #define ENABLE_VPP_NLMEANS 1 39 | #endif 40 | 41 | // dxdyのペアを何並列で同時計算するか 42 | static const int RGY_NLMEANS_DXDY_STEP = 8; 43 | 44 | class NVEncFilterParamDenoiseNLMeans : public NVEncFilterParam { 45 | public: 46 | std::pair compute_capability; 47 | VppNLMeans nlmeans; 48 | 49 | NVEncFilterParamDenoiseNLMeans() : compute_capability(), nlmeans() { 50 | 51 | }; 52 | virtual ~NVEncFilterParamDenoiseNLMeans() {}; 53 | virtual tstring print() const override; 54 | }; 55 | 56 | class NVEncFilterDenoiseNLMeans : public NVEncFilter { 57 | public: 58 | NVEncFilterDenoiseNLMeans(); 59 | virtual ~NVEncFilterDenoiseNLMeans(); 60 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 61 | protected: 62 | #if ENABLE_VPP_NLMEANS 63 | RGY_ERR denoisePlane( 64 | RGYFrameInfo *pOutputPlane, 65 | RGYFrameInfo *pTmpUPlane, RGYFrameInfo *pTmpVPlane, 66 | RGYFrameInfo *pTmpIWPlane, 67 | const RGYFrameInfo *pInputPlane, 68 | cudaStream_t stream); 69 | RGY_ERR denoiseFrame(RGYFrameInfo *pOutputFrame, const RGYFrameInfo *pInputFrame, cudaStream_t stream); 70 | #endif 71 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 72 | virtual void close() override; 73 | std::array, 2 + 1 + RGY_NLMEANS_DXDY_STEP> m_tmpBuf; 74 | }; 75 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterDenoisePmd.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include "NVEncFilter.h" 32 | #include "rgy_prm.h" 33 | 34 | class NVEncFilterParamDenoisePmd : public NVEncFilterParam { 35 | public: 36 | VppPmd pmd; 37 | 38 | NVEncFilterParamDenoisePmd() : pmd() { 39 | 40 | }; 41 | virtual ~NVEncFilterParamDenoisePmd() {}; 42 | virtual tstring print() const override; 43 | }; 44 | 45 | class NVEncFilterDenoisePmd : public NVEncFilter { 46 | public: 47 | NVEncFilterDenoisePmd(); 48 | virtual ~NVEncFilterDenoisePmd(); 49 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 50 | protected: 51 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 52 | virtual void close() override; 53 | 54 | RGY_ERR denoise(RGYFrameInfo *pOutputFrame[2], RGYFrameInfo *pGauss, const RGYFrameInfo *pInputFrame, cudaStream_t stream); 55 | 56 | bool m_bInterlacedWarn; 57 | CUFrameBuf m_Gauss; 58 | }; 59 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterEdgelevel.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include "NVEncFilter.h" 32 | #include "rgy_prm.h" 33 | 34 | class NVEncFilterParamEdgelevel : public NVEncFilterParam { 35 | public: 36 | VppEdgelevel edgelevel; 37 | 38 | NVEncFilterParamEdgelevel() : edgelevel() {}; 39 | virtual ~NVEncFilterParamEdgelevel() {}; 40 | virtual tstring print() const override; 41 | }; 42 | 43 | class NVEncFilterEdgelevel : public NVEncFilter { 44 | public: 45 | NVEncFilterEdgelevel(); 46 | virtual ~NVEncFilterEdgelevel(); 47 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 48 | protected: 49 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 50 | virtual void close() override; 51 | }; 52 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterNnedi.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include "NVEncFilter.h" 32 | #include "rgy_prm.h" 33 | 34 | enum NnediTargetField { 35 | NNEDI_GEN_FIELD_UNKNOWN = -1, 36 | NNEDI_GEN_FIELD_TOP = 0, 37 | NNEDI_GEN_FIELD_BOTTOM 38 | }; 39 | 40 | class NVEncFilterParamNnedi : public NVEncFilterParam { 41 | public: 42 | VppNnedi nnedi; 43 | std::pair compute_capability; 44 | HMODULE hModule; 45 | rgy_rational timebase; 46 | 47 | NVEncFilterParamNnedi() : nnedi(), compute_capability(std::make_pair(0, 0)), hModule(NULL), timebase() {}; 48 | virtual ~NVEncFilterParamNnedi() {}; 49 | virtual tstring print() const override; 50 | }; 51 | 52 | class NVEncFilterNnedi : public NVEncFilter { 53 | public: 54 | static const int weight_loop_1; 55 | static const int sizeNX[]; 56 | static const int sizeNY[]; 57 | static const int sizeNN[]; 58 | static const int maxVal = 65535 >> 8; 59 | public: 60 | NVEncFilterNnedi(); 61 | virtual ~NVEncFilterNnedi(); 62 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 63 | protected: 64 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 65 | virtual void close() override; 66 | virtual RGY_ERR checkParam(const std::shared_ptr pParam); 67 | virtual RGY_ERR initParams(const std::shared_ptr pNnediParam); 68 | void setBobTimestamp(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames); 69 | 70 | template 71 | void setWeight0(TypeWeight *ptrDst, const float *ptrW, const std::shared_ptr pNnediParam); 72 | 73 | template 74 | void setWeight1(TypeWeight *ptrDst, const float *ptrW, const std::shared_ptr pNnediParam); 75 | virtual shared_ptr readWeights(const tstring& weightFile, HMODULE hModule); 76 | 77 | CUMemBuf m_weight0; 78 | std::array m_weight1; 79 | }; 80 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterSmooth.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2020 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include 32 | #include "NVEncFilter.h" 33 | #include "rgy_prm.h" 34 | 35 | static const int VPP_SMOOTH_MAX_QUALITY_LEVEL = 6; 36 | 37 | class NVEncFilterParamSmooth : public NVEncFilterParam { 38 | public: 39 | VppSmooth smooth; 40 | std::pair compute_capability; 41 | RGYListRef *qpTableRef; 42 | 43 | NVEncFilterParamSmooth() : smooth(), compute_capability(), qpTableRef(nullptr) { 44 | 45 | }; 46 | virtual ~NVEncFilterParamSmooth() {}; 47 | virtual tstring print() const override; 48 | }; 49 | 50 | class NVEncFilterSmooth : public NVEncFilter { 51 | public: 52 | NVEncFilterSmooth(); 53 | virtual ~NVEncFilterSmooth(); 54 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 55 | protected: 56 | int qp_size(int res) { return divCeil(res + 15, 16); } 57 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 58 | virtual void close() override; 59 | RGY_ERR check_param(shared_ptr prmYadif); 60 | float getQPMul(int qp_scale); 61 | 62 | std::unique_ptr m_qp; 63 | std::shared_ptr m_qpSrc; 64 | std::shared_ptr m_qpSrcB; 65 | RGYListRef *m_qpTableRef; 66 | int m_qpTableErrCount; 67 | }; 68 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterTweak.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include "NVEncFilter.h" 32 | #include "rgy_prm.h" 33 | 34 | class NVEncFilterParamTweak : public NVEncFilterParam { 35 | public: 36 | VppTweak tweak; 37 | VideoVUIInfo vui; 38 | 39 | NVEncFilterParamTweak() : tweak(), vui() {}; 40 | virtual ~NVEncFilterParamTweak() {}; 41 | virtual tstring print() const override; 42 | }; 43 | 44 | class NVEncFilterTweak : public NVEncFilter { 45 | public: 46 | NVEncFilterTweak(); 47 | virtual ~NVEncFilterTweak(); 48 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 49 | protected: 50 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 51 | virtual void close() override; 52 | 53 | std::unique_ptr m_convA; 54 | std::unique_ptr m_convB; 55 | std::unique_ptr m_convC; 56 | }; 57 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterUnsharp.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include "NVEncFilter.h" 32 | #include "rgy_prm.h" 33 | 34 | class NVEncFilterParamUnsharp : public NVEncFilterParam { 35 | public: 36 | VppUnsharp unsharp; 37 | 38 | NVEncFilterParamUnsharp() : unsharp() {}; 39 | virtual ~NVEncFilterParamUnsharp() {}; 40 | virtual tstring print() const override; 41 | }; 42 | 43 | class NVEncFilterUnsharp : public NVEncFilter { 44 | public: 45 | NVEncFilterUnsharp(); 46 | virtual ~NVEncFilterUnsharp(); 47 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 48 | protected: 49 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 50 | RGY_ERR setWeight(unique_ptr& m_pGaussWeightBuf, int radius, float sigma); 51 | virtual void close() override; 52 | 53 | bool m_bInterlacedWarn; 54 | unique_ptr m_pGaussWeightBufY; 55 | unique_ptr m_pGaussWeightBufUV; 56 | }; 57 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterVulkan.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // VCEEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2021 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // IABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // ------------------------------------------------------------------------------------------ 27 | 28 | #pragma once 29 | #ifndef __NVENC_FILTER_VULKAN_H__ 30 | #define __NVENC_FILTER_VULKAN_H__ 31 | 32 | class DeviceVulkan; 33 | 34 | #include "rgy_version.h" 35 | #if ENABLE_VULKAN 36 | #include "rgy_vulkan.h" 37 | #include "rgy_err.h" 38 | 39 | class DeviceVulkan; 40 | 41 | class CUDAVulkanFrame { 42 | DeviceVulkan *m_vk; 43 | 44 | VkFormat m_format; 45 | VkBufferUsageFlags m_usage; 46 | VkImage m_image; 47 | VkDeviceMemory m_bufferMemory; 48 | 49 | cudaExternalMemory_t m_cudaMem; 50 | cudaArray *m_cudaArray; 51 | cudaMipmappedArray *m_cudaMipmappedArray; 52 | 53 | int m_width; 54 | int m_height; 55 | int m_pitch; 56 | uint64_t m_bufferSize; 57 | public: 58 | CUDAVulkanFrame(); 59 | ~CUDAVulkanFrame(); 60 | RGY_ERR create(DeviceVulkan *vk, const int width, const int height, const VkFormat dataType); 61 | RGY_ERR registerTexture(); 62 | RGY_ERR unregisterTexture(); 63 | cudaArray *getMappedArray() { return m_cudaArray; } 64 | 65 | VkImage image() { return m_image; } 66 | VkFormat format() const { return m_format; } 67 | VkBufferUsageFlags usage() const { return m_usage; } 68 | 69 | void release(); 70 | 71 | int width() const { return m_width; } 72 | int height() const { return m_height; } 73 | int pitch() const { return m_pitch; } 74 | int getTextureBytePerPix() const; 75 | protected: 76 | VkExternalMemoryHandleTypeFlagBits getDefaultMemHandleType() const; 77 | RGY_ERR importCudaExternalMemory(VkExternalMemoryHandleTypeFlagBits handleType); 78 | void *getMemHandle(VkExternalMemoryHandleTypeFlagBits handleType); 79 | uint32_t findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties); 80 | }; 81 | 82 | class CUDAVulkanSemaphore { 83 | DeviceVulkan *m_vk; 84 | VkSemaphore m_semaphore; 85 | cudaExternalSemaphore_t m_cudaSem; 86 | uint64_t m_waitValue; 87 | uint64_t m_signalValue; 88 | public: 89 | CUDAVulkanSemaphore(); 90 | ~CUDAVulkanSemaphore(); 91 | RGY_ERR create(DeviceVulkan *vk); 92 | void release(); 93 | RGY_ERR wait(cudaStream_t stream); 94 | RGY_ERR signal(cudaStream_t stream); 95 | VkSemaphore get() { return m_semaphore; } 96 | protected: 97 | VkExternalSemaphoreHandleTypeFlagBits getDefaultSemaphoreHandleType() const; 98 | RGY_ERR importCudaExternalSemaphore(VkExternalSemaphoreHandleTypeFlagBits handleType); 99 | void *getSemaphoreHandle(VkExternalSemaphoreHandleTypeFlagBits handleType); 100 | }; 101 | 102 | 103 | #endif //#if ENABLE_VULKAN 104 | 105 | #endif //#ifndef __NVENC_FILTER_VULKAN_H__ 106 | -------------------------------------------------------------------------------- /cufilters_common/NVEncFilterWarpsharp.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | 31 | #include "NVEncFilter.h" 32 | #include "rgy_prm.h" 33 | 34 | class NVEncFilterParamWarpsharp : public NVEncFilterParam { 35 | public: 36 | VppWarpsharp warpsharp; 37 | 38 | NVEncFilterParamWarpsharp() : warpsharp() {}; 39 | virtual ~NVEncFilterParamWarpsharp() {}; 40 | virtual tstring print() const override; 41 | }; 42 | 43 | class NVEncFilterWarpsharp : public NVEncFilter { 44 | public: 45 | NVEncFilterWarpsharp(); 46 | virtual ~NVEncFilterWarpsharp(); 47 | virtual RGY_ERR init(shared_ptr pParam, shared_ptr pPrintMes) override; 48 | protected: 49 | RGY_ERR checkParam(const std::shared_ptr prm); 50 | virtual RGY_ERR run_filter(const RGYFrameInfo *pInputFrame, RGYFrameInfo **ppOutputFrames, int *pOutputFrameNum, cudaStream_t stream) override; 51 | virtual void close() override; 52 | std::array m_mask; 53 | }; 54 | -------------------------------------------------------------------------------- /cufilters_common/NVEncNVSDKNGX.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2024 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // ------------------------------------------------------------------------------------------- 27 | #pragma once 28 | #ifndef _NVENC_NVSDKNGX_H__ 29 | #define _NVENC_NVSDKNGX_H__ 30 | 31 | #include "rgy_err.h" 32 | 33 | #if defined(_WIN32) || defined(_WIN64) 34 | #ifdef NVENC_NVSDKNGX_EXPORTS 35 | #define NVENC_NVSDKNGX_API __declspec(dllexport) 36 | #else 37 | #define NVENC_NVSDKNGX_API __declspec(dllimport) 38 | #endif 39 | #else 40 | #define NVENC_NVSDKNGX_API 41 | #endif 42 | 43 | struct ID3D11Device; 44 | struct ID3D11DeviceContext; 45 | struct ID3D11Texture2D; 46 | 47 | #if defined(__cplusplus) 48 | extern "C" { 49 | #endif /* __cplusplus */ 50 | 51 | #if defined(_WIN32) || defined(_WIN64) 52 | static const TCHAR * NVENC_NVSDKNGX_MODULENAME = _T("NVEncNVSDKNGX.dll"); 53 | #else 54 | static const TCHAR * NVENC_NVSDKNGX_MODULENAME = _T("NVEncNVSDKNGX.so"); 55 | #endif 56 | 57 | enum NVEncNVSDKNGXFeature { 58 | NVSDK_NVX_NA = 0, 59 | NVSDK_NVX_VSR, 60 | NVSDK_NVX_TRUEHDR, 61 | NVSDK_NVX_MAX, 62 | }; 63 | 64 | typedef void * NVEncNVSDKNGXHandle; 65 | typedef void * NVEncNVSDKNGXParam; 66 | 67 | typedef struct { 68 | int left; 69 | int top; 70 | int right; 71 | int bottom; 72 | } NVEncNVSDKNGXRect; 73 | 74 | typedef struct { 75 | int quality; 76 | } NVEncNVSDKNGXParamVSR; 77 | 78 | typedef struct { 79 | uint32_t contrast; 80 | uint32_t saturation; 81 | uint32_t middleGray; 82 | uint32_t maxLuminance; 83 | } NVEncNVSDKNGXParamTrueHDR; 84 | 85 | NVENC_NVSDKNGX_API RGY_ERR __stdcall NVEncNVSDKNGXCreate(NVEncNVSDKNGXHandle *ppNVSDKNGX, const NVEncNVSDKNGXFeature feature); 86 | NVENC_NVSDKNGX_API RGY_ERR __stdcall NVEncNVSDKNGXInit(NVEncNVSDKNGXHandle pNVSDKNGX, ID3D11Device* pD3DDevice, ID3D11DeviceContext* pD3D11DeviceContext); 87 | NVENC_NVSDKNGX_API void __stdcall NVEncNVSDKNGXDelete(NVEncNVSDKNGXHandle pNVSDKNGX); 88 | NVENC_NVSDKNGX_API RGY_ERR __stdcall NVEncNVSDKNGXProcFrame(NVEncNVSDKNGXHandle pNVSDKNGX, ID3D11Texture2D* frameDst, const NVEncNVSDKNGXRect *rectDst, ID3D11Texture2D* frameSrc, const NVEncNVSDKNGXRect *rectSrc, const NVEncNVSDKNGXParam *param); 89 | 90 | #if defined(__cplusplus) 91 | } 92 | #endif /* __cplusplus */ 93 | 94 | static const TCHAR *NVENC_NVSDKNGX_DLL_NAME[] = { 95 | _T(""), 96 | _T("nvngx_vsr.dll"), 97 | _T("nvngx_truehdr.dll") 98 | }; 99 | 100 | static_assert(_countof(NVENC_NVSDKNGX_DLL_NAME) == NVSDK_NVX_MAX, "NVENC_NVSDKNGX_DLL_NAME size mismatch"); 101 | 102 | #endif //#ifndef _NVENC_NVSDKNGX_H__ -------------------------------------------------------------------------------- /cufilters_common/cufilters_common.cpp: -------------------------------------------------------------------------------- 1 | // cufilters_common.cpp : スタティック ライブラリ用の関数を定義します。 2 | // 3 | 4 | #include "pch.h" 5 | #include "framework.h" 6 | 7 | // TODO: これは、ライブラリ関数の例です 8 | void fncufilterscommon() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /cufilters_common/rgy_nvrtc.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2011-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #include "rgy_tchar.h" 30 | #include "rgy_osdep.h" 31 | #define NVRTC_EXTERN 32 | #include "rgy_nvrtc.h" 33 | 34 | extern const TCHAR *NVRTC_DLL_NAME_TSTR; 35 | extern const TCHAR *NVRTC_BUILTIN_DLL_NAME_TSTR; 36 | 37 | static HMODULE nvrtcHandle = nullptr; 38 | 39 | int initNVRTCGlobal() { 40 | if (nvrtcHandle) { 41 | return 0; 42 | } 43 | if ((nvrtcHandle = RGY_LOAD_LIBRARY(NVRTC_DLL_NAME_TSTR)) == nullptr) { 44 | return 1; 45 | } 46 | 47 | #define LOAD(name) \ 48 | f_##name = (decltype(f_##name)) RGY_GET_PROC_ADDRESS(nvrtcHandle, #name); \ 49 | if (f_##name == nullptr) { \ 50 | RGY_FREE_LIBRARY(nvrtcHandle); \ 51 | nvrtcHandle = nullptr; \ 52 | return 1; \ 53 | } 54 | 55 | LOAD(nvrtcGetErrorString); 56 | LOAD(nvrtcVersion); 57 | LOAD(nvrtcCreateProgram); 58 | LOAD(nvrtcDestroyProgram); 59 | LOAD(nvrtcCompileProgram); 60 | LOAD(nvrtcGetPTXSize); 61 | LOAD(nvrtcGetPTX); 62 | LOAD(nvrtcGetProgramLogSize); 63 | LOAD(nvrtcGetProgramLog); 64 | LOAD(nvrtcAddNameExpression); 65 | LOAD(nvrtcGetLoweredName); 66 | 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /cufilters_common/rgy_nvrtc.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2011-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #pragma once 30 | #ifndef __RGY_NVRTC_H__ 31 | #define __RGY_NVRTC_H__ 32 | 33 | #include "rgy_osdep.h" 34 | #include 35 | 36 | #ifndef NVRTC_EXTERN 37 | #define NVRTC_EXTERN extern 38 | #endif 39 | 40 | #if defined(_WIN32) 41 | #define NVRTC_API_ENTRY 42 | #define NVRTC_API_CALL __stdcall 43 | #define NVRTC_CALLBACK __stdcall 44 | #else 45 | #define NVRTC_API_ENTRY 46 | #define NVRTC_API_CALL 47 | #define NVRTC_CALLBACK 48 | #endif 49 | 50 | NVRTC_EXTERN const char *(NVRTC_API_CALL* f_nvrtcGetErrorString)(nvrtcResult result); 51 | NVRTC_EXTERN nvrtcResult (NVRTC_API_CALL* f_nvrtcVersion)(int *major, int *minor); 52 | NVRTC_EXTERN nvrtcResult (NVRTC_API_CALL* f_nvrtcCreateProgram)(nvrtcProgram *prog, const char *src, const char *name, int numHeaders, const char * const *headers, const char * const *includeNames); 53 | NVRTC_EXTERN nvrtcResult (NVRTC_API_CALL* f_nvrtcDestroyProgram)(nvrtcProgram *prog); 54 | NVRTC_EXTERN nvrtcResult (NVRTC_API_CALL* f_nvrtcCompileProgram)(nvrtcProgram prog, int numOptions, const char * const *options); 55 | NVRTC_EXTERN nvrtcResult (NVRTC_API_CALL* f_nvrtcGetPTXSize)(nvrtcProgram prog, size_t *ptxSizeRet); 56 | NVRTC_EXTERN nvrtcResult (NVRTC_API_CALL* f_nvrtcGetPTX)(nvrtcProgram prog, char *ptx); 57 | NVRTC_EXTERN nvrtcResult (NVRTC_API_CALL* f_nvrtcGetProgramLogSize)(nvrtcProgram prog, size_t *logSizeRet); 58 | NVRTC_EXTERN nvrtcResult (NVRTC_API_CALL* f_nvrtcGetProgramLog)(nvrtcProgram prog, char *log); 59 | NVRTC_EXTERN nvrtcResult (NVRTC_API_CALL* f_nvrtcAddNameExpression)(nvrtcProgram prog, const char * const name_expression); 60 | NVRTC_EXTERN nvrtcResult (NVRTC_API_CALL* f_nvrtcGetLoweredName)(nvrtcProgram prog, const char *const name_expression, const char** lowered_name); 61 | 62 | #define nvrtcGetErrorString f_nvrtcGetErrorString 63 | #define nvrtcVersion f_nvrtcVersion 64 | #define nvrtcCreateProgram f_nvrtcCreateProgram 65 | #define nvrtcDestroyProgram f_nvrtcDestroyProgram 66 | #define nvrtcCompileProgram f_nvrtcCompileProgram 67 | #define nvrtcGetPTXSize f_nvrtcGetPTXSize 68 | #define nvrtcGetPTX f_nvrtcGetPTX 69 | #define nvrtcGetProgramLogSize f_nvrtcGetProgramLogSize 70 | #define nvrtcGetProgramLog f_nvrtcGetProgramLog 71 | #define nvrtcAddNameExpression f_nvrtcAddNameExpression 72 | #define nvrtcGetLoweredName f_nvrtcGetLoweredName 73 | 74 | int initNVRTCGlobal(); 75 | 76 | #endif //__RGY_NVRTC_H__ 77 | -------------------------------------------------------------------------------- /cufilters_exe/cufilters_exe.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // clfilters by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2024 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #ifndef __CUFILTERS_EXE_H__ 30 | #define __CUFILTERS_EXE_H__ 31 | 32 | #include "clcufilters_exe.h" 33 | 34 | class cuFiltersExe : public clcuFiltersExe { 35 | public: 36 | cuFiltersExe(); 37 | virtual ~cuFiltersExe(); 38 | virtual RGY_ERR initDevices() override; 39 | virtual std::string checkDevices() override; 40 | virtual bool isCUDA() const override { return true; } 41 | protected: 42 | std::string checkCUDADevices(); 43 | virtual RGY_ERR initDevice(const clfitersSharedPrms *sharedPrms, clFilterChainParam& prm) override; 44 | }; 45 | 46 | #endif // !__CUFILTERS_EXE_H__ 47 | -------------------------------------------------------------------------------- /cufilters_exe/cufilters_exe.rc: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // clfilters by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2022 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #include 30 | #include "clcufilters_version.h" 31 | 32 | NNEDI_WEIGHTBIN EXE_DATA DISCARDABLE "..\\resource\\nnedi3_weights.bin" 33 | NVENC_FILTER_COLRSPACE_FUNC_HEADER EXE_DATA DISCARDABLE "..\\cufilters_common\\NVEncFilterColorspaceFunc.h" 34 | 35 | 36 | // 37 | // Version Information 38 | // 39 | 40 | 41 | VS_VERSION_INFO VERSIONINFO 42 | FILEVERSION VER_FILEVERSION 43 | PRODUCTVERSION VER_PRODUCTVERSION 44 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 45 | FILEFLAGS ( VER_DEBUG | VER_PRIVATE ) 46 | FILEOS VOS_NT_WINDOWS32 47 | FILETYPE VFT_DLL 48 | FILESUBTYPE VFT_APP 49 | BEGIN 50 | BLOCK "VarFileInfo" 51 | BEGIN 52 | VALUE "Translation", 0x411, 1200 53 | END 54 | 55 | BLOCK "StringFileInfo" 56 | BEGIN 57 | BLOCK "041104b0" 58 | BEGIN 59 | VALUE "Comments", VER_STR_COMMENTS 60 | VALUE "CompanyName", VER_STR_COMPANYNAME 61 | VALUE "FileDescription", VER_STR_FILEDESCRIPTION 62 | VALUE "FileVersion", VER_STR_FILEVERSION 63 | VALUE "InternalName", VER_STR_INTERNALNAME 64 | VALUE "OriginalFileName", VER_STR_ORIGINALFILENAME 65 | VALUE "LegalCopyright", VER_STR_LEGALCOPYRIGHT 66 | VALUE "ProductName", VER_STR_PRODUCTNAME 67 | VALUE "ProductVersion", VER_STR_PRODUCTVERSION 68 | END 69 | END 70 | END 71 | -------------------------------------------------------------------------------- /cufilters_exe/cufilters_exe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | ソース ファイル 20 | 21 | 22 | ソース ファイル 23 | 24 | 25 | 26 | 27 | ヘッダー ファイル 28 | 29 | 30 | ヘッダー ファイル 31 | 32 | 33 | 34 | 35 | リソース ファイル 36 | 37 | 38 | -------------------------------------------------------------------------------- /data/clcufilters_image.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigaya/Aviutl-clcufilters/e59336bd97c20a501feb7ec6aa77a0039efc73aa/data/clcufilters_image.webp -------------------------------------------------------------------------------- /data/clcufilters_install.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigaya/Aviutl-clcufilters/e59336bd97c20a501feb7ec6aa77a0039efc73aa/data/clcufilters_install.webp -------------------------------------------------------------------------------- /data/clcufilters_params.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigaya/Aviutl-clcufilters/e59336bd97c20a501feb7ec6aa77a0039efc73aa/data/clcufilters_params.png -------------------------------------------------------------------------------- /data/clcufilters_select_device.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigaya/Aviutl-clcufilters/e59336bd97c20a501feb7ec6aa77a0039efc73aa/data/clcufilters_select_device.png -------------------------------------------------------------------------------- /data/clfilters_filter_order.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigaya/Aviutl-clcufilters/e59336bd97c20a501feb7ec6aa77a0039efc73aa/data/clfilters_filter_order.png -------------------------------------------------------------------------------- /data/gpuz_opencl_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigaya/Aviutl-clcufilters/e59336bd97c20a501feb7ec6aa77a0039efc73aa/data/gpuz_opencl_check.png -------------------------------------------------------------------------------- /data/powered-by-nvidia-broadcast-lockup-rgb-blk-for-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigaya/Aviutl-clcufilters/e59336bd97c20a501feb7ec6aa77a0039efc73aa/data/powered-by-nvidia-broadcast-lockup-rgb-blk-for-screen.png -------------------------------------------------------------------------------- /filter_core/convert_csp_func.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // ------------------------------------------------------------------------------------------ 27 | 28 | #ifndef _CONVERT_CSP_FUNC_H_ 29 | #define _CONVERT_CSP_FUNC_H_ 30 | 31 | #include 32 | #include 33 | #include 34 | #include "rgy_osdep.h" 35 | #include "convert_csp.h" 36 | #include "rgy_thread_affinity.h" 37 | #include "rgy_util.h" 38 | 39 | struct RGYConvertCSPPrm { 40 | bool abort; 41 | void **dst; 42 | const void **src; 43 | int interlaced; 44 | int width; 45 | int src_y_pitch_byte; 46 | int src_uv_pitch_byte; 47 | int dst_y_pitch_byte; 48 | int height; 49 | int dst_height; 50 | int *crop; 51 | 52 | RGYConvertCSPPrm(); 53 | }; 54 | 55 | class RGYConvertCSP { 56 | private: 57 | const ConvertCSP *m_csp; 58 | RGY_CSP m_csp_from; 59 | RGY_CSP m_csp_to; 60 | bool m_uv_only; 61 | int m_threads; 62 | std::vector m_th; 63 | std::vector> m_heStart; 64 | std::vector> m_heFin; 65 | std::vector m_heFinCopy; 66 | RGYParamThread m_threadParam; 67 | RGYConvertCSPPrm m_prm; 68 | public: 69 | RGYConvertCSP(); 70 | RGYConvertCSP(int threads, RGYParamThread threadParam); 71 | ~RGYConvertCSP(); 72 | const ConvertCSP *getFunc(RGY_CSP csp_from, RGY_CSP csp_to, bool uv_only, RGY_SIMD simd); 73 | const ConvertCSP *getFunc() const { return m_csp; }; 74 | 75 | int run(int interlaced, void **dst, const void **src, int width, int src_y_pitch_byte, int src_uv_pitch_byte, int dst_y_pitch_byte, int height, int dst_height, int *crop); 76 | }; 77 | 78 | #endif //_CONVERT_CSP_FUNC_H_ 79 | -------------------------------------------------------------------------------- /filter_core/gpu_info.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2011-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #ifndef _GPU_INFO_H_ 30 | #define _GPU_INFO_H_ 31 | 32 | #include "rgy_tchar.h" 33 | 34 | int getGPUInfo(const char *VendorName, TCHAR *buffer, unsigned int buffer_size, int device_id = 0, bool driver_version_only = false); 35 | 36 | #endif //_GPU_INFO_H_ 37 | -------------------------------------------------------------------------------- /filter_core/gpuz_info.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #if (defined(_WIN32) || defined(_WIN64)) 29 | #define WIN32_LEAN_AND_MEAN 30 | #define NOMINMAX 31 | #include 32 | #include "gpuz_info.h" 33 | 34 | //大文字小文字を無視して、1文字検索 35 | static inline const WCHAR *wcsichr(const WCHAR *str, int c) { 36 | c = tolower(c); 37 | for (; *str; str++) 38 | if (c == tolower(*str)) 39 | return str; 40 | return NULL; 41 | } 42 | 43 | //大文字小文字を無視して、文字列を検索 44 | static inline const WCHAR *wcsistr(const WCHAR *str, const WCHAR *substr) { 45 | size_t len = 0; 46 | if (substr && (len = wcslen(substr)) != NULL) 47 | for (; (str = wcsichr(str, substr[0])) != NULL; str++) 48 | if (_wcsnicmp(str, substr, len) == NULL) 49 | return str; 50 | return NULL; 51 | } 52 | 53 | int get_gpuz_info(GPUZ_SH_MEM *data) { 54 | HANDLE memmap = OpenFileMapping(FILE_MAP_READ, FALSE, SHMEM_NAME); 55 | if (NULL == memmap) { 56 | return 1; 57 | } 58 | 59 | GPUZ_SH_MEM *ptr = (GPUZ_SH_MEM *)MapViewOfFile(memmap, FILE_MAP_READ, 0, 0, 0); 60 | if (ptr == nullptr) { 61 | CloseHandle(memmap); 62 | return 1; 63 | } 64 | memcpy(data, ptr, sizeof(data[0])); 65 | UnmapViewOfFile(ptr); 66 | CloseHandle(memmap); 67 | return 0; 68 | } 69 | 70 | double gpu_core_clock(GPUZ_SH_MEM *data) { 71 | for (int i = 0; i < MAX_RECORDS; i++) { 72 | if ( wcsistr(data->sensors[i].name, L"Core") 73 | && wcsistr(data->sensors[i].name, L"Clock")) { 74 | return data->sensors[i].value; 75 | } 76 | } 77 | return 0.0; 78 | } 79 | 80 | double gpu_load(GPUZ_SH_MEM *data) { 81 | for (int i = 0; i < MAX_RECORDS; i++) { 82 | if (wcsistr(data->sensors[i].name, L"GPU Load")) { 83 | return data->sensors[i].value; 84 | } 85 | } 86 | return 0.0; 87 | } 88 | 89 | double video_engine_load(GPUZ_SH_MEM *data, bool *pbVideoEngineUsage) { 90 | for (int i = 0; i < MAX_RECORDS; i++) { 91 | if (wcsistr(data->sensors[i].name, L"Video Engine Load")) { 92 | if (pbVideoEngineUsage) *pbVideoEngineUsage = true; 93 | return data->sensors[i].value; 94 | } 95 | } 96 | if (pbVideoEngineUsage) *pbVideoEngineUsage = false; 97 | return 0.0; 98 | } 99 | 100 | #endif //#if (defined(_WIN32) || defined(_WIN64)) 101 | -------------------------------------------------------------------------------- /filter_core/gpuz_info.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #ifndef __GPUZ_INFO_H__ 29 | #define __GPUZ_INFO_H__ 30 | 31 | #if (defined(_WIN32) || defined(_WIN64)) 32 | #include 33 | #include 34 | 35 | #define ENABLE_GPUZ_INFO 1 36 | #define SHMEM_NAME _T("GPUZShMem") 37 | #define MAX_RECORDS 128 38 | 39 | #pragma pack(push, 1) 40 | struct GPUZ_RECORD { 41 | WCHAR key[256]; 42 | WCHAR value[256]; 43 | }; 44 | 45 | struct GPUZ_SENSOR_RECORD { 46 | WCHAR name[256]; 47 | WCHAR unit[8]; 48 | UINT32 digits; 49 | double value; 50 | }; 51 | 52 | struct GPUZ_SH_MEM { 53 | UINT32 version; 54 | volatile LONG busy; 55 | UINT32 lastUpdate; 56 | GPUZ_RECORD data[MAX_RECORDS]; 57 | GPUZ_SENSOR_RECORD sensors[MAX_RECORDS]; 58 | }; 59 | #pragma pack(pop) 60 | 61 | int get_gpuz_info(GPUZ_SH_MEM *data); 62 | double gpu_core_clock(GPUZ_SH_MEM *data); 63 | double gpu_load(GPUZ_SH_MEM *data); 64 | double video_engine_load(GPUZ_SH_MEM *data, bool *pbVideoEngineUsage); 65 | 66 | #else 67 | #define ENABLE_GPUZ_INFO 0 68 | #endif //#if (defined(_WIN32) || defined(_WIN64)) 69 | 70 | #endif //__GPUZ_INFO_H__ 71 | -------------------------------------------------------------------------------- /filter_core/rgy_arch.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #pragma once 29 | #ifndef __RGY_ARCH_H__ 30 | #define __RGY_ARCH_H__ 31 | 32 | #if defined(_M_IX86) || defined(_M_X64) || defined(__x86_64) 33 | #include 34 | static inline void rgy_yield() { 35 | _mm_pause(); 36 | } 37 | #if !(defined(_WIN32) || defined(_WIN64)) 38 | static inline void __cpuid(int cpuInfo[4], int param) { 39 | int eax = 0, ebx = 0, ecx = 0, edx = 0; 40 | __asm("xor %%ecx, %%ecx\n\t" 41 | "cpuid" : "=a"(eax), "=b" (ebx), "=c"(ecx), "=d"(edx) 42 | : "0"(param)); 43 | cpuInfo[0] = eax; 44 | cpuInfo[1] = ebx; 45 | cpuInfo[2] = ecx; 46 | cpuInfo[3] = edx; 47 | } 48 | 49 | #ifndef _MSC_VER 50 | static inline unsigned long long rgy_xgetbv(unsigned int index) { 51 | unsigned int eax, edx; 52 | __asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index)); 53 | return ((unsigned long long)edx << 32) | eax; 54 | } 55 | #endif 56 | 57 | #if NO_RDTSCP_INTRIN 58 | static inline uint64_t __rdtscp(uint32_t *Aux) { 59 | uint32_t aux; 60 | uint64_t rax,rdx; 61 | asm volatile ( "rdtscp\n" : "=a" (rax), "=d" (rdx), "=c" (aux) : : ); 62 | *Aux = aux; 63 | return (rdx << 32) + rax; 64 | } 65 | #endif //#if NO_RDTSCP_INTRIN 66 | 67 | //uint64_t __rdtsc() { 68 | // unsigned int eax, edx; 69 | // __asm__ volatile("rdtsc" : "=a"(eax), "=d"(edx)); 70 | // return ((uint64_t)edx << 32) | eax; 71 | //} 72 | #endif //#if !(defined(_WIN32) || defined(_WIN64)) 73 | 74 | #elif (defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64__) || defined(__ARM_ARCH)) 75 | 76 | static inline void rgy_yield() { 77 | __asm__ __volatile__("isb\n"); 78 | } 79 | 80 | #endif 81 | 82 | #endif //__RGY_ARCH_H__ 83 | -------------------------------------------------------------------------------- /filter_core/rgy_codepage.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2019 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // ------------------------------------------------------------------------------------------- 27 | 28 | #pragma once 29 | #ifndef __RGY_CODEPAGE_H__ 30 | #define __RGY_CODEPAGE_H__ 31 | 32 | //日本語環境の一般的なコードページ一覧 33 | enum : uint32_t { 34 | CODE_PAGE_SJIS = 932, //Shift-JIS 35 | CODE_PAGE_JIS = 50220, 36 | CODE_PAGE_EUC_JP = 51932, 37 | CODE_PAGE_UTF8 = 65001, 38 | CODE_PAGE_UTF16_LE = 1200, //WindowsのUnicode WCHAR のコードページ 39 | CODE_PAGE_UTF16_BE = 1201, 40 | CODE_PAGE_US_ASCII = 20127, 41 | CODE_PAGE_WEST_EUROPE = 1252, //厄介な西ヨーロッパ言語 42 | CODE_PAGE_UNSET = 0xffffffff, 43 | }; 44 | 45 | uint32_t get_code_page(const void *str, uint32_t size_in_byte); 46 | const char *codepage_str(uint32_t codepage); 47 | 48 | #endif //__RGY_CODEPAGE_H__ 49 | -------------------------------------------------------------------------------- /filter_core/rgy_def.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #include "rgy_def.h" 29 | #include "rgy_log.h" 30 | 31 | const CX_DESC list_log_level[7] = { 32 | { _T("trace"), RGY_LOG_TRACE }, 33 | { _T("debug"), RGY_LOG_DEBUG }, 34 | { _T("more"), RGY_LOG_MORE }, 35 | { _T("info"), RGY_LOG_INFO }, 36 | { _T("warn"), RGY_LOG_WARN }, 37 | { _T("error"), RGY_LOG_ERROR }, 38 | { NULL, 0 } 39 | }; 40 | 41 | tstring VideoVUIInfo::print_main() const { 42 | return tstring(_T("matrix:")) + get_cx_desc(list_colormatrix, matrix) + _T(",") 43 | + tstring(_T("colorprim:")) + get_cx_desc(list_colorprim, colorprim) + _T(",") 44 | + tstring(_T("transfer:")) + get_cx_desc(list_transfer, transfer); 45 | } 46 | 47 | tstring VideoVUIInfo::print_all(bool write_all) const { 48 | tstring str; 49 | if (write_all || matrix != get_cx_value(list_colormatrix, _T("undef"))) { 50 | str += tstring(_T(",matrix:")) + get_cx_desc(list_colormatrix, matrix); 51 | } 52 | if (write_all || colorprim != get_cx_value(list_colorprim, _T("undef"))) { 53 | str += tstring(_T(",colorprim:")) + get_cx_desc(list_colorprim, colorprim); 54 | } 55 | if (write_all || transfer != get_cx_value(list_transfer, _T("undef"))) { 56 | str += tstring(_T(",transfer:")) + get_cx_desc(list_transfer, transfer); 57 | } 58 | if (write_all || format != get_cx_value(list_videoformat, _T("undef"))) { 59 | str += tstring(_T(",videoformat:")) + get_cx_desc(list_videoformat, format); 60 | } 61 | if (write_all || colorrange != get_cx_value(list_colorrange, _T("undef"))) { 62 | str += tstring(_T(",range:")) + get_cx_desc(list_colorrange, colorrange); 63 | } 64 | if (write_all || chromaloc != get_cx_value(list_chromaloc_str, _T("undef"))) { 65 | str += tstring(_T(",chromaloc:")) + get_cx_desc(list_chromaloc_str, chromaloc); 66 | } 67 | return (str.length() > 1) ? str.substr(1) : str; 68 | } 69 | -------------------------------------------------------------------------------- /filter_core/rgy_env.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #pragma once 29 | #ifndef __RGY_ENV_H__ 30 | #define __RGY_ENV_H__ 31 | 32 | #include 33 | #include 34 | #include 35 | #include "rgy_util.h" 36 | 37 | #if defined(_WIN32) || defined(_WIN64) 38 | tstring getOSVersion(OSVERSIONINFOEXW *osinfo); 39 | tstring getOSVersion(); 40 | #else 41 | tstring getOSVersion(); 42 | #endif 43 | BOOL rgy_is_64bit_os(); 44 | uint64_t getPhysicalRamSize(uint64_t *ramUsed); 45 | tstring getEnviromentInfo(int device_id = 0); 46 | 47 | BOOL check_OS_Win8orLater(); 48 | 49 | #if defined(_WIN32) || defined(_WIN64) 50 | using unique_handle = std::unique_ptr::type, std::function>; 51 | 52 | std::vector createChildProcessIDList(const size_t target_pid); 53 | std::vector createProcessHandleList(const std::vector& list_pid, const wchar_t *handle_type); 54 | #endif 55 | 56 | #endif //__RGY_ENV_H__ 57 | -------------------------------------------------------------------------------- /filter_core/rgy_event.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #pragma once 29 | #ifndef __RGY_EVENT_H__ 30 | #define __RGY_EVENT_H__ 31 | 32 | #include 33 | #include 34 | #include 35 | #include "rgy_osdep.h" 36 | 37 | #if defined(_WIN32) || defined(_WIN64) 38 | #define CloseEvent CloseHandle 39 | #else //#if defined(_WIN32) || defined(_WIN64) 40 | 41 | enum : uint32_t { 42 | WAIT_OBJECT_0 = 0, 43 | WAIT_TIMEOUT = 258L, 44 | WAIT_ABANDONED_0 = 0x00000080L 45 | }; 46 | 47 | #ifndef INFINITE 48 | #define INFINITE (UINT_MAX) 49 | #endif 50 | 51 | void ResetEvent(HANDLE ev); 52 | 53 | void SetEvent(HANDLE ev); 54 | 55 | HANDLE CreateEvent(void *pDummy, int bManualReset, int bInitialState, void *pDummy2); 56 | 57 | void CloseEvent(HANDLE ev); 58 | 59 | uint32_t WaitForSingleObject(HANDLE ev, uint32_t millisec); 60 | 61 | uint32_t WaitForMultipleObjects(uint32_t count, HANDLE *pev, int dummy, uint32_t millisec); 62 | 63 | #endif //#if defined(_WIN32) || defined(_WIN64) 64 | 65 | using unique_event = std::unique_ptr::type, decltype(&CloseEvent)>; 66 | 67 | unique_event CreateEventUnique(void *pDummy, int bManualReset, int bInitialState, const char* name); 68 | unique_event CreateEventUnique(void *pDummy, int bManualReset, int bInitialState, const wchar_t* name); 69 | unique_event CreateEventUnique(void *pDummy, int bManualReset, int bInitialState); 70 | 71 | #endif //__RGY_EVENT_H__ 72 | -------------------------------------------------------------------------------- /filter_core/rgy_filter.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/VCEEnc/rkmppenc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2019-2021 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // IABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // ------------------------------------------------------------------------------------------ 27 | 28 | #include "rgy_filter.h" 29 | 30 | RGYFilterBase::RGYFilterBase() : 31 | m_name(), 32 | m_infoStr(), 33 | m_pLog(), 34 | m_param(), 35 | m_pathThrough(FILTER_PATHTHROUGH_ALL), 36 | m_perfMonitor() { 37 | 38 | } 39 | 40 | RGYFilterBase::~RGYFilterBase() { 41 | 42 | } 43 | -------------------------------------------------------------------------------- /filter_core/rgy_hdr10plus.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2019 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #include "rgy_osdep.h" 29 | #include "rgy_hdr10plus.h" 30 | #include "rgy_filesystem.h" 31 | #include "rgy_util.h" 32 | #if ENABLE_LIBHDR10PLUS 33 | #include 34 | 35 | #if defined(_WIN32) || defined(_WIN64) 36 | #pragma comment(lib, "hdr10plus-rs.lib") 37 | #pragma comment(lib, "ws2_32.lib") 38 | #pragma comment(lib, "ntdll.lib") 39 | #pragma comment(lib, "Userenv.lib") 40 | #endif 41 | 42 | #endif 43 | 44 | RGYHDR10Plus::RGYHDR10Plus() : 45 | m_hdr10plusJson(std::unique_ptr(nullptr, nullptr)), 46 | m_inputJson() { 47 | } 48 | 49 | RGYHDR10Plus::~RGYHDR10Plus() { 50 | } 51 | 52 | RGY_ERR RGYHDR10Plus::init(const tstring &inputJson) { 53 | #if ENABLE_LIBHDR10PLUS 54 | if (!(rgy_file_exists(inputJson))) { 55 | return RGY_ERR_NOT_FOUND; 56 | } 57 | m_inputJson = inputJson; 58 | 59 | auto inputJsonStr = tchar_to_string(inputJson); 60 | m_hdr10plusJson = std::unique_ptr( 61 | hdr10plus_rs_parse_json(inputJsonStr.c_str()), hdr10plus_rs_json_free); 62 | if (!m_hdr10plusJson) { 63 | return RGY_ERR_INVALID_FORMAT; 64 | } 65 | return RGY_ERR_NONE; 66 | #else 67 | return RGY_ERR_UNSUPPORTED; 68 | #endif 69 | } 70 | 71 | tstring RGYHDR10Plus::getError() { 72 | #if ENABLE_LIBHDR10PLUS 73 | return (m_hdr10plusJson) ? char_to_tstring(hdr10plus_rs_json_get_error(m_hdr10plusJson.get())) : tstring(); 74 | #else 75 | return tstring(); 76 | #endif 77 | } 78 | 79 | const std::vector RGYHDR10Plus::getData(int iframe) { 80 | #if ENABLE_LIBHDR10PLUS 81 | std::unique_ptr av1_metadata( 82 | hdr10plus_rs_write_av1_metadata_obu_t35_complete(m_hdr10plusJson.get(), iframe), hdr10plus_rs_data_free); 83 | if (!av1_metadata) { 84 | return std::vector(); 85 | } 86 | std::vector buffer(av1_metadata->len); 87 | memcpy(buffer.data(), av1_metadata->data, av1_metadata->len); 88 | return buffer; 89 | #else 90 | return std::vector(); 91 | #endif 92 | } 93 | -------------------------------------------------------------------------------- /filter_core/rgy_hdr10plus.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2019 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #pragma once 29 | #ifndef __RGY_HDR10PLUS_H__ 30 | #define __RGY_HDR10PLUS_H__ 31 | 32 | #include 33 | #include 34 | #include 35 | #include "rgy_err.h" 36 | #include "rgy_tchar.h" 37 | 38 | struct Hdr10PlusRsJsonOpaque; 39 | 40 | typedef void (*funcHdr10PlusRsJsonOpaqueDelete)(Hdr10PlusRsJsonOpaque *ptr); 41 | 42 | class RGYHDR10Plus { 43 | public: 44 | RGYHDR10Plus(); 45 | virtual ~RGYHDR10Plus(); 46 | 47 | RGY_ERR init(const tstring& inputJson); 48 | const std::vector getData(int iframe); 49 | const tstring &inputJson() const { return m_inputJson; }; 50 | tstring getError(); 51 | protected: 52 | std::unique_ptr m_hdr10plusJson; 53 | tstring m_inputJson; 54 | }; 55 | 56 | #endif //__RGY_HDR10PLUS_H__ 57 | -------------------------------------------------------------------------------- /filter_core/rgy_ini.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #pragma once 29 | #ifndef __RGY_INI_H__ 30 | #define __RGY_INI_H__ 31 | 32 | #include "rgy_tchar.h" 33 | #include "rgy_osdep.h" 34 | 35 | #if (defined(_WIN32) || defined(_WIN64)) 36 | #define GetPrivateProfileStringCP(Section, Key, Default, buf, nSize, IniFile, codecpage) GetPrivateProfileStringA((Section), (Key), (Default), (buf), (nSize), (IniFile)) 37 | #define GetPrivateProfileIntCP(Section, Key, defaultValue, IniFile, codecpage) GetPrivateProfileStringA((Section), (Key), (defaultValue), (IniFile)) 38 | #else 39 | uint32_t GetPrivateProfileStringCP(const TCHAR* Section, const TCHAR* Key, const TCHAR* Default, TCHAR* buf, size_t nSize, const TCHAR* IniFile, uint32_t codecpage = CP_THREAD_ACP); 40 | uint32_t GetPrivateProfileIntCP(const TCHAR* Section, const TCHAR* Key, const uint32_t defaultValue, const TCHAR* IniFile, uint32_t codecpage = CP_THREAD_ACP); 41 | 42 | #define GetPrivateProfileStringA GetPrivateProfileStringCP 43 | #define GetPrivateProfileIntA GetPrivateProfileIntCP 44 | 45 | #endif //#if !(defined(_WIN32) || defined(_WIN64)) 46 | 47 | #endif //__RGY_INI_H__ 48 | 49 | -------------------------------------------------------------------------------- /filter_core/rgy_language.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2019 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // ------------------------------------------------------------------------------------------- 27 | 28 | #pragma once 29 | #ifndef __RGY_LANGUAGE_H__ 30 | #define __RGY_LANGUAGE_H__ 31 | 32 | #include 33 | 34 | std::string rgy_lang_2letter_6391(const std::string &lang_code); 35 | std::string rgy_lang_3letter_6392b(const std::string&lang_code); 36 | std::string rgy_lang_desc(const std::string &lang_code); 37 | bool rgy_lang_equal(const std::string &lang1, const std::string &lang2); 38 | bool rgy_lang_exist(const std::string &lang_code); 39 | 40 | #endif //__RGY_LANGUAGE_H__ 41 | -------------------------------------------------------------------------------- /filter_core/rgy_libdovi.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // 5 | // The MIT License 6 | // 7 | // Copyright (c) 2014-2016 rigaya 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // ------------------------------------------------------------------------------------------ 28 | 29 | #ifndef __RGY_LIBDOVI_H__ 30 | #define __RGY_LIBDOVI_H__ 31 | 32 | #if ENABLE_LIBDOVI 33 | 34 | extern "C" 35 | #include "libdovi/rpu_parser.h" 36 | 37 | #if 1 38 | #if defined(_WIN32) || defined(_WIN64) 39 | #pragma comment(lib, "dovi.lib") 40 | #pragma comment(lib, "ws2_32.lib") 41 | #pragma comment(lib, "ntdll.lib") 42 | #pragma comment(lib, "Userenv.lib") 43 | #endif 44 | #else 45 | 46 | #include "rgy_osdep.h" 47 | 48 | class RGYDoviFuncs { 49 | private: 50 | HMODULE m_hModule; 51 | 52 | public: 53 | decltype(&dovi_parse_rpu) parse_rpu; 54 | decltype(&dovi_parse_itu_t35_dovi_metadata_obu) parse_itu_t35_dovi_metadata_obu; 55 | decltype(&dovi_parse_unspec62_nalu) parse_unspec62_nalu; 56 | decltype(&dovi_rpu_free) rpu_free; 57 | decltype(&dovi_rpu_get_error) rpu_get_error; 58 | decltype(&dovi_data_free) data_free; 59 | decltype(&dovi_write_rpu) write_rpu; 60 | decltype(&dovi_write_unspec62_nalu) write_unspec62_nalu; 61 | decltype(&dovi_convert_rpu_with_mode) convert_rpu_with_mode; 62 | decltype(&dovi_rpu_get_header) rpu_get_header; 63 | decltype(&dovi_rpu_free_header) rpu_free_header; 64 | decltype(&dovi_rpu_get_data_mapping) rpu_get_data_mapping; 65 | decltype(&dovi_rpu_free_data_mapping) rpu_free_data_mapping; 66 | decltype(&dovi_rpu_get_vdr_dm_data) rpu_get_vdr_dm_data; 67 | decltype(&dovi_rpu_free_vdr_dm_data) rpu_free_vdr_dm_data; 68 | decltype(&dovi_parse_rpu_bin_file) parse_rpu_bin_file; 69 | decltype(&dovi_rpu_list_free) rpu_list_free; 70 | decltype(&dovi_rpu_set_active_area_offsets) rpu_set_active_area_offsets; 71 | decltype(&dovi_rpu_remove_mapping) rpu_remove_mapping; 72 | decltype(&dovi_write_av1_rpu_metadata_obu_t35_payload) write_av1_rpu_metadata_obu_t35_payload; 73 | decltype(&dovi_write_av1_rpu_metadata_obu_t35_complete) write_av1_rpu_metadata_obu_t35_complete; 74 | 75 | RGYDoviFuncs(); 76 | ~RGYDoviFuncs(); 77 | 78 | bool load(); 79 | 80 | void close(); 81 | }; 82 | #endif 83 | 84 | #endif // ENABLE_LIBDOVI 85 | 86 | #endif // __RGY_LIBDOVI_H__ 87 | -------------------------------------------------------------------------------- /filter_core/rgy_memmem.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2023 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #include 29 | #include 30 | #include "rgy_simd.h" 31 | #include "rgy_memmem.h" 32 | 33 | size_t rgy_memmem_c(const void *data_, const size_t data_size, const void *target_, const size_t target_size) { 34 | const uint8_t *data = (const uint8_t *)data_; 35 | if (data_size < target_size) { 36 | return RGY_MEMMEM_NOT_FOUND; 37 | } 38 | for (size_t i = 0; i <= data_size - target_size; i++) { 39 | if (memcmp(data + i, target_, target_size) == 0) { 40 | return i; 41 | } 42 | } 43 | return RGY_MEMMEM_NOT_FOUND; 44 | } 45 | 46 | decltype(rgy_memmem_c)* get_memmem_func() { 47 | #if defined(_M_IX86) || defined(_M_X64) || defined(__x86_64) 48 | const auto simd = get_availableSIMD(); 49 | #if defined(_M_X64) || defined(__x86_64) 50 | if ((simd & RGY_SIMD::AVX512BW) == RGY_SIMD::AVX512BW) return rgy_memmem_avx512bw; 51 | #endif 52 | if ((simd & RGY_SIMD::AVX2) == RGY_SIMD::AVX2) return rgy_memmem_avx2; 53 | #endif 54 | return rgy_memmem_c; 55 | } 56 | -------------------------------------------------------------------------------- /filter_core/rgy_memmem_avx2.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2023 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #define RGY_MEMMEM_AVX2 29 | #include "rgy_memmem.h" 30 | 31 | #if defined(_M_IX86) || defined(_M_X64) || defined(__x86_64) 32 | size_t rgy_memmem_avx2(const void *data_, const size_t data_size, const void *target_, const size_t target_size) { 33 | return rgy_memmem_avx2_imp(data_, data_size, target_, target_size); 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /filter_core/rgy_memmem_avx512bw.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2023 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #define RGY_MEMMEM_AVX512 29 | #include "rgy_memmem.h" 30 | 31 | #if defined(_M_X64) || defined(__x86_64) 32 | size_t rgy_memmem_avx512bw(const void *data_, const size_t data_size, const void *target_, const size_t target_size) { 33 | return rgy_memmem_avx512_imp(data_, data_size, target_, target_size); 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /filter_core/rgy_resource.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #pragma once 29 | #ifndef __RGY_RESOURCE_H__ 30 | #define __RGY_RESOURCE_H__ 31 | 32 | #include "rgy_osdep.h" 33 | #include "rgy_tchar.h" 34 | 35 | int getEmbeddedResource(void **data, const TCHAR *name, const TCHAR *type, HMODULE hModule); 36 | std::string getEmbeddedResourceStr(const tstring& name, const tstring& type, HMODULE hModule); 37 | 38 | #endif //__RGY_RESOURCE_H__ 39 | -------------------------------------------------------------------------------- /filter_core/rgy_simd.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #include 29 | #include "rgy_osdep.h" 30 | #include "rgy_simd.h" 31 | #include "rgy_arch.h" 32 | #if defined(_M_IX86) || defined(_M_X64) || defined(__x86_64) 33 | #if _MSC_VER 34 | #include 35 | #else 36 | #include 37 | #endif //_MSC_VER 38 | 39 | RGY_SIMD get_availableSIMD() { 40 | int CPUInfo[4]; 41 | __cpuid(CPUInfo, 1); 42 | RGY_SIMD simd = RGY_SIMD::NONE; 43 | if (CPUInfo[3] & 0x04000000) simd |= RGY_SIMD::SSE2; 44 | if (CPUInfo[2] & 0x00000001) simd |= RGY_SIMD::SSE3; 45 | if (CPUInfo[2] & 0x00000200) simd |= RGY_SIMD::SSSE3; 46 | if (CPUInfo[2] & 0x00080000) simd |= RGY_SIMD::SSE41; 47 | if (CPUInfo[2] & 0x00100000) simd |= RGY_SIMD::SSE42; 48 | if (CPUInfo[2] & 0x00800000) simd |= RGY_SIMD::POPCNT; 49 | uint64_t xgetbv = 0; 50 | if ((CPUInfo[2] & 0x18000000) == 0x18000000) { 51 | #if _MSC_VER 52 | xgetbv = _xgetbv(0); 53 | #else 54 | xgetbv = rgy_xgetbv(0); 55 | #endif 56 | if ((xgetbv & 0x06) == 0x06) 57 | simd |= RGY_SIMD::AVX; 58 | } 59 | __cpuid(CPUInfo, 7); 60 | if (!!(simd & RGY_SIMD::AVX) && (CPUInfo[1] & 0x00000020)) { 61 | simd |= RGY_SIMD::AVX2; 62 | } 63 | if (!!(simd & RGY_SIMD::AVX) && ((xgetbv >> 5) & 7) == 7) { 64 | if (CPUInfo[1] & (1u << 3)) simd |= RGY_SIMD::BMI1; 65 | if (CPUInfo[1] & (1u << 8)) simd |= RGY_SIMD::BMI2; 66 | if (CPUInfo[1] & (1u << 16)) simd |= RGY_SIMD::AVX512F; 67 | if (!!(simd & RGY_SIMD::AVX512F)) { 68 | if (CPUInfo[1] & (1u << 17)) simd |= RGY_SIMD::AVX512DQ; 69 | if (CPUInfo[1] & (1u << 21)) simd |= RGY_SIMD::AVX512IFMA; 70 | if (CPUInfo[1] & (1u << 26)) simd |= RGY_SIMD::AVX512PF; 71 | if (CPUInfo[1] & (1u << 27)) simd |= RGY_SIMD::AVX512ER; 72 | if (CPUInfo[1] & (1u << 28)) simd |= RGY_SIMD::AVX512CD; 73 | if (CPUInfo[1] & (1u << 30)) simd |= RGY_SIMD::AVX512BW; 74 | if (CPUInfo[1] & (1u << 31)) simd |= RGY_SIMD::AVX512VL; 75 | if (CPUInfo[2] & (1u << 1)) simd |= RGY_SIMD::AVX512VBMI; 76 | if (CPUInfo[2] & (1u << 6)) simd |= RGY_SIMD::AVX512VBMI2; 77 | if (CPUInfo[2] & (1u << 11)) simd |= RGY_SIMD::AVX512VNNI; 78 | if (CPUInfo[2] & (1u << 12)) simd |= RGY_SIMD::AVX512BITALG; 79 | if (CPUInfo[2] & (1u << 14)) simd |= RGY_SIMD::AVX512VPOPCNTDQ; 80 | } 81 | } 82 | return simd; 83 | } 84 | #else 85 | RGY_SIMD get_availableSIMD() { 86 | return RGY_SIMD::NONE; 87 | } 88 | #endif 89 | -------------------------------------------------------------------------------- /filter_core/rgy_simd.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // ------------------------------------------------------------------------------------------- 27 | 28 | #pragma once 29 | #ifndef __RGY_SIMD_H__ 30 | #define __RGY_SIMD_H__ 31 | 32 | #include 33 | #include 34 | 35 | #ifndef _MSC_VER 36 | 37 | #ifndef __forceinline 38 | #define __forceinline __attribute__((always_inline)) 39 | #endif 40 | 41 | #endif //#ifndef _MSC_VER 42 | 43 | enum class RGY_SIMD : uint64_t { 44 | NONE = 0x000000, 45 | SSE2 = 0x000001, 46 | SSE3 = 0x000002, 47 | SSSE3 = 0x000004, 48 | SSE41 = 0x000008, 49 | SSE42 = 0x000010, 50 | POPCNT = 0x000020, 51 | AVX = 0x000040, 52 | AVX2 = 0x000080, 53 | BMI1 = 0x000100, 54 | BMI2 = 0x000200, 55 | AVX512F = 0x000400, 56 | AVX512DQ = 0x000800, 57 | AVX512IFMA = 0x001000, 58 | AVX512PF = 0x002000, 59 | AVX512ER = 0x004000, 60 | AVX512CD = 0x008000, 61 | AVX512BW = 0x010000, 62 | AVX512VL = 0x020000, 63 | AVX512VBMI = 0x040000, 64 | AVX512VBMI2 = 0x080000, 65 | AVX512VNNI = 0x100000, 66 | AVX512BITALG = 0x200000, 67 | AVX512VPOPCNTDQ = 0x400000, 68 | 69 | SIMD_ALL = std::numeric_limits::max(), 70 | }; 71 | 72 | static bool operator!(RGY_SIMD e) { 73 | return e == static_cast(0); 74 | } 75 | 76 | static RGY_SIMD operator|(RGY_SIMD a, RGY_SIMD b) { 77 | return (RGY_SIMD)((uint64_t)a | (uint64_t)b); 78 | } 79 | 80 | static RGY_SIMD operator|=(RGY_SIMD &a, RGY_SIMD b) { 81 | a = a | b; 82 | return a; 83 | } 84 | 85 | static RGY_SIMD operator&(RGY_SIMD a, RGY_SIMD b) { 86 | return (RGY_SIMD)((uint64_t)a & (uint64_t)b); 87 | } 88 | 89 | static RGY_SIMD operator&=(RGY_SIMD &a, RGY_SIMD b) { 90 | a = a & b; 91 | return a; 92 | } 93 | 94 | RGY_SIMD get_availableSIMD(); 95 | 96 | #endif //__RGY_SIMD_H__ 97 | -------------------------------------------------------------------------------- /filter_core/rgy_tchar.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc/NVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #pragma once 29 | #ifndef __RGY_TCHAR_H__ 30 | #define __RGY_TCHAR_H__ 31 | 32 | #if defined(_WIN32) || defined(_WIN64) 33 | #define WIN32_LEAN_AND_MEAN 34 | #define NOMINMAX 35 | #include 36 | #else 37 | #include 38 | #include 39 | #include 40 | 41 | typedef char TCHAR; 42 | #define _T(x) x 43 | #define _tmain main 44 | #define _tcslen strlen 45 | #define _ftprintf fprintf 46 | #define _stscanf_s sscanf 47 | #define _stscanf sscanf 48 | #define _tcscmp strcmp 49 | #define _tcsnccmp strncmp 50 | #define _tcsicmp strcasecmp 51 | #define _tcschr strchr 52 | #define _tcsrchr strrchr 53 | #define _tcsstr strstr 54 | #define _tcscat_s strcat_s 55 | #define _tcstol strtol 56 | #define _tcsdup strdup 57 | #define _tfopen fopen 58 | #define _tfopen_s fopen_s 59 | #define _stprintf_s sprintf_s 60 | #define _vsctprintf _vscprintf 61 | #define _vstprintf_s _vsprintf_s 62 | #define _tcstok_s strtok_s 63 | #define _tcserror strerror 64 | #define _fgetts fgets 65 | #define _tcscpy strcpy 66 | #define _tcsncpy strncpy 67 | #define _tremove remove 68 | #define _trename rename 69 | #define _istalpha isalpha 70 | #define _tcsftime strftime 71 | #define _tcsncmp strncmp 72 | 73 | #define _SH_DENYRW 0x10 // deny read/write mode 74 | #define _SH_DENYWR 0x20 // deny write mode 75 | #define _SH_DENYRD 0x30 // deny read mode 76 | #define _SH_DENYNO 0x40 // deny none mode 77 | #define _SH_SECURE 0x80 // secure mode 78 | 79 | static inline FILE *_tfsopen(const TCHAR *filename, const TCHAR *mode, int shflag) { 80 | return fopen(filename, mode); 81 | } 82 | 83 | static inline char *_tcscpy_s(TCHAR *dst, const TCHAR *src) { 84 | return strcpy(dst, src); 85 | } 86 | 87 | static inline char *_tcscpy_s(TCHAR *dst, size_t size, const TCHAR *src) { 88 | return strcpy(dst, src); 89 | } 90 | #endif //#if defined(_WIN32) || defined(_WIN64) 91 | 92 | #include 93 | 94 | typedef std::basic_string tstring; 95 | 96 | #endif // __RGY_TCHAR_H__ 97 | -------------------------------------------------------------------------------- /filter_core/rgy_version.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // QSVEnc by rigaya 3 | // ----------------------------------------------------------------------------------------- 4 | // The MIT License 5 | // 6 | // Copyright (c) 2011-2016 rigaya 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // -------------------------------------------------------------------------------------------- 27 | 28 | #include "rgy_version.h" 29 | #include "rgy_rev.h" 30 | #include "rgy_osdep.h" 31 | #include "rgy_util.h" 32 | 33 | #define SSTRING(str) STRING(str) 34 | #define STRING(str) #str 35 | 36 | const TCHAR *get_encoder_version() { 37 | return 38 | _T(ENCODER_NAME) _T(" (") 39 | BUILD_ARCH_STR _T(") ") VER_STR_FILEVERSION_TCHAR _T(" (r") ENCODER_REV _T(") by rigaya, ") _T(__DATE__) _T(" ") _T(__TIME__) 40 | #if defined(_MSC_VER) 41 | _T(" (VC ") _T(SSTRING(_MSC_VER)) 42 | #elif defined(__clang__) 43 | _T(" (clang ") _T(SSTRING(__clang_major__)) _T(".") _T(SSTRING(__clang_minor__)) _T(".") _T(SSTRING(__clang_patchlevel__)) 44 | #elif defined(__GNUC__) 45 | _T(" (gcc ") _T(SSTRING(__GNUC__)) _T(".") _T(SSTRING(__GNUC_MINOR__)) _T(".") _T(SSTRING(__GNUC_PATCHLEVEL__)) 46 | #else 47 | _T(" (unknown") 48 | #endif 49 | _T("/") 50 | #ifdef _WIN32 51 | _T("Win") 52 | #elif __linux 53 | _T("Linux") 54 | #else 55 | _T("unknown") 56 | #endif 57 | _T(")"); 58 | } 59 | -------------------------------------------------------------------------------- /opencl_load_error.md: -------------------------------------------------------------------------------- 1 | # clfiltersで "OpenCLを使用できません。" と出てしまう場合の対応 2 | 3 | まず、OpenCLが使用可能となっているか確認します。 4 | 5 | ## GPU-Zでの確認 6 | 7 | [GPU-Z](https://www.techpowerup.com/gpuz/)の[Advanced]タブからOpenCLを選択し、下記のように情報が表示されるか確認してください。 8 | 9 | このように適切に認識されているにもかかわらず、clfiltersで"OpenCLを使用できません。"と出てしまう場合は、clfiltersの問題と思われますので、ご連絡ください。 10 | 11 | ![デバイス選択](./data/gpuz_opencl_check.png) 12 | 13 | "not supported" と表示されている場合は、OpenCLに対応していないデバイスであるか、なんらかの原因でOpenCLが適切に認識されていません。 14 | 15 | ## モジュールの確認 16 | 17 | まず、```C:\Windows\SysWOW64\OepnCL.dll``` が存在するか確認してください。 18 | 19 | また、使用するGPUに応じて下記のモジュールが存在するか確認してください。 20 | 21 | | ベンダー | モジュール(32bit) | 場所 | 22 | |:-- |:-- |:-- | 23 | | Intel | igdrcl32.dll | C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_* | 24 | | NVIDIA | nvopencl32.dll | C:\Windows\System32\DriverStore\FileRepository\nv_dispig.inf_amd64_* | 25 | | AMD | amdocl.dll | C:\Windows\System32\DriverStore\FileRepository\xxxxxxxx.inf_amd64_* | 26 | 27 | ## モジュールが存在しない場合 28 | 29 | これらが存在しない場合は、まずはGPUドライバパッケージをダウンロードし、クリーンインストールを行ってください。 30 | 31 | PC再起動後、問題が解消するか確認してください。 32 | 33 | ## モジュールが存在するが、OpenCLが有効にならない場合 34 | 35 | **下記操作はレジストリを操作するため、自己責任で十分注意して行ってください。** 36 | 37 | レジストリエディタ(regedit)を開き、下記キーを追加してください。 38 | 39 | ``` 40 | レジストリキー HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Khronos\OpenCL\Vendors 41 | 42 | [新規] > [DWORD (32bit) 値] 43 | 名前: モジュールへのフルパス 44 | 種類: REG_DWORD 45 | データ: 0x00000000 (0) 46 | ``` 47 | 48 | PC再起動後、問題が解消するか確認してください。 49 | 50 | # OpenCLモジュールのロードの仕組み 51 | 52 | OpenCLは、本来はGPUに限らず並列計算を行うための汎用的な仕組みになっており、複数のベンダーがサポートしています。(Intel, NVIDIA, AMD, ...) 53 | 54 | これをサポートするため、OpenCLモジュールについても同一PCで複数のベンダーのOpenCLデバイスを利用できるよう、以下のような仕組みになっています。 55 | 56 | アプリケーションが使用するOpenCLモジュールは、OpenCL.dllですが、これは一般にはICDローダーと呼ばれるもので、 57 | これがさらに各デバイス用の実装の実体となるモジュールをロードして呼び出してOpenCLを実行することになります。 58 | 59 | この「各デバイス用の実装の実体となるモジュール」は一般的には各ベンダーのGPUドライバに含まれています。 60 | 61 | | ベンダー | モジュール(32bit) | モジュール(64bit) | 場所 | 62 | |:-- |:-- |:-- |:-- | 63 | | Intel | igdrcl32.dll | igdrcl64.dll | C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_* | 64 | | NVIDIA | nvopencl32.dll | nvopencl64.dll | C:\Windows\System32\DriverStore\FileRepository\nv_dispig.inf_amd64_* | 65 | | AMD | amdocl.dll | amdocl64.dll | C:\Windows\System32\DriverStore\FileRepository\xxxxxxxx.inf_amd64_* | 66 | 67 | OpenCL.dllが呼び出されると、OpenCL.dllがこれらモジュールを見つけに行くことになります。 68 | 一般にはGPUドライバインストール時にレジストリに各モジュールの場所が書き込まれており、 69 | OpenCL.dllがこの値を参照してロードしているようです。 70 | 71 | レジストリを検索すると複数あるので、どれを参照しているのかよくわからないですが…。 72 | 73 | ``` 74 | HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\yyyy 75 | 32bit: OpenCLDriverNameWow 76 | 64bit: OpenCLDriverName 77 | ``` 78 | 79 | それとは別に、OpenCLの検索用レジストリキーとして下記も用意されています。 80 | 81 | こちらにキーを下記のように登録すると、そのモジュールを探しに行ってくれます。手動での登録の際には、こちらを使うのがよさそうです。 82 | 83 | ただ、手動の場合、ドライバを更新するたびに再設定が必要になるかもしれないので、 84 | 基本的にはドライバセットアップに任せるほうがよく、それでうまくいかない場合にのみ使用したほうがよいでしょう。 85 | 86 | ``` 87 | 32bit: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Khronos\OpenCL\Vendors 88 | 64bit: HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\vendors 89 | 90 | 新規キーの追加 91 | 名前: モジュールへのフルパス 92 | 種類: REG_DWORD 93 | データ: 0x00000000 (0) 94 | ``` 95 | 96 | ちょっとややこしいのですが、このあたりはOpenCLが汎用的でオープンな仕組みであるため、仕方ない面だと思います。 97 | 98 | クローズドなCUDAとは対照的で、あちらはNVIDIAに閉じているのでシンプルになっている一方、基本的にはNVIDIAでしか使えないです。 99 | 100 | どちらがいいということではなく、想定する用途・使われ方によって、良し悪しは異なると思います。 101 | -------------------------------------------------------------------------------- /resource/nnedi3_weights.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigaya/Aviutl-clcufilters/e59336bd97c20a501feb7ec6aa77a0039efc73aa/resource/nnedi3_weights.bin --------------------------------------------------------------------------------