├── .gitattributes ├── COPYING ├── README.md ├── build ├── unix │ ├── Makefile.am │ ├── autogen.sh │ ├── configure.ac │ └── m4 │ │ ├── ax_check_compile_flag.m4 │ │ └── ax_check_link_flag.m4 └── win │ ├── chickendream.sln │ ├── chickendream │ ├── chickendream.vcxproj │ └── chickendream.vcxproj.filters │ ├── common │ ├── common.vcxproj │ └── common.vcxproj.filters │ ├── test │ └── test.vcxproj │ └── toolset.props ├── doc ├── chickendream.html ├── grain.png └── vapourdoc.css ├── src ├── AvstpFinder.cpp ├── AvstpFinder.h ├── AvstpWrapper.cpp ├── AvstpWrapper.h ├── VapourSynth4.h ├── avisynth.h ├── avs │ ├── alignment.h │ ├── capi.h │ ├── config.h │ ├── cpuid.h │ ├── filesystem.h │ ├── minmax.h │ ├── posix.h │ ├── types.h │ └── win.h ├── avstp.h ├── avsutl │ ├── CsPlane.cpp │ ├── CsPlane.h │ ├── PlaneProcCbInterface.h │ ├── PlaneProcCbInterface_avs.cpp │ ├── PlaneProcMode.h │ ├── PlaneProcessor.h │ ├── PlaneProcessor_avs.cpp │ ├── TFlag.h │ ├── VideoFilterBase.cpp │ ├── VideoFilterBase.h │ ├── fnc.h │ ├── fnc.hpp │ └── fnc_avsutl.cpp ├── chkdr │ ├── AvstpScopedDispatcher.cpp │ ├── AvstpScopedDispatcher.h │ ├── CpuOptBase.cpp │ ├── CpuOptBase.h │ ├── GrainProc.cpp │ └── GrainProc.h ├── chkdravs │ ├── Grain.h │ ├── Grain_avs.cpp │ └── function_names.h ├── chkdrvs │ ├── Grain.h │ ├── Grain_vs.cpp │ └── version.h ├── fgrn │ ├── Cell.h │ ├── Cell.hpp │ ├── CellCache.cpp │ ├── CellCache.h │ ├── GenGrain.cpp │ ├── GenGrain.h │ ├── GenGrain.hpp │ ├── GenGrain_avx.cpp │ ├── GrainDensity.cpp │ ├── GrainDensity.h │ ├── PointList.h │ ├── PointList.hpp │ ├── UtilPrng.h │ ├── UtilPrng.hpp │ ├── VisionFilter.cpp │ ├── VisionFilter.h │ └── VisionFilter.hpp ├── fstb │ ├── AllocAlign.h │ ├── AllocAlign.hpp │ ├── Approx.h │ ├── Approx.hpp │ ├── ArrayAlign.h │ ├── ArrayAlign.hpp │ ├── CpuId.cpp │ ├── CpuId.h │ ├── Hash.h │ ├── Hash.hpp │ ├── Poly.h │ ├── Poly.hpp │ ├── Scale.h │ ├── Scale.hpp │ ├── SingleObj.h │ ├── SingleObj.hpp │ ├── ToolsAvx2.cpp │ ├── ToolsAvx2.h │ ├── ToolsAvx2.hpp │ ├── ToolsSimd.cpp │ ├── ToolsSimd.h │ ├── ToolsSimd.hpp │ ├── ToolsSse2.cpp │ ├── ToolsSse2.h │ ├── ToolsSse2.hpp │ ├── VecAlign.h │ ├── Vf32.h │ ├── Vf32.hpp │ ├── Vs32.h │ ├── Vs32.hpp │ ├── Vu32.h │ ├── Vu32.hpp │ ├── def.h │ ├── fnc.h │ ├── fnc.hpp │ └── fnc_fstb.cpp ├── main-avs.cpp ├── main-vs.cpp ├── test │ └── main.cpp └── vsutl │ ├── FilterBase.cpp │ ├── FilterBase.h │ ├── FrameRefSPtr.h │ ├── FuncRefSPtr.h │ ├── NodeRefSPtr.h │ ├── ObjRefSPtr.h │ ├── ObjRefSPtr.hpp │ ├── PlaneProcCbInterface.h │ ├── PlaneProcCbInterface_vs.cpp │ ├── PlaneProcMode.h │ ├── PlaneProcessor.h │ ├── PlaneProcessor_vs.cpp │ ├── Redirect.h │ ├── Redirect.hpp │ ├── fnc.h │ └── fnc_vsutl.cpp └── zip-release.bat /.gitattributes: -------------------------------------------------------------------------------- 1 | 2 | *.sh text eol=lf 3 | *.ac text eol=lf 4 | *.am text eol=lf 5 | 6 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /build/unix/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autoreconf --verbose --install --force 4 | -------------------------------------------------------------------------------- /build/unix/configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([ChickenDream film grain generator], [r2], [http://ldesoras.free.fr], [chickendream], [http://ldesoras.free.fr]) 2 | AC_CONFIG_MACRO_DIR([m4]) 3 | 4 | AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-xz subdir-objects no-define]) 5 | AM_SILENT_RULES([yes]) 6 | 7 | LT_INIT([win32-dll disable-static]) 8 | 9 | : ${CXXFLAGS=""} 10 | : ${CFLAGS=""} 11 | 12 | AC_PROG_CXX 13 | AC_PROG_CC 14 | 15 | AC_CANONICAL_HOST 16 | 17 | AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Compilation options required for debugging. [default=no]])) 18 | 19 | 20 | 21 | X86="false" 22 | PPC="false" 23 | ARM="false" 24 | WIN="false" 25 | UNX="false" 26 | MAC="false" 27 | CLG="false" 28 | 29 | AS_CASE( 30 | [$host_cpu], 31 | [i?86], [BITS="32" X86="true"], 32 | [x86_64], [BITS="64" X86="true"], 33 | [powerpc*], [ PPC="true"], 34 | [arm*], [BITS="32" ARM="true"], 35 | [aarch64*], [BITS="64" ARM="true"] 36 | ) 37 | 38 | AS_CASE( 39 | [$host_os], 40 | [cygwin*|mingw*], [WIN="true"], 41 | [darwin*], [MAC="true"], 42 | [*linux*|gnu*|dragonfly*|*bsd*], [UNX="true"] 43 | ) 44 | 45 | AS_IF( 46 | [test "x$enable_debug" = "xyes"], 47 | [ 48 | DEBUGCFLAGS="-O0 -g3 -ggdb" 49 | AC_MSG_NOTICE([Debug mode enabled.]) 50 | ], 51 | [DEBUGCFLAGS="-O3 -g3 -DNDEBUG"] 52 | ) 53 | 54 | AS_IF( 55 | [test "x$CXX" = "xclang++"], 56 | [ 57 | CLG="true" 58 | MFLAGS="$MFLAGS -fexperimental-new-pass-manager -mllvm -inline-threshold=1000" 59 | COMPWARNFLAGS="" 60 | AC_MSG_NOTICE([Using clang as compiler.]) 61 | ], 62 | [COMPWARNFLAGS="-Wduplicated-cond -Wduplicated-branches -Wlogical-op"] 63 | ) 64 | 65 | AC_LANG_PUSH([C++]) 66 | #AS_IF([test "x$CXXSTD" = "x"], AX_CHECK_COMPILE_FLAG([-std=c++20], [CXXSTD="c++20"])) 67 | #AS_IF([test "x$CXXSTD" = "x"], AX_CHECK_COMPILE_FLAG([-std=c++17], [CXXSTD="c++17"])) 68 | AS_IF([test "x$CXXSTD" = "x"], AX_CHECK_COMPILE_FLAG([-std=c++14], [CXXSTD="c++14"])) 69 | AS_IF([test "x$CXXSTD" = "x"], AC_MSG_ERROR([Minimum requirement: C++14])) 70 | AC_LANG_POP([C++]) 71 | 72 | # It seems that -latomic is needed only for some versions of GCC < 5.3 73 | AX_CHECK_LINK_FLAG([-latomic], [LIBS="$LIBS -latomic"]) 74 | 75 | AS_IF( 76 | [test "x$WIN" = "xtrue"], 77 | [ 78 | AS_IF( 79 | [test "x$BITS" = "x32"], 80 | [ 81 | PLUGINLDFLAGS="-Wl,--kill-at" 82 | STACKREALIGN="-mstackrealign" 83 | ] 84 | ) 85 | ] 86 | ) 87 | 88 | AS_IF( 89 | [test "x$X86" = "xtrue"], 90 | [ 91 | MFLAGS="$MFLAGS -mfpmath=sse -msse2" 92 | COMPWARNFLAGS="$COMPWARNFLAGS -Wno-ignored-attributes" 93 | # We need this to use CMPXCHG16B for 2x64-bit CAS (compare and swap) 94 | AS_IF([test "x$BITS" = "x64"], [MFLAGS="$MFLAGS -mcx16"]) 95 | ] 96 | ) 97 | 98 | AS_IF( 99 | [test "x$ARM" = "xtrue"], 100 | [ 101 | MFLAGS="-ftree-vectorize" 102 | 103 | AX_CHECK_COMPILE_FLAG([-mfpu=neon], [MFLAGS="$MFLAGS -mfpu=neon"]) 104 | 105 | # GCC 7 emits some warnings about ABI changes when using std::vector 106 | AX_CHECK_COMPILE_FLAG([-Wpsabi], [COMPWARNFLAGS="$COMPWARNFLAGS -Wno-psabi"], , [-Werror]) 107 | ] 108 | ) 109 | 110 | AX_CHECK_COMPILE_FLAG([-Wmisleading-indentation] , [COMPWARNFLAGS="$COMPWARNFLAGS -Wmisleading-indentation"] , , [-Werror]) 111 | # Clang only 112 | AX_CHECK_COMPILE_FLAG([-Wno-implicit-int-float-conversion], [COMPWARNFLAGS="$COMPWARNFLAGS -Wno-implicit-int-float-conversion"], , [-Werror]) 113 | 114 | AC_SUBST([CXXSTD]) 115 | AC_SUBST([EXTRA_CXXFLAGS]) 116 | AC_SUBST([LDFLAGS]) 117 | AC_SUBST([MFLAGS]) 118 | AC_SUBST([DEBUGCFLAGS]) 119 | AC_SUBST([PLUGINLDFLAGS]) 120 | AC_SUBST([STACKREALIGN]) 121 | 122 | AM_CONDITIONAL([X86], [test "x$X86" = "xtrue"]) 123 | AM_CONDITIONAL([ARM], [test "x$ARM" = "xtrue"]) 124 | AM_CONDITIONAL([UNX], [test "x$UNX" = "xtrue"]) 125 | AM_CONDITIONAL([WIN], [test "x$WIN" = "xtrue"]) 126 | AM_CONDITIONAL([CLG], [test "x$CLG" = "xtrue"]) 127 | 128 | AC_CONFIG_FILES([Makefile]) 129 | AC_OUTPUT 130 | -------------------------------------------------------------------------------- /build/unix/m4/ax_check_compile_flag.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check whether the given FLAG works with the current language's compiler 12 | # or gives an error. (Warnings, however, are ignored) 13 | # 14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on 15 | # success/failure. 16 | # 17 | # If EXTRA-FLAGS is defined, it is added to the current language's default 18 | # flags (e.g. CFLAGS) when the check is done. The check is thus made with 19 | # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to 20 | # force the compiler to issue an error when a bad flag is given. 21 | # 22 | # INPUT gives an alternative input source to AC_COMPILE_IFELSE. 23 | # 24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this 25 | # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. 26 | # 27 | # LICENSE 28 | # 29 | # Copyright (c) 2008 Guido U. Draheim 30 | # Copyright (c) 2011 Maarten Bosmans 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | 37 | #serial 6 38 | 39 | AC_DEFUN([AX_CHECK_COMPILE_FLAG], 40 | [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF 41 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl 42 | AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ 43 | ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS 44 | _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" 45 | AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], 46 | [AS_VAR_SET(CACHEVAR,[yes])], 47 | [AS_VAR_SET(CACHEVAR,[no])]) 48 | _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) 49 | AS_VAR_IF(CACHEVAR,yes, 50 | [m4_default([$2], :)], 51 | [m4_default([$3], :)]) 52 | AS_VAR_POPDEF([CACHEVAR])dnl 53 | ])dnl AX_CHECK_COMPILE_FLAGS 54 | -------------------------------------------------------------------------------- /build/unix/m4/ax_check_link_flag.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check whether the given FLAG works with the linker or gives an error. 12 | # (Warnings, however, are ignored) 13 | # 14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on 15 | # success/failure. 16 | # 17 | # If EXTRA-FLAGS is defined, it is added to the linker's default flags 18 | # when the check is done. The check is thus made with the flags: "LDFLAGS 19 | # EXTRA-FLAGS FLAG". This can for example be used to force the linker to 20 | # issue an error when a bad flag is given. 21 | # 22 | # INPUT gives an alternative input source to AC_LINK_IFELSE. 23 | # 24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this 25 | # macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. 26 | # 27 | # LICENSE 28 | # 29 | # Copyright (c) 2008 Guido U. Draheim 30 | # Copyright (c) 2011 Maarten Bosmans 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | 37 | #serial 6 38 | 39 | AC_DEFUN([AX_CHECK_LINK_FLAG], 40 | [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF 41 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl 42 | AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ 43 | ax_check_save_flags=$LDFLAGS 44 | LDFLAGS="$LDFLAGS $4 $1" 45 | AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], 46 | [AS_VAR_SET(CACHEVAR,[yes])], 47 | [AS_VAR_SET(CACHEVAR,[no])]) 48 | LDFLAGS=$ax_check_save_flags]) 49 | AS_VAR_IF(CACHEVAR,yes, 50 | [m4_default([$2], :)], 51 | [m4_default([$3], :)]) 52 | AS_VAR_POPDEF([CACHEVAR])dnl 53 | ])dnl AX_CHECK_LINK_FLAGS 54 | -------------------------------------------------------------------------------- /build/win/chickendream.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29613.14 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chickendream", "chickendream\chickendream.vcxproj", "{474C5DF2-2DD1-4D2C-A06D-1F4D8BC3C004}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF} = {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common\common.vcxproj", "{C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF}" 12 | EndProject 13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{4F6DD521-F0B5-442B-86EB-B8A2A3AAC1B7}" 14 | ProjectSection(ProjectDependencies) = postProject 15 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF} = {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF} 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|ARM = Debug|ARM 21 | Debug|Win32 = Debug|Win32 22 | Debug|x64 = Debug|x64 23 | Release|ARM = Release|ARM 24 | Release|Win32 = Release|Win32 25 | Release|x64 = Release|x64 26 | EndGlobalSection 27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 28 | {474C5DF2-2DD1-4D2C-A06D-1F4D8BC3C004}.Debug|ARM.ActiveCfg = Debug|Win32 29 | {474C5DF2-2DD1-4D2C-A06D-1F4D8BC3C004}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {474C5DF2-2DD1-4D2C-A06D-1F4D8BC3C004}.Debug|Win32.Build.0 = Debug|Win32 31 | {474C5DF2-2DD1-4D2C-A06D-1F4D8BC3C004}.Debug|x64.ActiveCfg = Debug|x64 32 | {474C5DF2-2DD1-4D2C-A06D-1F4D8BC3C004}.Debug|x64.Build.0 = Debug|x64 33 | {474C5DF2-2DD1-4D2C-A06D-1F4D8BC3C004}.Release|ARM.ActiveCfg = Release|Win32 34 | {474C5DF2-2DD1-4D2C-A06D-1F4D8BC3C004}.Release|Win32.ActiveCfg = Release|Win32 35 | {474C5DF2-2DD1-4D2C-A06D-1F4D8BC3C004}.Release|Win32.Build.0 = Release|Win32 36 | {474C5DF2-2DD1-4D2C-A06D-1F4D8BC3C004}.Release|x64.ActiveCfg = Release|x64 37 | {474C5DF2-2DD1-4D2C-A06D-1F4D8BC3C004}.Release|x64.Build.0 = Release|x64 38 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF}.Debug|ARM.ActiveCfg = Debug|Win32 39 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF}.Debug|Win32.ActiveCfg = Debug|Win32 40 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF}.Debug|Win32.Build.0 = Debug|Win32 41 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF}.Debug|x64.ActiveCfg = Debug|x64 42 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF}.Debug|x64.Build.0 = Debug|x64 43 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF}.Release|ARM.ActiveCfg = Release|Win32 44 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF}.Release|Win32.ActiveCfg = Release|Win32 45 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF}.Release|Win32.Build.0 = Release|Win32 46 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF}.Release|x64.ActiveCfg = Release|x64 47 | {C5964F75-5C6B-42AF-BE8B-0F654DFFCEFF}.Release|x64.Build.0 = Release|x64 48 | {4F6DD521-F0B5-442B-86EB-B8A2A3AAC1B7}.Debug|ARM.ActiveCfg = Debug|Win32 49 | {4F6DD521-F0B5-442B-86EB-B8A2A3AAC1B7}.Debug|Win32.ActiveCfg = Debug|Win32 50 | {4F6DD521-F0B5-442B-86EB-B8A2A3AAC1B7}.Debug|Win32.Build.0 = Debug|Win32 51 | {4F6DD521-F0B5-442B-86EB-B8A2A3AAC1B7}.Debug|x64.ActiveCfg = Debug|x64 52 | {4F6DD521-F0B5-442B-86EB-B8A2A3AAC1B7}.Debug|x64.Build.0 = Debug|x64 53 | {4F6DD521-F0B5-442B-86EB-B8A2A3AAC1B7}.Release|ARM.ActiveCfg = Release|Win32 54 | {4F6DD521-F0B5-442B-86EB-B8A2A3AAC1B7}.Release|Win32.ActiveCfg = Release|Win32 55 | {4F6DD521-F0B5-442B-86EB-B8A2A3AAC1B7}.Release|Win32.Build.0 = Release|Win32 56 | {4F6DD521-F0B5-442B-86EB-B8A2A3AAC1B7}.Release|x64.ActiveCfg = Release|x64 57 | {4F6DD521-F0B5-442B-86EB-B8A2A3AAC1B7}.Release|x64.Build.0 = Release|x64 58 | EndGlobalSection 59 | GlobalSection(SolutionProperties) = preSolution 60 | HideSolutionNode = FALSE 61 | EndGlobalSection 62 | GlobalSection(ExtensibilityGlobals) = postSolution 63 | SolutionGuid = {8345EAB3-AB5A-47A5-835E-325EF51CA47A} 64 | EndGlobalSection 65 | EndGlobal 66 | -------------------------------------------------------------------------------- /build/win/toolset.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>12.0.30501.0 5 | 6 | 7 | v142 8 | 9 | 10 | v142 11 | 12 | -------------------------------------------------------------------------------- /doc/grain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EleonoreMizo/chickendream/b8b339da721d55ad9bfe022b10c42c3cdac16dc5/doc/grain.png -------------------------------------------------------------------------------- /src/AvstpFinder.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | AvstpFinder.h 4 | Author: Laurent de Soras, 2012 5 | 6 | Private class used by AvstpWrapper on Windows. 7 | Handles library publication and discovery. 8 | 9 | --- Legal stuff --- 10 | 11 | This program is free software. It comes without any warranty, to 12 | the extent permitted by applicable law. You can redistribute it 13 | and/or modify it under the terms of the Do What The Fuck You Want 14 | To Public License, Version 2, as published by Sam Hocevar. See 15 | http://sam.zoy.org/wtfpl/COPYING for more details. 16 | 17 | *Tab=3***********************************************************************/ 18 | 19 | 20 | 21 | #if ! defined (AvstpFinder_HEADER_INCLUDED) 22 | #define AvstpFinder_HEADER_INCLUDED 23 | 24 | #if defined (_MSC_VER) 25 | #pragma once 26 | #pragma warning (4 : 4250) 27 | #endif 28 | 29 | 30 | 31 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 32 | 33 | #define NOMINMAX 34 | 35 | #include 36 | 37 | 38 | 39 | class AvstpFinder 40 | { 41 | 42 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 43 | 44 | public: 45 | 46 | static void publish_lib (::HMODULE hinst); 47 | static ::HMODULE 48 | find_lib (); 49 | 50 | static const wchar_t 51 | _lib_name_0 []; 52 | 53 | 54 | 55 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 56 | 57 | protected: 58 | 59 | 60 | 61 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 62 | 63 | private: 64 | 65 | enum { BUFFER_LEN = 32767+1 }; // Characters 66 | 67 | static void compose_mapped_filename (wchar_t mf_name_0 [], wchar_t mu_name_0 []); 68 | static ::HMODULE 69 | get_code_module (); 70 | 71 | 72 | 73 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 74 | 75 | private: 76 | 77 | AvstpFinder (); 78 | AvstpFinder (const AvstpFinder &other); 79 | virtual ~AvstpFinder () {} 80 | AvstpFinder & operator = (const AvstpFinder &other); 81 | bool operator == (const AvstpFinder &other) const; 82 | bool operator != (const AvstpFinder &other) const; 83 | 84 | }; // class AvstpFinder 85 | 86 | 87 | 88 | //#include "AvstpFinder.hpp" 89 | 90 | 91 | 92 | #endif // AvstpFinder_HEADER_INCLUDED 93 | 94 | 95 | 96 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 97 | -------------------------------------------------------------------------------- /src/AvstpWrapper.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | AvstpWrapper.h 4 | Author: Laurent de Soras, 2012 5 | 6 | A convenient wrapper on top of the AVSTP low-level API. 7 | Take care of: 8 | - Library discovery and initialisation 9 | - Fallback to mono-threaded mode if not found 10 | 11 | This is a singleton, you cannot construct it directly. Use use_instance() 12 | to access it from anywhere. 13 | 14 | Note: must be compiled with a C++11-compliant compiler, in order to ensure 15 | that the construction of the singleton is thread-safe. 16 | 17 | --- Legal stuff --- 18 | 19 | This program is free software. It comes without any warranty, to 20 | the extent permitted by applicable law. You can redistribute it 21 | and/or modify it under the terms of the Do What The Fuck You Want 22 | To Public License, Version 2, as published by Sam Hocevar. See 23 | http://sam.zoy.org/wtfpl/COPYING for more details. 24 | 25 | *Tab=3***********************************************************************/ 26 | 27 | 28 | 29 | #if ! defined (AvstpWrapper_HEADER_INCLUDED) 30 | #define AvstpWrapper_HEADER_INCLUDED 31 | 32 | #if defined (_MSC_VER) 33 | #pragma once 34 | #pragma warning (4 : 4250) 35 | #endif 36 | 37 | 38 | 39 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 40 | 41 | #include "avstp.h" 42 | 43 | 44 | 45 | class AvstpWrapper 46 | { 47 | 48 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 49 | 50 | public: 51 | 52 | virtual ~AvstpWrapper (); 53 | 54 | static AvstpWrapper & 55 | use_instance (); 56 | 57 | // Wrapped functions 58 | int get_interface_version () const; 59 | avstp_TaskDispatcher * 60 | create_dispatcher (); 61 | void destroy_dispatcher (avstp_TaskDispatcher *td_ptr); 62 | int get_nbr_threads () const; 63 | int enqueue_task (avstp_TaskDispatcher *td_ptr, avstp_TaskPtr task_ptr, void *user_data_ptr); 64 | int wait_completion (avstp_TaskDispatcher *td_ptr); 65 | 66 | 67 | 68 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 69 | 70 | protected: 71 | 72 | AvstpWrapper (); 73 | 74 | 75 | 76 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 77 | 78 | private: 79 | 80 | template 81 | void resolve_name (T &fnc_ptr, const char *name_0); 82 | 83 | void assign_normal (); 84 | void assign_fallback (); 85 | 86 | static int fallback_get_interface_version_ptr (); 87 | static avstp_TaskDispatcher * 88 | fallback_create_dispatcher_ptr (); 89 | static void fallback_destroy_dispatcher_ptr (avstp_TaskDispatcher *td_ptr); 90 | static int fallback_get_nbr_threads_ptr (); 91 | static int fallback_enqueue_task_ptr (avstp_TaskDispatcher *td_ptr, avstp_TaskPtr task_ptr, void *user_data_ptr); 92 | static int fallback_wait_completion_ptr (avstp_TaskDispatcher *td_ptr); 93 | 94 | int (*_avstp_get_interface_version_ptr) (); 95 | avstp_TaskDispatcher * 96 | (*_avstp_create_dispatcher_ptr) (); 97 | void (*_avstp_destroy_dispatcher_ptr) (avstp_TaskDispatcher *td_ptr); 98 | int (*_avstp_get_nbr_threads_ptr) (); 99 | int (*_avstp_enqueue_task_ptr) (avstp_TaskDispatcher *td_ptr, avstp_TaskPtr task_ptr, void *user_data_ptr); 100 | int (*_avstp_wait_completion_ptr) (avstp_TaskDispatcher *td_ptr); 101 | 102 | void * _dll_hnd; // Avoids loading windows.h just for HMODULE 103 | 104 | static int _dummy_dispatcher; 105 | 106 | 107 | 108 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 109 | 110 | private: 111 | 112 | AvstpWrapper (const AvstpWrapper &other); 113 | AvstpWrapper & operator = (const AvstpWrapper &other); 114 | bool operator == (const AvstpWrapper &other) const; 115 | bool operator != (const AvstpWrapper &other) const; 116 | 117 | }; // class AvstpWrapper 118 | 119 | 120 | 121 | //#include "AvstpWrapper.hpp" 122 | 123 | 124 | 125 | #endif // AvstpWrapper_HEADER_INCLUDED 126 | 127 | 128 | 129 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 130 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/avstp.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | avstp.h 4 | Author: Laurent de Soras, 2011 5 | 6 | Main avstp public interface. 7 | 8 | --- Legal stuff --- 9 | 10 | This program is free software. It comes without any warranty, to 11 | the extent permitted by applicable law. You can redistribute it 12 | and/or modify it under the terms of the Do What The Fuck You Want 13 | To Public License, Version 2, as published by Sam Hocevar. See 14 | http://sam.zoy.org/wtfpl/COPYING for more details. 15 | 16 | *Tab=3***********************************************************************/ 17 | 18 | 19 | 20 | #if ! defined (avstp_HEADER_INCLUDED) 21 | #define avstp_HEADER_INCLUDED 22 | 23 | #if defined (_MSC_VER) 24 | #pragma once 25 | #pragma warning (4 : 4250) 26 | #endif 27 | 28 | 29 | 30 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 31 | 32 | 33 | 34 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 35 | 36 | 37 | 38 | #if defined (_WIN32) || defined (WIN32) || defined (__WIN32__) || defined (__CYGWIN__) || defined (__CYGWIN32__) 39 | #define avstp_CC __cdecl 40 | #define avstp_EXPORT(ret) __declspec(dllexport) ret avstp_CC 41 | 42 | #else 43 | #define avstp_CC 44 | #if defined (__GNUC__) && __GNUC__ >= 4 45 | #define avstp_EXPORT(ret) __attribute__((visibility("default"))) ret avstp_CC 46 | #else 47 | #define avstp_EXPORT(ret) ret avstp_CC 48 | #endif 49 | 50 | #endif 51 | 52 | 53 | 54 | #ifdef __cplusplus 55 | extern "C" 56 | { 57 | #endif 58 | 59 | 60 | 61 | #ifdef __cplusplus 62 | namespace avstp { class TaskDispatcher; } 63 | typedef avstp::TaskDispatcher avstp_TaskDispatcher; 64 | #else 65 | typedef struct avstp_TaskDispatcher avstp_TaskDispatcher; 66 | #endif // __cplusplus 67 | 68 | typedef void (avstp_CC *avstp_TaskPtr) (avstp_TaskDispatcher *td_ptr, void *user_data_ptr); 69 | 70 | enum 71 | { 72 | avstp_Err_OK = 0, 73 | 74 | avstp_Err_EXCEPTION = -999, 75 | avstp_Err_INVALID_ARG 76 | }; 77 | 78 | enum { avstp_INTERFACE_VERSION = 1 }; 79 | 80 | 81 | 82 | avstp_EXPORT (int) avstp_get_interface_version (); 83 | avstp_EXPORT (avstp_TaskDispatcher *) avstp_create_dispatcher (); 84 | avstp_EXPORT (void) avstp_destroy_dispatcher (avstp_TaskDispatcher *td_ptr); 85 | 86 | avstp_EXPORT (int) avstp_get_nbr_threads (); 87 | avstp_EXPORT (int) avstp_enqueue_task (avstp_TaskDispatcher *td_ptr, avstp_TaskPtr task_ptr, void *user_data_ptr); 88 | avstp_EXPORT (int) avstp_wait_completion (avstp_TaskDispatcher *td_ptr); 89 | 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | 97 | 98 | #endif // avstp_HEADER_INCLUDED 99 | 100 | 101 | 102 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 103 | -------------------------------------------------------------------------------- /src/avsutl/CsPlane.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | CsPlane.cpp 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if defined (_MSC_VER) 19 | #pragma warning (1 : 4130 4223 4705 4706) 20 | #pragma warning (4 : 4355 4786 4800) 21 | #endif 22 | 23 | 24 | 25 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 26 | 27 | #include "avsutl/CsPlane.h" 28 | #include "avisynth.h" 29 | 30 | #include 31 | 32 | 33 | 34 | namespace avsutl 35 | { 36 | 37 | 38 | 39 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 40 | 41 | 42 | 43 | constexpr int CsPlane::_max_nbr_planes; 44 | constexpr int CsPlane::_plane_index_alpha; 45 | 46 | 47 | 48 | CsPlane::CategCs CsPlane::get_cs_categ (const ::VideoInfo &vi) noexcept 49 | { 50 | return 51 | (vi.IsRGB () || vi.IsPlanarRGB () || vi.IsPlanarRGBA ()) 52 | ? CategCs_RGB 53 | : CategCs_YUV; 54 | } 55 | 56 | 57 | 58 | const CsPlane::CategInfo & CsPlane::use_categ_info (const ::VideoInfo &vi) noexcept 59 | { 60 | const CategCs categ = get_cs_categ (vi); 61 | 62 | return _plane_info_list [categ]; 63 | } 64 | 65 | 66 | 67 | const CsPlane::PlaneInfo & CsPlane::use_plane_info (int plane_index, const ::VideoInfo &vi) noexcept 68 | { 69 | assert (plane_index >= 0); 70 | assert (plane_index < _max_nbr_planes); 71 | assert (plane_index < vi.NumComponents ()); 72 | 73 | const auto & categ_info = use_categ_info (vi); 74 | 75 | return categ_info [plane_index]; 76 | } 77 | 78 | 79 | 80 | int CsPlane::get_plane_id (int plane_index, const ::VideoInfo &vi) noexcept 81 | { 82 | assert (plane_index >= 0); 83 | assert (plane_index < _max_nbr_planes); 84 | assert (plane_index < vi.NumComponents ()); 85 | 86 | const auto & plane_info = use_plane_info (plane_index, vi); 87 | 88 | return plane_info._id; 89 | } 90 | 91 | 92 | 93 | const std::array < 94 | CsPlane::CategInfo, 95 | CsPlane::CategCs_NBR_ELT 96 | > CsPlane::_plane_info_list = 97 | {{ 98 | {{ 99 | { ::PLANAR_Y, 'y' }, 100 | { ::PLANAR_U, 'u' }, 101 | { ::PLANAR_V, 'v' }, 102 | { ::PLANAR_A, 'a' } 103 | }}, 104 | {{ 105 | { ::PLANAR_R, 'r' }, 106 | { ::PLANAR_G, 'g' }, 107 | { ::PLANAR_B, 'b' }, 108 | { ::PLANAR_A, 'a' } 109 | }} 110 | }}; 111 | 112 | 113 | 114 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 115 | 116 | 117 | 118 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 119 | 120 | 121 | 122 | } // namespace avsutl 123 | 124 | 125 | 126 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 127 | -------------------------------------------------------------------------------- /src/avsutl/CsPlane.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | CsPlane.h 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (avsutl_CsPlane_HEADER_INCLUDED) 20 | #define avsutl_CsPlane_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include 27 | 28 | 29 | 30 | struct VideoInfo; 31 | 32 | namespace avsutl 33 | { 34 | 35 | 36 | 37 | class CsPlane 38 | { 39 | 40 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 41 | 42 | public: 43 | 44 | static constexpr int _max_nbr_planes = 4; 45 | static constexpr int _plane_index_alpha = 3; 46 | 47 | enum CategCs 48 | { 49 | CategCs_YUV = 0, 50 | CategCs_RGB, 51 | 52 | CategCs_NBR_ELT 53 | }; 54 | 55 | struct PlaneInfo 56 | { 57 | int _id; // PLANAR_? 58 | char _name; // Lower case 59 | }; 60 | 61 | typedef std::array CategInfo; 62 | 63 | static CategCs get_cs_categ (const ::VideoInfo &vi) noexcept; 64 | static const CategInfo & 65 | use_categ_info (const ::VideoInfo &vi) noexcept; 66 | static const PlaneInfo & 67 | use_plane_info (int plane_index, const ::VideoInfo &vi) noexcept; 68 | static int get_plane_id (int plane_index, const ::VideoInfo &vi) noexcept; 69 | 70 | static const std::array 71 | _plane_info_list; 72 | 73 | 74 | 75 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 76 | 77 | protected: 78 | 79 | 80 | 81 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 82 | 83 | private: 84 | 85 | 86 | 87 | 88 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 89 | 90 | private: 91 | 92 | CsPlane () = delete; 93 | CsPlane (const CsPlane &other) = delete; 94 | CsPlane (CsPlane &&other) = delete; 95 | CsPlane & operator = (const CsPlane &other) = delete; 96 | CsPlane & operator = (CsPlane &&other) = delete; 97 | bool operator == (const CsPlane &other) const = delete; 98 | bool operator != (const CsPlane &other) const = delete; 99 | 100 | }; // class CsPlane 101 | 102 | 103 | 104 | } // namespace avsutl 105 | 106 | 107 | 108 | //#include "avsutl/CsPlane.hpp" 109 | 110 | 111 | 112 | #endif // avsutl_CsPlane_HEADER_INCLUDED 113 | 114 | 115 | 116 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 117 | -------------------------------------------------------------------------------- /src/avsutl/PlaneProcCbInterface.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | PlaneProcCbInterface.h 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (avsutl_PlaneProcCbInterface_HEADER_INCLUDED) 20 | #define avsutl_PlaneProcCbInterface_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | 27 | 28 | class IScriptEnvironment; 29 | class PVideoFrame; 30 | 31 | namespace avsutl 32 | { 33 | 34 | 35 | 36 | class PlaneProcCbInterface 37 | { 38 | 39 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 40 | 41 | public: 42 | 43 | PlaneProcCbInterface () = default; 44 | virtual ~PlaneProcCbInterface () = default; 45 | 46 | void process_plane (::PVideoFrame &dst_sptr, int n, ::IScriptEnvironment &env, int plane_index, int plane_id, void *ctx_ptr); 47 | 48 | 49 | 50 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 51 | 52 | protected: 53 | 54 | virtual void do_process_plane (::PVideoFrame &dst_sptr, int n, ::IScriptEnvironment &env, int plane_index, int plane_id, void *ctx_ptr) = 0; 55 | 56 | 57 | 58 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 59 | 60 | private: 61 | 62 | PlaneProcCbInterface (const PlaneProcCbInterface &other) = delete; 63 | PlaneProcCbInterface (PlaneProcCbInterface &&other) = delete; 64 | PlaneProcCbInterface & 65 | operator = (const PlaneProcCbInterface &other) = delete; 66 | PlaneProcCbInterface & 67 | operator = (PlaneProcCbInterface &&other) = delete; 68 | 69 | }; // class PlaneProcCbInterface 70 | 71 | 72 | 73 | } // namespace avsutl 74 | 75 | 76 | 77 | //#include "avsutl/PlaneProcCbInterface.hpp" 78 | 79 | 80 | 81 | #endif // avsutl_PlaneProcCbInterface_HEADER_INCLUDED 82 | 83 | 84 | 85 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 86 | -------------------------------------------------------------------------------- /src/avsutl/PlaneProcCbInterface_avs.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | PlaneProcCbInterface.cpp 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if defined (_MSC_VER) 19 | #pragma warning (1 : 4130 4223 4705 4706) 20 | #pragma warning (4 : 4355 4786 4800) 21 | #endif 22 | 23 | 24 | 25 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 26 | 27 | #include "avsutl/PlaneProcCbInterface.h" 28 | #include "avisynth.h" 29 | 30 | #include 31 | 32 | 33 | 34 | namespace avsutl 35 | { 36 | 37 | 38 | 39 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 40 | 41 | 42 | 43 | void PlaneProcCbInterface::process_plane (::PVideoFrame &dst_sptr, int n, ::IScriptEnvironment &env, int plane_index, int plane_id, void *ctx_ptr) 44 | { 45 | assert (dst_sptr != nullptr); 46 | assert (n >= 0); 47 | assert (plane_index >= 0); 48 | 49 | do_process_plane (dst_sptr, n, env, plane_index, plane_id, ctx_ptr); 50 | } 51 | 52 | 53 | 54 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 55 | 56 | 57 | 58 | } // namespace avsutl 59 | 60 | 61 | 62 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 63 | -------------------------------------------------------------------------------- /src/avsutl/PlaneProcMode.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | PlaneProcMode.h 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (avsutl_PlaneProcMode_HEADER_INCLUDED) 20 | #define avsutl_PlaneProcMode_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | 27 | 28 | namespace avsutl 29 | { 30 | 31 | 32 | 33 | enum PlaneProcMode 34 | { 35 | PlaneProcMode_ILLEGAL = -999666 * 256, // Exact representation in float & int 36 | 37 | PlaneProcMode_FILL = 0, 38 | PlaneProcMode_GARBAGE, 39 | PlaneProcMode_COPY1, 40 | PlaneProcMode_PROCESS, 41 | PlaneProcMode_COPY2, 42 | PlaneProcMode_COPY3, 43 | 44 | PlaneProcMode_NBR_ELT, 45 | }; // enum PlaneProcMode 46 | 47 | 48 | 49 | } // namespace avsutl 50 | 51 | 52 | 53 | //#include "avsutl/PlaneProcMode.hpp" 54 | 55 | 56 | 57 | #endif // avsutl_PlaneProcMode_HEADER_INCLUDED 58 | 59 | 60 | 61 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 62 | -------------------------------------------------------------------------------- /src/avsutl/TFlag.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | TFlag.h 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (avsutl_TFlag_HEADER_INCLUDED) 20 | #define avsutl_TFlag_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | 27 | 28 | namespace avsutl 29 | { 30 | 31 | 32 | 33 | enum class TFlag 34 | { 35 | 36 | U = -1, // Undefined 37 | F = 0, // True 38 | T = 1 // False 39 | 40 | }; // enum TFlag 41 | 42 | 43 | 44 | } // namespace avsutl 45 | 46 | 47 | 48 | //#include "avsutl/TFlag.hpp" 49 | 50 | 51 | 52 | #endif // avsutl_TFlag_HEADER_INCLUDED 53 | 54 | 55 | 56 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 57 | -------------------------------------------------------------------------------- /src/avsutl/VideoFilterBase.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | VideoFilterBase.cpp 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if defined (_MSC_VER) 19 | #pragma warning (1 : 4130 4223 4705 4706) 20 | #pragma warning (4 : 4355 4786 4800) 21 | #endif 22 | 23 | 24 | 25 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 26 | 27 | #include "avsutl/VideoFilterBase.h" 28 | 29 | #include 30 | 31 | 32 | 33 | namespace avsutl 34 | { 35 | 36 | 37 | 38 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 39 | 40 | 41 | 42 | VideoFilterBase::VideoFilterBase (::IScriptEnvironment &env, ::PClip c) 43 | : Inherited (c) 44 | { 45 | try 46 | { 47 | env.CheckVersion (8); 48 | _prop_flag = true; 49 | } 50 | catch (const ::AvisynthError &) 51 | { 52 | _prop_flag = false; 53 | } 54 | } 55 | 56 | 57 | 58 | bool VideoFilterBase::supports_props () const noexcept 59 | { 60 | return _prop_flag; 61 | } 62 | 63 | 64 | 65 | ::PVideoFrame VideoFilterBase::build_new_frame (::IScriptEnvironment &env, const ::VideoInfo &vi_n, ::PVideoFrame *src_ptr, int align) 66 | { 67 | if (supports_props ()) 68 | { 69 | return env.NewVideoFrameP (vi_n, src_ptr, align); 70 | } 71 | else 72 | { 73 | return env.NewVideoFrame (vi_n, align); 74 | } 75 | } 76 | 77 | 78 | 79 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 80 | 81 | 82 | 83 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 84 | 85 | 86 | 87 | } // namespace avsutl 88 | 89 | 90 | 91 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 92 | -------------------------------------------------------------------------------- /src/avsutl/VideoFilterBase.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | VideoFilterBase.h 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (avsutl_VideoFilterBase_HEADER_INCLUDED) 20 | #define avsutl_VideoFilterBase_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "avisynth.h" 27 | 28 | 29 | 30 | namespace avsutl 31 | { 32 | 33 | 34 | 35 | class VideoFilterBase 36 | : public ::GenericVideoFilter 37 | { 38 | 39 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 40 | 41 | public: 42 | 43 | explicit VideoFilterBase (::IScriptEnvironment &env, ::PClip c); 44 | 45 | bool supports_props () const noexcept; 46 | ::PVideoFrame build_new_frame (::IScriptEnvironment &env, const ::VideoInfo &vi, ::PVideoFrame *src_ptr, int align = FRAME_ALIGN); 47 | 48 | 49 | 50 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 51 | 52 | protected: 53 | 54 | 55 | 56 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 57 | 58 | private: 59 | 60 | typedef ::GenericVideoFilter Inherited; 61 | 62 | bool _prop_flag = false; 63 | 64 | 65 | 66 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 67 | 68 | private: 69 | 70 | VideoFilterBase () = delete; 71 | VideoFilterBase (const VideoFilterBase &other) = delete; 72 | VideoFilterBase (VideoFilterBase &&other) = delete; 73 | VideoFilterBase & 74 | operator = (const VideoFilterBase &other) = delete; 75 | VideoFilterBase & 76 | operator = (VideoFilterBase &&other) = delete; 77 | bool operator == (const VideoFilterBase &other) const = delete; 78 | bool operator != (const VideoFilterBase &other) const = delete; 79 | 80 | }; // class VideoFilterBase 81 | 82 | 83 | 84 | } // namespace avsutl 85 | 86 | 87 | 88 | //#include "avsutl/VideoFilterBase.hpp" 89 | 90 | 91 | 92 | #endif // avsutl_VideoFilterBase_HEADER_INCLUDED 93 | 94 | 95 | 96 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 97 | -------------------------------------------------------------------------------- /src/avsutl/fnc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | fnc.h 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (avsutl_fnc_HEADER_INCLUDED) 20 | #define avsutl_fnc_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "avsutl/TFlag.h" 27 | 28 | 29 | 30 | class AVSValue; 31 | struct VideoInfo; 32 | 33 | namespace avsutl 34 | { 35 | 36 | 37 | 38 | TFlag set_tristate (const ::AVSValue &val); 39 | bool set_default (TFlag tristate, bool def_flag); 40 | bool has_alpha (const ::VideoInfo &vi); 41 | int get_nbr_comp_non_alpha (const ::VideoInfo &vi); 42 | bool is_rgb (const ::VideoInfo &vi); 43 | bool is_full_range_default (const ::VideoInfo &vi); 44 | 45 | template 46 | void fill_block (void *ptr, T val, int stride, int w, int h); 47 | 48 | 49 | 50 | } // namespace avsutl 51 | 52 | 53 | 54 | #include "avsutl/fnc.hpp" 55 | 56 | 57 | 58 | #endif // avsutl_fnc_HEADER_INCLUDED 59 | 60 | 61 | 62 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 63 | -------------------------------------------------------------------------------- /src/avsutl/fnc.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | fnc.hpp 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (avsutl_fnc_CODEHEADER_INCLUDED) 19 | #define avsutl_fnc_CODEHEADER_INCLUDED 20 | 21 | 22 | 23 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | 31 | 32 | namespace avsutl 33 | { 34 | 35 | 36 | 37 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 38 | 39 | 40 | 41 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 42 | 43 | 44 | 45 | // Stride in bytes, w and h in pixels 46 | template 47 | void fill_block (void *ptr, T val, int stride, int w, int h) 48 | { 49 | assert (ptr != nullptr); 50 | assert (stride > 0); 51 | assert (w > 0); 52 | assert (h > 0); 53 | 54 | constexpr int min_align = 16; 55 | 56 | if (sizeof (val) == 1 && stride >= 0 && stride - w < min_align) 57 | { 58 | auto u8_ptr = static_cast (ptr); 59 | std::fill (u8_ptr, u8_ptr + stride * (h - 1) + w, uint8_t (val)); 60 | } 61 | 62 | else 63 | { 64 | T * data_ptr = reinterpret_cast (ptr); 65 | const int stride_pix = stride / int (sizeof (val)); 66 | assert (stride_pix * int (sizeof (val)) == stride); 67 | for (int y = 0; y < h; ++y) 68 | { 69 | std::fill (data_ptr, data_ptr + w, val); 70 | data_ptr += stride_pix; 71 | } 72 | } 73 | } 74 | 75 | 76 | 77 | } // namespace avsutl 78 | 79 | 80 | 81 | #endif // avsutl_fnc_CODEHEADER_INCLUDED 82 | 83 | 84 | 85 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 86 | -------------------------------------------------------------------------------- /src/avsutl/fnc_avsutl.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | fnc_avsutl.cpp 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if defined (_MSC_VER) 19 | #pragma warning (1 : 4130 4223 4705 4706) 20 | #pragma warning (4 : 4355 4786 4800) 21 | #endif 22 | 23 | 24 | 25 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 26 | 27 | #include "avsutl/fnc.h" 28 | #include "avsutl/TFlag.h" 29 | #include "avisynth.h" 30 | 31 | #include 32 | 33 | 34 | 35 | namespace avsutl 36 | { 37 | 38 | 39 | 40 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 41 | 42 | 43 | 44 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 45 | 46 | 47 | 48 | TFlag set_tristate (const ::AVSValue &val) 49 | { 50 | assert (val.IsBool ()); 51 | 52 | return ( 53 | (! val.Defined ()) ? avsutl::TFlag::U 54 | : val.AsBool () ? avsutl::TFlag::T 55 | : avsutl::TFlag::F 56 | ); 57 | } 58 | 59 | 60 | 61 | bool set_default (TFlag tristate, bool def_flag) 62 | { 63 | return 64 | (tristate == avsutl::TFlag::T) ? 1 65 | : (tristate == avsutl::TFlag::F) ? 0 66 | : def_flag; 67 | } 68 | 69 | 70 | 71 | bool has_alpha (const ::VideoInfo &vi) 72 | { 73 | return ( 74 | vi.IsRGB32 () || vi.IsRGB64 () 75 | || vi.IsPlanarRGBA () || vi.IsYUVA () 76 | ); 77 | } 78 | 79 | 80 | 81 | int get_nbr_comp_non_alpha (const ::VideoInfo &vi) 82 | { 83 | const int nbr_alpha = has_alpha (vi) ? 1 : 0; 84 | const int nbr_comp = vi.NumComponents (); 85 | 86 | return nbr_comp - nbr_alpha; 87 | } 88 | 89 | 90 | bool is_rgb (const ::VideoInfo &vi) 91 | { 92 | return ( 93 | vi.IsRGB () || vi.IsRGB48 () || vi.IsRGB64 () 94 | || vi.IsPlanarRGB () || vi.IsPlanarRGBA () 95 | ); 96 | } 97 | 98 | 99 | 100 | bool is_full_range_default (const ::VideoInfo &vi) 101 | { 102 | return is_rgb (vi); 103 | } 104 | 105 | 106 | 107 | } // namespace avsutl 108 | 109 | 110 | 111 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 112 | -------------------------------------------------------------------------------- /src/chkdr/AvstpScopedDispatcher.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | AvstpScopedDispatcher.cpp 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | 19 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 20 | 21 | #include "chkdr/AvstpScopedDispatcher.h" 22 | #include "AvstpWrapper.h" 23 | 24 | #include 25 | 26 | 27 | 28 | namespace chkdr 29 | { 30 | 31 | 32 | 33 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 34 | 35 | 36 | 37 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 38 | 39 | 40 | 41 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 42 | 43 | 44 | 45 | AvstpScopedDispatcher::AvstpScopedDispatcher (AvstpWrapper &avstp) 46 | : _avstp (avstp) 47 | , _ptr (avstp.create_dispatcher ()) 48 | { 49 | // Nothing 50 | } 51 | 52 | 53 | 54 | AvstpScopedDispatcher::~AvstpScopedDispatcher () 55 | { 56 | _avstp.destroy_dispatcher (_ptr); 57 | } 58 | 59 | 60 | 61 | } // namespace chkdr 62 | 63 | 64 | 65 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 66 | -------------------------------------------------------------------------------- /src/chkdr/AvstpScopedDispatcher.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | AvstpScopedDispatcher.h 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (chkdr_AvstpScopedDispatcher_HEADER_INCLUDED) 20 | #define chkdr_AvstpScopedDispatcher_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "avstp.h" 27 | 28 | 29 | 30 | class AvstpWrapper; 31 | 32 | namespace chkdr 33 | { 34 | 35 | 36 | 37 | class AvstpScopedDispatcher 38 | { 39 | 40 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 41 | 42 | public: 43 | 44 | explicit AvstpScopedDispatcher (AvstpWrapper &avstp); 45 | ~AvstpScopedDispatcher (); 46 | 47 | AvstpWrapper & _avstp; 48 | avstp_TaskDispatcher * const 49 | _ptr; 50 | 51 | 52 | 53 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 54 | 55 | protected: 56 | 57 | 58 | 59 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 60 | 61 | private: 62 | 63 | 64 | 65 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 66 | 67 | private: 68 | 69 | AvstpScopedDispatcher () = delete; 70 | AvstpScopedDispatcher (const AvstpScopedDispatcher &other) = delete; 71 | AvstpScopedDispatcher (AvstpScopedDispatcher &&other) = delete; 72 | AvstpScopedDispatcher & 73 | operator = (const AvstpScopedDispatcher &other) = delete; 74 | AvstpScopedDispatcher & 75 | operator = (AvstpScopedDispatcher &&other) = delete; 76 | bool operator == (const AvstpScopedDispatcher &other) const = delete; 77 | bool operator != (const AvstpScopedDispatcher &other) const = delete; 78 | 79 | }; // class AvstpScopedDispatcher 80 | 81 | 82 | 83 | } // namespace chkdr 84 | 85 | 86 | 87 | //#include "chkdr/AvstpScopedDispatcher.hpp" 88 | 89 | 90 | 91 | #endif // chkdr_AvstpScopedDispatcher_HEADER_INCLUDED 92 | 93 | 94 | 95 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 96 | -------------------------------------------------------------------------------- /src/chkdr/CpuOptBase.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | CpuOptBase.cpp 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if defined (_MSC_VER) 19 | #pragma warning (1 : 4130 4223 4705 4706) 20 | #pragma warning (4 : 4355 4786 4800) 21 | #endif 22 | 23 | 24 | 25 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 26 | 27 | #include "chkdr/CpuOptBase.h" 28 | 29 | #include 30 | 31 | 32 | 33 | namespace chkdr 34 | { 35 | 36 | 37 | 38 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 39 | 40 | 41 | 42 | void CpuOptBase::set_level (Level level) 43 | { 44 | assert (level >= 0); 45 | assert (level <= Level_ANY_AVAILABLE); 46 | 47 | _level = level; 48 | } 49 | 50 | 51 | 52 | bool CpuOptBase::has_mmx () const 53 | { 54 | return (_cpu._mmx_flag && _level >= Level_SSE2); 55 | } 56 | 57 | 58 | 59 | bool CpuOptBase::has_isse () const 60 | { 61 | return (_cpu._isse_flag && _level >= Level_SSE2); 62 | } 63 | 64 | 65 | 66 | bool CpuOptBase::has_sse () const 67 | { 68 | return (_cpu._sse_flag && _level >= Level_SSE2); 69 | } 70 | 71 | 72 | 73 | bool CpuOptBase::has_sse2 () const 74 | { 75 | return (_cpu._sse2_flag && _level >= Level_SSE2); 76 | } 77 | 78 | 79 | 80 | bool CpuOptBase::has_sse3 () const 81 | { 82 | return (_cpu._sse3_flag && _level >= Level_SSE3); 83 | } 84 | 85 | 86 | 87 | bool CpuOptBase::has_ssse3 () const 88 | { 89 | return (_cpu._ssse3_flag && _level >= Level_SSSE3); 90 | } 91 | 92 | 93 | 94 | bool CpuOptBase::has_sse41 () const 95 | { 96 | return (_cpu._sse41_flag && _level >= Level_SSE41); 97 | } 98 | 99 | 100 | 101 | bool CpuOptBase::has_sse42 () const 102 | { 103 | return (_cpu._sse42_flag && _level >= Level_SSE42); 104 | } 105 | 106 | 107 | 108 | bool CpuOptBase::has_sse4a () const 109 | { 110 | return (_cpu._sse4a_flag && _level >= Level_FMA4); 111 | } 112 | 113 | 114 | 115 | bool CpuOptBase::has_fma3 () const 116 | { 117 | return (_cpu._fma3_flag && _level >= Level_FMA3); 118 | } 119 | 120 | 121 | 122 | bool CpuOptBase::has_fma4 () const 123 | { 124 | return (_cpu._fma4_flag && _level >= Level_FMA4); 125 | } 126 | 127 | 128 | 129 | bool CpuOptBase::has_avx () const 130 | { 131 | return (_cpu._avx_flag && _level >= Level_AVX); 132 | } 133 | 134 | 135 | 136 | bool CpuOptBase::has_avx2 () const 137 | { 138 | return (_cpu._avx2_flag && _level >= Level_AVX2); 139 | } 140 | 141 | 142 | 143 | bool CpuOptBase::has_avx512f () const 144 | { 145 | return (_cpu._avx512f_flag && _level >= Level_AVX512F); 146 | } 147 | 148 | 149 | 150 | bool CpuOptBase::has_f16c () const 151 | { 152 | return (_cpu._f16c_flag && _level >= Level_F16C); 153 | } 154 | 155 | 156 | 157 | bool CpuOptBase::has_cx16 () const 158 | { 159 | return _cpu._cx16_flag; 160 | } 161 | 162 | 163 | 164 | const fstb::CpuId & CpuOptBase::use_raw_cpuid () const 165 | { 166 | return _cpu; 167 | } 168 | 169 | 170 | 171 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 172 | 173 | 174 | 175 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 176 | 177 | 178 | 179 | } // namespace chkdr 180 | 181 | 182 | 183 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 184 | -------------------------------------------------------------------------------- /src/chkdr/CpuOptBase.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | CpuOptBase.h 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (chkdr_CpuOptBase_HEADER_INCLUDED) 20 | #define chkdr_CpuOptBase_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "fstb/CpuId.h" 27 | 28 | 29 | 30 | namespace chkdr 31 | { 32 | 33 | 34 | 35 | class CpuOptBase 36 | { 37 | 38 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 39 | 40 | public: 41 | 42 | enum Level 43 | { 44 | Level_NO_OPT = 0, 45 | Level_SSE2, // 1 46 | Level_SSE3, 47 | Level_SSSE3, 48 | Level_SSE41, 49 | Level_SSE42, 50 | Level_FMA4, 51 | Level_AVX, // 7 52 | Level_FMA3, 53 | Level_F16C, 54 | Level_AVX2, // 10 55 | Level_AVX512F, 56 | 57 | Level_MASK = 0xFFFF, 58 | Level_ANY_AVAILABLE = Level_MASK 59 | }; 60 | 61 | CpuOptBase () = default; 62 | virtual ~CpuOptBase () = default; 63 | CpuOptBase (const CpuOptBase &other) = default; 64 | CpuOptBase (CpuOptBase &&other) = default; 65 | CpuOptBase & operator = (const CpuOptBase &other) = default; 66 | CpuOptBase & operator = (CpuOptBase &&other) = default; 67 | 68 | void set_level (Level level); 69 | 70 | bool has_mmx () const; 71 | bool has_isse () const; 72 | bool has_sse () const; 73 | bool has_sse2 () const; 74 | bool has_sse3 () const; 75 | bool has_ssse3 () const; 76 | bool has_sse41 () const; 77 | bool has_sse42 () const; 78 | bool has_sse4a () const; 79 | bool has_fma3 () const; 80 | bool has_fma4 () const; 81 | bool has_avx () const; 82 | bool has_avx2 () const; 83 | bool has_avx512f () const; 84 | bool has_f16c () const; 85 | bool has_cx16 () const; 86 | 87 | const fstb::CpuId & 88 | use_raw_cpuid () const; 89 | 90 | 91 | 92 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 93 | 94 | protected: 95 | 96 | 97 | 98 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 99 | 100 | private: 101 | 102 | fstb::CpuId _cpu; 103 | Level _level = Level_ANY_AVAILABLE; 104 | 105 | 106 | 107 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 108 | 109 | private: 110 | 111 | bool operator == (const CpuOptBase &other) const = delete; 112 | bool operator != (const CpuOptBase &other) const = delete; 113 | 114 | }; // class CpuOptBase 115 | 116 | 117 | 118 | } // namespace chkdr 119 | 120 | 121 | 122 | //#include "chkdr/CpuOptBase.hpp" 123 | 124 | 125 | 126 | #endif // chkdr_CpuOptBase_HEADER_INCLUDED 127 | 128 | 129 | 130 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 131 | -------------------------------------------------------------------------------- /src/chkdr/GrainProc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | GrainProc.h 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (chkdr_GrainProc_HEADER_INCLUDED) 20 | #define chkdr_GrainProc_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "chkdr/AvstpScopedDispatcher.h" 27 | #include "fgrn/GenGrain.h" 28 | #include "fgrn/VisionFilter.h" 29 | #include "avstp.h" 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | 37 | class AvstpWrapper; 38 | 39 | namespace chkdr 40 | { 41 | 42 | 43 | 44 | class GrainProc 45 | { 46 | 47 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 48 | 49 | public: 50 | 51 | explicit GrainProc (float sigma, int res, float rad, float dev, uint32_t seed, bool cf_flag, bool cp_flag, bool draft_flag, bool simd4_flag, bool avx_flag); 52 | virtual ~GrainProc () {} 53 | 54 | void process_plane (uint8_t *dst_ptr, ptrdiff_t dst_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, int w, int h, int frame_idx, int plane_idx); 55 | 56 | static bool check_sigma (float sigma) noexcept; 57 | static bool check_res (int res) noexcept; 58 | static bool check_rad (float rad) noexcept; 59 | static bool check_dev (float dev) noexcept; 60 | 61 | 62 | 63 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 64 | 65 | protected: 66 | 67 | 68 | 69 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 70 | 71 | private: 72 | 73 | class TaskInfo 74 | { 75 | public: 76 | fgrn::GenGrain * 77 | _gen_ptr = nullptr; 78 | int _pass = 0; // 1 or 2 79 | int _tid = 0; // Task identifier 80 | }; 81 | 82 | class FrameProc 83 | { 84 | public: 85 | explicit FrameProc (bool simd4_flag, bool avx_flag); 86 | fgrn::GenGrain _generator; 87 | std::vector 88 | _task_list; 89 | }; 90 | 91 | typedef std::shared_ptr ProcSPtr; 92 | 93 | static void redirect_task (avstp_TaskDispatcher *dispatcher_ptr, void *data_ptr); 94 | 95 | bool _simd4_flag = false; 96 | bool _avx_flag = false; 97 | 98 | fgrn::VisionFilter 99 | _filter; 100 | 101 | uint32_t _seed_base = 12345; 102 | bool _cf_flag = false; // Constant seed for all frames 103 | bool _cp_flag = false; // Constant seed for all planes of a frame 104 | bool _draft_flag = false; 105 | 106 | AvstpWrapper & _avstp; 107 | 108 | // Mutex to lock before accessing the processor pool 109 | std::mutex _mtx_pool; 110 | std::vector 111 | _proc_pool; 112 | 113 | 114 | 115 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 116 | 117 | private: 118 | 119 | GrainProc () = delete; 120 | GrainProc (const GrainProc &other) = delete; 121 | GrainProc (GrainProc &&other) = delete; 122 | GrainProc & operator = (const GrainProc &other) = delete; 123 | GrainProc & operator = (GrainProc &&other) = delete; 124 | bool operator == (const GrainProc &other) const = delete; 125 | bool operator != (const GrainProc &other) const = delete; 126 | 127 | }; // class GrainProc 128 | 129 | 130 | 131 | } // namespace chkdr 132 | 133 | 134 | 135 | //#include "chkdr/GrainProc.hpp" 136 | 137 | 138 | 139 | #endif // chkdr_GrainProc_HEADER_INCLUDED 140 | 141 | 142 | 143 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 144 | -------------------------------------------------------------------------------- /src/chkdravs/Grain.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Grain.h 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (chkdravs_Grain_HEADER_INCLUDED) 20 | #define chkdravs_Grain_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "avsutl/PlaneProcCbInterface.h" 27 | #include "avsutl/PlaneProcessor.h" 28 | #include "avsutl/VideoFilterBase.h" 29 | #include "chkdr/CpuOptBase.h" 30 | #include "chkdr/GrainProc.h" 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | 37 | 38 | namespace chkdravs 39 | { 40 | 41 | 42 | 43 | class Grain 44 | : public avsutl::VideoFilterBase 45 | , public avsutl::PlaneProcCbInterface 46 | { 47 | 48 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 49 | 50 | public: 51 | 52 | typedef avsutl::VideoFilterBase Inherited; 53 | 54 | enum Param 55 | { 56 | Param_CLIP_SRC = 0, // 0 57 | Param_SIGMA, 58 | Param_RES, 59 | Param_RAD, 60 | Param_DEV, 61 | Param_SEED, 62 | Param_CF, 63 | Param_CP, 64 | Param_DRAFT, 65 | Param_CPUOPT, 66 | 67 | Param_NBR_ELT, 68 | }; 69 | 70 | explicit Grain (::IScriptEnvironment &env, const ::AVSValue &args); 71 | virtual ~Grain () = default; 72 | 73 | // VideoFilterBase 74 | ::PVideoFrame __stdcall 75 | GetFrame (int n, ::IScriptEnvironment *env_ptr) override; 76 | 77 | 78 | 79 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 80 | 81 | protected: 82 | 83 | // PlaneProcCbInterface 84 | void do_process_plane (::PVideoFrame &dst_sptr, int n, ::IScriptEnvironment &env, int plane_index, int plane_id, void *ctx_ptr) override; 85 | 86 | 87 | 88 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 89 | 90 | private: 91 | 92 | class CpuOpt : public chkdr::CpuOptBase 93 | { 94 | public: 95 | explicit CpuOpt (const ::AVSValue &arg); 96 | }; 97 | 98 | ::PClip _clip_src_sptr; 99 | const ::VideoInfo 100 | _vi_src; 101 | 102 | std::unique_ptr 103 | _plane_proc_uptr; 104 | 105 | std::unique_ptr 106 | _proc_uptr; 107 | 108 | 109 | 110 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 111 | 112 | private: 113 | 114 | Grain () = delete; 115 | Grain (const Grain &other) = delete; 116 | Grain (Grain &&other) = delete; 117 | Grain & operator = (const Grain &other) = delete; 118 | Grain & operator = (Grain &&other) = delete; 119 | bool operator == (const Grain &other) const = delete; 120 | bool operator != (const Grain &other) const = delete; 121 | 122 | }; // class Grain 123 | 124 | 125 | 126 | } // namespace chkdravs 127 | 128 | 129 | 130 | //#include "chkdravs/Grain.hpp" 131 | 132 | 133 | 134 | #endif // chkdravs_Grain_HEADER_INCLUDED 135 | 136 | 137 | 138 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 139 | -------------------------------------------------------------------------------- /src/chkdravs/function_names.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | function_names.h 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (chkdravs_function_names_HEADER_INCLUDED) 20 | #define chkdravs_function_names_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | 27 | 28 | namespace chkdravs 29 | { 30 | 31 | 32 | 33 | #define chkdravs_NAMESPACE "chkdr" 34 | 35 | #define chkdravs_BUILD_NAME(x) chkdravs_NAMESPACE "_" x 36 | 37 | #define chkdravs_GRAIN chkdravs_BUILD_NAME ("grain") 38 | 39 | 40 | 41 | } // namespace chkdravs 42 | 43 | 44 | 45 | //#include "chkdravs/function_names.hpp" 46 | 47 | 48 | 49 | #endif // chkdravs_function_names_HEADER_INCLUDED 50 | 51 | 52 | 53 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 54 | -------------------------------------------------------------------------------- /src/chkdrvs/Grain.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Grain.h 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (chkdrvs_Grain_HEADER_INCLUDED) 20 | #define chkdrvs_Grain_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "chkdr/GrainProc.h" 27 | #include "chkdr/CpuOptBase.h" 28 | #include "vsutl/FilterBase.h" 29 | #include "vsutl/NodeRefSPtr.h" 30 | #include "vsutl/PlaneProcCbInterface.h" 31 | #include "vsutl/PlaneProcessor.h" 32 | #include "VapourSynth4.h" 33 | #include "avstp.h" 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | 40 | 41 | namespace chkdrvs 42 | { 43 | 44 | 45 | 46 | class Grain 47 | : public vsutl::FilterBase 48 | , public vsutl::PlaneProcCbInterface 49 | { 50 | 51 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 52 | 53 | public: 54 | 55 | typedef Grain ThisType; 56 | 57 | explicit Grain (const ::VSMap &in, ::VSMap &out, void *user_data_ptr, ::VSCore &core, const ::VSAPI &vsapi); 58 | virtual ~Grain () {} 59 | 60 | // vsutl::FilterBase 61 | virtual ::VSVideoInfo 62 | get_video_info () const; 63 | virtual std::vector <::VSFilterDependency> 64 | get_dependencies () const; 65 | virtual const ::VSFrame * 66 | get_frame (int n, int activation_reason, void * &frame_data_ptr, ::VSFrameContext &frame_ctx, ::VSCore &core); 67 | 68 | 69 | 70 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 71 | 72 | protected: 73 | 74 | // vsutl::PlaneProcCbInterface 75 | virtual int do_process_plane (::VSFrame &dst, int n, int plane_index, void *frame_data_ptr, ::VSFrameContext &frame_ctx, ::VSCore &core, const vsutl::NodeRefSPtr &src_node1_sptr, const vsutl::NodeRefSPtr &src_node2_sptr, const vsutl::NodeRefSPtr &src_node3_sptr); 76 | 77 | 78 | 79 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 80 | 81 | private: 82 | 83 | class CpuOpt : public chkdr::CpuOptBase 84 | { 85 | public: 86 | explicit CpuOpt (vsutl::FilterBase &filter, const ::VSMap &in, ::VSMap &out, const char *param_name_0 = "cpuopt"); 87 | }; 88 | 89 | vsutl::NodeRefSPtr 90 | _clip_src_sptr; 91 | const ::VSVideoInfo 92 | _vi_in; // Input. Must be declared after _clip_src_sptr because of initialisation order. 93 | ::VSVideoInfo _vi_out; // Output. Must be declared after _vi_in. 94 | 95 | vsutl::PlaneProcessor 96 | _plane_processor; 97 | 98 | std::unique_ptr 99 | _proc_uptr; 100 | 101 | 102 | 103 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 104 | 105 | private: 106 | 107 | Grain () = delete; 108 | Grain (const Grain &other) = delete; 109 | Grain (Grain &&other) = delete; 110 | Grain & operator = (const Grain &other) = delete; 111 | Grain & operator = (Grain &&other) = delete; 112 | bool operator == (const Grain &other) const = delete; 113 | bool operator != (const Grain &other) const = delete; 114 | 115 | }; // class Grain 116 | 117 | 118 | 119 | } // namespace chkdrvs 120 | 121 | 122 | 123 | //#include "chkdrvs/Grain.hpp" 124 | 125 | 126 | 127 | #endif // chkdrvs_Grain_HEADER_INCLUDED 128 | 129 | 130 | 131 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 132 | -------------------------------------------------------------------------------- /src/chkdrvs/version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define chkdrvs_VERSION 2 4 | #define chkdrvs_PLUGIN_NAME "ChickenDream" 5 | #define chkdrvs_NAMESPACE "chkdr" 6 | -------------------------------------------------------------------------------- /src/fgrn/Cell.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Cell.h 4 | Author: Laurent de Soras, 2022 5 | 6 | List of grains for a single source pixel 7 | 1 cell covers 1 source pixel 8 | 9 | --- Legal stuff --- 10 | 11 | This program is free software. It comes without any warranty, to 12 | the extent permitted by applicable law. You can redistribute it 13 | and/or modify it under the terms of the Do What The Fuck You Want 14 | To Public License, Version 2, as published by Sam Hocevar. See 15 | http://sam.zoy.org/wtfpl/COPYING for more details. 16 | 17 | *Tab=3***********************************************************************/ 18 | 19 | 20 | 21 | #pragma once 22 | #if ! defined (fgrn_Cell_HEADER_INCLUDED) 23 | #define fgrn_Cell_HEADER_INCLUDED 24 | 25 | 26 | 27 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 28 | 29 | #include "fgrn/PointList.h" 30 | #include "fstb/def.h" 31 | 32 | 33 | 34 | namespace fgrn 35 | { 36 | 37 | 38 | 39 | class Cell 40 | { 41 | 42 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 43 | 44 | public: 45 | 46 | typedef PointList::VectF32Align VectF32Align; 47 | 48 | inline void resize (int sz); 49 | fstb_FORCEINLINE bool 50 | check_intersect_fpu (float tx, float ty) const noexcept; 51 | fstb_FORCEINLINE bool 52 | check_intersect_simd4 (float tx, float ty) const noexcept; 53 | #if fstb_ARCHI == fstb_ARCHI_X86 54 | fstb_FORCEINLINE bool 55 | check_intersect_avx (float tx, float ty) const noexcept; 56 | #endif 57 | 58 | // Grain coordinates in pixels, relative to the pixel origin (its center) 59 | PointList _centers; 60 | 61 | // Corresponding squared grain radii, in pixels^2 62 | VectF32Align _r2_arr; 63 | 64 | 65 | 66 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 67 | 68 | protected: 69 | 70 | 71 | 72 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 73 | 74 | private: 75 | 76 | fstb_FORCEINLINE static bool 77 | check_intersect_fpu (float tx, float ty, int nbr_grains, const float * fstb_RESTRICT cx_ptr, const float * fstb_RESTRICT cy_ptr, const float * fstb_RESTRICT r2_ptr) noexcept; 78 | fstb_FORCEINLINE static bool 79 | check_intersect_simd4 (float tx, float ty, int nbr_grains, const float * fstb_RESTRICT cx_ptr, const float * fstb_RESTRICT cy_ptr, const float * fstb_RESTRICT r2_ptr) noexcept; 80 | #if fstb_ARCHI == fstb_ARCHI_X86 81 | fstb_FORCEINLINE static bool 82 | check_intersect_avx (float tx, float ty, int nbr_grains, const float * fstb_RESTRICT cx_ptr, const float * fstb_RESTRICT cy_ptr, const float * fstb_RESTRICT r2_ptr) noexcept; 83 | #endif 84 | 85 | 86 | 87 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 88 | 89 | private: 90 | 91 | bool operator == (const Cell &other) const = delete; 92 | bool operator != (const Cell &other) const = delete; 93 | 94 | }; // class Cell 95 | 96 | 97 | 98 | } // namespace fgrn 99 | 100 | 101 | 102 | #include "fgrn/Cell.hpp" 103 | 104 | 105 | 106 | #endif // fgrn_Cell_HEADER_INCLUDED 107 | 108 | 109 | 110 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 111 | -------------------------------------------------------------------------------- /src/fgrn/CellCache.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | CellCache.cpp 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | 19 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 20 | 21 | #include "fgrn/CellCache.h" 22 | #include "fgrn/GenGrain.h" 23 | 24 | #include 25 | 26 | #include 27 | 28 | 29 | 30 | namespace fgrn 31 | { 32 | 33 | 34 | 35 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 36 | 37 | 38 | 39 | void CellCache::reset (int w, int h) 40 | { 41 | assert (w > 0); 42 | assert (h > 0); 43 | 44 | _w = w; 45 | _h = h; 46 | _tl_x = 0; 47 | _tl_y = 0; 48 | _tl_x_pos = 0; 49 | _tl_y_pos = 0; 50 | _storage.resize (_w * _h); 51 | for (auto &ce : _storage) 52 | { 53 | ce._cached_flag = false; 54 | } 55 | } 56 | 57 | 58 | 59 | const Cell & CellCache::use_cell (int px, int py, GenGrain &cell_provider) 60 | { 61 | assert (_w > 0); 62 | assert (_h > 0); 63 | assert (px >= 0); 64 | assert (py >= 0); 65 | 66 | // Position out of the cache? 67 | if ( px < _tl_x || px >= _tl_x + _w 68 | || py < _tl_y || py >= _tl_y + _h) 69 | { 70 | // No cell can be kept: we clear everything 71 | if ( px < _tl_x - (_w - 1) || px >= _tl_x + 2 * _w - 1 72 | || py < _tl_y - (_h - 1) || py >= _tl_y + 2 * _h - 1) 73 | { 74 | for (auto &entry : _storage) 75 | { 76 | entry._cached_flag = false; 77 | } 78 | _tl_x = px; 79 | _tl_y = py; 80 | _tl_x_pos = 0; 81 | _tl_y_pos = 0; 82 | } 83 | 84 | // Moves the cache until we reach the requested cell 85 | else 86 | { 87 | while (px < _tl_x) 88 | { 89 | move_h (-1); 90 | } 91 | while (px >= _tl_x + _w) 92 | { 93 | move_h (+1); 94 | } 95 | while (py < _tl_y) 96 | { 97 | move_v (-1); 98 | } 99 | while (py >= _tl_y + _h) 100 | { 101 | move_v (+1); 102 | } 103 | } 104 | } 105 | assert (px >= _tl_x && px < _tl_x + _w && py >= _tl_y && py < _tl_y + _h); 106 | 107 | // Finds the cell within the cache 108 | auto c_x = px - _tl_x + _tl_x_pos; 109 | if (c_x >= _w) 110 | { 111 | c_x -= _w; 112 | } 113 | auto c_y = py - _tl_y + _tl_y_pos; 114 | if (c_y >= _h) 115 | { 116 | c_y -= _h; 117 | } 118 | const auto c_pos = c_y * _w + c_x; 119 | auto & entry = _storage [c_pos]; 120 | if (! entry._cached_flag) 121 | { 122 | cell_provider.build_cell (entry._cell, px, py); 123 | entry._cached_flag = true; 124 | } 125 | 126 | return entry._cell; 127 | } 128 | 129 | 130 | 131 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 132 | 133 | 134 | 135 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 136 | 137 | 138 | 139 | void CellCache::move_h (int d) noexcept 140 | { 141 | invalidate_col ((_tl_x_pos + std::min (d, 0) + _w) % _w); 142 | _tl_x += d; 143 | _tl_x_pos = (_tl_x_pos + d + _w) % _w; 144 | } 145 | 146 | 147 | 148 | void CellCache::move_v (int d) noexcept 149 | { 150 | invalidate_row ((_tl_y_pos + std::min (d, 0) + _h) % _h); 151 | _tl_y += d; 152 | _tl_y_pos = (_tl_y_pos + d + _h) % _h; 153 | } 154 | 155 | 156 | 157 | void CellCache::invalidate_col (int c_x) noexcept 158 | { 159 | for (int k = 0; k < _h; ++k) 160 | { 161 | _storage [k * _w + c_x]._cached_flag = false; 162 | } 163 | } 164 | 165 | 166 | 167 | void CellCache::invalidate_row (int c_y) noexcept 168 | { 169 | for (int k = 0; k < _w; ++k) 170 | { 171 | _storage [c_y * _w + k]._cached_flag = false; 172 | } 173 | } 174 | 175 | 176 | 177 | } // namespace fgrn 178 | 179 | 180 | 181 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 182 | -------------------------------------------------------------------------------- /src/fgrn/CellCache.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | CellCache.h 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (fgrn_CellCache_HEADER_INCLUDED) 20 | #define fgrn_CellCache_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "fgrn/Cell.h" 27 | 28 | #include 29 | 30 | 31 | 32 | namespace fgrn 33 | { 34 | 35 | 36 | 37 | class GenGrain; 38 | 39 | class CellCache 40 | { 41 | 42 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 43 | 44 | public: 45 | 46 | void reset (int w, int h); 47 | const Cell & use_cell (int px, int py, GenGrain &cell_provider); 48 | 49 | 50 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 51 | 52 | protected: 53 | 54 | 55 | 56 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 57 | 58 | private: 59 | 60 | class CellEntry 61 | { 62 | public: 63 | bool _cached_flag = false; 64 | Cell _cell; 65 | }; 66 | 67 | inline void move_h (int d) noexcept; 68 | inline void move_v (int d) noexcept; 69 | inline void invalidate_col (int c_x) noexcept; 70 | inline void invalidate_row (int c_y) noexcept; 71 | 72 | // Cache size. 73 | // Minimum size: vision filter width * height 74 | // 0 = not initialised. 75 | int _w = 0; 76 | int _h = 0; 77 | 78 | // The cache is a circular buffer of lines, which are circular buffers 79 | // too. 80 | // Lines are stored contiguously (stride = _w). 81 | std::vector 82 | _storage; 83 | 84 | // Position of the cache top-left element in the picture 85 | int _tl_x = 0; 86 | int _tl_y = 0; 87 | 88 | // Position of the cache top-left element in the circular buffer 89 | int _tl_x_pos = 0; 90 | int _tl_y_pos = 0; 91 | 92 | 93 | 94 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 95 | 96 | private: 97 | 98 | bool operator == (const CellCache &other) const = delete; 99 | bool operator != (const CellCache &other) const = delete; 100 | 101 | }; // class CellCache 102 | 103 | 104 | 105 | } // namespace fgrn 106 | 107 | 108 | 109 | //#include "fgrn/CellCache.hpp" 110 | 111 | 112 | 113 | #endif // fgrn_CellCache_HEADER_INCLUDED 114 | 115 | 116 | 117 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 118 | -------------------------------------------------------------------------------- /src/fgrn/GenGrain.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | GenGrain.hpp 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (fgrn_GenGrain_CODEHEADER_INCLUDED) 19 | #define fgrn_GenGrain_CODEHEADER_INCLUDED 20 | 21 | 22 | 23 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 24 | 25 | #include "fgrn/VisionFilter.h" 26 | 27 | #include 28 | 29 | 30 | 31 | namespace fgrn 32 | { 33 | 34 | 35 | 36 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 37 | 38 | 39 | 40 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 41 | 42 | 43 | 44 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 45 | 46 | 47 | 48 | template 49 | void GenGrain::render_part (Context &ctx, F check_inter) 50 | { 51 | for (int y = ctx._y_beg; y < ctx._y_end; ++y) 52 | { 53 | for (int x = 0; x < _pic_w; ++x) 54 | { 55 | const auto v = render_pixel (ctx, x, y, check_inter); 56 | _dst_ptr [y * _dst_stride + x] = v; 57 | } 58 | } 59 | } 60 | 61 | 62 | 63 | template 64 | float GenGrain::render_pixel (Context &ctx, int px, int py, F check_inter) 65 | { 66 | assert (px >= 0); 67 | assert (py < _pic_w); 68 | assert (px >= 0); 69 | assert (py < _pic_h); 70 | 71 | int lum = 0; 72 | 73 | // Iterates on the groups 74 | const auto & fmap = _filter_ptr->use_map (); 75 | for (auto &f_p : fmap) 76 | { 77 | const auto & cell_list = f_p.first; 78 | const auto & point_list = f_p.second; 79 | 80 | // Test each point of the group 81 | const auto nbr_points = point_list.get_size (); 82 | for (int p_cnt = 0; p_cnt < nbr_points; ++p_cnt) 83 | { 84 | const auto fx = point_list._x_arr [p_cnt]; 85 | const auto fy = point_list._y_arr [p_cnt]; 86 | 87 | // Check all the cells containing grains that could intersect with 88 | // the given filter point. 89 | for (const auto &cell_coord : cell_list) 90 | { 91 | // cx_r, cy_r are cell center coordinates relative to the filter 92 | // center. 93 | const auto cx_r = cell_coord [0]; 94 | const auto cy_r = cell_coord [1]; 95 | const auto cx = fstb::limit (px + cx_r, 0, _pic_w - 1); 96 | const auto cy = fstb::limit (py + cy_r, 0, _pic_h - 1); 97 | const auto & cell = use_cell (ctx, cx, cy); 98 | // tst_x and tst_y are the point coordinates relative to the 99 | // current cell center. 100 | const auto tst_x = fx - float (cx_r); 101 | const auto tst_y = fy - float (cy_r); 102 | if (check_inter (cell, tst_x, tst_y)) 103 | { 104 | ++ lum; 105 | break; // Escapes to the loop over filter points 106 | } 107 | } 108 | } 109 | } 110 | 111 | return float (lum) * _out_scale; 112 | } 113 | 114 | 115 | 116 | } // namespace fgrn 117 | 118 | 119 | 120 | #endif // fgrn_GenGrain_CODEHEADER_INCLUDED 121 | 122 | 123 | 124 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 125 | -------------------------------------------------------------------------------- /src/fgrn/GenGrain_avx.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | GenGrain.cpp 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | 19 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 20 | 21 | #include "fgrn/GenGrain.h" 22 | 23 | #include 24 | 25 | 26 | 27 | namespace fgrn 28 | { 29 | 30 | 31 | 32 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 33 | 34 | 35 | 36 | void GenGrain::render_part_avx (Context &ctx) 37 | { 38 | render_part (ctx, 39 | [] (const Cell &cell, float px, float py) 40 | { 41 | return cell.check_intersect_avx (px, py); 42 | } 43 | ); 44 | } 45 | 46 | 47 | 48 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 49 | 50 | 51 | 52 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 53 | 54 | 55 | 56 | } // namespace fgrn 57 | 58 | 59 | 60 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 61 | -------------------------------------------------------------------------------- /src/fgrn/PointList.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | PointList.h 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (fgrn_PointList_HEADER_INCLUDED) 20 | #define fgrn_PointList_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "fstb/def.h" 27 | #include "fstb/VecAlign.h" 28 | 29 | 30 | 31 | namespace fgrn 32 | { 33 | 34 | 35 | 36 | class PointList 37 | { 38 | 39 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 40 | 41 | public: 42 | 43 | typedef fstb::VecAlign VectF32Align; 44 | 45 | fstb_FORCEINLINE int 46 | get_size () const noexcept; 47 | 48 | VectF32Align _x_arr; 49 | VectF32Align _y_arr; 50 | 51 | 52 | 53 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 54 | 55 | protected: 56 | 57 | 58 | 59 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 60 | 61 | private: 62 | 63 | 64 | 65 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 66 | 67 | private: 68 | 69 | bool operator == (const PointList &other) const = delete; 70 | bool operator != (const PointList &other) const = delete; 71 | 72 | }; // class PointList 73 | 74 | 75 | 76 | } // namespace fgrn 77 | 78 | 79 | 80 | #include "fgrn/PointList.hpp" 81 | 82 | 83 | 84 | #endif // fgrn_PointList_HEADER_INCLUDED 85 | 86 | 87 | 88 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 89 | -------------------------------------------------------------------------------- /src/fgrn/PointList.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | PointList.hpp 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (fgrn_PointList_CODEHEADER_INCLUDED) 19 | #define fgrn_PointList_CODEHEADER_INCLUDED 20 | 21 | 22 | 23 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 24 | 25 | #include 26 | 27 | 28 | 29 | namespace fgrn 30 | { 31 | 32 | 33 | 34 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 35 | 36 | 37 | 38 | int PointList::get_size () const noexcept 39 | { 40 | assert (_x_arr.size () == _y_arr.size ()); 41 | 42 | return int (_x_arr.size ()); 43 | } 44 | 45 | 46 | 47 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 48 | 49 | 50 | 51 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 52 | 53 | 54 | 55 | } // namespace fgrn 56 | 57 | 58 | 59 | #endif // fgrn_PointList_CODEHEADER_INCLUDED 60 | 61 | 62 | 63 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 64 | -------------------------------------------------------------------------------- /src/fgrn/UtilPrng.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | UtilPrng.h 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (fgrn_UtilPrng_HEADER_INCLUDED) 20 | #define fgrn_UtilPrng_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "fstb/Vf32.h" 27 | #include "fstb/Vs32.h" 28 | #include "fstb/Vu32.h" 29 | 30 | #include 31 | 32 | #include 33 | 34 | 35 | 36 | namespace fgrn 37 | { 38 | 39 | 40 | 41 | class UtilPrng 42 | { 43 | 44 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 45 | 46 | public: 47 | 48 | // More or less arbitrary limit to be refined, keeping in mind the balance 49 | // between accuracy and speed. At least, stay below 70. 50 | static constexpr float _poisson_algo_cutoff = 30; 51 | 52 | static inline float 53 | gen_uniform (uint32_t rnd_state) noexcept; 54 | static inline int 55 | gen_poisson (uint32_t rnd_state, float lambda) noexcept; 56 | static inline std::array 57 | make_norm_from_uni (float u0, float u1) noexcept; 58 | static inline float 59 | gen_norm_trunc (uint32_t rnd_state) noexcept; 60 | static inline float 61 | gen_log_norm (uint32_t rnd_state, float mu_log, float sigma) noexcept; 62 | 63 | static inline fstb::Vf32 64 | gen_uniform (fstb::Vu32 x) noexcept; 65 | static inline fstb::Vs32 66 | gen_poisson (fstb::Vu32 rnd_state, fstb::Vf32 lambda) noexcept; 67 | static inline std::array 68 | make_norm_from_uni (fstb::Vf32 u0, fstb::Vf32 u1) noexcept; 69 | static inline fstb::Vf32 70 | gen_norm_trunc (fstb::Vu32 rnd_state) noexcept; 71 | static inline fstb::Vf32 72 | gen_log_norm (fstb::Vu32 rnd_state, fstb::Vf32 mu_log, fstb::Vf32 sigma) noexcept; 73 | 74 | 75 | 76 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 77 | 78 | protected: 79 | 80 | 81 | 82 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 83 | 84 | private: 85 | 86 | template 87 | static inline void 88 | gen_poisson_one (std::tuple &n, const std::tuple &x, const std::tuple &rnd_state, unsigned int mask) noexcept; 89 | static inline std::array 90 | cos_sin_twopi (fstb::Vf32 an) noexcept; 91 | 92 | 93 | 94 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 95 | 96 | private: 97 | 98 | UtilPrng () = delete; 99 | UtilPrng (const UtilPrng &other) = delete; 100 | UtilPrng (UtilPrng &&other) = delete; 101 | UtilPrng & operator = (const UtilPrng &other) = delete; 102 | UtilPrng & operator = (UtilPrng &&other) = delete; 103 | bool operator == (const UtilPrng &other) const = delete; 104 | bool operator != (const UtilPrng &other) const = delete; 105 | 106 | }; // class UtilPrng 107 | 108 | 109 | 110 | } // namespace fgrn 111 | 112 | 113 | 114 | #include "fgrn/UtilPrng.hpp" 115 | 116 | 117 | 118 | #endif // fgrn_UtilPrng_HEADER_INCLUDED 119 | 120 | 121 | 122 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 123 | -------------------------------------------------------------------------------- /src/fgrn/VisionFilter.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | VisionFilter.h 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (fgrn_VisionFilter_HEADER_INCLUDED) 20 | #define fgrn_VisionFilter_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "fgrn/PointList.h" 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | 36 | 37 | namespace fgrn 38 | { 39 | 40 | 41 | 42 | class VisionFilter 43 | { 44 | 45 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 46 | 47 | public: 48 | 49 | typedef std::array C2di; // Integer 2D coordinates 50 | typedef std::set PixSet; 51 | 52 | // All the vision filter points grouped by covered area. 53 | // All coordinates are in pixels and relative to the filter center. 54 | typedef std::map FilterMap; 55 | 56 | explicit VisionFilter (float sigma, int nbr_points, float grain_radius_avg, float grain_radius_stddev); 57 | VisionFilter (const VisionFilter &other) = default; 58 | VisionFilter (VisionFilter &&other) = default; 59 | ~VisionFilter () = default; 60 | VisionFilter & operator = (const VisionFilter &other) = default; 61 | VisionFilter & operator = (VisionFilter &&other) = default; 62 | 63 | inline float get_grain_radius_avg () const noexcept; 64 | inline float get_grain_radius_stddev () const noexcept; 65 | inline int get_w () const noexcept; 66 | inline int get_h () const noexcept; 67 | inline int get_nbr_points () const noexcept; 68 | inline const FilterMap & 69 | use_map () const noexcept; 70 | 71 | 72 | 73 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 74 | 75 | protected: 76 | 77 | 78 | 79 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 80 | 81 | private: 82 | 83 | class ResultLambda 84 | { 85 | public: 86 | int _q = 0; 87 | uint32_t _rnd_state = 0; 88 | }; 89 | 90 | void build_filter (float sigma, float grain_radius_avg, float grain_radius_stddev); 91 | void compute_filter_area () noexcept; 92 | 93 | template 94 | static void add_and_wrap (T &acc, T inc) noexcept; 95 | 96 | // Number of points 97 | int _nbr_points = 0; 98 | 99 | // Grain characteristics 100 | float _rad_avg = 0; 101 | float _rad_stddev = 0; 102 | 103 | FilterMap _filter; 104 | 105 | // Filter width and height in source pixels, > 0. 106 | // Helps for setting the size of the cell cache. 107 | int _w = 0; 108 | int _h = 0; 109 | 110 | 111 | 112 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 113 | 114 | private: 115 | 116 | VisionFilter () = delete; 117 | bool operator == (const VisionFilter &other) const = delete; 118 | bool operator != (const VisionFilter &other) const = delete; 119 | 120 | }; // class VisionFilter 121 | 122 | 123 | 124 | } // namespace fgrn 125 | 126 | 127 | 128 | #include "fgrn/VisionFilter.hpp" 129 | 130 | 131 | 132 | #endif // fgrn_VisionFilter_HEADER_INCLUDED 133 | 134 | 135 | 136 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 137 | -------------------------------------------------------------------------------- /src/fgrn/VisionFilter.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | VisionFilter.hpp 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (fgrn_VisionFilter_CODEHEADER_INCLUDED) 19 | #define fgrn_VisionFilter_CODEHEADER_INCLUDED 20 | 21 | 22 | 23 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 24 | 25 | 26 | 27 | namespace fgrn 28 | { 29 | 30 | 31 | 32 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 33 | 34 | 35 | 36 | float VisionFilter::get_grain_radius_avg () const noexcept 37 | { 38 | return _rad_avg; 39 | } 40 | 41 | 42 | 43 | float VisionFilter::get_grain_radius_stddev () const noexcept 44 | { 45 | return _rad_stddev; 46 | } 47 | 48 | 49 | 50 | int VisionFilter::get_w () const noexcept 51 | { 52 | return _w; 53 | } 54 | 55 | 56 | 57 | int VisionFilter::get_h () const noexcept 58 | { 59 | return _h; 60 | } 61 | 62 | 63 | 64 | int VisionFilter::get_nbr_points () const noexcept 65 | { 66 | return _nbr_points; 67 | } 68 | 69 | 70 | 71 | const VisionFilter::FilterMap & VisionFilter::use_map () const noexcept 72 | { 73 | return _filter; 74 | } 75 | 76 | 77 | 78 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 79 | 80 | 81 | 82 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 83 | 84 | 85 | 86 | } // namespace fgrn 87 | 88 | 89 | 90 | #endif // fgrn_VisionFilter_CODEHEADER_INCLUDED 91 | 92 | 93 | 94 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 95 | -------------------------------------------------------------------------------- /src/fstb/AllocAlign.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | AllocAlign.h 4 | Author: Laurent de Soras, 2011 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (fstb_AllocAlign_HEADER_INCLUDED) 20 | #define fstb_AllocAlign_HEADER_INCLUDED 21 | 22 | #if defined (_MSC_VER) 23 | #pragma warning (4 : 4250) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | 36 | 37 | namespace fstb 38 | { 39 | 40 | 41 | 42 | template 43 | class AllocAlign 44 | { 45 | 46 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 47 | 48 | public: 49 | 50 | static constexpr long ALIGNMENT = ALIG; 51 | 52 | typedef T value_type; 53 | typedef value_type * pointer; 54 | typedef const value_type * const_pointer; 55 | typedef value_type & reference; 56 | typedef const value_type & const_reference; 57 | typedef size_t size_type; 58 | typedef ptrdiff_t difference_type; 59 | 60 | AllocAlign () = default; 61 | AllocAlign (AllocAlign const &other) = default; 62 | template 63 | AllocAlign (AllocAlign const &/*other*/) {} 64 | ~AllocAlign () = default; 65 | 66 | // Address 67 | [[deprecated]] inline pointer 68 | address (reference r) noexcept; 69 | [[deprecated]] inline const_pointer 70 | address (const_reference r) noexcept; 71 | 72 | // Memory allocation 73 | [[deprecated]] inline pointer 74 | allocate (size_type n, const void *ptr); 75 | inline pointer allocate (size_type n); 76 | inline void deallocate (pointer p, size_type n) noexcept; 77 | 78 | // Size 79 | [[deprecated]] inline size_type 80 | max_size () const noexcept; 81 | 82 | // Construction/destruction 83 | [[deprecated]] inline void 84 | construct (pointer ptr, const T & t); 85 | [[deprecated]] inline void 86 | destroy (pointer ptr); 87 | 88 | inline bool operator == (AllocAlign const &other) noexcept; 89 | inline bool operator != (AllocAlign const &other) noexcept; 90 | 91 | template 92 | struct rebind 93 | { 94 | typedef AllocAlign other; 95 | }; 96 | 97 | 98 | 99 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 100 | 101 | protected: 102 | 103 | 104 | 105 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 106 | 107 | private: 108 | 109 | 110 | 111 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 112 | 113 | private: 114 | 115 | }; // class AllocAlign 116 | 117 | 118 | 119 | } // namespace fstb 120 | 121 | 122 | 123 | #include "fstb/AllocAlign.hpp" 124 | 125 | 126 | 127 | #endif // fstb_AllocAlign_HEADER_INCLUDED 128 | 129 | 130 | 131 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 132 | -------------------------------------------------------------------------------- /src/fstb/ArrayAlign.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | ArrayAlign.h 4 | Author: Laurent de Soras, 2010 5 | 6 | Template parameters: 7 | 8 | - T: Element type 9 | - LEN: Number of elements, > 0 10 | - AL: Desired memory alignement, in bytes. > 0 and must a power of 2. 11 | 12 | --- Legal stuff --- 13 | 14 | This program is free software. It comes without any warranty, to 15 | the extent permitted by applicable law. You can redistribute it 16 | and/or modify it under the terms of the Do What The Fuck You Want 17 | To Public License, Version 2, as published by Sam Hocevar. See 18 | http://sam.zoy.org/wtfpl/COPYING for more details. 19 | 20 | *Tab=3***********************************************************************/ 21 | 22 | 23 | 24 | #if ! defined (fstb_ArrayAlign_HEADER_INCLUDED) 25 | #define fstb_ArrayAlign_HEADER_INCLUDED 26 | 27 | #if defined (_MSC_VER) 28 | #pragma once 29 | #pragma warning (4 : 4250) 30 | #endif 31 | 32 | 33 | 34 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 35 | 36 | #include 37 | #include 38 | 39 | 40 | 41 | namespace fstb 42 | { 43 | 44 | 45 | 46 | template 47 | class ArrayAlign 48 | { 49 | 50 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 51 | 52 | public: 53 | 54 | typedef T Element; 55 | 56 | static const int NBR_ELT = LEN; 57 | static const int ALIGNMENT = AL; 58 | 59 | ArrayAlign (); 60 | ArrayAlign (const ArrayAlign &other); 61 | ~ArrayAlign (); 62 | 63 | ArrayAlign & operator = (const ArrayAlign &other); 64 | 65 | inline const Element & 66 | operator [] (long pos) const noexcept; 67 | inline Element & 68 | operator [] (long pos) noexcept; 69 | 70 | inline const Element * 71 | data () const noexcept; 72 | inline Element * 73 | data () noexcept; 74 | 75 | static inline long 76 | size () noexcept; 77 | static inline long 78 | length () noexcept; 79 | static inline long 80 | get_alignment () noexcept; 81 | 82 | 83 | 84 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 85 | 86 | protected: 87 | 88 | 89 | 90 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 91 | 92 | private: 93 | 94 | static const int ELT_SIZE_BYTE = sizeof (Element) * CHAR_BIT / 8; 95 | 96 | uint8_t _data [NBR_ELT * ELT_SIZE_BYTE + ALIGNMENT - 1]; 97 | Element * _data_ptr; 98 | 99 | 100 | 101 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 102 | 103 | private: 104 | 105 | bool operator == (const ArrayAlign &other) const = delete; 106 | bool operator != (const ArrayAlign &other) const = delete; 107 | 108 | }; // class ArrayAlign 109 | 110 | 111 | 112 | } // namespace fstb 113 | 114 | 115 | 116 | #include "fstb/ArrayAlign.hpp" 117 | 118 | 119 | 120 | #endif // fstb_ArrayAlign_HEADER_INCLUDED 121 | 122 | 123 | 124 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 125 | -------------------------------------------------------------------------------- /src/fstb/CpuId.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | CpuId.cpp 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if defined (_MSC_VER) 19 | #pragma warning (1 : 4130 4223 4705 4706) 20 | #pragma warning (4 : 4355 4786 4800) 21 | #endif 22 | 23 | 24 | 25 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 26 | 27 | #include "fstb/CpuId.h" 28 | 29 | #if fstb_ARCHI == fstb_ARCHI_X86 30 | #if defined (__GNUC__) 31 | #include 32 | #elif defined (_MSC_VER) 33 | #include 34 | #endif 35 | #endif 36 | 37 | #include 38 | 39 | 40 | 41 | namespace fstb 42 | { 43 | 44 | 45 | 46 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 47 | 48 | 49 | 50 | CpuId::CpuId () 51 | { 52 | #if fstb_ARCHI == fstb_ARCHI_X86 53 | 54 | unsigned int eax; 55 | unsigned int ebx; 56 | unsigned int ecx; 57 | unsigned int edx; 58 | 59 | // Highest function available 60 | call_cpuid (0x00000000, 0, eax, ebx, ecx, edx); 61 | const unsigned int hf_basic = eax; 62 | 63 | // Processor Info and Feature Bits 64 | call_cpuid (0x00000001, 0, eax, ebx, ecx, edx); 65 | 66 | _mmx_flag = ((edx & (1L << 23)) != 0); 67 | _fxsr_flag = ((edx & (1L << 24)) != 0); 68 | _sse_flag = ((edx & (1L << 25)) != 0); 69 | _sse2_flag = ((edx & (1L << 26)) != 0); 70 | _sse3_flag = ((ecx & (1L << 0)) != 0); 71 | _ssse3_flag = ((ecx & (1L << 9)) != 0); 72 | _cx16_flag = ((ecx & (1L << 13)) != 0); 73 | _fma3_flag = ((ecx & (1L << 16)) != 0); 74 | _sse41_flag = ((ecx & (1L << 19)) != 0); 75 | _sse42_flag = ((ecx & (1L << 20)) != 0); 76 | _abm_flag = ((ecx & (1L << 23)) != 0); 77 | _avx_flag = ((ecx & (1L << 28)) != 0); 78 | _f16c_flag = ((ecx & (1L << 29)) != 0); 79 | 80 | if (hf_basic >= 0x00000007) 81 | { 82 | // Extended Features 83 | call_cpuid (0x00000007, 0, eax, ebx, ecx, edx); 84 | _bmi1_flag = ((ebx & (1L << 3)) != 0); 85 | _avx2_flag = ((ebx & (1L << 5)) != 0); 86 | _bmi2_flag = ((ebx & (1L << 8)) != 0); 87 | _avx512f_flag = ((ebx & (1L << 16)) != 0); 88 | } 89 | 90 | // Extended Processor Info and Feature Bits 91 | call_cpuid (0x80000000, 0, eax, ebx, ecx, edx); 92 | const unsigned int hf_ext = eax; 93 | if (hf_ext >= 0x80000001) 94 | { 95 | call_cpuid (0x80000001, 0, eax, ebx, ecx, edx); 96 | _isse_flag = ((edx & (1L << 22)) != 0) || _sse_flag; 97 | _sse4a_flag = ((ecx & (1L << 6)) != 0); 98 | _fma4_flag = ((ecx & (1L << 16)) != 0); 99 | _3dnow_flag = ((ecx & (1L << 31)) != 0); 100 | } 101 | 102 | #endif 103 | } 104 | 105 | 106 | 107 | #if fstb_ARCHI == fstb_ARCHI_X86 108 | 109 | void CpuId::call_cpuid (unsigned int fnc_nbr, unsigned int subfnc_nbr, unsigned int &v_eax, unsigned int &v_ebx, unsigned int &v_ecx, unsigned int &v_edx) 110 | { 111 | #if defined (__GNUC__) 112 | 113 | #if defined (__x86_64__) 114 | __cpuid_count (fnc_nbr, subfnc_nbr, v_eax, v_ebx, v_ecx, v_edx); 115 | #else 116 | fstb::unused (subfnc_nbr); 117 | __cpuid (fnc_nbr, v_eax, v_ebx, v_ecx, v_edx); 118 | #endif 119 | 120 | #elif defined (_MSC_VER) 121 | 122 | int cpu_info [4]; 123 | __cpuidex (cpu_info, fnc_nbr, subfnc_nbr); 124 | v_eax = cpu_info [0]; 125 | v_ebx = cpu_info [1]; 126 | v_ecx = cpu_info [2]; 127 | v_edx = cpu_info [3]; 128 | 129 | #else 130 | 131 | #pragma error "Unsupported compiler" 132 | 133 | #endif 134 | } 135 | 136 | #endif 137 | 138 | 139 | 140 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 141 | 142 | 143 | 144 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 145 | 146 | 147 | 148 | } // namespace fstb 149 | 150 | 151 | 152 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 153 | -------------------------------------------------------------------------------- /src/fstb/CpuId.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | CpuId.h 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (fstb_CpuId_HEADER_INCLUDED) 19 | #define fstb_CpuId_HEADER_INCLUDED 20 | 21 | #if defined (_MSC_VER) 22 | #pragma once 23 | #pragma warning (4 : 4250) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include "fstb/def.h" 31 | 32 | 33 | 34 | namespace fstb 35 | { 36 | 37 | 38 | 39 | class CpuId 40 | { 41 | 42 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 43 | 44 | public: 45 | 46 | CpuId (); 47 | CpuId (const CpuId &other) = default; 48 | 49 | CpuId & operator = (const CpuId &other) = default; 50 | 51 | #if fstb_ARCHI == fstb_ARCHI_X86 52 | static void call_cpuid (unsigned int fnc_nbr, unsigned int subfnc_nbr, unsigned int &v_eax, unsigned int &v_ebx, unsigned int &v_ecx, unsigned int &v_edx); 53 | #endif 54 | 55 | bool _mmx_flag = false; 56 | bool _fxsr_flag = false; // FXSAVE, FXRESTOR, CR4 bit 9 57 | bool _3dnow_flag = false; 58 | bool _isse_flag = false; 59 | bool _sse_flag = false; 60 | bool _sse2_flag = false; 61 | bool _sse3_flag = false; 62 | bool _ssse3_flag = false; 63 | bool _sse41_flag = false; 64 | bool _sse42_flag = false; 65 | bool _sse4a_flag = false; 66 | bool _fma3_flag = false; 67 | bool _fma4_flag = false; 68 | bool _avx_flag = false; 69 | bool _avx2_flag = false; 70 | bool _avx512f_flag = false; 71 | bool _f16c_flag = false; // Half-precision FP 72 | bool _cx16_flag = false; // CMPXCHG16B 73 | bool _abm_flag = false; // POPCNT + LZCNT 74 | bool _bmi1_flag = false; // Bit Manipulation Instruction Set 75 | bool _bmi2_flag = false; 76 | 77 | 78 | 79 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 80 | 81 | protected: 82 | 83 | 84 | 85 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 86 | 87 | private: 88 | 89 | 90 | 91 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 92 | 93 | private: 94 | 95 | bool operator == (const CpuId &other) const = delete; 96 | bool operator != (const CpuId &other) const = delete; 97 | 98 | }; // class CpuId 99 | 100 | 101 | 102 | } // namespace fstb 103 | 104 | 105 | 106 | //#include "fstb/CpuId.hpp" 107 | 108 | 109 | 110 | #endif // fstb_CpuId_HEADER_INCLUDED 111 | 112 | 113 | 114 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 115 | -------------------------------------------------------------------------------- /src/fstb/Hash.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Hash.h 4 | Author: Laurent de Soras, 2020 5 | 6 | Hash functions with a low bias. These hash functions are invertible. 7 | Note: hash of 0 is still 0, for any data size. 8 | 9 | Source: Chris Wellons 10 | https://nullprogram.com/blog/2018/07/31/ 11 | 12 | Also: Vincent Lunot 13 | https://lemire.me/blog/2017/09/18/computing-the-inverse-of-odd-integers/ 14 | 15 | Other hash functions. Probably invertible, but formula was not given. 16 | They make even better peseudo-random generators when feed with a counter. 17 | 18 | rrmxmx: Pelle Evensen, 19 | http://mostlymangling.blogspot.com/2018/07/on-mixing-functions-in-fast-splittable.html 20 | 21 | nasam: Pelle Evensen, 22 | http://mostlymangling.blogspot.com/2020/01/nasam-not-another-strange-acronym-mixer.html 23 | 24 | pelican: Tommy Ettinger, similar to nasam, but without fixed point at 0, 25 | https://github.com/tommyettinger/sarong/blob/master/src/main/java/sarong/PelicanRNG.java 26 | 27 | --- Legal stuff --- 28 | 29 | This program is free software. It comes without any warranty, to 30 | the extent permitted by applicable law. You can redistribute it 31 | and/or modify it under the terms of the Do What The Fuck You Want 32 | To Public License, Version 2, as published by Sam Hocevar. See 33 | http://www.wtfpl.net/ for more details. 34 | 35 | *Tab=3***********************************************************************/ 36 | 37 | 38 | 39 | #pragma once 40 | #if ! defined (fstb_Hash_HEADER_INCLUDED) 41 | #define fstb_Hash_HEADER_INCLUDED 42 | 43 | 44 | 45 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 46 | 47 | #include "fstb/def.h" 48 | #include "fstb/Vu32.h" 49 | 50 | #include 51 | 52 | 53 | 54 | namespace fstb 55 | { 56 | 57 | 58 | 59 | class Hash 60 | { 61 | 62 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 63 | 64 | public: 65 | 66 | static fstb_FORCEINLINE constexpr uint32_t 67 | hash (uint32_t x) noexcept; 68 | static fstb_FORCEINLINE Vu32 69 | hash (Vu32 x) noexcept; 70 | static fstb_FORCEINLINE constexpr uint32_t 71 | hash_inv (uint32_t x) noexcept; 72 | static fstb_FORCEINLINE Vu32 73 | hash_inv (Vu32 x) noexcept; 74 | 75 | static fstb_FORCEINLINE constexpr uint64_t 76 | hash (uint64_t x) noexcept; 77 | static fstb_FORCEINLINE constexpr uint64_t 78 | hash_inv (uint64_t x) noexcept; 79 | 80 | static fstb_FORCEINLINE constexpr uint64_t 81 | rrmxmx (uint64_t x) noexcept; 82 | static fstb_FORCEINLINE constexpr uint64_t 83 | nasam (uint64_t x) noexcept; 84 | static fstb_FORCEINLINE constexpr uint64_t 85 | pelican (uint64_t x) noexcept; 86 | 87 | 88 | 89 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 90 | 91 | protected: 92 | 93 | 94 | 95 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 96 | 97 | private: 98 | 99 | 100 | 101 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 102 | 103 | private: 104 | 105 | Hash () = delete; 106 | Hash (const Hash &other) = delete; 107 | Hash (Hash &&other) = delete; 108 | ~Hash () = delete; 109 | Hash & operator = (const Hash &other) = delete; 110 | Hash & operator = (Hash &&other) = delete; 111 | bool operator == (const Hash &other) const = delete; 112 | bool operator != (const Hash &other) const = delete; 113 | 114 | }; // class Hash 115 | 116 | 117 | 118 | } // namespace fstb 119 | 120 | 121 | 122 | #include "fstb/Hash.hpp" 123 | 124 | 125 | 126 | #endif // fstb_Hash_HEADER_INCLUDED 127 | 128 | 129 | 130 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 131 | -------------------------------------------------------------------------------- /src/fstb/Poly.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Poly.h 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (fstb_Poly_HEADER_INCLUDED) 20 | #define fstb_Poly_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "fstb/def.h" 27 | #include "fstb/Vf32.h" 28 | 29 | 30 | 31 | namespace fstb 32 | { 33 | 34 | 35 | 36 | class Poly 37 | { 38 | 39 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 40 | 41 | public: 42 | 43 | template 44 | fstb_FORCEINLINE static constexpr T 45 | horner (T x, T c0, T c1) noexcept; 46 | template 47 | fstb_FORCEINLINE static constexpr T 48 | horner (T x, T c0, T c1, T c2) noexcept; 49 | template 50 | fstb_FORCEINLINE static constexpr T 51 | horner (T x, T c0, T c1, T c2, T c3) noexcept; 52 | template 53 | fstb_FORCEINLINE static constexpr T 54 | horner (T x, T c0, T c1, T c2, T c3, T c4) noexcept; 55 | template 56 | fstb_FORCEINLINE static constexpr T 57 | horner (T x, T c0, T c1, T c2, T c3, T c4, T c5) noexcept; 58 | template 59 | fstb_FORCEINLINE static constexpr T 60 | horner (T x, T c0, T c1, T c2, T c3, T c4, T c5, T c6) noexcept; 61 | template 62 | fstb_FORCEINLINE static constexpr T 63 | horner (T x, T c0, T c1, T c2, T c3, T c4, T c5, T c6, T c7) noexcept; 64 | 65 | template 66 | fstb_FORCEINLINE static constexpr T 67 | estrin (T x, T c0, T c1, T c2, T c3) noexcept; 68 | template 69 | fstb_FORCEINLINE static constexpr T 70 | estrin (T x, T c0, T c1, T c2, T c3, T c4) noexcept; 71 | template 72 | fstb_FORCEINLINE static constexpr T 73 | estrin (T x, T c0, T c1, T c2, T c3, T c4, T c5) noexcept; 74 | template 75 | fstb_FORCEINLINE static constexpr T 76 | estrin (T x, T c0, T c1, T c2, T c3, T c4, T c5, T c6) noexcept; 77 | template 78 | fstb_FORCEINLINE static constexpr T 79 | estrin (T x, T c0, T c1, T c2, T c3, T c4, T c5, T c6, T c7) noexcept; 80 | 81 | 82 | 83 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 84 | 85 | protected: 86 | 87 | 88 | 89 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 90 | 91 | private: 92 | 93 | template 94 | fstb_FORCEINLINE static constexpr T 95 | fma (T x, T a, T b) noexcept; 96 | 97 | 98 | 99 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 100 | 101 | private: 102 | 103 | Poly () = delete; 104 | Poly (const Poly &other) = delete; 105 | Poly (Poly &&other) = delete; 106 | Poly & operator = (const Poly &other) = delete; 107 | Poly & operator = (Poly &&other) = delete; 108 | bool operator == (const Poly &other) const = delete; 109 | bool operator != (const Poly &other) const = delete; 110 | 111 | }; // class Poly 112 | 113 | 114 | 115 | } // namespace fstb 116 | 117 | 118 | 119 | #include "fstb/Poly.hpp" 120 | 121 | 122 | 123 | #endif // fstb_Poly_HEADER_INCLUDED 124 | 125 | 126 | 127 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 128 | -------------------------------------------------------------------------------- /src/fstb/Poly.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Poly.hpp 4 | Author: Laurent de Soras, 2021 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (fstb_Poly_CODEHEADER_INCLUDED) 19 | #define fstb_Poly_CODEHEADER_INCLUDED 20 | 21 | 22 | 23 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 24 | 25 | 26 | 27 | namespace fstb 28 | { 29 | 30 | 31 | 32 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 33 | 34 | 35 | 36 | template 37 | constexpr T Poly::horner (T x, T c0, T c1) noexcept 38 | { 39 | return fma (c1, x, c0); 40 | } 41 | 42 | template 43 | constexpr T Poly::horner (T x, T c0, T c1, T c2) noexcept 44 | { 45 | return horner (x, c0, fma (c2, x, c1)); 46 | } 47 | 48 | template 49 | constexpr T Poly::horner (T x, T c0, T c1, T c2, T c3) noexcept 50 | { 51 | return horner (x, c0, c1, fma (c3, x, c2)); 52 | } 53 | 54 | template 55 | constexpr T Poly::horner (T x, T c0, T c1, T c2, T c3, T c4) noexcept 56 | { 57 | return horner (x, c0, c1, c2, fma (c4, x, c3)); 58 | } 59 | 60 | template 61 | constexpr T Poly::horner (T x, T c0, T c1, T c2, T c3, T c4, T c5) noexcept 62 | { 63 | return horner (x, c0, c1, c2, c3, fma (c5, x, c4)); 64 | } 65 | 66 | template 67 | constexpr T Poly::horner (T x, T c0, T c1, T c2, T c3, T c4, T c5, T c6) noexcept 68 | { 69 | return horner (x, c0, c1, c2, c3, c4, fma (c6, x, c5)); 70 | } 71 | 72 | template 73 | constexpr T Poly::horner (T x, T c0, T c1, T c2, T c3, T c4, T c5, T c6, T c7) noexcept 74 | { 75 | return horner (x, c0, c1, c2, c3, c4, c5, fma (c7, x, c6)); 76 | } 77 | 78 | 79 | 80 | // Estrin evaluation is slightly less precise than Horner. 81 | // Speed improvement starts with 6 coefficients (5 on ARM). 82 | template 83 | constexpr T Poly::estrin (T x, T c0, T c1, T c2, T c3) noexcept 84 | { 85 | const auto x2 = x * x; 86 | return fma (x2, fma (x, c3, c2), fma (x, c1, c0)); 87 | } 88 | 89 | template 90 | constexpr T Poly::estrin (T x, T c0, T c1, T c2, T c3, T c4) noexcept 91 | { 92 | const auto x2 = x * x; 93 | const auto x4 = x2 * x2; 94 | return fma ( 95 | x4, 96 | c4, 97 | fma (x2, fma (x, c3, c2), fma (x, c1, c0)) 98 | ); 99 | } 100 | 101 | template 102 | constexpr T Poly::estrin (T x, T c0, T c1, T c2, T c3, T c4, T c5) noexcept 103 | { 104 | const auto x2 = x * x; 105 | const auto x4 = x2 * x2; 106 | return fma ( 107 | x4, 108 | fma (x, c5, c4), 109 | fma (x2, fma (x, c3, c2), fma (x, c1, c0)) 110 | ); 111 | } 112 | 113 | template 114 | constexpr T Poly::estrin (T x, T c0, T c1, T c2, T c3, T c4, T c5, T c6) noexcept 115 | { 116 | const auto x2 = x * x; 117 | const auto x4 = x2 * x2; 118 | return fma ( 119 | x4, 120 | fma (x2, c6, fma (x, c5, c4)), 121 | fma (x2, fma (x, c3, c2), fma (x, c1, c0)) 122 | ); 123 | } 124 | 125 | template 126 | constexpr T Poly::estrin (T x, T c0, T c1, T c2, T c3, T c4, T c5, T c6, T c7) noexcept 127 | { 128 | const auto x2 = x * x; 129 | const auto x4 = x2 * x2; 130 | return fma ( 131 | x4, 132 | fma (x2, fma (x, c7, c6), fma (x, c5, c4)), 133 | fma (x2, fma (x, c3, c2), fma (x, c1, c0)) 134 | ); 135 | } 136 | 137 | 138 | 139 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 140 | 141 | 142 | 143 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 144 | 145 | 146 | 147 | // We don't use std::fma for scalars, as it could be very slow, depending on 148 | // the platform. 149 | template 150 | constexpr T Poly::fma (T x, T a, T b) noexcept 151 | { 152 | return x * a + b; 153 | } 154 | 155 | 156 | 157 | } // namespace fstb 158 | 159 | 160 | 161 | #endif // fstb_Poly_CODEHEADER_INCLUDED 162 | 163 | 164 | 165 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 166 | -------------------------------------------------------------------------------- /src/fstb/Scale.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Scale.h 4 | Author: Laurent de Soras, 2019 5 | 6 | Scales a number with another number. Typically this is just a multiplication 7 | (for floating point or similar types), but integers are considered like 8 | fixed-point data. For example, using int32_t with 1 << 30 as nominal "1" 9 | level, the operation would be equivalent to: 10 | 11 | result = int32_t ((int64_t (a) * int64_t (b)) >> 30); 12 | 13 | Full precision of the operation is not guaranteed. 14 | 15 | Template parameters: 16 | 17 | - T: type to scale. May be interger or floating point, or any object with 18 | a *= operator. Integers may be signed or not. 19 | 20 | - LL2: bitdepth of the nominal level (1 << LL2), for integer types. 21 | Ignored with other types. 22 | 23 | --- Legal stuff --- 24 | 25 | This program is free software. It comes without any warranty, to 26 | the extent permitted by applicable law. You can redistribute it 27 | and/or modify it under the terms of the Do What The Fuck You Want 28 | To Public License, Version 2, as published by Sam Hocevar. See 29 | http://sam.zoy.org/wtfpl/COPYING for more details. 30 | 31 | *Tab=3***********************************************************************/ 32 | 33 | 34 | 35 | #pragma once 36 | #if ! defined (fstb_Scale_HEADER_INCLUDED) 37 | #define fstb_Scale_HEADER_INCLUDED 38 | 39 | #if defined (_MSC_VER) 40 | #pragma warning (4 : 4250) 41 | #endif 42 | 43 | 44 | 45 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 46 | 47 | #include "fstb/def.h" 48 | 49 | 50 | 51 | namespace fstb 52 | { 53 | 54 | 55 | 56 | template 57 | class Scale 58 | { 59 | public: 60 | template 61 | static fstb_FORCEINLINE T 62 | mul (T a, T b) noexcept; 63 | }; // class Scale 64 | 65 | 66 | 67 | } // namespace fstb 68 | 69 | 70 | 71 | #include "fstb/Scale.hpp" 72 | 73 | 74 | 75 | #endif // fstb_Scale_HEADER_INCLUDED 76 | 77 | 78 | 79 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 80 | -------------------------------------------------------------------------------- /src/fstb/Scale.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Scale.hpp 4 | Author: Laurent de Soras, 2019 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (fstb_Scale_CODEHEADER_INCLUDED) 19 | #define fstb_Scale_CODEHEADER_INCLUDED 20 | 21 | 22 | 23 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 24 | 25 | #include "fstb/def.h" 26 | 27 | #if fstb_ARCHI == fstb_ARCHI_ARM 28 | #include 29 | #endif 30 | #if defined (_MSC_VER) 31 | #include 32 | #endif 33 | 34 | #include 35 | 36 | #include 37 | 38 | 39 | 40 | namespace fstb 41 | { 42 | 43 | 44 | 45 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 46 | 47 | 48 | // Defines an integer type with double capacity 49 | // Default is not defined. Only specializations can be used. 50 | template 51 | struct Scale_Int2x { }; 52 | 53 | template <> 54 | struct Scale_Int2x { typedef int16_t Ty; }; 55 | template <> 56 | struct Scale_Int2x { typedef int32_t Ty; }; 57 | template <> 58 | struct Scale_Int2x { typedef int64_t Ty; }; 59 | 60 | template <> 61 | struct Scale_Int2x { typedef uint16_t Ty; }; 62 | template <> 63 | struct Scale_Int2x { typedef uint32_t Ty; }; 64 | template <> 65 | struct Scale_Int2x { typedef uint64_t Ty; }; 66 | 67 | 68 | 69 | // Floating point and other types 70 | template 71 | class Scale_Internal 72 | { 73 | public: 74 | static constexpr fstb_FORCEINLINE T mul (T a, T b) noexcept 75 | { 76 | return a *= b; 77 | } 78 | }; 79 | 80 | // Specialization for integer types 81 | template 82 | class Scale_Internal 83 | { 84 | public: 85 | static constexpr fstb_FORCEINLINE T mul (T a, T b) noexcept 86 | { 87 | typedef typename Scale_Int2x ::Ty T2; 88 | return T ((T2 (a) * T2 (b)) >> LL2); 89 | } 90 | }; 91 | 92 | #if fstb_ARCHI == fstb_ARCHI_ARM 93 | 94 | template <> 95 | class Scale_Internal 96 | { 97 | public: 98 | static fstb_FORCEINLINE int32_t mul (int32_t a, int32_t b) noexcept 99 | { 100 | const auto aa = vdup_n_s32 (a); 101 | const auto bb = vdup_n_s32 (b); 102 | const auto rr = vqrdmulh_s32 (aa, bb); 103 | 104 | return vget_lane_s32 (rr, 0); 105 | } 106 | }; 107 | template <> 108 | class Scale_Internal 109 | { 110 | public: 111 | static fstb_FORCEINLINE int32_t mul (int32_t a, int32_t b) noexcept 112 | { 113 | return Scale_Internal ::mul (a, b) << 1; 114 | } 115 | }; 116 | 117 | #elif fstb_ARCHI == fstb_ARCHI_X86 && defined (_MSC_VER) 118 | 119 | template 120 | class Scale_Internal 121 | { 122 | public: 123 | static fstb_FORCEINLINE uint32_t mul (uint32_t a, uint32_t b) noexcept 124 | { 125 | return uint32_t (__emulu (a, b) >> LL2); 126 | } 127 | }; 128 | 129 | # if fstb_WORD_SIZE == 64 130 | 131 | template <> 132 | class Scale_Internal 133 | { 134 | public: 135 | static fstb_FORCEINLINE uint64_t mul (uint64_t a, uint64_t b) noexcept 136 | { 137 | return __umulh (a, b); 138 | } 139 | }; 140 | 141 | # endif // fstb_WORD_SIZE 64 142 | 143 | #endif // ARM, X86, _MSC_VER 144 | 145 | 146 | 147 | 148 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 149 | 150 | 151 | 152 | template 153 | template 154 | T Scale ::mul (T a, T b) noexcept 155 | { 156 | return Scale_Internal ::value>::mul (a, b); 157 | } 158 | 159 | 160 | 161 | } // namespace fstb 162 | 163 | 164 | 165 | #endif // fstb_Scale_CODEHEADER_INCLUDED 166 | 167 | 168 | 169 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 170 | -------------------------------------------------------------------------------- /src/fstb/SingleObj.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | SingleObj.h 4 | Author: Laurent de Soras, 2015 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (fstb_SingleObj_HEADER_INCLUDED) 20 | #define fstb_SingleObj_HEADER_INCLUDED 21 | 22 | #if defined (_MSC_VER) 23 | #pragma warning (4 : 4250) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include "fstb/AllocAlign.h" 31 | 32 | 33 | 34 | namespace fstb 35 | { 36 | 37 | 38 | 39 | template > 40 | class SingleObj 41 | { 42 | 43 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 44 | 45 | public: 46 | 47 | SingleObj (); 48 | virtual ~SingleObj (); 49 | 50 | T * operator -> () const noexcept; 51 | T & operator * () const noexcept; 52 | 53 | 54 | 55 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 56 | 57 | protected: 58 | 59 | 60 | 61 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 62 | 63 | private: 64 | 65 | A _allo; 66 | T * _obj_ptr; 67 | 68 | 69 | 70 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 71 | 72 | private: 73 | 74 | SingleObj (const SingleObj &other) = delete; 75 | SingleObj (const SingleObj &&other) = delete; 76 | SingleObj & 77 | operator = (const SingleObj &other) = delete; 78 | SingleObj & 79 | operator = (const SingleObj &&other) = delete; 80 | bool operator == (const SingleObj &other) const = delete; 81 | bool operator != (const SingleObj &other) const = delete; 82 | 83 | }; // class SingleObj 84 | 85 | 86 | 87 | } // namespace fstb 88 | 89 | 90 | 91 | #include "fstb/SingleObj.hpp" 92 | 93 | 94 | 95 | #endif // fstb_SingleObj_HEADER_INCLUDED 96 | 97 | 98 | 99 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 100 | -------------------------------------------------------------------------------- /src/fstb/SingleObj.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | SingleObj.hpp 4 | Author: Laurent de Soras, 2015 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (fstb_SingleObj_CODEHEADER_INCLUDED) 19 | #define fstb_SingleObj_CODEHEADER_INCLUDED 20 | 21 | 22 | 23 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 24 | 25 | #include 26 | 27 | 28 | 29 | namespace fstb 30 | { 31 | 32 | 33 | 34 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 35 | 36 | 37 | 38 | template 39 | SingleObj ::SingleObj () 40 | : _allo () 41 | , _obj_ptr (_allo.allocate (1)) 42 | { 43 | if (_obj_ptr == nullptr) 44 | { 45 | #if defined (__cpp_exceptions) || ! defined (__GNUC__) 46 | throw std::bad_alloc (); 47 | #endif 48 | } 49 | 50 | #if defined (__cpp_exceptions) || ! defined (__GNUC__) 51 | try 52 | #endif 53 | { 54 | new (_obj_ptr) T (); 55 | } 56 | #if defined (__cpp_exceptions) || ! defined (__GNUC__) 57 | catch (...) 58 | { 59 | _allo.deallocate (_obj_ptr, 1); 60 | throw; 61 | } 62 | #endif 63 | } 64 | 65 | 66 | 67 | template 68 | SingleObj ::~SingleObj () 69 | { 70 | _obj_ptr->~T (); 71 | _allo.deallocate (_obj_ptr, 1); 72 | _obj_ptr = nullptr; 73 | } 74 | 75 | 76 | 77 | template 78 | T * SingleObj ::operator -> () const noexcept 79 | { 80 | assert (_obj_ptr != nullptr); 81 | 82 | return _obj_ptr; 83 | } 84 | 85 | 86 | 87 | template 88 | T & SingleObj ::operator * () const noexcept 89 | { 90 | assert (_obj_ptr != 0); 91 | 92 | return *_obj_ptr; 93 | } 94 | 95 | 96 | 97 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 98 | 99 | 100 | 101 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 102 | 103 | 104 | 105 | } // namespace fstb 106 | 107 | 108 | 109 | #endif // fstb_SingleObj_CODEHEADER_INCLUDED 110 | 111 | 112 | 113 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 114 | -------------------------------------------------------------------------------- /src/fstb/ToolsAvx2.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | ToolsAvx2.cpp 4 | Author: Laurent de Soras, 2015 5 | 6 | To be compiled with /arch:AVX2 in order to avoid SSE/AVX state switch 7 | slowdown. 8 | 9 | --- Legal stuff --- 10 | 11 | This program is free software. It comes without any warranty, to 12 | the extent permitted by applicable law. You can redistribute it 13 | and/or modify it under the terms of the Do What The Fuck You Want 14 | To Public License, Version 2, as published by Sam Hocevar. See 15 | http://sam.zoy.org/wtfpl/COPYING for more details. 16 | 17 | *Tab=3***********************************************************************/ 18 | 19 | 20 | 21 | #if defined (_MSC_VER) 22 | #pragma warning (1 : 4130 4223 4705 4706) 23 | #pragma warning (4 : 4355 4786 4800) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include "fstb/ToolsAvx2.h" 31 | 32 | #include 33 | 34 | 35 | 36 | namespace fstb 37 | { 38 | 39 | 40 | 41 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 42 | 43 | 44 | 45 | const ToolsAvx2::VectI32 ToolsAvx2::_zero = { 0, 0, 0, 0, 0, 0, 0, 0 }; 46 | 47 | const ToolsAvx2::VectI32 ToolsAvx2::_c16_8000 = 48 | { 49 | 0x80008000, 0x80008000, 0x80008000, 0x80008000, 50 | 0x80008000, 0x80008000, 0x80008000, 0x80008000 51 | }; 52 | 53 | const ToolsAvx2::VectI32 ToolsAvx2::_c32_00008000 = 54 | { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; 55 | 56 | const ToolsAvx2::VectI32 ToolsAvx2::_c32_0000ffff = 57 | { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF }; 58 | 59 | const ToolsAvx2::VectI32 ToolsAvx2::_mask_abs = 60 | { 61 | 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 62 | 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF 63 | }; 64 | 65 | 66 | 67 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 68 | 69 | 70 | 71 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 72 | 73 | 74 | 75 | } // namespace fstb 76 | 77 | 78 | 79 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 80 | -------------------------------------------------------------------------------- /src/fstb/ToolsSimd.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | ToolsSimd.h 4 | Author: Laurent de Soras, 2016 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (fstb_ToolsSimd_HEADER_INCLUDED) 20 | #define fstb_ToolsSimd_HEADER_INCLUDED 21 | 22 | #if defined (_MSC_VER) 23 | #pragma warning (4 : 4250) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include "fstb/def.h" 31 | #include "fstb/Vf32.h" 32 | #include "fstb/Vs32.h" 33 | #include "fstb/Vu32.h" 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | 40 | 41 | 42 | namespace fstb 43 | { 44 | 45 | 46 | 47 | class ToolsSimd 48 | { 49 | 50 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 51 | 52 | public: 53 | 54 | class VectU32Scalar 55 | { 56 | public: 57 | uint32_t _ [4]; 58 | }; 59 | 60 | union Combo 61 | { 62 | Vf32 _vf32; 63 | Vs32 _vs32; 64 | Vu32 _vu32; 65 | float _f32 [4]; 66 | int32_t _s32 [4]; 67 | uint32_t _u32 [4]; 68 | int16_t _s16 [8]; 69 | uint16_t _u16 [8]; 70 | }; 71 | 72 | static void disable_denorm () noexcept; 73 | 74 | static inline Vf32 75 | cast_f32 (Vs32 x) noexcept; 76 | static inline Vs32 77 | cast_s32 (Vf32 x) noexcept; 78 | 79 | static inline void 80 | transpose_f32 (Vf32 &a0, Vf32 &a1, Vf32 &a2, Vf32 &a3) noexcept; 81 | 82 | static inline Vs32 83 | conv_f32_to_s32 (Vf32 x) noexcept; 84 | static inline Vs32 85 | round_f32_to_s32 (Vf32 x) noexcept; 86 | static inline Vs32 87 | floor_f32_to_s32 (Vf32 x) noexcept; 88 | static inline Vf32 89 | conv_s32_to_f32 (Vs32 x) noexcept; 90 | 91 | static inline void 92 | start_lerp (Vf32 &val_cur, Vf32 &step, float val_beg, float val_end, int size) noexcept; 93 | 94 | template 95 | static inline Vs32 96 | srai_s32 (Vs32 lhs) noexcept; 97 | template 98 | static inline Vs32 99 | srli_s32 (Vs32 lhs) noexcept; 100 | template 101 | static inline Vs32 102 | slli_s32 (Vs32 lhs) noexcept; 103 | 104 | 105 | 106 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 107 | 108 | protected: 109 | 110 | 111 | 112 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 113 | 114 | private: 115 | 116 | static const int 117 | _inv_table_4_len = 1024+1; 118 | static const float 119 | _inv_table_4 [_inv_table_4_len]; 120 | 121 | static constexpr int8_t _sign8 = INT8_MIN; 122 | static constexpr int16_t _sign16 = INT16_MIN; 123 | static constexpr int32_t _sign32 = INT32_MIN; 124 | static constexpr int64_t _sign64 = INT64_MIN; 125 | 126 | 127 | 128 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 129 | 130 | private: 131 | 132 | ~ToolsSimd () = delete; 133 | ToolsSimd () = delete; 134 | ToolsSimd (const ToolsSimd &other) = delete; 135 | ToolsSimd (const ToolsSimd &&other) = delete; 136 | ToolsSimd & operator = (const ToolsSimd &other) = delete; 137 | ToolsSimd & operator = (const ToolsSimd &&other) = delete; 138 | bool operator == (const ToolsSimd &other) const = delete; 139 | bool operator != (const ToolsSimd &other) const = delete; 140 | 141 | }; // class ToolsSimd 142 | 143 | 144 | 145 | } // namespace fstb 146 | 147 | 148 | 149 | #include "fstb/ToolsSimd.hpp" 150 | 151 | 152 | 153 | #endif // fstb_ToolsSimd_HEADER_INCLUDED 154 | 155 | 156 | 157 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 158 | -------------------------------------------------------------------------------- /src/fstb/ToolsSse2.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | ToolsSse2.cpp 4 | Author: Laurent de Soras, 2016 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if defined (_MSC_VER) 19 | #pragma warning (1 : 4130 4223 4705 4706) 20 | #pragma warning (4 : 4355 4786 4800) 21 | #endif 22 | 23 | 24 | 25 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 26 | 27 | #include "ToolsSse2.h" 28 | 29 | #include 30 | 31 | 32 | 33 | namespace fstb 34 | { 35 | 36 | 37 | 38 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 39 | 40 | 41 | 42 | const ToolsSse2::VectI32 ToolsSse2::_zero = { 0, 0, 0, 0 }; 43 | 44 | const ToolsSse2::VectI32 ToolsSse2::_c16_8000 = 45 | { 0x80008000, 0x80008000, 0x80008000, 0x80008000 }; 46 | 47 | const ToolsSse2::VectI32 ToolsSse2::_c32_00008000 = 48 | { 0x8000, 0x8000, 0x8000, 0x8000 }; 49 | 50 | const ToolsSse2::VectI32 ToolsSse2::_c32_0000ffff = 51 | { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF }; 52 | 53 | const ToolsSse2::VectI32 ToolsSse2::_mask_lo64 = 54 | { 0xFFFFFFFF, 0xFFFFFFFF, 0, 0 }; 55 | 56 | const ToolsSse2::VectI32 ToolsSse2::_mask_abs = 57 | { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; 58 | 59 | 60 | 61 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 62 | 63 | 64 | 65 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 66 | 67 | 68 | 69 | } // namespace fstb 70 | 71 | 72 | 73 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 74 | -------------------------------------------------------------------------------- /src/fstb/VecAlign.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | VecAlign.h 4 | Author: Laurent de Soras, 2022 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://www.wtfpl.net/ for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (fstb_VecAlign_HEADER_INCLUDED) 20 | #define fstb_VecAlign_HEADER_INCLUDED 21 | 22 | 23 | 24 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 25 | 26 | #include "fstb/AllocAlign.h" 27 | 28 | #include 29 | 30 | 31 | 32 | namespace fstb 33 | { 34 | 35 | 36 | 37 | template 38 | using VecAlign = std::vector >; 39 | 40 | 41 | 42 | } // namespace fstb 43 | 44 | 45 | 46 | //#include "fstb/VecAlign.hpp" 47 | 48 | 49 | 50 | #endif // fstb_VecAlign_HEADER_INCLUDED 51 | 52 | 53 | 54 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 55 | -------------------------------------------------------------------------------- /src/fstb/fnc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | fnc.h 4 | Author: Laurent de Soras, 2010 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #pragma once 19 | #if ! defined (fstb_fnc_HEADER_INCLUDED) 20 | #define fstb_fnc_HEADER_INCLUDED 21 | 22 | #if defined (_MSC_VER) 23 | #pragma warning (4 : 4250) // "Inherits via dominance." 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include "fstb/def.h" 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | 40 | 41 | namespace fstb 42 | { 43 | 44 | 45 | 46 | template 47 | inline constexpr int sgn (T x) noexcept; 48 | template 49 | inline constexpr T limit (T x, T mi, T ma) noexcept; 50 | template 51 | inline constexpr void sort_2_elt (T &mi,T &ma, T a, T b) noexcept; 52 | template 53 | inline constexpr bool is_pow_2 (T x) noexcept; 54 | inline double round (double x) noexcept; 55 | inline float round (float x) noexcept; 56 | inline int round_int (float x) noexcept; 57 | inline int round_int (double x) noexcept; 58 | inline int round_int_accurate (double x) noexcept; 59 | inline int64_t round_int64 (double x) noexcept; 60 | inline int floor_int (float x) noexcept; 61 | inline int floor_int (double x) noexcept; 62 | inline int floor_int_accurate (double x) noexcept; 63 | inline int64_t floor_int64 (double x) noexcept; 64 | inline int ceil_int (double x) noexcept; 65 | template 66 | inline int trunc_int (T x) noexcept; 67 | template 68 | inline int conv_int_fast (T x) noexcept; 69 | template 70 | inline constexpr bool is_null (T val, T eps = T (1e-9)) noexcept; 71 | template 72 | inline constexpr bool is_eq (T v1, T v2, T eps = T (1e-9)) noexcept; 73 | template 74 | inline constexpr bool is_eq_rel (T v1, T v2, T tol = T (1e-6)) noexcept; 75 | inline constexpr bool is_eq_ulp (float v1, float v2, int32_t tol = 1) noexcept; 76 | inline int get_prev_pow_2 (uint32_t x) noexcept; 77 | inline int get_next_pow_2 (uint32_t x) noexcept; 78 | inline constexpr double sinc (double x) noexcept; 79 | inline double pseudo_exp (double x, double c) noexcept; 80 | inline double pseudo_log (double y, double c) noexcept; 81 | template 82 | inline constexpr T sshift_l (T x) noexcept; 83 | template 84 | inline constexpr T sshift_r (T x) noexcept; 85 | template 86 | inline constexpr T sra_ceil (T x, int s) noexcept; 87 | template 88 | inline constexpr T div_ceil (T num, T den) noexcept; 89 | template 90 | inline constexpr T sq (T x) noexcept; 91 | template 92 | inline constexpr T cube (T x) noexcept; 93 | template 94 | inline constexpr T ipow (T x, U n) noexcept; 95 | template 96 | inline constexpr T ipowp (T x, U n) noexcept; 97 | template 98 | inline constexpr T ipowpc (T x) noexcept; 99 | template 100 | inline constexpr T rcp_uint (int x) noexcept; 101 | template 102 | inline constexpr T lerp (T v0, T v1, T p) noexcept; 103 | template 104 | inline constexpr T find_extremum_pos_parabolic (T r1, T r2, T r3) noexcept; 105 | 106 | template 107 | inline constexpr T rotl (T x, int k) noexcept; 108 | template 109 | inline constexpr T rotr (T x, int k) noexcept; 110 | 111 | template 112 | constexpr std::array make_array (const T &init_val); 113 | 114 | template 115 | inline T read_unalign (const void *ptr) noexcept; 116 | template 117 | inline void write_unalign (void *ptr, T val) noexcept; 118 | template 119 | inline void copy_no_overlap (T * fstb_RESTRICT dst_ptr, const T * fstb_RESTRICT src_ptr, int nbr_elt) noexcept; 120 | 121 | void conv_to_lower_case (std::string &str); 122 | 123 | int snprintf4all (char *out_0, size_t size, const char *format_0, ...); 124 | //FILE * fopen_utf8 (const char *filename_0, const char *mode_0); 125 | 126 | template 127 | inline bool is_ptr_align_nz (const T *ptr, int a = 16) noexcept; 128 | 129 | 130 | 131 | } // namespace fstb 132 | 133 | 134 | 135 | #include "fstb/fnc.hpp" 136 | 137 | 138 | 139 | #endif // fstb_fnc_HEADER_INCLUDED 140 | 141 | 142 | 143 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 144 | -------------------------------------------------------------------------------- /src/fstb/fnc_fstb.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | fnc.cpp 4 | Author: Laurent de Soras, 2010 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if defined (_MSC_VER) 19 | #pragma warning (1 : 4130 4223 4705 4706) 20 | #pragma warning (4 : 4355 4786 4800) 21 | #endif 22 | 23 | 24 | 25 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 26 | 27 | #include "fstb/fnc.h" 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | 35 | namespace fstb 36 | { 37 | 38 | 39 | 40 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 41 | 42 | 43 | 44 | // Only for ANSI strings. 45 | void conv_to_lower_case (std::string &str) 46 | { 47 | for (std::string::size_type p = 0; p < str.length (); ++p) 48 | { 49 | str [p] = char (tolower (str [p])); 50 | } 51 | } 52 | 53 | 54 | 55 | int snprintf4all (char *out_0, size_t size, const char *format_0, ...) 56 | { 57 | va_list ap; 58 | va_start (ap, format_0); 59 | int cnt = -1; 60 | 61 | #if defined (_MSC_VER) && (_MSC_VER < 1900) 62 | 63 | if (size != 0) 64 | { 65 | cnt = _vsnprintf_s (out_0, size, _TRUNCATE, format_0, ap); 66 | } 67 | if (cnt == -1) 68 | { 69 | cnt = _vscprintf (format_0, ap); 70 | } 71 | 72 | #else 73 | 74 | cnt = vsnprintf (out_0, size, format_0, ap); 75 | 76 | #endif 77 | 78 | va_end (ap); 79 | 80 | return cnt; 81 | } 82 | 83 | 84 | 85 | } // namespace fstb 86 | 87 | 88 | 89 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 90 | -------------------------------------------------------------------------------- /src/main-avs.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define WIN32_LEAN_AND_MEAN 3 | #define NOMINMAX 4 | #define NOGDI 5 | 6 | #include "avsutl/fnc.h" 7 | #include "chkdravs/Grain.h" 8 | #include "chkdravs/function_names.h" 9 | #include "fstb/def.h" 10 | 11 | #include 12 | #include "avisynth.h" 13 | 14 | #if defined (_MSC_VER) && ! defined (NDEBUG) && defined (_DEBUG) 15 | #include 16 | #endif 17 | 18 | 19 | 20 | template 21 | ::AVSValue __cdecl main_avs_create (::AVSValue args, void *user_data_ptr, ::IScriptEnvironment *env_ptr) 22 | { 23 | fstb::unused (user_data_ptr); 24 | 25 | return new T (*env_ptr, args); 26 | } 27 | 28 | 29 | 30 | const ::AVS_Linkage * AVS_linkage = nullptr; 31 | 32 | extern "C" __declspec (dllexport) 33 | const char * __stdcall AvisynthPluginInit3 (::IScriptEnvironment *env_ptr, const ::AVS_Linkage * const vectors_ptr) 34 | { 35 | AVS_linkage = vectors_ptr; 36 | 37 | env_ptr->AddFunction (chkdravs_GRAIN, 38 | "c" "[sigma]f" "[res]i" "[rad]f" // 0 39 | "[dev]f" "[seed]i" "[cf]b" "[cp]b" // 4 40 | "[draft]b" "[cpuopt]i" 41 | , &main_avs_create , nullptr 42 | ); 43 | 44 | return "ChickenDream - film grain generator"; 45 | } 46 | 47 | 48 | 49 | static void main_avs_dll_load (::HINSTANCE hinst) 50 | { 51 | fstb::unused (hinst); 52 | 53 | #if defined (_MSC_VER) && ! defined (NDEBUG) && defined (_DEBUG) 54 | { 55 | const int mode = (1 * _CRTDBG_MODE_DEBUG) 56 | | (1 * _CRTDBG_MODE_WNDW); 57 | ::_CrtSetReportMode (_CRT_WARN, mode); 58 | ::_CrtSetReportMode (_CRT_ERROR, mode); 59 | ::_CrtSetReportMode (_CRT_ASSERT, mode); 60 | 61 | const int old_flags = ::_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG); 62 | ::_CrtSetDbgFlag ( old_flags 63 | | (1 * _CRTDBG_LEAK_CHECK_DF) 64 | | (0 * _CRTDBG_CHECK_ALWAYS_DF)); 65 | ::_CrtSetBreakAlloc (-1); // Specify here a memory bloc number 66 | } 67 | #endif // _MSC_VER, NDEBUG 68 | } 69 | 70 | 71 | 72 | static void main_avs_dll_unload (::HINSTANCE hinst) 73 | { 74 | fstb::unused (hinst); 75 | 76 | #if defined (_MSC_VER) && ! defined (NDEBUG) && defined (_DEBUG) 77 | { 78 | const int mode = (1 * _CRTDBG_MODE_DEBUG) 79 | | (0 * _CRTDBG_MODE_WNDW); 80 | ::_CrtSetReportMode (_CRT_WARN, mode); 81 | ::_CrtSetReportMode (_CRT_ERROR, mode); 82 | ::_CrtSetReportMode (_CRT_ASSERT, mode); 83 | 84 | ::_CrtMemState mem_state; 85 | ::_CrtMemCheckpoint (&mem_state); 86 | ::_CrtMemDumpStatistics (&mem_state); 87 | } 88 | #endif // _MSC_VER, NDEBUG 89 | } 90 | 91 | 92 | 93 | BOOL WINAPI DllMain (::HINSTANCE hinst, ::DWORD reason, ::LPVOID reserved_ptr) 94 | { 95 | fstb::unused (reserved_ptr); 96 | 97 | switch (reason) 98 | { 99 | case DLL_PROCESS_ATTACH: 100 | main_avs_dll_load (hinst); 101 | break; 102 | 103 | case DLL_PROCESS_DETACH: 104 | main_avs_dll_unload (hinst); 105 | break; 106 | } 107 | 108 | return TRUE; 109 | } 110 | -------------------------------------------------------------------------------- /src/main-vs.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | main.cpp 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #include "chkdrvs/Grain.h" 19 | #include "chkdrvs/version.h" 20 | #include "fstb/def.h" 21 | #include "vsutl/Redirect.h" 22 | #include "VapourSynth4.h" 23 | 24 | #include 25 | 26 | 27 | 28 | VS_EXTERNAL_API (void) VapourSynthPluginInit2 (::VSPlugin *plugin_ptr, const ::VSPLUGINAPI *api_ptr) 29 | { 30 | api_ptr->configPlugin ( 31 | chkdrvs_PLUGIN_NAME, 32 | chkdrvs_NAMESPACE, 33 | "Film grain generator", 34 | VS_MAKE_VERSION (chkdrvs_VERSION, 0), 35 | VAPOURSYNTH_API_VERSION, 36 | 0, // VSPluginConfigFlags 37 | plugin_ptr 38 | ); 39 | 40 | api_ptr->registerFunction ("grain", 41 | "clip:vnode;" 42 | "sigma:float:opt;" 43 | "res:int:opt;" 44 | "rad:float:opt;" 45 | "dev:float:opt;" 46 | "seed:int:opt;" 47 | "cf:int:opt;" 48 | "cp:int:opt;" 49 | "draft:int:opt;" 50 | "cpuopt:int:opt;" 51 | , "clip:vnode;" 52 | , &vsutl::Redirect ::create, nullptr, plugin_ptr 53 | ); 54 | } 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/vsutl/FrameRefSPtr.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FrameRefSPtr.h 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (vsutl_FrameRefSPtr_HEADER_INCLUDED) 19 | #define vsutl_FrameRefSPtr_HEADER_INCLUDED 20 | 21 | #if defined (_MSC_VER) 22 | #pragma once 23 | #pragma warning (4 : 4250) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include "vsutl/ObjRefSPtr.h" 31 | #include "VapourSynth4.h" 32 | 33 | 34 | 35 | namespace vsutl 36 | { 37 | 38 | 39 | 40 | class FrameRefSPtr_FncWrapper 41 | { 42 | public: 43 | static inline const ::VSFrame * clone (const ::VSAPI &vsapi, const ::VSFrame *f) VS_NOEXCEPT 44 | { 45 | return (*vsapi.addFrameRef) (f); 46 | } 47 | static inline void free (const ::VSAPI &vsapi, const ::VSFrame *f) VS_NOEXCEPT 48 | { 49 | (*vsapi.freeFrame) (f); 50 | } 51 | }; 52 | 53 | typedef ObjRefSPtr < 54 | const ::VSFrame, 55 | FrameRefSPtr_FncWrapper 56 | > FrameRefSPtr; 57 | 58 | 59 | 60 | } // namespace vsutl 61 | 62 | 63 | 64 | //#include "vsutl/FrameRefSPtr.hpp" 65 | 66 | 67 | 68 | #endif // vsutl_FrameRefSPtr_HEADER_INCLUDED 69 | 70 | 71 | 72 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 73 | -------------------------------------------------------------------------------- /src/vsutl/FuncRefSPtr.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | FuncRefSPtr.h 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (vsutl_FuncRefSPtr_HEADER_INCLUDED) 19 | #define vsutl_FuncRefSPtr_HEADER_INCLUDED 20 | 21 | #if defined (_MSC_VER) 22 | #pragma once 23 | #pragma warning (4 : 4250) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include "vsutl/ObjRefSPtr.h" 31 | #include "VapourSynth4.h" 32 | 33 | 34 | 35 | namespace vsutl 36 | { 37 | 38 | 39 | 40 | class FuncRefSPtr_FncWrapper 41 | { 42 | public: 43 | static inline ::VSFunction * clone (const ::VSAPI &vsapi, ::VSFunction *func) VS_NOEXCEPT 44 | { 45 | return (*vsapi.addFunctionRef) (func); 46 | } 47 | static inline void free (const ::VSAPI &vsapi, ::VSFunction *func) VS_NOEXCEPT 48 | { 49 | (*vsapi.freeFunc) (func); 50 | } 51 | }; 52 | 53 | typedef ObjRefSPtr < 54 | ::VSFunction, 55 | FuncRefSPtr_FncWrapper 56 | > FuncRefSPtr; 57 | 58 | 59 | 60 | } // namespace vsutl 61 | 62 | 63 | 64 | //#include "vsutl/FuncRefSPtr.hpp" 65 | 66 | 67 | 68 | #endif // vsutl_FuncRefSPtr_HEADER_INCLUDED 69 | 70 | 71 | 72 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 73 | -------------------------------------------------------------------------------- /src/vsutl/NodeRefSPtr.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | NodeRefSPtr.h 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (vsutl_NodeRefSPtr_HEADER_INCLUDED) 19 | #define vsutl_NodeRefSPtr_HEADER_INCLUDED 20 | 21 | #if defined (_MSC_VER) 22 | #pragma once 23 | #pragma warning (4 : 4250) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include "vsutl/ObjRefSPtr.h" 31 | #include "VapourSynth4.h" 32 | 33 | 34 | 35 | namespace vsutl 36 | { 37 | 38 | 39 | 40 | class NodeRefSPtr_FncWrapper 41 | { 42 | public: 43 | static inline ::VSNode * clone (const ::VSAPI &vsapi, ::VSNode *node) VS_NOEXCEPT 44 | { 45 | return (*vsapi.addNodeRef) (node); 46 | } 47 | static inline void free (const ::VSAPI &vsapi, ::VSNode *node) VS_NOEXCEPT 48 | { 49 | (*vsapi.freeNode) (node); 50 | } 51 | }; 52 | 53 | typedef ObjRefSPtr < 54 | ::VSNode, 55 | NodeRefSPtr_FncWrapper 56 | > NodeRefSPtr; 57 | 58 | 59 | 60 | } // namespace vsutl 61 | 62 | 63 | 64 | //#include "vsutl/NodeRefSPtr.hpp" 65 | 66 | 67 | 68 | #endif // vsutl_NodeRefSPtr_HEADER_INCLUDED 69 | 70 | 71 | 72 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 73 | -------------------------------------------------------------------------------- /src/vsutl/ObjRefSPtr.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | ObjRefSPtr.h 4 | Author: Laurent de Soras, 2012 5 | 6 | Smart pointer template class for the Vapoursynth object references. 7 | 8 | Template parameters: 9 | 10 | - T: The type of the object possibly with const, but without pointer 11 | (currently ::VSNode, const ::VSFrame or const ::VSFunction). 12 | 13 | - FW: Wrapper class for clone and free functions. Requires: 14 | static inline T * FW::clone (const ::VSAPI &, T *) VS_NOEXCEPT; 15 | static inline void FW::free (const ::VSAPI &, T *) VS_NOEXCEPT; 16 | 17 | --- Legal stuff --- 18 | 19 | This program is free software. It comes without any warranty, to 20 | the extent permitted by applicable law. You can redistribute it 21 | and/or modify it under the terms of the Do What The Fuck You Want 22 | To Public License, Version 2, as published by Sam Hocevar. See 23 | http://sam.zoy.org/wtfpl/COPYING for more details. 24 | 25 | *Tab=3***********************************************************************/ 26 | 27 | 28 | 29 | #if ! defined (vsutl_ObjRefSPtr_HEADER_INCLUDED) 30 | #define vsutl_ObjRefSPtr_HEADER_INCLUDED 31 | 32 | #if defined (_MSC_VER) 33 | #pragma once 34 | #pragma warning (4 : 4250) 35 | #endif 36 | 37 | 38 | 39 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 40 | 41 | #include "VapourSynth4.h" 42 | 43 | 44 | 45 | namespace vsutl 46 | { 47 | 48 | 49 | 50 | template 51 | class ObjRefSPtr 52 | { 53 | 54 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 55 | 56 | public: 57 | 58 | ObjRefSPtr () = default; 59 | ObjRefSPtr (T *ptr, const ::VSAPI &vsapi); 60 | ObjRefSPtr (const ObjRefSPtr &other); 61 | ObjRefSPtr (ObjRefSPtr &&other); 62 | virtual ~ObjRefSPtr (); 63 | 64 | ObjRefSPtr & 65 | operator = (const ObjRefSPtr &other); 66 | ObjRefSPtr & 67 | operator = (ObjRefSPtr &&other); 68 | 69 | T * operator -> () const; 70 | T & operator * () const; 71 | T * get () const; 72 | T * dup () const; 73 | void clear (); 74 | 75 | 76 | 77 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 78 | 79 | protected: 80 | 81 | 82 | 83 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 84 | 85 | private: 86 | 87 | void release_resource (); 88 | 89 | T * _obj_ptr = nullptr; 90 | const ::VSAPI* _vsapi_ptr = nullptr; // Can be 0 only if _obj_ptr is 0 too. 91 | 92 | 93 | 94 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 95 | 96 | private: 97 | 98 | bool operator == (const ObjRefSPtr &other) const; 99 | bool operator != (const ObjRefSPtr &other) const; 100 | 101 | }; // class ObjRefSPtr 102 | 103 | 104 | 105 | } // namespace vsutl 106 | 107 | 108 | 109 | #include "vsutl/ObjRefSPtr.hpp" 110 | 111 | 112 | 113 | #endif // vsutl_ObjRefSPtr_HEADER_INCLUDED 114 | 115 | 116 | 117 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 118 | -------------------------------------------------------------------------------- /src/vsutl/ObjRefSPtr.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | ObjRefSPtr.hpp 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (vsutl_ObjRefSPtr_CODEHEADER_INCLUDED) 19 | #define vsutl_ObjRefSPtr_CODEHEADER_INCLUDED 20 | 21 | 22 | 23 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 24 | 25 | #include "VapourSynth4.h" 26 | 27 | #include 28 | 29 | #include 30 | 31 | 32 | 33 | namespace vsutl 34 | { 35 | 36 | 37 | 38 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 39 | 40 | 41 | 42 | // Does not increase the reference count. 43 | template 44 | ObjRefSPtr ::ObjRefSPtr (T *ptr, const ::VSAPI &vsapi) 45 | : _obj_ptr (ptr) 46 | , _vsapi_ptr (&vsapi) 47 | { 48 | assert (_obj_ptr == nullptr || _vsapi_ptr != nullptr); 49 | } 50 | 51 | 52 | 53 | template 54 | ObjRefSPtr ::ObjRefSPtr (const ObjRefSPtr &other) 55 | : _obj_ptr (nullptr) 56 | , _vsapi_ptr (other._vsapi_ptr) 57 | { 58 | if (other._obj_ptr != nullptr) 59 | { 60 | _obj_ptr = FW::clone (*_vsapi_ptr, other._obj_ptr); 61 | if (_obj_ptr == nullptr) 62 | { 63 | throw std::runtime_error ("Cannot clone VS object reference."); 64 | } 65 | } 66 | } 67 | 68 | 69 | 70 | template 71 | ObjRefSPtr ::ObjRefSPtr (ObjRefSPtr &&other) 72 | : _obj_ptr (other._obj_ptr) 73 | , _vsapi_ptr (other._vsapi_ptr) 74 | { 75 | other._obj_ptr = nullptr; 76 | } 77 | 78 | 79 | 80 | template 81 | ObjRefSPtr ::~ObjRefSPtr () 82 | { 83 | release_resource (); 84 | } 85 | 86 | 87 | 88 | template 89 | ObjRefSPtr & ObjRefSPtr ::operator = (const ObjRefSPtr &other) 90 | { 91 | if (other._obj_ptr != _obj_ptr) 92 | { 93 | T * tmp_ptr = nullptr; 94 | 95 | if (other._obj_ptr != nullptr) 96 | { 97 | if (_vsapi_ptr == nullptr) 98 | { 99 | assert (other._vsapi_ptr != nullptr); 100 | _vsapi_ptr = other._vsapi_ptr; 101 | } 102 | 103 | tmp_ptr = FW::clone (*_vsapi_ptr, other._obj_ptr); 104 | if (tmp_ptr == nullptr) 105 | { 106 | throw std::runtime_error ("Cannot clone VS object reference."); 107 | } 108 | } 109 | 110 | release_resource (); 111 | 112 | _obj_ptr = tmp_ptr; 113 | } 114 | 115 | return *this; 116 | } 117 | 118 | 119 | 120 | template 121 | ObjRefSPtr & ObjRefSPtr ::operator = (ObjRefSPtr &&other) 122 | { 123 | if (other._obj_ptr != _obj_ptr) 124 | { 125 | _obj_ptr = other._obj_ptr; 126 | _vsapi_ptr = other._vsapi_ptr; 127 | other._obj_ptr = nullptr; 128 | } 129 | 130 | return *this; 131 | } 132 | 133 | 134 | 135 | template 136 | T * ObjRefSPtr ::operator -> () const 137 | { 138 | return _obj_ptr; 139 | } 140 | 141 | 142 | 143 | template 144 | T & ObjRefSPtr ::operator * () const 145 | { 146 | return *_obj_ptr; 147 | } 148 | 149 | 150 | 151 | template 152 | T * ObjRefSPtr ::get () const 153 | { 154 | return _obj_ptr; 155 | } 156 | 157 | 158 | 159 | template 160 | T * ObjRefSPtr ::dup () const 161 | { 162 | assert (_obj_ptr != nullptr); 163 | assert (_vsapi_ptr != nullptr); 164 | 165 | T * tmp_ptr = FW::clone (*_vsapi_ptr, _obj_ptr); 166 | 167 | return tmp_ptr; 168 | } 169 | 170 | 171 | 172 | template 173 | void ObjRefSPtr ::clear () 174 | { 175 | release_resource (); 176 | } 177 | 178 | 179 | 180 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 181 | 182 | 183 | 184 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 185 | 186 | 187 | 188 | template 189 | void ObjRefSPtr ::release_resource () 190 | { 191 | if (_obj_ptr != nullptr) 192 | { 193 | assert (_vsapi_ptr != nullptr); 194 | FW::free (*_vsapi_ptr, _obj_ptr); 195 | _obj_ptr = nullptr; 196 | } 197 | } 198 | 199 | 200 | 201 | } // namespace vsutl 202 | 203 | 204 | 205 | #endif // vsutl_ObjRefSPtr_CODEHEADER_INCLUDED 206 | 207 | 208 | 209 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 210 | -------------------------------------------------------------------------------- /src/vsutl/PlaneProcCbInterface.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | PlaneProcCbInterface.h 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (vsutl_PlaneProcCbInterface_HEADER_INCLUDED) 19 | #define vsutl_PlaneProcCbInterface_HEADER_INCLUDED 20 | 21 | #if defined (_MSC_VER) 22 | #pragma once 23 | #pragma warning (4 : 4250) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include "vsutl/NodeRefSPtr.h" 31 | 32 | 33 | 34 | struct VSCore; 35 | struct VSFrameContext; 36 | struct VSFrame; 37 | 38 | 39 | 40 | namespace vsutl 41 | { 42 | 43 | 44 | 45 | class PlaneProcCbInterface 46 | { 47 | 48 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 49 | 50 | public: 51 | 52 | virtual ~PlaneProcCbInterface () = default; 53 | 54 | int process_plane (::VSFrame &dst, int n, int plane_index, void *frame_data_ptr, ::VSFrameContext &frame_ctx, ::VSCore &core, const NodeRefSPtr &src_node1_sptr, const NodeRefSPtr &src_node2_sptr, const NodeRefSPtr &src_node3_sptr); 55 | 56 | 57 | 58 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 59 | 60 | protected: 61 | 62 | virtual int do_process_plane (::VSFrame &dst, int n, int plane_index, void *frame_data_ptr, ::VSFrameContext &frame_ctx, ::VSCore &core, const NodeRefSPtr &src_node1_sptr, const NodeRefSPtr &src_node2_sptr, const NodeRefSPtr &src_node3_sptr) = 0; 63 | 64 | 65 | 66 | }; // class PlaneProcCbInterface 67 | 68 | 69 | 70 | } // namespace vsutl 71 | 72 | 73 | 74 | //#include "vsutl/PlaneProcCbInterface.hpp" 75 | 76 | 77 | 78 | #endif // vsutl_PlaneProcCbInterface_HEADER_INCLUDED 79 | 80 | 81 | 82 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 83 | -------------------------------------------------------------------------------- /src/vsutl/PlaneProcCbInterface_vs.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | PlaneProcCbInterface.cpp 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if defined (_MSC_VER) 19 | #pragma warning (1 : 4130 4223 4705 4706) 20 | #pragma warning (4 : 4355 4786 4800) 21 | #endif 22 | 23 | 24 | 25 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 26 | 27 | #include "vsutl/PlaneProcCbInterface.h" 28 | 29 | #include 30 | 31 | 32 | 33 | namespace vsutl 34 | { 35 | 36 | 37 | 38 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 39 | 40 | 41 | 42 | int PlaneProcCbInterface::process_plane (::VSFrame &dst, int n, int plane_index, void *frame_data_ptr, ::VSFrameContext &frame_ctx, ::VSCore &core, const NodeRefSPtr &src_node1_sptr, const NodeRefSPtr &src_node2_sptr, const NodeRefSPtr &src_node3_sptr) 43 | { 44 | assert (n >= 0); 45 | assert (plane_index >= 0); 46 | 47 | return (do_process_plane ( 48 | dst, 49 | n, 50 | plane_index, 51 | frame_data_ptr, 52 | frame_ctx, 53 | core, 54 | src_node1_sptr, 55 | src_node2_sptr, 56 | src_node3_sptr 57 | )); 58 | } 59 | 60 | 61 | 62 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 63 | 64 | 65 | 66 | } // namespace vsutl 67 | 68 | 69 | 70 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 71 | -------------------------------------------------------------------------------- /src/vsutl/PlaneProcMode.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | PlaneProcMode.h 4 | Author: Laurent de Soras, 2011 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (vsutl_PlaneProcMode_HEADER_INCLUDED) 19 | #define vsutl_PlaneProcMode_HEADER_INCLUDED 20 | 21 | #if defined (_MSC_VER) 22 | #pragma once 23 | #pragma warning (4 : 4250) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | 31 | 32 | namespace vsutl 33 | { 34 | 35 | 36 | 37 | enum PlaneProcMode 38 | { 39 | PlaneProcMode_FILL = 0, 40 | PlaneProcMode_GARBAGE, 41 | PlaneProcMode_COPY1, 42 | PlaneProcMode_PROCESS, 43 | PlaneProcMode_COPY2, 44 | PlaneProcMode_COPY3, 45 | 46 | PlaneProcMode_NBR_ELT 47 | 48 | }; // class PlaneProcMode 49 | 50 | 51 | 52 | } // namespace vsutl 53 | 54 | 55 | 56 | #endif // vsutl_PlaneProcMode_HEADER_INCLUDED 57 | 58 | 59 | 60 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 61 | -------------------------------------------------------------------------------- /src/vsutl/PlaneProcessor.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | PlaneProcessor.h 4 | Author: Laurent de Soras, 2012 5 | 6 | Reorganisation necessaire: 7 | 8 | - Separer plus clairement le mode manuel du mode pris en charge. 9 | - On a besoin d'un suivi entre la demande des frames sources et la mise 10 | a disposition du resultat. PlaneProcessor doit donc fournir une pool de 11 | PlaneProcContext qui contient entre autres la frame destination. 12 | - La frame destination devrait etre cree directement par le PlaneProcessor, 13 | en rajoutant les parametres necessaires a la fonction principale. On pourrait 14 | ainsi utiliser newVideoFrame2 pour tout ce qui est copie exacte de plans. 15 | - Reflechir au cas des frames a taille variable. 16 | 17 | 18 | 19 | --- Legal stuff --- 20 | 21 | This program is free software. It comes without any warranty, to 22 | the extent permitted by applicable law. You can redistribute it 23 | and/or modify it under the terms of the Do What The Fuck You Want 24 | To Public License, Version 2, as published by Sam Hocevar. See 25 | http://sam.zoy.org/wtfpl/COPYING for more details. 26 | 27 | *Tab=3***********************************************************************/ 28 | 29 | 30 | 31 | #if ! defined (vsutl_PlaneProcessor_HEADER_INCLUDED) 32 | #define vsutl_PlaneProcessor_HEADER_INCLUDED 33 | 34 | #if defined (_MSC_VER) 35 | #pragma once 36 | #pragma warning (4 : 4250) 37 | #endif 38 | 39 | 40 | 41 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 42 | 43 | #include "vsutl/NodeRefSPtr.h" 44 | #include "vsutl/FrameRefSPtr.h" 45 | #include "vsutl/PlaneProcMode.h" 46 | 47 | #include 48 | 49 | 50 | 51 | struct VSAPI; 52 | struct VSCore; 53 | struct VSFrameContext; 54 | struct VSFrame; 55 | struct VSMap; 56 | struct VSVideoInfo; 57 | 58 | 59 | 60 | namespace vsutl 61 | { 62 | 63 | 64 | 65 | class PlaneProcCbInterface; 66 | 67 | class PlaneProcessor 68 | { 69 | 70 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 71 | 72 | public: 73 | 74 | static const int MAX_NBR_PLANES = 3; 75 | static const int MAX_NBR_CLIPS = 1+3; // Index 0 = destination 76 | 77 | explicit PlaneProcessor (const ::VSAPI &vsapi, PlaneProcCbInterface &cb, const char filter_name_0 [], bool manual_flag); 78 | virtual ~PlaneProcessor () {} 79 | 80 | void set_filter (const ::VSMap &in, ::VSMap &out, const ::VSVideoInfo &vi_out, bool simple_flag = false, int max_def_planes = MAX_NBR_PLANES, const char *prop_name_0 = "planes", const char *clip_name_0 = "clip"); 81 | 82 | const ::VSFrame * 83 | try_initial (::VSCore &core); 84 | int process_frame (::VSFrame &dst, int n, void *frame_data_ptr, ::VSFrameContext &frame_ctx, ::VSCore &core, NodeRefSPtr src_node1_sptr = vsutl::NodeRefSPtr (), NodeRefSPtr src_node2_sptr = vsutl::NodeRefSPtr (), NodeRefSPtr src_node3_sptr = vsutl::NodeRefSPtr ()); 85 | 86 | // For manual operations 87 | bool is_manual () const; 88 | PlaneProcMode get_mode (int plane_index) const; 89 | double get_mode_val (int plane_index) const; 90 | 91 | void fill_plane (::VSFrame &dst, double val, int plane_index); 92 | void copy_plane (::VSFrame &dst, const ::VSFrame &src, int plane_index); 93 | 94 | 95 | 96 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 97 | 98 | protected: 99 | 100 | 101 | 102 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 103 | 104 | private: 105 | 106 | template 107 | void fill_plane (void *ptr, T val, ptrdiff_t stride, int w, int h); 108 | 109 | 110 | const ::VSAPI& _vsapi; 111 | const std::string 112 | _filter_name; 113 | PlaneProcCbInterface & 114 | _cb; 115 | ::VSVideoInfo _vi_out; 116 | int _nbr_planes; 117 | double _proc_mode_arr [MAX_NBR_PLANES]; // PlaneProcMode or value < 1 118 | bool _manual_flag; 119 | bool _input_flag; // Indicates that we need an input (at least one copy or process) 120 | FrameRefSPtr _blank_frame_sptr; 121 | 122 | 123 | 124 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 125 | 126 | private: 127 | 128 | PlaneProcessor () = delete; 129 | PlaneProcessor (const PlaneProcessor &other) = delete; 130 | PlaneProcessor & 131 | operator = (const PlaneProcessor &other) = delete; 132 | bool operator == (const PlaneProcessor &other) const = delete; 133 | bool operator != (const PlaneProcessor &other) const = delete; 134 | 135 | }; // class PlaneProcessor 136 | 137 | 138 | 139 | } // namespace vsutl 140 | 141 | 142 | 143 | //#include "vsutl/PlaneProcessor.hpp" 144 | 145 | 146 | 147 | #endif // vsutl_PlaneProcessor_HEADER_INCLUDED 148 | 149 | 150 | 151 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 152 | -------------------------------------------------------------------------------- /src/vsutl/Redirect.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Redirect.h 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (vsutl_Redirect_HEADER_INCLUDED) 19 | #define vsutl_Redirect_HEADER_INCLUDED 20 | 21 | #if defined (_MSC_VER) 22 | #pragma once 23 | #pragma warning (4 : 4250) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include "VapourSynth4.h" 31 | 32 | 33 | 34 | namespace vsutl 35 | { 36 | 37 | 38 | 39 | template 40 | class Redirect 41 | { 42 | 43 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 44 | 45 | public: 46 | 47 | // ::VSPublicFunction 48 | static void VS_CC 49 | create (const ::VSMap *in, ::VSMap *out, void *userData, ::VSCore *core, const ::VSAPI *vsapi); 50 | 51 | 52 | 53 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 54 | 55 | protected: 56 | 57 | 58 | 59 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 60 | 61 | private: 62 | 63 | static const ::VSFrame * VS_CC 64 | get_frame (int n, int activationReason, void *instanceData, void **frameData, ::VSFrameContext *frameCtx, ::VSCore *core, const ::VSAPI *vsapi); 65 | static void VS_CC 66 | free_filter (void *instanceData, ::VSCore *core, const ::VSAPI *vsapi); 67 | 68 | 69 | 70 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 71 | 72 | private: 73 | 74 | Redirect () = delete; 75 | virtual ~Redirect () = delete; 76 | Redirect (const Redirect &other) = delete; 77 | Redirect & operator = (const Redirect &other) = delete; 78 | bool operator == (const Redirect &other) const = delete; 79 | bool operator != (const Redirect &other) const = delete; 80 | 81 | }; // class Redirect 82 | 83 | 84 | 85 | } // namespace vsutl 86 | 87 | 88 | 89 | #include "vsutl/Redirect.hpp" 90 | 91 | 92 | 93 | #endif // vsutl_Redirect_HEADER_INCLUDED 94 | 95 | 96 | 97 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 98 | -------------------------------------------------------------------------------- /src/vsutl/Redirect.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | Redirect.hpp 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (vsutl_Redirect_CODEHEADER_INCLUDED) 19 | #define vsutl_Redirect_CODEHEADER_INCLUDED 20 | 21 | 22 | 23 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 24 | 25 | #include "fstb/def.h" 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | 33 | 34 | namespace vsutl 35 | { 36 | 37 | 38 | 39 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 40 | 41 | 42 | 43 | template 44 | void VS_CC Redirect ::create (const ::VSMap *in, ::VSMap *out, void *userData, ::VSCore *core, const ::VSAPI *vsapi) 45 | { 46 | assert (in != nullptr); 47 | assert (out != nullptr); 48 | assert (core != nullptr); 49 | assert (vsapi != nullptr); 50 | 51 | std::unique_ptr plugin_uptr; 52 | 53 | try 54 | { 55 | plugin_uptr = std::make_unique (*in, *out, userData, *core, *vsapi); 56 | const auto vi = plugin_uptr->get_video_info (); 57 | const auto mode = plugin_uptr->get_filter_mode (); 58 | const auto deps = plugin_uptr->get_dependencies (); 59 | 60 | vsapi->createVideoFilter ( 61 | out, 62 | plugin_uptr->use_filter_name ().c_str (), 63 | &vi, 64 | &get_frame, 65 | &free_filter, 66 | mode, 67 | deps.data (), 68 | int (deps.size ()), 69 | plugin_uptr.get (), 70 | core 71 | ); 72 | } 73 | catch (const std::exception &e) 74 | { 75 | if (vsapi->mapGetError (out) == nullptr) 76 | { 77 | vsapi->mapSetError (out, e.what ()); 78 | } 79 | } 80 | catch (...) 81 | { 82 | if (vsapi->mapGetError (out) == nullptr) 83 | { 84 | vsapi->mapSetError (out, "Exception"); 85 | } 86 | } 87 | 88 | // If finally there isn't any error, we release the unique_ptr ownership 89 | // so the object can live out of the function scope. 90 | if (vsapi->mapGetError (out) == nullptr) 91 | { 92 | plugin_uptr.release (); 93 | } 94 | } 95 | 96 | 97 | 98 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 99 | 100 | 101 | 102 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 103 | 104 | 105 | 106 | template 107 | const ::VSFrame * VS_CC Redirect ::get_frame (int n, int activationReason, void *instanceData, void **frameData, ::VSFrameContext *frameCtx, ::VSCore *core, const ::VSAPI *vsapi) 108 | { 109 | fstb::unused (vsapi); 110 | assert (n >= 0); 111 | assert (instanceData != nullptr); 112 | assert (frameData != nullptr); 113 | assert (frameCtx != nullptr); 114 | assert (core != nullptr); 115 | assert (vsapi != nullptr); 116 | 117 | T * plugin_ptr = reinterpret_cast (instanceData); 118 | const ::VSFrame * frame_ptr = plugin_ptr->get_frame ( 119 | n, 120 | activationReason, 121 | *frameData, 122 | *frameCtx, 123 | *core 124 | ); 125 | 126 | return frame_ptr; 127 | } 128 | 129 | 130 | 131 | template 132 | void VS_CC Redirect ::free_filter (void *instanceData, ::VSCore *core, const ::VSAPI *vsapi) 133 | { 134 | fstb::unused (core, vsapi); 135 | assert (instanceData != nullptr); 136 | assert (core != nullptr); 137 | assert (vsapi != nullptr); 138 | 139 | T * plugin_ptr = reinterpret_cast (instanceData); 140 | 141 | delete plugin_ptr; 142 | plugin_ptr = nullptr; 143 | } 144 | 145 | 146 | 147 | } // namespace vsutl 148 | 149 | 150 | 151 | #endif // vsutl_Redirect_CODEHEADER_INCLUDED 152 | 153 | 154 | 155 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 156 | -------------------------------------------------------------------------------- /src/vsutl/fnc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | fnc.h 4 | Author: Laurent de Soras, 2012 5 | 6 | --- Legal stuff --- 7 | 8 | This program is free software. It comes without any warranty, to 9 | the extent permitted by applicable law. You can redistribute it 10 | and/or modify it under the terms of the Do What The Fuck You Want 11 | To Public License, Version 2, as published by Sam Hocevar. See 12 | http://sam.zoy.org/wtfpl/COPYING for more details. 13 | 14 | *Tab=3***********************************************************************/ 15 | 16 | 17 | 18 | #if ! defined (vsutl_fnc_HEADER_INCLUDED) 19 | #define vsutl_fnc_HEADER_INCLUDED 20 | 21 | #if defined (_MSC_VER) 22 | #pragma once 23 | #pragma warning (4 : 4250) 24 | #endif 25 | 26 | 27 | 28 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 | 30 | #include "VapourSynth4.h" 31 | 32 | #include 33 | 34 | 35 | 36 | namespace vsutl 37 | { 38 | 39 | 40 | bool is_vs_gray (int cf); 41 | bool is_vs_rgb (int cf); 42 | bool is_vs_yuv (int cf); 43 | bool is_vs_same_colfam (int lhs, int rhs); 44 | 45 | bool is_constant_format (const ::VSVideoInfo &vi); 46 | bool has_chroma (int cf); 47 | bool has_chroma (const ::VSVideoFormat &fmt); 48 | bool is_chroma_plane (const ::VSVideoFormat &fmt, int plane_index); 49 | bool is_full_range_default (const ::VSVideoFormat &fmt); 50 | double compute_pix_scale (const ::VSVideoFormat &fmt, int plane_index, bool full_flag); 51 | double get_pix_min (const ::VSVideoFormat &fmt, int plane_index, bool full_flag); 52 | void compute_fmt_mac_cst (double &gain, double &add_cst, const ::VSVideoFormat &fmt_dst, bool full_dst_flag, const ::VSVideoFormat &fmt_src, bool full_src_flag, int plane_index); 53 | int compute_plane_width (const ::VSVideoFormat &fmt, int plane_index, int base_w); 54 | int compute_plane_height (const ::VSVideoFormat &fmt, int plane_index, int base_h); 55 | 56 | 57 | 58 | } // namespace vsutl 59 | 60 | 61 | 62 | //#include "vsutl/fnc.hpp" 63 | 64 | 65 | 66 | #endif // vsutl_fnc_HEADER_INCLUDED 67 | 68 | 69 | 70 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 71 | -------------------------------------------------------------------------------- /zip-release.bat: -------------------------------------------------------------------------------- 1 | 2 | @cd /d "%~dp0" 3 | 4 | @mkdir "releases" 5 | @if exist "releases\chickendream-rnew.zip" del "releases\chickendream-rnew.zip" 6 | @rmdir /s /q "reltmp" 7 | 8 | @mkdir "reltmp" 9 | @mkdir "reltmp\src" 10 | @mkdir "reltmp\build\unix\m4" 11 | @mkdir "reltmp\build\win\common" 12 | @mkdir "reltmp\build\win\chickendream" 13 | @mkdir "reltmp\build\win\test" 14 | @mkdir "reltmp\win32" 15 | @mkdir "reltmp\win64" 16 | @xcopy /I "doc" "reltmp\doc" 17 | @xcopy /I "src\avs" "reltmp\src\avs" 18 | @xcopy /I "src\avsutl" "reltmp\src\avsutl" 19 | @xcopy /I "src\chkdr" "reltmp\src\chkdr" 20 | @xcopy /I "src\chkdravs" "reltmp\src\chkdravs" 21 | @xcopy /I "src\chkdrvs" "reltmp\src\chkdrvs" 22 | @xcopy /I "src\fgrn" "reltmp\src\fgrn" 23 | @xcopy /I "src\fstb" "reltmp\src\fstb" 24 | @xcopy /I "src\test" "reltmp\src\test" 25 | @xcopy /I "src\vsutl" "reltmp\src\vsutl" 26 | @copy "src\*.cpp" "reltmp\src" 27 | @copy "src\*.h" "reltmp\src" 28 | @copy "src\*.hpp" "reltmp\src" 29 | @copy "build\unix\autogen.sh" "reltmp\build\unix" 30 | @copy "build\unix\configure.ac" "reltmp\build\unix" 31 | @copy "build\unix\Makefile.am" "reltmp\build\unix" 32 | @copy "build\unix\m4\ax_*.m4" "reltmp\build\unix\m4" 33 | @copy "build\win\*.sln" "reltmp\build\win" 34 | @copy "build\win\*.vcxproj" "reltmp\build\win" 35 | @copy "build\win\*.vcxproj.filters" "reltmp\build\win" 36 | @copy "build\win\*.props" "reltmp\build\win" 37 | @copy "build\win\common\*.vcxproj" "reltmp\build\win\common" 38 | @copy "build\win\common\*.vcxproj.filters" "reltmp\build\win\common" 39 | @copy "build\win\chickendream\*.vcxproj" "reltmp\build\win\chickendream" 40 | @copy "build\win\chickendream\*.vcxproj.filters" "reltmp\build\win\chickendream" 41 | @copy "build\win\chickendream\ReleaseWin32\chickendream.dll" "reltmp\win32" 42 | @copy "build\win\chickendream\Releasex64\chickendream.dll" "reltmp\win64" 43 | @copy "build\win\test\*.vcxproj" "reltmp\build\win\test" 44 | @copy "build\win\test\*.vcxproj.filters" "reltmp\build\win\test" 45 | @copy "*.md" "reltmp" 46 | @copy "COPYING" "reltmp" 47 | 48 | @cd reltmp 49 | 50 | del /S *.lo *.o *.dirstamp *.deps 51 | 52 | @echo chickendream - Realistic grain generator for Vapoursynth and Avisynth+ | "C:\Program Files (x86)\Infozip\zip.exe" -r -o -9 -z "..\releases\chickendream-rnew.zip" "*.*" 53 | @cd .. 54 | 55 | @rmdir /s /q "reltmp" 56 | 57 | @pause 58 | --------------------------------------------------------------------------------