├── Frfun7 ├── Frfun7.h ├── Frfun7.rc ├── avs │ ├── filesystem.h │ ├── minmax.h │ ├── types.h │ ├── win.h │ ├── cpuid.h │ ├── capi.h │ ├── alignment.h │ ├── posix.h │ └── config.h ├── Frfun7.vcxproj.filters ├── CMakeLists.txt ├── Frfun7.vcxproj └── avisynth.h ├── .editorconfig ├── cmake_uninstall.cmake.in ├── Frfun7.sln ├── README.md ├── .gitignore ├── CMakeLists.txt └── LICENSE /Frfun7/Frfun7.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pinterf/Frfun7/HEAD/Frfun7/Frfun7.h -------------------------------------------------------------------------------- /Frfun7/Frfun7.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pinterf/Frfun7/HEAD/Frfun7/Frfun7.rc -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | # NOTE: editorconfig-core-c has a hardcoded limitation of 50 chars per .ini section name 4 | 5 | [*.{cpp,h,hpp,c,asm}] 6 | indent_style = space 7 | indent_size = 2 8 | trim_trailing_whitespace = true 9 | end_of_line = crlf 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | indent_style = space 14 | trim_trailing_whitespace = false 15 | 16 | -------------------------------------------------------------------------------- /Frfun7/avs/filesystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Snippet copied from filesystem/README.md 4 | 5 | #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) 6 | #if __has_include() 7 | #define GHC_USE_STD_FS 8 | #include 9 | namespace fs = std::filesystem; 10 | #endif 11 | #endif 12 | #ifndef GHC_USE_STD_FS 13 | #include 14 | namespace fs = ghc::filesystem; 15 | #endif 16 | -------------------------------------------------------------------------------- /cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 3 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | 5 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program( 11 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 12 | OUTPUT_VARIABLE rm_out 13 | RETURN_VALUE rm_retval 14 | ) 15 | if(NOT "${rm_retval}" STREQUAL 0) 16 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 17 | endif(NOT "${rm_retval}" STREQUAL 0) 18 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 19 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 20 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | endforeach(file) 22 | -------------------------------------------------------------------------------- /Frfun7.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31205.134 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Frfun7", "Frfun7\Frfun7.vcxproj", "{29983FF5-313E-46C2-AEA7-BCA7E546A3E3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | ReleaseClang|Win32 = ReleaseClang|Win32 15 | ReleaseClang|x64 = ReleaseClang|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.Debug|Win32.Build.0 = Debug|Win32 20 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.Debug|x64.ActiveCfg = Debug|x64 21 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.Debug|x64.Build.0 = Debug|x64 22 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.Release|Win32.ActiveCfg = Release|Win32 23 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.Release|Win32.Build.0 = Release|Win32 24 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.Release|x64.ActiveCfg = Release|x64 25 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.Release|x64.Build.0 = Release|x64 26 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.ReleaseClang|Win32.ActiveCfg = ReleaseClang|Win32 27 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.ReleaseClang|Win32.Build.0 = ReleaseClang|Win32 28 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.ReleaseClang|x64.ActiveCfg = ReleaseClang|x64 29 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3}.ReleaseClang|x64.Build.0 = ReleaseClang|x64 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {17698D20-890D-47CA-ABDF-DE36F8B17C6B} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /Frfun7/Frfun7.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;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 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | 47 | 48 | Source Files 49 | 50 | 51 | 52 | 53 | Resource Files 54 | 55 | 56 | -------------------------------------------------------------------------------- /Frfun7/avs/minmax.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifndef AVSCORE_MINMAX_H 33 | #define AVSCORE_MINMAX_H 34 | 35 | template 36 | T min(T v1, T v2) 37 | { 38 | return v1 < v2 ? v1 : v2; 39 | } 40 | 41 | template 42 | T max(T v1, T v2) 43 | { 44 | return v1 > v2 ? v1 : v2; 45 | } 46 | 47 | template 48 | T clamp(T n, T min, T max) 49 | { 50 | n = n > max ? max : n; 51 | return n < min ? min : n; 52 | } 53 | 54 | #endif // AVSCORE_MINMAX_H 55 | -------------------------------------------------------------------------------- /Frfun7/avs/types.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_TYPES_H 34 | #define AVS_TYPES_H 35 | 36 | // Define all types necessary for interfacing with avisynth.dll 37 | #include 38 | #include 39 | #ifdef __cplusplus 40 | #include 41 | #include 42 | #else 43 | #include 44 | #include 45 | #endif 46 | 47 | // Raster types used by VirtualDub & Avisynth 48 | typedef uint32_t Pixel32; 49 | typedef uint8_t BYTE; 50 | 51 | // Audio Sample information 52 | typedef float SFLOAT; 53 | 54 | #endif //AVS_TYPES_H 55 | -------------------------------------------------------------------------------- /Frfun7/avs/win.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifndef AVSCORE_WIN_H 33 | #define AVSCORE_WIN_H 34 | 35 | // Whenever you need windows headers, start by including this file, then the rest. 36 | 37 | // WWUUT? We require XP now? 38 | #if !defined(NTDDI_VERSION) && !defined(_WIN32_WINNT) 39 | #define NTDDI_VERSION 0x05020000 40 | #define _WIN32_WINNT 0x0502 41 | #endif 42 | 43 | #define WIN32_LEAN_AND_MEAN 44 | #define STRICT 45 | #if !defined(NOMINMAX) 46 | #define NOMINMAX 47 | #endif 48 | 49 | #include 50 | 51 | // Provision for UTF-8 max 4 bytes per code point 52 | #define AVS_MAX_PATH MAX_PATH*4 53 | 54 | #endif // AVSCORE_WIN_H 55 | -------------------------------------------------------------------------------- /Frfun7/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(PluginName "Frfun7") 2 | 3 | if (NOT WIN32) 4 | string(TOLOWER "${PluginName}" PluginName) 5 | endif() 6 | 7 | set(ProjectName "${PluginName}") 8 | project(${ProjectName} LANGUAGES CXX) 9 | 10 | file(GLOB AddGrainCSources RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" *.cpp *.h) 11 | add_library(${PluginName} SHARED ${AddGrainCSources}) 12 | 13 | #require sse2, some other plugins may need to set sse4.1 for quick msvc->gcc porting 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DINTEL_INTRINSICS -msse2") 15 | 16 | if (MSVC_IDE) 17 | IF(CLANG_IN_VS STREQUAL "1") 18 | # special AVX option for source files with *_avx.cpp pattern 19 | file(GLOB_RECURSE SRCS_AVX "*_avx.cpp") 20 | set_source_files_properties(${SRCS_AVX} PROPERTIES COMPILE_FLAGS " -mavx ") 21 | 22 | # special AVX2 option for source files with *_avx2.cpp pattern 23 | file(GLOB_RECURSE SRCS_AVX2 "*_avx2.cpp") 24 | set_source_files_properties(${SRCS_AVX2} PROPERTIES COMPILE_FLAGS " -mavx2 -mfma ") 25 | 26 | # special AVX512 option for source files with *_avx512.cpp pattern 27 | file(GLOB_RECURSE SRCS_AVX512 "*_avx512.cpp") 28 | set_source_files_properties(${SRCS_AVX512} PROPERTIES COMPILE_FLAGS " -mavx512f -mavx512bw ") 29 | ELSE() 30 | # special AVX option for source files with *_avx.cpp pattern 31 | file(GLOB_RECURSE SRCS_AVX "*_avx.cpp") 32 | set_source_files_properties(${SRCS_AVX} PROPERTIES COMPILE_FLAGS " /arch:AVX ") 33 | 34 | # special AVX2 option for source files with *_avx2.cpp pattern 35 | file(GLOB_RECURSE SRCS_AVX2 "*_avx2.cpp") 36 | set_source_files_properties(${SRCS_AVX2} PROPERTIES COMPILE_FLAGS " /arch:AVX2 ") 37 | 38 | # special AVX512 option for source files with *_avx512.cpp pattern 39 | file(GLOB_RECURSE SRCS_AVX512 "*_avx512.cpp") 40 | set_source_files_properties(${SRCS_AVX512} PROPERTIES COMPILE_FLAGS " /arch:AVX512 ") 41 | ENDIF() 42 | else() 43 | # special AVX option for source files with *_avx.cpp pattern 44 | file(GLOB_RECURSE SRCS_AVX "*_avx.cpp") 45 | set_source_files_properties(${SRCS_AVX} PROPERTIES COMPILE_FLAGS " -mavx ") 46 | 47 | # special AVX2 option for source files with *_avx2.cpp pattern 48 | file(GLOB_RECURSE SRCS_AVX2 "*_avx2.cpp") 49 | set_source_files_properties(${SRCS_AVX2} PROPERTIES COMPILE_FLAGS " -mavx2 -mfma ") 50 | 51 | # special AVX512 option for source files with *_avx512.cpp pattern 52 | file(GLOB_RECURSE SRCS_AVX512 "*_avx512.cpp") 53 | set_source_files_properties(${SRCS_AVX512} PROPERTIES COMPILE_FLAGS " -mavx512f -mavx512bw ") 54 | endif() 55 | 56 | target_link_libraries(${ProjectName}) 57 | target_include_directories(${ProjectName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 58 | 59 | include(GNUInstallDirs) 60 | 61 | INSTALL(TARGETS ${ProjectName} 62 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/avisynth") 63 | -------------------------------------------------------------------------------- /Frfun7/avs/cpuid.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifndef AVSCORE_CPUID_H 33 | #define AVSCORE_CPUID_H 34 | 35 | // For GetCPUFlags. These are backwards-compatible with those in VirtualDub. 36 | // ending with SSE4_2 37 | // For emulation see https://software.intel.com/en-us/articles/intel-software-development-emulator 38 | enum { 39 | /* oldest CPU to support extension */ 40 | CPUF_FORCE = 0x01, // N/A 41 | CPUF_FPU = 0x02, // 386/486DX 42 | CPUF_MMX = 0x04, // P55C, K6, PII 43 | CPUF_INTEGER_SSE = 0x08, // PIII, Athlon 44 | CPUF_SSE = 0x10, // PIII, Athlon XP/MP 45 | CPUF_SSE2 = 0x20, // PIV, K8 46 | CPUF_3DNOW = 0x40, // K6-2 47 | CPUF_3DNOW_EXT = 0x80, // Athlon 48 | CPUF_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2, which 49 | // only Hammer will have anyway) 50 | CPUF_SSE3 = 0x100, // PIV+, K8 Venice 51 | CPUF_SSSE3 = 0x200, // Core 2 52 | CPUF_SSE4 = 0x400, 53 | CPUF_SSE4_1 = 0x400, // Penryn, Wolfdale, Yorkfield 54 | CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer 55 | CPUF_SSE4_2 = 0x1000, // Nehalem 56 | // AVS+ 57 | CPUF_AVX2 = 0x2000, // Haswell 58 | CPUF_FMA3 = 0x4000, 59 | CPUF_F16C = 0x8000, 60 | CPUF_MOVBE = 0x10000, // Big Endian move 61 | CPUF_POPCNT = 0x20000, 62 | CPUF_AES = 0x40000, 63 | CPUF_FMA4 = 0x80000, 64 | 65 | CPUF_AVX512F = 0x100000, // AVX-512 Foundation. 66 | CPUF_AVX512DQ = 0x200000, // AVX-512 DQ (Double/Quad granular) Instructions 67 | CPUF_AVX512PF = 0x400000, // AVX-512 Prefetch 68 | CPUF_AVX512ER = 0x800000, // AVX-512 Exponential and Reciprocal 69 | CPUF_AVX512CD = 0x1000000, // AVX-512 Conflict Detection 70 | CPUF_AVX512BW = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions 71 | CPUF_AVX512VL = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions 72 | CPUF_AVX512IFMA = 0x8000000, // AVX-512 IFMA integer 52 bit 73 | CPUF_AVX512VBMI = 0x10000000,// AVX-512 VBMI 74 | }; 75 | 76 | #ifdef BUILDING_AVSCORE 77 | int GetCPUFlags(); 78 | void SetMaxCPU(int new_flags); 79 | #endif 80 | 81 | #endif // AVSCORE_CPUID_H 82 | -------------------------------------------------------------------------------- /Frfun7/avs/capi.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_CAPI_H 34 | #define AVS_CAPI_H 35 | 36 | #include "config.h" 37 | 38 | #ifdef AVS_POSIX 39 | // this is also defined in avs/posix.h 40 | #ifndef AVS_HAIKU 41 | #define __declspec(x) 42 | #endif 43 | #endif 44 | 45 | #ifdef __cplusplus 46 | # define EXTERN_C extern "C" 47 | #else 48 | # define EXTERN_C 49 | #endif 50 | 51 | #ifdef AVS_WINDOWS 52 | #ifdef BUILDING_AVSCORE 53 | # if defined(GCC) && defined(X86_32) 54 | # define AVSC_CC 55 | # else // MSVC builds and 64-bit GCC 56 | # ifndef AVSC_USE_STDCALL 57 | # define AVSC_CC __cdecl 58 | # else 59 | # define AVSC_CC __stdcall 60 | # endif 61 | # endif 62 | #else // needed for programs that talk to AviSynth+ 63 | # ifndef AVSC_WIN32_GCC32 // see comment below 64 | # ifndef AVSC_USE_STDCALL 65 | # define AVSC_CC __cdecl 66 | # else 67 | # define AVSC_CC __stdcall 68 | # endif 69 | # else 70 | # define AVSC_CC 71 | # endif 72 | #endif 73 | # else 74 | # define AVSC_CC 75 | #endif 76 | 77 | // On 64-bit Windows, there's only one calling convention, 78 | // so there is no difference between MSVC and GCC. On 32-bit, 79 | // this isn't true. The convention that GCC needs to use to 80 | // even build AviSynth+ as 32-bit makes anything that uses 81 | // it incompatible with 32-bit MSVC builds of AviSynth+. 82 | // The AVSC_WIN32_GCC32 define is meant to provide a user 83 | // switchable way to make builds of FFmpeg to test 32-bit 84 | // GCC builds of AviSynth+ without having to screw around 85 | // with alternate headers, while still default to the usual 86 | // situation of using 32-bit MSVC builds of AviSynth+. 87 | 88 | // Hopefully, this situation will eventually be resolved 89 | // and a broadly compatible solution will arise so the 90 | // same 32-bit FFmpeg build can handle either MSVC or GCC 91 | // builds of AviSynth+. 92 | 93 | #define AVSC_INLINE static __inline 94 | 95 | #ifdef BUILDING_AVSCORE 96 | #ifdef AVS_WINDOWS 97 | # ifndef AVS_STATIC_LIB 98 | # define AVSC_EXPORT __declspec(dllexport) 99 | # else 100 | # define AVSC_EXPORT 101 | # endif 102 | # define AVSC_API(ret, name) EXTERN_C AVSC_EXPORT ret AVSC_CC name 103 | #else 104 | # define AVSC_EXPORT EXTERN_C 105 | # define AVSC_API(ret, name) EXTERN_C ret AVSC_CC name 106 | #endif 107 | #else 108 | # define AVSC_EXPORT EXTERN_C __declspec(dllexport) 109 | # ifndef AVS_STATIC_LIB 110 | # define AVSC_IMPORT __declspec(dllimport) 111 | # else 112 | # define AVSC_IMPORT 113 | # endif 114 | # ifndef AVSC_NO_DECLSPEC 115 | # define AVSC_API(ret, name) EXTERN_C AVSC_IMPORT ret AVSC_CC name 116 | # else 117 | # define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func) 118 | # endif 119 | #endif 120 | 121 | #endif //AVS_CAPI_H 122 | -------------------------------------------------------------------------------- /Frfun7/avs/alignment.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_ALIGNMENT_H 34 | #define AVS_ALIGNMENT_H 35 | 36 | // Functions and macros to help work with alignment requirements. 37 | 38 | // Tells if a number is a power of two. 39 | #define IS_POWER2(n) ((n) && !((n) & ((n) - 1))) 40 | 41 | // Tells if the pointer "ptr" is aligned to "align" bytes. 42 | #define IS_PTR_ALIGNED(ptr, align) (((uintptr_t)ptr & ((uintptr_t)(align-1))) == 0) 43 | 44 | // Rounds up the number "n" to the next greater multiple of "align" 45 | #define ALIGN_NUMBER(n, align) (((n) + (align)-1) & (~((align)-1))) 46 | 47 | // Rounds up the pointer address "ptr" to the next greater multiple of "align" 48 | #define ALIGN_POINTER(ptr, align) (((uintptr_t)(ptr) + (align)-1) & (~(uintptr_t)((align)-1))) 49 | 50 | #ifdef __cplusplus 51 | 52 | #include 53 | #include 54 | #include 55 | #include "config.h" 56 | 57 | #if defined(MSVC) && _MSC_VER<1400 58 | // needed for VS2013, otherwise C++11 'alignas' works 59 | #define avs_alignas(x) __declspec(align(x)) 60 | #else 61 | // assumes C++11 support 62 | #define avs_alignas(x) alignas(x) 63 | #endif 64 | 65 | template 66 | static bool IsPtrAligned(T* ptr, size_t align) 67 | { 68 | assert(IS_POWER2(align)); 69 | return (bool)IS_PTR_ALIGNED(ptr, align); 70 | } 71 | 72 | template 73 | static T AlignNumber(T n, T align) 74 | { 75 | assert(IS_POWER2(align)); 76 | return ALIGN_NUMBER(n, align); 77 | } 78 | 79 | template 80 | static T* AlignPointer(T* ptr, size_t align) 81 | { 82 | assert(IS_POWER2(align)); 83 | return (T*)ALIGN_POINTER(ptr, align); 84 | } 85 | 86 | extern "C" 87 | { 88 | #else 89 | #include 90 | #endif // __cplusplus 91 | 92 | // Returns a new buffer that is at least the size "nbytes". 93 | // The buffer will be aligned to "align" bytes. 94 | // Returns NULL on error. On successful allocation, 95 | // the returned buffer must be freed using "avs_free". 96 | inline void* avs_malloc(size_t nbytes, size_t align) 97 | { 98 | if (!IS_POWER2(align)) 99 | return NULL; 100 | 101 | size_t offset = sizeof(void*) + align - 1; 102 | 103 | void *orig = malloc(nbytes + offset); 104 | if (orig == NULL) 105 | return NULL; 106 | 107 | void **aligned = (void**)(((uintptr_t)orig + (uintptr_t)offset) & (~(uintptr_t)(align-1))); 108 | aligned[-1] = orig; 109 | return aligned; 110 | } 111 | 112 | // Buffers allocated using "avs_malloc" must be freed 113 | // using "avs_free" instead of "free". 114 | inline void avs_free(void *ptr) 115 | { 116 | // Mirroring free()'s semantic requires us to accept NULLs 117 | if (ptr == NULL) 118 | return; 119 | 120 | free(((void**)ptr)[-1]); 121 | } 122 | 123 | #ifdef __cplusplus 124 | } // extern "C" 125 | 126 | // The point of these undef's is to force using the template functions 127 | // if we are in C++ mode. For C, the user can rely only on the macros. 128 | #undef IS_PTR_ALIGNED 129 | #undef ALIGN_NUMBER 130 | #undef ALIGN_POINTER 131 | 132 | #endif // __cplusplus 133 | 134 | #endif //AVS_ALIGNMENT_H 135 | -------------------------------------------------------------------------------- /Frfun7/avs/posix.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifdef AVS_POSIX 33 | #ifndef AVSCORE_POSIX_H 34 | #define AVSCORE_POSIX_H 35 | 36 | #ifdef __cplusplus 37 | #include 38 | #endif 39 | #include 40 | #include 41 | 42 | // Define these MSVC-extension used in Avisynth 43 | #define __single_inheritance 44 | 45 | // These things don't exist in Linux 46 | #if defined(AVS_HAIKU) 47 | #undef __declspec 48 | #endif 49 | #define __declspec(x) 50 | #define lstrlen strlen 51 | #define lstrcmp strcmp 52 | #define lstrcmpi strcasecmp 53 | #define _stricmp strcasecmp 54 | #define _strnicmp strncasecmp 55 | #define _strdup strdup 56 | #define SetCurrentDirectory(x) chdir(x) 57 | #define SetCurrentDirectoryW(x) chdir(x) 58 | #define GetCurrentDirectoryW(x) getcwd(x) 59 | #define _putenv putenv 60 | #define _alloca alloca 61 | 62 | // Borrowing some compatibility macros from AvxSynth, slightly modified 63 | #define UInt32x32To64(a, b) ((uint64_t)(((uint64_t)((uint32_t)(a))) * ((uint32_t)(b)))) 64 | #define Int64ShrlMod32(a, b) ((uint64_t)((uint64_t)(a) >> (b))) 65 | #define Int32x32To64(a, b) ((int64_t)(((int64_t)((long)(a))) * ((long)(b)))) 66 | 67 | #define InterlockedIncrement(x) __sync_add_and_fetch((x), 1) 68 | #define InterlockedDecrement(x) __sync_sub_and_fetch((x), 1) 69 | #define MulDiv(nNumber, nNumerator, nDenominator) (int32_t) (((int64_t) (nNumber) * (int64_t) (nNumerator) + (int64_t) ((nDenominator)/2)) / (int64_t) (nDenominator)) 70 | 71 | #ifndef TRUE 72 | #define TRUE true 73 | #endif 74 | 75 | #ifndef FALSE 76 | #define FALSE false 77 | #endif 78 | 79 | #define S_FALSE (0x00000001) 80 | #define E_FAIL (0x80004005) 81 | #define FAILED(hr) ((hr) & 0x80000000) 82 | #define SUCCEEDED(hr) (!FAILED(hr)) 83 | 84 | // Statuses copied from comments in exception.cpp 85 | #define STATUS_GUARD_PAGE_VIOLATION 0x80000001 86 | #define STATUS_DATATYPE_MISALIGNMENT 0x80000002 87 | #define STATUS_BREAKPOINT 0x80000003 88 | #define STATUS_SINGLE_STEP 0x80000004 89 | #define STATUS_ACCESS_VIOLATION 0xc0000005 90 | #define STATUS_IN_PAGE_ERROR 0xc0000006 91 | #define STATUS_INVALID_HANDLE 0xc0000008 92 | #define STATUS_NO_MEMORY 0xc0000017 93 | #define STATUS_ILLEGAL_INSTRUCTION 0xc000001d 94 | #define STATUS_NONCONTINUABLE_EXCEPTION 0xc0000025 95 | #define STATUS_INVALID_DISPOSITION 0xc0000026 96 | #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xc000008c 97 | #define STATUS_FLOAT_DENORMAL_OPERAND 0xc000008d 98 | #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xc000008e 99 | #define STATUS_FLOAT_INEXACT_RESULT 0xc000008f 100 | #define STATUS_FLOAT_INVALID_OPERATION 0xc0000090 101 | #define STATUS_FLOAT_OVERFLOW 0xc0000091 102 | #define STATUS_FLOAT_STACK_CHECK 0xc0000092 103 | #define STATUS_FLOAT_UNDERFLOW 0xc0000093 104 | #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xc0000094 105 | #define STATUS_INTEGER_OVERFLOW 0xc0000095 106 | #define STATUS_PRIVILEGED_INSTRUCTION 0xc0000096 107 | #define STATUS_STACK_OVERFLOW 0xc00000fd 108 | 109 | // Calling convension 110 | #ifndef AVS_HAIKU 111 | #define __stdcall 112 | #define __cdecl 113 | #endif 114 | 115 | // PowerPC OS X is really niche these days, but this painless equivocation 116 | // of the function/macro names used in posix_get_available_memory() 117 | // is all it takes to let it work. The G5 was 64-bit, and if 10.5 Leopard 118 | // can run in native 64-bit, it probably uses the names in that block as-is. 119 | #ifdef AVS_MACOS 120 | #ifdef PPC32 121 | #define vm_statistics64_data_t vm_statistics_data_t 122 | #define HOST_VM_INFO64_COUNT HOST_VM_INFO_COUNT 123 | #define HOST_VM_INFO64 HOST_VM_INFO 124 | #define host_statistics64 host_statistics 125 | #endif // PPC32 126 | #endif // AVS_MACOS 127 | 128 | #endif // AVSCORE_POSIX_H 129 | #endif // AVS_POSIX 130 | -------------------------------------------------------------------------------- /Frfun7/avs/config.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_CONFIG_H 34 | #define AVS_CONFIG_H 35 | 36 | // Undefine this to get cdecl calling convention 37 | #define AVSC_USE_STDCALL 1 38 | 39 | // NOTE TO PLUGIN AUTHORS: 40 | // Because FRAME_ALIGN can be substantially higher than the alignment 41 | // a plugin actually needs, plugins should not use FRAME_ALIGN to check for 42 | // alignment. They should always request the exact alignment value they need. 43 | // This is to make sure that plugins work over the widest range of AviSynth 44 | // builds possible. 45 | #define FRAME_ALIGN 64 46 | 47 | #if defined(_M_AMD64) || defined(__x86_64) 48 | # define X86_64 49 | #elif defined(_M_IX86) || defined(__i386__) 50 | # define X86_32 51 | // VS2017 introduced _M_ARM64 52 | #elif defined(_M_ARM64) || defined(__aarch64__) 53 | # define ARM64 54 | #elif defined(_M_ARM) || defined(__arm__) 55 | # define ARM32 56 | #elif defined(__PPC64__) 57 | # define PPC64 58 | #elif defined(_M_PPC) || defined(__PPC__) || defined(__POWERPC__) 59 | # define PPC32 60 | #else 61 | # error Unsupported CPU architecture. 62 | #endif 63 | 64 | // VC++ LLVM-Clang-cl MinGW-Gnu 65 | // MSVC x x 66 | // MSVC_PURE x 67 | // CLANG x 68 | // GCC x 69 | 70 | #if defined(__clang__) 71 | // Check clang first. clang-cl also defines __MSC_VER 72 | // We set MSVC because they are mostly compatible 73 | # define CLANG 74 | #if defined(_MSC_VER) 75 | # define MSVC 76 | # define AVS_FORCEINLINE __attribute__((always_inline)) 77 | #else 78 | # define AVS_FORCEINLINE __attribute__((always_inline)) inline 79 | #endif 80 | #elif defined(_MSC_VER) 81 | # define MSVC 82 | # define MSVC_PURE 83 | # define AVS_FORCEINLINE __forceinline 84 | #elif defined(__GNUC__) 85 | # define GCC 86 | # define AVS_FORCEINLINE __attribute__((always_inline)) inline 87 | #else 88 | # error Unsupported compiler. 89 | # define AVS_FORCEINLINE inline 90 | # undef __forceinline 91 | # define __forceinline inline 92 | #endif 93 | 94 | #if defined(_WIN32) 95 | # define AVS_WINDOWS 96 | #elif defined(__linux__) 97 | # define AVS_LINUX 98 | # define AVS_POSIX 99 | #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) 100 | # define AVS_BSD 101 | # define AVS_POSIX 102 | #elif defined(__APPLE__) 103 | # define AVS_MACOS 104 | # define AVS_POSIX 105 | #elif defined(__HAIKU__) 106 | # define AVS_HAIKU 107 | # define AVS_POSIX 108 | #else 109 | # error Operating system unsupported. 110 | #endif 111 | 112 | // useful warnings disabler macros for supported compilers 113 | 114 | #if defined(_MSC_VER) 115 | #define DISABLE_WARNING_PUSH __pragma(warning( push )) 116 | #define DISABLE_WARNING_POP __pragma(warning( pop )) 117 | #define DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber )) 118 | 119 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE DISABLE_WARNING(4101) 120 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(4505) 121 | // other warnings you want to deactivate... 122 | 123 | #elif defined(__GNUC__) || defined(__clang__) 124 | #define DO_PRAGMA(X) _Pragma(#X) 125 | #define DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push) 126 | #define DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop) 127 | #define DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored #warningName) 128 | 129 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE DISABLE_WARNING(-Wunused-variable) 130 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(-Wunused-function) 131 | // other warnings you want to deactivate... 132 | 133 | #else 134 | #define DISABLE_WARNING_PUSH 135 | #define DISABLE_WARNING_POP 136 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE 137 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION 138 | // other warnings you want to deactivate... 139 | 140 | #endif 141 | 142 | #if defined(AVS_POSIX) 143 | #define NEW_AVSVALUE 144 | #else 145 | #define NEW_AVSVALUE 146 | #endif 147 | 148 | #if defined(AVS_WINDOWS) 149 | // Windows XP does not have proper initialization for 150 | // thread local variables. 151 | // Use workaround instead __declspec(thread) 152 | #define XP_TLS 153 | #endif 154 | 155 | #endif //AVS_CONFIG_H 156 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Frfun7 ## 2 | 3 | Frfun7 is a spatial fractal denoising plugin by 4 | Copyright (C) 2002-2006, 2013 by Marc Fauconneau (prunedtree), (C)2021 Ferenc Pintér 5 | Additional work and fixes (C)2022 by dubhater. 6 | 7 | ### Usage 8 | ``` 9 | frfun7 (clip, float "lambda", float "T", float "Tuv", int "P", int "TP", int "R1") 10 | ``` 11 | clip = 12 | 13 | Input clip. 14 | 15 | 16 | float lambda = 1.1 17 | 18 | Adjust the power of the local denoising. 19 | 20 | It must not be negative. 21 | 22 | 23 | float T = 6.0 24 | 25 | Limits the max luma denoising power for edges; 0 disables processing. 26 | 27 | It must not be negative. 28 | 29 | 30 | float Tuv = 2.0 31 | 32 | Limits the max chroma denoising power for edges; 0 disables processing. 33 | 34 | It must not be negative. 35 | 36 | 37 | int P = 0 38 | 39 | By testing, one can conclude it's a "speed -vs- quality" trade off setting. 40 | 41 | 0 : faster but slightly lower quality than frfun7_rev6 (may create minor artifacts around line edges). 42 | 1 : adaptive overlapping (see also TP1). slower than frfun7_rev6 but the quality is a little bit better. 43 | 2 : temporal 44 | 4 : adaptive radius 45 | 46 | Internally the parameter is treated as a bit mask but probably it has no point. 47 | 48 | Parameter is available since frfun7 2013. 49 | 50 | 51 | int TP1 = 0 52 | 53 | A threshold which affects P=1 (adaptive overlapping). 54 | 0 will always run into a final filtering part. 55 | Values greater than 0 will make it skip processing some pixels. 56 | (Introduced as a separate parameter in r0.7test. This value had to be encoded into P as TP1*1000 previously.) 57 | 58 | int R1 = 3 59 | 60 | Radius for first pass of the internal algorithm. 61 | First pass in pre v0.7 was fixed to 3 (and was no separate parameter) 62 | Valid values are 2 or 3. 2 is faster. 63 | 64 | frfun7 with default settings: 65 | 66 | ``` 67 | AviSource("Blah.avi") 68 | frfun7(lambda=1.1, T=6.0, Tuv=2.0, P=0, TP1=0, R1=3) 69 | ``` 70 | 71 | ### Links 72 | 73 | http://avisynth.nl/index.php/Frfun7 74 | 75 | VapourSynth port: 76 | 77 | https://github.com/dubhater/vapoursynth-frfun7 78 | 79 | ### Other 80 | 81 | Special thanks to Reel.Deel for the testing and comparison with previous versions and maintaining the documentation at avisynth.nl. 82 | 83 | 84 | Build instructions 85 | ================== 86 | ## Visual Studio 2019: 87 | 88 | use IDE 89 | 90 | ## Windows GCC 91 | 92 | (mingw installed by msys2) 93 | From the 'build' folder under project root: 94 | 95 | ``` 96 | del ..\CMakeCache.txt 97 | cmake .. -G "MinGW Makefiles" -DENABLE_INTEL_SIMD:bool=on 98 | cmake --build . --config Release 99 | ``` 100 | 101 | ## Linux 102 | 103 | from the 'build' folder under project root: 104 | ENABLE_INTEL_SIMD is automatically off for non-x86 architectures 105 | Note: plugin source supports non-INTEL compilation since v0.8 106 | 107 | * Clone repo and build 108 | 109 | git clone https://github.com/pinterf/Frfun7 110 | cd Frfun7 111 | cmake -B build -S . 112 | cmake --build build 113 | 114 | Useful hints: 115 | build after clean: 116 | 117 | cmake --build build --clean-first 118 | 119 | Force no assembler support (valid since v0.8) 120 | 121 | cmake -B build -S . -DENABLE_INTEL_SIMD:bool=off 122 | 123 | 124 | delete CMake cache 125 | 126 | rm build/CMakeCache.txt 127 | 128 | * Find binaries at 129 | 130 | build/Frfun7/libfrfun7.so 131 | 132 | * Install binaries 133 | 134 | cd build 135 | sudo make install 136 | 137 | ### History 138 | ``` 139 | Version Date Changes 140 | 0.9 2022/06/29 - Performance increase in Intel sse2 - backport from VapourSynth (dubhater): 141 | p=0 184 fps to 304 fps 65% faster 142 | p=1 36 fps to 61 fps 69% faster 143 | p=2 233 fps to 282 fps 21% faster 144 | p=4 263 fps to 401 fps 52% faster 145 | note: The output is slightly different at the left and right edges of the frame. 146 | - additional fix bug when p=1 and tp1>0 147 | 0.8 2022/05/18 - backport some fixes and non-Intel C code from VapourSynth port by dubhater: 148 | - Fix P=2 (temporal) blocky rectangular artifacts at the most top and bottom area 149 | - Fix bug when p=1 and tp1>0 150 | - Avoid loss of precision when p=1 or p=2, Fixes https://github.com/pinterf/Frfun7/issues/1 151 | - Add C-only (other than Intel SIMD) code path, enable usage of ENABLE_INTEL_SIMD build option. 152 | 153 | 0.7 2021/09/09 - release 154 | 155 | 0.7 WIP 2021/05/25 - re-enable T=0, Tuv=0 cases (unprocessed plane copy) 156 | - add experimental TP1 (default 0) a threshold for P=1 (temporal overlapping) mode 157 | - add experimental R1 (default 3, can be set to 2) first pass radius 158 | 159 | 0.7 WIP 2021/05/20 - Source is based on a 2006/05/11 snapshot 160 | - Code refresh and additions by pinterf 161 | - move to git: https://github.com/pinterf/Frfun7 162 | - Source to VS2019 solution 163 | - Add readme, usage based on Avisynth wiki 164 | - Add/guess missing source parts, rename files 165 | - Update AviSynth headers 166 | - Add version resource 167 | - Avisynth V2.6 style plugin 168 | - Implement all mmx inline assembler as SIMD intrinsics 169 | - x64 build 170 | - fix some rounding and other issue 171 | 172 | 2013 2013/09/04 - no longer buffers the input; yields a nice speed increase. 173 | - "P" parameter added 174 | Note: frfun7 2013 is the updated version, unfortunately the output is 175 | not completely identical to frfun7_rev6, for that reason both versions 176 | are available. Read description of the P parameter for more information. 177 | 178 | rev6 2006/05/10 - bug fixes 179 | - remove mod8 restriction 180 | - process first and last frame 181 | 182 | rev1 2006/05/05 - initial release. 183 | 184 | ``` 185 | 186 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles/* 3 | 4 | #cmake generated files 5 | cmake_install.cmake 6 | cmake_uninstall.cmake 7 | generate.stamp 8 | generate.stamp.depend 9 | makefile 10 | 11 | #make 12 | install_manifest.txt 13 | 14 | ## Ignore Visual Studio temporary files, build results, and 15 | ## files generated by popular Visual Studio add-ons. 16 | ## 17 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 18 | 19 | # User-specific files 20 | *.rsuser 21 | *.suo 22 | *.user 23 | *.userosscache 24 | *.sln.docstates 25 | 26 | # User-specific files (MonoDevelop/Xamarin Studio) 27 | *.userprefs 28 | 29 | # Mono auto generated files 30 | mono_crash.* 31 | 32 | # Build results 33 | build/ 34 | [Dd]ebug/ 35 | [Dd]ebugPublic/ 36 | [Rr]elease/ 37 | [Rr]eleases/ 38 | [Rr]elease Clang/ 39 | [Rr]eleases/ 40 | x64/ 41 | x86/ 42 | [Aa][Rr][Mm]/ 43 | [Aa][Rr][Mm]64/ 44 | bld/ 45 | [Bb]in/ 46 | [Oo]bj/ 47 | [Ll]og/ 48 | [Ll]ogs/ 49 | 50 | # Visual Studio 2015/2017 cache/options directory 51 | .vs/ 52 | # Uncomment if you have tasks that create the project's static files in wwwroot 53 | #wwwroot/ 54 | 55 | # Visual Studio 2017 auto generated files 56 | Generated\ Files/ 57 | 58 | # MSTest test Results 59 | [Tt]est[Rr]esult*/ 60 | [Bb]uild[Ll]og.* 61 | 62 | # NUnit 63 | *.VisualState.xml 64 | TestResult.xml 65 | nunit-*.xml 66 | 67 | # Build Results of an ATL Project 68 | [Dd]ebugPS/ 69 | [Rr]eleasePS/ 70 | dlldata.c 71 | 72 | # Benchmark Results 73 | BenchmarkDotNet.Artifacts/ 74 | 75 | # .NET Core 76 | project.lock.json 77 | project.fragment.lock.json 78 | artifacts/ 79 | 80 | # StyleCop 81 | StyleCopReport.xml 82 | 83 | # Files built by Visual Studio 84 | *_i.c 85 | *_p.c 86 | *_h.h 87 | *.ilk 88 | *.meta 89 | *.obj 90 | *.iobj 91 | *.pch 92 | *.pdb 93 | *.ipdb 94 | *.pgc 95 | *.pgd 96 | *.rsp 97 | *.sbr 98 | *.tlb 99 | *.tli 100 | *.tlh 101 | *.tmp 102 | *.tmp_proj 103 | *_wpftmp.csproj 104 | *.log 105 | *.vspscc 106 | *.vssscc 107 | .builds 108 | *.pidb 109 | *.svclog 110 | *.scc 111 | 112 | # Chutzpah Test files 113 | _Chutzpah* 114 | 115 | # Visual C++ cache files 116 | ipch/ 117 | *.aps 118 | *.ncb 119 | *.opendb 120 | *.opensdf 121 | *.sdf 122 | *.cachefile 123 | *.VC.db 124 | *.VC.VC.opendb 125 | 126 | # Visual Studio profiler 127 | *.psess 128 | *.vsp 129 | *.vspx 130 | *.sap 131 | 132 | # Visual Studio Trace Files 133 | *.e2e 134 | 135 | # TFS 2012 Local Workspace 136 | $tf/ 137 | 138 | # Guidance Automation Toolkit 139 | *.gpState 140 | 141 | # ReSharper is a .NET coding add-in 142 | _ReSharper*/ 143 | *.[Rr]e[Ss]harper 144 | *.DotSettings.user 145 | 146 | # TeamCity is a build add-in 147 | _TeamCity* 148 | 149 | # DotCover is a Code Coverage Tool 150 | *.dotCover 151 | 152 | # AxoCover is a Code Coverage Tool 153 | .axoCover/* 154 | !.axoCover/settings.json 155 | 156 | # Visual Studio code coverage results 157 | *.coverage 158 | *.coveragexml 159 | 160 | # NCrunch 161 | _NCrunch_* 162 | .*crunch*.local.xml 163 | nCrunchTemp_* 164 | 165 | # MightyMoose 166 | *.mm.* 167 | AutoTest.Net/ 168 | 169 | # Web workbench (sass) 170 | .sass-cache/ 171 | 172 | # Installshield output folder 173 | [Ee]xpress/ 174 | 175 | # DocProject is a documentation generator add-in 176 | DocProject/buildhelp/ 177 | DocProject/Help/*.HxT 178 | DocProject/Help/*.HxC 179 | DocProject/Help/*.hhc 180 | DocProject/Help/*.hhk 181 | DocProject/Help/*.hhp 182 | DocProject/Help/Html2 183 | DocProject/Help/html 184 | 185 | # Click-Once directory 186 | publish/ 187 | 188 | # Publish Web Output 189 | *.[Pp]ublish.xml 190 | *.azurePubxml 191 | # Note: Comment the next line if you want to checkin your web deploy settings, 192 | # but database connection strings (with potential passwords) will be unencrypted 193 | *.pubxml 194 | *.publishproj 195 | 196 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 197 | # checkin your Azure Web App publish settings, but sensitive information contained 198 | # in these scripts will be unencrypted 199 | PublishScripts/ 200 | 201 | # NuGet Packages 202 | *.nupkg 203 | # NuGet Symbol Packages 204 | *.snupkg 205 | # The packages folder can be ignored because of Package Restore 206 | **/[Pp]ackages/* 207 | # except build/, which is used as an MSBuild target. 208 | !**/[Pp]ackages/build/ 209 | # Uncomment if necessary however generally it will be regenerated when needed 210 | #!**/[Pp]ackages/repositories.config 211 | # NuGet v3's project.json files produces more ignorable files 212 | *.nuget.props 213 | *.nuget.targets 214 | 215 | # Microsoft Azure Build Output 216 | csx/ 217 | *.build.csdef 218 | 219 | # Microsoft Azure Emulator 220 | ecf/ 221 | rcf/ 222 | 223 | # Windows Store app package directories and files 224 | AppPackages/ 225 | BundleArtifacts/ 226 | Package.StoreAssociation.xml 227 | _pkginfo.txt 228 | *.appx 229 | *.appxbundle 230 | *.appxupload 231 | 232 | # Visual Studio cache files 233 | # files ending in .cache can be ignored 234 | *.[Cc]ache 235 | # but keep track of directories ending in .cache 236 | !?*.[Cc]ache/ 237 | 238 | # Others 239 | ClientBin/ 240 | ~$* 241 | *~ 242 | *.dbmdl 243 | *.dbproj.schemaview 244 | *.jfm 245 | *.pfx 246 | *.publishsettings 247 | orleans.codegen.cs 248 | 249 | # Including strong name files can present a security risk 250 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 251 | #*.snk 252 | 253 | # Since there are multiple workflows, uncomment next line to ignore bower_components 254 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 255 | #bower_components/ 256 | 257 | # RIA/Silverlight projects 258 | Generated_Code/ 259 | 260 | # Backup & report files from converting an old project file 261 | # to a newer Visual Studio version. Backup files are not needed, 262 | # because we have git ;-) 263 | _UpgradeReport_Files/ 264 | Backup*/ 265 | UpgradeLog*.XML 266 | UpgradeLog*.htm 267 | ServiceFabricBackup/ 268 | *.rptproj.bak 269 | 270 | # SQL Server files 271 | *.mdf 272 | *.ldf 273 | *.ndf 274 | 275 | # Business Intelligence projects 276 | *.rdl.data 277 | *.bim.layout 278 | *.bim_*.settings 279 | *.rptproj.rsuser 280 | *- [Bb]ackup.rdl 281 | *- [Bb]ackup ([0-9]).rdl 282 | *- [Bb]ackup ([0-9][0-9]).rdl 283 | 284 | # Microsoft Fakes 285 | FakesAssemblies/ 286 | 287 | # GhostDoc plugin setting file 288 | *.GhostDoc.xml 289 | 290 | # Node.js Tools for Visual Studio 291 | .ntvs_analysis.dat 292 | node_modules/ 293 | 294 | # Visual Studio 6 build log 295 | *.plg 296 | 297 | # Visual Studio 6 workspace options file 298 | *.opt 299 | 300 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 301 | *.vbw 302 | 303 | # Visual Studio LightSwitch build output 304 | **/*.HTMLClient/GeneratedArtifacts 305 | **/*.DesktopClient/GeneratedArtifacts 306 | **/*.DesktopClient/ModelManifest.xml 307 | **/*.Server/GeneratedArtifacts 308 | **/*.Server/ModelManifest.xml 309 | _Pvt_Extensions 310 | 311 | # Paket dependency manager 312 | .paket/paket.exe 313 | paket-files/ 314 | 315 | # FAKE - F# Make 316 | .fake/ 317 | 318 | # CodeRush personal settings 319 | .cr/personal 320 | 321 | # Python Tools for Visual Studio (PTVS) 322 | __pycache__/ 323 | *.pyc 324 | 325 | # Cake - Uncomment if you are using it 326 | # tools/** 327 | # !tools/packages.config 328 | 329 | # Tabs Studio 330 | *.tss 331 | 332 | # Telerik's JustMock configuration file 333 | *.jmconfig 334 | 335 | # BizTalk build output 336 | *.btp.cs 337 | *.btm.cs 338 | *.odx.cs 339 | *.xsd.cs 340 | 341 | # OpenCover UI analysis results 342 | OpenCover/ 343 | 344 | # Azure Stream Analytics local run output 345 | ASALocalRun/ 346 | 347 | # MSBuild Binary and Structured Log 348 | *.binlog 349 | 350 | # NVidia Nsight GPU debugger configuration file 351 | *.nvuser 352 | 353 | # MFractors (Xamarin productivity tool) working folder 354 | .mfractor/ 355 | 356 | # Local History for Visual Studio 357 | .localhistory/ 358 | 359 | # BeatPulse healthcheck temp database 360 | healthchecksdb 361 | 362 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 363 | MigrationBackup/ 364 | 365 | # Ionide (cross platform F# VS Code tools) working folder 366 | .ionide/ 367 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | # CMAKE_CXX_STANDARD to be set to C++17. 3 | # Visual Studio 2019 is supported from CMake 3.14.1 4 | project(Frfun7 LANGUAGES CXX) 5 | 6 | include(GNUInstallDirs) 7 | 8 | # Avoid uselessly linking to unused libraries 9 | set(CMAKE_STANDARD_LIBRARIES "" CACHE STRING "" FORCE) 10 | set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE) 11 | set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE) 12 | 13 | # We require C++17 or higher. 14 | set(CMAKE_CXX_STANDARD 17) 15 | set(CMAKE_CXX_STANDARD_REQUIRED TRUE) 16 | set(CMAKE_CXX_EXTENSIONS FALSE) 17 | 18 | option(ENABLE_INTEL_SIMD "Enable SIMD intrinsics for Intel processors" ON) 19 | 20 | IF( MSVC ) # Check for Visual Studio 21 | 22 | #1800 = VS 12.0 (v120 toolset) 23 | #1900 = VS 14.0 (v140 toolset) 24 | #1910-1919 = VS 15.0 (v141 toolset) Visual Studio 2017 25 | #1920 = VS 16.0 (v142 toolset) Visual Studio 2019 26 | 27 | IF( MSVC_VERSION VERSION_LESS 1910 ) 28 | MESSAGE(FATAL_ERROR "Visual C++ 2017 or newer required.") 29 | ENDIF() 30 | IF(MSVC_IDE) 31 | message("Reported CMAKE_GENERATOR_TOOLSET is: ${CMAKE_GENERATOR_TOOLSET}") 32 | 33 | # For LLVM Clang installed separately, specify llvm or LLVM 34 | # Since Visual Studio 2019 v16.4, LLVM 9.0 is integrated, for this use Toolset: ClangCL 35 | IF(CMAKE_GENERATOR_TOOLSET STREQUAL "LLVM" OR CMAKE_GENERATOR_TOOLSET STREQUAL "llvm" OR CMAKE_GENERATOR_TOOLSET STREQUAL "ClangCL") 36 | if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") # hope: always 37 | message("LLVM toolset was specified via -T. Compiler ID is: ${CMAKE_CXX_COMPILER_ID}; CMAKE_CXX_COMPILER_VERSION is: ${CMAKE_CXX_COMPILER_VERSION}") 38 | # Clang; 9.0.0 39 | # These are probably not supported when clang is downloaded as a ready-made binary: CLANG_VERSION_MAJOR CLANG_VERSION_MINOR CLANG_VERSION_STRING 40 | # string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string}) 41 | if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.1 ) 42 | MESSAGE(FATAL_ERROR "Clang 7.0.1 or newer required") # as of 2019.december actually we are using 9.0 43 | endif() 44 | endif() 45 | set(CLANG_IN_VS "1") 46 | ELSEIF(CMAKE_GENERATOR_TOOLSET STREQUAL "v141_clang_c2") 47 | #1900 is reported 48 | message("v141_clang_c2 toolset was specified via -T. Reported MSVC_VERSION is: ${MSVC_VERSION}") 49 | message("May not work, try LLVM") 50 | set(CLANG_IN_VS "1") 51 | ENDIF() 52 | 53 | option(WINXP_SUPPORT "Make binaries compatible with Windows XP and Vista" OFF) 54 | if(WINXP_SUPPORT) 55 | # We want our project to also run on Windows XP 56 | # Not for LLVM: Clang stopped XP support in 2016 57 | # 1900 (VS2015) is not supported but we leave here 58 | IF(MSVC_VERSION VERSION_LESS 1910 ) 59 | IF(NOT CLANG_IN_VS STREQUAL "1") 60 | set(CMAKE_GENERATOR_TOOLSET "v140_xp" CACHE STRING "The compiler toolset to use for Visual Studio." FORCE) # VS2015 61 | # https://connect.microsoft.com/VisualStudio/feedback/details/1789709/visual-c-2015-runtime-broken-on-windows-server-2003-c-11-magic-statics 62 | message("CMAKE_GENERATOR_TOOLSET is forced to: ${CMAKE_GENERATOR_TOOLSET}") 63 | add_definitions("/Zc:threadSafeInit-") 64 | ENDIF() 65 | ELSE() 66 | IF(NOT CLANG_IN_VS STREQUAL "1") 67 | set(CMAKE_GENERATOR_TOOLSET "v141_xp" CACHE STRING "The compiler toolset to use for Visual Studio." FORCE) # VS2017, also choosable for VS2019 68 | # https://connect.microsoft.com/VisualStudio/feedback/details/1789709/visual-c-2015-runtime-broken-on-windows-server-2003-c-11-magic-statics 69 | message("CMAKE_GENERATOR_TOOLSET is forced to: ${CMAKE_GENERATOR_TOOLSET}") 70 | add_definitions("/Zc:threadSafeInit-") 71 | ENDIF() 72 | ENDIF() 73 | endif() 74 | ENDIF() 75 | 76 | IF(CLANG_IN_VS STREQUAL "1") 77 | #these are unknown 78 | #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions") 79 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") 80 | STRING( REPLACE "/EHsc" "/EHa" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") 81 | STRING( REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 82 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-inconsistent-missing-override") 83 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override") 84 | ELSE() 85 | # Enable C++ with SEH exceptions 86 | # Avoid an obnoxious 'overrriding /EHsc with /EHa' warning when 87 | # using something other than MSBuild 88 | STRING( REPLACE "/EHsc" "/EHa" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") 89 | STRING( REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 90 | ENDIF() 91 | # Prevent VC++ from complaining about not using MS-specific functions 92 | add_definitions("/D _CRT_SECURE_NO_WARNINGS /D _SECURE_SCL=0") 93 | 94 | # Enable CRT heap debugging - only effective in debug builds 95 | add_definitions("/D _CRTDBG_MAP_ALLOC") 96 | 97 | # if missing, some modules inhibit source containing assembler/simd parts 98 | add_definitions("/D __SSE2__") 99 | 100 | # Set additional optimization flags 101 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oy /Ot /GS- /Oi") 102 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oy /Ot /GS- /Oi") 103 | 104 | # CPU_ARCH can be overridden with the corresponding values when using MSVC: 105 | # IA32 (disabled), 106 | # SSE (Pentium III and higher, 1999), 107 | # SSE2 (Pentium 4 and higher, 2000/2001), 108 | # AVX (Sandy Bridge and higher, 2011), 109 | # AVX2 (Haswell and higher, 2013) 110 | set(MSVC_CPU_ARCH "SSE2" CACHE STRING "Set MSVC architecture optimization level (default: SSE2)") 111 | 112 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:${MSVC_CPU_ARCH}") 113 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:${MSVC_CPU_ARCH}") 114 | 115 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 116 | # MSVC doesn't allow 64-bit builds to have their /arch set to SSE2 (no-op) or below 117 | if("${MSVC_CPU_ARCH}" MATCHES "(IA32|SSE|SSE2)") 118 | set(DELETE_THIS "/arch:${MSVC_CPU_ARCH}") 119 | message("MSVC doesn't allow x86-64 builds to define /arch:${MSVC_CPU_ARCH}. Setting will be ignored.") 120 | STRING( REPLACE "${DELETE_THIS}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") 121 | STRING( REPLACE "${DELETE_THIS}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 122 | endif() 123 | endif() 124 | 125 | IF(CLANG_IN_VS STREQUAL "1") 126 | # suppress other frequent but harmless/unavoidable warnings 127 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") 128 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") 129 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder") 130 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-reorder") 131 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-value") 132 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-value") 133 | # allow per-function attributes like __attribute__((__target__("sse4.1"))) 134 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gcc-compat") 135 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-gcc-compat") 136 | ENDIF() 137 | 138 | # Enable standards-conformance mode for MSVC compilers that support this 139 | # flag (Visual C++ 2017 and later). Default. DirectShowSource will remove if needed. 140 | if (NOT (MSVC_VERSION LESS 1910)) 141 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-") 142 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /permissive-") 143 | endif() 144 | 145 | if(ENABLE_INTEL_SIMD) 146 | add_definitions("/D INTEL_INTRINSICS") 147 | endif() 148 | 149 | ELSE() 150 | # other than MSVC 151 | if(ENABLE_INTEL_SIMD) 152 | SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -DINTEL_INTRINSICS" ) 153 | endif() 154 | IF(WIN32) 155 | SET( CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-stdcall-fixup" ) 156 | ELSE() 157 | if(APPLE) 158 | # macOS uses Clang's linker, doesn't like --no-undefined 159 | SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,error" ) 160 | else() 161 | if(GNUC) 162 | # make sure there are no undefined symbols 163 | SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" ) 164 | endif() 165 | endif() 166 | ENDIF() 167 | 168 | ENDIF() 169 | 170 | 171 | add_subdirectory(Frfun7) 172 | 173 | # uninstall target 174 | configure_file( 175 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" 176 | "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" 177 | IMMEDIATE @ONLY) 178 | 179 | add_custom_target(uninstall 180 | COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) 181 | -------------------------------------------------------------------------------- /Frfun7/Frfun7.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | ReleaseClang 14 | Win32 15 | 16 | 17 | ReleaseClang 18 | x64 19 | 20 | 21 | Release 22 | Win32 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | 30 | {29983FF5-313E-46C2-AEA7-BCA7E546A3E3} 31 | Frfun7 32 | 10.0 33 | 34 | 35 | 36 | DynamicLibrary 37 | true 38 | v142 39 | MultiByte 40 | 41 | 42 | DynamicLibrary 43 | true 44 | v142 45 | MultiByte 46 | 47 | 48 | DynamicLibrary 49 | false 50 | v142 51 | true 52 | MultiByte 53 | 54 | 55 | DynamicLibrary 56 | false 57 | ClangCL 58 | true 59 | MultiByte 60 | 61 | 62 | DynamicLibrary 63 | false 64 | v142 65 | true 66 | MultiByte 67 | 68 | 69 | DynamicLibrary 70 | false 71 | ClangCL 72 | true 73 | MultiByte 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | $(SolutionDir)Build\$(Platform)\$(Configuration)\ 99 | $(SolutionDir)Build\$(Platform)\Temp\$(Configuration)\ 100 | 101 | 102 | $(SolutionDir)Build\$(Platform)\$(Configuration)\ 103 | $(SolutionDir)Build\$(Platform)\Temp\$(Configuration)\ 104 | 105 | 106 | $(SolutionDir)Build\$(Platform)\$(Configuration)\ 107 | $(SolutionDir)Build\$(Platform)\Temp\$(Configuration)\ 108 | 109 | 110 | $(SolutionDir)Build\$(Platform)\$(Configuration)\ 111 | $(SolutionDir)Build\$(Platform)\Temp\$(Configuration)\ 112 | 113 | 114 | $(SolutionDir)Build\$(Platform)\$(Configuration)\ 115 | $(SolutionDir)Build\$(Platform)\Temp\$(Configuration)\ 116 | 117 | 118 | $(SolutionDir)Build\$(Platform)\$(Configuration)\ 119 | $(SolutionDir)Build\$(Platform)\Temp\$(Configuration)\ 120 | 121 | 122 | 123 | Level3 124 | Disabled 125 | true 126 | .\ 127 | /Zc:threadSafeInit- %(AdditionalOptions) 128 | stdcpp17 129 | StreamingSIMDExtensions2 130 | _WINDLL;INTEL_INTRINSICS;%(PreprocessorDefinitions) 131 | 132 | 133 | true 134 | 135 | 136 | 137 | 138 | Level3 139 | Disabled 140 | true 141 | .\ 142 | /Zc:threadSafeInit- %(AdditionalOptions) 143 | stdcpp17 144 | _WINDLL;INTEL_INTRINSICS;%(PreprocessorDefinitions) 145 | 146 | 147 | true 148 | 149 | 150 | 151 | 152 | Level3 153 | MaxSpeed 154 | true 155 | true 156 | true 157 | AssemblyAndSourceCode 158 | .\ 159 | /Zc:threadSafeInit- %(AdditionalOptions) 160 | AnySuitable 161 | Speed 162 | false 163 | true 164 | StreamingSIMDExtensions2 165 | stdcpp17 166 | _WINDLL;INTEL_INTRINSICS;%(PreprocessorDefinitions) 167 | 168 | 169 | true 170 | true 171 | true 172 | 173 | 174 | 175 | 176 | Level3 177 | MaxSpeed 178 | true 179 | true 180 | true 181 | NoListing 182 | .\ 183 | /Zc:threadSafeInit- %(AdditionalOptions) 184 | AnySuitable 185 | Speed 186 | false 187 | true 188 | StreamingSIMDExtensions2 189 | stdcpp17 190 | _WINDLL;INTEL_INTRINSICS;%(PreprocessorDefinitions) 191 | 192 | 193 | true 194 | true 195 | true 196 | 197 | 198 | 199 | 200 | Level3 201 | MaxSpeed 202 | true 203 | true 204 | true 205 | AssemblyAndSourceCode 206 | .\ 207 | /Zc:threadSafeInit- %(AdditionalOptions) 208 | AnySuitable 209 | Speed 210 | false 211 | stdcpp17 212 | NotSet 213 | _WINDLL;INTEL_INTRINSICS;%(PreprocessorDefinitions) 214 | 215 | 216 | true 217 | true 218 | true 219 | 220 | 221 | 222 | 223 | Level3 224 | MaxSpeed 225 | true 226 | true 227 | true 228 | NoListing 229 | .\ 230 | /Zc:threadSafeInit- %(AdditionalOptions) 231 | AnySuitable 232 | Speed 233 | false 234 | stdcpp17 235 | NotSet 236 | _WINDLL;INTEL_INTRINSICS;%(PreprocessorDefinitions) 237 | 238 | 239 | true 240 | true 241 | true 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Frfun7/avisynth.h: -------------------------------------------------------------------------------- 1 | // Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al. 2 | // Avisynth v2.6. Copyright 2006 Klaus Post. 3 | // Avisynth v2.6. Copyright 2009 Ian Brabham. 4 | // Avisynth+ project 5 | // 20160613: new 16 bit planar pixel_type constants go live! 6 | // 20160725: pixel_type constants 10-12-14 bit + planar RGB + BRG48/64 7 | // 20161005: Fallback of VideoInfo functions to defaults if no function exists 8 | // 20170117: global variables for VfW output OPT_xxxx 9 | // 20170310: new MT mode: MT_SPECIAL_MT 10 | // 20171103: (test with SIZETMOD define: Videoframe offsets to size_t, may affect x64) 11 | // 20171207: C++ Standard Conformance (no change for plugin writers) 12 | // 20180525: AVS_UNUSED define to supress parameter not used warnings 13 | // 2020xxxx: AVS_WINDOWS and AVS_POSIX option see avs/config.h 14 | // 20200305: ScriptEnvironment::VSprintf parameter (void *) changed back to va_list 15 | // 20200330: removed __stdcall from variadic argument functions (Sprintf) 16 | // (remove test SIZETMOD define for clarity) 17 | // Integrate Avisynth Neo structures and interface, PFunction, PDevice 18 | // 20200501: frame property support (NewVideoFrameP and other helpers) to legacy IScriptEnvironment. 19 | // move some former IScriptEnvironment2 functions to IScriptEnvironment: 20 | // GetEnvProperty (system prop), Allocate, Free (buffer pool) 21 | // GetVarTry, GetVarBool/Int/String/Double/Long 22 | // Invoke2, Invoke3, InvokeTry, Invoke2Try, Invoke3Try 23 | // Interface Version to 8 (classic 2.6 = 6) 24 | // 20200527 Add IScriptEnvironment_Avs25, used internally 25 | // 20200607 AVS frame property enums to match existing Avisynth enum style 26 | 27 | // http://www.avisynth.org 28 | 29 | // This program is free software; you can redistribute it and/or modify 30 | // it under the terms of the GNU General Public License as published by 31 | // the Free Software Foundation; either version 2 of the License, or 32 | // (at your option) any later version. 33 | // 34 | // This program is distributed in the hope that it will be useful, 35 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 36 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 37 | // GNU General Public License for more details. 38 | // 39 | // You should have received a copy of the GNU General Public License 40 | // along with this program; if not, write to the Free Software 41 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 42 | // http://www.gnu.org/copyleft/gpl.html . 43 | // 44 | // Linking Avisynth statically or dynamically with other modules is making 45 | // a combined work based on Avisynth. Thus, the terms and conditions of 46 | // the GNU General Public License cover the whole combination. 47 | // 48 | // As a special exception, the copyright holders of Avisynth give you 49 | // permission to link Avisynth with independent modules that communicate 50 | // with Avisynth solely through the interfaces defined in avisynth.h, 51 | // regardless of the license terms of these independent modules, and to 52 | // copy and distribute the resulting combined work under terms of your 53 | // choice, provided that every copy of the combined work is accompanied 54 | // by a complete copy of the source code of Avisynth (the version of 55 | // Avisynth used to produce the combined work), being distributed under 56 | // the terms of the GNU General Public License plus this exception. An 57 | // independent module is a module which is not derived from or based on 58 | // Avisynth, such as 3rd-party filters, import and export plugins, or 59 | // graphical user interfaces. 60 | 61 | 62 | #ifndef __AVISYNTH_8_H__ 63 | #define __AVISYNTH_8_H__ 64 | 65 | #include "avs/config.h" 66 | #include "avs/capi.h" 67 | #include "avs/types.h" 68 | 69 | #ifdef AVS_POSIX 70 | # include "avs/posix.h" 71 | #endif 72 | 73 | #if defined(AVS_POSIX) 74 | #if defined(AVS_HAIKU) 75 | #undef __stdcall 76 | #undef __cdecl 77 | #endif 78 | #define __stdcall 79 | #define __cdecl 80 | #endif 81 | 82 | // Important note on AVISYNTH_INTERFACE_VERSION V6->V8 change: 83 | // Note 1: Those few plugins which were using earlier IScriptEnvironment2 despite the big Warning will crash have to be rebuilt. 84 | // Note 2: How to support earlier avisynth interface with an up-to-date avisynth.h: 85 | // Use the new frame property features adaptively after querying that at least v8 is supported 86 | // AviSynth property support can be queried (cpp iface example): 87 | // has_at_least_v8 = true; 88 | // try { env->CheckVersion(8); } catch (const AvisynthError&) { has_at_least_v8 = false; } 89 | // and use it: 90 | // if (has_at_least_v8) dst = env->NewVideoFrameP(vi, &src); else dst = env->NewVideoFrame(vi); 91 | 92 | enum { 93 | AVISYNTH_CLASSIC_INTERFACE_VERSION_25 = 3, 94 | AVISYNTH_CLASSIC_INTERFACE_VERSION_26BETA = 5, 95 | AVISYNTH_CLASSIC_INTERFACE_VERSION = 6, 96 | AVISYNTH_INTERFACE_VERSION = 8 97 | }; 98 | 99 | /* Compiler-specific crap */ 100 | 101 | // Tell MSVC to stop precompiling here 102 | #if defined(_MSC_VER) && !defined(__clang__) 103 | #pragma hdrstop 104 | #endif 105 | 106 | // Set up debugging macros for MS compilers; for others, step down to the 107 | // standard interface 108 | #ifdef _MSC_VER 109 | #include 110 | #else 111 | #undef _RPT0 112 | #undef _RPT1 113 | #undef _RPT2 114 | #undef _RPT3 115 | #undef _RPT4 116 | #undef _RPT5 117 | #define _RPT0(a,b) ((void)0) 118 | #define _RPT1(a,b,c) ((void)0) 119 | #define _RPT2(a,b,c,d) ((void)0) 120 | #define _RPT3(a,b,c,d,e) ((void)0) 121 | #define _RPT4(a,b,c,d,e,f) ((void)0) 122 | #define _RPT5(a,b,c,d,e,f,g) ((void)0) 123 | 124 | #include 125 | #undef _ASSERTE 126 | #undef _ASSERT 127 | #define _ASSERTE(x) assert(x) 128 | #define _ASSERT(x) assert(x) 129 | #endif 130 | 131 | 132 | 133 | // I had problems with Premiere wanting 1-byte alignment for its structures, 134 | // so I now set the Avisynth struct alignment explicitly here. 135 | #pragma pack(push,8) 136 | 137 | // The VideoInfo struct holds global information about a clip (i.e. 138 | // information that does not depend on the frame number). The GetVideoInfo 139 | // method in IClip returns this struct. 140 | 141 | enum {SAMPLE_INT8 = 1<<0, 142 | SAMPLE_INT16 = 1<<1, 143 | SAMPLE_INT24 = 1<<2, // Int24 is a very stupid thing to code, but it's supported by some hardware. 144 | SAMPLE_INT32 = 1<<3, 145 | SAMPLE_FLOAT = 1<<4}; 146 | 147 | enum { 148 | PLANAR_Y=1<<0, 149 | PLANAR_U=1<<1, 150 | PLANAR_V=1<<2, 151 | PLANAR_ALIGNED=1<<3, 152 | PLANAR_Y_ALIGNED=PLANAR_Y|PLANAR_ALIGNED, 153 | PLANAR_U_ALIGNED=PLANAR_U|PLANAR_ALIGNED, 154 | PLANAR_V_ALIGNED=PLANAR_V|PLANAR_ALIGNED, 155 | PLANAR_A=1<<4, 156 | PLANAR_R=1<<5, 157 | PLANAR_G=1<<6, 158 | PLANAR_B=1<<7, 159 | PLANAR_A_ALIGNED=PLANAR_A|PLANAR_ALIGNED, 160 | PLANAR_R_ALIGNED=PLANAR_R|PLANAR_ALIGNED, 161 | PLANAR_G_ALIGNED=PLANAR_G|PLANAR_ALIGNED, 162 | PLANAR_B_ALIGNED=PLANAR_B|PLANAR_ALIGNED, 163 | }; 164 | 165 | class AvisynthError /* exception */ { 166 | public: 167 | const char* const msg; 168 | AvisynthError(const char* _msg) : msg(_msg) {} 169 | 170 | // Ensure AvisynthError cannot be publicly assigned! 171 | private: 172 | AvisynthError& operator=(const AvisynthError&); 173 | }; // end class AvisynthError 174 | 175 | enum AvsDeviceType { 176 | DEV_TYPE_NONE = 0, 177 | DEV_TYPE_CPU = 1, 178 | DEV_TYPE_CUDA = 2, 179 | DEV_TYPE_ANY = 0xFFFF 180 | }; 181 | 182 | /* Forward references */ 183 | #if defined(MSVC) 184 | #define SINGLE_INHERITANCE __single_inheritance 185 | #else 186 | #define SINGLE_INHERITANCE 187 | #endif 188 | struct SINGLE_INHERITANCE VideoInfo; 189 | class SINGLE_INHERITANCE VideoFrameBuffer; 190 | class SINGLE_INHERITANCE VideoFrame; 191 | class IClip; 192 | class SINGLE_INHERITANCE PClip; 193 | class SINGLE_INHERITANCE PVideoFrame; 194 | class IScriptEnvironment; 195 | class SINGLE_INHERITANCE AVSValue; 196 | class INeoEnv; 197 | class IFunction; 198 | class SINGLE_INHERITANCE PFunction; 199 | class Device; 200 | class SINGLE_INHERITANCE PDevice; 201 | class AVSMap; 202 | 203 | 204 | 205 | /* 206 | * Avisynth C++ plugin API code function pointers. 207 | * 208 | * In order to maintain binary compatibility with 209 | * future version do not change the order of the 210 | * existing function pointers. It will be baked 211 | * into all existing plugins. 212 | * 213 | * Add new function pointers to the end of the 214 | * structure. The linkage macros generate some 215 | * protection code to ensure newer plugin do not 216 | * call non-existing functions in an older host. 217 | */ 218 | 219 | struct AVS_Linkage { 220 | 221 | int Size; 222 | 223 | /**********************************************************************/ 224 | 225 | // struct VideoInfo 226 | bool (VideoInfo::*HasVideo)() const; 227 | bool (VideoInfo::*HasAudio)() const; 228 | bool (VideoInfo::*IsRGB)() const; 229 | bool (VideoInfo::*IsRGB24)() const; 230 | bool (VideoInfo::*IsRGB32)() const; 231 | bool (VideoInfo::*IsYUV)() const; 232 | bool (VideoInfo::*IsYUY2)() const; 233 | bool (VideoInfo::*IsYV24)() const; 234 | bool (VideoInfo::*IsYV16)() const; 235 | bool (VideoInfo::*IsYV12)() const; 236 | bool (VideoInfo::*IsYV411)() const; 237 | bool (VideoInfo::*IsY8)() const; 238 | bool (VideoInfo::*IsColorSpace)(int c_space) const; 239 | bool (VideoInfo::*Is)(int property) const; 240 | bool (VideoInfo::*IsPlanar)() const; 241 | bool (VideoInfo::*IsFieldBased)() const; 242 | bool (VideoInfo::*IsParityKnown)() const; 243 | bool (VideoInfo::*IsBFF)() const; 244 | bool (VideoInfo::*IsTFF)() const; 245 | bool (VideoInfo::*IsVPlaneFirst)() const; 246 | int (VideoInfo::*BytesFromPixels)(int pixels) const; 247 | int (VideoInfo::*RowSize)(int plane) const; 248 | int (VideoInfo::*BMPSize)() const; 249 | int64_t (VideoInfo::*AudioSamplesFromFrames)(int frames) const; 250 | int (VideoInfo::*FramesFromAudioSamples)(int64_t samples) const; 251 | int64_t (VideoInfo::*AudioSamplesFromBytes)(int64_t bytes) const; 252 | int64_t (VideoInfo::*BytesFromAudioSamples)(int64_t samples) const; 253 | int (VideoInfo::*AudioChannels)() const; 254 | int (VideoInfo::*SampleType)() const; 255 | bool (VideoInfo::*IsSampleType)(int testtype) const; 256 | int (VideoInfo::*SamplesPerSecond)() const; 257 | int (VideoInfo::*BytesPerAudioSample)() const; 258 | void (VideoInfo::*SetFieldBased)(bool isfieldbased); 259 | void (VideoInfo::*Set)(int property); 260 | void (VideoInfo::*Clear)(int property); 261 | int (VideoInfo::*GetPlaneWidthSubsampling)(int plane) const; 262 | int (VideoInfo::*GetPlaneHeightSubsampling)(int plane) const; 263 | int (VideoInfo::*BitsPerPixel)() const; 264 | int (VideoInfo::*BytesPerChannelSample)() const; 265 | void (VideoInfo::*SetFPS)(unsigned numerator, unsigned denominator); 266 | void (VideoInfo::*MulDivFPS)(unsigned multiplier, unsigned divisor); 267 | bool (VideoInfo::*IsSameColorspace)(const VideoInfo& vi) const; 268 | // end struct VideoInfo 269 | 270 | /**********************************************************************/ 271 | 272 | // class VideoFrameBuffer 273 | const BYTE* (VideoFrameBuffer::*VFBGetReadPtr)() const; 274 | BYTE* (VideoFrameBuffer::*VFBGetWritePtr)(); 275 | int (VideoFrameBuffer::*GetDataSize)() const; 276 | int (VideoFrameBuffer::*GetSequenceNumber)() const; 277 | int (VideoFrameBuffer::*GetRefcount)() const; 278 | // end class VideoFrameBuffer 279 | 280 | /**********************************************************************/ 281 | 282 | // class VideoFrame 283 | int (VideoFrame::*GetPitch)(int plane) const; 284 | int (VideoFrame::*GetRowSize)(int plane) const; 285 | int (VideoFrame::*GetHeight)(int plane) const; 286 | VideoFrameBuffer* (VideoFrame::*GetFrameBuffer)() const; 287 | int (VideoFrame::*GetOffset)(int plane) const; 288 | const BYTE* (VideoFrame::*VFGetReadPtr)(int plane) const; 289 | bool (VideoFrame::*IsWritable)() const; 290 | BYTE* (VideoFrame::*VFGetWritePtr)(int plane) const; 291 | void (VideoFrame::*VideoFrame_DESTRUCTOR)(); 292 | // end class VideoFrame 293 | 294 | /**********************************************************************/ 295 | 296 | // class IClip 297 | /* nothing */ 298 | // end class IClip 299 | 300 | /**********************************************************************/ 301 | 302 | // class PClip 303 | void (PClip::*PClip_CONSTRUCTOR0)(); 304 | void (PClip::*PClip_CONSTRUCTOR1)(const PClip& x); 305 | void (PClip::*PClip_CONSTRUCTOR2)(IClip* x); 306 | void (PClip::*PClip_OPERATOR_ASSIGN0)(IClip* x); 307 | void (PClip::*PClip_OPERATOR_ASSIGN1)(const PClip& x); 308 | void (PClip::*PClip_DESTRUCTOR)(); 309 | // end class PClip 310 | 311 | /**********************************************************************/ 312 | 313 | // class PVideoFrame 314 | void (PVideoFrame::*PVideoFrame_CONSTRUCTOR0)(); 315 | void (PVideoFrame::*PVideoFrame_CONSTRUCTOR1)(const PVideoFrame& x); 316 | void (PVideoFrame::*PVideoFrame_CONSTRUCTOR2)(VideoFrame* x); 317 | void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN0)(VideoFrame* x); 318 | void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN1)(const PVideoFrame& x); 319 | void (PVideoFrame::*PVideoFrame_DESTRUCTOR)(); 320 | // end class PVideoFrame 321 | 322 | /**********************************************************************/ 323 | 324 | // class AVSValue 325 | void (AVSValue::*AVSValue_CONSTRUCTOR0)(); 326 | void (AVSValue::*AVSValue_CONSTRUCTOR1)(IClip* c); 327 | void (AVSValue::*AVSValue_CONSTRUCTOR2)(const PClip& c); 328 | void (AVSValue::*AVSValue_CONSTRUCTOR3)(bool b); 329 | void (AVSValue::*AVSValue_CONSTRUCTOR4)(int i); 330 | void (AVSValue::*AVSValue_CONSTRUCTOR5)(float f); 331 | void (AVSValue::*AVSValue_CONSTRUCTOR6)(double f); 332 | void (AVSValue::*AVSValue_CONSTRUCTOR7)(const char* s); 333 | void (AVSValue::*AVSValue_CONSTRUCTOR8)(const AVSValue* a, int size); 334 | void (AVSValue::*AVSValue_CONSTRUCTOR9)(const AVSValue& v); 335 | void (AVSValue::*AVSValue_DESTRUCTOR)(); 336 | AVSValue& (AVSValue::*AVSValue_OPERATOR_ASSIGN)(const AVSValue& v); 337 | const AVSValue& (AVSValue::*AVSValue_OPERATOR_INDEX)(int index) const; 338 | bool (AVSValue::*Defined)() const; 339 | bool (AVSValue::*IsClip)() const; 340 | bool (AVSValue::*IsBool)() const; 341 | bool (AVSValue::*IsInt)() const; 342 | bool (AVSValue::*IsFloat)() const; 343 | bool (AVSValue::*IsString)() const; 344 | bool (AVSValue::*IsArray)() const; 345 | PClip (AVSValue::*AsClip)() const; 346 | bool (AVSValue::*AsBool1)() const; 347 | int (AVSValue::*AsInt1)() const; 348 | const char* (AVSValue::*AsString1)() const; 349 | double (AVSValue::*AsFloat1)() const; 350 | bool (AVSValue::*AsBool2)(bool def) const; 351 | int (AVSValue::*AsInt2)(int def) const; 352 | double (AVSValue::*AsDblDef)(double def) const; 353 | double (AVSValue::*AsFloat2)(float def) const; 354 | const char* (AVSValue::*AsString2)(const char* def) const; 355 | int (AVSValue::*ArraySize)() const; 356 | // end class AVSValue 357 | 358 | /**********************************************************************/ 359 | // Reserve pointer space so that we can keep compatibility with Avs "classic" even if it adds functions on its own 360 | void (VideoInfo::*reserved[32])(); 361 | /**********************************************************************/ 362 | // AviSynth+ additions 363 | int (VideoInfo::*NumComponents)() const; 364 | int (VideoInfo::*ComponentSize)() const; 365 | int (VideoInfo::*BitsPerComponent)() const; 366 | bool (VideoInfo::*Is444)() const; 367 | bool (VideoInfo::*Is422)() const; 368 | bool (VideoInfo::*Is420)() const; 369 | bool (VideoInfo::*IsY)() const; 370 | bool (VideoInfo::*IsRGB48)() const; 371 | bool (VideoInfo::*IsRGB64)() const; 372 | bool (VideoInfo::*IsYUVA)() const; 373 | bool (VideoInfo::*IsPlanarRGB)() const; 374 | bool (VideoInfo::*IsPlanarRGBA)() const; 375 | /**********************************************************************/ 376 | 377 | // frame property access 378 | AVSMap& (VideoFrame::* getProperties)(); 379 | const AVSMap& (VideoFrame::* getConstProperties)(); 380 | void (VideoFrame::* setProperties)(const AVSMap& properties); 381 | 382 | // PFunction 383 | void (AVSValue::* AVSValue_CONSTRUCTOR11)(const PFunction& o); 384 | bool (AVSValue::* IsFunction)() const; 385 | void (PFunction::* PFunction_CONSTRUCTOR0)(); 386 | void (PFunction::* PFunction_CONSTRUCTOR1)(IFunction* p); 387 | void (PFunction::* PFunction_CONSTRUCTOR2)(const PFunction& p); 388 | PFunction& (PFunction::* PFunction_OPERATOR_ASSIGN0)(IFunction* other); 389 | PFunction& (PFunction::* PFunction_OPERATOR_ASSIGN1)(const PFunction& other); 390 | void (PFunction::* PFunction_DESTRUCTOR)(); 391 | // end PFunction 392 | 393 | // extra VideoFrame functions 394 | int (VideoFrame::* VideoFrame_CheckMemory)() const; 395 | PDevice (VideoFrame::* VideoFrame_GetDevice)() const; 396 | 397 | // class PDevice, even if only CPU device 398 | void (PDevice::* PDevice_CONSTRUCTOR0)(); 399 | void (PDevice::* PDevice_CONSTRUCTOR1)(Device* p); 400 | void (PDevice::* PDevice_CONSTRUCTOR2)(const PDevice& p); 401 | PDevice& (PDevice::* PDevice_OPERATOR_ASSIGN0)(Device* other); 402 | PDevice& (PDevice::* PDevice_OPERATOR_ASSIGN1)(const PDevice& other); 403 | void (PDevice::* PDevice_DESTRUCTOR)(); 404 | AvsDeviceType (PDevice::* PDevice_GetType)() const; 405 | int (PDevice::* PDevice_GetId)() const; 406 | int (PDevice::* PDevice_GetIndex)() const; 407 | const char* (PDevice::* PDevice_GetName)() const; 408 | // end class PDevice 409 | 410 | /**********************************************************************/ 411 | // Reserve pointer space for Avisynth+ 412 | void (VideoInfo::* reserved2[64 - 23])(); 413 | /**********************************************************************/ 414 | 415 | // AviSynth Neo additions 416 | INeoEnv* (__stdcall *GetNeoEnv)(IScriptEnvironment* env); 417 | // As of V8 most PDevice, PFunction linkage entries are moved to standard avs+ place. 418 | /**********************************************************************/ 419 | 420 | // this part should be identical with AVS_Linkage entries in interface.cpp 421 | }; 422 | 423 | #if defined(BUILDING_AVSCORE) || defined(AVS_STATIC_LIB) 424 | /* Macro resolution for code inside Avisynth.dll */ 425 | # define AVS_BakedCode(arg) ; 426 | # define AVS_LinkCall(arg) 427 | # define AVS_LinkCallV(arg) 428 | # define AVS_LinkCallOpt(arg, argOpt) AVSLinkCall(arg) 429 | # define AVS_LinkCallOptDefault(arg, argDefaultValue) AVSLinkCall(arg()) 430 | # define CALL_MEMBER_FN(object,ptrToMember) 431 | 432 | #else 433 | /* Macro resolution for code inside user plugin */ 434 | # ifdef AVS_LINKAGE_DLLIMPORT 435 | extern __declspec(dllimport) const AVS_Linkage* const AVS_linkage; 436 | # else 437 | extern const AVS_Linkage* AVS_linkage; 438 | # endif 439 | 440 | # ifndef offsetof 441 | # include 442 | # endif 443 | 444 | # define AVS_BakedCode(arg) { arg ; } 445 | # define AVS_LinkCall(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= AVS_linkage->Size ? 0 : (this->*(AVS_linkage->arg)) 446 | # define AVS_LinkCall_Void(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= AVS_linkage->Size ? (void)0 : (this->*(AVS_linkage->arg)) 447 | # define AVS_LinkCallV(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= AVS_linkage->Size ? *this : (this->*(AVS_linkage->arg)) 448 | // Helper macros for fallback option when a function does not exists 449 | #define CALL_MEMBER_FN(object,ptrToMember) ((object)->*(ptrToMember)) 450 | #define AVS_LinkCallOpt(arg, argOpt) !AVS_linkage ? 0 : \ 451 | ( offsetof(AVS_Linkage, arg) >= AVS_linkage->Size ? \ 452 | (offsetof(AVS_Linkage, argOpt) >= AVS_linkage->Size ? 0 : CALL_MEMBER_FN(this, AVS_linkage->argOpt)() ) : \ 453 | CALL_MEMBER_FN(this, AVS_linkage->arg)() ) 454 | // AVS_LinkCallOptDefault puts automatically () only after arg 455 | # define AVS_LinkCallOptDefault(arg, argDefaultValue) !AVS_linkage || offsetof(AVS_Linkage, arg) >= AVS_linkage->Size ? (argDefaultValue) : ((this->*(AVS_linkage->arg))()) 456 | 457 | #endif 458 | 459 | class PDevice 460 | { 461 | public: 462 | PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR0)()) 463 | PDevice(Device* p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR1)(p)) 464 | PDevice(const PDevice& p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR2)(p)) 465 | PDevice& operator=(Device* p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN0)(p)) 466 | PDevice& operator=(const PDevice& p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN1)(p)) 467 | ~PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_DESTRUCTOR)()) 468 | 469 | int operator!() const { return !e; } 470 | operator void*() const { return e; } 471 | Device* operator->() const { return e; } 472 | 473 | AvsDeviceType GetType() const AVS_BakedCode(return AVS_LinkCallOptDefault(PDevice_GetType, DEV_TYPE_NONE)) 474 | int GetId() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetId)()) 475 | int GetIndex() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetIndex)()) 476 | const char* GetName() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetName)()) 477 | 478 | private: 479 | Device * e; 480 | 481 | #ifdef BUILDING_AVSCORE 482 | public: 483 | void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ 484 | void CONSTRUCTOR1(Device* p); 485 | void CONSTRUCTOR2(const PDevice& p); 486 | PDevice& OPERATOR_ASSIGN0(Device* p); 487 | PDevice& OPERATOR_ASSIGN1(const PDevice& p); 488 | void DESTRUCTOR(); 489 | #endif 490 | }; 491 | struct VideoInfo { 492 | int width, height; // width=0 means no video 493 | unsigned fps_numerator, fps_denominator; 494 | int num_frames; 495 | // This is more extensible than previous versions. More properties can be added seeminglesly. 496 | 497 | // Colorspace properties. 498 | /* 499 | 500 | Planar match mask 1111.1000.0000.0111.0000.0111.0000.0111 501 | Planar signature 10xx.1000.0000.00xx.0000.00xx.00xx.00xx ? 502 | Planar signature 10xx.1000.0000.0xxx.0000.00xx.000x.x0xx ? *new 503 | Planar filter mask 1111.1111.1111.1111.1111.1111.1110.0111 (typo from old header fixed) 504 | 505 | pixel_type mapping 506 | ================== 507 | pixel_type bit-map PIYB.Z000.0???.0SSS.0000.0???.????.???? 508 | planar YUV CCC HHH.000u.vWWW 509 | planar RGB(A) CCC AR 510 | nonplanar CCC 000.00wx xyAR 511 | Legend 512 | ====== 513 | Planar YUV: 514 | Code Bits Remark 515 | W 0-2 Planar Width Subsampling bits 516 | Use (X+1) & 3 for GetPlaneWidthSubsampling 517 | 000 => 1 YV12, YV16, YUV420, YUV422 518 | 001 => 2 YV411, YUV9 519 | 010 => reserved 520 | 011 => 0 YV24, YUV444, RGBP 521 | 1xx => reserved 522 | v 3 VPlaneFirst YV12, YV16, YV24, YV411, YUV9 523 | u 4 UPlaneFirst I420 524 | H 7-9 Planar Height Subsampling bits 525 | Use ((X>>8)+1) & 3 for GetPlaneHeightSubsampling 526 | 000 => 1 YV12, YUV420 527 | 001 => 2 YUV9 528 | 010 => reserved 529 | 011 => 0 YV16, YV24, YV411, YUV422, YUV444, RGBP 530 | 1xx => reserved 531 | 532 | Planar RGB 533 | Code Bits Remark 534 | R 0 BGR, (with SSS bits for 8/16 bit/sample or float) 535 | A 1 BGRA, (with SSS bits for 8/16 bit/sample or float) 536 | 537 | 538 | Not Planar, Interleaved (I flag) 539 | Code Bits Remark 540 | R 0 BGR24, and BGRx in future (with SSS bits for 8/16 bit/sample or float) 541 | A 1 BGR32, and BGRAx in future (with SSS bits for 8/16 bit/sample or float) 542 | y 2 YUY2 543 | x 3-4 reserved 544 | w 5 Raw32 545 | 546 | General 547 | Code Bits Remark 548 | S 16-18 Sample resolution bits 549 | 000 => 8 550 | 001 => 16 551 | 010 => 32 (float) 552 | 011,100 => reserved 553 | 101 => 10 bits 554 | 110 => 12 bits 555 | 111 => 14 bits 556 | for packed RGB(A): only 8 and 16 bits are valid 557 | 558 | Other YV12 specific (not used?) 559 | C 20-22 Chroma Placement values 0-4 see CS_xxx_CHROMA_PLACEMENT 560 | 561 | Color family and layout 562 | Packed Planar Planar Planar 563 | Code Bits Remark RGB/RGBA YUV YUY2 Y_Grey RGB/RGBA YUVA 564 | R 0 1/0 - 0 - 1/0 - 565 | A 1 0/1 - 0 - 0/1 - 566 | y 2 - - 1 - 0 - 567 | Z 27 YUVA 0 0 0 0 1 1 568 | B 28 BGR 1 0 0 0 1* 0 569 | Y 29 YUV 0 1 1 1 0 0 570 | I 30 Interleaved 1 0 1 1 0 0 571 | P 31 Planar 0 1 0 1 1 1 572 | * Planar RGB plane order: G,B,R(,A) 573 | 574 | */ 575 | enum { 576 | CS_YUVA = 1<<27, 577 | CS_BGR = 1<<28, 578 | CS_YUV = 1<<29, 579 | CS_INTERLEAVED = 1<<30, 580 | CS_PLANAR = 1<<31, 581 | 582 | CS_Shift_Sub_Width = 0, 583 | CS_Shift_Sub_Height = 8, 584 | CS_Shift_Sample_Bits = 16, 585 | 586 | CS_Sub_Width_Mask = 7 << CS_Shift_Sub_Width, 587 | CS_Sub_Width_1 = 3 << CS_Shift_Sub_Width, // YV24 588 | CS_Sub_Width_2 = 0 << CS_Shift_Sub_Width, // YV12, I420, YV16 589 | CS_Sub_Width_4 = 1 << CS_Shift_Sub_Width, // YUV9, YV411 590 | 591 | CS_VPlaneFirst = 1 << 3, // YV12, YV16, YV24, YV411, YUV9 592 | CS_UPlaneFirst = 1 << 4, // I420 593 | 594 | CS_Sub_Height_Mask = 7 << CS_Shift_Sub_Height, 595 | CS_Sub_Height_1 = 3 << CS_Shift_Sub_Height, // YV16, YV24, YV411 596 | CS_Sub_Height_2 = 0 << CS_Shift_Sub_Height, // YV12, I420 597 | CS_Sub_Height_4 = 1 << CS_Shift_Sub_Height, // YUV9 598 | 599 | CS_Sample_Bits_Mask = 7 << CS_Shift_Sample_Bits, 600 | CS_Sample_Bits_8 = 0 << CS_Shift_Sample_Bits, 601 | CS_Sample_Bits_10 = 5 << CS_Shift_Sample_Bits, 602 | CS_Sample_Bits_12 = 6 << CS_Shift_Sample_Bits, 603 | CS_Sample_Bits_14 = 7 << CS_Shift_Sample_Bits, 604 | CS_Sample_Bits_16 = 1 << CS_Shift_Sample_Bits, 605 | CS_Sample_Bits_32 = 2 << CS_Shift_Sample_Bits, 606 | 607 | CS_PLANAR_MASK = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_BGR | CS_YUVA | CS_Sample_Bits_Mask 608 | | CS_Sub_Height_Mask | CS_Sub_Width_Mask, 609 | CS_PLANAR_FILTER = ~( CS_VPlaneFirst | CS_UPlaneFirst ), 610 | 611 | CS_RGB_TYPE = 1 << 0, 612 | CS_RGBA_TYPE = 1 << 1, 613 | 614 | // Specific colorformats 615 | CS_UNKNOWN = 0, 616 | 617 | CS_BGR24 = CS_RGB_TYPE | CS_BGR | CS_INTERLEAVED, 618 | CS_BGR32 = CS_RGBA_TYPE | CS_BGR | CS_INTERLEAVED, 619 | CS_YUY2 = 1<<2 | CS_YUV | CS_INTERLEAVED, 620 | // CS_YV12 = 1<<3 Reserved 621 | // CS_I420 = 1<<4 Reserved 622 | CS_RAW32 = 1<<5 | CS_INTERLEAVED, 623 | 624 | // YV12 must be 0xA000008 2.5 Baked API will see all new planar as YV12 625 | // I420 must be 0xA000010 626 | 627 | CS_GENERIC_YUV420 = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // 4:2:0 planar 628 | CS_GENERIC_YUV422 = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_2, // 4:2:2 planar 629 | CS_GENERIC_YUV444 = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_1, // 4:4:4 planar 630 | CS_GENERIC_Y = CS_PLANAR | CS_INTERLEAVED | CS_YUV, // Y only (4:0:0) 631 | CS_GENERIC_RGBP = CS_PLANAR | CS_BGR | CS_RGB_TYPE, // planar RGB. Though name is RGB but plane order G,B,R 632 | CS_GENERIC_RGBAP = CS_PLANAR | CS_BGR | CS_RGBA_TYPE, // planar RGBA 633 | CS_GENERIC_YUVA420 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // 4:2:0:A planar 634 | CS_GENERIC_YUVA422 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_2, // 4:2:2:A planar 635 | CS_GENERIC_YUVA444 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_1, // 4:4:4:A planar 636 | 637 | CS_YV24 = CS_GENERIC_YUV444 | CS_Sample_Bits_8, // YVU 4:4:4 planar 638 | CS_YV16 = CS_GENERIC_YUV422 | CS_Sample_Bits_8, // YVU 4:2:2 planar 639 | CS_YV12 = CS_GENERIC_YUV420 | CS_Sample_Bits_8, // YVU 4:2:0 planar 640 | CS_I420 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_UPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // YUV 4:2:0 planar 641 | CS_IYUV = CS_I420, 642 | CS_YUV9 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_4 | CS_Sub_Width_4, // YUV 4:1:0 planar 643 | CS_YV411 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_4, // YUV 4:1:1 planar 644 | 645 | CS_Y8 = CS_GENERIC_Y | CS_Sample_Bits_8, // Y 4:0:0 planar 646 | 647 | //------------------------- 648 | // AVS16: new planar constants go live! Experimental PF 160613 649 | // 10-12-14 bit + planar RGB + BRG48/64 160725 650 | 651 | CS_YUV444P10 = CS_GENERIC_YUV444 | CS_Sample_Bits_10, // YUV 4:4:4 10bit samples 652 | CS_YUV422P10 = CS_GENERIC_YUV422 | CS_Sample_Bits_10, // YUV 4:2:2 10bit samples 653 | CS_YUV420P10 = CS_GENERIC_YUV420 | CS_Sample_Bits_10, // YUV 4:2:0 10bit samples 654 | CS_Y10 = CS_GENERIC_Y | CS_Sample_Bits_10, // Y 4:0:0 10bit samples 655 | 656 | CS_YUV444P12 = CS_GENERIC_YUV444 | CS_Sample_Bits_12, // YUV 4:4:4 12bit samples 657 | CS_YUV422P12 = CS_GENERIC_YUV422 | CS_Sample_Bits_12, // YUV 4:2:2 12bit samples 658 | CS_YUV420P12 = CS_GENERIC_YUV420 | CS_Sample_Bits_12, // YUV 4:2:0 12bit samples 659 | CS_Y12 = CS_GENERIC_Y | CS_Sample_Bits_12, // Y 4:0:0 12bit samples 660 | 661 | CS_YUV444P14 = CS_GENERIC_YUV444 | CS_Sample_Bits_14, // YUV 4:4:4 14bit samples 662 | CS_YUV422P14 = CS_GENERIC_YUV422 | CS_Sample_Bits_14, // YUV 4:2:2 14bit samples 663 | CS_YUV420P14 = CS_GENERIC_YUV420 | CS_Sample_Bits_14, // YUV 4:2:0 14bit samples 664 | CS_Y14 = CS_GENERIC_Y | CS_Sample_Bits_14, // Y 4:0:0 14bit samples 665 | 666 | CS_YUV444P16 = CS_GENERIC_YUV444 | CS_Sample_Bits_16, // YUV 4:4:4 16bit samples 667 | CS_YUV422P16 = CS_GENERIC_YUV422 | CS_Sample_Bits_16, // YUV 4:2:2 16bit samples 668 | CS_YUV420P16 = CS_GENERIC_YUV420 | CS_Sample_Bits_16, // YUV 4:2:0 16bit samples 669 | CS_Y16 = CS_GENERIC_Y | CS_Sample_Bits_16, // Y 4:0:0 16bit samples 670 | 671 | // 32 bit samples (float) 672 | CS_YUV444PS = CS_GENERIC_YUV444 | CS_Sample_Bits_32, // YUV 4:4:4 32bit samples 673 | CS_YUV422PS = CS_GENERIC_YUV422 | CS_Sample_Bits_32, // YUV 4:2:2 32bit samples 674 | CS_YUV420PS = CS_GENERIC_YUV420 | CS_Sample_Bits_32, // YUV 4:2:0 32bit samples 675 | CS_Y32 = CS_GENERIC_Y | CS_Sample_Bits_32, // Y 4:0:0 32bit samples 676 | 677 | // RGB packed 678 | CS_BGR48 = CS_RGB_TYPE | CS_BGR | CS_INTERLEAVED | CS_Sample_Bits_16, // BGR 3x16 bit 679 | CS_BGR64 = CS_RGBA_TYPE | CS_BGR | CS_INTERLEAVED | CS_Sample_Bits_16, // BGR 4x16 bit 680 | // no packed 32 bit (float) support for these legacy types 681 | 682 | // RGB planar 683 | CS_RGBP = CS_GENERIC_RGBP | CS_Sample_Bits_8, // Planar RGB 8 bit samples 684 | CS_RGBP8 = CS_GENERIC_RGBP | CS_Sample_Bits_8, // Planar RGB 8 bit samples 685 | CS_RGBP10 = CS_GENERIC_RGBP | CS_Sample_Bits_10, // Planar RGB 10bit samples 686 | CS_RGBP12 = CS_GENERIC_RGBP | CS_Sample_Bits_12, // Planar RGB 12bit samples 687 | CS_RGBP14 = CS_GENERIC_RGBP | CS_Sample_Bits_14, // Planar RGB 14bit samples 688 | CS_RGBP16 = CS_GENERIC_RGBP | CS_Sample_Bits_16, // Planar RGB 16bit samples 689 | CS_RGBPS = CS_GENERIC_RGBP | CS_Sample_Bits_32, // Planar RGB 32bit samples 690 | 691 | // RGBA planar 692 | CS_RGBAP = CS_GENERIC_RGBAP | CS_Sample_Bits_8, // Planar RGBA 8 bit samples 693 | CS_RGBAP8 = CS_GENERIC_RGBAP | CS_Sample_Bits_8, // Planar RGBA 8 bit samples 694 | CS_RGBAP10 = CS_GENERIC_RGBAP | CS_Sample_Bits_10, // Planar RGBA 10bit samples 695 | CS_RGBAP12 = CS_GENERIC_RGBAP | CS_Sample_Bits_12, // Planar RGBA 12bit samples 696 | CS_RGBAP14 = CS_GENERIC_RGBAP | CS_Sample_Bits_14, // Planar RGBA 14bit samples 697 | CS_RGBAP16 = CS_GENERIC_RGBAP | CS_Sample_Bits_16, // Planar RGBA 16bit samples 698 | CS_RGBAPS = CS_GENERIC_RGBAP | CS_Sample_Bits_32, // Planar RGBA 32bit samples 699 | 700 | // Planar YUVA 701 | CS_YUVA444 = CS_GENERIC_YUVA444 | CS_Sample_Bits_8, // YUVA 4:4:4 8bit samples 702 | CS_YUVA422 = CS_GENERIC_YUVA422 | CS_Sample_Bits_8, // YUVA 4:2:2 8bit samples 703 | CS_YUVA420 = CS_GENERIC_YUVA420 | CS_Sample_Bits_8, // YUVA 4:2:0 8bit samples 704 | 705 | CS_YUVA444P10 = CS_GENERIC_YUVA444 | CS_Sample_Bits_10, // YUVA 4:4:4 10bit samples 706 | CS_YUVA422P10 = CS_GENERIC_YUVA422 | CS_Sample_Bits_10, // YUVA 4:2:2 10bit samples 707 | CS_YUVA420P10 = CS_GENERIC_YUVA420 | CS_Sample_Bits_10, // YUVA 4:2:0 10bit samples 708 | 709 | CS_YUVA444P12 = CS_GENERIC_YUVA444 | CS_Sample_Bits_12, // YUVA 4:4:4 12bit samples 710 | CS_YUVA422P12 = CS_GENERIC_YUVA422 | CS_Sample_Bits_12, // YUVA 4:2:2 12bit samples 711 | CS_YUVA420P12 = CS_GENERIC_YUVA420 | CS_Sample_Bits_12, // YUVA 4:2:0 12bit samples 712 | 713 | CS_YUVA444P14 = CS_GENERIC_YUVA444 | CS_Sample_Bits_14, // YUVA 4:4:4 14bit samples 714 | CS_YUVA422P14 = CS_GENERIC_YUVA422 | CS_Sample_Bits_14, // YUVA 4:2:2 14bit samples 715 | CS_YUVA420P14 = CS_GENERIC_YUVA420 | CS_Sample_Bits_14, // YUVA 4:2:0 14bit samples 716 | 717 | CS_YUVA444P16 = CS_GENERIC_YUVA444 | CS_Sample_Bits_16, // YUVA 4:4:4 16bit samples 718 | CS_YUVA422P16 = CS_GENERIC_YUVA422 | CS_Sample_Bits_16, // YUVA 4:2:2 16bit samples 719 | CS_YUVA420P16 = CS_GENERIC_YUVA420 | CS_Sample_Bits_16, // YUVA 4:2:0 16bit samples 720 | 721 | CS_YUVA444PS = CS_GENERIC_YUVA444 | CS_Sample_Bits_32, // YUVA 4:4:4 32bit samples 722 | CS_YUVA422PS = CS_GENERIC_YUVA422 | CS_Sample_Bits_32, // YUVA 4:2:2 32bit samples 723 | CS_YUVA420PS = CS_GENERIC_YUVA420 | CS_Sample_Bits_32, // YUVA 4:2:0 32bit samples 724 | 725 | }; 726 | 727 | int pixel_type; // changed to int as of 2.5 728 | 729 | 730 | int audio_samples_per_second; // 0 means no audio 731 | int sample_type; // as of 2.5 732 | int64_t num_audio_samples; // changed as of 2.5 733 | int nchannels; // as of 2.5 734 | 735 | // Imagetype properties 736 | 737 | int image_type; 738 | 739 | enum { 740 | IT_BFF = 1<<0, 741 | IT_TFF = 1<<1, 742 | IT_FIELDBASED = 1<<2 743 | }; 744 | 745 | // Chroma placement bits 20 -> 23 ::FIXME:: Really want a Class to support this 746 | enum { 747 | CS_UNKNOWN_CHROMA_PLACEMENT = 0 << 20, 748 | CS_MPEG1_CHROMA_PLACEMENT = 1 << 20, 749 | CS_MPEG2_CHROMA_PLACEMENT = 2 << 20, 750 | CS_YUY2_CHROMA_PLACEMENT = 3 << 20, 751 | CS_TOPLEFT_CHROMA_PLACEMENT = 4 << 20 752 | }; 753 | 754 | // useful functions of the above 755 | bool HasVideo() const AVS_BakedCode(return AVS_LinkCall(HasVideo)()) 756 | bool HasAudio() const AVS_BakedCode(return AVS_LinkCall(HasAudio)()) 757 | bool IsRGB() const AVS_BakedCode(return AVS_LinkCall(IsRGB)()) 758 | bool IsRGB24() const AVS_BakedCode(return AVS_LinkCall(IsRGB24)()) 759 | bool IsRGB32() const AVS_BakedCode(return AVS_LinkCall(IsRGB32)()) 760 | bool IsYUV() const AVS_BakedCode(return AVS_LinkCall(IsYUV)()) 761 | bool IsYUY2() const AVS_BakedCode(return AVS_LinkCall(IsYUY2)()) 762 | 763 | bool IsYV24() const AVS_BakedCode(return AVS_LinkCall(IsYV24)()) 764 | bool IsYV16() const AVS_BakedCode(return AVS_LinkCall(IsYV16)()) 765 | bool IsYV12() const AVS_BakedCode(return AVS_LinkCall(IsYV12)()) 766 | bool IsYV411() const AVS_BakedCode(return AVS_LinkCall(IsYV411)()) 767 | //bool IsYUV9() const; 768 | bool IsY8() const AVS_BakedCode(return AVS_LinkCall(IsY8)()) 769 | 770 | bool IsColorSpace(int c_space) const AVS_BakedCode(return AVS_LinkCall(IsColorSpace)(c_space)) 771 | 772 | bool Is(int property) const AVS_BakedCode(return AVS_LinkCall(Is)(property)) 773 | bool IsPlanar() const AVS_BakedCode(return AVS_LinkCall(IsPlanar)()) 774 | bool IsFieldBased() const AVS_BakedCode(return AVS_LinkCall(IsFieldBased)()) 775 | bool IsParityKnown() const AVS_BakedCode(return AVS_LinkCall(IsParityKnown)()) 776 | bool IsBFF() const AVS_BakedCode(return AVS_LinkCall(IsBFF)()) 777 | bool IsTFF() const AVS_BakedCode(return AVS_LinkCall(IsTFF)()) 778 | 779 | bool IsVPlaneFirst() const AVS_BakedCode(return AVS_LinkCall(IsVPlaneFirst)()) // Don't use this 780 | // Will not work on planar images, but will return only luma planes 781 | int BytesFromPixels(int pixels) const AVS_BakedCode(return AVS_LinkCall(BytesFromPixels)(pixels)) 782 | int RowSize(int plane = 0) const AVS_BakedCode(return AVS_LinkCall(RowSize)(plane)) 783 | int BMPSize() const AVS_BakedCode(return AVS_LinkCall(BMPSize)()) 784 | 785 | int64_t AudioSamplesFromFrames(int frames) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromFrames)(frames)) 786 | int FramesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(FramesFromAudioSamples)(samples)) 787 | int64_t AudioSamplesFromBytes(int64_t bytes) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromBytes)(bytes)) 788 | int64_t BytesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(BytesFromAudioSamples)(samples)) 789 | int AudioChannels() const AVS_BakedCode(return AVS_LinkCall(AudioChannels)()) 790 | int SampleType() const AVS_BakedCode(return AVS_LinkCall(SampleType)()) 791 | bool IsSampleType(int testtype) const AVS_BakedCode(return AVS_LinkCall(IsSampleType)(testtype)) 792 | int SamplesPerSecond() const AVS_BakedCode(return AVS_LinkCall(SamplesPerSecond)()) 793 | int BytesPerAudioSample() const AVS_BakedCode(return AVS_LinkCall(BytesPerAudioSample)()) 794 | void SetFieldBased(bool isfieldbased) AVS_BakedCode(AVS_LinkCall_Void(SetFieldBased)(isfieldbased)) 795 | void Set(int property) AVS_BakedCode(AVS_LinkCall_Void(Set)(property)) 796 | void Clear(int property) AVS_BakedCode(AVS_LinkCall_Void(Clear)(property)) 797 | // Subsampling in bitshifts! 798 | int GetPlaneWidthSubsampling(int plane) const AVS_BakedCode(return AVS_LinkCall(GetPlaneWidthSubsampling)(plane)) 799 | int GetPlaneHeightSubsampling(int plane) const AVS_BakedCode(return AVS_LinkCall(GetPlaneHeightSubsampling)(plane)) 800 | int BitsPerPixel() const AVS_BakedCode(return AVS_LinkCall(BitsPerPixel)()) 801 | 802 | int BytesPerChannelSample() const AVS_BakedCode(return AVS_LinkCall(BytesPerChannelSample)()) 803 | 804 | // useful mutator 805 | void SetFPS(unsigned numerator, unsigned denominator) AVS_BakedCode(AVS_LinkCall_Void(SetFPS)(numerator, denominator)) 806 | 807 | // Range protected multiply-divide of FPS 808 | void MulDivFPS(unsigned multiplier, unsigned divisor) AVS_BakedCode(AVS_LinkCall_Void(MulDivFPS)(multiplier, divisor)) 809 | 810 | // Test for same colorspace 811 | bool IsSameColorspace(const VideoInfo& vi) const AVS_BakedCode(return AVS_LinkCall(IsSameColorspace)(vi)) 812 | 813 | // AVS+ extensions 814 | // 20161005: 815 | // Mapping of AVS+ extensions to classic 2.6 functions. 816 | // In order to use these extended AVS+ functions for plugins that should work 817 | // either with AVS+ or with Classic (8 bit) Avs 2.6 ans earlier AVS+ versions, there is an 818 | // automatic fallback mechanism. 819 | // From AVS+'s point of view these are not "baked" codes, the primary functions should exist. 820 | // Examples: 821 | // Is444() is mapped to IsYV24() for classic AVS2.6 822 | // ComponentSize() returns constant 1 (1 bytes per pixel component) 823 | // BitsPerComponent() returns constant 8 (Classic AVS2.6 is 8 bit only) 824 | 825 | // Returns the number of color channels or planes in a frame 826 | int NumComponents() const AVS_BakedCode(return AVS_LinkCallOptDefault(NumComponents, (((AVS_LinkCall(IsYUV)()) && !(AVS_LinkCall(IsY8)())) ? 3 : AVS_LinkCall(BytesFromPixels)(1)) ) ) 827 | 828 | // Returns the size in bytes of a single component of a pixel 829 | int ComponentSize() const AVS_BakedCode(return AVS_LinkCallOptDefault(ComponentSize, 1)) 830 | 831 | // Returns the bit depth of a single component of a pixel 832 | int BitsPerComponent() const AVS_BakedCode(return AVS_LinkCallOptDefault(BitsPerComponent, 8)) 833 | 834 | // like IsYV24, but bit-depth independent also for YUVA 835 | bool Is444() const AVS_BakedCode(return AVS_LinkCallOpt(Is444, IsYV24) ) 836 | 837 | // like IsYV16, but bit-depth independent also for YUVA 838 | bool Is422() const AVS_BakedCode(return AVS_LinkCallOpt(Is422, IsYV16) ) 839 | 840 | // like IsYV12, but bit-depth independent also for YUVA 841 | bool Is420() const AVS_BakedCode( return AVS_LinkCallOpt(Is420, IsYV12) ) 842 | 843 | // like IsY8, but bit-depth independent 844 | bool IsY() const AVS_BakedCode( return AVS_LinkCallOpt(IsY, IsY8) ) 845 | 846 | // like IsRGB24 for 16 bit samples 847 | bool IsRGB48() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsRGB48, false) ) 848 | 849 | // like IsRGB32 for 16 bit samples 850 | bool IsRGB64() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsRGB64, false) ) 851 | 852 | // YUVA? 853 | bool IsYUVA() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsYUVA, false) ) 854 | 855 | // Planar RGB? 856 | bool IsPlanarRGB() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsPlanarRGB, false) ) 857 | 858 | // Planar RGBA? 859 | bool IsPlanarRGBA() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsPlanarRGBA, false) ) 860 | 861 | }; // end struct VideoInfo 862 | 863 | 864 | 865 | 866 | // VideoFrameBuffer holds information about a memory block which is used 867 | // for video data. For efficiency, instances of this class are not deleted 868 | // when the refcount reaches zero; instead they're stored in a linked list 869 | // to be reused. The instances are deleted when the corresponding AVS 870 | // file is closed. 871 | 872 | class VideoFrameBuffer { 873 | BYTE* data; 874 | int data_size; 875 | // sequence_number is incremented every time the buffer is changed, so 876 | // that stale views can tell they're no longer valid. 877 | volatile long sequence_number; 878 | 879 | friend class VideoFrame; 880 | friend class Cache; 881 | friend class ScriptEnvironment; 882 | volatile long refcount; 883 | 884 | // AVS+CUDA extension, does not break plugins if appended here 885 | Device* device; 886 | 887 | protected: 888 | VideoFrameBuffer(int size, int margin, Device* device); 889 | VideoFrameBuffer(); 890 | ~VideoFrameBuffer(); 891 | 892 | public: 893 | const BYTE* GetReadPtr() const AVS_BakedCode( return AVS_LinkCall(VFBGetReadPtr)() ) 894 | BYTE* GetWritePtr() AVS_BakedCode( return AVS_LinkCall(VFBGetWritePtr)() ) 895 | int GetDataSize() const AVS_BakedCode( return AVS_LinkCall(GetDataSize)() ) 896 | int GetSequenceNumber() const AVS_BakedCode( return AVS_LinkCall(GetSequenceNumber)() ) 897 | int GetRefcount() const AVS_BakedCode( return AVS_LinkCall(GetRefcount)() ) 898 | 899 | // Ensure VideoFrameBuffer cannot be publicly assigned 900 | private: 901 | VideoFrameBuffer& operator=(const VideoFrameBuffer&); 902 | 903 | }; // end class VideoFrameBuffer 904 | 905 | 906 | // smart pointer to VideoFrame 907 | class PVideoFrame { 908 | 909 | VideoFrame* p; 910 | 911 | void Init(VideoFrame* x); 912 | void Set(VideoFrame* x); 913 | 914 | public: 915 | PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR0)()) 916 | PVideoFrame(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR1)(x)) 917 | PVideoFrame(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR2)(x)) 918 | void operator=(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN0)(x)) 919 | void operator=(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN1)(x)) 920 | 921 | VideoFrame* operator->() const { return p; } 922 | 923 | // for conditional expressions 924 | operator void*() const { return p; } 925 | bool operator!() const { return !p; } 926 | 927 | ~PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_DESTRUCTOR)()) 928 | #ifdef BUILDING_AVSCORE 929 | public: 930 | void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ 931 | void CONSTRUCTOR1(const PVideoFrame& x); 932 | void CONSTRUCTOR2(VideoFrame* x); 933 | void OPERATOR_ASSIGN0(VideoFrame* x); 934 | void OPERATOR_ASSIGN1(const PVideoFrame& x); 935 | void DESTRUCTOR(); 936 | #endif 937 | }; // end class PVideoFrame 938 | 939 | 940 | // VideoFrame holds a "window" into a VideoFrameBuffer. Operator new 941 | // is overloaded to recycle class instances. 942 | 943 | class VideoFrame { 944 | volatile long refcount; 945 | VideoFrameBuffer* vfb; 946 | 947 | // Due to technical reasons these members are not const, but should be treated as such. 948 | // That means do not modify them once the class has been constructed. 949 | int offset; 950 | int pitch, row_size, height; 951 | int offsetU, offsetV; // U&V offsets are from top of picture. 952 | int pitchUV, row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane. 953 | // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable) 954 | // the decision on existance of UV is checked by zero pitch 955 | // AVS+ extension, does not break plugins if appended here 956 | int offsetA; 957 | int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none 958 | 959 | AVSMap *properties; 960 | 961 | friend class PVideoFrame; 962 | void AddRef(); 963 | void Release(); 964 | 965 | friend class ScriptEnvironment; 966 | friend class Cache; 967 | 968 | VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height); 969 | VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV); 970 | // for Alpha 971 | VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV, int _offsetA); 972 | void* operator new(size_t size); 973 | // TESTME: OFFSET U/V may be switched to what could be expected from AVI standard! 974 | public: 975 | int GetPitch(int plane=0) const AVS_BakedCode( return AVS_LinkCall(GetPitch)(plane) ) 976 | int GetRowSize(int plane=0) const AVS_BakedCode( return AVS_LinkCall(GetRowSize)(plane) ) 977 | int GetHeight(int plane=0) const AVS_BakedCode( return AVS_LinkCall(GetHeight)(plane) ) 978 | 979 | // generally you shouldn't use these three 980 | VideoFrameBuffer* GetFrameBuffer() const AVS_BakedCode( return AVS_LinkCall(GetFrameBuffer)() ) 981 | int GetOffset(int plane=0) const AVS_BakedCode( return AVS_LinkCall(GetOffset)(plane) ) 982 | 983 | // in plugins use env->SubFrame() -- because implementation code is only available inside avisynth.dll. Doh! 984 | VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height) const; 985 | VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int pitchUV) const; 986 | // for Alpha 987 | VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int pitchUV, int rel_offsetA) const; 988 | 989 | const BYTE* GetReadPtr(int plane=0) const AVS_BakedCode( return AVS_LinkCall(VFGetReadPtr)(plane) ) 990 | bool IsWritable() const AVS_BakedCode( return AVS_LinkCall(IsWritable)() ) 991 | BYTE* GetWritePtr(int plane=0) const AVS_BakedCode( return AVS_LinkCall(VFGetWritePtr)(plane) ) 992 | 993 | AVSMap& getProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getProperties, (AVSMap&)*(AVSMap*)0)) 994 | const AVSMap& getConstProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getConstProperties, (const AVSMap&)*(const AVSMap*)0)) 995 | void setProperties(const AVSMap & _properties) AVS_BakedCode(AVS_LinkCall_Void(setProperties)(_properties)) 996 | 997 | PDevice GetDevice() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_GetDevice)()) 998 | 999 | // 0: OK, 1: NG, -1: disabled or non CPU frame 1000 | int CheckMemory() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_CheckMemory)()) 1001 | 1002 | ~VideoFrame() AVS_BakedCode( AVS_LinkCall_Void(VideoFrame_DESTRUCTOR)() ) 1003 | #ifdef BUILDING_AVSCORE 1004 | public: 1005 | void DESTRUCTOR(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ 1006 | #endif 1007 | 1008 | // Ensure VideoFrame cannot be publicly assigned 1009 | private: 1010 | VideoFrame& operator=(const VideoFrame&); 1011 | 1012 | }; // end class VideoFrame 1013 | 1014 | enum CachePolicyHint { 1015 | // Values 0 to 5 are reserved for old 2.5 plugins 1016 | // do not use them in new plugins 1017 | 1018 | // New 2.6 explicitly defined cache hints. 1019 | CACHE_NOTHING=10, // Do not cache video. 1020 | CACHE_WINDOW=11, // Hard protect upto X frames within a range of X from the current frame N. 1021 | CACHE_GENERIC=12, // LRU cache upto X frames. 1022 | CACHE_FORCE_GENERIC=13, // LRU cache upto X frames, override any previous CACHE_WINDOW. 1023 | 1024 | CACHE_GET_POLICY=30, // Get the current policy. 1025 | CACHE_GET_WINDOW=31, // Get the current window h_span. 1026 | CACHE_GET_RANGE=32, // Get the current generic frame range. 1027 | 1028 | CACHE_AUDIO=50, // Explicitly cache audio, X byte cache. 1029 | CACHE_AUDIO_NOTHING=51, // Explicitly do not cache audio. 1030 | CACHE_AUDIO_NONE=52, // Audio cache off (auto mode), X byte intial cache. 1031 | CACHE_AUDIO_AUTO=53, // Audio cache on (auto mode), X byte intial cache. 1032 | 1033 | CACHE_GET_AUDIO_POLICY=70, // Get the current audio policy. 1034 | CACHE_GET_AUDIO_SIZE=71, // Get the current audio cache size. 1035 | 1036 | CACHE_PREFETCH_FRAME=100, // Queue request to prefetch frame N. 1037 | CACHE_PREFETCH_GO=101, // Action video prefetches. 1038 | 1039 | CACHE_PREFETCH_AUDIO_BEGIN=120, // Begin queue request transaction to prefetch audio (take critical section). 1040 | CACHE_PREFETCH_AUDIO_STARTLO=121, // Set low 32 bits of start. 1041 | CACHE_PREFETCH_AUDIO_STARTHI=122, // Set high 32 bits of start. 1042 | CACHE_PREFETCH_AUDIO_COUNT=123, // Set low 32 bits of length. 1043 | CACHE_PREFETCH_AUDIO_COMMIT=124, // Enqueue request transaction to prefetch audio (release critical section). 1044 | CACHE_PREFETCH_AUDIO_GO=125, // Action audio prefetches. 1045 | 1046 | CACHE_GETCHILD_CACHE_MODE=200, // Cache ask Child for desired video cache mode. 1047 | CACHE_GETCHILD_CACHE_SIZE=201, // Cache ask Child for desired video cache size. 1048 | CACHE_GETCHILD_AUDIO_MODE=202, // Cache ask Child for desired audio cache mode. 1049 | CACHE_GETCHILD_AUDIO_SIZE=203, // Cache ask Child for desired audio cache size. 1050 | 1051 | CACHE_GETCHILD_COST=220, // Cache ask Child for estimated processing cost. 1052 | CACHE_COST_ZERO=221, // Child response of zero cost (ptr arithmetic only). 1053 | CACHE_COST_UNIT=222, // Child response of unit cost (less than or equal 1 full frame blit). 1054 | CACHE_COST_LOW=223, // Child response of light cost. (Fast) 1055 | CACHE_COST_MED=224, // Child response of medium cost. (Real time) 1056 | CACHE_COST_HI=225, // Child response of heavy cost. (Slow) 1057 | 1058 | CACHE_GETCHILD_THREAD_MODE=240, // Cache ask Child for thread safetyness. 1059 | CACHE_THREAD_UNSAFE=241, // Only 1 thread allowed for all instances. 2.5 filters default! 1060 | CACHE_THREAD_CLASS=242, // Only 1 thread allowed for each instance. 2.6 filters default! 1061 | CACHE_THREAD_SAFE=243, // Allow all threads in any instance. 1062 | CACHE_THREAD_OWN=244, // Safe but limit to 1 thread, internally threaded. 1063 | 1064 | CACHE_GETCHILD_ACCESS_COST=260, // Cache ask Child for preferred access pattern. 1065 | CACHE_ACCESS_RAND=261, // Filter is access order agnostic. 1066 | CACHE_ACCESS_SEQ0=262, // Filter prefers sequential access (low cost) 1067 | CACHE_ACCESS_SEQ1=263, // Filter needs sequential access (high cost) 1068 | 1069 | CACHE_AVSPLUS_CONSTANTS = 500, // Smaller values are reserved for classic Avisynth 1070 | 1071 | CACHE_DONT_CACHE_ME, // Filters that don't need caching (eg. trim, cache etc.) should return 1 to this request 1072 | CACHE_SET_MIN_CAPACITY, 1073 | CACHE_SET_MAX_CAPACITY, 1074 | CACHE_GET_MIN_CAPACITY, 1075 | CACHE_GET_MAX_CAPACITY, 1076 | CACHE_GET_SIZE, 1077 | CACHE_GET_REQUESTED_CAP, 1078 | CACHE_GET_CAPACITY, 1079 | CACHE_GET_MTMODE, 1080 | 1081 | CACHE_IS_CACHE_REQ, 1082 | CACHE_IS_CACHE_ANS, 1083 | CACHE_IS_MTGUARD_REQ, 1084 | CACHE_IS_MTGUARD_ANS, 1085 | 1086 | CACHE_AVSPLUS_CUDA_CONSTANTS = 600, 1087 | 1088 | CACHE_GET_DEV_TYPE, // Device types a filter can return 1089 | CACHE_GET_CHILD_DEV_TYPE, // Device types a fitler can receive 1090 | 1091 | CACHE_USER_CONSTANTS = 1000 // Smaller values are reserved for the core 1092 | 1093 | }; 1094 | 1095 | // Base class for all filters. 1096 | class IClip { 1097 | friend class PClip; 1098 | friend class AVSValue; 1099 | volatile long refcnt; 1100 | void AddRef(); 1101 | #if BUILDING_AVSCORE 1102 | public: 1103 | #endif 1104 | void Release(); 1105 | public: 1106 | IClip() : refcnt(0) {} 1107 | virtual int __stdcall GetVersion() { return AVISYNTH_INTERFACE_VERSION; } 1108 | virtual PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) = 0; 1109 | virtual bool __stdcall GetParity(int n) = 0; // return field parity if field_based, else parity of first field in frame 1110 | virtual void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) = 0; // start and count are in samples 1111 | /* Need to check GetVersion first, pre v5 will return random crap from EAX reg. */ 1112 | virtual int __stdcall SetCacheHints(int cachehints,int frame_range) = 0 ; // We do not pass cache requests upwards, only to the next filter. 1113 | virtual const VideoInfo& __stdcall GetVideoInfo() = 0; 1114 | virtual ~IClip() {} 1115 | }; // end class IClip 1116 | 1117 | 1118 | // smart pointer to IClip 1119 | class PClip { 1120 | 1121 | IClip* p; 1122 | 1123 | IClip* GetPointerWithAddRef() const; 1124 | friend class AVSValue; 1125 | friend class VideoFrame; 1126 | 1127 | void Init(IClip* x); 1128 | void Set(IClip* x); 1129 | 1130 | public: 1131 | PClip() AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR0)() ) 1132 | PClip(const PClip& x) AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR1)(x) ) 1133 | PClip(IClip* x) AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR2)(x) ) 1134 | void operator=(IClip* x) AVS_BakedCode( AVS_LinkCall_Void(PClip_OPERATOR_ASSIGN0)(x) ) 1135 | void operator=(const PClip& x) AVS_BakedCode( AVS_LinkCall_Void(PClip_OPERATOR_ASSIGN1)(x) ) 1136 | 1137 | IClip* operator->() const { return p; } 1138 | 1139 | // useful in conditional expressions 1140 | operator void*() const { return p; } 1141 | bool operator!() const { return !p; } 1142 | 1143 | ~PClip() AVS_BakedCode( AVS_LinkCall_Void(PClip_DESTRUCTOR)() ) 1144 | #ifdef BUILDING_AVSCORE 1145 | public: 1146 | void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ 1147 | void CONSTRUCTOR1(const PClip& x); 1148 | void CONSTRUCTOR2(IClip* x); 1149 | void OPERATOR_ASSIGN0(IClip* x); 1150 | void OPERATOR_ASSIGN1(const PClip& x); 1151 | void DESTRUCTOR(); 1152 | #endif 1153 | }; // end class PClip 1154 | 1155 | // enums for frame property functions 1156 | enum AVSPropTypes { 1157 | PROPTYPE_UNSET = 'u', // ptUnset 1158 | PROPTYPE_INT = 'i', // peType 1159 | PROPTYPE_FLOAT = 'f', // ptFloat 1160 | PROPTYPE_DATA = 's', // ptData 1161 | PROPTYPE_CLIP = 'c', // ptClip 1162 | PROPTYPE_FRAME = 'v' // ptFrame 1163 | // ptFunction = 'm' 1164 | }; 1165 | 1166 | enum AVSGetPropErrors { 1167 | GETPROPERROR_UNSET = 1, // peUnset 1168 | GETPROPERROR_TYPE = 2, // peType 1169 | GETPROPERROR_INDEX = 4 // peIndex 1170 | }; 1171 | 1172 | enum AVSPropAppendMode { 1173 | PROPAPPENDMODE_REPLACE = 0, // paReplace 1174 | PROPAPPENDMODE_APPEND = 1, // paAppend 1175 | PROPAPPENDMODE_TOUCH = 2 // paTouch 1176 | }; 1177 | 1178 | 1179 | class AVSValue { 1180 | public: 1181 | 1182 | AVSValue() AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR0)() ) 1183 | AVSValue(IClip* c) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR1)(c) ) 1184 | AVSValue(const PClip& c) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR2)(c) ) 1185 | AVSValue(bool b) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR3)(b) ) 1186 | AVSValue(int i) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR4)(i) ) 1187 | // AVSValue(int64_t l); 1188 | AVSValue(float f) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR5)(f) ) 1189 | AVSValue(double f) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR6)(f) ) 1190 | AVSValue(const char* s) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR7)(s) ) 1191 | AVSValue(const AVSValue* a, int size) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR8)(a, size) ) 1192 | AVSValue(const AVSValue& a, int size) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR8)(&a, size) ) 1193 | AVSValue(const AVSValue& v) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR9)(v) ) 1194 | AVSValue(const PFunction& n) AVS_BakedCode(AVS_LinkCall_Void(AVSValue_CONSTRUCTOR11)(n)) 1195 | 1196 | ~AVSValue() AVS_BakedCode( AVS_LinkCall_Void(AVSValue_DESTRUCTOR)() ) 1197 | AVSValue& operator=(const AVSValue& v) AVS_BakedCode( return AVS_LinkCallV(AVSValue_OPERATOR_ASSIGN)(v) ) 1198 | 1199 | // Note that we transparently allow 'int' to be treated as 'float'. 1200 | // There are no int<->bool conversions, though. 1201 | 1202 | bool Defined() const AVS_BakedCode( return AVS_LinkCall(Defined)() ) 1203 | bool IsClip() const AVS_BakedCode( return AVS_LinkCall(IsClip)() ) 1204 | bool IsBool() const AVS_BakedCode( return AVS_LinkCall(IsBool)() ) 1205 | bool IsInt() const AVS_BakedCode( return AVS_LinkCall(IsInt)() ) 1206 | // bool IsLong() const; 1207 | bool IsFloat() const AVS_BakedCode( return AVS_LinkCall(IsFloat)() ) 1208 | bool IsString() const AVS_BakedCode( return AVS_LinkCall(IsString)() ) 1209 | bool IsArray() const AVS_BakedCode(return AVS_LinkCall(IsArray)()) 1210 | bool IsFunction() const AVS_BakedCode( return AVS_LinkCall(IsFunction)() ) 1211 | 1212 | PClip AsClip() const AVS_BakedCode( return AVS_LinkCall(AsClip)() ) 1213 | bool AsBool() const AVS_BakedCode( return AVS_LinkCall(AsBool1)() ) 1214 | int AsInt() const AVS_BakedCode( return AVS_LinkCall(AsInt1)() ) 1215 | // int AsLong() const; 1216 | const char* AsString() const AVS_BakedCode( return AVS_LinkCall(AsString1)() ) 1217 | double AsFloat() const AVS_BakedCode( return AVS_LinkCall(AsFloat1)() ) 1218 | float AsFloatf() const AVS_BakedCode( return float( AVS_LinkCall(AsFloat1)() ) ) 1219 | 1220 | bool AsBool(bool def) const AVS_BakedCode( return AVS_LinkCall(AsBool2)(def) ) 1221 | int AsInt(int def) const AVS_BakedCode( return AVS_LinkCall(AsInt2)(def) ) 1222 | double AsDblDef(double def) const AVS_BakedCode( return AVS_LinkCall(AsDblDef)(def) ) // Value is still a float 1223 | double AsFloat(float def) const AVS_BakedCode( return AVS_LinkCall(AsFloat2)(def) ) 1224 | float AsFloatf(float def) const AVS_BakedCode( return float( AVS_LinkCall(AsFloat2)(def) ) ) 1225 | const char* AsString(const char* def) const AVS_BakedCode( return AVS_LinkCall(AsString2)(def) ) 1226 | PFunction AsFunction() const; // internal use only 1227 | 1228 | int ArraySize() const AVS_BakedCode( return AVS_LinkCall(ArraySize)() ) 1229 | 1230 | const AVSValue& operator[](int index) const AVS_BakedCode( return AVS_LinkCallV(AVSValue_OPERATOR_INDEX)(index) ) 1231 | 1232 | private: 1233 | 1234 | short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, fu'n'ction, or RFU: 'l'ong ('d'ouble) 1235 | short array_size; 1236 | union { 1237 | IClip* clip; 1238 | bool boolean; 1239 | int integer; 1240 | float floating_pt; 1241 | const char* string; 1242 | const AVSValue* array; 1243 | IFunction* function; 1244 | #ifdef X86_64 1245 | // if ever, only x64 will support. It breaks struct size on 32 bit 1246 | int64_t longlong; // 8 bytes 1247 | double double_pt; // 8 bytes 1248 | #endif 1249 | }; 1250 | 1251 | void Assign(const AVSValue* src, bool init); 1252 | #ifdef BUILDING_AVSCORE 1253 | public: 1254 | void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ 1255 | void CONSTRUCTOR1(IClip* c); 1256 | void CONSTRUCTOR2(const PClip& c); 1257 | void CONSTRUCTOR3(bool b); 1258 | void CONSTRUCTOR4(int i); 1259 | void CONSTRUCTOR5(float f); 1260 | void CONSTRUCTOR6(double f); 1261 | void CONSTRUCTOR7(const char* s); 1262 | void CONSTRUCTOR8(const AVSValue* a, int size); 1263 | void CONSTRUCTOR9(const AVSValue& v); 1264 | void CONSTRUCTOR11(const PFunction& n); 1265 | void DESTRUCTOR(); 1266 | AVSValue& OPERATOR_ASSIGN(const AVSValue& v); 1267 | const AVSValue& OPERATOR_INDEX(int index) const; 1268 | 1269 | bool AsBool1() const; 1270 | int AsInt1() const; 1271 | const char* AsString1() const; 1272 | double AsFloat1() const; 1273 | 1274 | bool AsBool2(bool def) const; 1275 | int AsInt2(int def) const; 1276 | double AsFloat2(float def) const; 1277 | const char* AsString2(const char* def) const; 1278 | 1279 | #ifdef NEW_AVSVALUE 1280 | void MarkArrayAsC(); // for C interface, no deep-copy and deep-free 1281 | void CONSTRUCTOR10(const AVSValue& v, bool c_arrays); 1282 | AVSValue(const AVSValue& v, bool c_arrays); 1283 | void Assign2(const AVSValue* src, bool init, bool c_arrays); 1284 | #endif 1285 | 1286 | #endif 1287 | }; // end class AVSValue 1288 | 1289 | #define AVS_UNUSED(x) (void)(x) 1290 | 1291 | // instantiable null filter 1292 | class GenericVideoFilter : public IClip { 1293 | protected: 1294 | PClip child; 1295 | VideoInfo vi; 1296 | public: 1297 | GenericVideoFilter(PClip _child) : child(_child) { vi = child->GetVideoInfo(); } 1298 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) { return child->GetFrame(n, env); } 1299 | void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) { child->GetAudio(buf, start, count, env); } 1300 | const VideoInfo& __stdcall GetVideoInfo() { return vi; } 1301 | bool __stdcall GetParity(int n) { return child->GetParity(n); } 1302 | int __stdcall SetCacheHints(int cachehints, int frame_range) { AVS_UNUSED(cachehints); AVS_UNUSED(frame_range); return 0; }; // We do not pass cache requests upwards, only to the next filter. 1303 | }; 1304 | 1305 | 1306 | class PFunction 1307 | { 1308 | public: 1309 | PFunction() AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR0)()) 1310 | PFunction(IFunction* p) AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR1)(p)) 1311 | PFunction(const PFunction& p) AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR2)(p)) 1312 | PFunction& operator=(IFunction* p) AVS_BakedCode(return AVS_LinkCallV(PFunction_OPERATOR_ASSIGN0)(p)) 1313 | PFunction& operator=(const PFunction& p) AVS_BakedCode(return AVS_LinkCallV(PFunction_OPERATOR_ASSIGN1)(p)) 1314 | ~PFunction() AVS_BakedCode(AVS_LinkCall_Void(PFunction_DESTRUCTOR)()) 1315 | 1316 | int operator!() const { return !e; } 1317 | operator void*() const { return e; } 1318 | IFunction* operator->() const { return e; } 1319 | 1320 | private: 1321 | IFunction * e; 1322 | 1323 | friend class AVSValue; 1324 | IFunction * GetPointerWithAddRef() const; 1325 | void Init(IFunction* p); 1326 | void Set(IFunction* p); 1327 | 1328 | #ifdef BUILDING_AVSCORE 1329 | public: 1330 | void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ 1331 | void CONSTRUCTOR1(IFunction* p); 1332 | void CONSTRUCTOR2(const PFunction& p); 1333 | PFunction& OPERATOR_ASSIGN0(IFunction* p); 1334 | PFunction& OPERATOR_ASSIGN1(const PFunction& p); 1335 | void DESTRUCTOR(); 1336 | #endif 1337 | }; 1338 | 1339 | 1340 | #undef CALL_MEMBER_FN 1341 | #undef AVS_LinkCallOptDefault 1342 | #undef AVS_LinkCallOpt 1343 | #undef AVS_LinkCallV 1344 | #undef AVS_LinkCall 1345 | #undef AVS_BakedCode 1346 | 1347 | 1348 | #include "avs/cpuid.h" 1349 | 1350 | // IScriptEnvironment GetEnvProperty 1351 | enum AvsEnvProperty 1352 | { 1353 | AEP_PHYSICAL_CPUS = 1, 1354 | AEP_LOGICAL_CPUS = 2, 1355 | AEP_THREADPOOL_THREADS = 3, 1356 | AEP_FILTERCHAIN_THREADS = 4, 1357 | AEP_THREAD_ID = 5, 1358 | AEP_VERSION = 6, 1359 | 1360 | // Neo additionals 1361 | AEP_NUM_DEVICES = 901, 1362 | AEP_FRAME_ALIGN = 902, 1363 | AEP_PLANE_ALIGN = 903, 1364 | 1365 | AEP_SUPPRESS_THREAD = 921, 1366 | AEP_GETFRAME_RECURSIVE = 922, 1367 | }; 1368 | 1369 | // IScriptEnvironment Allocate 1370 | enum AvsAllocType 1371 | { 1372 | AVS_NORMAL_ALLOC = 1, 1373 | AVS_POOLED_ALLOC = 2 1374 | }; 1375 | 1376 | 1377 | class IScriptEnvironment { 1378 | public: 1379 | virtual ~IScriptEnvironment() {} 1380 | 1381 | virtual /*static*/ int __stdcall GetCPUFlags() = 0; 1382 | 1383 | virtual char* __stdcall SaveString(const char* s, int length = -1) = 0; 1384 | virtual char* Sprintf(const char* fmt, ...) = 0; 1385 | // note: val is really a va_list; I hope everyone typedefs va_list to a pointer 1386 | // 20200305: (void *) changed back to va_list 1387 | virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0; 1388 | 1389 | #ifdef AVS_WINDOWS 1390 | __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0; 1391 | #else 1392 | virtual void ThrowError(const char* fmt, ...) = 0; 1393 | #endif 1394 | 1395 | class NotFound /*exception*/ {}; // thrown by Invoke and GetVar 1396 | 1397 | typedef AVSValue (__cdecl *ApplyFunc)(AVSValue args, void* user_data, IScriptEnvironment* env); 1398 | 1399 | virtual void __stdcall AddFunction(const char* name, const char* params, ApplyFunc apply, void* user_data) = 0; 1400 | virtual bool __stdcall FunctionExists(const char* name) = 0; 1401 | virtual AVSValue __stdcall Invoke(const char* name, const AVSValue args, const char* const* arg_names=0) = 0; 1402 | 1403 | virtual AVSValue __stdcall GetVar(const char* name) = 0; 1404 | virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0; 1405 | virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0; 1406 | 1407 | virtual void __stdcall PushContext(int level=0) = 0; 1408 | virtual void __stdcall PopContext() = 0; 1409 | 1410 | // note v8: deprecated in most cases, use NewVideoFrameP is possible 1411 | virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, int align=FRAME_ALIGN) = 0; 1412 | 1413 | virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0; 1414 | 1415 | virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0; 1416 | 1417 | typedef void (__cdecl *ShutdownFunc)(void* user_data, IScriptEnvironment* env); 1418 | virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0; 1419 | 1420 | virtual void __stdcall CheckVersion(int version = AVISYNTH_INTERFACE_VERSION) = 0; 1421 | 1422 | virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0; 1423 | 1424 | virtual int __stdcall SetMemoryMax(int mem) = 0; 1425 | 1426 | virtual int __stdcall SetWorkingDir(const char * newdir) = 0; 1427 | 1428 | virtual void* __stdcall ManageCache(int key, void* data) = 0; 1429 | 1430 | enum PlanarChromaAlignmentMode { 1431 | PlanarChromaAlignmentOff, 1432 | PlanarChromaAlignmentOn, 1433 | PlanarChromaAlignmentTest }; 1434 | 1435 | virtual bool __stdcall PlanarChromaAlignment(PlanarChromaAlignmentMode key) = 0; 1436 | 1437 | virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, 1438 | int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0; 1439 | 1440 | // **** AVISYNTH_INTERFACE_VERSION 5 **** defined since classic Avisynth 2.6 beta 1441 | virtual void __stdcall DeleteScriptEnvironment() = 0; 1442 | 1443 | virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size, 1444 | int textcolor, int halocolor, int bgcolor) = 0; 1445 | 1446 | virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0; 1447 | 1448 | // **** AVISYNTH_INTERFACE_VERSION 6 **** defined since classic Avisynth 2.6 1449 | // noThrow version of GetVar 1450 | virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0; 1451 | 1452 | // **** AVISYNTH_INTERFACE_VERSION 8 **** AviSynth+ 3.6.0- 1453 | virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, 1454 | int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0; 1455 | 1456 | virtual void __stdcall copyFrameProps(const PVideoFrame& src, PVideoFrame& dst) = 0; 1457 | virtual const AVSMap* __stdcall getFramePropsRO(const PVideoFrame& frame) = 0; 1458 | virtual AVSMap* __stdcall getFramePropsRW(PVideoFrame& frame) = 0; 1459 | 1460 | virtual int __stdcall propNumKeys(const AVSMap* map) = 0; 1461 | 1462 | virtual const char* __stdcall propGetKey(const AVSMap* map, int index) = 0; 1463 | virtual int __stdcall propNumElements(const AVSMap* map, const char* key) = 0; 1464 | virtual char __stdcall propGetType(const AVSMap* map, const char* key) = 0; 1465 | 1466 | virtual int64_t __stdcall propGetInt(const AVSMap* map, const char* key, int index, int* error) = 0; 1467 | virtual double __stdcall propGetFloat(const AVSMap* map, const char* key, int index, int* error) = 0; 1468 | virtual const char* __stdcall propGetData(const AVSMap* map, const char* key, int index, int* error) = 0; 1469 | virtual int __stdcall propGetDataSize(const AVSMap* map, const char* key, int index, int* error) = 0; 1470 | virtual PClip __stdcall propGetClip(const AVSMap* map, const char* key, int index, int* error) = 0; 1471 | virtual const PVideoFrame __stdcall propGetFrame(const AVSMap* map, const char* key, int index, int* error) = 0; 1472 | 1473 | virtual int __stdcall propDeleteKey(AVSMap* map, const char* key) = 0; 1474 | 1475 | virtual int __stdcall propSetInt(AVSMap* map, const char* key, int64_t i, int append) = 0; 1476 | virtual int __stdcall propSetFloat(AVSMap* map, const char* key, double d, int append) = 0; 1477 | virtual int __stdcall propSetData(AVSMap* map, const char* key, const char* d, int length, int append) = 0; 1478 | virtual int __stdcall propSetClip(AVSMap* map, const char* key, PClip& clip, int append) = 0; 1479 | virtual int __stdcall propSetFrame(AVSMap* map, const char* key, const PVideoFrame& frame, int append) = 0; 1480 | 1481 | virtual const int64_t* __stdcall propGetIntArray(const AVSMap* map, const char* key, int* error) = 0; 1482 | virtual const double* __stdcall propGetFloatArray(const AVSMap* map, const char* key, int* error) = 0; 1483 | virtual int __stdcall propSetIntArray(AVSMap* map, const char* key, const int64_t* i, int size) = 0; 1484 | virtual int __stdcall propSetFloatArray(AVSMap* map, const char* key, const double* d, int size) = 0; 1485 | 1486 | virtual AVSMap* __stdcall createMap() = 0; 1487 | virtual void __stdcall freeMap(AVSMap* map) = 0; 1488 | virtual void __stdcall clearMap(AVSMap* map) = 0; 1489 | 1490 | // NewVideoFrame with frame property source. 1491 | virtual PVideoFrame __stdcall NewVideoFrameP(const VideoInfo& vi, PVideoFrame* propSrc, int align = FRAME_ALIGN) = 0; 1492 | 1493 | // Note: do not declare existing names like 'NewVideoFrame' again with different parameters since MSVC will reorder it 1494 | // in the vtable and group it together with the first NewVideoFrame variant. 1495 | // This results in shifting all vtable method pointers after NewVideoFrame and breaks all plugins who expect the old order. 1496 | // E.g. ApplyMessage will be called instead of GetAVSLinkage 1497 | 1498 | // Generic query to ask for various system properties 1499 | virtual size_t __stdcall GetEnvProperty(AvsEnvProperty prop) = 0; 1500 | 1501 | // Support functions 1502 | virtual void* __stdcall Allocate(size_t nBytes, size_t alignment, AvsAllocType type) = 0; 1503 | virtual void __stdcall Free(void* ptr) = 0; 1504 | 1505 | // these GetVar versions (renamed differently) were moved from IScriptEnvironment2 1506 | 1507 | // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'. 1508 | virtual bool __stdcall GetVarTry(const char* name, AVSValue* val) const = 0; // ex virtual bool __stdcall GetVar(const char* name, AVSValue* val) const = 0; 1509 | // Return the value of the requested variable. 1510 | // If the variable was not found or had the wrong type, 1511 | // return the supplied default value. 1512 | virtual bool __stdcall GetVarBool(const char* name, bool def) const = 0; 1513 | virtual int __stdcall GetVarInt(const char* name, int def) const = 0; 1514 | virtual double __stdcall GetVarDouble(const char* name, double def) const = 0; 1515 | virtual const char* __stdcall GetVarString(const char* name, const char* def) const = 0; 1516 | // brand new in v8 - though no real int64 support yet 1517 | virtual int64_t __stdcall GetVarLong(const char* name, int64_t def) const = 0; 1518 | 1519 | // 'Invoke' functions moved here from internal ScriptEnvironments are renamed in order to keep vtable order 1520 | // Invoke functions with 'Try' will return false instead of throwing NotFound(). 1521 | // ex-IScriptEnvironment2 1522 | virtual bool __stdcall InvokeTry(AVSValue* result, const char* name, const AVSValue& args, const char* const* arg_names = 0) = 0; 1523 | // Since V8 1524 | virtual AVSValue __stdcall Invoke2(const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; 1525 | // Ex-INeo 1526 | virtual bool __stdcall Invoke2Try(AVSValue* result, const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; 1527 | virtual AVSValue __stdcall Invoke3(const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; 1528 | virtual bool __stdcall Invoke3Try(AVSValue* result, const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; 1529 | 1530 | }; // end class IScriptEnvironment 1531 | 1532 | // used internally 1533 | class IScriptEnvironment_Avs25 { 1534 | public: 1535 | virtual ~IScriptEnvironment_Avs25() {} 1536 | 1537 | virtual /*static*/ int __stdcall GetCPUFlags() = 0; 1538 | 1539 | virtual char* __stdcall SaveString(const char* s, int length = -1) = 0; 1540 | virtual char* Sprintf(const char* fmt, ...) = 0; 1541 | virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0; 1542 | 1543 | #ifdef AVS_WINDOWS 1544 | __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0; 1545 | #else 1546 | virtual void ThrowError(const char* fmt, ...) = 0; 1547 | #endif 1548 | 1549 | class NotFound /*exception*/ {}; // thrown by Invoke and GetVar 1550 | 1551 | typedef AVSValue(__cdecl* ApplyFunc)(AVSValue args, void* user_data, IScriptEnvironment* env); 1552 | 1553 | virtual void __stdcall AddFunction25(const char* name, const char* params, ApplyFunc apply, void* user_data) = 0; 1554 | virtual bool __stdcall FunctionExists(const char* name) = 0; 1555 | virtual AVSValue __stdcall Invoke25(const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; 1556 | 1557 | virtual AVSValue __stdcall GetVar(const char* name) = 0; 1558 | virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0; 1559 | virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0; 1560 | 1561 | virtual void __stdcall PushContext(int level = 0) = 0; 1562 | virtual void __stdcall PopContext() = 0; 1563 | 1564 | virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, int align = FRAME_ALIGN) = 0; 1565 | 1566 | virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0; 1567 | 1568 | virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0; 1569 | 1570 | typedef void(__cdecl* ShutdownFunc)(void* user_data, IScriptEnvironment* env); 1571 | virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0; 1572 | 1573 | virtual void __stdcall CheckVersion(int version = AVISYNTH_CLASSIC_INTERFACE_VERSION_25) = 0; 1574 | 1575 | virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0; 1576 | 1577 | virtual int __stdcall SetMemoryMax(int mem) = 0; 1578 | 1579 | virtual int __stdcall SetWorkingDir(const char* newdir) = 0; 1580 | 1581 | // specially returns 1 for key MC_QueryAvs25 to check if called from AVS2.5 interface 1582 | virtual void* __stdcall ManageCache25(int key, void* data) = 0; 1583 | 1584 | enum PlanarChromaAlignmentMode { 1585 | PlanarChromaAlignmentOff, 1586 | PlanarChromaAlignmentOn, 1587 | PlanarChromaAlignmentTest 1588 | }; 1589 | 1590 | virtual bool __stdcall PlanarChromaAlignment(IScriptEnvironment::PlanarChromaAlignmentMode key) = 0; 1591 | 1592 | virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, 1593 | int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0; 1594 | 1595 | // Despite the name, we provide entries up to V6 in case someone requests 1596 | // a V3 interface and still wants to use V5-V6 functions 1597 | 1598 | // **** AVISYNTH_INTERFACE_VERSION 5 **** defined since classic Avisynth 2.6 beta 1599 | virtual void __stdcall DeleteScriptEnvironment() = 0; 1600 | 1601 | virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size, 1602 | int textcolor, int halocolor, int bgcolor) = 0; 1603 | 1604 | virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0; 1605 | 1606 | // **** AVISYNTH_INTERFACE_VERSION 6 **** defined since classic Avisynth 2.6 1607 | // noThrow version of GetVar 1608 | virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0; 1609 | 1610 | }; // end class IScriptEnvironment_Avs25 1611 | 1612 | 1613 | enum MtMode 1614 | { 1615 | MT_INVALID = 0, 1616 | MT_NICE_FILTER = 1, 1617 | MT_MULTI_INSTANCE = 2, 1618 | MT_SERIALIZED = 3, 1619 | MT_SPECIAL_MT = 4, 1620 | MT_MODE_COUNT = 5 1621 | }; 1622 | 1623 | class IJobCompletion 1624 | { 1625 | public: 1626 | 1627 | virtual ~IJobCompletion() {} 1628 | virtual void __stdcall Wait() = 0; 1629 | virtual AVSValue __stdcall Get(size_t i) = 0; 1630 | virtual size_t __stdcall Size() const = 0; 1631 | virtual size_t __stdcall Capacity() const = 0; 1632 | virtual void __stdcall Reset() = 0; 1633 | virtual void __stdcall Destroy() = 0; 1634 | }; 1635 | 1636 | class IScriptEnvironment2; 1637 | class Prefetcher; 1638 | typedef AVSValue (*ThreadWorkerFuncPtr)(IScriptEnvironment2* env, void* data); 1639 | 1640 | 1641 | /* ----------------------------------------------------------------------------- 1642 | Note to plugin authors: The interface in IScriptEnvironment2 is 1643 | preliminary / under construction / only for testing / non-final etc.! 1644 | As long as you see this note here, IScriptEnvironment2 might still change, 1645 | in which case your plugin WILL break. This also means that you are welcome 1646 | to test it and give your feedback about any ideas, improvements, or issues 1647 | you might have. 1648 | ----------------------------------------------------------------------------- */ 1649 | class IScriptEnvironment2 : public IScriptEnvironment{ 1650 | public: 1651 | virtual ~IScriptEnvironment2() {} 1652 | 1653 | // V8: SubframePlanarA, GetEnvProperty, GetVar versions, Allocate, Free, no-throw Invoke moved to IScriptEnvironment 1654 | 1655 | // Plugin functions 1656 | virtual bool __stdcall LoadPlugin(const char* filePath, bool throwOnError, AVSValue *result) = 0; 1657 | virtual void __stdcall AddAutoloadDir(const char* dirPath, bool toFront) = 0; 1658 | virtual void __stdcall ClearAutoloadDirs() = 0; 1659 | virtual void __stdcall AutoloadPlugins() = 0; 1660 | virtual void __stdcall AddFunction(const char* name, const char* params, ApplyFunc apply, void* user_data, const char *exportVar) = 0; 1661 | virtual bool __stdcall InternalFunctionExists(const char* name) = 0; 1662 | 1663 | // Threading 1664 | virtual void __stdcall SetFilterMTMode(const char* filter, MtMode mode, bool force) = 0; // If filter is "DEFAULT_MT_MODE", sets the default MT mode 1665 | virtual IJobCompletion* __stdcall NewCompletion(size_t capacity) = 0; 1666 | virtual void __stdcall ParallelJob(ThreadWorkerFuncPtr jobFunc, void* jobData, IJobCompletion* completion) = 0; 1667 | 1668 | // These lines are needed so that we can overload the older functions from IScriptEnvironment. 1669 | using IScriptEnvironment::Invoke; 1670 | using IScriptEnvironment::AddFunction; 1671 | 1672 | }; // end class IScriptEnvironment2 1673 | 1674 | 1675 | // To allow Avisynth+ add functions to IScriptEnvironment2, 1676 | // Neo defines another new interface, INeoEnv. 1677 | // INeoEnv and the legacy interfaces (IScriptEnvironment/IScriptEnvironment2) 1678 | // share the same ScriptEnvironment instance. The function with the same signature 1679 | // is exactly identical and there is no limitation to switch interfaces. 1680 | // You can use any interface you like. 1681 | // Note to plugin authors : The interface is not stable, see comments in IScriptEnvironment2 1682 | class INeoEnv { 1683 | public: 1684 | virtual ~INeoEnv() {} 1685 | 1686 | typedef IScriptEnvironment::NotFound NotFound; 1687 | typedef IScriptEnvironment::ApplyFunc ApplyFunc; 1688 | typedef IScriptEnvironment::ShutdownFunc ShutdownFunc; 1689 | 1690 | virtual void __stdcall DeleteScriptEnvironment() = 0; 1691 | 1692 | virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0; 1693 | 1694 | // Get legacy interface (Avisynth+) 1695 | virtual IScriptEnvironment2* __stdcall GetEnv2() = 0; 1696 | // Get compatibility interface for AVS CPP 2.5 plugins 1697 | virtual IScriptEnvironment_Avs25* __stdcall GetEnv25() = 0; 1698 | 1699 | // Generic system to ask for various properties 1700 | virtual size_t __stdcall GetEnvProperty(AvsEnvProperty prop) = 0; 1701 | virtual int __stdcall GetCPUFlags() = 0; 1702 | 1703 | // Plugin functions 1704 | virtual bool __stdcall LoadPlugin(const char* filePath, bool throwOnError, AVSValue *result) = 0; 1705 | virtual void __stdcall AddAutoloadDir(const char* dirPath, bool toFront) = 0; 1706 | virtual void __stdcall ClearAutoloadDirs() = 0; 1707 | virtual void __stdcall AutoloadPlugins() = 0; 1708 | 1709 | virtual void __stdcall AddFunction( 1710 | const char* name, const char* params, ApplyFunc apply, void* user_data) = 0; 1711 | virtual void __stdcall AddFunction( 1712 | const char* name, const char* params, ApplyFunc apply, void* user_data, const char *exportVar) = 0; 1713 | virtual bool __stdcall FunctionExists(const char* name) = 0; 1714 | virtual bool __stdcall InternalFunctionExists(const char* name) = 0; 1715 | 1716 | // Invoke function. Throws NotFound exception when the specified function does not exist. 1717 | virtual AVSValue __stdcall Invoke( 1718 | const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; 1719 | virtual AVSValue __stdcall Invoke2( 1720 | const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; 1721 | virtual AVSValue __stdcall Invoke3( 1722 | const AVSValue& implicit_last, 1723 | const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; 1724 | 1725 | // These versions of Invoke will return false instead of throwing NotFound(). 1726 | virtual bool __stdcall InvokeTry( 1727 | AVSValue* result, const char* name, const AVSValue& args, const char* const* arg_names = 0) = 0; 1728 | virtual bool __stdcall Invoke2Try( 1729 | AVSValue* result, const AVSValue& implicit_last, 1730 | const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; 1731 | virtual bool __stdcall Invoke3Try( 1732 | AVSValue* result, const AVSValue& implicit_last, 1733 | const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; 1734 | 1735 | // Throws exception when the requested variable is not found. 1736 | virtual AVSValue __stdcall GetVar(const char* name) = 0; 1737 | 1738 | // noThrow version of GetVar 1739 | virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0; 1740 | 1741 | // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'. 1742 | virtual bool __stdcall GetVarTry(const char* name, AVSValue* val) const = 0; 1743 | 1744 | // Return the value of the requested variable. 1745 | // If the variable was not found or had the wrong type, 1746 | // return the supplied default value. 1747 | virtual bool __stdcall GetVarBool(const char* name, bool def) const = 0; 1748 | virtual int __stdcall GetVarInt(const char* name, int def) const = 0; 1749 | virtual double __stdcall GetVarDouble(const char* name, double def) const = 0; 1750 | virtual const char* __stdcall GetVarString(const char* name, const char* def) const = 0; 1751 | virtual int64_t __stdcall GetVarLong(const char* name, int64_t def) const = 0; 1752 | 1753 | virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0; 1754 | virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0; 1755 | 1756 | // Switch local variables 1757 | virtual void __stdcall PushContext(int level = 0) = 0; 1758 | virtual void __stdcall PopContext() = 0; 1759 | 1760 | // Global variable frame support 1761 | virtual void __stdcall PushContextGlobal() = 0; 1762 | virtual void __stdcall PopContextGlobal() = 0; 1763 | 1764 | // Allocate new video frame 1765 | // in PNeoEnv: align parameter is no longer supported 1766 | virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi) = 0; // current device is used 1767 | virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PDevice& device) = 0; 1768 | // as above but with property sources 1769 | virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, PVideoFrame *propSrc) = 0; // current device is used + frame property source 1770 | virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PDevice& device, PVideoFrame* propSrc) = 0; // current device is used + frame property source 1771 | 1772 | // Frame related operations 1773 | virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0; 1774 | virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0; 1775 | 1776 | virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0; 1777 | virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, 1778 | int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0; 1779 | virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, 1780 | int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0; 1781 | 1782 | // frame properties support 1783 | virtual void __stdcall copyFrameProps(const PVideoFrame& src, PVideoFrame& dst) = 0; 1784 | virtual const AVSMap* __stdcall getFramePropsRO(const PVideoFrame& frame) = 0; 1785 | virtual AVSMap* __stdcall getFramePropsRW(PVideoFrame& frame) = 0; 1786 | 1787 | virtual int __stdcall propNumKeys(const AVSMap* map) = 0; 1788 | virtual const char* __stdcall propGetKey(const AVSMap* map, int index) = 0; 1789 | virtual int __stdcall propNumElements(const AVSMap* map, const char* key) = 0; 1790 | virtual char __stdcall propGetType(const AVSMap* map, const char* key) = 0; 1791 | 1792 | virtual int64_t __stdcall propGetInt(const AVSMap* map, const char* key, int index, int* error) = 0; 1793 | virtual double __stdcall propGetFloat(const AVSMap* map, const char* key, int index, int* error) = 0; 1794 | virtual const char* __stdcall propGetData(const AVSMap* map, const char* key, int index, int* error) = 0; 1795 | virtual int __stdcall propGetDataSize(const AVSMap* map, const char* key, int index, int* error) = 0; 1796 | virtual PClip __stdcall propGetClip(const AVSMap* map, const char* key, int index, int* error) = 0; 1797 | virtual const PVideoFrame __stdcall propGetFrame(const AVSMap* map, const char* key, int index, int* error) = 0; 1798 | 1799 | virtual int __stdcall propDeleteKey(AVSMap* map, const char* key) = 0; 1800 | 1801 | virtual int __stdcall propSetInt(AVSMap* map, const char* key, int64_t i, int append) = 0; 1802 | virtual int __stdcall propSetFloat(AVSMap* map, const char* key, double d, int append) = 0; 1803 | virtual int __stdcall propSetData(AVSMap* map, const char* key, const char* d, int length, int append) = 0; 1804 | virtual int __stdcall propSetClip(AVSMap* map, const char* key, PClip& clip, int append) = 0; 1805 | virtual int __stdcall propSetFrame(AVSMap* map, const char* key, const PVideoFrame& frame, int append) = 0; 1806 | 1807 | virtual const int64_t *__stdcall propGetIntArray(const AVSMap* map, const char* key, int* error) = 0; 1808 | virtual const double *__stdcall propGetFloatArray(const AVSMap* map, const char* key, int* error) = 0; 1809 | virtual int __stdcall propSetIntArray(AVSMap* map, const char* key, const int64_t* i, int size) = 0; 1810 | virtual int __stdcall propSetFloatArray(AVSMap* map, const char* key, const double* d, int size) = 0; 1811 | 1812 | virtual AVSMap* __stdcall createMap() = 0; 1813 | virtual void __stdcall freeMap(AVSMap* map) = 0; 1814 | virtual void __stdcall clearMap(AVSMap* map) = 0; 1815 | 1816 | // Support functions 1817 | virtual void* __stdcall Allocate(size_t nBytes, size_t alignment, AvsAllocType type) = 0; 1818 | virtual void __stdcall Free(void* ptr) = 0; 1819 | 1820 | virtual char* __stdcall SaveString(const char* s, int length = -1) = 0; 1821 | virtual char* __stdcall SaveString(const char* s, int length, bool escape) = 0; 1822 | virtual char* Sprintf(const char* fmt, ...) = 0; 1823 | virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0; 1824 | 1825 | __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0; 1826 | 1827 | virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size, 1828 | int textcolor, int halocolor, int bgcolor) = 0; 1829 | 1830 | // Setting 1831 | virtual int __stdcall SetMemoryMax(int mem) = 0; 1832 | virtual int __stdcall SetMemoryMax(AvsDeviceType type, int index, int mem) = 0; 1833 | 1834 | virtual bool __stdcall PlanarChromaAlignment(IScriptEnvironment::PlanarChromaAlignmentMode key) = 0; 1835 | virtual int __stdcall SetWorkingDir(const char * newdir) = 0; 1836 | virtual void* __stdcall ManageCache(int key, void* data) = 0; 1837 | 1838 | virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0; 1839 | virtual void __stdcall CheckVersion(int version = AVISYNTH_INTERFACE_VERSION) = 0; 1840 | 1841 | // Threading 1842 | virtual void __stdcall SetFilterMTMode(const char* filter, MtMode mode, bool force) = 0; 1843 | virtual IJobCompletion* __stdcall NewCompletion(size_t capacity) = 0; 1844 | virtual void __stdcall ParallelJob(ThreadWorkerFuncPtr jobFunc, void* jobData, IJobCompletion* completion) = 0; 1845 | 1846 | // CUDA Support 1847 | virtual PDevice __stdcall GetDevice(AvsDeviceType dev_type, int dev_index) const = 0; 1848 | virtual PDevice __stdcall GetDevice() const = 0; // get current device 1849 | virtual AvsDeviceType __stdcall GetDeviceType() const = 0; 1850 | virtual int __stdcall GetDeviceId() const = 0; 1851 | virtual int __stdcall GetDeviceIndex() const = 0; 1852 | virtual void* __stdcall GetDeviceStream() const = 0; 1853 | virtual void __stdcall DeviceAddCallback(void(*cb)(void*), void* user_data) = 0; 1854 | 1855 | virtual PVideoFrame __stdcall GetFrame(PClip c, int n, const PDevice& device) = 0; 1856 | 1857 | }; 1858 | 1859 | // support interface conversion 1860 | struct PNeoEnv { 1861 | INeoEnv* p; 1862 | PNeoEnv() : p() { } 1863 | PNeoEnv(IScriptEnvironment* env) 1864 | #if defined(BUILDING_AVSCORE) || defined(AVS_STATIC_LIB) 1865 | ; 1866 | #else 1867 | : p(!AVS_linkage || offsetof(AVS_Linkage, GetNeoEnv) >= AVS_linkage->Size ? 0 : AVS_linkage->GetNeoEnv(env)) { } 1868 | #endif 1869 | 1870 | int operator!() const { return !p; } 1871 | operator void*() const { return p; } 1872 | INeoEnv* operator->() const { return p; } 1873 | #ifdef BUILDING_AVSCORE 1874 | inline operator IScriptEnvironment2*(); 1875 | inline operator IScriptEnvironment_Avs25* (); 1876 | #else 1877 | operator IScriptEnvironment2*() { return p->GetEnv2(); } 1878 | operator IScriptEnvironment_Avs25* () { return p->GetEnv25(); } 1879 | #endif 1880 | }; 1881 | 1882 | 1883 | // avisynth.dll exports this; it's a way to use it as a library, without 1884 | // writing an AVS script or without going through AVIFile. 1885 | AVSC_API(IScriptEnvironment*, CreateScriptEnvironment)(int version = AVISYNTH_INTERFACE_VERSION); 1886 | 1887 | 1888 | // These are some global variables you can set in your script to change AviSynth's behavior. 1889 | #define VARNAME_AllowFloatAudio "OPT_AllowFloatAudio" // Allow WAVE_FORMAT_IEEE_FLOAT audio output 1890 | #define VARNAME_VDubPlanarHack "OPT_VDubPlanarHack" // Hack YV16 and YV24 chroma plane order for old VDub's 1891 | #define VARNAME_AVIPadScanlines "OPT_AVIPadScanlines" // Have scanlines mod4 padded in all pixel formats 1892 | #define VARNAME_UseWaveExtensible "OPT_UseWaveExtensible" // Use WAVEFORMATEXTENSIBLE when describing audio to Windows 1893 | #define VARNAME_dwChannelMask "OPT_dwChannelMask" // Integer audio channel mask. See description of WAVEFORMATEXTENSIBLE for more info. 1894 | #define VARNAME_Enable_V210 "OPT_Enable_V210" // AVS+ use V210 instead of P210 (VfW) 1895 | #define VARNAME_Enable_Y3_10_10 "OPT_Enable_Y3_10_10" // AVS+ use Y3[10][10] instead of P210 (VfW) 1896 | #define VARNAME_Enable_Y3_10_16 "OPT_Enable_Y3_10_16" // AVS+ use Y3[10][16] instead of P216 (VfW) 1897 | #define VARNAME_Enable_b64a "OPT_Enable_b64a" // AVS+ use b64a instead of BRA[64] (VfW) 1898 | #define VARNAME_Enable_PlanarToPackedRGB "OPT_Enable_PlanarToPackedRGB" // AVS+ convert Planar RGB to packed RGB (VfW) 1899 | 1900 | // C exports 1901 | #include "avs/capi.h" 1902 | AVSC_API(IScriptEnvironment2*, CreateScriptEnvironment2)(int version = AVISYNTH_INTERFACE_VERSION); 1903 | 1904 | #ifndef BUILDING_AVSCORE 1905 | #undef AVS_UNUSED 1906 | #endif 1907 | 1908 | #pragma pack(pop) 1909 | 1910 | #endif //__AVISYNTH_8_H__ 1911 | --------------------------------------------------------------------------------