├── .gitmodules ├── installer ├── template.vpy ├── MANIFEST.in └── make installers.bat ├── src ├── filters │ ├── avisource │ │ ├── stdafx.cpp │ │ ├── AVIReadHandler.cpp │ │ ├── stdafx.h │ │ ├── Compiling.txt │ │ ├── Avisynth.h │ │ ├── Fixes.h │ │ ├── AVIReadCache.h │ │ ├── FastReadStream.h │ │ ├── misc.h │ │ ├── DubSource.cpp │ │ ├── clip_info.h │ │ └── DubSource.h │ ├── subtext │ │ └── common.h │ ├── morpho │ │ ├── morpho_selems.h │ │ ├── morpho.h │ │ ├── morpho_filters.h │ │ └── morpho_selems.c │ └── removegrain │ │ └── shared.cpp ├── vfw │ └── vsvfw.def ├── core │ ├── settings.h │ ├── x86utils.h │ ├── vslog.h │ ├── kernel │ │ ├── cpulevel.h │ │ ├── cpulevel.cpp │ │ ├── average.h │ │ ├── planestats.h │ │ └── transpose.c │ ├── cpufeatures.h │ ├── version.h │ ├── internalfilters.h │ ├── intrusive_ptr.h │ └── expr │ │ └── main.cpp ├── vspipe │ ├── vspipe.manifest │ ├── vsjson.h │ ├── printgraph.h │ └── md5.h ├── avfs │ ├── assertive.cpp │ ├── ss.h │ ├── avfsincludes.h │ ├── avfs.rc │ ├── include │ │ ├── ptblob.h │ │ ├── pfmprefix.h │ │ └── pfmformatter.h │ ├── files.h │ ├── xxfs.h │ └── avfspfm.h ├── cython │ ├── vsscript.pxd │ └── vsscript_internal.pxd ├── vsscript │ └── vsscript_internal.h ├── common │ ├── vsutf16.h │ └── fourcc.h └── avisynth │ └── avs │ ├── minmax.h │ ├── types.h │ ├── win.h │ ├── capi.h │ └── config.h ├── docs_build.bat ├── autogen.sh ├── python-requirements.txt ├── doc ├── functions │ ├── audio │ │ ├── assumesamplerate.rst │ │ ├── setaudiocache.rst │ │ ├── splitchannels.rst │ │ ├── audioreverse.rst │ │ ├── audiotrim.rst │ │ ├── audiosplice.rst │ │ ├── audiogain.rst │ │ ├── audioloop.rst │ │ ├── blankaudio.rst │ │ ├── audiomix.rst │ │ └── shufflechannels.rst │ ├── video │ │ ├── turn180.rst │ │ ├── splitplanes.rst │ │ ├── text │ │ │ ├── framenum.rst │ │ │ ├── clipinfo.rst │ │ │ ├── frameprops.rst │ │ │ ├── coreinfo.rst │ │ │ └── text.rst │ │ ├── flipvertical_fliphorizontal.rst │ │ ├── duplicateframes.rst │ │ ├── deleteframes.rst │ │ ├── reverse.rst │ │ ├── boxblur.rst │ │ ├── proptoclip.rst │ │ ├── addborders.rst │ │ ├── splice.rst │ │ ├── setframeprops.rst │ │ ├── loop.rst │ │ ├── stackvertical_stackhorizontal.rst │ │ ├── copyframeprops.rst │ │ ├── pemverifier.rst │ │ ├── cliptoprop.rst │ │ ├── assumefps.rst │ │ ├── makediff.rst │ │ ├── mergediff.rst │ │ ├── removeframeprops.rst │ │ ├── premultiply.rst │ │ ├── transpose.rst │ │ ├── planestats.rst │ │ ├── median.rst │ │ ├── freezeframes.rst │ │ ├── trim.rst │ │ ├── separatefields.rst │ │ ├── crop_cropabs.rst │ │ ├── limiter.rst │ │ ├── invert_invertmask.rst │ │ ├── setfieldbased.rst │ │ ├── blankclip.rst │ │ ├── interleave.rst │ │ ├── prewitt_sobel.rst │ │ ├── doubleweave.rst │ │ ├── setframeprop.rst │ │ ├── merge.rst │ │ ├── selectevery.rst │ │ ├── setvideocache.rst │ │ ├── averageframes.rst │ │ ├── binarize_binarizemask.rst │ │ ├── lut.rst │ │ ├── levels.rst │ │ ├── lut2.rst │ │ ├── deflate_inflate.rst │ │ ├── maskedmerge.rst │ │ ├── modifyframe.rst │ │ ├── shuffleplanes.rst │ │ └── minimum_maximum.rst │ └── general │ │ ├── setmaxcpu.rst │ │ ├── loadallplugins.rst │ │ ├── loadplugin.rst │ │ └── loadpluginavs.rst ├── includedplugins.rst ├── custom │ └── css │ │ └── custom.css ├── index.rst ├── functions.rst ├── plugins │ ├── vinverse.rst │ ├── avisource.rst │ ├── morpho.rst │ └── misc.rst ├── gettingstarted.rst ├── introduction.rst └── applications.rst ├── MANIFEST.in ├── pc ├── vapoursynth.pc.in └── vapoursynth-script.pc.in ├── cython_build.bat ├── .codespellignore ├── .github └── workflows │ ├── codespell.yml │ ├── macos.yml │ └── linux.yml ├── .gitignore ├── test ├── log_test.py ├── expr_compiler │ ├── compiler_test.py │ ├── muvs_exprs.txt │ └── havs_exprs.txt ├── weakref_test.py ├── filter_test.py ├── zimgtest.py └── environment_test.py ├── msvc_project ├── EEDI3 │ └── EEDI3.vcxproj.filters ├── VIVTC │ └── VIVTC.vcxproj.filters ├── Vinverse │ └── Vinverse.vcxproj.filters ├── MiscFilters │ └── MiscFilters.vcxproj.filters ├── ExprDebugger │ └── ExprDebugger.vcxproj.filters ├── VSScript │ └── VSScript.vcxproj.filters ├── Morpho │ └── Morpho.vcxproj.filters ├── RemoveGrainVS │ └── RemoveGrainVS.vcxproj.filters ├── AvsCompat │ └── AvsCompat.vcxproj.filters ├── VSVFW │ └── VSVFW.vcxproj.filters └── VSPipe │ └── VSPipe.vcxproj.filters ├── README.md ├── include ├── VapourSynthC.h └── cython │ └── vapoursynth.h └── sdk └── filter_skeleton.c /.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /installer/template.vpy: -------------------------------------------------------------------------------- 1 | import vapoursynth as vs 2 | -------------------------------------------------------------------------------- /src/filters/avisource/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /docs_build.bat: -------------------------------------------------------------------------------- 1 | pushd doc 2 | call make html 3 | pause 4 | popd 5 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autoreconf --verbose --install --force 4 | -------------------------------------------------------------------------------- /python-requirements.txt: -------------------------------------------------------------------------------- 1 | setuptools 2 | wheel 3 | cython 4 | sphinx 5 | sphinx-intl 6 | -------------------------------------------------------------------------------- /installer/MANIFEST.in: -------------------------------------------------------------------------------- 1 | global-include *.dll portable.vs .keep VSPipe.exe 2 | global-exclude VapourSynth.dll 3 | -------------------------------------------------------------------------------- /src/vfw/vsvfw.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | EXPORTS 3 | DllGetClassObject PRIVATE 4 | DllCanUnloadNow PRIVATE 5 | 6 | -------------------------------------------------------------------------------- /src/core/settings.h: -------------------------------------------------------------------------------- 1 | #ifndef SETTINGS_H 2 | #define SETTINGS_H 3 | 4 | VSMap *readSettings(const std::string &path); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/filters/avisource/AVIReadHandler.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmusementClub/vapoursynth-classic/doodle2/src/filters/avisource/AVIReadHandler.cpp -------------------------------------------------------------------------------- /doc/functions/audio/assumesamplerate.rst: -------------------------------------------------------------------------------- 1 | AssumeSampleRate 2 | ================ 3 | 4 | .. function:: AssumeSampleRate(anode clip[, anode src, int samplerate]) 5 | :module: std 6 | -------------------------------------------------------------------------------- /installer/make installers.bat: -------------------------------------------------------------------------------- 1 | "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DInstallerBits=64 vsinstaller.iss 2 | "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DInstallerBits=32 vsinstaller.iss -------------------------------------------------------------------------------- /doc/functions/video/turn180.rst: -------------------------------------------------------------------------------- 1 | Turn180 2 | ======= 3 | 4 | .. function:: Turn180(vnode clip) 5 | :module: std 6 | 7 | Turns the frames in a clip 180 degrees (to the left, not to the right). 8 | -------------------------------------------------------------------------------- /doc/functions/video/splitplanes.rst: -------------------------------------------------------------------------------- 1 | SplitPlanes 2 | =========== 3 | 4 | .. function:: SplitPlanes(vnode clip) 5 | :module: std 6 | 7 | SplitPlanes returns each plane of the input as 8 | separate clips. 9 | -------------------------------------------------------------------------------- /doc/functions/audio/setaudiocache.rst: -------------------------------------------------------------------------------- 1 | SetAudioCache 2 | ============= 3 | 4 | .. function:: SetAudioCache(anode clip[, int mode, int fixedsize, int maxsize, int historysize]) 5 | :module: std 6 | 7 | see SetVideoCache 8 | -------------------------------------------------------------------------------- /doc/functions/audio/splitchannels.rst: -------------------------------------------------------------------------------- 1 | SplitChannels 2 | ============= 3 | 4 | .. function:: SplitChannels(anode clip) 5 | :module: std 6 | 7 | SplitChannels returns each audio channel of the input as 8 | a separate clip. 9 | -------------------------------------------------------------------------------- /doc/functions/video/text/framenum.rst: -------------------------------------------------------------------------------- 1 | FrameNum 2 | ======== 3 | 4 | .. function:: FrameNum(vnode clip[, int alignment=7, int scale=1]) 5 | :module: text 6 | 7 | Prints the current frame number. 8 | 9 | This is a convenience function for *Text*. 10 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include COPYING.LESSER 2 | 3 | recursive-include test * 4 | recursive-include src/cython *.pyx *.pxd 5 | recursive-include src/vsscript *.h 6 | recursive-include include *.h *.asm 7 | recursive-exclude include/cython * 8 | 9 | global-exclude *.dll 10 | -------------------------------------------------------------------------------- /doc/functions/video/flipvertical_fliphorizontal.rst: -------------------------------------------------------------------------------- 1 | FlipVertical/FlipHorizontal 2 | =========================== 3 | 4 | .. function:: FlipVertical(vnode clip) 5 | FlipHorizontal(vnode clip) 6 | :module: std 7 | 8 | Flips the *clip* in the vertical or horizontal direction. 9 | -------------------------------------------------------------------------------- /doc/functions/video/text/clipinfo.rst: -------------------------------------------------------------------------------- 1 | ClipInfo 2 | ======== 3 | 4 | .. function:: ClipInfo(vnode clip[, int alignment=7, int scale=1]]) 5 | :module: text 6 | 7 | Prints information about the *clip*, such as the format and framerate. 8 | 9 | This is a convenience function for *Text*. 10 | -------------------------------------------------------------------------------- /doc/includedplugins.rst: -------------------------------------------------------------------------------- 1 | Included Plugins 2 | ================ 3 | 4 | The source code for these plugins can be found in the VapourSynth source 5 | tree. Many of them are included in the Windows installer in DLL form. 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | :glob: 10 | 11 | plugins/* 12 | -------------------------------------------------------------------------------- /doc/functions/video/duplicateframes.rst: -------------------------------------------------------------------------------- 1 | DuplicateFrames 2 | =============== 3 | 4 | .. function:: DuplicateFrames(vnode clip, int[] frames) 5 | :module: std 6 | 7 | Duplicates the specified frames. 8 | 9 | A frame may be duplicated several times. 10 | 11 | All frame numbers apply to the input clip. 12 | -------------------------------------------------------------------------------- /doc/functions/video/deleteframes.rst: -------------------------------------------------------------------------------- 1 | DeleteFrames 2 | ============ 3 | 4 | .. function:: DeleteFrames(vnode clip, int[] frames) 5 | :module: std 6 | 7 | Deletes the specified frames. 8 | 9 | All frame numbers apply to the input clip. 10 | 11 | Returns an error if the same frame is deleted twice or if all frames in a clip are deleted. 12 | -------------------------------------------------------------------------------- /doc/functions/video/text/frameprops.rst: -------------------------------------------------------------------------------- 1 | FrameProps 2 | ========== 3 | 4 | .. function:: FrameProps(vnode clip[, string props=[], int alignment=7, int scale=1]) 5 | :module: text 6 | 7 | Prints all properties attached to the frames, or if the *props* array is 8 | given only those properties. 9 | 10 | This is a convenience function for *Text*. 11 | -------------------------------------------------------------------------------- /doc/functions/video/reverse.rst: -------------------------------------------------------------------------------- 1 | Reverse 2 | ======= 3 | 4 | .. function:: Reverse(vnode clip) 5 | :module: std 6 | 7 | Returns a clip with the frame or sample order reversed. For example, a clip with 3 8 | frames would have the frame order 2, 1, 0. 9 | 10 | In Python, std.Reverse can also be invoked by :ref:`slicing a clip `. 11 | -------------------------------------------------------------------------------- /pc/vapoursynth.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@/vapoursynth 5 | 6 | Name: vapoursynth 7 | Description: A frameserver for the 21st century 8 | Version: @VERSION@ 9 | 10 | Requires.private: zimg 11 | Libs: -L${libdir} -lvapoursynth 12 | Libs.private: @ZIMG_LIBS@ @DLOPENLIB@ 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /doc/functions/video/text/coreinfo.rst: -------------------------------------------------------------------------------- 1 | CoreInfo 2 | ======== 3 | 4 | .. function:: CoreInfo([vnode clip=std.BlankClip(), int alignment=7, int scale=1]) 5 | :module: text 6 | 7 | Prints information about the VapourSynth core, such as version and memory 8 | use. If no *clip* is supplied, a default blank one is used. 9 | 10 | This is a convenience function for *Text*. 11 | -------------------------------------------------------------------------------- /doc/functions/audio/audioreverse.rst: -------------------------------------------------------------------------------- 1 | AudioReverse 2 | ============ 3 | 4 | .. function:: AudioReverse(anode clip) 5 | :module: std 6 | 7 | Returns a clip with the frame or sample order reversed. For example, a clip with 3 8 | frames would have the frame order 2, 1, 0. 9 | 10 | In Python, std.AudioReverse can also be invoked by :ref:`slicing a clip `. 11 | -------------------------------------------------------------------------------- /doc/functions/audio/audiotrim.rst: -------------------------------------------------------------------------------- 1 | AudioTrim 2 | ========= 3 | 4 | .. function:: AudioTrim(anode clip[, int first=0, int last, int length]) 5 | :module: std 6 | 7 | AudioTrim performs exactly the same operation on audio clips but the unit is 8 | obviously samples instead of frames. 9 | 10 | In Python, std.AudioTrim can also be invoked by :ref:`slicing a clip `. 11 | -------------------------------------------------------------------------------- /doc/functions/video/boxblur.rst: -------------------------------------------------------------------------------- 1 | BoxBlur 2 | ======= 3 | 4 | .. function:: BoxBlur(vnode clip[, int[] planes, int hradius = 1, int hpasses = 1, int vradius = 1, int vpasses = 1]) 5 | :module: std 6 | 7 | Performs a box blur which is fast even for large radius values. Using multiple *passes* can be used to fairly cheaply 8 | approximate a gaussian blur. A *radius* of 0 means no processing is performed. 9 | -------------------------------------------------------------------------------- /doc/functions/video/proptoclip.rst: -------------------------------------------------------------------------------- 1 | PropToClip 2 | ========== 3 | 4 | .. function:: PropToClip(vnode clip[, string prop='_Alpha']) 5 | :module: std 6 | 7 | Extracts a clip from the frames attached to the frame property *prop* in 8 | *clip*. 9 | This function is mainly used to extract a mask/alpha clip that was stored in 10 | another one. 11 | 12 | It is the inverse of ClipToProp(). 13 | -------------------------------------------------------------------------------- /doc/functions/video/addborders.rst: -------------------------------------------------------------------------------- 1 | AddBorders 2 | ========== 3 | 4 | .. function:: AddBorders(vnode clip[, int left=0, int right=0, int top=0, int bottom=0, float[] color=]) 5 | :module: std 6 | 7 | Adds borders to frames. The arguments specify the number of pixels to add on 8 | each side. They must obey the subsampling restrictions. 9 | The newly added borders will be set to *color*. 10 | -------------------------------------------------------------------------------- /doc/custom/css/custom.css: -------------------------------------------------------------------------------- 1 | .wy-nav-content { 2 | max-width: none; 3 | padding: 1.618em 4.854em; 4 | } 5 | /* margin */ 6 | h2, h3, h4, h5, h6 { 7 | margin-top: 32px !important; 8 | } 9 | /* decoration */ 10 | h1, h2, h3, h4, h5, h6 { 11 | color: #3465a4; 12 | } 13 | h2 { 14 | padding-bottom: 6px; 15 | border-bottom: 2px solid #3465a4; 16 | } 17 | h4, h5, h6 { 18 | font-weight: 400; 19 | } 20 | -------------------------------------------------------------------------------- /cython_build.bat: -------------------------------------------------------------------------------- 1 | rmdir /s /q build 2 | del vapoursynth.*.pyd 3 | del /q dist\*.whl 4 | py.exe -3.9-32 setup.py build_ext --inplace 5 | py.exe -3.9-32 setup.py bdist_wheel 6 | py.exe -3.9 setup.py build_ext --inplace 7 | py.exe -3.9 setup.py bdist_wheel 8 | py.exe -3.8-32 setup.py build_ext --inplace 9 | py.exe -3.8-32 setup.py bdist_wheel 10 | py.exe -3.8 setup.py build_ext --inplace 11 | py.exe -3.8 setup.py bdist_wheel 12 | pause 13 | -------------------------------------------------------------------------------- /doc/functions/video/splice.rst: -------------------------------------------------------------------------------- 1 | Splice 2 | ====== 3 | 4 | .. function:: Splice(vnode[] clips[, bint mismatch=0]) 5 | :module: std 6 | 7 | Returns a clip with all *clips* appended in the given order. 8 | 9 | Splicing clips with different formats or dimensions is 10 | considered an error unless *mismatch* is true. 11 | 12 | In Python, std.Splice can also be invoked :ref:`using the addition operator `. 13 | -------------------------------------------------------------------------------- /doc/functions/general/setmaxcpu.rst: -------------------------------------------------------------------------------- 1 | SetMaxCPU 2 | ========= 3 | 4 | .. function:: SetMaxCPU(string cpu) 5 | :module: std 6 | 7 | This function is only intended for testing and debugging purposes 8 | and sets the maximum used instruction set for optimized functions. 9 | 10 | Possible values for x86: "avx2", "sse2", "none" 11 | 12 | Other platforms: "none" 13 | 14 | By default all supported cpu features are used. -------------------------------------------------------------------------------- /pc/vapoursynth-script.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@/vapoursynth 5 | 6 | Name: vapoursynth-script 7 | Description: Library for interfacing VapourSynth with Python 8 | Version: @VERSION@ 9 | 10 | Requires: vapoursynth 11 | Requires.private: python-@PYTHON_VERSION@ 12 | Libs: -L${libdir} -lvapoursynth-script 13 | Libs.private: @PYTHON3_LIBS@ 14 | Cflags: -I${includedir} 15 | -------------------------------------------------------------------------------- /doc/functions/audio/audiosplice.rst: -------------------------------------------------------------------------------- 1 | AudioSplice 2 | =========== 3 | 4 | .. function:: AudioSplice(anode[] clips) 5 | :module: std 6 | 7 | Returns a clip with all *clips* appended in the given order. 8 | 9 | Splicing clips with different formats or dimensions is 10 | considered an error unless *mismatch* is true. 11 | 12 | In Python, std.AudioSplice can also be invoked :ref:`using the addition operator `. 13 | -------------------------------------------------------------------------------- /doc/functions/video/setframeprops.rst: -------------------------------------------------------------------------------- 1 | SetFrameProps 2 | ============= 3 | 4 | .. function:: SetFrameProps(vnode clip, ...) 5 | :module: std 6 | 7 | Adds the specified values as a frame property of every frame 8 | in *clip*. If a frame property with the same key already exists 9 | it will be replaced. 10 | 11 | For example, to set the field order to top field first:: 12 | 13 | clip = c.std.SetFrameProps(clip, _FieldBased=2) 14 | -------------------------------------------------------------------------------- /doc/functions/audio/audiogain.rst: -------------------------------------------------------------------------------- 1 | AudioGain 2 | ========= 3 | 4 | .. function:: AudioGain(anode clip, float[] gain) 5 | :module: std 6 | 7 | AudioGain can either change the volume of individual channels 8 | if a separate *gain* for each channel is given or if only a single 9 | *gain* value is supplied it's applied to all channels. 10 | 11 | Negative *gain* values are allowed. Applying a too large gain will 12 | lead to clipping in integer formats. -------------------------------------------------------------------------------- /doc/functions/video/loop.rst: -------------------------------------------------------------------------------- 1 | Loop 2 | ==== 3 | 4 | .. function:: Loop(vnode clip[, int times=0]) 5 | :module: std 6 | 7 | Returns a clip with the frames or samples repeated over and over again. If *times* is 8 | less than 1 the clip will be repeated until the maximum clip length is 9 | reached, otherwise it will be repeated *times* times. 10 | 11 | In Python, std.Loop can also be invoked :ref:`using the multiplication operator `. 12 | -------------------------------------------------------------------------------- /src/filters/subtext/common.h: -------------------------------------------------------------------------------- 1 | #ifndef SUBTEXT_COMMON_H 2 | #define SUBTEXT_COMMON_H 3 | 4 | #include 5 | 6 | #include "VapourSynth4.h" 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | void blendSubtitles(VSNode *clip, VSNode *subs, const VSMap *in, VSMap *out, const char *filter_name, char *error, size_t error_size, VSCore *core, const VSAPI *vsapi); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif // SUBTEXT_COMMON_H 19 | -------------------------------------------------------------------------------- /doc/functions/audio/audioloop.rst: -------------------------------------------------------------------------------- 1 | AudioLoop 2 | ========= 3 | 4 | .. function:: AudioLoop(anode clip[, int times=0]) 5 | :module: std 6 | 7 | Returns a clip with the frames or samples repeated over and over again. If *times* is 8 | less than 1 the clip will be repeated until the maximum clip length is 9 | reached, otherwise it will be repeated *times* times. 10 | 11 | In Python, std.AudioLoop can also be invoked :ref:`using the multiplication operator `. 12 | -------------------------------------------------------------------------------- /src/vspipe/vspipe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | true 7 | 8 | 9 | -------------------------------------------------------------------------------- /doc/functions/video/stackvertical_stackhorizontal.rst: -------------------------------------------------------------------------------- 1 | StackVertical/StackHorizontal 2 | ============================= 3 | 4 | .. function:: StackVertical(vnode[] clips) 5 | StackHorizontal(vnode[] clips) 6 | :module: std 7 | 8 | Stacks all given *clips* together. The same format is a requirement. For 9 | StackVertical all clips also need to be the same width and for 10 | StackHorizontal all clips need to be the same height. 11 | 12 | The frame properties are copied from the first clip. 13 | -------------------------------------------------------------------------------- /.codespellignore: -------------------------------------------------------------------------------- 1 | static bool funcToLut(int nin, int nout, void *vlut, VSFunction *func, const VSAPI *vsapi, std::string &errstr) { 2 | for (int i = 0; i < nin; i++) { 3 | std::string aLine = nstringToUtf8(argv[arg + 1]).c_str(); 4 | size_t equalsPos = aLine.find("="); 5 | fprintf(stderr, "No value specified for argument: %s\n", aLine.c_str()); 6 | opts.scriptArgs[aLine.substr(0, equalsPos)] = aLine.substr(equalsPos + 1); 7 | ba bb bc bd be bf bg bh bi bj bk bl bm bn bo bp 8 | -------------------------------------------------------------------------------- /src/filters/avisource/stdafx.h: -------------------------------------------------------------------------------- 1 | #ifndef __Stdafx_H__ 2 | #define __Stdafx_H__ 3 | 4 | //C 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | //windows 15 | #define WIN32_LEAN_AND_MEAN 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | //STL 23 | #include 24 | #include 25 | 26 | #endif // __Stdafx_H__ 27 | -------------------------------------------------------------------------------- /.github/workflows/codespell.yml: -------------------------------------------------------------------------------- 1 | name: codespell 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | codespell: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | 12 | - uses: codespell-project/actions-codespell@master 13 | with: 14 | exclude_file: .codespellignore 15 | skip: ./src/avfs/include,./src/avisynth/avisynth.h,./src/avisynth/interface.cpp,./src/core/ter-116n.h,./src/core/expr/jitasm.h,./src/filters/vivtc/vivtc.c,./src/filters/subtext/text.c,./src/common/nvtx3/*,./src/common/nvtx3/*/* 16 | -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to `VapourSynth-Classic `_’s documentation! 2 | ========================================================================================= 3 | 4 | Contents: 5 | 6 | .. toctree:: 7 | :maxdepth: 3 8 | 9 | introduction 10 | installation 11 | gettingstarted 12 | pythonreference 13 | functions 14 | output 15 | applications 16 | avisynthcomp 17 | includedplugins 18 | apireference 19 | 20 | 21 | Indices and tables 22 | ================== 23 | 24 | * :ref:`genindex` 25 | * :ref:`search` 26 | -------------------------------------------------------------------------------- /doc/functions/general/loadallplugins.rst: -------------------------------------------------------------------------------- 1 | LoadAllPlugins 2 | ============== 3 | 4 | .. function:: LoadAllPlugins(string path) 5 | :module: std 6 | 7 | Loads all native VapourSynth plugins found in the 8 | specified *path*. Plugins that fail to load are 9 | silently skipped. 10 | 11 | Beware of Python's escape character, this will fail:: 12 | 13 | LoadAllPlugins(path='c:\plugins') 14 | 15 | Correct ways:: 16 | 17 | LoadAllPlugins(path='c:/plugins') 18 | LoadAllPlugins(path=r'c:\plugins') 19 | LoadAllPlugins(path='c:\\plugins\\') 20 | -------------------------------------------------------------------------------- /src/avfs/assertive.cpp: -------------------------------------------------------------------------------- 1 | #include "assertive.h" 2 | #include 3 | #define WIN32_LEAN_AND_MEAN 4 | #include 5 | 6 | void AssertHandler(const char* file,int line,const char* expr) 7 | { 8 | static const size_t maxScratchChars = 300; 9 | char scratch[maxScratchChars] = ""; 10 | snprintf(scratch,maxScratchChars,"ASSERT: %s:%i \"%s\"\n",file,line, 11 | expr); 12 | scratch[maxScratchChars-1] = 0; 13 | MessageBoxA(0,scratch,"AVFS ASSERT",MB_OK); 14 | TRAP; 15 | TerminateProcess(GetCurrentProcess(),static_cast(-1)); 16 | } 17 | -------------------------------------------------------------------------------- /doc/functions.rst: -------------------------------------------------------------------------------- 1 | Function Reference 2 | ================== 3 | 4 | General Functions 5 | ################# 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | :glob: 10 | 11 | functions/general/* 12 | 13 | Video Functions 14 | ############### 15 | 16 | .. toctree:: 17 | :maxdepth: 2 18 | :glob: 19 | 20 | functions/video/* 21 | 22 | Text 23 | **** 24 | 25 | .. toctree:: 26 | :maxdepth: 2 27 | :glob: 28 | 29 | functions/video/text/* 30 | 31 | Audio Functions 32 | ############### 33 | 34 | .. toctree:: 35 | :maxdepth: 2 36 | :glob: 37 | 38 | functions/audio/* 39 | -------------------------------------------------------------------------------- /doc/functions/video/copyframeprops.rst: -------------------------------------------------------------------------------- 1 | CopyFrameProps 2 | ============== 3 | 4 | .. function:: CopyFrameProps(vnode clip, vnode prop_src[, string[] props]) 5 | :module: std 6 | 7 | Returns *clip* but with all the frame properties replaced with the 8 | ones from the clip in *prop_src*. Note that if *clip* is longer 9 | than *prop_src* then the last source frame's properties will be 10 | used instead. 11 | 12 | If *props* is set only the specified properties will be copied. If 13 | the *prop_src* doesn't have the property it is deleted. In this mode 14 | all other properties in *clip* remain unchanged. 15 | -------------------------------------------------------------------------------- /doc/functions/video/pemverifier.rst: -------------------------------------------------------------------------------- 1 | PEMVerifier 2 | =========== 3 | 4 | .. function:: PEMVerifier(vnode clip[, float[] upper, float[] lower]) 5 | :module: std 6 | 7 | The *PEMVerifier* is used to check for out-of-bounds pixel values during filter 8 | development. It is a public function so badly coded filters won't go 9 | unnoticed. 10 | 11 | If no values are set, then *upper* and *lower* default to the max and min values 12 | allowed in the current format. If an out of bounds value is 13 | encountered a frame error is set and the coordinates of the first bad pixel 14 | are included in the error message. 15 | -------------------------------------------------------------------------------- /doc/functions/video/cliptoprop.rst: -------------------------------------------------------------------------------- 1 | ClipToProp 2 | ========== 3 | 4 | .. function:: ClipToProp(vnode clip, vnode mclip[, string prop='_Alpha']) 5 | :module: std 6 | 7 | Stores each frame of *mclip* as a frame property named *prop* in *clip*. This 8 | is primarily intended to attach mask/alpha clips to another clip so that 9 | editing operations will apply to both. Unlike most other filters the output 10 | length is derived from the second argument named *mclip*. 11 | 12 | If the attached *mclip* does not represent the alpha channel, you should set 13 | *prop* to something else. 14 | 15 | It is the inverse of PropToClip(). 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | doc/_build/* 3 | 4 | *.pyc 5 | __pycache__ 6 | 7 | src/cython/vapoursynth.c 8 | src/cython/vapoursynth.h 9 | src/cython/vapoursynth_api.h 10 | 11 | *.o 12 | *.la 13 | *.lo 14 | *.so 15 | *.dll 16 | .libs 17 | .deps/ 18 | .dirstamp 19 | Makefile 20 | Makefile.in 21 | aclocal.m4 22 | autom4te.cache 23 | compile 24 | config.guess 25 | config.log 26 | config.status 27 | config.sub 28 | configure 29 | depcomp 30 | install-sh 31 | libtool 32 | ltmain.sh 33 | missing 34 | *.pc 35 | 36 | dist/ 37 | .eggs 38 | *.egg-info/ 39 | 40 | zimg/ 41 | AviSynthPlus 42 | 43 | *.log 44 | *.user 45 | x64 46 | Debug 47 | Release 48 | msvc_project/.vs 49 | -------------------------------------------------------------------------------- /doc/functions/video/assumefps.rst: -------------------------------------------------------------------------------- 1 | AssumeFPS 2 | ========= 3 | 4 | .. function:: AssumeFPS(vnode clip[, vnode src, int fpsnum, int fpsden=1]) 5 | :module: std 6 | 7 | Returns a clip with the framerate changed. This does not in any way modify 8 | the frames, only their metadata. 9 | 10 | The framerate to assign can either be read from another clip, *src*, or given 11 | as a rational number with *fpsnum* and *fpsden*. 12 | 13 | It is an error to specify both *src* and *fpsnum*. 14 | 15 | AssumeFPS overwrites the frame properties ``_DurationNum`` and 16 | ``_DurationDen`` with the frame duration computed from the new frame rate. 17 | -------------------------------------------------------------------------------- /doc/functions/video/makediff.rst: -------------------------------------------------------------------------------- 1 | MakeDiff 2 | ======== 3 | 4 | .. function:: MakeDiff(vnode clipa, vnode clipb[, int[] planes]) 5 | :module: std 6 | 7 | Calculates the difference between *clipa* and *clipb* and clamps the result. 8 | By default all *planes* are processed. This function is usually used together with *MergeDiff*, which can be used to add back the difference. 9 | 10 | Unsharp masking of luma:: 11 | 12 | blur_clip = core.std.Convolution(clip, matrix=[1, 2, 1, 2, 4, 2, 1, 2, 1], planes=[0]) 13 | diff_clip = core.std.MakeDiff(clip, blur_clip, planes=[0]) 14 | sharpened_clip = core.std.MergeDiff(clip, diff_clip, planes=[0]) 15 | 16 | -------------------------------------------------------------------------------- /doc/functions/video/mergediff.rst: -------------------------------------------------------------------------------- 1 | MergeDiff 2 | ========= 3 | 4 | .. function:: MergeDiff(vnode clipa, vnode clipb[, int[] planes]) 5 | :module: std 6 | 7 | Merges back the difference in *clipb* to *clipa* and clamps the result. 8 | By default all *planes* are processed. This function is usually used together with *MakeDiff*, which is normally used to calculate the difference. 9 | 10 | Unsharp masking of luma:: 11 | 12 | blur_clip = core.std.Convolution(clip, matrix=[1, 2, 1, 2, 4, 2, 1, 2, 1], planes=[0]) 13 | diff_clip = core.std.MakeDiff(clip, blur_clip, planes=[0]) 14 | sharpened_clip = core.std.MergeDiff(clip, diff_clip, planes=[0]) 15 | 16 | -------------------------------------------------------------------------------- /doc/functions/video/removeframeprops.rst: -------------------------------------------------------------------------------- 1 | RemoveFrameProps 2 | ================ 3 | 4 | .. function:: RemoveFrameProps(vnode clip[, string props[]]) 5 | :module: std 6 | 7 | Returns *clip* but with all the frame properties named in 8 | *props* removed. If *props* is unset them all frame properties 9 | are removed. 10 | 11 | Note that *props* accepts wildcards (* and ?) which can be very 12 | useful if you for example only want to clear properties set by 13 | a single filter since they're usually prefixed such as VFM\* or 14 | _\* can be used as a shorthand to conveniently clear only 15 | the internally reserved properties (colorimetry, time, 16 | field structure). 17 | -------------------------------------------------------------------------------- /doc/functions/video/premultiply.rst: -------------------------------------------------------------------------------- 1 | PreMultiply 2 | =========== 3 | 4 | .. function:: PreMultiply(vnode clip, vnode alpha) 5 | :module: std 6 | 7 | PreMultiply simply multiplies *clip* and *alpha* in order to make it more suitable for 8 | later operations. This will yield much better results when resizing and a clip with an 9 | alpha channel and :doc:`MaskedMerge ` can use it as input. The *alpha* clip 10 | must be the grayscale format equivalent of *clip*. 11 | 12 | Note that limited range pre-multiplied contents excludes the offset. For example with 13 | 8 bit input 60 luma and 128 alpha would be calculated as ((60 - 16) * 128)/255 + 16 14 | and not (60 * 128)/255. -------------------------------------------------------------------------------- /doc/functions/video/transpose.rst: -------------------------------------------------------------------------------- 1 | Transpose 2 | ========= 3 | 4 | .. function:: Transpose(vnode clip) 5 | :module: std 6 | 7 | Flips the contents of the frames in the same way as a matrix transpose would 8 | do. Combine it with FlipVertical or FlipHorizontal to synthesize a left or 9 | right rotation. Calling Transpose twice in a row is the same as doing nothing 10 | (but slower). 11 | 12 | Here is a picture to illustrate what Transpose does:: 13 | 14 | 0 5 55 15 | 0 1 1 2 3 1 8 89 16 | 5 8 13 21 34 => 1 13 144 17 | 55 89 144 233 377 2 21 233 18 | 3 34 377 19 | -------------------------------------------------------------------------------- /doc/plugins/vinverse.rst: -------------------------------------------------------------------------------- 1 | .. _vinverse: 2 | 3 | Vinverse 4 | ======== 5 | 6 | Vinverse is a simple filter to remove residual combing, based on 7 | `an AviSynth script by Didée `_. 8 | 9 | .. function:: Vinverse(clip clip[, float sstr=2.7, int amnt=255, float scl=0.25]) 10 | :module: vinverse 11 | 12 | Parameters: 13 | clip 14 | Clip to be processed. The bit depth must be 8 bits per sample. 15 | 16 | sstr 17 | Strength of contra sharpening. 18 | 19 | amnt 20 | Change no pixel by more than this. Valid range is [0, 255]. 21 | 22 | scl 23 | Scale factor for VshrpD * VblurD < 0. 24 | -------------------------------------------------------------------------------- /doc/functions/video/planestats.rst: -------------------------------------------------------------------------------- 1 | PlaneStats 2 | ========== 3 | 4 | .. function:: PlaneStats(vnode clipa[, vnode clipb, int plane=0, string prop='PlaneStats']) 5 | :module: std 6 | 7 | This function calculates the min, max and average normalized value of all 8 | the pixels in the specified *plane* and stores the values in the frame properties 9 | named *prop*\ Min, *prop*\ Max and *prop*\ Average. 10 | 11 | If *clipb* is supplied, the absolute normalized difference between the two clips 12 | will be stored in *prop*\ Diff as well. 13 | 14 | The normalization means that the average and the diff will always be floats 15 | between 0 and 1, no matter what the input format is. 16 | -------------------------------------------------------------------------------- /doc/functions/video/median.rst: -------------------------------------------------------------------------------- 1 | Median 2 | ====== 3 | 4 | .. function:: Median(vnode clip[, int[] planes=[0, 1, 2]]) 5 | :module: std 6 | 7 | Replaces each pixel with the median of the nine pixels in its 3x3 8 | neighbourhood. In other words, the nine pixels are sorted from lowest 9 | to highest, and the middle value is picked. 10 | 11 | *clip* 12 | Clip to process. It must have integer sample type and bit depth 13 | between 8 and 16, or float sample type and bit depth of 32. If 14 | there are any frames with other formats, an error will be 15 | returned. 16 | 17 | *planes* 18 | Specifies which planes will be processed. Any unprocessed planes 19 | will be simply copied. 20 | -------------------------------------------------------------------------------- /doc/functions/video/freezeframes.rst: -------------------------------------------------------------------------------- 1 | FreezeFrames 2 | ============ 3 | 4 | .. function:: FreezeFrames(vnode clip, int[] first, int[] last, int[] replacement) 5 | :module: std 6 | 7 | FreezeFrames replaces all the frames in the [*first*,\ *last*] range 8 | (inclusive) with *replacement*. 9 | 10 | A single call to FreezeFrames can freeze any number of ranges:: 11 | 12 | core.std.FreezeFrames(input, first=[0, 100, 231], last=[15, 112, 300], replacement=[8, 50, 2]) 13 | 14 | This replaces [0,15] with 8, [100,112] with 50, and [231,300] with 2 (the 15 | original frame number 2, not frame number 2 after it was replaced with 16 | number 8 by the first range). 17 | 18 | The frame ranges must not overlap. 19 | -------------------------------------------------------------------------------- /src/avfs/ss.h: -------------------------------------------------------------------------------- 1 | 2 | // Null ptr and buffer overflow safe C string primitives. 3 | 4 | inline const wchar_t* ssfix(const wchar_t* s) { return s?s:L""; } 5 | inline size_t sslen(const wchar_t* s) { return s?wcslen(s):0; } 6 | inline size_t sslen(const char* s) { return s?strlen(s):0; } 7 | wchar_t* ssalloc(size_t count); 8 | wchar_t* ssdup(const wchar_t* s); 9 | wchar_t* ssdupn(const wchar_t* s,size_t len); 10 | int sscmpi(const wchar_t* s1,const wchar_t* s2); 11 | wchar_t* ssrchr(const wchar_t* s,wchar_t c); 12 | void ssvformat(wchar_t* dest,size_t maxDestChars,const wchar_t* format,va_list args); 13 | void ssformat(wchar_t* dest,size_t maxDestChars,const wchar_t* format,...); 14 | wchar_t* ssvformatalloc(const wchar_t* format,va_list args); 15 | -------------------------------------------------------------------------------- /src/filters/avisource/Compiling.txt: -------------------------------------------------------------------------------- 1 | The code was derived from virtualdub 1.10.3 test 8 so use that as a starting point for diffs if you want to try to update the included files. 2 | Most files are copied unchanged or only had some logging commented out, the biggest exception being misc.cpp where large parts were stripped out. 3 | 4 | To compile it you need a full copy of the vdub source. First compile only the system project in the vdub solution. It is needed to link to later. 5 | 6 | Then add all source files to a project. 7 | Add the h directory from the vdub source and the vapoursynth include directory to your includes. 8 | Add system.lib from the previous step vfw32.lib and winmm.lib to the linker inputs. 9 | 10 | Debug compiles will fail to link. 11 | -------------------------------------------------------------------------------- /test/log_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import vapoursynth as vs 3 | 4 | class LogTestSequence(unittest.TestCase): 5 | 6 | def setUp(self): 7 | self.core = vs.core 8 | self.handle = self.core.add_log_handler(lambda message_type, message : print(str(message_type) + ' ' + message)) 9 | 10 | 11 | ########################################################################## 12 | # Tests start here 13 | 14 | def test_log(self): 15 | self.core.log_message(vs.MESSAGE_TYPE_INFORMATION, 'hello!') 16 | self.core.remove_log_handler(self.handle) 17 | self.handle = None 18 | self.core.log_message(vs.MESSAGE_TYPE_INFORMATION, 'not hello!') 19 | 20 | if __name__ == '__main__': 21 | unittest.main() 22 | -------------------------------------------------------------------------------- /doc/functions/video/trim.rst: -------------------------------------------------------------------------------- 1 | Trim 2 | ==== 3 | 4 | .. function:: Trim(vnode clip[, int first=0, int last, int length]) 5 | :module: std 6 | 7 | Trim returns a clip with only the frames between the arguments *first* and 8 | *last*, or a clip of *length* frames, starting at *first*. 9 | Trim is inclusive so Trim(clip, first=3, last=3) will return one frame. If 10 | neither *last* nor *length* is specified, no frames are removed from the end 11 | of the clip. 12 | 13 | Specifying both *last* and *length* is considered to be an error. 14 | Likewise is calling Trim in a way that returns no frames, as 0 frame clips are 15 | not allowed in VapourSynth. 16 | 17 | In Python, std.Trim can also be invoked by :ref:`slicing a clip `. 18 | -------------------------------------------------------------------------------- /src/avfs/avfsincludes.h: -------------------------------------------------------------------------------- 1 | #include "assertive.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include "ss.h" 21 | namespace avs { 22 | #include 23 | } 24 | #include "avfspfm.h" 25 | #include "xxfs.h" 26 | #include "avfs.h" 27 | #include "vsfs.h" 28 | #include "videoinfoadapter.h" 29 | #include "../common/fourcc.h" 30 | #include "../common/wave.h" 31 | #include "../common/vsutf16.h" 32 | using namespace vsh; -------------------------------------------------------------------------------- /doc/functions/video/separatefields.rst: -------------------------------------------------------------------------------- 1 | SeparateFields 2 | ============== 3 | 4 | .. function:: SeparateFields(vnode clip[, bint tff, bint modify_duration=True]) 5 | :module: std 6 | 7 | Returns a clip with the fields separated and interleaved. 8 | 9 | The *tff* argument only has an effect when the field order isn't set for a frame. 10 | Setting *tff* to true means top field first and false means bottom field 11 | first. 12 | 13 | If *modify_duration* is set then the output clip's frame rate is double that of the input clip. 14 | The frame durations will also be halved. 15 | 16 | The ``_FieldBased`` frame property is deleted. The ``_Field`` frame 17 | property is added. 18 | 19 | If no field order is specified in ``_FieldBased`` or *tff* an error 20 | will be returned. 21 | -------------------------------------------------------------------------------- /doc/functions/video/crop_cropabs.rst: -------------------------------------------------------------------------------- 1 | Crop/CropAbs 2 | =============== 3 | 4 | .. function:: Crop(vnode clip[, int left=0, int right=0, int top=0, int bottom=0]) 5 | CropAbs(vnode clip, int width, int height[, int left=0, int top=0]) 6 | :module: std 7 | 8 | Crops the frames in a clip. 9 | 10 | Crop is the simplest to use of the two. The arguments specify how many 11 | pixels to crop from each side. This function used to be called CropRel 12 | which is still an alias for it. 13 | 14 | CropAbs, on the other hand, is special, because it can accept clips with 15 | variable frame sizes and crop out a fixed size area, thus making it a fixed 16 | size clip. 17 | 18 | Both functions return an error if the whole picture is cropped away, if the 19 | cropped area extends beyond the input or if the subsampling restrictions 20 | aren't met. 21 | -------------------------------------------------------------------------------- /test/expr_compiler/compiler_test.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | 4 | EXPR_DEBUGGER_PATH = os.path.realpath(os.path.dirname(__file__) + \ 5 | "../../../msvc_project/x64/Debug/ExprDebugger.exe") 6 | 7 | TEST_CASES = ['havs_exprs.txt', 'muvs_exprs.txt'] 8 | OUTPUT = 'compiler_output.txt' 9 | 10 | def main(): 11 | with open(OUTPUT, 'wb') as o: 12 | for test_file in TEST_CASES: 13 | where = os.path.realpath(os.path.dirname(__file__) + "/" + 14 | test_file) 15 | with open(where, 'r') as file: 16 | for line in file: 17 | result = subprocess.check_output([EXPR_DEBUGGER_PATH, line], 18 | creationflags=0x08000000) 19 | o.write(result) 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /doc/functions/video/limiter.rst: -------------------------------------------------------------------------------- 1 | Limiter 2 | ======= 3 | 4 | .. function:: Limiter(vnode clip[, float[] min, float[] max, int[] planes=[0, 1, 2]]) 5 | :module: std 6 | 7 | Limits the pixel values to the range [*min*, *max*]. 8 | 9 | *clip* 10 | Clip to process. It must have integer sample type and bit depth 11 | between 8 and 16, or float sample type and bit depth of 32. If 12 | there are any frames with other formats, an error will be 13 | returned. 14 | 15 | *min* 16 | Lower bound. Defaults to the lowest allowed value for the input. Can be specified for each plane individually. 17 | 18 | *max* 19 | Upper bound. Defaults to the highest allowed value for the input. Can be specified for each plane individually. 20 | 21 | *planes* 22 | Specifies which planes will be processed. Any unprocessed planes 23 | will be simply copied. 24 | -------------------------------------------------------------------------------- /doc/functions/video/invert_invertmask.rst: -------------------------------------------------------------------------------- 1 | Invert/InvertMask 2 | ================= 3 | 4 | .. function:: Invert(vnode clip[, int[] planes=[0, 1, 2]]) 5 | InvertMask(vnode clip[, int[] planes=[0, 1, 2]]) 6 | :module: std 7 | 8 | Inverts the pixel values. Specifically, it subtracts the value of the 9 | input pixel from the format's maximum allowed value. The *InvertMask* 10 | version is intended for use on mask clips where all planes have the 11 | same maximum value regardless of the colorspace. 12 | 13 | *clip* 14 | Clip to process. It must have integer sample type and bit depth 15 | between 8 and 16, or float sample type and bit depth of 32. If 16 | there are any frames with other formats, an error will be 17 | returned. 18 | 19 | *planes* 20 | Specifies which planes will be processed. Any unprocessed planes 21 | will be simply copied. 22 | -------------------------------------------------------------------------------- /doc/functions/video/setfieldbased.rst: -------------------------------------------------------------------------------- 1 | SetFieldBased 2 | ============= 3 | 4 | .. function:: SetFieldBased(vnode clip, int value) 5 | :module: std 6 | 7 | This is a convenience function. See *SetFrameProps* if you want to 8 | set other properties. 9 | 10 | SetFieldBased sets ``_FieldBased`` to *value* and deletes 11 | the ``_Field`` frame property. The possible values are: 12 | 13 | 0 = Frame Based 14 | 15 | 1 = Bottom Field First 16 | 17 | 2 = Top Field First 18 | 19 | For example, if you have source material that's progressive but has 20 | been encoded as interlaced you can set it to be treated as frame based 21 | (not interlaced) to improve resizing quality:: 22 | 23 | clip = core.lsmas.LWLibavSource("rule6.mkv") 24 | clip = core.std.SetFieldBased(clip, 0) 25 | clip = clip.resize.Bilinear(clip, width=320, height=240) 26 | -------------------------------------------------------------------------------- /doc/plugins/avisource.rst: -------------------------------------------------------------------------------- 1 | .. _avisource: 2 | 3 | AVISource 4 | ========= 5 | 6 | .. function:: AVISource(string path[, string pixel_type, string fourcc, bint alpha=False]) 7 | :module: avisource 8 | 9 | .. function:: AVIFileSource(string path[, string pixel_type, string fourcc, bint alpha=False]) 10 | :module: avisource 11 | 12 | .. function:: OpenDMLSource(string path[, string pixel_type, string fourcc, bint alpha=False]) 13 | :module: avisource 14 | 15 | Opens an AVI file using VFW in windows. *AVISource* should usually be 16 | the only function you have to use. 17 | 18 | The only two options are *fourcc*, which overrides the fourcc stored 19 | in the AVI, and *pixel_type*, which tells the decoder to prefer 20 | a certain output format. 21 | 22 | Accepted *pixel_type* values:: 23 | 24 | YV24, YV16, YV12, YV411, YUY2, Y8, RGB32, RGB24, RGB48, P010, P016, P210, P216, v210 25 | -------------------------------------------------------------------------------- /doc/functions/video/blankclip.rst: -------------------------------------------------------------------------------- 1 | BlankClip 2 | ========= 3 | 4 | .. function:: BlankClip([vnode clip, int width=640, int height=480, int format=vs.RGB24, int length=(10*fpsnum)/fpsden, int fpsnum=24, int fpsden=1, float[] color=, bint keep=0]) 5 | :module: std 6 | 7 | Generates a new empty clip. This can be useful to have when editing video or 8 | for testing. The default is a 640x480 RGB24 24fps 10 second long black clip. 9 | Instead of specifying every property individually, BlankClip can also copy 10 | the properties from *clip*. If both an argument such as *width*, and *clip* 11 | are set, then *width* will take precedence. 12 | 13 | If *keep* is set, a reference to the same frame is returned on every request. 14 | Otherwise a new frame is generated every time. There should usually be no 15 | reason to change this setting. 16 | 17 | It is never an error to use BlankClip. 18 | 19 | -------------------------------------------------------------------------------- /doc/functions/video/interleave.rst: -------------------------------------------------------------------------------- 1 | Interleave 2 | ========== 3 | 4 | .. function:: Interleave(vnode[] clips[, bint extend=0, bint mismatch=0, bint modify_duration=True]) 5 | :module: std 6 | 7 | Returns a clip with the frames from all *clips* interleaved. For example, 8 | Interleave(clips=[A, B]) will return A.Frame 0, B.Frame 0, A.Frame 1, 9 | B.Frame... 10 | 11 | The *extend* argument controls whether or not all input clips will be treated 12 | as if they have the same length as the longest clip. 13 | 14 | Interleaving clips with different formats or dimensions is considered an 15 | error unless *mismatch* is true. 16 | 17 | If *modify_duration* is set then the output clip's frame rate is the first 18 | input clip's frame rate multiplied by the number of input clips. The frame durations are divided 19 | by the number of input clips. Otherwise the first input clip's frame rate is used. 20 | -------------------------------------------------------------------------------- /test/weakref_test.py: -------------------------------------------------------------------------------- 1 | import weakref 2 | import unittest 3 | import vapoursynth as vs 4 | 5 | 6 | class FilterTestSequence(unittest.TestCase): 7 | 8 | def setUp(self): 9 | self.core = vs.core 10 | 11 | def test_weakref_coreproxy(self): 12 | with self.assertRaises(TypeError): 13 | ref = weakref.ref(self.core) 14 | 15 | def test_weakref_core(self): 16 | ref = weakref.ref(self.core.core) 17 | self.assertTrue(ref() is self.core.core) 18 | 19 | def test_weakref_node(self): 20 | video = self.core.std.BlankClip() 21 | ref = weakref.ref(video) 22 | self.assertTrue(ref() is video) 23 | 24 | def test_weakref_frame(self): 25 | video = self.core.std.BlankClip() 26 | frame = video.get_frame(0) 27 | ref = weakref.ref(frame) 28 | self.assertTrue(ref() is frame) 29 | 30 | if __name__ == '__main__': 31 | unittest.main() 32 | -------------------------------------------------------------------------------- /doc/functions/video/prewitt_sobel.rst: -------------------------------------------------------------------------------- 1 | Prewitt/Sobel 2 | =================== 3 | 4 | .. function:: Prewitt(vnode clip[, int[] planes=[0, 1, 2], float scale=1]) 5 | :module: std 6 | 7 | Creates an edge mask using the Prewitt operator. 8 | 9 | .. function:: Sobel(vnode clip[, int[] planes=[0, 1, 2], float scale=1]) 10 | :module: std 11 | 12 | Creates an edge mask using the Sobel operator. 13 | 14 | *clip* 15 | Clip to process. It must have integer sample type and bit depth 16 | between 8 and 16, or float sample type and bit depth of 32. If 17 | there are any frames with other formats, an error will be 18 | returned. 19 | 20 | *planes* 21 | Specifies which planes will be processed. Any unprocessed planes 22 | will be simply copied. 23 | 24 | *scale* 25 | Multiply all pixels by scale before outputting. This can be used to 26 | increase or decrease the intensity of edges in the output. 27 | -------------------------------------------------------------------------------- /doc/functions/video/doubleweave.rst: -------------------------------------------------------------------------------- 1 | DoubleWeave 2 | =========== 3 | 4 | .. function:: DoubleWeave(vnode clip[, bint tff]) 5 | :module: std 6 | 7 | Weaves the fields back together from a clip with interleaved fields. 8 | 9 | Since VapourSynth only has a weak notion of field order internally, *tff* 10 | may have to be set. Setting *tff* to true means top fields first and false 11 | means bottom fields first. Note that the ``_Field`` frame property, if present 12 | and in a valid combination, takes precedence over *tff*. 13 | 14 | DoubleWeave's output has the same number of frames as the input. One must 15 | use DoubleWeave together with SelectEvery to undo the effect of 16 | SeparateFields:: 17 | 18 | sep = core.std.SeparateFields(source) 19 | ... 20 | woven = core.std.DoubleWeave(sep) 21 | woven = core.std.SelectEvery(woven, 2, 0) 22 | 23 | The ``_Field`` frame property is deleted and ``_FieldBased`` is set accordingly. 24 | -------------------------------------------------------------------------------- /doc/functions/video/setframeprop.rst: -------------------------------------------------------------------------------- 1 | SetFrameProp 2 | ============ 3 | 4 | .. function:: SetFrameProp(vnode clip, string prop[, bint delete=False, int[] intval, float[] floatval, string[] data]) 5 | :module: std 6 | 7 | Adds/deletes a frame property to every frame in *clip*. 8 | 9 | If there is already a property with the name *prop* in the frames, 10 | it will be overwritten. 11 | 12 | The type of the property added depends on which of the *intval*, 13 | *floatval*, or *data* parameters is used. 14 | 15 | The *data* parameter can only be used to add NULL-terminated strings, 16 | not arbitrary binary data. 17 | 18 | For example, to set the field order to top field first:: 19 | 20 | clip = c.std.SetFrameProp(clip, prop="_FieldBased", intval=2) 21 | 22 | For users not requiring compatibility with R54 or older VapourSynth releases, it 23 | is recommended to use the more intuitive *SetFrameProps* and *RemoveFrameProps* 24 | functions instead. 25 | -------------------------------------------------------------------------------- /doc/functions/general/loadplugin.rst: -------------------------------------------------------------------------------- 1 | LoadPlugin 2 | ========== 3 | 4 | .. function:: LoadPlugin(string path, bint altsearchpath = False) 5 | :module: std 6 | 7 | Load a native VapourSynth plugin. If successful, the loaded plugin's 8 | functions will end up in their own namespace. 9 | 10 | Returns an error if a plugin with the same identifier or namespace already 11 | has been loaded. This is to prevent naming collisions or multiple versions 12 | of the same plugin being loaded at once. 13 | 14 | Plugins are normally loaded with a very specific search order for 15 | dependencies. Setting *altsearchpath* modifies this behavior to also 16 | include dlls in the PATH. 17 | 18 | Beware of Python's escape character, this will fail:: 19 | 20 | LoadPlugin(path='c:\plugins\filter.dll') 21 | 22 | Correct ways:: 23 | 24 | LoadPlugin(path='c:/plugins/filter.dll') 25 | LoadPlugin(path=r'c:\plugins\filter.dll') 26 | LoadPlugin(path='c:\\plugins\\filter.dll') 27 | -------------------------------------------------------------------------------- /doc/functions/video/text/text.rst: -------------------------------------------------------------------------------- 1 | Text 2 | ==== 3 | 4 | .. function:: Text(vnode clip, string text[, int alignment=7, int scale=1]) 5 | :module: text 6 | 7 | Text is a simple text printing filter. It doesn't use any external libraries 8 | for drawing the text. It uses a built-in bitmap font: the not-bold, 8×16 9 | version of Terminus. The font was not modified, only converted from PCF to an 10 | array of bytes. 11 | 12 | The font covers Windows-1252, which is a superset of ISO-8859-1 (aka latin1). 13 | Unprintable characters get turned into underscores. Long lines get wrapped in 14 | a dumb way. Lines that end up too low to fit in the frame are silently 15 | dropped. 16 | 17 | The *alignment* parameter takes a number from 1 to 9, corresponding to the 18 | positions of the keys on a numpad. 19 | 20 | The *scale* parameter sets an integer scaling factor for the bitmap font. 21 | 22 | *ClipInfo*, *CoreInfo*, *FrameNum*, and *FrameProps* are convenience functions 23 | based on *Text*. 24 | -------------------------------------------------------------------------------- /src/core/x86utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2019 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | 23 | static bool vs_isSSEStateOk() { 24 | return (_mm_getcsr() & 0x7f80) == 0x1f80; 25 | } 26 | -------------------------------------------------------------------------------- /src/cython/vsscript.pxd: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020 Fredrik Mellbin 3 | # 4 | # This file is part of VapourSynth. 5 | # 6 | # VapourSynth is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # VapourSynth is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with VapourSynth; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | # 20 | 21 | cdef extern from "include/VSScript4.h" nogil: 22 | enum: 23 | VSSCRIPT_API_MAJOR 24 | VSSCRIPT_API_MINOR 25 | VSSCRIPT_API_VERSION 26 | -------------------------------------------------------------------------------- /msvc_project/EEDI3/EEDI3.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /msvc_project/VIVTC/VIVTC.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /msvc_project/Vinverse/Vinverse.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /doc/functions/audio/blankaudio.rst: -------------------------------------------------------------------------------- 1 | BlankAudio 2 | ========== 3 | 4 | .. function:: BlankAudio([anode clip, int[] channels=[FRONT_LEFT, FRONT_RIGHT], int bits=16, int sampletype=INTEGER, int samplerate=44100, int length=(10*samplerate), bint keep=0]) 5 | :module: std 6 | 7 | Generates a new empty clip. This can be useful to have when editing audio 8 | or for testing. The default is a 10 second long 44.1kHz 16 bit stereo clip. 9 | Instead of specifying every property individually, BlankAudio can also copy 10 | the properties from *clip*. If both an argument such as *sampletype*, and *clip* 11 | are set, then *sampletype* will take precedence. 12 | 13 | The *channels* argument is a list of channel constants. Specifying the same channel twice 14 | is not allowed. 15 | 16 | The possible *sampletype* values are currently INTEGER (0) and FLOAT (1). 17 | 18 | If *keep* is set, a reference to the same frame is returned on every request. 19 | Otherwise a new frame is generated every time. There should usually be no 20 | reason to change this setting. 21 | -------------------------------------------------------------------------------- /doc/functions/video/merge.rst: -------------------------------------------------------------------------------- 1 | Merge 2 | ===== 3 | 4 | .. function:: Merge(vnode clipa, vnode clipb[, float[] weight = 0.5]) 5 | :module: std 6 | 7 | Merges *clipa* and *clipb* using the specified *weight* for each plane. The default 8 | is to use a 0.5 *weight* for all planes. A zero *weight* means that *clipa* 9 | is returned unchanged and 1 means that *clipb* is returned unchanged. If a 10 | single *weight* is specified, it will be used for all planes. If two weights 11 | are given then the second value will be used for the third plane as well. 12 | 13 | Values outside the 0-1 range are considered to be an error. Specifying more 14 | weights than planes in the clips is also an error. The clips must have the 15 | same dimensions and format. 16 | 17 | How to merge luma:: 18 | 19 | Merge(clipa=A, clipb=B, weight=[1, 0]) 20 | 21 | How to merge chroma:: 22 | 23 | Merge(clipa=A, clipb=B, weight=[0, 1]) 24 | 25 | The average of two clips:: 26 | 27 | Merge(clipa=A, clipb=B) 28 | 29 | The frame properties are copied from *clipa*. 30 | -------------------------------------------------------------------------------- /doc/plugins/morpho.rst: -------------------------------------------------------------------------------- 1 | .. _morpho: 2 | 3 | Morpho 4 | ====== 5 | 6 | .. function:: Dilate(clip clip[, int size=5, int shape=0]) 7 | :module: morpho 8 | 9 | .. function:: Erode(clip clip[, int size=5, int shape=0]) 10 | :module: morpho 11 | 12 | .. function:: Open(clip clip[, int size=5, int shape=0]) 13 | :module: morpho 14 | 15 | .. function:: Close(clip clip[, int size=5, int shape=0]) 16 | :module: morpho 17 | 18 | .. function:: TopHat(clip clip[, int size=5, int shape=0]) 19 | :module: morpho 20 | 21 | .. function:: BottomHat(clip clip[, int size=5, int shape=0]) 22 | :module: morpho 23 | 24 | A set of simple morphological filters. Useful for working with mask clips. 25 | 26 | Parameters (common to all functions): 27 | 28 | clip 29 | Clip to be processed. Must be 8-16 bits per sample. 30 | 31 | size 32 | Size of the structuring element, in pixels. 33 | 34 | shape 35 | Shape of the structuring element. Possible values are: 36 | 37 | 0: Square 38 | 1: Diamond 39 | 2: Circle 40 | -------------------------------------------------------------------------------- /msvc_project/MiscFilters/MiscFilters.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/vspipe/vsjson.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef VSJSON_H 22 | #define VSJSON_H 23 | 24 | #include 25 | #include 26 | 27 | std::string escapeJSONString(const std::string &s); 28 | std::string convertVSMapToJSON(const VSMap *map, const VSAPI *vsapi); 29 | #endif 30 | -------------------------------------------------------------------------------- /src/filters/morpho/morpho_selems.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple morphological filters 3 | * 4 | * Copyright (c) 2014, Martin Herkt 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 11 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 12 | * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 13 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 14 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 15 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 | * PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | typedef void (*SElemFunc)(uint8_t*, int); 20 | 21 | void SquareSElem(uint8_t *selem, int size); 22 | void DiamondSElem(uint8_t *selem, int size); 23 | void CircleSElem(uint8_t *selem, int size); 24 | 25 | extern const SElemFunc SElemFuncs[]; 26 | -------------------------------------------------------------------------------- /doc/functions/video/selectevery.rst: -------------------------------------------------------------------------------- 1 | SelectEvery 2 | =========== 3 | 4 | .. function:: SelectEvery(vnode clip, int cycle, int[] offsets[, bint modify_duration=True]) 5 | :module: std 6 | 7 | Returns a clip with only some of the frames in every *cycle* selected. The 8 | *offsets* given must be between 0 and *cycle* - 1. 9 | 10 | Below are some examples of useful operations. 11 | 12 | Return even numbered frames, starting with 0:: 13 | 14 | SelectEvery(clip=clip, cycle=2, offsets=0) 15 | 16 | Return odd numbered frames, starting with 1:: 17 | 18 | SelectEvery(clip=clip, cycle=2, offsets=1) 19 | 20 | Fixed pattern 1 in 5 decimation, first frame in every cycle removed:: 21 | 22 | SelectEvery(clip=clip, cycle=5, offsets=[1, 2, 3, 4]) 23 | 24 | Duplicate every fourth frame:: 25 | 26 | SelectEvery(clip=clip, cycle=4, offsets=[0, 1, 2, 3, 3]) 27 | 28 | In Python, std.SelectEvery can also be invoked by :ref:`slicing a clip `. 29 | 30 | If *modify_duration* is set the clip's frame rate is multiplied by the number 31 | of offsets and divided by *cycle*. The frame durations are adjusted in the same manner. 32 | -------------------------------------------------------------------------------- /doc/functions/video/setvideocache.rst: -------------------------------------------------------------------------------- 1 | SetVideoCache 2 | ============= 3 | 4 | .. function:: SetVideoCache(vnode clip[, int mode, int fixedsize, int maxsize, int historysize]) 5 | :module: std 6 | 7 | Every filter node has a cache associated with it that 8 | may or may not be enabled depending on the dependencies 9 | and request patterns. This function allows all automatic 10 | behavior to be overridden. 11 | 12 | The *mode* option has 3 possible options where 0 always 13 | disables caching, 1 always enables the cache and -1 14 | uses the automatically calculated settings. Note that 15 | setting *mode* to -1 will reset the other values to 16 | their defaults as well. 17 | 18 | The other options are fairly self-explanatory where 19 | setting *fixedsize* prevents the cache from over time 20 | altering its *maxsize* based on request history. The 21 | final *historysize* argument controls how many previous 22 | and no longer cached requests should be considered for 23 | decisions on growing *maxsize* should generally not 24 | be touched at all. 25 | 26 | Note that setting *mode* will reset all other options 27 | to their defaults. -------------------------------------------------------------------------------- /src/cython/vsscript_internal.pxd: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020 Fredrik Mellbin 3 | # 4 | # This file is part of VapourSynth. 5 | # 6 | # VapourSynth is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # VapourSynth is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with VapourSynth; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | # 20 | 21 | from vapoursynth cimport VSCore 22 | 23 | cdef extern from "src/vsscript/vsscript_internal.h" nogil: 24 | 25 | ctypedef struct VSScript: 26 | void *pyenvdict 27 | void *errstr 28 | VSCore *core 29 | int id 30 | int exitCode 31 | int setCWD 32 | -------------------------------------------------------------------------------- /src/vspipe/printgraph.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef PRINTGRAPH_H 22 | #define PRINTGRAPH_H 23 | 24 | #include 25 | #include 26 | 27 | std::string printNodeGraph(bool simple, VSNode *node, const VSAPI *vsapi); 28 | std::string printNodeTimes(VSNode *node, double processingTime, const VSAPI *vsapi); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/avfs/avfs.rc: -------------------------------------------------------------------------------- 1 | 2 | #include "../core/version.h" 3 | #define BUILD VAPOURSYNTH_CORE_VERSION 4 | 5 | 6 | #define _VER_QUOTE_(s) #s 7 | #define _VER_QUOTE(s) _VER_QUOTE_(s) 8 | #define BUILDA _VER_QUOTE(BUILD) 9 | #define VER_DESCRIPTION "Avisynth Virtual File System" 10 | #define VER_VERSION "1.0.0." BUILDA 11 | #define VER_COPYRIGHT "Copyright 2008-2015 Ben Rudiak-Gould et al." 12 | 13 | #ifdef RC_INVOKED 14 | #include "winresrc.h" 15 | 16 | VS_VERSION_INFO VERSIONINFO 17 | FILEVERSION 1,0,0,BUILD 18 | PRODUCTVERSION 1,0,0,BUILD 19 | FILEFLAGSMASK 0x3fL 20 | #ifdef _DEBUG 21 | FILEFLAGS 0x1L 22 | #else 23 | FILEFLAGS 0x0L 24 | #endif 25 | FILEOS 0x40004L 26 | FILETYPE 0x2L 27 | FILESUBTYPE 0x0L 28 | BEGIN 29 | BLOCK "StringFileInfo" 30 | BEGIN 31 | BLOCK "000004b0" 32 | BEGIN 33 | VALUE "FileDescription", VER_DESCRIPTION "\0" 34 | VALUE "FileVersion", "1, 0, 0, " BUILDA "0\0" 35 | VALUE "LegalCopyright", VER_COPYRIGHT "\0" 36 | VALUE "ProductName", VER_DESCRIPTION "\0" 37 | END 38 | END 39 | BLOCK "VarFileInfo" 40 | BEGIN 41 | VALUE "Translation", 0x0, 1200 42 | END 43 | END 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /msvc_project/ExprDebugger/ExprDebugger.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/vsscript/vsscript_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef VSSCRIPT_INTERNAL_H 22 | #define VSSCRIPT_INTERNAL_H 23 | 24 | #include "../../include/VapourSynth4.h" 25 | 26 | typedef struct VSScript { 27 | void *pyenvdict; 28 | void *errstr; 29 | VSCore *core; 30 | int id; 31 | int exitCode; 32 | int setCWD; 33 | } VSScript; 34 | 35 | #endif -------------------------------------------------------------------------------- /test/filter_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import vapoursynth as vs 3 | 4 | class FilterTestSequence(unittest.TestCase): 5 | 6 | def setUp(self): 7 | self.core = vs.core 8 | self.Transpose = self.core.std.Transpose 9 | self.BlankClip = self.core.std.BlankClip 10 | 11 | def test_transpose8_test(self): 12 | clip = self.BlankClip(format=vs.YUV420P8, color=[0, 0, 0], width=1156, height=752) 13 | self.Transpose(clip).get_frame(0) 14 | 15 | def test_transpose16(self): 16 | clip = self.BlankClip(format=vs.YUV420P16, color=[0, 0, 0], width=1156, height=752) 17 | self.Transpose(clip).get_frame(0) 18 | 19 | def test_transposeS(self): 20 | clip = self.BlankClip(format=vs.YUV444PS, color=[0, 0, 0], width=1156, height=752) 21 | self.Transpose(clip).get_frame(0) 22 | 23 | def test_setframeprops(self): 24 | """ https://github.com/vapoursynth/vapoursynth/issues/1046 """ 25 | matrix = vs.MatrixCoefficients.MATRIX_ST170_M 26 | clip = self.BlankClip(format=vs.GRAY8, width=1, height=1) 27 | clip = clip.std.SetFrameProps(_Matrix=matrix) 28 | self.assertEqual(clip.get_frame(0).props["_Matrix"], int(matrix)) 29 | 30 | if __name__ == '__main__': 31 | unittest.main() 32 | -------------------------------------------------------------------------------- /doc/functions/video/averageframes.rst: -------------------------------------------------------------------------------- 1 | AverageFrames 2 | ============= 3 | 4 | .. function:: AverageFrames(vnode[] clips, float[] weights[, float scale, bint scenechange, int[] planes]) 5 | :module: std 6 | 7 | AverageFrames has two main modes depending on whether one or multiple *clips* are supplied. 8 | The filter is named AverageFrames since using ones for weights is an easy way to average 9 | many frames together but it can also be seen as a temporal or multiple frame convolution. 10 | 11 | If multiple *clips* are supplied then the frames from each of the *clips* are multiplied by 12 | the respective *weights*, summed together and divided by *scale* before being output. Note 13 | that only integer *weights* and *scale* are allowed for integer input formats. 14 | 15 | If a single *clip* is supplied then an odd number of *weights* are needed and they will instead 16 | be temporally centered on the current frame of the *clip*. The rest works as multiple *clip* mode 17 | with the only difference being that *scenechange* can be set to avoid averaging frames over scene 18 | changes. If this happens then all the weights beyond a scene change are instead applied to the frame 19 | right before it. 20 | 21 | At most 31 *weights* can be supplied. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vapoursynth-classic 2 | [![Windows](https://github.com/AmusementClub/vapoursynth-classic/actions/workflows/windows.yml/badge.svg)](https://github.com/AmusementClub/vapoursynth-classic/actions/workflows/windows.yml) [![Linux](https://github.com/AmusementClub/vapoursynth-classic/actions/workflows/linux.yml/badge.svg)](https://github.com/AmusementClub/vapoursynth-classic/actions/workflows/linux.yml) [![macOS](https://github.com/AmusementClub/vapoursynth-classic/actions/workflows/macos.yml/badge.svg)](https://github.com/AmusementClub/vapoursynth-classic/actions/workflows/macos.yml) 3 | 4 | *A video processing framework with simplicity and backward compatibility in mind* 5 | 6 | VapourSynth-Classic is a fork of VapourSynth R55 to provide long-term stable API: 7 | If your vpy script works under VapourSynth R54, then it should continue to work for the foreseeable future. 8 | 9 | We simply do not break vpy-level API. 10 | 11 | **Looking for the documentation?** 12 | Read the documentation here: [VapourSynth-Classic Documentation](https://amusementclub.github.io/doc/) 13 | 14 | # Building 15 | For build instructions, visit [Windows Compilation](https://amusementclub.github.io/doc/installation.html#windows-compilation) and [Linux and OS X Compilation](http://amusementclub.github.io/doc/installation.html#linux-and-os-x-compilation) 16 | -------------------------------------------------------------------------------- /src/core/vslog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2013 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | // This file only exists for V3 compatibility 22 | 23 | #ifndef VSLOG_H 24 | #define VSLOG_H 25 | 26 | #include "VapourSynth4.h" 27 | #include "VapourSynth3.h" 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | void vsSetMessageHandler3(vs3::VSMessageHandler handler, void *userData); 34 | int vsAddMessageHandler3(vs3::VSMessageHandler handler, vs3::VSMessageHandlerFree free, void *userData); 35 | int vsRemoveMessageHandler3(int id); 36 | void vsLog3(bool handled, vs3::VSMessageType type, const char *msg, ...); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/core/kernel/cpulevel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2019 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef CPULEVEL_H 22 | #define CPULEVEL_H 23 | 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | enum { 31 | VS_CPU_LEVEL_NONE = 0, 32 | #ifdef VS_TARGET_CPU_X86 33 | VS_CPU_LEVEL_SSE2 = 1, 34 | VS_CPU_LEVEL_AVX2 = 2, 35 | #endif 36 | VS_CPU_LEVEL_MAX = INT_MAX 37 | }; 38 | 39 | struct VSCore; 40 | 41 | int vs_get_cpulevel(const struct VSCore *core); 42 | int vs_set_cpulevel(struct VSCore *core, int level); 43 | 44 | int vs_cpulevel_from_str(const char *name); 45 | const char *vs_cpulevel_to_str(int level); 46 | 47 | #ifdef __cplusplus 48 | } // extern "C" 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /doc/functions/video/binarize_binarizemask.rst: -------------------------------------------------------------------------------- 1 | Binarize/BinarizeMask 2 | ===================== 3 | 4 | .. function:: Binarize(vnode clip[, float[] threshold, float[] v0, float[] v1, int[] planes=[0, 1, 2]]) 5 | BinarizeMask(vnode clip[, float[] threshold, float[] v0, float[] v1, int[] planes=[0, 1, 2]]) 6 | :module: std 7 | 8 | Turns every pixel in the image into either *v0*, if it's below 9 | *threshold*, or *v1*, otherwise. The *BinarizeMask* version is intended 10 | for use on mask clips where all planes have the same value range and 11 | only differs in the default values of *v0* and *v1*. 12 | 13 | *clip* 14 | Clip to process. It must have integer sample type and bit depth 15 | between 8 and 16, or float sample type and bit depth of 32. If 16 | there are any frames with other formats, an error will be 17 | returned. 18 | 19 | *threshold* 20 | Defaults to the middle point of range allowed by the format. 21 | Can be specified for each plane individually. 22 | 23 | *v0* 24 | Value given to pixels that are below *threshold*. Can be specified 25 | for each plane individually. Defaults to the lower bound of the format. 26 | 27 | *v1* 28 | Value given to pixels that are greater than or equal to *threshold*. 29 | Defaults to the maximum value allowed by the format. Can be specified 30 | for each plane individually. Defaults to the upper bound of the format. 31 | 32 | *planes* 33 | Specifies which planes will be processed. Any unprocessed planes 34 | will be simply copied. 35 | -------------------------------------------------------------------------------- /src/vspipe/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. 3 | * MD5 Message-Digest Algorithm (RFC 1321). 4 | * 5 | * Homepage: 6 | * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 7 | * 8 | * Author: 9 | * Alexander Peslyak, better known as Solar Designer 10 | * 11 | * This software was written by Alexander Peslyak in 2001. No copyright is 12 | * claimed, and the software is hereby placed in the public domain. 13 | * In case this attempt to disclaim copyright and place the software in the 14 | * public domain is deemed null and void, then the software is 15 | * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the 16 | * general public under the following terms: 17 | * 18 | * Redistribution and use in source and binary forms, with or without 19 | * modification, are permitted. 20 | * 21 | * There's ABSOLUTELY NO WARRANTY, express or implied. 22 | * 23 | * See md5.c for more information. 24 | */ 25 | 26 | #ifdef HAVE_OPENSSL 27 | #include 28 | #elif !defined(_MD5_H) 29 | #define _MD5_H 30 | 31 | /* Any 32-bit or wider unsigned integer data type will do */ 32 | typedef unsigned int MD5_u32plus; 33 | 34 | typedef struct { 35 | MD5_u32plus lo, hi; 36 | MD5_u32plus a, b, c, d; 37 | unsigned char buffer[64]; 38 | MD5_u32plus block[16]; 39 | } MD5_CTX; 40 | 41 | extern void MD5_Init(MD5_CTX *ctx); 42 | extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); 43 | extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/VapourSynthC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2022 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth Classic. 5 | * 6 | * VS-C is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | // This API is for VS-C internal use only. 22 | 23 | #ifndef VAPOURSYNTHC_H 24 | #define VAPOURSYNTHC_H 25 | 26 | #include 27 | 28 | #define VAPOURSYNTHC_API_VERSION 0x76732d63 // 'vs-c' 29 | 30 | typedef struct VSCAPI { 31 | int (VS_CC *getPluginAPIVersion)(const VSPlugin *); // major version only 32 | int (VS_CC *pluginSetRO)(VSPlugin *, int readonly); // returns old status 33 | int (VS_CC *pluginRenameFunc)(VSPlugin *, const char *oldname, const char *newname); 34 | VSPlugin *(VS_CC *createPlugin)(const char *id, const char *ns, int version, VSCore *core); 35 | void (VS_CC *setNodeName)(VSNode *node, const char *name); 36 | } VSCAPI; 37 | 38 | #endif /* VAPOURSYNTHC_H */ 39 | -------------------------------------------------------------------------------- /src/filters/avisource/Avisynth.h: -------------------------------------------------------------------------------- 1 | // Avisynth v1.0 beta. Copyright 2000 Ben Rudiak-Gould. 2 | // http://www.math.berkeley.edu/~benrg/avisynth.html 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 | #ifndef f_AVISYNTH_H 20 | #define f_AVISYNTH_H 21 | 22 | extern "C" const GUID CLSID_CAVIFileSynth // {E6D6B700-124D-11D4-86F3-DB80AFD98778} 23 | = {0xe6d6b700, 0x124d, 0x11d4, {0x86, 0xf3, 0xdb, 0x80, 0xaf, 0xd9, 0x87, 0x78}}; 24 | 25 | extern "C" const GUID IID_IAvisynthClipInfo // {E6D6B708-124D-11D4-86F3-DB80AFD98778} 26 | = {0xe6d6b708, 0x124d, 0x11d4, {0x86, 0xf3, 0xdb, 0x80, 0xaf, 0xd9, 0x87, 0x78}}; 27 | 28 | 29 | struct IAvisynthClipInfo : IUnknown { 30 | virtual int __stdcall GetError(const char** ppszMessage) = 0; 31 | virtual bool __stdcall GetParity(int n) = 0; 32 | virtual bool __stdcall IsFieldBased() = 0; 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /doc/functions/video/lut.rst: -------------------------------------------------------------------------------- 1 | Lut 2 | === 3 | 4 | .. function:: Lut(vnode clip[, int[] planes, int[] lut, float[] lutf, func function, int bits, bint floatout]) 5 | :module: std 6 | 7 | Applies a look-up table to the given clip. The lut can be specified as either an array 8 | of 2^bits_per_sample values or given as a *function* having an argument named 9 | *x* to be evaluated. Either *lut*, *lutf* or *function* must be used. The lut will be 10 | applied to the planes listed in *planes* and the other planes will simply be 11 | passed through unchanged. By default all *planes* are processed. 12 | 13 | If *floatout* is set then the output will be floating point instead, and either 14 | *lutf* needs to be set or *function* always needs to return floating point 15 | values. 16 | 17 | How to limit YUV range (by passing an array): 18 | 19 | .. code-block:: python 20 | 21 | luty = [] 22 | for x in range(2**clip.format.bits_per_sample): 23 | luty.append(max(min(x, 235), 16)) 24 | lutuv = [] 25 | for x in range(2**clip.format.bits_per_sample): 26 | lutuv.append(max(min(x, 240), 16)) 27 | ret = Lut(clip=clip, planes=0, lut=luty) 28 | limited_clip = Lut(clip=ret, planes=[1, 2], lut=lutuv) 29 | 30 | How to limit YUV range (using a function): 31 | 32 | .. code-block:: python 33 | 34 | def limity(x): 35 | return max(min(x, 235), 16) 36 | def limituv(x): 37 | return max(min(x, 240), 16) 38 | ret = Lut(clip=clip, planes=0, function=limity) 39 | limited_clip = Lut(clip=ret, planes=[1, 2], function=limituv) 40 | -------------------------------------------------------------------------------- /src/filters/avisource/Fixes.h: -------------------------------------------------------------------------------- 1 | // VirtualDub - Video processing and capture application 2 | // Copyright (C) 1998-2001 Avery Lee 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. 17 | 18 | #ifndef f_FIXES_H 19 | #define f_FIXES_H 20 | 21 | typedef struct { 22 | uint32 fccType; 23 | uint32 fccHandler; 24 | uint32 dwFlags; 25 | uint16 wPriority; 26 | uint16 wLanguage; 27 | uint32 dwInitialFrames; 28 | uint32 dwScale; 29 | uint32 dwRate; 30 | uint32 dwStart; 31 | uint32 dwLength; 32 | uint32 dwSuggestedBufferSize; 33 | uint32 dwQuality; 34 | uint32 dwSampleSize; 35 | struct { 36 | sint16 left; 37 | sint16 top; 38 | sint16 right; 39 | sint16 bottom; 40 | } rcFrame; 41 | } AVIStreamHeader_fixed; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /doc/gettingstarted.rst: -------------------------------------------------------------------------------- 1 | Getting Started 2 | =============== 3 | 4 | So you managed to install VapourSynth. Now what? 5 | 6 | If you don't know the basics of Python, you may want to check out a 7 | `tutorial `_. 8 | 9 | You can "play around" in the python interpreter if you want, but that's not how 10 | most video scripts are created. 11 | 12 | Example Script 13 | ############## 14 | 15 | Here's a sample script to be inspired by, it assumes that lsmas is installed and :doc:`auto-loaded `:: 16 | 17 | from vapoursynth import core 18 | video = core.lsmas.LWLibavSource(source='Rule6.mkv') 19 | video = core.std.Transpose(video) 20 | video.set_output() 21 | 22 | What it does is to get an instance of the core and load a video file using L-SMASH. The video is then transposed 23 | (think matrix transpose, or if you don't know that, a 90 degree rotation plus horizontal flip). 24 | 25 | Remember that most VapourSynth objects have a quite nice string representation 26 | in Python, so if you want to know more about an instance just call print(). 27 | 28 | It it also possible to directly open the script in VapourSynth Editor or VirtualDub FilterMod for previewing. 29 | 30 | Output with VSPipe 31 | ################## 32 | 33 | VSPipe is very useful to pipe the output to various applications, for example x264 and FFmpeg for encoding. 34 | Here are two examples of command lines that automatically pass on most video attributes. 35 | 36 | For x264:: 37 | 38 | vspipe -c y4m script.vpy - | x264 --demuxer y4m - --output encoded.mkv 39 | 40 | For FFmpeg:: 41 | 42 | vspipe -c y4m script.vpy - | ffmpeg -i pipe: encoded.mkv 43 | -------------------------------------------------------------------------------- /doc/functions/audio/audiomix.rst: -------------------------------------------------------------------------------- 1 | AudioMix 2 | ======== 3 | 4 | .. function:: AudioMix(anode[] clips, float[] matrix, int[] channels_out) 5 | :module: std 6 | 7 | AudioMix can mix and combine channels from different clips in the most 8 | general way possible. 9 | 10 | Most of the returned clip's properties are implicitly determined from the 11 | first clip given to *clips*. 12 | 13 | The *clips* parameter takes one or more clips with the same format. If the clips 14 | are different lengths they'll be zero extended to that of the longest. 15 | 16 | The argument *matrix* applies the coefficients to each channel of each input clip where 17 | the channels are in the numerical order of their channel constants. For example a stereo clip 18 | will have its channels presented in the order FRONT_LEFT and then FRONT_RIGHT. 19 | 20 | Output channels and order is determined by the *channels_out* array 21 | between input index and output channel happens on the order of lowest output channel 22 | identifier to the highest. 23 | 24 | 25 | 26 | Below are some examples of useful operations. 27 | 28 | Downmix stereo audio to mono:: 29 | 30 | AudioMix(clips=clip, matrix=[0.5, 0.5], channels_out=[vs.FRONT_CENTER]) 31 | 32 | Downmix 5.1 audio:: 33 | 34 | AudioMix(clips=clip, matrix=[1, 0, 0.7071, 0, 0.7071, 0, 0, 1, 0.7071, 0, 0, 0.7071], channels_out=[vs.FRONT_LEFT, vs.FRONT_RIGHT]) 35 | 36 | Copy stereo audio to 5.1 and zero the other channels:: 37 | 38 | AudioMix(clips=c, matrix=[1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], channels_out=[vs.FRONT_LEFT, vs.FRONT_RIGHT, vs.FRONT_CENTER, vs.LOW_FREQUENCY, vs.BACK_LEFT, vs.BACK_RIGHT]) 39 | -------------------------------------------------------------------------------- /doc/functions/video/levels.rst: -------------------------------------------------------------------------------- 1 | Levels 2 | ====== 3 | 4 | .. function:: Levels(vnode clip[, float min_in, float max_in, float gamma=1.0, float min_out, float max_out, int[] planes=[0, 1, 2]]) 5 | :module: std 6 | 7 | Adjusts brightness, contrast, and gamma. 8 | 9 | The range [*min_in*, *max_in*] is remapped into [*min_out*, *max_out*]. Note that the 10 | range behavior is unintuitive for YUV float formats since the assumed range will be 11 | 0-1 even for the UV-planes. 12 | 13 | For example, to convert from limited range YUV to full range (8 bit):: 14 | 15 | clip = std.Levels(clip, min_in=16, max_in=235, min_out=0, max_out=255, planes=0) 16 | clip = std.Levels(clip, min_in=16, max_in=240, min_out=0, max_out=255, planes=[1,2]) 17 | 18 | The default value of *max_in* and *max_out* is the format's minimum and maximum 19 | allowed values respectively. Note that all input is clamped to the input range 20 | to prevent out of range output. 21 | 22 | .. warning:: 23 | The default ranges are 0-1 for floating point formats. This may have an undesired 24 | effect on YUV formats. 25 | 26 | *clip* 27 | Clip to process. It must have integer sample type and bit depth 28 | between 8 and 16, or float sample type and bit depth of 32. If 29 | there are any frames with other formats, an error will be 30 | returned. 31 | 32 | *gamma* 33 | Controls the degree of non-linearity of the conversion. Values 34 | greater than 1.0 brighten the output, while values less than 1.0 35 | darken it. 36 | 37 | *planes* 38 | Specifies which planes will be processed. Any unprocessed planes 39 | will be simply copied. 40 | -------------------------------------------------------------------------------- /msvc_project/VSScript/VSScript.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/avfs/include/ptblob.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // Copyright 2013 Joe Lowe 3 | // 4 | // Permission is granted to any person obtaining a copy of this Software, 5 | // to deal in the Software without restriction, including the rights to use, 6 | // copy, modify, merge, publish, distribute, sublicense, and sell copies of 7 | // the Software. 8 | // 9 | // The above copyright and permission notice must be left intact in all 10 | // copies or substantial portions of the Software. 11 | // 12 | // THE SOFTWARE IS WITHOUT WARRANTY. 13 | //--------------------------------------------------------------------------- 14 | // file name: ptblob.h 15 | // created: 2013.01.16 16 | // 17 | // Untyped variable size data container. Generally for use with 18 | // authentication data such as passwords and keys, to insure 19 | // copies are not left strewn about memory. Also useful for passing 20 | // variable size data around as a single arg, instead of 21 | // ptr,size argument pairs. 22 | // 23 | // The interfaces defined here are expected to be used as privimitives 24 | // in other interfaces, and so must indefinately maintain ABI 25 | // compatibility. Source compatibility may change over time. 26 | //--------------------------------------------------------------------------- 27 | #ifndef PTBLOB_H 28 | #define PTBLOB_H 29 | #include "ptpublic.h" 30 | 31 | #define INTERFACE_NAME blob_i 32 | PT_INTERFACE_DEFINE 33 | { 34 | PT_INTERFACE_FUN0( void , retain ); 35 | PT_INTERFACE_FUN0( void , release ); 36 | PT_INTERFACE_FUN0( const void*, data ); 37 | PT_INTERFACE_FUN0( size_t , size ); 38 | }; 39 | #undef INTERFACE_NAME 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /doc/functions/video/lut2.rst: -------------------------------------------------------------------------------- 1 | Lut2 2 | ==== 3 | 4 | .. function:: Lut2(vnode clipa, vnode clipb[, int[] planes, int[] lut, float[] lutf, func function, int bits, bint floatout]) 5 | :module: std 6 | 7 | Applies a look-up table that takes into account the pixel values of two clips. The 8 | *lut* needs to contain 2^(clip1.bits_per_sample + clip2.bits_per_sample) 9 | entries and will be applied to the planes listed in *planes*. Alternatively 10 | a *function* taking *x* and *y* as arguments can be used to make the lut. 11 | The other planes will be passed through unchanged. By default all *planes* 12 | are processed. 13 | 14 | Lut2 also takes an optional bit depth parameter, *bits*, which defaults to 15 | the bit depth of the first input clip, and specifies the bit depth of the 16 | output clip. The user is responsible for understanding the effects of bit 17 | depth conversion, specifically from higher bit depths to lower bit depths, 18 | as no scaling or clamping is applied. 19 | 20 | If *floatout* is set then the output will be floating point instead, and either 21 | *lutf* needs to be set or *function* always needs to return floating point 22 | values. 23 | 24 | How to average 2 clips: 25 | 26 | .. code-block:: python 27 | 28 | lut = [] 29 | for y in range(2 ** clipy.format.bits_per_sample): 30 | for x in range(2 ** clipx.format.bits_per_sample): 31 | lut.append((x + y)//2) 32 | Lut2(clipa=clipa, clipb=clipb, lut=lut) 33 | 34 | How to average 2 clips with a 10-bit output: 35 | 36 | .. code-block:: python 37 | 38 | def f(x, y): 39 | return (x*4 + y)//2 40 | Lut2(clipa=clipa8bit, clipb=clipb10bit, function=f, bits=10) 41 | -------------------------------------------------------------------------------- /src/filters/avisource/AVIReadCache.h: -------------------------------------------------------------------------------- 1 | #ifndef f_AVIREADCACHE_H 2 | #define f_AVIREADCACHE_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class AVIStreamNode; 9 | 10 | class VDINTERFACE IAVIReadCacheSource { 11 | public: 12 | virtual long ReadData(int stream, void *buffer, sint64 position, long len); 13 | virtual bool Stream(AVIStreamNode *, _int64 pos) = 0; 14 | virtual sint64 getStreamPtr() = 0; 15 | }; 16 | 17 | class AVIReadCache { 18 | public: 19 | long cache_hit_bytes, cache_miss_bytes; 20 | int reads; 21 | 22 | AVIReadCache(int nlines, int nstream, IAVIReadCacheSource *root, AVIStreamNode *psnData); 23 | ~AVIReadCache(); 24 | 25 | void ResetStatistics(); 26 | bool WriteBegin(sint64 pos, uint32 len); 27 | void Write(const void *buffer, uint32 len); 28 | void WriteEnd(); 29 | long Read(void *dest, sint64 chunk_pos, sint64 pos, uint32 len); 30 | 31 | long getMaxRead() { 32 | return (long)mSize; 33 | } 34 | 35 | private: 36 | struct IndexBlockEntry { 37 | sint64 pos; 38 | uint32 start; 39 | uint32 len; 40 | }; 41 | 42 | struct IndexBlock { 43 | enum { kBlocksPerIndex = 64 }; 44 | 45 | int mHead; 46 | int mTail; 47 | IndexBlockEntry mBlocks[kBlocksPerIndex]; 48 | }; 49 | 50 | AVIStreamNode *psnData; 51 | 52 | vdfastvector mBuffer; 53 | 54 | typedef std::list tIndexBlockList; 55 | tIndexBlockList mActiveIndices; 56 | tIndexBlockList mFreeIndices; 57 | 58 | int mSize, mFree; 59 | int mWritePos; 60 | int stream; 61 | IAVIReadCacheSource *source; 62 | }; 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /doc/functions/video/deflate_inflate.rst: -------------------------------------------------------------------------------- 1 | Deflate/Inflate 2 | =============== 3 | 4 | .. function:: Deflate(vnode clip[, int[] planes=[0, 1, 2], float threshold]) 5 | :module: std 6 | 7 | Replaces each pixel with the average of the eight pixels in its 3x3 8 | neighbourhood, but only if that average is less than the center pixel. 9 | 10 | *clip* 11 | Clip to process. It must have integer sample type and bit depth 12 | between 8 and 16, or float sample type and bit depth of 32. If 13 | there are any frames with other formats, an error will be 14 | returned. 15 | 16 | *planes* 17 | Specifies which planes will be processed. Any unprocessed planes 18 | will be simply copied. 19 | 20 | *threshold* 21 | Allows to limit how much pixels are changed. Output pixels will not 22 | become less than ``input - threshold``. The default is no limit. 23 | 24 | 25 | .. function:: Inflate(vnode clip[, int[] planes=[0, 1, 2], int threshold=65535]) 26 | :module: std 27 | 28 | Replaces each pixel with the average of the eight pixels in its 3x3 29 | neighbourhood, but only if that average is greater than the center 30 | pixel. 31 | 32 | *clip* 33 | Clip to process. It must have integer sample type and bit depth 34 | between 8 and 16, or float sample type and bit depth of 32. If 35 | there are any frames with other formats, an error will be 36 | returned. 37 | 38 | *planes* 39 | Specifies which planes will be processed. Any unprocessed planes 40 | will be simply copied. 41 | 42 | *threshold* 43 | Allows to limit how much pixels are changed. Output pixels will not 44 | become greater than ``input + threshold``. The default is no limit. 45 | -------------------------------------------------------------------------------- /msvc_project/Morpho/Morpho.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/filters/morpho/morpho.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple morphological filters 3 | * 4 | * Copyright (c) 2014, Martin Herkt 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 11 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 12 | * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 13 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 14 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 15 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 | * PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | typedef struct MorphoData { 20 | VSNode *node; 21 | VSVideoInfo vi; 22 | 23 | uint8_t *selem; 24 | int shape; 25 | int size; 26 | 27 | uintptr_t filter; 28 | } MorphoData; 29 | 30 | static const VSFrame *VS_CC MorphoGetFrame(int n, int activationReason, 31 | void *instanceData, 32 | void **frameData, 33 | VSFrameContext *frameCtx, 34 | VSCore *core, 35 | const VSAPI *vsapi); 36 | 37 | static void VS_CC MorphoFree(void *instanceData, VSCore *core, 38 | const VSAPI *vsapi); 39 | 40 | VS_EXTERNAL_API(void) VapourSynthPluginInit2(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 41 | -------------------------------------------------------------------------------- /doc/functions/video/maskedmerge.rst: -------------------------------------------------------------------------------- 1 | MaskedMerge 2 | =========== 3 | 4 | .. function:: MaskedMerge(vnode clipa, vnode clipb, vnode mask[, int[] planes, bint first_plane=0, bint premultiplied=0]) 5 | :module: std 6 | 7 | MaskedMerge merges *clipa* with *clipb* using the per pixel weights in the *mask*, 8 | where 0 means that *clipa* is returned unchanged. 9 | The *mask* clip is assumed to be full range for all planes and in the 10 | 0-1 interval for float formats regardless of the colorspace. 11 | If *mask* is a grayscale clip or if *first_plane* is true, the mask's first 12 | plane will be used as the mask for merging all planes. The mask will be 13 | bilinearly resized if necessary. 14 | 15 | If *premultiplied* is set the blending is performed as if *clipb* has been pre-multiplied 16 | with alpha. In pre-multiplied mode it is an error to try to merge two frames with 17 | mismatched full and limited range since it will most likely cause horrible unintended 18 | color shifts. In the other mode it's just a very, very bad idea. 19 | 20 | By default all planes will be 21 | processed, but it is also possible to specify a list of the *planes* to merge 22 | in the output. The unprocessed planes will be copied from the first clip. 23 | 24 | *clipa* and *clipb* must have the same dimensions and format, and the *mask* must be the 25 | same format as the clips or the grayscale equivalent. 26 | 27 | How to apply a mask to the first plane:: 28 | 29 | MaskedMerge(clipa=A, clipb=B, mask=Mask, planes=0) 30 | 31 | How to apply the first plane of a mask to the second and third plane:: 32 | 33 | MaskedMerge(clipa=A, clipb=B, mask=Mask, planes=[1, 2], first_plane=True) 34 | 35 | The frame properties are copied from *clipa*. 36 | -------------------------------------------------------------------------------- /src/common/vsutf16.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef VSUTF16_H 22 | #define VSUTF16_H 23 | 24 | #include 25 | #include 26 | 27 | static std::string utf16_to_utf8(const std::wstring &wstr) { 28 | int required_size = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, nullptr, 0, nullptr, nullptr); 29 | std::string buffer; 30 | buffer.resize(required_size - 1); 31 | WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), static_cast(wstr.size()), &buffer[0], required_size, nullptr, nullptr); 32 | return buffer; 33 | } 34 | 35 | static std::wstring utf16_from_utf8(const std::string &str) { 36 | int required_size = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, nullptr, 0); 37 | std::wstring wbuffer; 38 | wbuffer.resize(required_size - 1); 39 | MultiByteToWideChar(CP_UTF8, 0, str.c_str(), static_cast(str.size()), &wbuffer[0], required_size); 40 | return wbuffer; 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/avfs/files.h: -------------------------------------------------------------------------------- 1 | 2 | void FileClose(HANDLE handle); 3 | int/*error*/ FileOpenRead(const wchar_t* fileName,HANDLE* outHandle); 4 | int/*error*/ FileOpenWrite(const wchar_t* fileName,HANDLE* outHandle); 5 | int/*error*/ FileRead(HANDLE fileHandle,void* buffer,size_t count,size_t* bytesRead); 6 | int/*error*/ FileWrite(HANDLE fileHandle,const void* buffer,size_t count,size_t* bytesWritten); 7 | int/*error*/ FileSetSize(HANDLE fileHandle,uint64_t length); 8 | int/*error*/ FilePointer(HANDLE fileHandle,uint64_t offset,int method,uint64_t* newOffset); 9 | uint64_t FileGetPointer(HANDLE fileHandle); 10 | void FileSetPointer(HANDLE fileHandle,uint64_t offset); 11 | uint64_t FileGetSize(HANDLE fileHandle); 12 | int64_t FileGetTime(HANDLE fileHandle); 13 | int/*error*/ FileSetTime(HANDLE fileHandle,int64_t fileTime); 14 | int/*error*/ FileCreateSocket(int/*bool*/ bidir,int/*bool*/ async,HANDLE* outHandle1,HANDLE* outHandle2); 15 | int/*error*/ FileCreatePipe(HANDLE* read,HANDLE* write); 16 | int/*error*/ FileGetTime2(const wchar_t* fileName,int64_t* outWriteTime); 17 | 18 | // inline int64_t FileCurrentTime(void) 19 | // { 20 | // FILETIME time; 21 | // GetSystemTimeAsFileTime(&time); 22 | // return time; 23 | // } 24 | 25 | inline void FileCleanup(HANDLE* handle) 26 | { 27 | if(*handle != INVALID_HANDLE_VALUE) 28 | { 29 | CloseHandle(*handle); 30 | *handle = INVALID_HANDLE_VALUE; 31 | } 32 | } 33 | 34 | inline void FileCleanupPair(HANDLE* handle1,HANDLE* handle2) 35 | { 36 | if(*handle1 != INVALID_HANDLE_VALUE) 37 | { 38 | CloseHandle(*handle1); 39 | if(*handle2 == *handle1) 40 | { 41 | *handle2 = INVALID_HANDLE_VALUE; 42 | } 43 | *handle1 = INVALID_HANDLE_VALUE; 44 | } 45 | FileCleanup(handle2); 46 | } 47 | -------------------------------------------------------------------------------- /msvc_project/RemoveGrainVS/RemoveGrainVS.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/core/cpufeatures.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2020 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef CPUFEATURES_H 22 | #define CPUFEATURES_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef struct CPUFeatures { 29 | // This is to determine if the cpu is up to the minimum requirements in terms of supported instructions 30 | // that the VapourSynth core uses. 31 | char can_run_vs; 32 | #ifdef VS_TARGET_CPU_X86 33 | // On x86, all features up to sse2 are required. 34 | char sse3; 35 | char ssse3; 36 | char sse4_1; 37 | char sse4_2; 38 | char fma3; 39 | char avx; 40 | char avx2; 41 | char f16c; 42 | char aes; 43 | char movbe; 44 | char popcnt; 45 | char avx512_f; 46 | char avx512_cd; 47 | char avx512_bw; 48 | char avx512_dq; 49 | char avx512_vl; 50 | #endif 51 | } CPUFeatures; 52 | 53 | const CPUFeatures *getCPUFeatures(void); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif -------------------------------------------------------------------------------- /src/filters/avisource/FastReadStream.h: -------------------------------------------------------------------------------- 1 | // VirtualDub - Video processing and capture application 2 | // Copyright (C) 1998-2001 Avery Lee 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. 17 | 18 | #ifndef f_VIRTUALDUB_FASTREADSTREAM_H 19 | #define f_VIRTUALDUB_FASTREADSTREAM_H 20 | 21 | #include 22 | 23 | class FastReadStreamHeader; 24 | 25 | class FastReadStream { 26 | public: 27 | FastReadStream(HANDLE hFile, long lBlockCount, long lBlockSize); 28 | FastReadStream(int iFile, long lBlockCount, long lBlockSize); 29 | ~FastReadStream(); 30 | 31 | bool Ready(); 32 | long Read(int stream, __int64 i64Pos, void *pBuffer, long lBytes); 33 | void Flush(); 34 | 35 | private: 36 | HANDLE hFile; 37 | int iFile; 38 | long lBlockCount; 39 | long lBlockSize; 40 | long lHistory; 41 | 42 | FastReadStreamHeader *pHeaders; 43 | void *pBuffer; 44 | 45 | void _Init(long lBlockCount, long lBlockSize); 46 | int _PickVictim(int stream); 47 | int _Commit(int stream, __int64 i64BlockNo); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: macOS 2 | 3 | on: [push, pull_request, workflow_dispatch] 4 | 5 | jobs: 6 | build-clang: 7 | runs-on: macos-latest 8 | 9 | env: 10 | CC: clang 11 | CXX: clang++ 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | 16 | - name: Print compiler version 17 | run: ${{ env.CC }} --version 18 | 19 | - name: Install autotools 20 | run: | 21 | brew update 22 | brew install automake autoconf libtool pkg-config llvm 23 | 24 | - name: Install zimg 25 | run: | 26 | git clone https://github.com/sekrit-twc/zimg --branch v3.0 --depth 1 27 | pushd zimg 28 | ./autogen.sh 29 | ./configure 30 | make -j$(sysctl -n hw.logicalcpu) 31 | sudo make install -j$(sysctl -n hw.logicalcpu) 32 | popd 33 | rm -rf zimg 34 | 35 | - name: Setup Python 36 | uses: actions/setup-python@v5 37 | with: 38 | # Version range or exact version of a Python version to use, using SemVer's version range syntax. 39 | python-version: 3.9 40 | 41 | - name: Install cython 42 | run: | 43 | python -m pip install --upgrade pip 44 | pip install cython==3.0.12 wheel==0.45.1 45 | 46 | - name: Set PKG_CONFIG_PATH 47 | run: echo "PKG_CONFIG_PATH=$pythonLocation/lib/pkgconfig" >> $GITHUB_ENV 48 | 49 | - name: configure 50 | run: | 51 | export CC=/opt/homebrew/opt/llvm/bin/clang 52 | export CXX=/opt/homebrew/opt/llvm/bin/clang++ 53 | ./autogen.sh 54 | ./configure 55 | 56 | - name: make install 57 | run: | 58 | sudo make install -j$(sysctl -n hw.logicalcpu) 59 | pip install . 60 | 61 | - name: Run test 62 | run: python -m unittest discover -s test -p "*test.py" 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/filters/avisource/misc.h: -------------------------------------------------------------------------------- 1 | // VirtualDub - Video processing and capture application 2 | // Copyright (C) 1998-2001 Avery Lee 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. 17 | 18 | #ifndef f_VIRTUALDUB_MISC_H 19 | #define f_VIRTUALDUB_MISC_H 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | long MulDivTrunc(long a, long b, long c); 28 | int NearestLongValue(long v, const long *array, int array_size); 29 | unsigned __stdcall MulDivUnsigned(unsigned a, unsigned b, unsigned c); 30 | 31 | // only works properly when d1,d2>0!! 32 | 33 | long inline int64divto32(__int64 d1, __int64 d2) { 34 | return d2?(long)((d1+d2/2)/d2):0; 35 | } 36 | 37 | __int64 inline int64divround(__int64 d1, __int64 d2) { 38 | return d2?((d1+d2/2)/d2):0; 39 | } 40 | 41 | __int64 inline int64divroundup(__int64 d1, __int64 d2) { 42 | return d2?((d1+d2-1)/d2):0; 43 | } 44 | 45 | bool isEqualFOURCC(FOURCC fccA, FOURCC fccB); 46 | bool isValidFOURCC(FOURCC fcc); 47 | FOURCC toupperFOURCC(FOURCC fcc); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | name: Linux 2 | 3 | on: [push, pull_request, workflow_dispatch] 4 | 5 | jobs: 6 | build-gcc: 7 | runs-on: ubuntu-24.04 8 | 9 | env: 10 | CC: ${{ matrix.cc }} 11 | CXX: ${{ matrix.cxx }} 12 | 13 | strategy: 14 | matrix: 15 | include: 16 | - cc: gcc-13 17 | cxx: g++-13 18 | - cc: gcc-14 19 | cxx: g++-14 20 | fail-fast: false 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | 25 | - name: Print compiler version 26 | run: ${{ env.CC }} --version 27 | 28 | - name: Install zimg 29 | run: | 30 | git clone https://github.com/sekrit-twc/zimg --branch v3.0 --depth 1 31 | pushd zimg 32 | ./autogen.sh 33 | ./configure --prefix=/usr 34 | make -j$(nproc) 35 | sudo make install -j$(nproc) 36 | popd 37 | rm -rf zimg 38 | 39 | - name: Setup Python 40 | uses: actions/setup-python@v5 41 | with: 42 | # Version range or exact version of a Python version to use, using SemVer's version range syntax. 43 | python-version: 3.12 44 | 45 | - name: Install cython 46 | run: | 47 | python -m pip install --upgrade pip 48 | pip install cython==3.0.12 setuptools==78.1.0 wheel==0.45.1 49 | 50 | - name: Set PKG_CONFIG_PATH 51 | run: echo "PKG_CONFIG_PATH=$pythonLocation/lib/pkgconfig" >> $GITHUB_ENV 52 | 53 | - name: configure 54 | run: | 55 | ./autogen.sh 56 | ./configure --prefix=/usr 57 | 58 | - name: make 59 | run: make -j$(nproc) 60 | 61 | - name: make install 62 | run: | 63 | sudo make install -j$(nproc) 64 | python setup.py install 65 | 66 | - name: Run test 67 | run: python -m unittest discover -s test -p "*test.py" 68 | -------------------------------------------------------------------------------- /msvc_project/AvsCompat/AvsCompat.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/filters/morpho/morpho_filters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple morphological filters 3 | * 4 | * Copyright (c) 2014, Martin Herkt 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 11 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 12 | * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 13 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 14 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 15 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 | * PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | typedef void (*MorphoFilter)(const uint8_t*, uint8_t*, int, int, ptrdiff_t, MorphoData*); 20 | 21 | void MorphoDilate(const uint8_t *src, uint8_t *dst, 22 | int width, int height, ptrdiff_t stride, MorphoData *d); 23 | void MorphoErode(const uint8_t *src, uint8_t *dst, 24 | int width, int height, ptrdiff_t stride, MorphoData *d); 25 | void MorphoOpen(const uint8_t *src, uint8_t *dst, 26 | int width, int height, ptrdiff_t stride, MorphoData *d); 27 | void MorphoClose(const uint8_t *src, uint8_t *dst, 28 | int width, int height, ptrdiff_t stride, MorphoData *d); 29 | void MorphoTopHat(const uint8_t *src, uint8_t *dst, 30 | int width, int height, ptrdiff_t stride, MorphoData *d); 31 | void MorphoBottomHat(const uint8_t *src, uint8_t *dst, 32 | int width, int height, ptrdiff_t stride, MorphoData *d); 33 | 34 | extern const char *FilterNames[]; 35 | extern const MorphoFilter FilterFuncs[]; 36 | -------------------------------------------------------------------------------- /src/core/kernel/cpulevel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2019 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include "cpulevel.h" 23 | #include "../vscore.h" 24 | 25 | int vs_get_cpulevel(const struct VSCore *core) { 26 | return core->getCpuLevel(); 27 | } 28 | 29 | int vs_set_cpulevel(struct VSCore *core, int level) { 30 | return core->setCpuLevel(level); 31 | } 32 | 33 | int vs_cpulevel_from_str(const char *name) { 34 | if (!strcmp(name, "none")) 35 | return VS_CPU_LEVEL_NONE; 36 | #ifdef VS_TARGET_CPU_X86 37 | else if (!strcmp(name, "sse2")) 38 | return VS_CPU_LEVEL_SSE2; 39 | else if (!strcmp(name, "avx2")) 40 | return VS_CPU_LEVEL_AVX2; 41 | #endif 42 | else 43 | return VS_CPU_LEVEL_MAX; 44 | } 45 | 46 | const char *vs_cpulevel_to_str(int level) { 47 | if (level <= VS_CPU_LEVEL_NONE) 48 | return "none"; 49 | #ifdef VS_TARGET_CPU_X86 50 | else if (level <= VS_CPU_LEVEL_SSE2) 51 | return "sse2"; 52 | else if (level <= VS_CPU_LEVEL_AVX2) 53 | return "avx2"; 54 | #endif 55 | else 56 | return ""; 57 | } 58 | -------------------------------------------------------------------------------- /src/filters/removegrain/shared.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | 3 | AvsFilterRemoveGrain/Repair16 4 | Author: Laurent de Soras, 2012 5 | Modified for VapourSynth by Fredrik Mellbin 2013 6 | 7 | --- Legal stuff --- 8 | 9 | This program is free software. It comes without any warranty, to 10 | the extent permitted by applicable law. You can redistribute it 11 | and/or modify it under the terms of the Do What The Fuck You Want 12 | To Public License, Version 2, as published by Sam Hocevar. See 13 | http://sam.zoy.org/wtfpl/COPYING for more details. 14 | 15 | *Tab=3***********************************************************************/ 16 | 17 | #include "shared.h" 18 | 19 | ////////////////////////////////////////// 20 | // Init 21 | 22 | VS_EXTERNAL_API(void) VapourSynthPluginInit2(VSPlugin *plugin, const VSPLUGINAPI *vspapi) { 23 | vspapi->configPlugin("com.vapoursynth.removegrainvs", "rgvs", "RemoveGrain VapourSynth Port", VS_MAKE_VERSION(1, 0), VAPOURSYNTH_API_VERSION, 0, plugin); 24 | vspapi->registerFunction("RemoveGrain", "clip:vnode;mode:int[];", "clip:vnode;", removeGrainCreate, nullptr, plugin); 25 | vspapi->registerFunction("Repair", "clip:vnode;repairclip:vnode;mode:int[];", "clip:vnode;", repairCreate, nullptr, plugin); 26 | vspapi->registerFunction("Clense", "clip:vnode;previous:vnode:opt;next:vnode:opt;planes:int[]:opt;", "clip:vnode;", clenseCreate, reinterpret_cast(cmNormal), plugin); 27 | vspapi->registerFunction("ForwardClense", "clip:vnode;planes:int[]:opt;", "clip:vnode;", clenseCreate, reinterpret_cast(cmForward), plugin); 28 | vspapi->registerFunction("BackwardClense", "clip:vnode;planes:int[]:opt;", "clip:vnode;", clenseCreate, reinterpret_cast(cmBackward), plugin); 29 | vspapi->registerFunction("VerticalCleaner", "clip:vnode;mode:int[];", "clip:vnode;", verticalCleanerCreate, nullptr, plugin); 30 | } 31 | -------------------------------------------------------------------------------- /src/common/fourcc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016-2021 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef FOURCC_H 22 | #define FOURCC_H 23 | 24 | #include "VapourSynth4.h" 25 | 26 | #define VS_FCC(ch4) ((((unsigned long)(ch4) & 0xFF) << 24) | \ 27 | (((unsigned long)(ch4) & 0xFF00) << 8) | \ 28 | (((unsigned long)(ch4) & 0xFF0000) >> 8) | \ 29 | (((unsigned long)(ch4) & 0xFF000000) >> 24)) 30 | 31 | bool GetFourCC(const VSVideoFormat &fi, int alt_output, unsigned long &fourcc); 32 | bool GetBiCompression(const VSVideoFormat &format, int alt_output, unsigned long &compression); 33 | int BMPSize(const VSVideoInfo *vi, int alt_output); 34 | int BitsPerPixel(const VSVideoFormat &format, int alt_output); 35 | bool HasSupportedFourCC(const VSVideoFormat &fi); 36 | bool NeedsPacking(const VSVideoFormat &fi, int alt_output); 37 | bool NeedsUVSwap(const VSVideoFormat &fi, int alt_output); // Returns false for YVU plane order and true for YUV when doing planar output 38 | void PackOutputFrame(const uint8_t *src[3], const ptrdiff_t src_stride[3], uint8_t *dst, int width, int height, const VSVideoFormat &fi, int alt_output); 39 | 40 | #endif -------------------------------------------------------------------------------- /include/cython/vapoursynth.h: -------------------------------------------------------------------------------- 1 | /* Generated by Cython 0.29.24 */ 2 | 3 | #ifndef __PYX_HAVE__vapoursynth 4 | #define __PYX_HAVE__vapoursynth 5 | 6 | #include "Python.h" 7 | 8 | #ifndef __PYX_HAVE_API__vapoursynth 9 | 10 | #ifndef __PYX_EXTERN_C 11 | #ifdef __cplusplus 12 | #define __PYX_EXTERN_C extern "C" 13 | #else 14 | #define __PYX_EXTERN_C extern 15 | #endif 16 | #endif 17 | 18 | #ifndef DL_IMPORT 19 | #define DL_IMPORT(_T) _T 20 | #endif 21 | 22 | __PYX_EXTERN_C int vpy4_createScript(VSScript *); 23 | __PYX_EXTERN_C int vpy_evaluateScript(VSScript *, char const *, char const *, int); 24 | __PYX_EXTERN_C int vpy_evaluateFile(VSScript *, char const *, int); 25 | __PYX_EXTERN_C int vpy4_evaluateBuffer(VSScript *, char const *, char const *); 26 | __PYX_EXTERN_C int vpy4_evaluateFile(VSScript *, char const *); 27 | __PYX_EXTERN_C void vpy4_freeScript(VSScript *); 28 | __PYX_EXTERN_C char const *vpy4_getError(VSScript *); 29 | __PYX_EXTERN_C VSNode *vpy4_getOutput(VSScript *, int); 30 | __PYX_EXTERN_C VSNode *vpy4_getAlphaOutput(VSScript *, int); 31 | __PYX_EXTERN_C int vpy4_getAltOutputMode(VSScript *, int); 32 | __PYX_EXTERN_C int vpy_clearOutput(VSScript *, int); 33 | __PYX_EXTERN_C VSCore *vpy4_getCore(VSScript *); 34 | __PYX_EXTERN_C VSAPI const *vpy4_getVSAPI(int); 35 | __PYX_EXTERN_C int vpy4_getVariable(VSScript *, char const *, VSMap *); 36 | __PYX_EXTERN_C int vpy4_setVariables(VSScript *, VSMap const *); 37 | __PYX_EXTERN_C int vpy_clearVariable(VSScript *, char const *); 38 | __PYX_EXTERN_C void vpy_clearEnvironment(VSScript *); 39 | __PYX_EXTERN_C int vpy4_initVSScript(void); 40 | 41 | #endif /* !__PYX_HAVE_API__vapoursynth */ 42 | 43 | /* WARNING: the interface of the module init function changed in CPython 3.5. */ 44 | /* It now returns a PyModuleDef instance instead of a PyModule instance. */ 45 | 46 | #if PY_MAJOR_VERSION < 3 47 | PyMODINIT_FUNC initvapoursynth(void); 48 | #else 49 | PyMODINIT_FUNC PyInit_vapoursynth(void); 50 | #endif 51 | 52 | #endif /* !__PYX_HAVE__vapoursynth */ 53 | -------------------------------------------------------------------------------- /doc/introduction.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | VapourSynth is an application for video manipulation. Or a plugin. Or a library. 5 | It's hard to tell because it has a core library written in C++ and a Python 6 | module to allow video scripts to be created. It came to be when I started 7 | thinking about alternative designs for Avisynth and most of it was written 8 | over a 3 month period. 9 | 10 | The software has been heavily inspired by `Avisynth `_ 11 | and aims to be a 21st century rewrite, taking advantage of the advancements 12 | computers have made since the late 90s. 13 | The main features compared to Avisynth are: 14 | 15 | * Multithreaded - Frame level multithreading that scales well 16 | * Generalized Colorspaces - New colorspaces can be specified at runtime 17 | * Per Frame Properties - Additional metadata can be attached to frames 18 | * Python Based - The scripting part is implemented as a Python module so you 19 | don't have to learn a special language 20 | * Support for video with format changes - Some video just can't stick to one 21 | format or frame size. VapourSynth can handle any kind of change 22 | * Compatible with a large number of already existing Avisynth plugins 23 | 24 | About the author 25 | ################ 26 | 27 | Fredrik Mellbin majored in electrical engineering with a focus on image analysis 28 | and processing with medical applications. He has previously worked with digital 29 | electronics and likes to plan his own software projects in his spare time. 30 | When he one day found himself out of work he needed something to do between 31 | sending out job applications and waiting for a reply. The natural choice for 32 | the author was to try to improve Avisynth, the software that once made him 33 | interested in video editing. VapourSynth is the result of all that time waiting. 34 | 35 | Feel free to contact me at fredrik.mellbin that round thingy with an a gmail.com 36 | if you need help to port a filter or want to sponsor the development. 37 | -------------------------------------------------------------------------------- /msvc_project/VSVFW/VSVFW.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | -------------------------------------------------------------------------------- /doc/functions/video/modifyframe.rst: -------------------------------------------------------------------------------- 1 | ModifyFrame 2 | =========== 3 | 4 | .. function:: ModifyFrame(vnode clip, clip[] clips, func selector) 5 | :module: std 6 | 7 | The *selector* function is called for every single frame and can modify the 8 | properties of one of the frames gotten from *clips*. The additional *clips*' 9 | properties should only be read and not modified because only one modified 10 | frame can be returned. 11 | 12 | You must first copy the input frame to make it modifiable. Any frame may be 13 | returned as long as it has the same format as the *clip*. 14 | Failure to do so will produce an error. If for conditional reasons you do not 15 | need to modify the current frame's properties, you can simply pass it through. 16 | The selector function is passed *n*, the current frame number, and *f*, which 17 | is a frame or a list of frames if there is more than one clip specified. 18 | 19 | If you do not need to modify frame properties but only read them, you should 20 | probably be using *FrameEval* instead. 21 | 22 | How to set the property FrameNumber to the current frame number:: 23 | 24 | def set_frame_number(n, f): 25 | fout = f.copy() 26 | fout.props['FrameNumber'] = n 27 | return fout 28 | ... 29 | ModifyFrame(clip=clip, clips=clip, selector=set_frame_number) 30 | 31 | How to remove a property:: 32 | 33 | def remove_property(n, f): 34 | fout = f.copy() 35 | del fout.props['FrameNumber'] 36 | return fout 37 | ... 38 | ModifyFrame(clip=clip, clips=clip, selector=remove_property) 39 | 40 | An example of how to copy certain properties from one clip to another 41 | (clip1 and clip2 have the same format):: 42 | 43 | def transfer_property(n, f): 44 | fout = f[1].copy() 45 | fout.props['FrameNumber'] = f[0].props['FrameNumber'] 46 | fout.props['_Combed'] = f[0].props['_Combed'] 47 | return fout 48 | ... 49 | ModifyFrame(clip=clip1, clips=[clip1, clip2], selector=transfer_property) 50 | -------------------------------------------------------------------------------- /doc/functions/video/shuffleplanes.rst: -------------------------------------------------------------------------------- 1 | ShufflePlanes 2 | ============= 3 | 4 | .. function:: ShufflePlanes(vnode[] clips, int[] planes, int colorfamily) 5 | :module: std 6 | 7 | ShufflePlanes can extract and combine planes from different clips in the most 8 | general way possible. 9 | This is both good and bad, as there are almost no error checks. 10 | 11 | Most of the returned clip's properties are implicitly determined from the 12 | first clip given to *clips*. 13 | 14 | The *clips* parameter takes between one and three clips for color families 15 | with three planes. In this case clips=[A] is equivalent to clips=[A, A, A] 16 | and clips=[A, B] is equivalent to clips=[A, B, B]. For the GRAY color 17 | family, which has one plane, it takes exactly one clip. 18 | 19 | The argument *planes* controls which of the input clips' planes to use. 20 | Zero indexed. The first number refers to the first input clip, the second 21 | number to the second clip, the third number to the third clip. 22 | 23 | The only thing that needs to be specified is *colorfamily*, which controls which 24 | color family (YUV, RGB, GRAY) the output clip will be. 25 | Properties such as subsampling are determined from the relative size of the 26 | given planes to combine. 27 | 28 | ShufflePlanes accepts clips with variable format and dimensions only when 29 | extracting a single plane. 30 | 31 | Below are some examples of useful operations. 32 | 33 | Extract plane with index X. X=0 will mean luma in a YUV clip and R in an RGB 34 | clip. Likewise 1 will return the U and G channels, respectively:: 35 | 36 | ShufflePlanes(clips=clip, planes=X, colorfamily=vs.GRAY) 37 | 38 | Swap U and V in a YUV clip:: 39 | 40 | ShufflePlanes(clips=clip, planes=[0, 2, 1], colorfamily=vs.YUV) 41 | 42 | Merge 3 grayscale clips into a YUV clip:: 43 | 44 | ShufflePlanes(clips=[Yclip, Uclip, Vclip], planes=[0, 0, 0], colorfamily=vs.YUV) 45 | 46 | Cast a YUV clip to RGB:: 47 | 48 | ShufflePlanes(clips=[YUVclip], planes=[0, 1, 2], colorfamily=vs.RGB) 49 | -------------------------------------------------------------------------------- /test/zimgtest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import itertools 3 | import vapoursynth as vs 4 | core = vs.core 5 | 6 | colorfamilies = (vs.GRAY, vs.YUV, vs.RGB) 7 | intbitdepths = (8, 9, 10, 11, 12, 13, 14, 15, 16) 8 | floatbitdepths = (16, 32) 9 | yuvss = (0, 1, 2) 10 | 11 | 12 | 13 | class ZimgTest(unittest.TestCase): 14 | def _build_format_ids(self): 15 | for cfs in colorfamilies: 16 | for bps in intbitdepths: 17 | if cfs == vs.YUV: 18 | for wss in yuvss: 19 | for hss in yuvss: 20 | yield core.query_video_format(cfs, vs.INTEGER, bps, wss, hss).id 21 | else: 22 | yield core.query_video_format(cfs, vs.INTEGER, bps, 0, 0).id 23 | 24 | for cfs in colorfamilies: 25 | for bps in floatbitdepths: 26 | if cfs == vs.YUV: 27 | for wss in yuvss: 28 | for hss in yuvss: 29 | yield core.query_video_format(cfs, vs.FLOAT, bps, wss, hss).id 30 | else: 31 | yield core.query_video_format(cfs, vs.FLOAT, bps, 0, 0).id 32 | 33 | def test_blank_clip_with_format(self): 34 | formatids = list(self._build_format_ids()) 35 | for informat, outformat in itertools.product(formatids, formatids): 36 | try: 37 | clip = core.std.BlankClip(format=informat) 38 | if clip.format.color_family in (vs.YUV, vs.GRAY): 39 | clip = core.resize.Bicubic(clip, format=outformat, matrix_in_s="709") 40 | elif core.get_video_format(outformat).color_family in (vs.YUV, vs.GRAY): 41 | clip = core.resize.Bicubic(clip, format=outformat, matrix_s="709") 42 | else: 43 | clip = core.resize.Bicubic(clip, format=outformat) 44 | clip.get_frame(0) 45 | except vs.Error as e: 46 | raise RuntimeError(f"Failed to convert from {informat} to {outformat}") from e 47 | 48 | if __name__ == '__main__': 49 | unittest.main() -------------------------------------------------------------------------------- /doc/functions/general/loadpluginavs.rst: -------------------------------------------------------------------------------- 1 | LoadPlugin (Avisynth Compatibility) 2 | =================================== 3 | 4 | .. function:: LoadPlugin(string path) 5 | :module: avs 6 | 7 | Load an Avisynth 2.5 (32 bit only), 2.6 (32 and 64 bit) or Avisynth+ (32 and 64 bit) plugin. 8 | If successful, the loaded plugin's functions will end up in the avs namespace. Note that 9 | in the case of Avisynth+ there's no way to use the formats combined with alpha or 10 | higher bitdepth packed RGB. Coincidentally there are no plugins that use this in a 11 | meaningful way yet. 12 | 13 | The compatibility module can work with a large number of Avisynth's plugins. 14 | However, the wrapping is not complete, so the following things will cause 15 | problems: 16 | 17 | * The plugin expects YUY2 or RGB32 input. In this case provide input in 18 | either YUV422P8 or RGB24 format pass compatpack=True as an argument 19 | to the Avisynth function. 20 | * The plugin tries to call env->invoke(). 21 | These calls are ignored when it is safe to do so, but otherwise they 22 | will most likely trigger a fatal error. 23 | * Plugins trying to read global variables. 24 | There are no global variables. 25 | 26 | If there are function name collisions functions will have a number appended 27 | to them to make them distinct. For example if three functions are named 28 | *func* then they will be named *func*, *func_2* and *func_3*. This means 29 | that Avisynth functions that have multiple overloads (rare) will give 30 | each overload a different name. 31 | 32 | Note that if you are really insane you can load Avisynth's VirtualDub plugin 33 | loader and use VirtualDub plugins as well. Function overloads are very common 34 | when dealing with VirtualDub. 35 | 36 | Beware of Python's escape character, this will fail:: 37 | 38 | LoadPlugin(path='c:\plugins\filter.dll') 39 | 40 | Correct ways:: 41 | 42 | LoadPlugin(path='c:/plugins/filter.dll') 43 | LoadPlugin(path=r'c:\plugins\filter.dll') 44 | LoadPlugin(path='c:\\plugins\\filter.dll') 45 | -------------------------------------------------------------------------------- /sdk/filter_skeleton.c: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////// 2 | // This file contains a simple filter 3 | // skeleton you can use to get started. 4 | // With no changes it simply passes 5 | // frames through. 6 | 7 | #include "VapourSynth4.h" 8 | #include "VSHelper4.h" 9 | 10 | typedef struct { 11 | VSNode *node; 12 | const VSVideoInfo *vi; 13 | } FilterData; 14 | 15 | 16 | static const VSFrame *VS_CC filterGetFrame(int n, int activationReason, void *instanceData, void **frameData, VSFrameContext *frameCtx, VSCore *core, const VSAPI *vsapi) { 17 | FilterData *d = (FilterData *)instanceData; 18 | 19 | if (activationReason == arInitial) { 20 | vsapi->requestFrameFilter(n, d->node, frameCtx); 21 | } else if (activationReason == arAllFramesReady) { 22 | const VSFrame *frame = vsapi->getFrameFilter(n, d->node, frameCtx); 23 | 24 | /* your code here... */ 25 | 26 | return frame; 27 | } 28 | 29 | return NULL; 30 | } 31 | 32 | static void VS_CC filterFree(void *instanceData, VSCore *core, const VSAPI *vsapi) { 33 | FilterData *d = (FilterData *)instanceData; 34 | vsapi->freeNode(d->node); 35 | free(d); 36 | } 37 | 38 | static void VS_CC filterCreate(const VSMap *in, VSMap *out, void *userData, VSCore *core, const VSAPI *vsapi) { 39 | FilterData d; 40 | FilterData *data; 41 | 42 | d.node = vsapi->mapGetNode(in, "clip", 0, 0); 43 | d.vi = vsapi->getVideoInfo(d.node); 44 | 45 | data = (FilterData *)malloc(sizeof(d)); 46 | *data = d; 47 | 48 | VSFilterDependency deps[] = {{d.node, rpGeneral}}; /* Depending the the request patterns you may want to change this */ 49 | vsapi->createVideoFilter(out, "Filter", data->vi, filterGetFrame, filterFree, fmParallel, deps, 1, data, core); 50 | } 51 | 52 | ////////////////////////////////////////// 53 | // Init 54 | 55 | VS_EXTERNAL_API(void) VapourSynthPluginInit2(VSPlugin *plugin, const VSPLUGINAPI *vspapi) { 56 | vspapi->configPlugin("com.example.filter", "filter", "VapourSynth Filter Skeleton", VS_MAKE_VERSION(1, 0), VAPOURSYNTH_API_VERSION, 0, plugin); 57 | vspapi->registerFunction("Filter", "clip:vnode;", "clip:vnode;", filterCreate, NULL, plugin); 58 | } 59 | -------------------------------------------------------------------------------- /src/core/kernel/average.h: -------------------------------------------------------------------------------- 1 | #ifndef AVERAGE_H 2 | #define AVERAGE_H 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void vs_average_plane_byte_luma_c(const void *weights, const void * const *srcs, unsigned num_srcs, void *dst, const void *scale, unsigned depth, unsigned w, unsigned h, ptrdiff_t stride); 11 | void vs_average_plane_byte_chroma_c(const void *weights, const void * const *srcs, unsigned num_srcs, void *dst, const void *scale, unsigned depth, unsigned w, unsigned h, ptrdiff_t stride); 12 | void vs_average_plane_word_luma_c(const void *weights, const void * const *srcs, unsigned num_srcs, void *dst, const void *scale, unsigned depth, unsigned w, unsigned h, ptrdiff_t stride); 13 | void vs_average_plane_word_chroma_c(const void *weights, const void * const *srcs, unsigned num_srcs, void *dst, const void *scale, unsigned depth, unsigned w, unsigned h, ptrdiff_t stride); 14 | void vs_average_plane_float_c(const void *weights, const void * const *srcs, unsigned num_srcs, void *dst, const void *scale, unsigned depth, unsigned w, unsigned h, ptrdiff_t stride); 15 | 16 | #ifdef VS_TARGET_CPU_X86 17 | void vs_average_plane_byte_luma_sse2(const void *weights, const void * const *srcs, unsigned num_srcs, void *dst, const void *scale, unsigned depth, unsigned w, unsigned h, ptrdiff_t stride); 18 | void vs_average_plane_byte_chroma_sse2(const void *weights, const void * const *srcs, unsigned num_srcs, void *dst, const void *scale, unsigned depth, unsigned w, unsigned h, ptrdiff_t stride); 19 | void vs_average_plane_word_luma_sse2(const void *weights, const void * const *srcs, unsigned num_srcs, void *dst, const void *scale, unsigned depth, unsigned w, unsigned h, ptrdiff_t stride); 20 | void vs_average_plane_word_chroma_sse2(const void *weights, const void * const *srcs, unsigned num_srcs, void *dst, const void *scale, unsigned depth, unsigned w, unsigned h, ptrdiff_t stride); 21 | void vs_average_plane_float_sse2(const void *weights, const void * const *srcs, unsigned num_srcs, void *dst, const void *scale, unsigned depth, unsigned w, unsigned h, ptrdiff_t stride); 22 | #endif 23 | 24 | #ifdef __cplusplus 25 | } // extern "C" 26 | #endif 27 | 28 | #endif /* AVERAGE_H */ 29 | -------------------------------------------------------------------------------- /src/avfs/include/pfmprefix.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PFMPREFIX_H 3 | #define PFMPREFIX_H 4 | #include "ptpublic.h" 5 | 6 | #define PFM_COMPANY Pismo Technic Inc. 7 | #define PFM_COMPANYA "Pismo Technic Inc." 8 | #define PFM_COMPANYW L"Pismo Technic Inc." 9 | #define PFM_REVURL com.pismotechnic 10 | #define PFM_REVURLA "com.pismotechnic" 11 | #define PFM_REVURLW L"com.pismotechnic" 12 | #define PFM_PRODUCT Pismo File Mount 13 | #define PFM_PRODUCTA "Pismo File Mount" 14 | #define PFM_PRODUCTW L"Pismo File Mount" 15 | #define PFM_PRODID PismoFileMount 16 | #define PFM_PRODIDA "PismoFileMount" 17 | #define PFM_PRODIDW L"PismoFileMount" 18 | #define PFM_COPYRIGHT Pismo Technic Inc. Copyright 2006-2015 Joe Lowe 19 | #define PFM_COPYRIGHTA "Pismo Technic Inc. Copyright 2006-2015 Joe Lowe" 20 | #define PFM_COPYRIGHTW L"Pismo Technic Inc. Copyright 2006-2015 Joe Lowe" 21 | #define PFM_DATE 2015.3.25 22 | #define PFM_DATEA "2015.3.25" 23 | #define PFM_DATEW L"2015.3.25" 24 | #define PFM_BUILDTAG pfm.1.0.0.174 25 | #define PFM_BUILDTAGA "pfm.1.0.0.174" 26 | #define PFM_BUILDTAGW L"pfm.1.0.0.174" 27 | #define PFM_BUILD 174 28 | #define PFM_BUILDA "174" 29 | #define PFM_BUILDW L"174" 30 | #define PFM_PREFIX pfm 31 | #define PFM_PREFIXA "pfm" 32 | #define PFM_PREFIXW L"pfm" 33 | #define PFM_APIID pfmapi 34 | #define PFM_APIIDA "pfmapi" 35 | #define PFM_APIIDW L"pfmapi" 36 | #define PFM_APIBASENAME pfmapi_174 37 | #define PFM_APIBASENAMEA "pfmapi_174" 38 | #define PFM_APIBASENAMEW L"pfmapi_174" 39 | #define PFM_KERNELBASENAME pfmfs_174 40 | #define PFM_KERNELBASENAMEA "pfmfs_174" 41 | #define PFM_KERNELBASENAMEW L"pfmfs_174" 42 | #define PFM_CMDBASENAME pfm 43 | #define PFM_CMDBASENAMEA "pfm" 44 | #define PFM_CMDBASENAMEW L"pfm" 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/core/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2021 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "VapourSynth4.h" 22 | #include "VapourSynth3.h" 23 | 24 | /* 25 | 26 | Note that the version is stored in several places, in addition to version.h it's also in: 27 | src/cython/vapoursynth.pyx (__version__) 28 | setup.py (version = "" near the bottom) 29 | configure.ac (number on first line in []) 30 | installer/vsinstaller.iss (Version define at top) 31 | installer/setup.py (CURRENT_RELEASE at the top) 32 | doc/conf.py (version = '' near the top) 33 | 34 | */ 35 | 36 | #define XSTR(x) STR(x) 37 | #define STR(x) #x 38 | #define VAPOURSYNTH_CORE_VERSION 57 39 | #define VAPOURSYNTH_INTERNAL_PLUGIN_VERSION VS_MAKE_VERSION(VAPOURSYNTH_CORE_VERSION, 0) 40 | #if defined(VS_FRAME_GUARD) && !defined(NDEBUG) 41 | #define VS_OPTIONS_TEXT "Options: Frame Guard + Extra Assertions\n" 42 | #elif defined(VS_FRAME_GUARD) 43 | #define VS_OPTIONS_TEXT "Options: Frame Guard\n" 44 | #elif !defined(NDEBUG) 45 | #define VS_OPTIONS_TEXT "Options: Extra Assertions\n" 46 | #else 47 | #define VS_OPTIONS_TEXT "Options: -\n" 48 | #endif 49 | #define VAPOURSYNTH_VERSION_STRING "VapourSynth Video Processing Library\n" \ 50 | "Copyright (c) 2012-2021 Fredrik Mellbin\n" \ 51 | "Core R" XSTR(VAPOURSYNTH_CORE_VERSION) "\n" \ 52 | "API R" XSTR(VAPOURSYNTH_API_MAJOR) "." XSTR(VAPOURSYNTH_API_MINOR) "\n" \ 53 | "API R" XSTR(VAPOURSYNTH3_API_MAJOR) "." XSTR(VAPOURSYNTH3_API_MINOR) "\n" \ 54 | VS_OPTIONS_TEXT 55 | -------------------------------------------------------------------------------- /src/avisynth/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/filters/avisource/DubSource.cpp: -------------------------------------------------------------------------------- 1 | // VirtualDub - Video processing and capture application 2 | // Copyright (C) 1998-2001 Avery Lee 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. 17 | 18 | #include "stdafx.h" 19 | 20 | #include "DubSource.h" 21 | 22 | BOOL DubSource::init() { 23 | return TRUE; 24 | } 25 | 26 | bool DubSource::isStreaming() { 27 | return false; 28 | } 29 | 30 | int DubSource::read(LONG lStart, LONG lCount, LPVOID lpBuffer, LONG cbBuffer, LONG *lBytesRead, LONG *lSamplesRead) { 31 | if (lStart < lSampleFirst) return AVIERR_BADPARAM; 32 | if (lStart >= lSampleLast) { 33 | if (lSamplesRead) 34 | *lSamplesRead = 0; 35 | if (lBytesRead) 36 | *lBytesRead = 0; 37 | return 0; 38 | } 39 | 40 | if (lCount>0 && lCount > lSampleLast - lStart) lCount = lSampleLast - lStart; 41 | 42 | return _read(lStart, lCount, lpBuffer, cbBuffer, lBytesRead, lSamplesRead); 43 | } 44 | 45 | BOOL DubSource::isKey(LONG lSample) { 46 | if (lSample=lSampleLast) return TRUE; 47 | 48 | return _isKey(lSample); 49 | } 50 | 51 | BOOL DubSource::_isKey(LONG lSample) { 52 | return TRUE; 53 | } 54 | 55 | LONG DubSource::nearestKey(LONG lSample) { 56 | return lSample; 57 | } 58 | 59 | LONG DubSource::prevKey(LONG lSample) { 60 | return lSample <= lSampleFirst ? -1 : lSample-1; 61 | } 62 | 63 | LONG DubSource::nextKey(LONG lSample) { 64 | return lSample+1 >= lSampleFirst ? -1 : lSample+1; 65 | } 66 | 67 | void DubSource::streamBegin(bool fRealTime) { 68 | } 69 | 70 | void DubSource::streamEnd() { 71 | } 72 | 73 | -------------------------------------------------------------------------------- /src/avisynth/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 | 38 | #ifdef __cplusplus 39 | #include 40 | #else 41 | #include 42 | #endif 43 | 44 | // Raster types used by VirtualDub & Avisynth 45 | typedef unsigned int Pixel32; 46 | typedef unsigned char BYTE; 47 | 48 | // Audio Sample information 49 | typedef float SFLOAT; 50 | 51 | #ifdef __GNUC__ 52 | typedef long long int INT64; 53 | #else 54 | typedef __int64 INT64; 55 | #endif 56 | 57 | #endif //AVS_TYPES_H 58 | -------------------------------------------------------------------------------- /src/core/internalfilters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef INTERNALFILTERS_H 22 | #define INTERNALFILTERS_H 23 | 24 | #include "VapourSynth4.h" 25 | 26 | void stdlibInitialize(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 27 | void mergeInitialize(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 28 | void reorderInitialize(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 29 | void audioInitialize(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 30 | void textInitialize(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 31 | void exprInitialize(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 32 | void genericInitialize(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 33 | void lutInitialize(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 34 | void boxBlurInitialize(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 35 | void resizeInitialize(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 36 | void averageFramesInitialize(VSPlugin *plugin, const VSPLUGINAPI *vspapi); 37 | 38 | #ifdef VS_USE_MIMALLOC 39 | 40 | #include 41 | template 42 | static inline T *internal_aligned_malloc(size_t size, size_t alignment) { 43 | return static_cast(mi_malloc_aligned(size, alignment)); 44 | } 45 | 46 | static inline void internal_aligned_free(void *ptr) { 47 | mi_free(ptr); 48 | } 49 | 50 | #else 51 | 52 | #include "VSHelper4.h" 53 | 54 | #define internal_aligned_malloc vsh::vsh_aligned_malloc 55 | #define internal_aligned_free vsh::vsh_aligned_free 56 | 57 | #endif // VS_USE_MIMALLOC 58 | 59 | #endif // INTERNALFILTERS_H 60 | -------------------------------------------------------------------------------- /doc/functions/audio/shufflechannels.rst: -------------------------------------------------------------------------------- 1 | ShuffleChannels 2 | =============== 3 | 4 | .. function:: ShuffleChannels(anode[] clips, int[] channels_in, int[] channels_out) 5 | :module: std 6 | 7 | ShuffleChannels can extract and combine channels from different clips in the most 8 | general way possible. 9 | 10 | Most of the returned clip's properties are implicitly determined from the 11 | first clip given to *clips*. 12 | 13 | The *clips* parameter takes one or more clips with the same format. If the clips 14 | are different lengths they'll be zero extended to that of the longest. 15 | 16 | The argument *channels_in* controls which of the input clips' channels to use and 17 | takes a channel constants as its argument. Specifying a non-existent channel 18 | is an error. If more *channels_in* than *clips* values are specified then the last 19 | clip in the *clips* list is reused as a source. In addition to the channel constant 20 | it's also possible to specify the nth channel by using negative numbers. 21 | 22 | The output channel mapping is determined by *channels_out* and corresponds to the 23 | input channel order. The number of *channels_out* entries must be the same as the 24 | number of *channels_in* entries. Specifying the same output channel twice is an error. 25 | 26 | 27 | 28 | Below are some examples of useful operations. 29 | 30 | Extract the left channel (assuming it exists):: 31 | 32 | ShuffleChannels(clips=clip, channels_in=vs.FRONT_LEFT, channels_out=vs.FRONT_LEFT) 33 | 34 | Swap left and right audio channels in a stereo clip:: 35 | 36 | ShuffleChannels(clips=clip, channels_in=[vs.FRONT_RIGHT, vs.FRONT_LEFT], channels_out=[vs.FRONT_LEFT, vs.FRONT_RIGHT]) 37 | 38 | Swap left and right audio channels in a stereo clip (alternate ordering of arguments):: 39 | 40 | ShuffleChannels(clips=clip, channels_in=[vs.FRONT_LEFT, vs.FRONT_RIGHT], channels_out=[vs.FRONT_RIGHT, vs.FRONT_LEFT]) 41 | 42 | Swap left and right audio channels in a stereo clip (alternate indexing):: 43 | 44 | ShuffleChannels(clips=clip, channels_in=[-2, -1], channels_out=[vs.FRONT_LEFT, vs.FRONT_RIGHT]) 45 | 46 | Merge 2 mono audio clips into a single stereo clip:: 47 | 48 | ShuffleChannels(clips=[clipa, clipb], channels_in=[vs.FRONT_LEFT, vs.FRONT_LEFT], channels_out=[vs.FRONT_LEFT, vs.FRONT_RIGHT]) 49 | -------------------------------------------------------------------------------- /src/core/kernel/planestats.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2019 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef PLANESTATS_H 22 | #define PLANESTATS_H 23 | 24 | #include 25 | #include 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | union vs_plane_stats { 32 | struct { 33 | unsigned min; 34 | unsigned max; 35 | uint64_t acc; 36 | uint64_t diffacc; 37 | } i; 38 | 39 | struct { 40 | float min; 41 | float max; 42 | double acc; 43 | double diffacc; 44 | } f; 45 | }; 46 | 47 | #define DECL_1(pixel, isa) void vs_plane_stats_1_##pixel##_##isa(union vs_plane_stats *stats, const void *src, ptrdiff_t stride, unsigned width, unsigned height); 48 | #define DECL_2(pixel, isa) void vs_plane_stats_2_##pixel##_##isa(union vs_plane_stats *stats, const void *src1, ptrdiff_t src1_stride, const void *src2, ptrdiff_t src2_stride, unsigned width, unsigned height); 49 | 50 | DECL_1(byte, c) 51 | DECL_1(word, c) 52 | DECL_1(float, c) 53 | 54 | DECL_2(byte, c) 55 | DECL_2(word, c) 56 | DECL_2(float, c) 57 | 58 | #ifdef VS_TARGET_CPU_X86 59 | DECL_1(byte, sse2) 60 | DECL_1(word, sse2) 61 | DECL_1(float, sse2) 62 | 63 | DECL_2(byte, sse2) 64 | DECL_2(word, sse2) 65 | DECL_2(float, sse2) 66 | 67 | DECL_1(byte, avx2) 68 | DECL_1(word, avx2) 69 | DECL_1(float, avx2) 70 | 71 | DECL_2(byte, avx2) 72 | DECL_2(word, avx2) 73 | DECL_2(float, avx2) 74 | #endif /* VS_TARGET_CPU_X86 */ 75 | 76 | #undef DECL_2 77 | #undef DECL_1 78 | 79 | #ifdef __cplusplus 80 | } // extern "C" 81 | #endif 82 | 83 | #endif -------------------------------------------------------------------------------- /src/avfs/include/pfmformatter.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // Copyright 2006-2013 Joe Lowe 3 | // 4 | // Permission is granted to any person obtaining a copy of this Software, 5 | // to deal in the Software without restriction, including the rights to use, 6 | // copy, modify, merge, publish, distribute, sublicense, and sell copies of 7 | // the Software. 8 | // 9 | // The above copyright and permission notice must be left intact in all 10 | // copies or substantial portions of the Software. 11 | // 12 | // THE SOFTWARE IS WITHOUT WARRANTY. 13 | //--------------------------------------------------------------------------- 14 | // file name: pfmformatter.h 15 | // created: 2006.08.01 16 | //--------------------------------------------------------------------------- 17 | #ifndef PFMFORMATTER_H 18 | #define PFMFORMATTER_H 19 | #include "ptfactory1.h" 20 | #include "pfmprefix.h" 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #define INTERFACE_NAME PfmFormatter 26 | PT_INTERFACE_DEFINE 27 | { 28 | PT_INTERFACE_FUN0( void , Release ); 29 | PT_INTERFACE_FUNC( int/*systemError*/, Identify, PT_FD_T statusWrite,const wchar_t* mountFileName,PT_FD_T mountFileHandle,const void* mountFileData,size_t mountFileDataSize); 30 | PT_INTERFACE_FUNC( int/*systemError*/, Serve , const wchar_t* mountFileName,int mountFlags,PT_FD_T toFormatterRead,PT_FD_T fromFormatterWrite); 31 | PT_INTERFACE_FUN0( void , Cancel ); 32 | }; 33 | #undef INTERFACE_NAME 34 | 35 | #define PfmFormatterFactory PfmFormatterFactory2 36 | PT_EXPORT int/*systemError*/ PT_CCALL PfmFormatterFactory(PfmFormatter**); 37 | 38 | #define INTERFACE_NAME PfmConnector 39 | PT_INTERFACE_DEFINE 40 | { 41 | PT_INTERFACE_FUN0( void , Release ); 42 | PT_INTERFACE_FUN0( void , Cancel ); 43 | PT_INTERFACE_FUNC( int/*systemError*/, Identify, PT_FD_T statusWrite,const wchar_t* mountFileName,PT_FD_T mountFileHandle,const void* mountFileData,size_t mountFileDataSize); 44 | PT_INTERFACE_FUNC( int/*systemError*/, Connect , PT_FD_T statusWrite,const wchar_t* mountFileName,int mountFlags,PT_FD_T* fromFormatterRead,PT_FD_T* toFormatterWrite); 45 | }; 46 | #undef INTERFACE_NAME 47 | 48 | #define PfmConnectorFactory PfmConnectorFactory2 49 | PT_EXPORT int/*systemError*/ PT_CCALL PfmConnectorFactory(PfmConnector**); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif 55 | -------------------------------------------------------------------------------- /src/avisynth/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 | 46 | #include 47 | 48 | // Provision for UTF-8 max 4 bytes per code point 49 | #define AVS_MAX_PATH MAX_PATH*4 50 | 51 | #endif // AVSCORE_WIN_H 52 | -------------------------------------------------------------------------------- /test/expr_compiler/muvs_exprs.txt: -------------------------------------------------------------------------------- 1 | 255 1 x 0.0001 + y 0.0001 + / 1.0 pow + / 2 | y 0.0001 + x 0.0001 + dup * y 0.0001 + dup * + sqrt / 255 * 3 | y x - abs 1 + 1.5 pow 1 - 4 | y x - 20.17 * 32768 + 5 | x 0.9999 - 1.0001 0.9999 - / 255 * 6 | x 0 < 16 x ? 255 > 235 x ? 7 | x x * y y * + z z * + a a * + sqrt 8 | x y max z max a max 9 | x y + z + a + b + 4 / 10 | x y max z max a max b max c max d max e max 11 | x y + z + a + b + c + d + e + 8 / 12 | x x * y y * + z z * + a a * + b b * + c c * + d d * + e e * + 8 / sqrt 13 | x y max 128 / 0.86 pow 255 * 14 | x 128 - abs y 128 - abs < x y ? 15 | x x * y y * + 1 / sqrt 65535 > 255 x x * y y * + 1 / sqrt 0 < 0 x x * y y * + 1 / sqrt ? ? 16 | x 128 - y 128 - * 0 < x 128 - 0.24 * 128 + x 128 - abs y 128 - abs > x 0.24 * y 0.76 * + x ? ? 17 | x y and 255 y 128 0 ? ? 18 | x 2 + y < x 2 + x 2 - y > x 2 - y ? ? 19 | x -1 + y < x 3 + x -1 - y > x 3 - x 1 * y 99 * + 100 / ? ? 20 | y 128 2 + > x 2 - y 128 2 - < x 2 + x y 128 - - ? ? 21 | y 128 = x x y 128 - abs 1 / 1 4 / pow 1 * y 128 - y 128 - abs / * - ? 22 | x 128 < y 128 < xor x 128 - 100 / 100 * 128 + x 128 - abs y 128 - abs > x 100 * y 0 * + 100 / x ? ? 23 | x 128 < y 128 < xor x 128 - 100 / 75 * 128 + x 128 - abs y 128 - abs > x 75 * y 25 * + 100 / x ? ? 24 | x 8 + y < x 8 + x 24 - y > x 24 - y ? ? x y - abs * x 32 x y - abs - * + 32 / 25 | x y - abs 1 < 128 x y - 3.2 / abs 128 x y - 3.2 / abs - x y - 3.2 / abs 128 / * + x y - 3.2 / x y - 3.2 / abs 0 + / * 128 x y - 3.2 / abs - 20 / dup * 128 x y - 3.2 / abs - 20 / dup * 0 + / * 128 + ? 26 | x 0.001 1 1 1 0.03 y 0.5 - * exp + / - * z / + a 0.001 z / + / 27 | 2 x y * sqrt * 0.0026 + x y + 0.0026 + / 28 | 2 x * 0.01 + 2 y x - * 0.03 + * z a + 0.01 + b c - d e - + 0.03 + * / 29 | x y * 0 > 2 z * 0.01 + 3 a z - * 0.03 + * x y * / x 0 = not y 0 = and 2 z * 0.01 + x / 1 ? ? 30 | x z - 0.000001 < 0 y z - x z - / sqrt ? 31 | x y - z sqrt 0.0000001 + / b sqrt * a + 32 | x y = 0 255 ? 33 | x y - x z - xor x x y - abs x z - abs < y z ? ? 34 | y z - abs 2 <= y x <= and y x ? 35 | 1 x 0.00001 + 100 * 1 + / 36 | x y / 1 z y / - a * + 37 | x y * 2 * 0.00215 + x dup * y dup * + 0.00215 + / 38 | x y * z a * + 2 * 0.00846 + x dup * y dup * + z dup * + a dup * + 0.00846 + / 39 | x 0.6 * y 0.4 * + 0 max 1 min 0.25 pow 40 | x 128 - abs y 128 - abs < x 128 - abs x y + 256 - abs < and x 128 - abs dup sqrt - dup * y 128 - abs x y + 256 - abs < y 128 - abs dup sqrt - dup * x y + 256 - abs dup sqrt - dup * ? ? x 128 - y 128 - * 0 > -1 1 ? * 128 + 41 | -------------------------------------------------------------------------------- /src/core/kernel/transpose.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2019 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #define VS_TRANSPOSE_IMPL 22 | #define BLOCK_WIDTH_BYTE 1 23 | #define BLOCK_HEIGHT_BYTE 1 24 | #define BLOCK_WIDTH_WORD 1 25 | #define BLOCK_HEIGHT_WORD 1 26 | #define BLOCK_WIDTH_DWORD 1 27 | #define BLOCK_HEIGHT_DWORD 1 28 | #include "transpose.h" 29 | 30 | static void transpose_block_byte(const uint8_t * VS_RESTRICT src, ptrdiff_t src_stride, uint8_t * VS_RESTRICT dst, ptrdiff_t dst_stride) 31 | { 32 | *dst = *src; 33 | } 34 | 35 | static void transpose_block_word(const uint16_t * VS_RESTRICT src, ptrdiff_t src_stride, uint16_t * VS_RESTRICT dst, ptrdiff_t dst_stride) 36 | { 37 | *dst = *src; 38 | } 39 | 40 | static void transpose_block_dword(const uint32_t * VS_RESTRICT src, ptrdiff_t src_stride, uint32_t * VS_RESTRICT dst, ptrdiff_t dst_stride) 41 | { 42 | *dst = *src; 43 | } 44 | 45 | void vs_transpose_plane_byte_c(const void * VS_RESTRICT src, ptrdiff_t src_stride, void * VS_RESTRICT dst, ptrdiff_t dst_stride, unsigned width, unsigned height) 46 | { 47 | transpose_plane_byte(src, src_stride, dst, dst_stride, width, height); 48 | } 49 | 50 | void vs_transpose_plane_word_c(const void * VS_RESTRICT src, ptrdiff_t src_stride, void * VS_RESTRICT dst, ptrdiff_t dst_stride, unsigned width, unsigned height) 51 | { 52 | transpose_plane_word(src, src_stride, dst, dst_stride, width, height); 53 | } 54 | 55 | void vs_transpose_plane_dword_c(const void * VS_RESTRICT src, ptrdiff_t src_stride, void * VS_RESTRICT dst, ptrdiff_t dst_stride, unsigned width, unsigned height) 56 | { 57 | transpose_plane_dword(src, src_stride, dst, dst_stride, width, height); 58 | } 59 | -------------------------------------------------------------------------------- /src/core/intrusive_ptr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef INTRUSIVE_PTR_H 22 | #define INTRUSIVE_PTR_H 23 | 24 | #include 25 | 26 | template 27 | class vs_intrusive_ptr { 28 | private: 29 | T *obj; 30 | public: 31 | vs_intrusive_ptr(T *ptr = nullptr, bool add_ref = false) noexcept { 32 | obj = ptr; 33 | if (add_ref && obj) 34 | obj->add_ref(); 35 | } 36 | 37 | vs_intrusive_ptr(const vs_intrusive_ptr &ptr) noexcept { 38 | obj = ptr.obj; 39 | if (obj) 40 | obj->add_ref(); 41 | } 42 | 43 | vs_intrusive_ptr(vs_intrusive_ptr &&ptr) noexcept { 44 | obj = ptr.obj; 45 | ptr.obj = nullptr; 46 | } 47 | 48 | ~vs_intrusive_ptr() noexcept { 49 | if (obj) 50 | obj->release(); 51 | } 52 | 53 | vs_intrusive_ptr &operator=(vs_intrusive_ptr const &ptr) noexcept { 54 | if (obj) 55 | obj->release(); 56 | obj = ptr.obj; 57 | if (obj) 58 | obj->add_ref(); 59 | return *this; 60 | } 61 | 62 | T *operator->() const noexcept { 63 | return obj; 64 | } 65 | 66 | T &operator*() const noexcept { 67 | return *obj; 68 | } 69 | 70 | operator bool() const noexcept { 71 | return !!obj; 72 | } 73 | 74 | T *get() const noexcept { 75 | return obj; 76 | } 77 | 78 | void reset() noexcept { 79 | if (obj) { 80 | obj->release(); 81 | obj = nullptr; 82 | } 83 | } 84 | 85 | void swap(vs_intrusive_ptr &ptr) noexcept { 86 | std::swap(obj, ptr.obj); 87 | } 88 | }; 89 | 90 | #endif -------------------------------------------------------------------------------- /doc/applications.rst: -------------------------------------------------------------------------------- 1 | Applications and Libraries 2 | ========================== 3 | 4 | Applications 5 | ############ 6 | * `D2V Witch `_ -- creates indexes that can be opened by d2vsource 7 | * `Hybrid `_ `(Doom9) `__ -- encoding GUI with VapourSynth support 8 | * `mpv.net `_ -- a media player with VapourSynth built-in 9 | * `SmoothVideo Project `_ -- a plugin/video player component for realtime frame interpolation 10 | * `StaxRip `_ -- encoding GUI with extended VapourSynth scripting support 11 | * `VapourSynth Editor `_ `(Doom9) `__ -- an editor with syntax completion and fast preview support 12 | * `VapourSynth Editor 2 `_ `(Doom9) `__ -- a spiritual successor to VapourSynth Editor 13 | * `VirtualDub2 `_ `(Doom9) `__ -- VirtualDub with added support for high bitdepth colorspaces, useful for previewing 14 | * `vsmkv `_ -- a FUSE-based virtual filesystem for exporting VapourSynth scripts as uncompressed videos in the Matroska (MKV) file format 15 | * `vspreview `_ -- an advanced standalone previewer written in python with too many features to list 16 | * `vspreview-rs `_ `(Doom9) `__ -- minimal VapourSynth script previewer 17 | * `Wobbly `_ `(Doom9) `__ -- IVTC assistant similar to YATTA 18 | * `Yuuno `_ -- incorporates VapourSynth into Jupyter 19 | 20 | Libraries 21 | ######### 22 | * `VapourSynth.nim `_ -- Bindings for the Nim programming language 23 | * `vapoursynth-rs `_ -- VapourSynth Rust wrapper 24 | * `vsxx `_ -- VapourSynth C++ API wrapper 25 | 26 | Tools 27 | ##### 28 | 29 | * GitHub Action `install-vapoursynth `_ -- Installs vapoursynth in your GitHub Action. 30 | -------------------------------------------------------------------------------- /src/filters/avisource/clip_info.h: -------------------------------------------------------------------------------- 1 | // Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al. 2 | // http://www.avisynth.org 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 | // Linking Avisynth statically or dynamically with other modules is making a 20 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 21 | // General Public License cover the whole combination. 22 | // 23 | // As a special exception, the copyright holders of Avisynth give you 24 | // permission to link Avisynth with independent modules that communicate with 25 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 26 | // terms of these independent modules, and to copy and distribute the 27 | // resulting combined work under terms of your choice, provided that 28 | // every copy of the combined work is accompanied by a complete copy of 29 | // the source code of Avisynth (the version of Avisynth used to produce the 30 | // combined work), being distributed under the terms of the GNU General 31 | // Public License plus this exception. An independent module is a module 32 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 33 | // import and export plugins, or graphical user interfaces. 34 | 35 | #ifndef __CLIP_INFO_H__ 36 | #define __CLIP_INFO_H__ 37 | 38 | 39 | //extern "C" const GUID CLSID_CAVIFileSynth; // {E6D6B700-124D-11D4-86F3-DB80AFD98778} 40 | 41 | extern "C" const GUID IID_IAvisynthClipInfo // {E6D6B708-124D-11D4-86F3-DB80AFD98778} 42 | = {0xe6d6b708, 0x124d, 0x11d4, {0x86, 0xf3, 0xdb, 0x80, 0xaf, 0xd9, 0x87, 0x78}}; 43 | 44 | struct IAvisynthClipInfo : IUnknown { 45 | virtual int __stdcall GetError(const char** ppszMessage) = 0; 46 | virtual bool __stdcall GetParity(int n) = 0; 47 | virtual bool __stdcall IsFieldBased() = 0; 48 | }; 49 | 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /msvc_project/VSPipe/VSPipe.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/filters/morpho/morpho_selems.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple morphological filters 3 | * 4 | * Copyright (c) 2014, Martin Herkt 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 11 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 12 | * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 13 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 14 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 15 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 | * PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "morpho_selems.h" 24 | 25 | const SElemFunc SElemFuncs[] = { 26 | SquareSElem, 27 | DiamondSElem, 28 | CircleSElem, 29 | NULL 30 | }; 31 | 32 | void SquareSElem(uint8_t *selem, int size) { 33 | memset(selem, 1, sizeof(uint8_t) * size * size); 34 | } 35 | 36 | void DiamondSElem(uint8_t *selem, int size) { 37 | int x, y; 38 | int hs = size / 2; 39 | 40 | for (y = 0; y < size; y++) { 41 | for (x = 0; x < size; x++) { 42 | *selem++ = (abs(x - hs) - (hs - abs(y - hs)) <= 0); 43 | } 44 | } 45 | } 46 | 47 | void CircleSElem(uint8_t *selem, int size) { 48 | int r = size / 2; 49 | int f = 1 - r; 50 | int ddFx = 0, ddFy = -(r << 1); 51 | int x, y; 52 | 53 | for (x = 0, y = r; x < y;) { 54 | if (f >= 0) { 55 | int x1 = r - x, x2 = r + x; 56 | int y1 = r - y, y2 = r + y; 57 | int i; 58 | 59 | for (i = x1; i < x2; i++) { 60 | selem[i + y1 * size] = 1; 61 | selem[i + y2 * size] = 1; 62 | } 63 | 64 | f += (ddFy += 2); 65 | y--; 66 | } 67 | 68 | f += (ddFx += 2); 69 | 70 | if (y != x++) { 71 | int x1 = r - y, x2 = r + y; 72 | int y1 = r - x, y2 = r + x; 73 | int i; 74 | 75 | for (i = x1; i < x2; i++) { 76 | selem[i + y1 * size] = 1; 77 | selem[i + y2 * size] = 1; 78 | } 79 | } 80 | 81 | } 82 | 83 | for (y = 0; y < r * 2; y++) { 84 | selem[y + (r * size)] = 9; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/avfs/xxfs.h: -------------------------------------------------------------------------------- 1 | // xxfs.h : Avisynth Virtual File System 2 | // 3 | // Avisynth v2.5. Copyright 2008 Ben Rudiak-Gould et al. 4 | // http://www.avisynth.org 5 | 6 | // This program is free software; you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation; either version 2 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program; if not, write to the Free Software 18 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 19 | // http://www.gnu.org/copyleft/gpl.html . 20 | // 21 | // Linking Avisynth statically or dynamically with other modules is making a 22 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 23 | // General Public License cover the whole combination. 24 | // 25 | // As a special exception, the copyright holders of Avisynth give you 26 | // permission to link Avisynth with independent modules that communicate with 27 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 28 | // terms of these independent modules, and to copy and distribute the 29 | // resulting combined work under terms of your choice, provided that 30 | // every copy of the combined work is accompanied by a complete copy of 31 | // the source code of Avisynth (the version of Avisynth used to produce the 32 | // combined work), being distributed under the terms of the GNU General 33 | // Public License plus this exception. An independent module is a module 34 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 35 | // import and export plugins, or graphical user interfaces. 36 | #ifndef XXFS_H 37 | #define XXFS_H 38 | 39 | struct VideoInfoAdapter; 40 | 41 | struct Synther_ { 42 | virtual void AddRef(void) = 0; 43 | virtual void Release(void) = 0; 44 | 45 | virtual bool GetAudio(AvfsLog_* log, void* buf, __int64 start, unsigned count) = 0; 46 | virtual VideoInfoAdapter GetVideoInfo() = 0; 47 | 48 | virtual const char* GetVarAsString(const char* varName, const char* defVal) = 0; 49 | virtual bool GetVarAsBool(const char* varName, bool defVal) = 0; 50 | virtual int GetVarAsInt(const char* varName, int defVal) = 0; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /doc/functions/video/minimum_maximum.rst: -------------------------------------------------------------------------------- 1 | Minimum/Maximum 2 | =============== 3 | 4 | .. function:: Minimum(vnode clip[, int[] planes=[0, 1, 2], float threshold, bint[] coordinates=[1, 1, 1, 1, 1, 1, 1, 1]]) 5 | :module: std 6 | 7 | Replaces each pixel with the smallest value in its 3x3 neighbourhood. 8 | This operation is also known as erosion. 9 | 10 | *clip* 11 | Clip to process. It must have integer sample type and bit depth 12 | between 8 and 16, or float sample type and bit depth of 32. If 13 | there are any frames with other formats, an error will be 14 | returned. 15 | 16 | *planes* 17 | Specifies which planes will be processed. Any unprocessed planes 18 | will be simply copied. 19 | 20 | *threshold* 21 | Allows to limit how much pixels are changed. Output pixels will not 22 | become less than ``input - threshold``. The default is no limit. 23 | 24 | *coordinates* 25 | Specifies which pixels from the 3x3 neighbourhood are considered. 26 | If an element of this array is 0, the corresponding pixel is not 27 | considered when finding the minimum value. This must contain exactly 28 | 8 numbers. 29 | 30 | Here is how each number corresponds to a pixel in the 3x3 31 | neighbourhood:: 32 | 33 | 1 2 3 34 | 4 5 35 | 6 7 8 36 | 37 | 38 | .. function:: Maximum(vnode clip[, int[] planes=[0, 1, 2], float threshold, bint[] coordinates=[1, 1, 1, 1, 1, 1, 1, 1]]) 39 | :module: std 40 | 41 | Replaces each pixel with the largest value in its 3x3 neighbourhood. 42 | This operation is also known as dilation. 43 | 44 | *clip* 45 | Clip to process. It must have integer sample type and bit depth 46 | between 8 and 16, or float sample type and bit depth of 32. If 47 | there are any frames with other formats, an error will be 48 | returned. 49 | 50 | *planes* 51 | Specifies which planes will be processed. Any unprocessed planes 52 | will be simply copied. 53 | 54 | *threshold* 55 | Allows to limit how much pixels are changed. Output pixels will not 56 | become less than ``input - threshold``. The default is no limit. 57 | 58 | *coordinates* 59 | Specifies which pixels from the 3x3 neighbourhood are considered. 60 | If an element of this array is 0, the corresponding pixel is not 61 | considered when finding the maximum value. This must contain exactly 62 | 8 numbers. 63 | 64 | Here is how each number corresponds to a pixel in the 3x3 65 | neighbourhood:: 66 | 67 | 1 2 3 68 | 4 5 69 | 6 7 8 70 | -------------------------------------------------------------------------------- /src/avfs/avfspfm.h: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------------- 2 | // Copyright 2008 Joe Lowe 3 | // 4 | // Permission is granted to any person obtaining a copy of this Software, 5 | // to deal in the Software without restriction, including the rights to use, 6 | // copy, modify, merge, publish, distribute, sublicense, and sell copies of 7 | // the Software. 8 | // 9 | // The above copyright and permission notice must be left intact in all 10 | // copies or substantial portions of the Software. 11 | // 12 | // THE SOFTWARE IS WITHOUT WARRANTY. 13 | //---------------------------------------------------------------------------- 14 | // file name: avfspfm.h 15 | // created: 2008.01.07 16 | //---------------------------------------------------------------------------- 17 | #ifndef AVFSPFM_H 18 | #define AVFSPFM_H 19 | 20 | static const char avfsFormatterName[] = "AVFS"; 21 | static const char avisynthFileTypeTag[] = "avisynth"; 22 | 23 | struct AvfsLog_ 24 | { 25 | virtual void Print(const wchar_t* data) = 0; 26 | virtual void Vprintf(const wchar_t* format,va_list args) = 0; 27 | virtual void Printf(const wchar_t* format,...) = 0; 28 | virtual void Line(const wchar_t* data) = 0; 29 | }; 30 | 31 | struct AvfsMediaFile_ 32 | { 33 | virtual void AddRef(void) = 0; 34 | virtual void Release(void) = 0; 35 | virtual bool/*success*/ ReadMedia(AvfsLog_* log,uint64_t fileOffset,void* buffer,size_t requestedSize) = 0; 36 | }; 37 | 38 | struct AvfsVolume_ 39 | { 40 | // Returns full file name of real script file. 41 | // (c:\bob\myscript.avs) 42 | // Real script file on disk is accessible since the 43 | // virtual file system is not visible in this process. 44 | virtual const wchar_t* GetScriptFileName(void) = 0; 45 | // Returns file name of script file with no directory 46 | // component. (myscript.avs) 47 | virtual const wchar_t* GetScriptEndName(void) = 0; 48 | // Returns base name of script file, no directory or 49 | // extension. (myscript) 50 | virtual const wchar_t* GetMediaName(void) = 0; 51 | // Get in memory copy of current contents of script file. 52 | virtual const char* GetScriptData(void) = 0; 53 | virtual size_t GetScriptDataSize(void) = 0; 54 | // Add a virtual media file. 55 | virtual void CreateMediaFile( 56 | AvfsMediaFile_* mediaFile, 57 | const wchar_t* endName, 58 | uint64_t fileSize) = 0; 59 | }; 60 | 61 | void AvfsProcessScript(AvfsLog_* log,AvfsVolume_* volume); 62 | void VsfsProcessScript(AvfsLog_* log, AvfsVolume_* volume); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/core/expr/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "VapourSynth4.h" 4 | #include "expr.h" 5 | 6 | using namespace expr; 7 | 8 | static const char *op_names[] = { 9 | "loadu8", "loadu16", "loadf16", "loadf32", "constant", 10 | "storeu8", "storeu16", "storef16", "storef32", 11 | "add", "sub", "mul", "div", "fma", "sqrt", "abs", "neg", "max", "min", "cmp", 12 | "and", "or", "xor", "not", 13 | "exp", "log", "pow", "sin", "cos", 14 | "ternary", 15 | "mux", 16 | "dup", "swap", 17 | }; 18 | static_assert(sizeof(op_names) / sizeof(op_names[0]) == static_cast(ExprOpType::SWAP) + 1, ""); 19 | 20 | static const char *cmp_names[8] = { 21 | "EQ", "LT", "LE", "?", "NEQ", "NLT", "NLE", "?" 22 | }; 23 | 24 | int main(int argc, char **argv) try 25 | { 26 | VSVideoInfo realvi{}; 27 | const VSVideoInfo *vi[26]; 28 | 29 | realvi.format.bytesPerSample = 1; 30 | realvi.format.sampleType = stInteger; 31 | 32 | for (int i = 0; i < 26; ++i) { 33 | vi[i] = &realvi; 34 | } 35 | 36 | if (argc >= 2) { 37 | std::cout << argv[1] << '\n'; 38 | bool optimize = argc > 2 ? !!std::atoi(argv[2]) : true; 39 | 40 | std::vector code = compile(argv[1], vi, 26, realvi, optimize); 41 | 42 | for (auto &insn : code) { 43 | std::cout << std::setw(12) << std::left << op_names[static_cast(insn.op.type)]; 44 | 45 | if (insn.op.type == ExprOpType::MEM_STORE_U8 || insn.op.type == ExprOpType::MEM_STORE_U16 || insn.op.type == ExprOpType::MEM_STORE_F16 || insn.op.type == ExprOpType::MEM_STORE_F32) { 46 | std::cout << " r" << insn.src1 << '\n'; 47 | continue; 48 | } 49 | 50 | std::cout << " r" << insn.dst; 51 | 52 | if (insn.src1 >= 0) 53 | std::cout << ",r" << insn.src1; 54 | if (insn.src2 >= 0) 55 | std::cout << ",r" << insn.src2; 56 | if (insn.src3 >= 0) 57 | std::cout << ",r" << insn.src3; 58 | 59 | switch (insn.op.type) { 60 | case ExprOpType::MEM_LOAD_U8: 61 | case ExprOpType::MEM_LOAD_U16: 62 | case ExprOpType::MEM_LOAD_F16: 63 | case ExprOpType::MEM_LOAD_F32: 64 | std::cout << ',' << static_cast(insn.op.imm.u < 3 ? 'x' + insn.op.imm.u : 'a' + insn.op.imm.u - 3); 65 | break; 66 | case ExprOpType::CONSTANT: 67 | std::cout << ',' << insn.op.imm.f; 68 | break; 69 | case ExprOpType::FMA: 70 | std::cout << "," << insn.op.imm.u; 71 | break; 72 | case ExprOpType::CMP: 73 | std::cout << ',' << cmp_names[insn.op.imm.u]; 74 | break; 75 | } 76 | 77 | std::cout << '\n'; 78 | } 79 | } 80 | 81 | return 0; 82 | } catch (const std::exception &e) { 83 | std::cout << e.what() << '\n'; 84 | throw; 85 | } 86 | -------------------------------------------------------------------------------- /src/avisynth/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 | #ifdef __cplusplus 37 | # define EXTERN_C extern "C" 38 | #else 39 | # define EXTERN_C 40 | #endif 41 | 42 | #ifdef MSVC 43 | #ifndef AVSC_USE_STDCALL 44 | # define AVSC_CC __cdecl 45 | #else 46 | # define AVSC_CC __stdcall 47 | #endif 48 | #else 49 | # define AVSC_CC 50 | #endif 51 | 52 | #define AVSC_INLINE static __inline 53 | 54 | #ifdef BUILDING_AVSCORE 55 | # define AVSC_EXPORT __declspec(dllexport) 56 | # define AVSC_API(ret, name) EXTERN_C AVSC_EXPORT ret AVSC_CC name 57 | #else 58 | # define AVSC_EXPORT EXTERN_C __declspec(dllimport) 59 | # ifndef AVSC_NO_DECLSPEC 60 | # define AVSC_API(ret, name) EXTERN_C AVSC_EXPORT ret AVSC_CC name 61 | # else 62 | # define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func) 63 | # endif 64 | #endif 65 | 66 | #endif //AVS_CAPI_H 67 | -------------------------------------------------------------------------------- /test/expr_compiler/havs_exprs.txt: -------------------------------------------------------------------------------- 1 | y x - y y 0 = + / 255 * 50 - y 256 + 512 / 0.5 + * 2 | x 128 - y 128 - * 0 < 128 x 128 - abs y 128 - abs < x y ? ? 3 | x y < x x y - 1.0 * - x x y - 1.0 * - ? 4 | x 7 + y < x 2 + x 7 - y > x 2 - x 51 * y 49 * + 100 / ? ? 5 | x 128 - abs y 128 - abs > x y ? 0.6 * x y + 0.2 * + 6 | x y < x 1 + x y > x 1 - x ? ? 7 | x 128 - y 128 - * 0 > x 128 - abs y 128 - abs < x 128 - 128 x - * y 128 - 128 y - * ? x y + 256 - dup * ? 0.25 * 128 + 8 | x y - dup * 3 * x y + 256 - dup * - 128 + 9 | x 2 * y -1 * + 10 | y 0 > y 255 < and x 0 = x 255 = or and x y ? 11 | x x y - 2.7 * + 12 | x 128 - y 128 - * 0 < x 128 - abs y 128 - abs < x y ? 128 - 0.25 * 128 + x 128 - abs y 128 - abs < x y ? ? 13 | x y - abs 10 < x y + 2 / 0 ? 14 | x -1 - abs 255 * -1 128 - abs 128 + / 15 | x y - abs 2 <= x x y - 0 < y 2 - y 2 + ? ? 16 | x 16 < 255 x 75 > 0 255 x 16 - 255 75 16 - / * - ? ? 17 | x y - abs 1 < x x 5.122 + y < x 3 + x 5.122 - y > x 3 - x 51 * y 49 * + 100 / ? ? ? 18 | x 128 - abs 2 * 19 | z 16 - y 16 - / 8 min 0.4 max x 16 - * 16 + 20 | 0.5 1 x 65536 / 0.925 * 0.0373 + 0.00001 max / 1 - 0.00001 max log 6.5 / - 65536 * 21 | x 16 - 95 / 100 * 16 + x 239 - -10 / 0 max 1 min * x x 229 - 10 / 0 max 1 min * + 22 | x 128 < -3.5988432352121e-06 x 128 / * x 128 / * 0.00016044118478736 + x 128 / * x 128 / * -0.0046817541353187 + x 128 / * x 128 / * 0.079692626246167 + x 128 / * x 128 / * -0.64596409750625 + x 128 / * x 128 / * 1.5707963267949 + x 128 / * 1.0 pow x 128 > -3.5988432352121e-06 255 x - 255 128 - / * 255 x - 255 128 - / * 0.00016044118478736 + 255 x - 255 128 - / * 255 x - 255 128 - / * -0.0046817541353187 + 255 x - 255 128 - / * 255 x - 255 128 - / * 0.079692626246167 + 255 x - 255 128 - / * 255 x - 255 128 - / * -0.64596409750625 + 255 x - 255 128 - / * 255 x - 255 128 - / * 1.5707963267949 + 255 x - 255 128 - / * 1.0 pow 1 ? ? x 2 <= 0 x 18 >= 1 -3.5988432352121e-06 x 2 - 16 / * x 2 - 16 / * 0.00016044118478736 + x 2 - 16 / * x 2 - 16 / * -0.0046817541353187 + x 2 - 16 / * x 2 - 16 / * 0.079692626246167 + x 2 - 16 / * x 2 - 16 / * -0.64596409750625 + x 2 - 16 / * x 2 - 16 / * 1.5707963267949 + x 2 - 16 / * ? ? * x 0 - 255 / 1.0 pow 255 * 0 + x - * x + 23 | y 0.749 < y 0.749 ? x 4 + > x y 0.749 < y 0.749 ? - 0 ? 0.375 * x + 24 | y 130 <= 128 y 140 >= x 140 y 1 / - 128 * x 1 / y 1 / 130 - * + 10 / 1 * ? 128 - 1 * 128 + ? 25 | x y < x 1 + x y > x 1 - x ? ? 26 | x 128 - y 128 - * 0 < x 128 - 100 / 25 * 128 + x 128 - abs y 128 - abs > x 25 * y 75 * + 100 / x ? ? 27 | x y 0 + > y 0 + x ? z 0 - < z 0 - x y 0 + > y 0 + x ? ? 28 | x 128 > y 255 y - x 128 - * 128 / 0.5 y 128 - abs 255 / - * + y y 128 x - 128 / * 0.5 y 128 - abs 255 / - * - ? 29 | x y - x z - * 0 < x x y - abs x z - abs < y z ? ? 30 | -------------------------------------------------------------------------------- /test/environment_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import contextlib 3 | import multiprocessing 4 | from concurrent.futures import ProcessPoolExecutor 5 | 6 | from vapoursynth import core 7 | import vapoursynth as vs 8 | 9 | 10 | class StubPolicy(vs.EnvironmentPolicy): 11 | 12 | def __init__(self) -> None: 13 | self._current = None 14 | self._api = None 15 | 16 | def on_policy_registered(self, special_api): 17 | self._api = special_api 18 | self._current = None 19 | 20 | def on_policy_cleared(self): 21 | assert self._api is not None 22 | self._current = None 23 | 24 | def get_current_environment(self): 25 | return self._current 26 | 27 | def set_environment(self, environment): 28 | self._current = environment 29 | 30 | 31 | @contextlib.contextmanager 32 | def _with_policy(): 33 | pol = StubPolicy() 34 | vs.register_policy(pol) 35 | try: 36 | yield pol 37 | finally: 38 | pol._api.unregister_policy() 39 | 40 | 41 | def _wrap_with(func): 42 | func(EnvironmentTest()) 43 | 44 | 45 | def subprocess_runner(func): 46 | def _wrapper(self): 47 | with ProcessPoolExecutor(max_workers=1, mp_context=multiprocessing.get_context("spawn")) as executor: 48 | executor.submit(_wrap_with, func).result() 49 | return _wrapper 50 | 51 | def t_environment_use_unsets_environment_on_exit(self): 52 | with _with_policy() as pol: 53 | env = pol._api.create_environment() 54 | wrapped = pol._api.wrap_environment(env) 55 | 56 | with self.assertRaises(RuntimeError): 57 | vs.get_current_environment() 58 | 59 | with wrapped.use(): 60 | print(vs.get_current_environment()) 61 | 62 | with self.assertRaises(RuntimeError): 63 | print(vs.get_current_environment()) 64 | 65 | 66 | def t_environment_use_restores_environment_on_exit(self): 67 | with _with_policy() as pol: 68 | env1 = pol._api.create_environment() 69 | wrapped1 = pol._api.wrap_environment(env1) 70 | 71 | env2 = pol._api.create_environment() 72 | wrapped2 = pol._api.wrap_environment(env2) 73 | 74 | with wrapped1.use(): 75 | ce1 = vs.get_current_environment() 76 | 77 | with wrapped2.use(): 78 | self.assertNotEqual(ce1, vs.get_current_environment()) 79 | 80 | self.assertEqual(ce1, vs.get_current_environment()) 81 | 82 | 83 | class EnvironmentTest(unittest.TestCase): 84 | 85 | test_environment_use_unsets_environment_on_exit = subprocess_runner(t_environment_use_unsets_environment_on_exit) 86 | test_environment_use_restores_environment_on_exit = subprocess_runner(t_environment_use_restores_environment_on_exit) 87 | 88 | 89 | 90 | if __name__ == '__main__': 91 | unittest.main() -------------------------------------------------------------------------------- /src/filters/avisource/DubSource.h: -------------------------------------------------------------------------------- 1 | // VirtualDub - Video processing and capture application 2 | // Copyright (C) 1998-2001 Avery Lee 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. 17 | 18 | #ifndef f_DUBSOURCE_H 19 | #define f_DUBSOURCE_H 20 | 21 | #include 22 | 23 | class InputFile; 24 | 25 | class DubSource { 26 | protected: 27 | virtual BOOL _isKey(LONG lSample); 28 | 29 | public: 30 | VDPosition lSampleFirst, lSampleLast; 31 | VDAVIStreamInfo streamInfo; 32 | 33 | virtual BOOL init(); 34 | int read(LONG lStart, LONG lCount, LPVOID lpBuffer, LONG cbBuffer, LONG *lBytesRead, LONG *lSamplesRead); 35 | virtual int _read(LONG lStart, LONG lCount, LPVOID lpBuffer, LONG cbBuffer, LONG *lBytesRead, LONG *lSamplesRead) = 0; 36 | 37 | virtual bool isStreaming(); 38 | 39 | BOOL isKey(LONG lSample); 40 | virtual LONG nearestKey(LONG lSample); 41 | virtual LONG prevKey(LONG lSample); 42 | virtual LONG nextKey(LONG lSample); 43 | 44 | virtual void streamBegin( bool fRealTime); 45 | virtual void streamEnd(); 46 | 47 | LONG msToSamples(LONG lMs) const { 48 | return (LONG)(((__int64)lMs * streamInfo.dwRate + (__int64)500 * streamInfo.dwScale) / ((__int64)1000 * streamInfo.dwScale)); 49 | } 50 | LONG samplesToMs(LONG lSamples) const { 51 | return (LONG)( 52 | (((__int64)lSamples * streamInfo.dwScale) * 1000 + streamInfo.dwRate/2) / streamInfo.dwRate 53 | ); 54 | } 55 | 56 | // This is more accurate than AVIStreamSampleToSample(), which does a conversion to 57 | // milliseconds and back. 58 | 59 | static LONG samplesToSamples(const VDAVIStreamInfo *dest, const VDAVIStreamInfo *source, LONG lSamples) { 60 | __int64 divisor = (__int64)source->dwRate * dest->dwScale; 61 | 62 | return (LONG)((((__int64)lSamples * source->dwScale) * dest->dwRate + divisor/2) 63 | / divisor); 64 | } 65 | 66 | LONG samplesToSamples(const DubSource *source, LONG lSamples) const { 67 | return samplesToSamples(&streamInfo, &source->streamInfo, lSamples); 68 | } 69 | }; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /doc/plugins/misc.rst: -------------------------------------------------------------------------------- 1 | .. _misc: 2 | 3 | Miscellaneous Filters 4 | ===================== 5 | 6 | Miscellaneous Filters is a random collection of filters that mostly are useful for Avisynth compatibility. 7 | 8 | .. function:: AverageFrames(clip[] clips, float[] weights[, float scale, bint scenechange, int[] planes]) 9 | :module: misc 10 | 11 | AverageFrames has two main modes depending on whether one or multiple *clips* are supplied. 12 | The filter is named AverageFrames since using ones for weights is an easy way to average 13 | many frames together but it can also be seen as a temporal or multiple frame convolution. 14 | 15 | If multiple *clips* are supplied then the frames from each of the *clips* are multiplied by 16 | the respective *weights*, summed together and divided by *scale* before being output. Note 17 | that only integer *weights* and *scale* are allowed for integer input formats. 18 | 19 | If a single *clip* is supplied then an odd number of *weights* are needed and they will instead 20 | be temporally centered on the current frame of the *clip*. The rest works as multiple *clip* mode 21 | with the only difference being that *scenechange* can be set to avoid averaging frames over scene 22 | changes. If this happens then all the weights beyond a scene change are instead applied to the frame 23 | right before it. 24 | 25 | At most 31 *weights* can be supplied. 26 | 27 | .. function:: Hysteresis(clip clipa, clip clipb[, int[] planes]) 28 | :module: misc 29 | 30 | Grows the mask in *clipa* into the mask in *clipb*. This is an equivalent of the Avisynth function *mt_hysteresis*. 31 | Note that both clips are are expected to be in the typical mask range which means that all 32 | planes have to be in the 0-1 range for floating point formats. 33 | 34 | Specifically, Hysteresis takes two bi-level masks *clipa* and *clipb* and generates another 35 | bi-level mask clip. Both *clipa* and *clipb* must have the same dimensions and format, and the 36 | output clip will also have that format. 37 | If we treat the planes of the clips as representing 8-neighbourhood undirected 2D grid graphs, 38 | for each of the connected components in *clipb*, the whole component is copied to the output plane 39 | if and only if one of its pixels is also marked in the corresponding plane from *clipa*. 40 | The argument *planes* controls which planes to process, with the default being all. Any unprocessed 41 | planes will be copied from the corresponding plane in *clipa*. 42 | 43 | .. function:: SCDetect(clip clip[, float threshold=0.1]) 44 | :module: misc 45 | 46 | A simple filter to mark scene changes. It works by calculating the absolute difference between the next and previous 47 | frames and scaling it to a 0-1 range and then comparing it to *threshold*. It's basically just a wrapper for 48 | *PlaneStats*. 49 | -------------------------------------------------------------------------------- /src/avisynth/avs/config.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_CONFIG_H 34 | #define AVS_CONFIG_H 35 | 36 | // Undefine this to get cdecl calling convention 37 | #define AVSC_USE_STDCALL 1 38 | 39 | // NOTE TO PLUGIN AUTHORS: 40 | // Because FRAME_ALIGN can be substantially higher than the alignment 41 | // a plugin actually needs, plugins should not use FRAME_ALIGN to check for 42 | // alignment. They should always request the exact alignment value they need. 43 | // This is to make sure that plugins work over the widest range of AviSynth 44 | // builds possible. 45 | #define FRAME_ALIGN 32 46 | 47 | #if defined(_M_AMD64) || defined(__x86_64) 48 | # define X86_64 49 | #elif defined(_M_IX86) || defined(__i386__) 50 | # define X86_32 51 | #else 52 | # error Unsupported CPU architecture. 53 | #endif 54 | 55 | #if defined(_MSC_VER) 56 | # define MSVC 57 | #elif defined(__GNUC__) 58 | # define GCC 59 | #elif defined(__clang__) 60 | # define CLANG 61 | #else 62 | # error Unsupported compiler. 63 | #endif 64 | 65 | #if defined(GCC) 66 | # undef __forceinline 67 | # define __forceinline inline 68 | #endif 69 | 70 | #endif //AVS_CONFIG_H 71 | --------------------------------------------------------------------------------