From 8db8d843dfa97bd0a2c19ad89060466c956f702e Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Fri, 22 May 2020 19:19:55 +0200 Subject: [PATCH] 2.1.1.5 Beta --- Changelog.md | 18 +- Controls/SubtitleControl.vb | 4 +- Encoding/VideoEncoder.vb | 5 +- Encoding/x264Enc.vb | 5 +- Forms/AppsForm.vb | 48 +- Forms/MainForm.vb | 25 +- FrameServer/AviSynthServer.cpp | 2 +- FrameServer/AviSynthServer.h | 2 +- FrameServer/FrameServer.vcxproj | 1 + FrameServer/VapourSynthServer.h | 2 +- FrameServer/{avisynth_headers => }/avisynth.h | 751 +++++++--- FrameServer/avisynth_headers/avisynth_c.h | 1257 ----------------- .../{avisynth_headers => avs}/alignment.h | 2 +- FrameServer/{avisynth_headers => avs}/capi.h | 16 + .../{avisynth_headers => avs}/config.h | 66 +- FrameServer/{avisynth_headers => avs}/cpuid.h | 3 +- .../{avisynth_headers => avs}/minmax.h | 0 FrameServer/avs/posix.h | 111 ++ FrameServer/{avisynth_headers => avs}/types.h | 15 +- FrameServer/{avisynth_headers => avs}/win.h | 0 General/CommandLine.vb | 10 +- General/Documentation.vb | 2 +- General/GlobalClass.vb | 15 +- General/GlobalCommands.vb | 4 +- General/Package.vb | 91 +- Portable/PowerShell.vb | 5 + docs/generated/tools.rst | 42 +- 27 files changed, 961 insertions(+), 1541 deletions(-) rename FrameServer/{avisynth_headers => }/avisynth.h (67%) delete mode 100644 FrameServer/avisynth_headers/avisynth_c.h rename FrameServer/{avisynth_headers => avs}/alignment.h (99%) rename FrameServer/{avisynth_headers => avs}/capi.h (92%) rename FrameServer/{avisynth_headers => avs}/config.h (60%) rename FrameServer/{avisynth_headers => avs}/cpuid.h (97%) rename FrameServer/{avisynth_headers => avs}/minmax.h (100%) create mode 100644 FrameServer/avs/posix.h rename FrameServer/{avisynth_headers => avs}/types.h (93%) rename FrameServer/{avisynth_headers => avs}/win.h (100%) diff --git a/Changelog.md b/Changelog.md index 3919f7fc..71a876df 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,13 +1,27 @@ -2.1.1.5 Beta (not yet available) +2.1.1.6 Beta (not yet available) +============ + +2.1.1.5 Beta ============ - In the video encoder dialogs the feature *Execute Command Line* failed when Windows Terminal is installed and paths contained spaces. - Maximum number of parallel processes increased from 4 to 16. +- Issues fixed on systems with restricted PowerShell execution policy. - the Tools page in the docs lists all tools in a grid view with columns: Name, Type, Filename, Version, Modified Date - +- The muxer dialog is resizable and remembers the size. +- AviSynth headers updated and interface version changed to 8 +- AviSynth 3.6 +- yadifmod2 avs 0.2.2 +- AVSMeter 2.9.9.3 +- KNLMeansCL avs/vs 1.1.1 +- MPEG2DecPlus avs 0.1.2 (untested) +- QTGMC avs 3.364s +- masktools2 2.2.23 +- MediaInfo.NET 6.4.0.0 + 2.1.1.4 Beta ============ diff --git a/Controls/SubtitleControl.vb b/Controls/SubtitleControl.vb index d2d0ac83..47dc9868 100644 --- a/Controls/SubtitleControl.vb +++ b/Controls/SubtitleControl.vb @@ -422,7 +422,9 @@ Public Class SubtitleControl End Class Private Sub bnPlay_Click() Handles bnPlay.Click - If Not Package.mpvnet.VerifyOK(True) Then Exit Sub + If Not Package.mpvnet.VerifyOK(True) Then + Exit Sub + End If Dim st = Items(dgv.CurrentRow.Index).Subtitle Dim filepath = st.Path diff --git a/Encoding/VideoEncoder.vb b/Encoding/VideoEncoder.vb index f5ee72e3..0d78a12d 100644 --- a/Encoding/VideoEncoder.vb +++ b/Encoding/VideoEncoder.vb @@ -605,8 +605,9 @@ Public Class BatchEncoder Exit Sub End If - If Not g.VerifyRequirements Then Exit Sub - If Not g.IsValidSource Then Exit Sub + If Not g.VerifyRequirements OrElse Not g.IsValidSource Then + Exit Sub + End If Dim script As New VideoScript script.Engine = p.Script.Engine diff --git a/Encoding/x264Enc.vb b/Encoding/x264Enc.vb index d32afb93..54d941bb 100644 --- a/Encoding/x264Enc.vb +++ b/Encoding/x264Enc.vb @@ -80,8 +80,9 @@ Public Class x264Enc End Sub Overrides Sub RunCompCheck() - If Not g.VerifyRequirements Then Exit Sub - If Not g.IsValidSource Then Exit Sub + If Not g.VerifyRequirements OrElse Not g.IsValidSource Then + Exit Sub + End If Dim newParams As New x264Params Dim newStore = DirectCast(ObjectHelp.GetCopy(ParamsStore), PrimitiveStore) diff --git a/Forms/AppsForm.vb b/Forms/AppsForm.vb index 8eec9ae0..e590a9ea 100644 --- a/Forms/AppsForm.vb +++ b/Forms/AppsForm.vb @@ -103,8 +103,8 @@ Public Class AppsForm Me.tsbLaunch.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.tsbLaunch.ImageTransparentColor = System.Drawing.Color.Magenta Me.tsbLaunch.Name = "tsbLaunch" - Me.tsbLaunch.Size = New System.Drawing.Size(136, 69) - Me.tsbLaunch.Text = "Launch" + Me.tsbLaunch.Size = New System.Drawing.Size(156, 69) + Me.tsbLaunch.Text = " Launch " Me.tsbLaunch.ToolTipText = "Launches the app" ' 'tsbExplore @@ -112,8 +112,8 @@ Public Class AppsForm Me.tsbExplore.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.tsbExplore.ImageTransparentColor = System.Drawing.Color.Magenta Me.tsbExplore.Name = "tsbExplore" - Me.tsbExplore.Size = New System.Drawing.Size(142, 69) - Me.tsbExplore.Text = "Explore" + Me.tsbExplore.Size = New System.Drawing.Size(162, 69) + Me.tsbExplore.Text = " Explore " Me.tsbExplore.ToolTipText = "Opens the apps folder in File Explorer" ' 'tsbWebsite @@ -121,8 +121,8 @@ Public Class AppsForm Me.tsbWebsite.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.tsbWebsite.ImageTransparentColor = System.Drawing.Color.Magenta Me.tsbWebsite.Name = "tsbWebsite" - Me.tsbWebsite.Size = New System.Drawing.Size(117, 69) - Me.tsbWebsite.Text = " Web " + Me.tsbWebsite.Size = New System.Drawing.Size(137, 69) + Me.tsbWebsite.Text = " Web " Me.tsbWebsite.ToolTipText = "Opens the apps website" ' 'tsbDownload @@ -130,8 +130,8 @@ Public Class AppsForm Me.tsbDownload.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.tsbDownload.ImageTransparentColor = System.Drawing.Color.Magenta Me.tsbDownload.Name = "tsbDownload" - Me.tsbDownload.Size = New System.Drawing.Size(185, 69) - Me.tsbDownload.Text = "Download" + Me.tsbDownload.Size = New System.Drawing.Size(205, 69) + Me.tsbDownload.Text = " Download " Me.tsbDownload.ToolTipText = "Opens the apps download web page" ' 'tsbVersion @@ -139,8 +139,8 @@ Public Class AppsForm Me.tsbVersion.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.tsbVersion.ImageTransparentColor = System.Drawing.Color.Magenta Me.tsbVersion.Name = "tsbVersion" - Me.tsbVersion.Size = New System.Drawing.Size(141, 69) - Me.tsbVersion.Text = "Version" + Me.tsbVersion.Size = New System.Drawing.Size(181, 69) + Me.tsbVersion.Text = " Version " Me.tsbVersion.ToolTipText = "Edits the apps version (F12)" ' 'ddbPath @@ -151,8 +151,8 @@ Public Class AppsForm Me.ddbPath.Image = CType(resources.GetObject("ddbPath.Image"), System.Drawing.Image) Me.ddbPath.ImageTransparentColor = System.Drawing.Color.Magenta Me.ddbPath.Name = "ddbPath" - Me.ddbPath.Size = New System.Drawing.Size(120, 69) - Me.ddbPath.Text = "Path" + Me.ddbPath.Size = New System.Drawing.Size(160, 69) + Me.ddbPath.Text = " Path " ' 'miBrowsePath ' @@ -183,8 +183,8 @@ Public Class AppsForm Me.ddbTools.Image = CType(resources.GetObject("ddbTools.Image"), System.Drawing.Image) Me.ddbTools.ImageTransparentColor = System.Drawing.Color.Magenta Me.ddbTools.Name = "ddbTools" - Me.ddbTools.Size = New System.Drawing.Size(152, 69) - Me.ddbTools.Text = " Tools " + Me.ddbTools.Size = New System.Drawing.Size(172, 69) + Me.ddbTools.Text = " Tools " ' 'miShowGridView ' @@ -203,8 +203,8 @@ Public Class AppsForm Me.tsbHelp.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.tsbHelp.ImageTransparentColor = System.Drawing.Color.Magenta Me.tsbHelp.Name = "tsbHelp" - Me.tsbHelp.Size = New System.Drawing.Size(119, 69) - Me.tsbHelp.Text = " Help " + Me.tsbHelp.Size = New System.Drawing.Size(139, 69) + Me.tsbHelp.Text = " Help " Me.tsbHelp.ToolTipText = "Opens the apps help (F1)" ' 'flp @@ -356,8 +356,8 @@ Public Class AppsForm tsbDownload.Enabled = CurrentPackage.DownloadURL <> "" tsbHelp.Enabled = CurrentPackage.HelpFileOrURL <> "" - tsbVersion.Enabled = Not CurrentPackage.IgnoreVersion AndAlso CurrentPackage.Path.FileExists AndAlso - Not (CurrentPackage.IsOldVersion() AndAlso Not CurrentPackage.AllowOldVersion) + tsbVersion.Enabled = CurrentPackage.Path.FileExists AndAlso + Not (CurrentPackage.IsVersionOld() AndAlso Not CurrentPackage.VersionAllowOld) miBrowsePath.Enabled = CurrentPackage.FixedDir = "" miSearchUsingEverything.Enabled = CurrentPackage.FixedDir = "" @@ -370,14 +370,10 @@ Public Class AppsForm Contents("Description").Text = CurrentPackage.Description If File.Exists(CurrentPackage.Path) Then - Contents("Version").Text = CurrentPackage.Version + " (" + File.GetLastWriteTimeUtc(CurrentPackage.Path).ToShortDateString() + ")" - Else - Contents("Version").Text = CurrentPackage.Version + Contents("Version").Text = If(CurrentPackage.IsVersionCorrect, CurrentPackage.Version, "Unknown") + Contents("Version").Text += " (" + File.GetLastWriteTimeUtc(CurrentPackage.Path).ToShortDateString() + ")" End If - Headers("Version").Visible = CurrentPackage.IsCorrectVersion AndAlso Not CurrentPackage.IgnoreVersion - Contents("Version").Visible = CurrentPackage.IsCorrectVersion AndAlso Not CurrentPackage.IgnoreVersion - Contents("Status").Text = CurrentPackage.GetStatusDisplay() If CurrentPackage.GetStatus <> "" AndAlso CurrentPackage.Required Then @@ -609,7 +605,7 @@ Public Class AppsForm CurrentPackage.Version = input CurrentPackage.VersionDate = File.GetLastWriteTimeUtc(CurrentPackage.Path) - Dim txt = Application.ProductVersion + BR2 + Dim txt As String For Each pack In Package.Items.Values If pack.Version <> "" Then @@ -638,7 +634,7 @@ Public Class AppsForm row.Filename = pack.Filename row.Folder = pack.Directory - If pack.IsCorrectVersion Then + If pack.IsVersionCorrect Then row.Version = "'" + pack.Version + "'" End If diff --git a/Forms/MainForm.vb b/Forms/MainForm.vb index c974faf7..708e5924 100644 --- a/Forms/MainForm.vb +++ b/Forms/MainForm.vb @@ -1679,6 +1679,11 @@ Public Class MainForm g.RaiseAppEvent(ApplicationEvent.ProjectLoaded) g.RaiseAppEvent(ApplicationEvent.ProjectOrSourceLoaded) FiltersListView.RebuildMenu() + + If p.SourceFile <> "" AndAlso Not g.VerifyRequirements Then + Throw New AbortException + End If + Return True Catch ex As Exception OpenProject(g.StartupTemplatePath) @@ -3045,10 +3050,14 @@ Public Class MainForm p.SkippedAssistantTips.Add(CurrentAssistantTipKey) End If - If Not g.VerifyRequirements() Then Exit Sub + If Not g.VerifyRequirements() Then + Exit Sub + End If If AssistantPassed Then - If AbortDueToLowDiskSpace() Then Exit Sub + If AbortDueToLowDiskSpace() Then + Exit Sub + End If If Not TypeOf p.VideoEncoder Is NullEncoder AndAlso File.Exists(p.VideoEncoder.OutputPath) Then Select Case p.FileExistVideo @@ -3719,11 +3728,7 @@ Public Class MainForm If p.SourceFile = "" Then ShowOpenSourceDialog() Else - If Not g.VerifyRequirements Then - Exit Sub - End If - - If Not g.IsValidSource Then + If Not g.VerifyRequirements OrElse Not g.IsValidSource Then Exit Sub End If @@ -4454,7 +4459,6 @@ Public Class MainForm ret.Add("Apps|Media Info|MediaInfo File", NameOf(g.DefaultCommands.ShowMediaInfo)) ret.Add("Apps|Media Info|MediaInfo Folder", NameOf(g.DefaultCommands.ShowMediaInfoFolderViewDialog)) ret.Add("Apps|Media Info|Ingest HDR", NameOf(g.DefaultCommands.SaveMKVHDR)) - ret.Add("Apps|DGIndex|DGIndex", NameOf(g.DefaultCommands.StartTool), {"DGIndex"}) ret.Add("Apps|Players|mpv.net", NameOf(g.DefaultCommands.StartTool), {"mpv.net"}) ret.Add("Apps|Players|MPC-BE", NameOf(g.DefaultCommands.StartTool), {"MPC-BE"}) ret.Add("Apps|Players|MPC-HC", NameOf(g.DefaultCommands.StartTool), {"MPC-HC"}) @@ -5142,7 +5146,10 @@ Public Class MainForm For Each i In FileTypes.Video Dim files = Directory.GetFiles(path, "*." + i) Array.Sort(files) - If files.Length > 0 Then Return files + + If files.Length > 0 Then + Return files + End If Next End Function diff --git a/FrameServer/AviSynthServer.cpp b/FrameServer/AviSynthServer.cpp index cdca0ed0..2b150774 100644 --- a/FrameServer/AviSynthServer.cpp +++ b/FrameServer/AviSynthServer.cpp @@ -60,7 +60,7 @@ HRESULT __stdcall AviSynthServer::OpenFile(WCHAR* file) if (!CreateScriptEnvironment2) throw std::exception("Cannot resolve AviSynth+ CreateScriptEnvironment2 function"); - m_ScriptEnvironment = CreateScriptEnvironment2(6); + m_ScriptEnvironment = CreateScriptEnvironment2(8); if (!m_ScriptEnvironment) throw std::exception("A newer AviSynth+ version is required"); diff --git a/FrameServer/AviSynthServer.h b/FrameServer/AviSynthServer.h index 4454fdd3..8b6f9e17 100644 --- a/FrameServer/AviSynthServer.h +++ b/FrameServer/AviSynthServer.h @@ -3,7 +3,7 @@ #include "Common.h" #include "FrameServer.h" -#include "avisynth_headers\avisynth.h" +#include "avisynth.h" #include diff --git a/FrameServer/FrameServer.vcxproj b/FrameServer/FrameServer.vcxproj index d2d26f0e..14ea7df4 100644 --- a/FrameServer/FrameServer.vcxproj +++ b/FrameServer/FrameServer.vcxproj @@ -98,6 +98,7 @@ + diff --git a/FrameServer/VapourSynthServer.h b/FrameServer/VapourSynthServer.h index 25c59f33..957cb461 100644 --- a/FrameServer/VapourSynthServer.h +++ b/FrameServer/VapourSynthServer.h @@ -8,7 +8,7 @@ #include "FrameServer.h" #include "VSScript.h" #include "VSHelper.h" -#include "avisynth_headers\avisynth.h" +#include "avisynth.h" #include "Windows.h" #include diff --git a/FrameServer/avisynth_headers/avisynth.h b/FrameServer/avisynth.h similarity index 67% rename from FrameServer/avisynth_headers/avisynth.h rename to FrameServer/avisynth.h index ed887ba2..9dd70c3e 100644 --- a/FrameServer/avisynth_headers/avisynth.h +++ b/FrameServer/avisynth.h @@ -10,6 +10,17 @@ // 20171103: (test with SIZETMOD define: Videoframe offsets to size_t, may affect x64) // 20171207: C++ Standard Conformance (no change for plugin writers) // 20180525: AVS_UNUSED define to supress parameter not used warnings +// 2020xxxx: AVS_WINDOWS and AVS_POSIX option see avs/config.h +// 20200305: ScriptEnvironment::VSprintf parameter (void *) changed back to va_list +// 20200330: removed __stdcall from variadic argument functions (Sprintf) +// (remove test SIZETMOD define for clarity) +// Integrate Avisynth Neo structures and interface, PFunction, PDevice +// 20200501: frame property support (NewVideoFrameP and other helpers) to legacy IScriptEnvironment. +// move some former IScriptEnvironment2 functions to IScriptEnvironment: +// GetEnvProperty (system prop), Allocate, Free (buffer pool) +// GetVarTry, GetVarBool/Int/String/Double/Long +// Invoke2, Invoke3, InvokeTry, Invoke2Try, Invoke3Try +// Interface Version to 8 (classic 2.6 = 6) // http://www.avisynth.org @@ -46,18 +57,36 @@ // graphical user interfaces. +#ifndef __AVISYNTH_8_H__ +#define __AVISYNTH_8_H__ +#include "avs/config.h" +#include "avs/capi.h" +#include "avs/types.h" -#ifndef __AVISYNTH_6_H__ -#define __AVISYNTH_6_H__ +#ifdef AVS_POSIX +# include "avs/posix.h" +#endif -#include "config.h" -#include "capi.h" -#include "types.h" +#if defined(AVS_POSIX) +#define __stdcall +#define __cdecl +#endif +// Important note on AVISYNTH_INTERFACE_VERSION V6->V8 change: +// Note 1: Those few plugins which were using earlier IScriptEnvironment2 despite the big Warning will crash have to be rebuilt. +// Note 2: How to support earlier avisynth interface with an up-to-date avisynth.h: +// Use the new frame property features adaptively after querying that at least v8 is supported +// AviSynth property support can be queried (cpp iface example): +// has_at_least_v8 = true; +// try { env->CheckVersion(8); } catch (const AvisynthError&) { has_at_least_v8 = false; } +// and use it: +// if (has_at_least_v8) dst = env->NewVideoFrameP(vi, &src); else dst = env->NewVideoFrame(vi); -enum { AVISYNTH_INTERFACE_VERSION = 6 }; - +enum { + AVISYNTH_CLASSIC_INTERFACE_VERSION = 6, + AVISYNTH_INTERFACE_VERSION = 8 +}; /* Compiler-specific crap */ @@ -135,6 +164,12 @@ private: AvisynthError& operator=(const AvisynthError&); }; // end class AvisynthError +enum AvsDeviceType { + DEV_TYPE_NONE = 0, + DEV_TYPE_CPU = 1, + DEV_TYPE_CUDA = 2, + DEV_TYPE_ANY = 0xFFFF +}; /* Forward references */ #if defined(MSVC) @@ -150,6 +185,13 @@ class SINGLE_INHERITANCE PClip; class SINGLE_INHERITANCE PVideoFrame; class IScriptEnvironment; class SINGLE_INHERITANCE AVSValue; +class INeoEnv; +class IFunction; +class SINGLE_INHERITANCE PFunction; +class Device; +class SINGLE_INHERITANCE PDevice; +class AVSMap; + /* @@ -196,10 +238,10 @@ struct AVS_Linkage { int (VideoInfo::*BytesFromPixels)(int pixels) const; int (VideoInfo::*RowSize)(int plane) const; int (VideoInfo::*BMPSize)() const; - __int64 (VideoInfo::*AudioSamplesFromFrames)(int frames) const; - int (VideoInfo::*FramesFromAudioSamples)(__int64 samples) const; - __int64 (VideoInfo::*AudioSamplesFromBytes)(__int64 bytes) const; - __int64 (VideoInfo::*BytesFromAudioSamples)(__int64 samples) const; + int64_t (VideoInfo::*AudioSamplesFromFrames)(int frames) const; + int (VideoInfo::*FramesFromAudioSamples)(int64_t samples) const; + int64_t (VideoInfo::*AudioSamplesFromBytes)(int64_t bytes) const; + int64_t (VideoInfo::*BytesFromAudioSamples)(int64_t samples) const; int (VideoInfo::*AudioChannels)() const; int (VideoInfo::*SampleType)() const; bool (VideoInfo::*IsSampleType)(int testtype) const; @@ -222,11 +264,7 @@ struct AVS_Linkage { // class VideoFrameBuffer const BYTE* (VideoFrameBuffer::*VFBGetReadPtr)() const; BYTE* (VideoFrameBuffer::*VFBGetWritePtr)(); -#ifdef SIZETMOD - size_t (VideoFrameBuffer::*GetDataSize)() const; -#else int (VideoFrameBuffer::*GetDataSize)() const; -#endif int (VideoFrameBuffer::*GetSequenceNumber)() const; int (VideoFrameBuffer::*GetRefcount)() const; // end class VideoFrameBuffer @@ -238,11 +276,7 @@ struct AVS_Linkage { int (VideoFrame::*GetRowSize)(int plane) const; int (VideoFrame::*GetHeight)(int plane) const; VideoFrameBuffer* (VideoFrame::*GetFrameBuffer)() const; -#ifdef SIZETMOD - size_t (VideoFrame::*GetOffset)(int plane) const; -#else int (VideoFrame::*GetOffset)(int plane) const; -#endif const BYTE* (VideoFrame::*VFGetReadPtr)(int plane) const; bool (VideoFrame::*IsWritable)() const; BYTE* (VideoFrame::*VFGetWritePtr)(int plane) const; @@ -331,6 +365,51 @@ struct AVS_Linkage { bool (VideoInfo::*IsPlanarRGB)() const; bool (VideoInfo::*IsPlanarRGBA)() const; /**********************************************************************/ + + // frame property access + AVSMap& (VideoFrame::* getProperties)(); + const AVSMap& (VideoFrame::* getConstProperties)(); + void (VideoFrame::* setProperties)(const AVSMap& properties); + + // PFunction + void (AVSValue::* AVSValue_CONSTRUCTOR11)(const PFunction& o); + bool (AVSValue::* IsFunction)() const; + void (PFunction::* PFunction_CONSTRUCTOR0)(); + void (PFunction::* PFunction_CONSTRUCTOR1)(IFunction* p); + void (PFunction::* PFunction_CONSTRUCTOR2)(const PFunction& p); + PFunction& (PFunction::* PFunction_OPERATOR_ASSIGN0)(IFunction* other); + PFunction& (PFunction::* PFunction_OPERATOR_ASSIGN1)(const PFunction& other); + void (PFunction::* PFunction_DESTRUCTOR)(); + // end PFunction + + // extra VideoFrame functions + int (VideoFrame::* VideoFrame_CheckMemory)() const; + PDevice (VideoFrame::* VideoFrame_GetDevice)() const; + + // class PDevice, even if only CPU device + void (PDevice::* PDevice_CONSTRUCTOR0)(); + void (PDevice::* PDevice_CONSTRUCTOR1)(Device* p); + void (PDevice::* PDevice_CONSTRUCTOR2)(const PDevice& p); + PDevice& (PDevice::* PDevice_OPERATOR_ASSIGN0)(Device* other); + PDevice& (PDevice::* PDevice_OPERATOR_ASSIGN1)(const PDevice& other); + void (PDevice::* PDevice_DESTRUCTOR)(); + AvsDeviceType (PDevice::* PDevice_GetType)() const; + int (PDevice::* PDevice_GetId)() const; + int (PDevice::* PDevice_GetIndex)() const; + const char* (PDevice::* PDevice_GetName)() const; + // end class PDevice + + /**********************************************************************/ + // Reserve pointer space for Avisynth+ + void (VideoInfo::* reserved2[64 - 23])(); + /**********************************************************************/ + + // AviSynth Neo additions + INeoEnv* (__stdcall *GetNeoEnv)(IScriptEnvironment* env); + // As of V8 most PDevice, PFunction linkage entries are moved to standard avs+ place. + /**********************************************************************/ + + // this part should be identical with AVS_Linkage entries in interface.cpp }; #ifdef BUILDING_AVSCORE @@ -369,6 +448,38 @@ extern const AVS_Linkage* AVS_linkage; #endif +class PDevice +{ +public: + PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR0)()) + PDevice(Device* p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR1)(p)) + PDevice(const PDevice& p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR2)(p)) + PDevice& operator=(Device* p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN0)(p)) + PDevice& operator=(const PDevice& p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN1)(p)) + ~PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_DESTRUCTOR)()) + + int operator!() const { return !e; } + operator void*() const { return e; } + Device* operator->() const { return e; } + + AvsDeviceType GetType() const AVS_BakedCode(return AVS_LinkCallOptDefault(PDevice_GetType, DEV_TYPE_NONE)) + int GetId() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetId)()) + int GetIndex() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetIndex)()) + const char* GetName() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetName)()) + +private: + Device * e; + +#ifdef BUILDING_AVSCORE +public: + void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ + void CONSTRUCTOR1(Device* p); + void CONSTRUCTOR2(const PDevice& p); + PDevice& OPERATOR_ASSIGN0(Device* p); + PDevice& OPERATOR_ASSIGN1(const PDevice& p); + void DESTRUCTOR(); +#endif +}; struct VideoInfo { int width, height; // width=0 means no video unsigned fps_numerator, fps_denominator; @@ -562,6 +673,7 @@ enum { // RGB planar CS_RGBP = CS_GENERIC_RGBP | CS_Sample_Bits_8, // Planar RGB 8 bit samples + CS_RGBP8 = CS_GENERIC_RGBP | CS_Sample_Bits_8, // Planar RGB 8 bit samples CS_RGBP10 = CS_GENERIC_RGBP | CS_Sample_Bits_10, // Planar RGB 10bit samples CS_RGBP12 = CS_GENERIC_RGBP | CS_Sample_Bits_12, // Planar RGB 12bit samples CS_RGBP14 = CS_GENERIC_RGBP | CS_Sample_Bits_14, // Planar RGB 14bit samples @@ -570,6 +682,7 @@ enum { // RGBA planar CS_RGBAP = CS_GENERIC_RGBAP | CS_Sample_Bits_8, // Planar RGBA 8 bit samples + CS_RGBAP8 = CS_GENERIC_RGBAP | CS_Sample_Bits_8, // Planar RGBA 8 bit samples CS_RGBAP10 = CS_GENERIC_RGBAP | CS_Sample_Bits_10, // Planar RGBA 10bit samples CS_RGBAP12 = CS_GENERIC_RGBAP | CS_Sample_Bits_12, // Planar RGBA 12bit samples CS_RGBAP14 = CS_GENERIC_RGBAP | CS_Sample_Bits_14, // Planar RGBA 14bit samples @@ -608,7 +721,7 @@ enum { int audio_samples_per_second; // 0 means no audio int sample_type; // as of 2.5 - __int64 num_audio_samples; // changed as of 2.5 + int64_t num_audio_samples; // changed as of 2.5 int nchannels; // as of 2.5 // Imagetype properties @@ -661,10 +774,10 @@ enum { int RowSize(int plane = 0) const AVS_BakedCode(return AVS_LinkCall(RowSize)(plane)) int BMPSize() const AVS_BakedCode(return AVS_LinkCall(BMPSize)()) - __int64 AudioSamplesFromFrames(int frames) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromFrames)(frames)) - int FramesFromAudioSamples(__int64 samples) const AVS_BakedCode(return AVS_LinkCall(FramesFromAudioSamples)(samples)) - __int64 AudioSamplesFromBytes(__int64 bytes) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromBytes)(bytes)) - __int64 BytesFromAudioSamples(__int64 samples) const AVS_BakedCode(return AVS_LinkCall(BytesFromAudioSamples)(samples)) + int64_t AudioSamplesFromFrames(int frames) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromFrames)(frames)) + int FramesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(FramesFromAudioSamples)(samples)) + int64_t AudioSamplesFromBytes(int64_t bytes) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromBytes)(bytes)) + int64_t BytesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(BytesFromAudioSamples)(samples)) int AudioChannels() const AVS_BakedCode(return AVS_LinkCall(AudioChannels)()) int SampleType() const AVS_BakedCode(return AVS_LinkCall(SampleType)()) bool IsSampleType(int testtype) const AVS_BakedCode(return AVS_LinkCall(IsSampleType)(testtype)) @@ -750,11 +863,7 @@ enum { class VideoFrameBuffer { BYTE* data; -#ifdef SIZETMOD - size_t data_size; -#else int data_size; -#endif // sequence_number is incremented every time the buffer is changed, so // that stale views can tell they're no longer valid. volatile long sequence_number; @@ -764,23 +873,18 @@ class VideoFrameBuffer { friend class ScriptEnvironment; volatile long refcount; + // AVS+CUDA extension, does not break plugins if appended here + Device* device; + protected: -#ifdef SIZETMOD - VideoFrameBuffer(size_t size); -#else - VideoFrameBuffer(int size); -#endif + VideoFrameBuffer(int size, int margin, Device* device); VideoFrameBuffer(); ~VideoFrameBuffer(); public: const BYTE* GetReadPtr() const AVS_BakedCode( return AVS_LinkCall(VFBGetReadPtr)() ) BYTE* GetWritePtr() AVS_BakedCode( return AVS_LinkCall(VFBGetWritePtr)() ) -#ifdef SIZETMOD - size_t GetDataSize() const AVS_BakedCode(return AVS_LinkCall(GetDataSize)()) -#else int GetDataSize() const AVS_BakedCode( return AVS_LinkCall(GetDataSize)() ) -#endif int GetSequenceNumber() const AVS_BakedCode( return AVS_LinkCall(GetSequenceNumber)() ) int GetRefcount() const AVS_BakedCode( return AVS_LinkCall(GetRefcount)() ) @@ -791,6 +895,40 @@ private: }; // end class VideoFrameBuffer +// smart pointer to VideoFrame +class PVideoFrame { + + VideoFrame* p; + + void Init(VideoFrame* x); + void Set(VideoFrame* x); + +public: + PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR0)()) + PVideoFrame(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR1)(x)) + PVideoFrame(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR2)(x)) + void operator=(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN0)(x)) + void operator=(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN1)(x)) + + VideoFrame* operator->() const { return p; } + + // for conditional expressions + operator void*() const { return p; } + bool operator!() const { return !p; } + + ~PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_DESTRUCTOR)()) +#ifdef BUILDING_AVSCORE +public: + void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ + void CONSTRUCTOR1(const PVideoFrame& x); + void CONSTRUCTOR2(VideoFrame* x); + void OPERATOR_ASSIGN0(VideoFrame* x); + void OPERATOR_ASSIGN1(const PVideoFrame& x); + void DESTRUCTOR(); +#endif +}; // end class PVideoFrame + + // VideoFrame holds a "window" into a VideoFrameBuffer. Operator new // is overloaded to recycle class instances. @@ -800,28 +938,18 @@ class VideoFrame { // Due to technical reasons these members are not const, but should be treated as such. // That means do not modify them once the class has been constructed. -#ifdef SIZETMOD - size_t offset; -#else int offset; -#endif int pitch, row_size, height; -#ifdef SIZETMOD - size_t offsetU, offsetV; // U&V offsets are from top of picture. -#else int offsetU, offsetV; // U&V offsets are from top of picture. -#endif int pitchUV, row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane. // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable) // the decision on existance of UV is checked by zero pitch // AVS+ extension, does not break plugins if appended here -#ifdef SIZETMOD - size_t offsetA; -#else int offsetA; -#endif int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none + AVSMap *properties; + friend class PVideoFrame; void AddRef(); void Release(); @@ -829,18 +957,10 @@ class VideoFrame { friend class ScriptEnvironment; friend class Cache; -#ifdef SIZETMOD - VideoFrame(VideoFrameBuffer* _vfb, size_t _offset, int _pitch, int _row_size, int _height); - VideoFrame(VideoFrameBuffer* _vfb, size_t _offset, int _pitch, int _row_size, int _height, size_t _offsetU, size_t _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV); + VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height); + VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV); // for Alpha - VideoFrame(VideoFrameBuffer* _vfb, size_t _offset, int _pitch, int _row_size, int _height, size_t _offsetU, size_t _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV, size_t _offsetA); -#else - VideoFrame(VideoFrameBuffer* _vfb, int _offset, int _pitch, int _row_size, int _height); - VideoFrame(VideoFrameBuffer* _vfb, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV); - // for Alpha - VideoFrame(VideoFrameBuffer* _vfb, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV, int _offsetA); -#endif - + VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV, int _offsetA); void* operator new(size_t size); // TESTME: OFFSET U/V may be switched to what could be expected from AVI standard! public: @@ -850,11 +970,7 @@ public: // generally you shouldn't use these three VideoFrameBuffer* GetFrameBuffer() const AVS_BakedCode( return AVS_LinkCall(GetFrameBuffer)() ) -#ifdef SIZETMOD - size_t GetOffset(int plane = 0) const AVS_BakedCode(return AVS_LinkCall(GetOffset)(plane)) -#else int GetOffset(int plane=0) const AVS_BakedCode( return AVS_LinkCall(GetOffset)(plane) ) -#endif // in plugins use env->SubFrame() -- because implementation code is only available inside avisynth.dll. Doh! VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height) const; @@ -866,6 +982,15 @@ public: bool IsWritable() const AVS_BakedCode( return AVS_LinkCall(IsWritable)() ) BYTE* GetWritePtr(int plane=0) const AVS_BakedCode( return AVS_LinkCall(VFGetWritePtr)(plane) ) + AVSMap& getProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getProperties, (AVSMap&)*(AVSMap*)0)) + const AVSMap& getConstProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getConstProperties, (const AVSMap&)*(const AVSMap*)0)) + void setProperties(const AVSMap & _properties) AVS_BakedCode(AVS_LinkCall_Void(setProperties)(_properties)) + + PDevice GetDevice() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_GetDevice)()) + + // 0: OK, 1: NG, -1: disabled or non CPU frame + int CheckMemory() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_CheckMemory)()) + ~VideoFrame() AVS_BakedCode( AVS_LinkCall_Void(VideoFrame_DESTRUCTOR)() ) #ifdef BUILDING_AVSCORE public: @@ -950,6 +1075,11 @@ enum CachePolicyHint { CACHE_IS_MTGUARD_REQ, CACHE_IS_MTGUARD_ANS, + CACHE_AVSPLUS_CUDA_CONSTANTS = 600, + + CACHE_GET_DEV_TYPE, // Device types a filter can return + CACHE_GET_CHILD_DEV_TYPE, // Device types a fitler can receive + CACHE_USER_CONSTANTS = 1000 // Smaller values are reserved for the core }; @@ -966,11 +1096,11 @@ public: virtual int __stdcall GetVersion() { return AVISYNTH_INTERFACE_VERSION; } virtual PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) = 0; virtual bool __stdcall GetParity(int n) = 0; // return field parity if field_based, else parity of first field in frame - virtual void __stdcall GetAudio(void* buf, __int64 start, __int64 count, IScriptEnvironment* env) = 0; // start and count are in samples + virtual void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) = 0; // start and count are in samples /* Need to check GetVersion first, pre v5 will return random crap from EAX reg. */ virtual int __stdcall SetCacheHints(int cachehints,int frame_range) = 0 ; // We do not pass cache requests upwards, only to the next filter. virtual const VideoInfo& __stdcall GetVideoInfo() = 0; - virtual AVSC_CC ~IClip() {} + virtual ~IClip() {} }; // end class IClip @@ -1011,39 +1141,28 @@ public: #endif }; // end class PClip +// enums for frame property functions +typedef enum AVSPropTypes { + ptUnset = 'u', + ptInt = 'i', + ptFloat = 'f', + ptData = 's', + ptClip = 'c', + ptFrame = 'v', + // ptFunction = 'm' +} AVSPropTypes; -// smart pointer to VideoFrame -class PVideoFrame { +typedef enum AVSGetPropErrors { + peUnset = 1, + peType = 2, + peIndex = 4 +} AVSGetPropErrors; - VideoFrame* p; - - void Init(VideoFrame* x); - void Set(VideoFrame* x); - -public: - PVideoFrame() AVS_BakedCode( AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR0)() ) - PVideoFrame(const PVideoFrame& x) AVS_BakedCode( AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR1)(x) ) - PVideoFrame(VideoFrame* x) AVS_BakedCode( AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR2)(x) ) - void operator=(VideoFrame* x) AVS_BakedCode( AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN0)(x) ) - void operator=(const PVideoFrame& x) AVS_BakedCode( AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN1)(x) ) - - VideoFrame* operator->() const { return p; } - - // for conditional expressions - operator void*() const { return p; } - bool operator!() const { return !p; } - - ~PVideoFrame() AVS_BakedCode( AVS_LinkCall_Void(PVideoFrame_DESTRUCTOR)() ) -#ifdef BUILDING_AVSCORE -public: - void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ - void CONSTRUCTOR1(const PVideoFrame& x); - void CONSTRUCTOR2(VideoFrame* x); - void OPERATOR_ASSIGN0(VideoFrame* x); - void OPERATOR_ASSIGN1(const PVideoFrame& x); - void DESTRUCTOR(); -#endif -}; // end class PVideoFrame +typedef enum AVSPropAppendMode { + paReplace = 0, + paAppend = 1, + paTouch = 2 +} AVSPropAppendMode; class AVSValue { @@ -1054,13 +1173,14 @@ public: AVSValue(const PClip& c) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR2)(c) ) AVSValue(bool b) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR3)(b) ) AVSValue(int i) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR4)(i) ) -// AVSValue(__int64 l); +// AVSValue(int64_t l); AVSValue(float f) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR5)(f) ) AVSValue(double f) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR6)(f) ) AVSValue(const char* s) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR7)(s) ) AVSValue(const AVSValue* a, int size) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR8)(a, size) ) AVSValue(const AVSValue& a, int size) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR8)(&a, size) ) AVSValue(const AVSValue& v) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR9)(v) ) + AVSValue(const PFunction& n) AVS_BakedCode(AVS_LinkCall_Void(AVSValue_CONSTRUCTOR11)(n)) ~AVSValue() AVS_BakedCode( AVS_LinkCall_Void(AVSValue_DESTRUCTOR)() ) AVSValue& operator=(const AVSValue& v) AVS_BakedCode( return AVS_LinkCallV(AVSValue_OPERATOR_ASSIGN)(v) ) @@ -1075,7 +1195,8 @@ public: // bool IsLong() const; bool IsFloat() const AVS_BakedCode( return AVS_LinkCall(IsFloat)() ) bool IsString() const AVS_BakedCode( return AVS_LinkCall(IsString)() ) - bool IsArray() const AVS_BakedCode( return AVS_LinkCall(IsArray)() ) + bool IsArray() const AVS_BakedCode(return AVS_LinkCall(IsArray)()) + bool IsFunction() const AVS_BakedCode( return AVS_LinkCall(IsFunction)() ) PClip AsClip() const AVS_BakedCode( return AVS_LinkCall(AsClip)() ) bool AsBool() const AVS_BakedCode( return AVS_LinkCall(AsBool1)() ) @@ -1091,6 +1212,7 @@ public: double AsFloat(float def) const AVS_BakedCode( return AVS_LinkCall(AsFloat2)(def) ) float AsFloatf(float def) const AVS_BakedCode( return float( AVS_LinkCall(AsFloat2)(def) ) ) const char* AsString(const char* def) const AVS_BakedCode( return AVS_LinkCall(AsString2)(def) ) + PFunction AsFunction() const; // internal use only int ArraySize() const AVS_BakedCode( return AVS_LinkCall(ArraySize)() ) @@ -1098,7 +1220,7 @@ public: private: - short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or RFU: 'l'ong ('d'ouble) + short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, fu'n'ction, or RFU: 'l'ong ('d'ouble) short array_size; union { IClip* clip; @@ -1107,9 +1229,10 @@ private: float floating_pt; const char* string; const AVSValue* array; + IFunction* function; #ifdef X86_64 // if ever, only x64 will support. It breaks struct size on 32 bit - __int64 longlong; // 8 bytes + int64_t longlong; // 8 bytes double double_pt; // 8 bytes #endif }; @@ -1127,6 +1250,7 @@ public: void CONSTRUCTOR7(const char* s); void CONSTRUCTOR8(const AVSValue* a, int size); void CONSTRUCTOR9(const AVSValue& v); + void CONSTRUCTOR11(const PFunction& n); void DESTRUCTOR(); AVSValue& OPERATOR_ASSIGN(const AVSValue& v); const AVSValue& OPERATOR_INDEX(int index) const; @@ -1142,7 +1266,7 @@ public: const char* AsString2(const char* def) const; #ifdef NEW_AVSVALUE - void MarkArrayAsC(); + void MarkArrayAsC(); // for C interface, no deep-copy and deep-free void CONSTRUCTOR10(const AVSValue& v, bool c_arrays); AVSValue(const AVSValue& v, bool c_arrays); void Assign2(const AVSValue* src, bool init, bool c_arrays); @@ -1151,14 +1275,7 @@ public: #endif }; // end class AVSValue -#undef CALL_MEMBER_FN -#undef AVS_LinkCallOptDefault -#undef AVS_LinkCallOpt -#undef AVS_LinkCallV -#undef AVS_LinkCall -#undef AVS_BakedCode - -#define AVS_UNUSED(x) x +#define AVS_UNUSED(x) (void)(x) // instantiable null filter class GenericVideoFilter : public IClip { @@ -1168,31 +1285,101 @@ protected: public: GenericVideoFilter(PClip _child) : child(_child) { vi = child->GetVideoInfo(); } PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) { return child->GetFrame(n, env); } - void __stdcall GetAudio(void* buf, __int64 start, __int64 count, IScriptEnvironment* env) { child->GetAudio(buf, start, count, env); } + void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) { child->GetAudio(buf, start, count, env); } const VideoInfo& __stdcall GetVideoInfo() { return vi; } bool __stdcall GetParity(int n) { return child->GetParity(n); } int __stdcall SetCacheHints(int cachehints, int frame_range) { AVS_UNUSED(cachehints); AVS_UNUSED(frame_range); return 0; }; // We do not pass cache requests upwards, only to the next filter. }; +class PFunction +{ +public: + PFunction() AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR0)()) + PFunction(IFunction* p) AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR1)(p)) + PFunction(const PFunction& p) AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR2)(p)) + PFunction& operator=(IFunction* p) AVS_BakedCode(return AVS_LinkCallV(PFunction_OPERATOR_ASSIGN0)(p)) + PFunction& operator=(const PFunction& p) AVS_BakedCode(return AVS_LinkCallV(PFunction_OPERATOR_ASSIGN1)(p)) + ~PFunction() AVS_BakedCode(AVS_LinkCall_Void(PFunction_DESTRUCTOR)()) + + int operator!() const { return !e; } + operator void*() const { return e; } + IFunction* operator->() const { return e; } + +private: + IFunction * e; + + friend class AVSValue; + IFunction * GetPointerWithAddRef() const; + void Init(IFunction* p); + void Set(IFunction* p); + +#ifdef BUILDING_AVSCORE +public: + void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ + void CONSTRUCTOR1(IFunction* p); + void CONSTRUCTOR2(const PFunction& p); + PFunction& OPERATOR_ASSIGN0(IFunction* p); + PFunction& OPERATOR_ASSIGN1(const PFunction& p); + void DESTRUCTOR(); +#endif +}; -#include "cpuid.h" +#undef CALL_MEMBER_FN +#undef AVS_LinkCallOptDefault +#undef AVS_LinkCallOpt +#undef AVS_LinkCallV +#undef AVS_LinkCall +#undef AVS_BakedCode +#include + +// IScriptEnvironment GetEnvProperty +enum AvsEnvProperty +{ + AEP_PHYSICAL_CPUS = 1, + AEP_LOGICAL_CPUS = 2, + AEP_THREADPOOL_THREADS = 3, + AEP_FILTERCHAIN_THREADS = 4, + AEP_THREAD_ID = 5, + AEP_VERSION = 6, + + // Neo additionals + AEP_NUM_DEVICES = 901, + AEP_FRAME_ALIGN = 902, + AEP_PLANE_ALIGN = 903, + + AEP_SUPPRESS_THREAD = 921, + AEP_GETFRAME_RECURSIVE = 922, +}; + +// IScriptEnvironment Allocate +enum AvsAllocType +{ + AVS_NORMAL_ALLOC = 1, + AVS_POOLED_ALLOC = 2 +}; + class IScriptEnvironment { public: - virtual AVSC_CC ~IScriptEnvironment() {} + virtual ~IScriptEnvironment() {} virtual /*static*/ int __stdcall GetCPUFlags() = 0; virtual char* __stdcall SaveString(const char* s, int length = -1) = 0; - virtual char* __stdcall Sprintf(const char* fmt, ...) = 0; + virtual char* Sprintf(const char* fmt, ...) = 0; // note: val is really a va_list; I hope everyone typedefs va_list to a pointer - virtual char* __stdcall VSprintf(const char* fmt, void* val) = 0; + // 20200305: (void *) changed back to va_list + virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0; - __declspec(noreturn) virtual void __stdcall ThrowError(const char* fmt, ...) = 0; +#ifdef AVS_WINDOWS + __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0; +#else + virtual void ThrowError(const char* fmt, ...) = 0; +#endif class NotFound /*exception*/ {}; // thrown by Invoke and GetVar @@ -1209,7 +1396,7 @@ public: virtual void __stdcall PushContext(int level=0) = 0; virtual void __stdcall PopContext() = 0; - // align should be 4 or 8 + // note v8: deprecated in most cases, use NewVideoFrameP is possible virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, int align=FRAME_ALIGN) = 0; virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0; @@ -1239,16 +1426,96 @@ public: virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0; + // **** AVISYNTH_INTERFACE_VERSION 5 **** defined since classic Avisynth 2.6 beta virtual void __stdcall DeleteScriptEnvironment() = 0; virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size, int textcolor, int halocolor, int bgcolor) = 0; - virtual const AVS_Linkage* const __stdcall GetAVSLinkage() = 0; + virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0; + // **** AVISYNTH_INTERFACE_VERSION 6 **** defined since classic Avisynth 2.6 // noThrow version of GetVar virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0; + // **** AVISYNTH_INTERFACE_VERSION 8 **** AviSynth+ 3.6.0- + virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, + int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0; + + virtual void __stdcall copyFrameProps(const PVideoFrame& src, PVideoFrame& dst) = 0; + virtual const AVSMap* __stdcall getFramePropsRO(const PVideoFrame& frame) = 0; + virtual AVSMap* __stdcall getFramePropsRW(PVideoFrame& frame) = 0; + + virtual int __stdcall propNumKeys(const AVSMap* map) = 0; + + virtual const char* __stdcall propGetKey(const AVSMap* map, int index) = 0; + virtual int __stdcall propNumElements(const AVSMap* map, const char* key) = 0; + virtual char __stdcall propGetType(const AVSMap* map, const char* key) = 0; + + virtual int64_t __stdcall propGetInt(const AVSMap* map, const char* key, int index, int* error) = 0; + virtual double __stdcall propGetFloat(const AVSMap* map, const char* key, int index, int* error) = 0; + virtual const char* __stdcall propGetData(const AVSMap* map, const char* key, int index, int* error) = 0; + virtual int __stdcall propGetDataSize(const AVSMap* map, const char* key, int index, int* error) = 0; + virtual PClip __stdcall propGetClip(const AVSMap* map, const char* key, int index, int* error) = 0; + virtual const PVideoFrame __stdcall propGetFrame(const AVSMap* map, const char* key, int index, int* error) = 0; + + virtual int __stdcall propDeleteKey(AVSMap* map, const char* key) = 0; + + virtual int __stdcall propSetInt(AVSMap* map, const char* key, int64_t i, int append) = 0; + virtual int __stdcall propSetFloat(AVSMap* map, const char* key, double d, int append) = 0; + virtual int __stdcall propSetData(AVSMap* map, const char* key, const char* d, int length, int append) = 0; + virtual int __stdcall propSetClip(AVSMap* map, const char* key, PClip& clip, int append) = 0; + virtual int __stdcall propSetFrame(AVSMap* map, const char* key, const PVideoFrame& frame, int append) = 0; + + virtual const int64_t* __stdcall propGetIntArray(const AVSMap* map, const char* key, int* error) = 0; + virtual const double* __stdcall propGetFloatArray(const AVSMap* map, const char* key, int* error) = 0; + virtual int __stdcall propSetIntArray(AVSMap* map, const char* key, const int64_t* i, int size) = 0; + virtual int __stdcall propSetFloatArray(AVSMap* map, const char* key, const double* d, int size) = 0; + + virtual AVSMap* __stdcall createMap() = 0; + virtual void __stdcall freeMap(AVSMap* map) = 0; + virtual void __stdcall clearMap(AVSMap* map) = 0; + + // NewVideoFrame with frame property source. + virtual PVideoFrame __stdcall NewVideoFrameP(const VideoInfo& vi, PVideoFrame* propSrc, int align = FRAME_ALIGN) = 0; + + // Note: do not declare existing names like 'NewVideoFrame' again with different parameters since MSVC will reorder it + // in the vtable and group it together with the first NewVideoFrame variant. + // This results in shifting all vtable method pointers after NewVideoFrame and breaks all plugins who expect the old order. + // E.g. ApplyMessage will be called instead of GetAVSLinkage + + // Generic query to ask for various system properties + virtual size_t __stdcall GetEnvProperty(AvsEnvProperty prop) = 0; + + // Support functions + virtual void* __stdcall Allocate(size_t nBytes, size_t alignment, AvsAllocType type) = 0; + virtual void __stdcall Free(void* ptr) = 0; + + // these GetVar versions (renamed differently) were moved from IScriptEnvironment2 + + // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'. + virtual bool __stdcall GetVarTry(const char* name, AVSValue* val) const = 0; // ex virtual bool __stdcall GetVar(const char* name, AVSValue* val) const = 0; + // Return the value of the requested variable. + // If the variable was not found or had the wrong type, + // return the supplied default value. + virtual bool __stdcall GetVarBool(const char* name, bool def) const = 0; + virtual int __stdcall GetVarInt(const char* name, int def) const = 0; + virtual double __stdcall GetVarDouble(const char* name, double def) const = 0; + virtual const char* __stdcall GetVarString(const char* name, const char* def) const = 0; + // brand new in v8 - though no real int64 support yet + virtual int64_t __stdcall GetVarLong(const char* name, int64_t def) const = 0; + + // 'Invoke' functions moved here from internal ScriptEnvironments are renamed in order to keep vtable order + // Invoke functions with 'Try' will return false instead of throwing NotFound(). + // ex-IScriptEnvironment2 + virtual bool __stdcall InvokeTry(AVSValue* result, const char* name, const AVSValue& args, const char* const* arg_names = 0) = 0; + // Since V8 + virtual AVSValue __stdcall Invoke2(const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; + // Ex-INeo + virtual bool __stdcall Invoke2Try(AVSValue* result, const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; + virtual AVSValue __stdcall Invoke3(const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; + virtual bool __stdcall Invoke3Try(AVSValue* result, const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; + }; // end class IScriptEnvironment @@ -1266,7 +1533,7 @@ class IJobCompletion { public: - virtual __stdcall ~IJobCompletion() {} + virtual ~IJobCompletion() {} virtual void __stdcall Wait() = 0; virtual AVSValue __stdcall Get(size_t i) = 0; virtual size_t __stdcall Size() const = 0; @@ -1279,21 +1546,6 @@ class IScriptEnvironment2; class Prefetcher; typedef AVSValue (*ThreadWorkerFuncPtr)(IScriptEnvironment2* env, void* data); -enum AvsEnvProperty -{ - AEP_PHYSICAL_CPUS = 1, - AEP_LOGICAL_CPUS = 2, - AEP_THREADPOOL_THREADS = 3, - AEP_FILTERCHAIN_THREADS = 4, - AEP_THREAD_ID = 5, - AEP_VERSION = 6 -}; - -enum AvsAllocType -{ - AVS_NORMAL_ALLOC = 1, - AVS_POOLED_ALLOC = 2 -}; /* ----------------------------------------------------------------------------- Note to plugin authors: The interface in IScriptEnvironment2 is @@ -1303,24 +1555,11 @@ enum AvsAllocType to test it and give your feedback about any ideas, improvements, or issues you might have. ----------------------------------------------------------------------------- */ -class AVSFunction; class IScriptEnvironment2 : public IScriptEnvironment{ public: virtual ~IScriptEnvironment2() {} - // Generic system to ask for various properties - virtual size_t __stdcall GetProperty(AvsEnvProperty prop) = 0; - - // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'. - virtual bool __stdcall GetVar(const char* name, AVSValue *val) const = 0; - - // Return the value of the requested variable. - // If the variable was not found or had the wrong type, - // return the supplied default value. - virtual bool __stdcall GetVar(const char* name, bool def) const = 0; - virtual int __stdcall GetVar(const char* name, int def) const = 0; - virtual double __stdcall GetVar(const char* name, double def) const = 0; - virtual const char* __stdcall GetVar(const char* name, const char* def) const = 0; + // V8: SubframePlanarA, GetEnvProperty, GetVar versions, Allocate, Free, no-throw Invoke moved to IScriptEnvironment // Plugin functions virtual bool __stdcall LoadPlugin(const char* filePath, bool throwOnError, AVSValue *result) = 0; @@ -1335,22 +1574,216 @@ public: virtual IJobCompletion* __stdcall NewCompletion(size_t capacity) = 0; virtual void __stdcall ParallelJob(ThreadWorkerFuncPtr jobFunc, void* jobData, IJobCompletion* completion) = 0; - // This version of Invoke will return false instead of throwing NotFound(). - virtual bool __stdcall Invoke(AVSValue *result, const char* name, const AVSValue& args, const char* const* arg_names=0) = 0; + // These lines are needed so that we can overload the older functions from IScriptEnvironment. + using IScriptEnvironment::Invoke; + using IScriptEnvironment::AddFunction; + +}; // end class IScriptEnvironment2 + + +// To allow Avisynth+ add functions to IScriptEnvironment2, +// Neo defines another new interface, INeoEnv. +// INeoEnv and the legacy interfaces (IScriptEnvironment/IScriptEnvironment2) +// share the same ScriptEnvironment instance. The function with the same signature +// is exactly identical and there is no limitation to switch interfaces. +// You can use any interface you like. +class INeoEnv { +public: + virtual ~INeoEnv() {} + + typedef IScriptEnvironment::NotFound NotFound; + typedef IScriptEnvironment::ApplyFunc ApplyFunc; + typedef IScriptEnvironment::ShutdownFunc ShutdownFunc; + + virtual void __stdcall DeleteScriptEnvironment() = 0; + + virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0; + + // Get legacy interface + virtual IScriptEnvironment2* __stdcall GetEnv2() = 0; + + // Generic system to ask for various properties + virtual size_t __stdcall GetEnvProperty(AvsEnvProperty prop) = 0; +#ifdef INTEL_INTRINSICS + virtual int __stdcall GetCPUFlags() = 0; +#endif + + // Plugin functions + virtual bool __stdcall LoadPlugin(const char* filePath, bool throwOnError, AVSValue *result) = 0; + virtual void __stdcall AddAutoloadDir(const char* dirPath, bool toFront) = 0; + virtual void __stdcall ClearAutoloadDirs() = 0; + virtual void __stdcall AutoloadPlugins() = 0; + + virtual void __stdcall AddFunction( + const char* name, const char* params, ApplyFunc apply, void* user_data) = 0; + virtual void __stdcall AddFunction( + const char* name, const char* params, ApplyFunc apply, void* user_data, const char *exportVar) = 0; + virtual bool __stdcall FunctionExists(const char* name) = 0; + virtual bool __stdcall InternalFunctionExists(const char* name) = 0; + + // Invoke function. Throws NotFound exception when the specified function does not exist. + virtual AVSValue __stdcall Invoke( + const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; + virtual AVSValue __stdcall Invoke2( + const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; + virtual AVSValue __stdcall Invoke3( + const AVSValue& implicit_last, + const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; + + // These versions of Invoke will return false instead of throwing NotFound(). + virtual bool __stdcall InvokeTry( + AVSValue* result, const char* name, const AVSValue& args, const char* const* arg_names = 0) = 0; + virtual bool __stdcall Invoke2Try( + AVSValue* result, const AVSValue& implicit_last, + const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; + virtual bool __stdcall Invoke3Try( + AVSValue* result, const AVSValue& implicit_last, + const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; + + // Throws exception when the requested variable is not found. + virtual AVSValue __stdcall GetVar(const char* name) = 0; + + // noThrow version of GetVar + virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0; + + // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'. + virtual bool __stdcall GetVarTry(const char* name, AVSValue* val) const = 0; + + // Return the value of the requested variable. + // If the variable was not found or had the wrong type, + // return the supplied default value. + virtual bool __stdcall GetVarBool(const char* name, bool def) const = 0; + virtual int __stdcall GetVarInt(const char* name, int def) const = 0; + virtual double __stdcall GetVarDouble(const char* name, double def) const = 0; + virtual const char* __stdcall GetVarString(const char* name, const char* def) const = 0; + virtual int64_t __stdcall GetVarLong(const char* name, int64_t def) const = 0; + + virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0; + virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0; + + // Switch local variables + virtual void __stdcall PushContext(int level = 0) = 0; + virtual void __stdcall PopContext() = 0; + + // Global variable frame support + virtual void __stdcall PushContextGlobal() = 0; + virtual void __stdcall PopContextGlobal() = 0; + + // Allocate new video frame + // Align parameter is no longer supported + virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi) = 0; // current device is used + virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PDevice& device) = 0; + // as above but with property sources + virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, PVideoFrame *propSrc) = 0; // current device is used + frame property source + virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PDevice& device, PVideoFrame* propSrc) = 0; // current device is used + frame property source + + // Frame related operations + virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0; + virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0; + + virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0; + virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, + int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0; + virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, + int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0; + + // frame properties support + virtual void __stdcall copyFrameProps(const PVideoFrame& src, PVideoFrame& dst) = 0; + virtual const AVSMap* __stdcall getFramePropsRO(const PVideoFrame& frame) = 0; + virtual AVSMap* __stdcall getFramePropsRW(PVideoFrame& frame) = 0; + + virtual int __stdcall propNumKeys(const AVSMap* map) = 0; + virtual const char* __stdcall propGetKey(const AVSMap* map, int index) = 0; + virtual int __stdcall propNumElements(const AVSMap* map, const char* key) = 0; + virtual char __stdcall propGetType(const AVSMap* map, const char* key) = 0; + + virtual int64_t __stdcall propGetInt(const AVSMap* map, const char* key, int index, int* error) = 0; + virtual double __stdcall propGetFloat(const AVSMap* map, const char* key, int index, int* error) = 0; + virtual const char* __stdcall propGetData(const AVSMap* map, const char* key, int index, int* error) = 0; + virtual int __stdcall propGetDataSize(const AVSMap* map, const char* key, int index, int* error) = 0; + virtual PClip __stdcall propGetClip(const AVSMap* map, const char* key, int index, int* error) = 0; + virtual const PVideoFrame __stdcall propGetFrame(const AVSMap* map, const char* key, int index, int* error) = 0; + + virtual int __stdcall propDeleteKey(AVSMap* map, const char* key) = 0; + + virtual int __stdcall propSetInt(AVSMap* map, const char* key, int64_t i, int append) = 0; + virtual int __stdcall propSetFloat(AVSMap* map, const char* key, double d, int append) = 0; + virtual int __stdcall propSetData(AVSMap* map, const char* key, const char* d, int length, int append) = 0; + virtual int __stdcall propSetClip(AVSMap* map, const char* key, PClip& clip, int append) = 0; + virtual int __stdcall propSetFrame(AVSMap* map, const char* key, const PVideoFrame& frame, int append) = 0; + + virtual const int64_t *__stdcall propGetIntArray(const AVSMap* map, const char* key, int* error) = 0; + virtual const double *__stdcall propGetFloatArray(const AVSMap* map, const char* key, int* error) = 0; + virtual int __stdcall propSetIntArray(AVSMap* map, const char* key, const int64_t* i, int size) = 0; + virtual int __stdcall propSetFloatArray(AVSMap* map, const char* key, const double* d, int size) = 0; + + virtual AVSMap* __stdcall createMap() = 0; + virtual void __stdcall freeMap(AVSMap* map) = 0; + virtual void __stdcall clearMap(AVSMap* map) = 0; // Support functions virtual void* __stdcall Allocate(size_t nBytes, size_t alignment, AvsAllocType type) = 0; virtual void __stdcall Free(void* ptr) = 0; - // These lines are needed so that we can overload the older functions from IScriptEnvironment. - using IScriptEnvironment::Invoke; - using IScriptEnvironment::AddFunction; - using IScriptEnvironment::GetVar; + virtual char* __stdcall SaveString(const char* s, int length = -1) = 0; + virtual char* __stdcall SaveString(const char* s, int length, bool escape) = 0; + virtual char* Sprintf(const char* fmt, ...) = 0; + virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0; - virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, - int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0; + __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0; -}; // end class IScriptEnvironment2 + virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size, + int textcolor, int halocolor, int bgcolor) = 0; + + // Setting + virtual int __stdcall SetMemoryMax(int mem) = 0; + virtual int __stdcall SetMemoryMax(AvsDeviceType type, int index, int mem) = 0; + + virtual bool __stdcall PlanarChromaAlignment(IScriptEnvironment::PlanarChromaAlignmentMode key) = 0; + virtual int __stdcall SetWorkingDir(const char * newdir) = 0; + virtual void* __stdcall ManageCache(int key, void* data) = 0; + + virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0; + virtual void __stdcall CheckVersion(int version = AVISYNTH_INTERFACE_VERSION) = 0; + + // Threading + virtual void __stdcall SetFilterMTMode(const char* filter, MtMode mode, bool force) = 0; + virtual IJobCompletion* __stdcall NewCompletion(size_t capacity) = 0; + virtual void __stdcall ParallelJob(ThreadWorkerFuncPtr jobFunc, void* jobData, IJobCompletion* completion) = 0; + + // CUDA Support + virtual PDevice __stdcall GetDevice(AvsDeviceType dev_type, int dev_index) const = 0; + virtual PDevice __stdcall GetDevice() const = 0; // get current device + virtual AvsDeviceType __stdcall GetDeviceType() const = 0; + virtual int __stdcall GetDeviceId() const = 0; + virtual int __stdcall GetDeviceIndex() const = 0; + virtual void* __stdcall GetDeviceStream() const = 0; + virtual void __stdcall DeviceAddCallback(void(*cb)(void*), void* user_data) = 0; + + virtual PVideoFrame __stdcall GetFrame(PClip c, int n, const PDevice& device) = 0; + +}; + +// support interface conversion +struct PNeoEnv { + INeoEnv* p; + PNeoEnv() : p() { } + PNeoEnv(IScriptEnvironment* env) +#ifdef BUILDING_AVSCORE + ; +#else + : p(!AVS_linkage || offsetof(AVS_Linkage, GetNeoEnv) >= AVS_linkage->Size ? 0 : AVS_linkage->GetNeoEnv(env)) { } +#endif + + int operator!() const { return !p; } + operator void*() const { return p; } + INeoEnv* operator->() const { return p; } +#ifdef BUILDING_AVSCORE + inline operator IScriptEnvironment2*(); +#else + operator IScriptEnvironment2*() { return p->GetEnv2(); } +#endif +}; // avisynth.dll exports this; it's a way to use it as a library, without @@ -1371,7 +1804,7 @@ AVSC_API(IScriptEnvironment*, CreateScriptEnvironment)(int version = AVISYNTH_IN #define VARNAME_Enable_PlanarToPackedRGB "OPT_Enable_PlanarToPackedRGB" // AVS+ convert Planar RGB to packed RGB (VfW) // C exports -#include +#include "avs/capi.h" AVSC_API(IScriptEnvironment2*, CreateScriptEnvironment2)(int version = AVISYNTH_INTERFACE_VERSION); #ifndef BUILDING_AVSCORE @@ -1380,4 +1813,4 @@ AVSC_API(IScriptEnvironment2*, CreateScriptEnvironment2)(int version = AVISYNTH_ #pragma pack(pop) -#endif //__AVISYNTH_6_H__ +#endif //__AVISYNTH_8_H__ diff --git a/FrameServer/avisynth_headers/avisynth_c.h b/FrameServer/avisynth_headers/avisynth_c.h deleted file mode 100644 index f9934e0b..00000000 --- a/FrameServer/avisynth_headers/avisynth_c.h +++ /dev/null @@ -1,1257 +0,0 @@ -// Avisynth C Interface Version 0.20 -// Copyright 2003 Kevin Atkinson - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA, or visit -// http://www.gnu.org/copyleft/gpl.html . -// -// As a special exception, I give you permission to link to the -// Avisynth C interface with independent modules that communicate with -// the Avisynth C interface solely through the interfaces defined in -// avisynth_c.h, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting combined work -// under terms of your choice, provided that every copy of the -// combined work is accompanied by a complete copy of the source code -// of the Avisynth C interface and Avisynth itself (with the version -// used to produce the combined work), being distributed under the -// terms of the GNU General Public License plus this exception. An -// independent module is a module which is not derived from or based -// on Avisynth C Interface, such as 3rd-party filters, import and -// export plugins, or graphical user interfaces. - -// NOTE: this is a partial update of the Avisynth C interface to recognize -// new color spaces added in Avisynth 2.60. By no means is this document -// completely Avisynth 2.60 compliant. -// 170103: added new CPU constants (FMA4, AVX512xx) -// 171102: define SIZETMOD. do not use yet, experimental. Offsets are size_t instead of int. Affects x64. -// 171106: avs_get_row_size calls into avs_get_row_size_p, instead of direct field access -// 171106: avs_get_height calls into avs_get_row_size_p, instead of direct field access -// 180524: AVSC_EXPORT to dllexport in capi.h for avisynth_c_plugin_init -// 180524: avs_is_same_colorspace VideoInfo parameters to const -// 181230: Readability: functions regrouped to mix less AVSC_API and AVSC_INLINE, put together Avisynth+ specific stuff -// 181230: use #ifndef AVSC_NO_DECLSPEC for AVSC_INLINE functions which are calling API functions -// 181230: comments on avs_load_library (helper for loading API entries dynamically into a struct using AVSC_NO_DECLSPEC define) -// 181230: define alias AVS_FRAME_ALIGN as FRAME_ALIGN -// 181230: remove unused form of avs_get_rowsize and avs_get_height (kept earlier for reference) -// 190104: avs_load_library: smart fallback mechanism for Avisynth+ specific functions: -// if they are not loadable, they will work in a classic Avisynth compatible mode -// Example#1: e.g. avs_is_444 will call the existing avs_is_yv24 instead -// Example#2: avs_bits_per_component will return 8 for all colorspaces (Classic Avisynth supports only 8 bits/pixel) -// Thus the Avisynth+ specific API functions are safely callable even when connected to classic Avisynth DLL - -#ifndef __AVISYNTH_C__ -#define __AVISYNTH_C__ - -#include -#include -#include - -#define AVS_FRAME_ALIGN FRAME_ALIGN -///////////////////////////////////////////////////////////////////// -// -// Constants -// - -#ifndef __AVISYNTH_6_H__ -enum { AVISYNTH_INTERFACE_VERSION = 6 }; -#endif - -enum {AVS_SAMPLE_INT8 = 1<<0, - AVS_SAMPLE_INT16 = 1<<1, - AVS_SAMPLE_INT24 = 1<<2, - AVS_SAMPLE_INT32 = 1<<3, - AVS_SAMPLE_FLOAT = 1<<4}; - -enum {AVS_PLANAR_Y=1<<0, - AVS_PLANAR_U=1<<1, - AVS_PLANAR_V=1<<2, - AVS_PLANAR_ALIGNED=1<<3, - AVS_PLANAR_Y_ALIGNED=AVS_PLANAR_Y|AVS_PLANAR_ALIGNED, - AVS_PLANAR_U_ALIGNED=AVS_PLANAR_U|AVS_PLANAR_ALIGNED, - AVS_PLANAR_V_ALIGNED=AVS_PLANAR_V|AVS_PLANAR_ALIGNED, - AVS_PLANAR_A=1<<4, - AVS_PLANAR_R=1<<5, - AVS_PLANAR_G=1<<6, - AVS_PLANAR_B=1<<7, - AVS_PLANAR_A_ALIGNED=AVS_PLANAR_A|AVS_PLANAR_ALIGNED, - AVS_PLANAR_R_ALIGNED=AVS_PLANAR_R|AVS_PLANAR_ALIGNED, - AVS_PLANAR_G_ALIGNED=AVS_PLANAR_G|AVS_PLANAR_ALIGNED, - AVS_PLANAR_B_ALIGNED=AVS_PLANAR_B|AVS_PLANAR_ALIGNED}; - - // Colorspace properties. -enum { - AVS_CS_YUVA = 1 << 27, - AVS_CS_BGR = 1 << 28, - AVS_CS_YUV = 1 << 29, - AVS_CS_INTERLEAVED = 1 << 30, - AVS_CS_PLANAR = 1 << 31, - - AVS_CS_SHIFT_SUB_WIDTH = 0, - AVS_CS_SHIFT_SUB_HEIGHT = 8, - AVS_CS_SHIFT_SAMPLE_BITS = 16, - - AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH, - AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24 - AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16 - AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411 - - AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9 - AVS_CS_UPLANEFIRST = 1 << 4, // I420 - - AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT, - AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411 - AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420 - AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9 - - AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS, - AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS, - AVS_CS_SAMPLE_BITS_10 = 5 << AVS_CS_SHIFT_SAMPLE_BITS, - AVS_CS_SAMPLE_BITS_12 = 6 << AVS_CS_SHIFT_SAMPLE_BITS, - AVS_CS_SAMPLE_BITS_14 = 7 << AVS_CS_SHIFT_SAMPLE_BITS, - AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS, - AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS, - - AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_YUVA | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_HEIGHT_MASK | AVS_CS_SUB_WIDTH_MASK, - AVS_CS_PLANAR_FILTER = ~(AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST), - - AVS_CS_RGB_TYPE = 1 << 0, - AVS_CS_RGBA_TYPE = 1 << 1, - - AVS_CS_GENERIC_YUV420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // 4:2:0 planar - AVS_CS_GENERIC_YUV422 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // 4:2:2 planar - AVS_CS_GENERIC_YUV444 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1, // 4:4:4 planar - AVS_CS_GENERIC_Y = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV, // Y only (4:0:0) - AVS_CS_GENERIC_RGBP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGB_TYPE, // planar RGB - AVS_CS_GENERIC_RGBAP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGBA_TYPE, // planar RGBA - AVS_CS_GENERIC_YUVA420 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // 4:2:0:A planar - AVS_CS_GENERIC_YUVA422 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // 4:2:2:A planar - AVS_CS_GENERIC_YUVA444 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1 }; // 4:4:4:A planar - - - // Specific color formats -enum { - AVS_CS_UNKNOWN = 0, - AVS_CS_BGR24 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED, - AVS_CS_BGR32 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED, - AVS_CS_YUY2 = 1<<2 | AVS_CS_YUV | AVS_CS_INTERLEAVED, - // AVS_CS_YV12 = 1<<3 Reserved - // AVS_CS_I420 = 1<<4 Reserved - AVS_CS_RAW32 = 1<<5 | AVS_CS_INTERLEAVED, - - AVS_CS_YV24 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_8, // YUV 4:4:4 planar - AVS_CS_YV16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_8, // YUV 4:2:2 planar - AVS_CS_YV12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_8, // YUV 4:2:0 planar - AVS_CS_I420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_UPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // YUV 4:2:0 planar - AVS_CS_IYUV = AVS_CS_I420, - AVS_CS_YV411 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_4, // YUV 4:1:1 planar - AVS_CS_YUV9 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_4 | AVS_CS_SUB_WIDTH_4, // YUV 4:1:0 planar - AVS_CS_Y8 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_8, // Y 4:0:0 planar - - //------------------------- - // AVS16: new planar constants go live! Experimental PF 160613 - // 10-12-14-16 bit + planar RGB + BGR48/64 160725 - AVS_CS_YUV444P10 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_10, // YUV 4:4:4 10bit samples - AVS_CS_YUV422P10 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:2 10bit samples - AVS_CS_YUV420P10 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:0 10bit samples - AVS_CS_Y10 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_10, // Y 4:0:0 10bit samples - - AVS_CS_YUV444P12 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_12, // YUV 4:4:4 12bit samples - AVS_CS_YUV422P12 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:2 12bit samples - AVS_CS_YUV420P12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:0 12bit samples - AVS_CS_Y12 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_12, // Y 4:0:0 12bit samples - - AVS_CS_YUV444P14 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_14, // YUV 4:4:4 14bit samples - AVS_CS_YUV422P14 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:2 14bit samples - AVS_CS_YUV420P14 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:0 14bit samples - AVS_CS_Y14 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_14, // Y 4:0:0 14bit samples - - AVS_CS_YUV444P16 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_16, // YUV 4:4:4 16bit samples - AVS_CS_YUV422P16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:2 16bit samples - AVS_CS_YUV420P16 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:0 16bit samples - AVS_CS_Y16 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_16, // Y 4:0:0 16bit samples - - // 32 bit samples (float) - AVS_CS_YUV444PS = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_32, // YUV 4:4:4 32bit samples - AVS_CS_YUV422PS = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:2 32bit samples - AVS_CS_YUV420PS = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:0 32bit samples - AVS_CS_Y32 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_32, // Y 4:0:0 32bit samples - - // RGB packed - AVS_CS_BGR48 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 3x16 bit - AVS_CS_BGR64 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 4x16 bit - // no packed 32 bit (float) support for these legacy types - - // RGB planar - AVS_CS_RGBP = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_8, // Planar RGB 8 bit samples - AVS_CS_RGBP10 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_10, // Planar RGB 10bit samples - AVS_CS_RGBP12 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_12, // Planar RGB 12bit samples - AVS_CS_RGBP14 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_14, // Planar RGB 14bit samples - AVS_CS_RGBP16 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_16, // Planar RGB 16bit samples - AVS_CS_RGBPS = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_32, // Planar RGB 32bit samples - - // RGBA planar - AVS_CS_RGBAP = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_8, // Planar RGBA 8 bit samples - AVS_CS_RGBAP10 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_10, // Planar RGBA 10bit samples - AVS_CS_RGBAP12 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_12, // Planar RGBA 12bit samples - AVS_CS_RGBAP14 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_14, // Planar RGBA 14bit samples - AVS_CS_RGBAP16 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_16, // Planar RGBA 16bit samples - AVS_CS_RGBAPS = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_32, // Planar RGBA 32bit samples - - // Planar YUVA - AVS_CS_YUVA444 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:4:4 8bit samples - AVS_CS_YUVA422 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:2 8bit samples - AVS_CS_YUVA420 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:0 8bit samples - - AVS_CS_YUVA444P10 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:4:4 10bit samples - AVS_CS_YUVA422P10 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:2 10bit samples - AVS_CS_YUVA420P10 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:0 10bit samples - - AVS_CS_YUVA444P12 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:4:4 12bit samples - AVS_CS_YUVA422P12 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:2 12bit samples - AVS_CS_YUVA420P12 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:0 12bit samples - - AVS_CS_YUVA444P14 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:4:4 14bit samples - AVS_CS_YUVA422P14 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:2 14bit samples - AVS_CS_YUVA420P14 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:0 14bit samples - - AVS_CS_YUVA444P16 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:4:4 16bit samples - AVS_CS_YUVA422P16 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:2 16bit samples - AVS_CS_YUVA420P16 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:0 16bit samples - - AVS_CS_YUVA444PS = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:4:4 32bit samples - AVS_CS_YUVA422PS = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:2 32bit samples - AVS_CS_YUVA420PS = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:0 32bit samples - -}; - -enum { - AVS_IT_BFF = 1<<0, - AVS_IT_TFF = 1<<1, - AVS_IT_FIELDBASED = 1<<2}; - -enum { - AVS_FILTER_TYPE=1, - AVS_FILTER_INPUT_COLORSPACE=2, - AVS_FILTER_OUTPUT_TYPE=9, - AVS_FILTER_NAME=4, - AVS_FILTER_AUTHOR=5, - AVS_FILTER_VERSION=6, - AVS_FILTER_ARGS=7, - AVS_FILTER_ARGS_INFO=8, - AVS_FILTER_ARGS_DESCRIPTION=10, - AVS_FILTER_DESCRIPTION=11}; - -enum { //SUBTYPES - AVS_FILTER_TYPE_AUDIO=1, - AVS_FILTER_TYPE_VIDEO=2, - AVS_FILTER_OUTPUT_TYPE_SAME=3, - AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4}; - -enum { - // New 2.6 explicitly defined cache hints. - AVS_CACHE_NOTHING=10, // Do not cache video. - AVS_CACHE_WINDOW=11, // Hard protect up to X frames within a range of X from the current frame N. - AVS_CACHE_GENERIC=12, // LRU cache up to X frames. - AVS_CACHE_FORCE_GENERIC=13, // LRU cache up to X frames, override any previous CACHE_WINDOW. - - AVS_CACHE_GET_POLICY=30, // Get the current policy. - AVS_CACHE_GET_WINDOW=31, // Get the current window h_span. - AVS_CACHE_GET_RANGE=32, // Get the current generic frame range. - - AVS_CACHE_AUDIO=50, // Explicitly do cache audio, X byte cache. - AVS_CACHE_AUDIO_NOTHING=51, // Explicitly do not cache audio. - AVS_CACHE_AUDIO_NONE=52, // Audio cache off (auto mode), X byte initial cache. - AVS_CACHE_AUDIO_AUTO=53, // Audio cache on (auto mode), X byte initial cache. - - AVS_CACHE_GET_AUDIO_POLICY=70, // Get the current audio policy. - AVS_CACHE_GET_AUDIO_SIZE=71, // Get the current audio cache size. - - AVS_CACHE_PREFETCH_FRAME=100, // Queue request to prefetch frame N. - AVS_CACHE_PREFETCH_GO=101, // Action video prefetches. - - AVS_CACHE_PREFETCH_AUDIO_BEGIN=120, // Begin queue request transaction to prefetch audio (take critical section). - AVS_CACHE_PREFETCH_AUDIO_STARTLO=121, // Set low 32 bits of start. - AVS_CACHE_PREFETCH_AUDIO_STARTHI=122, // Set high 32 bits of start. - AVS_CACHE_PREFETCH_AUDIO_COUNT=123, // Set low 32 bits of length. - AVS_CACHE_PREFETCH_AUDIO_COMMIT=124, // Enqueue request transaction to prefetch audio (release critical section). - AVS_CACHE_PREFETCH_AUDIO_GO=125, // Action audio prefetches. - - AVS_CACHE_GETCHILD_CACHE_MODE=200, // Cache ask Child for desired video cache mode. - AVS_CACHE_GETCHILD_CACHE_SIZE=201, // Cache ask Child for desired video cache size. - AVS_CACHE_GETCHILD_AUDIO_MODE=202, // Cache ask Child for desired audio cache mode. - AVS_CACHE_GETCHILD_AUDIO_SIZE=203, // Cache ask Child for desired audio cache size. - - AVS_CACHE_GETCHILD_COST=220, // Cache ask Child for estimated processing cost. - AVS_CACHE_COST_ZERO=221, // Child response of zero cost (ptr arithmetic only). - AVS_CACHE_COST_UNIT=222, // Child response of unit cost (less than or equal 1 full frame blit). - AVS_CACHE_COST_LOW=223, // Child response of light cost. (Fast) - AVS_CACHE_COST_MED=224, // Child response of medium cost. (Real time) - AVS_CACHE_COST_HI=225, // Child response of heavy cost. (Slow) - - AVS_CACHE_GETCHILD_THREAD_MODE=240, // Cache ask Child for thread safety. - AVS_CACHE_THREAD_UNSAFE=241, // Only 1 thread allowed for all instances. 2.5 filters default! - AVS_CACHE_THREAD_CLASS=242, // Only 1 thread allowed for each instance. 2.6 filters default! - AVS_CACHE_THREAD_SAFE=243, // Allow all threads in any instance. - AVS_CACHE_THREAD_OWN=244, // Safe but limit to 1 thread, internally threaded. - - AVS_CACHE_GETCHILD_ACCESS_COST=260, // Cache ask Child for preferred access pattern. - AVS_CACHE_ACCESS_RAND=261, // Filter is access order agnostic. - AVS_CACHE_ACCESS_SEQ0=262, // Filter prefers sequential access (low cost) - AVS_CACHE_ACCESS_SEQ1=263, // Filter needs sequential access (high cost) - }; - -#ifdef BUILDING_AVSCORE -AVSValue create_c_video_filter(AVSValue args, void * user_data, IScriptEnvironment * e0); - -struct AVS_ScriptEnvironment { - IScriptEnvironment * env; - const char * error; - AVS_ScriptEnvironment(IScriptEnvironment * e = 0) - : env(e), error(0) {} -}; -#endif - -typedef struct AVS_Clip AVS_Clip; -typedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment; - -///////////////////////////////////////////////////////////////////// -// -// AVS_VideoInfo -// - -// AVS_VideoInfo is laid out identically to VideoInfo -typedef struct AVS_VideoInfo { - int width, height; // width=0 means no video - unsigned fps_numerator, fps_denominator; - int num_frames; - - int pixel_type; - - int audio_samples_per_second; // 0 means no audio - int sample_type; - INT64 num_audio_samples; - int nchannels; - - // Image type properties - - int image_type; -} AVS_VideoInfo; - -// useful functions of the above -AVSC_INLINE int avs_has_video(const AVS_VideoInfo * p) - { return (p->width!=0); } - -AVSC_INLINE int avs_has_audio(const AVS_VideoInfo * p) - { return (p->audio_samples_per_second!=0); } - -AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p) - { return !!(p->pixel_type&AVS_CS_BGR); } - -AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p) - { return ((p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); } - -AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p) - { return ((p->pixel_type&AVS_CS_BGR32)==AVS_CS_BGR32) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); } - -AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p) - { return !!(p->pixel_type&AVS_CS_YUV ); } - -AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p) - { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; } - -AVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p); // avs+: for generic 444 check, use avs_is_yuv444 - -AVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p); // avs+: for generic 422 check, use avs_is_yuv422 - -AVSC_API(int, avs_is_yv12)(const AVS_VideoInfo * p) ; // avs+: for generic 420 check, use avs_is_yuv420 - -AVSC_API(int, avs_is_yv411)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p); // avs+: for generic grayscale, use avs_is_y - -AVSC_API(int, avs_get_plane_width_subsampling)(const AVS_VideoInfo * p, int plane); - -AVSC_API(int, avs_get_plane_height_subsampling)(const AVS_VideoInfo * p, int plane); - -AVSC_API(int, avs_bits_per_pixel)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_bytes_from_pixels)(const AVS_VideoInfo * p, int pixels); - -AVSC_API(int, avs_row_size)(const AVS_VideoInfo * p, int plane); - -AVSC_API(int, avs_bmp_size)(const AVS_VideoInfo * vi); - -AVSC_API(int, avs_is_color_space)(const AVS_VideoInfo * p, int c_space); - -// no API for these, inline helper functions -AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property) -{ - return ((p->image_type & property) == property); -} - -AVSC_INLINE int avs_is_planar(const AVS_VideoInfo * p) -{ - return !!(p->pixel_type & AVS_CS_PLANAR); -} - -AVSC_INLINE int avs_is_field_based(const AVS_VideoInfo * p) -{ - return !!(p->image_type & AVS_IT_FIELDBASED); -} - -AVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo * p) -{ - return ((p->image_type & AVS_IT_FIELDBASED) && (p->image_type & (AVS_IT_BFF | AVS_IT_TFF))); -} - -AVSC_INLINE int avs_is_bff(const AVS_VideoInfo * p) -{ - return !!(p->image_type & AVS_IT_BFF); -} - -AVSC_INLINE int avs_is_tff(const AVS_VideoInfo * p) -{ - return !!(p->image_type & AVS_IT_TFF); -} - -AVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo * p) - { return p->audio_samples_per_second; } - -AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo * p) -{ - switch (p->sample_type) { - case AVS_SAMPLE_INT8: return sizeof(signed char); - case AVS_SAMPLE_INT16: return sizeof(signed short); - case AVS_SAMPLE_INT24: return 3; - case AVS_SAMPLE_INT32: return sizeof(signed int); - case AVS_SAMPLE_FLOAT: return sizeof(float); - default: return 0; - } -} - -AVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo * p) - { return p->nchannels*avs_bytes_per_channel_sample(p);} - -AVSC_INLINE INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames) - { return ((INT64)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); } - -AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples) - { return (int)(samples * (INT64)p->fps_numerator / (INT64)p->fps_denominator / (INT64)p->audio_samples_per_second); } - -AVSC_INLINE INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes) - { return bytes / avs_bytes_per_audio_sample(p); } - -AVSC_INLINE INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples) - { return samples * avs_bytes_per_audio_sample(p); } - -AVSC_INLINE int avs_audio_channels(const AVS_VideoInfo * p) - { return p->nchannels; } - -AVSC_INLINE int avs_sample_type(const AVS_VideoInfo * p) - { return p->sample_type;} - -// useful mutator -AVSC_INLINE void avs_set_property(AVS_VideoInfo * p, int property) - { p->image_type|=property; } - -AVSC_INLINE void avs_clear_property(AVS_VideoInfo * p, int property) - { p->image_type&=~property; } - -AVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased) - { if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; } - -AVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator) -{ - unsigned x=numerator, y=denominator; - while (y) { // find gcd - unsigned t = x%y; x = y; y = t; - } - p->fps_numerator = numerator/x; - p->fps_denominator = denominator/x; -} - -#ifndef AVSC_NO_DECLSPEC -// this inline function is calling an API function -AVSC_INLINE int avs_is_same_colorspace(const AVS_VideoInfo * x, const AVS_VideoInfo * y) -{ - return (x->pixel_type == y->pixel_type) - || (avs_is_yv12(x) && avs_is_yv12(y)); -} -#endif - -// Avisynth+ extensions -AVSC_API(int, avs_is_rgb48)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_is_rgb64)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_is_yuv444p16)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv444 - -AVSC_API(int, avs_is_yuv422p16)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv422 - -AVSC_API(int, avs_is_yuv420p16)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv420 - -AVSC_API(int, avs_is_y16)(const AVS_VideoInfo * p); // obsolete, use avs_is_y - -AVSC_API(int, avs_is_yuv444ps)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv444 - -AVSC_API(int, avs_is_yuv422ps)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv422 - -AVSC_API(int, avs_is_yuv420ps)(const AVS_VideoInfo * p); // obsolete, use avs_is_yuv420 - -AVSC_API(int, avs_is_y32)(const AVS_VideoInfo * p); // obsolete, use avs_is_y - -AVSC_API(int, avs_is_444)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_is_422)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_is_420)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_is_y)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_is_yuva)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_is_planar_rgb)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_is_planar_rgba)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_num_components)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_component_size)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_bits_per_component)(const AVS_VideoInfo * p); -// end of Avisynth+ specific - -///////////////////////////////////////////////////////////////////// -// -// AVS_VideoFrame -// - -// VideoFrameBuffer holds information about a memory block which is used -// for video data. For efficiency, instances of this class are not deleted -// when the refcount reaches zero; instead they're stored in a linked list -// to be reused. The instances are deleted when the corresponding AVS -// file is closed. - -// AVS_VideoFrameBuffer is laid out identically to VideoFrameBuffer -// DO NOT USE THIS STRUCTURE DIRECTLY -typedef struct AVS_VideoFrameBuffer { - BYTE * data; -#ifdef SIZETMOD - size_t data_size; -#else - int data_size; -#endif - // sequence_number is incremented every time the buffer is changed, so - // that stale views can tell they're no longer valid. - volatile long sequence_number; - - volatile long refcount; -} AVS_VideoFrameBuffer; - -// VideoFrame holds a "window" into a VideoFrameBuffer. - -// AVS_VideoFrame is laid out identically to IVideoFrame -// DO NOT USE THIS STRUCTURE DIRECTLY -typedef struct AVS_VideoFrame { - volatile long refcount; - AVS_VideoFrameBuffer * vfb; -#ifdef SIZETMOD - size_t offset; -#else - int offset; -#endif - int pitch, row_size, height; -#ifdef SIZETMOD - size_t offsetU, offsetV; -#else - int offsetU, offsetV; -#endif - int pitchUV; // U&V offsets are from top of picture. - int row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane. - // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable) - // the decision on existence of UV is checked by zero pitch - // AVS+ extension, avisynth.h: class does not break plugins if appended here -#ifdef SIZETMOD - size_t offsetA; -#else - int offsetA; -#endif - int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none -} AVS_VideoFrame; - -// Access functions for AVS_VideoFrame -AVSC_API(int, avs_get_pitch_p)(const AVS_VideoFrame * p, int plane); - -AVSC_API(int, avs_get_row_size_p)(const AVS_VideoFrame * p, int plane); - -AVSC_API(int, avs_get_height_p)(const AVS_VideoFrame * p, int plane); - -AVSC_API(const BYTE *, avs_get_read_ptr_p)(const AVS_VideoFrame * p, int plane); - -AVSC_API(int, avs_is_writable)(const AVS_VideoFrame * p); - -AVSC_API(BYTE *, avs_get_write_ptr_p)(const AVS_VideoFrame * p, int plane); - -AVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *); -// makes a shallow copy of a video frame -AVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *); - -// no API for these, inline helper functions -#ifndef AVSC_NO_DECLSPEC -// this inline function is calling an API function -AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) { - return avs_get_pitch_p(p, 0); -} -#endif - -#ifndef AVSC_NO_DECLSPEC -// this inline function is calling an API function -AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) { - return avs_get_row_size_p(p, 0); } -#endif - - -#ifndef AVSC_NO_DECLSPEC -// this inline function is calling an API function -AVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) { - return avs_get_height_p(p, 0); -} -#endif - -#ifndef AVSC_NO_DECLSPEC -// this inline function is calling an API function -AVSC_INLINE const BYTE* avs_get_read_ptr(const AVS_VideoFrame * p) { - return avs_get_read_ptr_p(p, 0);} -#endif - -#ifndef AVSC_NO_DECLSPEC -// this inline function is calling an API function -AVSC_INLINE BYTE* avs_get_write_ptr(const AVS_VideoFrame * p) { - return avs_get_write_ptr_p(p, 0);} -#endif - -#ifndef AVSC_NO_DECLSPEC -// this inline function is calling an API function -AVSC_INLINE void avs_release_frame(AVS_VideoFrame * f) - {avs_release_video_frame(f);} -#endif - -#ifndef AVSC_NO_DECLSPEC -// this inline function is calling an API function -AVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame * f) - {return avs_copy_video_frame(f);} -#endif - -///////////////////////////////////////////////////////////////////// -// -// AVS_Value -// - -// Treat AVS_Value as a fat pointer. That is use avs_copy_value -// and avs_release_value appropriately as you would if AVS_Value was -// a pointer. - -// To maintain source code compatibility with future versions of the -// avisynth_c API don't use the AVS_Value directly. Use the helper -// functions below. - -// AVS_Value is laid out identically to AVSValue -typedef struct AVS_Value AVS_Value; -struct AVS_Value { - short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong - // for some function e'rror - short array_size; - union { - void * clip; // do not use directly, use avs_take_clip - char boolean; - int integer; - float floating_pt; - const char * string; - const AVS_Value * array; - } d; -}; - -// AVS_Value should be initialized with avs_void. -// Should also set to avs_void after the value is released -// with avs_copy_value. Consider it the equivalent of setting -// a pointer to NULL -static const AVS_Value avs_void = {'v'}; - -AVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src); -AVSC_API(void, avs_release_value)(AVS_Value); -AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *); -AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *); - - -// no API for these, inline helper functions -AVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; } -AVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; } -AVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; } -AVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i'; } -AVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'f' || v.type == 'i'; } -AVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; } -AVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; } -AVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; } - -AVSC_INLINE int avs_as_bool(AVS_Value v) - { return v.d.boolean; } -AVSC_INLINE int avs_as_int(AVS_Value v) - { return v.d.integer; } -AVSC_INLINE const char * avs_as_string(AVS_Value v) - { return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; } -AVSC_INLINE double avs_as_float(AVS_Value v) - { return avs_is_int(v) ? v.d.integer : v.d.floating_pt; } -AVSC_INLINE const char * avs_as_error(AVS_Value v) - { return avs_is_error(v) ? v.d.string : 0; } -AVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v) - { return v.d.array; } -AVSC_INLINE int avs_array_size(AVS_Value v) - { return avs_is_array(v) ? v.array_size : 1; } -AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index) - { return avs_is_array(v) ? v.d.array[index] : v; } - -// only use these functions on an AVS_Value that does not already have -// an active value. Remember, treat AVS_Value as a fat pointer. -AVSC_INLINE AVS_Value avs_new_value_bool(int v0) - { AVS_Value v; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; } -AVSC_INLINE AVS_Value avs_new_value_int(int v0) - { AVS_Value v; v.type = 'i'; v.d.integer = v0; return v; } -AVSC_INLINE AVS_Value avs_new_value_string(const char * v0) - { AVS_Value v; v.type = 's'; v.d.string = v0; return v; } -AVSC_INLINE AVS_Value avs_new_value_float(float v0) - { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;} -AVSC_INLINE AVS_Value avs_new_value_error(const char * v0) - { AVS_Value v; v.type = 'e'; v.d.string = v0; return v; } -#ifndef AVSC_NO_DECLSPEC -// this inline function is calling an API function -AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0) - { AVS_Value v; avs_set_to_clip(&v, v0); return v; } -#endif -AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size) - { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = (short)size; return v; } -// end of inline helper functions - -///////////////////////////////////////////////////////////////////// -// -// AVS_Clip -// - -AVSC_API(void, avs_release_clip)(AVS_Clip *); -AVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *); - -AVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error - -AVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *); - -AVSC_API(int, avs_get_version)(AVS_Clip *); - -AVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n); -// The returned video frame must be released with avs_release_video_frame - -AVSC_API(int, avs_get_parity)(AVS_Clip *, int n); -// return field parity if field_based, else parity of first field in frame - -AVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf, - INT64 start, INT64 count); -// start and count are in samples - -AVSC_API(int, avs_set_cache_hints)(AVS_Clip *, - int cachehints, int frame_range); - -// This is the callback type used by avs_add_function -typedef AVS_Value (AVSC_CC * AVS_ApplyFunc) - (AVS_ScriptEnvironment *, AVS_Value args, void * user_data); - -typedef struct AVS_FilterInfo AVS_FilterInfo; -struct AVS_FilterInfo -{ - // these members should not be modified outside of the AVS_ApplyFunc callback - AVS_Clip * child; - AVS_VideoInfo vi; - AVS_ScriptEnvironment * env; - AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n); - int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n); - int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf, - INT64 start, INT64 count); - int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints, - int frame_range); - void (AVSC_CC * free_filter)(AVS_FilterInfo *); - - // Should be set when ever there is an error to report. - // It is cleared before any of the above methods are called - const char * error; - // this is to store whatever and may be modified at will - void * user_data; -}; - -// Create a new filter -// fi is set to point to the AVS_FilterInfo so that you can -// modify it once it is initialized. -// store_child should generally be set to true. If it is not -// set than ALL methods (the function pointers) must be defined -// If it is set than you do not need to worry about freeing the child -// clip. -AVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e, - AVS_FilterInfo * * fi, - AVS_Value child, int store_child); - -///////////////////////////////////////////////////////////////////// -// -// AVS_ScriptEnvironment -// - -// For GetCPUFlags. These are backwards-compatible with those in VirtualDub. -enum { - /* slowest CPU to support extension */ - AVS_CPU_FORCE = 0x01, // N/A - AVS_CPU_FPU = 0x02, // 386/486DX - AVS_CPU_MMX = 0x04, // P55C, K6, PII - AVS_CPU_INTEGER_SSE = 0x08, // PIII, Athlon - AVS_CPU_SSE = 0x10, // PIII, Athlon XP/MP - AVS_CPU_SSE2 = 0x20, // PIV, Hammer - AVS_CPU_3DNOW = 0x40, // K6-2 - AVS_CPU_3DNOW_EXT = 0x80, // Athlon - AVS_CPU_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2, - // which only Hammer will have anyway) - AVS_CPUF_SSE3 = 0x100, // PIV+, K8 Venice - AVS_CPUF_SSSE3 = 0x200, // Core 2 - AVS_CPUF_SSE4 = 0x400, // Penryn, Wolfdale, Yorkfield - AVS_CPUF_SSE4_1 = 0x400, - AVS_CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer - AVS_CPUF_SSE4_2 = 0x1000, // Nehalem - // AVS+ - AVS_CPUF_AVX2 = 0x2000, // Haswell - AVS_CPUF_FMA3 = 0x4000, - AVS_CPUF_F16C = 0x8000, - AVS_CPUF_MOVBE = 0x10000, // Big Endian Move - AVS_CPUF_POPCNT = 0x20000, - AVS_CPUF_AES = 0x40000, - AVS_CPUF_FMA4 = 0x80000, - - AVS_CPUF_AVX512F = 0x100000, // AVX-512 Foundation. - AVS_CPUF_AVX512DQ = 0x200000, // AVX-512 DQ (Double/Quad granular) Instructions - AVS_CPUF_AVX512PF = 0x400000, // AVX-512 Prefetch - AVS_CPUF_AVX512ER = 0x800000, // AVX-512 Exponential and Reciprocal - AVS_CPUF_AVX512CD = 0x1000000, // AVX-512 Conflict Detection - AVS_CPUF_AVX512BW = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions - AVS_CPUF_AVX512VL = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions - AVS_CPUF_AVX512IFMA = 0x8000000, // AVX-512 IFMA integer 52 bit - AVS_CPUF_AVX512VBMI = 0x10000000 // AVX-512 VBMI -}; - - -AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error - -AVSC_API(int, avs_get_cpu_flags)(AVS_ScriptEnvironment *); -AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version); - -AVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length); -AVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...); - -AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, void* val); - // note: val is really a va_list; I hope everyone typedefs va_list to a pointer - -AVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *, - const char * name, const char * params, - AVS_ApplyFunc apply, void * user_data); - -AVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name); - -AVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name, - AVS_Value args, const char** arg_names); -// The returned value must be be released with avs_release_value - -AVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name); -// The returned value must be be released with avs_release_value - -AVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val); - -AVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val); - -//void avs_push_context(AVS_ScriptEnvironment *, int level=0); -//void avs_pop_context(AVS_ScriptEnvironment *); - -AVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *, - const AVS_VideoInfo * vi, int align); -// align should be at least 16 for classic Avisynth -// Avisynth+: any value, Avs+ ensures a minimum alignment if too small align is provided - -// no API for these, inline helper functions -#ifndef AVSC_NO_DECLSPEC -// this inline function is calling an API function -AVSC_INLINE AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env, - const AVS_VideoInfo * vi) - {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);} - -// an older compatibility alias -// this inline function is calling an API function -AVSC_INLINE AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env, - const AVS_VideoInfo * vi) - {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);} -#endif -// end of inline helper functions - -AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf); - -AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height); - -typedef void (AVSC_CC *AVS_ShutdownFunc)(void* user_data, AVS_ScriptEnvironment * env); -AVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data); - -AVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height); -// The returned video frame must be be released - -AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem); - -AVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir); - -// avisynth.dll exports this; it's a way to use it as a library, without -// writing an AVS script or without going through AVIFile. -AVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version); - -// this symbol is the entry point for the plugin and must -// be defined -AVSC_EXPORT -const char * AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env); - - -AVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *); - - -AVSC_API(AVS_VideoFrame *, avs_subframe_planar)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV); -// The returned video frame must be be released - -#ifdef AVSC_NO_DECLSPEC -// This part uses LoadLibrary and related functions to dynamically load Avisynth instead of declspec(dllimport) -// When AVSC_NO_DECLSPEC is defined, you can use avs_load_library to populate API functions into a struct -// AVSC_INLINE functions which call onto an API functions should be treated specially (todo) - -/* - The following functions needs to have been declared, probably from windows.h - - void* malloc(size_t) - void free(void*); - - HMODULE LoadLibrary(const char*); - void* GetProcAddress(HMODULE, const char*); - FreeLibrary(HMODULE); -*/ - - -typedef struct AVS_Library AVS_Library; - -#define AVSC_DECLARE_FUNC(name) name##_func name - -// AVSC_DECLARE_FUNC helps keeping naming convention: type is xxxxx_func, function name is xxxxx -// e.g. "AVSC_DECLARE_FUNC(avs_add_function);" -// is a shortcut for "avs_add_function_func avs_add_function;" - -// Note: AVSC_INLINE functions which call into API, -// are guarded by #ifndef AVSC_NO_DECLSPEC -// They should call the appropriate library-> API entry - -struct AVS_Library { - HMODULE handle; - - AVSC_DECLARE_FUNC(avs_add_function); - AVSC_DECLARE_FUNC(avs_at_exit); - AVSC_DECLARE_FUNC(avs_bit_blt); - AVSC_DECLARE_FUNC(avs_check_version); - AVSC_DECLARE_FUNC(avs_clip_get_error); - AVSC_DECLARE_FUNC(avs_copy_clip); - AVSC_DECLARE_FUNC(avs_copy_value); - AVSC_DECLARE_FUNC(avs_copy_video_frame); - AVSC_DECLARE_FUNC(avs_create_script_environment); - AVSC_DECLARE_FUNC(avs_delete_script_environment); - AVSC_DECLARE_FUNC(avs_function_exists); - AVSC_DECLARE_FUNC(avs_get_audio); - AVSC_DECLARE_FUNC(avs_get_cpu_flags); - AVSC_DECLARE_FUNC(avs_get_frame); - AVSC_DECLARE_FUNC(avs_get_parity); - AVSC_DECLARE_FUNC(avs_get_var); - AVSC_DECLARE_FUNC(avs_get_version); - AVSC_DECLARE_FUNC(avs_get_video_info); - AVSC_DECLARE_FUNC(avs_invoke); - AVSC_DECLARE_FUNC(avs_make_writable); - AVSC_DECLARE_FUNC(avs_new_c_filter); - AVSC_DECLARE_FUNC(avs_new_video_frame_a); - AVSC_DECLARE_FUNC(avs_release_clip); - AVSC_DECLARE_FUNC(avs_release_value); - AVSC_DECLARE_FUNC(avs_release_video_frame); - AVSC_DECLARE_FUNC(avs_save_string); - AVSC_DECLARE_FUNC(avs_set_cache_hints); - AVSC_DECLARE_FUNC(avs_set_global_var); - AVSC_DECLARE_FUNC(avs_set_memory_max); - AVSC_DECLARE_FUNC(avs_set_to_clip); - AVSC_DECLARE_FUNC(avs_set_var); - AVSC_DECLARE_FUNC(avs_set_working_dir); - AVSC_DECLARE_FUNC(avs_sprintf); - AVSC_DECLARE_FUNC(avs_subframe); - AVSC_DECLARE_FUNC(avs_subframe_planar); - AVSC_DECLARE_FUNC(avs_take_clip); - AVSC_DECLARE_FUNC(avs_vsprintf); - - AVSC_DECLARE_FUNC(avs_get_error); - AVSC_DECLARE_FUNC(avs_is_yv24); - AVSC_DECLARE_FUNC(avs_is_yv16); - AVSC_DECLARE_FUNC(avs_is_yv12); - AVSC_DECLARE_FUNC(avs_is_yv411); - AVSC_DECLARE_FUNC(avs_is_y8); - AVSC_DECLARE_FUNC(avs_is_color_space); - - AVSC_DECLARE_FUNC(avs_get_plane_width_subsampling); - AVSC_DECLARE_FUNC(avs_get_plane_height_subsampling); - AVSC_DECLARE_FUNC(avs_bits_per_pixel); - AVSC_DECLARE_FUNC(avs_bytes_from_pixels); - AVSC_DECLARE_FUNC(avs_row_size); - AVSC_DECLARE_FUNC(avs_bmp_size); - AVSC_DECLARE_FUNC(avs_get_pitch_p); - AVSC_DECLARE_FUNC(avs_get_row_size_p); - AVSC_DECLARE_FUNC(avs_get_height_p); - AVSC_DECLARE_FUNC(avs_get_read_ptr_p); - AVSC_DECLARE_FUNC(avs_is_writable); - AVSC_DECLARE_FUNC(avs_get_write_ptr_p); - - // Avisynth+ specific - // Note: these functions are simulated/use fallback to existing functions - AVSC_DECLARE_FUNC(avs_is_rgb48); - AVSC_DECLARE_FUNC(avs_is_rgb64); - AVSC_DECLARE_FUNC(avs_is_yuv444p16); - AVSC_DECLARE_FUNC(avs_is_yuv422p16); - AVSC_DECLARE_FUNC(avs_is_yuv420p16); - AVSC_DECLARE_FUNC(avs_is_y16); - AVSC_DECLARE_FUNC(avs_is_yuv444ps); - AVSC_DECLARE_FUNC(avs_is_yuv422ps); - AVSC_DECLARE_FUNC(avs_is_yuv420ps); - AVSC_DECLARE_FUNC(avs_is_y32); - AVSC_DECLARE_FUNC(avs_is_444); - AVSC_DECLARE_FUNC(avs_is_422); - AVSC_DECLARE_FUNC(avs_is_420); - AVSC_DECLARE_FUNC(avs_is_y); - AVSC_DECLARE_FUNC(avs_is_yuva); - AVSC_DECLARE_FUNC(avs_is_planar_rgb); - AVSC_DECLARE_FUNC(avs_is_planar_rgba); - AVSC_DECLARE_FUNC(avs_num_components); - AVSC_DECLARE_FUNC(avs_component_size); - AVSC_DECLARE_FUNC(avs_bits_per_component); - // end of Avisynth+ specific - -}; - -#undef AVSC_DECLARE_FUNC - -// Helper functions for fallback simulation -// Avisynth+ extensions do not exist in classic Avisynth so they are simulated -AVSC_INLINE int avs_is_xx_fallback_return_false(const AVS_VideoInfo * p) -{ - return 0; -} - -// Avisynth+ extensions do not exist in classic Avisynth so they are simulated -AVSC_INLINE int avs_num_components_fallback(const AVS_VideoInfo * p) -{ - switch (p->pixel_type) { - case AVS_CS_UNKNOWN: - return 0; - case AVS_CS_RAW32: - case AVS_CS_Y8: - return 1; - case AVS_CS_BGR32: - return 4; // not planar but return the count - default: - return 3; - } -} - -// Avisynth+ extensions do not exist in classic Avisynth so they are simulated -AVSC_INLINE int avs_component_size_fallback(const AVS_VideoInfo * p) -{ - return 1; -} - -// Avisynth+ extensions do not exist in classic Avisynth so they are simulated -AVSC_INLINE int avs_bits_per_component_fallback(const AVS_VideoInfo * p) -{ - return 8; -} -// End of helper functions for fallback simulation - -// avs_load_library() allocates an array for API procedure entries -// reads and fills the entries with live procedure addresses. -// AVSC_INLINE helpers which are calling into API procedures are not treated here (todo) - -AVSC_INLINE AVS_Library * avs_load_library() { - AVS_Library *library = (AVS_Library *)malloc(sizeof(AVS_Library)); - if (library == NULL) - return NULL; - library->handle = LoadLibrary("avisynth"); - if (library->handle == NULL) - goto fail; - -#define __AVSC_STRINGIFY(x) #x -#define AVSC_STRINGIFY(x) __AVSC_STRINGIFY(x) -#define AVSC_LOAD_FUNC(name) {\ - library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\ - if (library->name == NULL)\ - goto fail;\ -} - -// When an API function is not loadable, let's try a replacement -// Missing Avisynth+ functions will be substituted with classic Avisynth compatible methods -/* -Avisynth+ When method is missing (classic Avisynth) -avs_is_rgb48 constant false -avs_is_rgb64 constant false -avs_is_yuv444p16 constant false -avs_is_yuv422p16 constant false -avs_is_yuv420p16 constant false -avs_is_y16 constant false -avs_is_yuv444ps constant false -avs_is_yuv422ps constant false -avs_is_yuv420ps constant false -avs_is_y32 constant false -avs_is_444 avs_is_yv24 -avs_is_422 avs_is_yv16 -avs_is_420 avs_is_yv12 -avs_is_y avs_is_y8 -avs_is_yuva constant false -avs_is_planar_rgb constant false -avs_is_planar_rgba constant false -avs_num_components special: avs_num_components_fake Y8:1 RGB32:4 else 3 -avs_component_size constant 1 (1 bytes/component) -avs_bits_per_component constant 8 (8 bits/component) -*/ - - // try to load an alternative function -#define AVSC_LOAD_FUNC_FALLBACK(name,name2) {\ - library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\ - if (library->name == NULL)\ - library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name2));\ - if (library->name == NULL)\ - goto fail;\ -} - - // try to assign a replacement function -#define AVSC_LOAD_FUNC_FALLBACK_SIMULATED(name,name2) {\ - library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\ - if (library->name == NULL)\ - library->name = name2;\ - if (library->name == NULL)\ - goto fail;\ -} - - AVSC_LOAD_FUNC(avs_add_function); - AVSC_LOAD_FUNC(avs_at_exit); - AVSC_LOAD_FUNC(avs_bit_blt); - AVSC_LOAD_FUNC(avs_check_version); - AVSC_LOAD_FUNC(avs_clip_get_error); - AVSC_LOAD_FUNC(avs_copy_clip); - AVSC_LOAD_FUNC(avs_copy_value); - AVSC_LOAD_FUNC(avs_copy_video_frame); - AVSC_LOAD_FUNC(avs_create_script_environment); - AVSC_LOAD_FUNC(avs_delete_script_environment); - AVSC_LOAD_FUNC(avs_function_exists); - AVSC_LOAD_FUNC(avs_get_audio); - AVSC_LOAD_FUNC(avs_get_cpu_flags); - AVSC_LOAD_FUNC(avs_get_frame); - AVSC_LOAD_FUNC(avs_get_parity); - AVSC_LOAD_FUNC(avs_get_var); - AVSC_LOAD_FUNC(avs_get_version); - AVSC_LOAD_FUNC(avs_get_video_info); - AVSC_LOAD_FUNC(avs_invoke); - AVSC_LOAD_FUNC(avs_make_writable); - AVSC_LOAD_FUNC(avs_new_c_filter); - AVSC_LOAD_FUNC(avs_new_video_frame_a); - AVSC_LOAD_FUNC(avs_release_clip); - AVSC_LOAD_FUNC(avs_release_value); - AVSC_LOAD_FUNC(avs_release_video_frame); - AVSC_LOAD_FUNC(avs_save_string); - AVSC_LOAD_FUNC(avs_set_cache_hints); - AVSC_LOAD_FUNC(avs_set_global_var); - AVSC_LOAD_FUNC(avs_set_memory_max); - AVSC_LOAD_FUNC(avs_set_to_clip); - AVSC_LOAD_FUNC(avs_set_var); - AVSC_LOAD_FUNC(avs_set_working_dir); - AVSC_LOAD_FUNC(avs_sprintf); - AVSC_LOAD_FUNC(avs_subframe); - AVSC_LOAD_FUNC(avs_subframe_planar); - AVSC_LOAD_FUNC(avs_take_clip); - AVSC_LOAD_FUNC(avs_vsprintf); - - AVSC_LOAD_FUNC(avs_get_error); - AVSC_LOAD_FUNC(avs_is_yv24); - AVSC_LOAD_FUNC(avs_is_yv16); - AVSC_LOAD_FUNC(avs_is_yv12); - AVSC_LOAD_FUNC(avs_is_yv411); - AVSC_LOAD_FUNC(avs_is_y8); - AVSC_LOAD_FUNC(avs_is_color_space); - - AVSC_LOAD_FUNC(avs_get_plane_width_subsampling); - AVSC_LOAD_FUNC(avs_get_plane_height_subsampling); - AVSC_LOAD_FUNC(avs_bits_per_pixel); - AVSC_LOAD_FUNC(avs_bytes_from_pixels); - AVSC_LOAD_FUNC(avs_row_size); - AVSC_LOAD_FUNC(avs_bmp_size); - AVSC_LOAD_FUNC(avs_get_pitch_p); - AVSC_LOAD_FUNC(avs_get_row_size_p); - AVSC_LOAD_FUNC(avs_get_height_p); - AVSC_LOAD_FUNC(avs_get_read_ptr_p); - AVSC_LOAD_FUNC(avs_is_writable); - AVSC_LOAD_FUNC(avs_get_write_ptr_p); - - // Avisynth+ specific but made them callable for classic Avisynth hosts - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb48, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb64, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv444p16, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv422p16, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv420p16, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_y16, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv444ps, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv422ps, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuv420ps, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_y32, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK(avs_is_444, avs_is_yv24); - AVSC_LOAD_FUNC_FALLBACK(avs_is_422, avs_is_yv16); - AVSC_LOAD_FUNC_FALLBACK(avs_is_420, avs_is_yv12); - AVSC_LOAD_FUNC_FALLBACK(avs_is_y, avs_is_y8); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuva, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgb, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgba, avs_is_xx_fallback_return_false); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_num_components, avs_num_components_fallback); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_component_size, avs_component_size_fallback); - AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_bits_per_component, avs_bits_per_component_fallback); - -#undef __AVSC_STRINGIFY -#undef AVSC_STRINGIFY -#undef AVSC_LOAD_FUNC -#undef AVSC_LOAD_FUNC_FALLBACK -#undef AVSC_LOAD_FUNC_FALLBACK_SIMULATED - - return library; - -fail: - free(library); - return NULL; -} - -AVSC_INLINE void avs_free_library(AVS_Library *library) { - if (library == NULL) - return; - FreeLibrary(library->handle); - free(library); -} -#endif - -#endif diff --git a/FrameServer/avisynth_headers/alignment.h b/FrameServer/avs/alignment.h similarity index 99% rename from FrameServer/avisynth_headers/alignment.h rename to FrameServer/avs/alignment.h index 3775aa18..170d9cc1 100644 --- a/FrameServer/avisynth_headers/alignment.h +++ b/FrameServer/avs/alignment.h @@ -52,7 +52,7 @@ #include #include #include -#include +#include "config.h" #if defined(MSVC) && _MSC_VER<1400 // needed for VS2013, otherwise C++11 'alignas' works diff --git a/FrameServer/avisynth_headers/capi.h b/FrameServer/avs/capi.h similarity index 92% rename from FrameServer/avisynth_headers/capi.h rename to FrameServer/avs/capi.h index 8799bf1f..4e31a5de 100644 --- a/FrameServer/avisynth_headers/capi.h +++ b/FrameServer/avs/capi.h @@ -33,12 +33,20 @@ #ifndef AVS_CAPI_H #define AVS_CAPI_H +#include "config.h" + +#ifdef AVS_POSIX +// this is also defined in avs/posix.h +#define __declspec(x) +#endif + #ifdef __cplusplus # define EXTERN_C extern "C" #else # define EXTERN_C #endif +#ifdef AVS_WINDOWS #ifdef BUILDING_AVSCORE # if defined(GCC) && defined(X86_32) # define AVSC_CC @@ -60,6 +68,9 @@ # define AVSC_CC # endif #endif +# else +# define AVSC_CC +#endif // On 64-bit Windows, there's only one calling convention, // so there is no difference between MSVC and GCC. On 32-bit, @@ -80,9 +91,14 @@ #define AVSC_INLINE static __inline #ifdef BUILDING_AVSCORE +#ifdef AVS_WINDOWS # define AVSC_EXPORT __declspec(dllexport) # define AVSC_API(ret, name) EXTERN_C AVSC_EXPORT ret AVSC_CC name #else +# define AVSC_EXPORT EXTERN_C +# define AVSC_API(ret, name) EXTERN_C ret AVSC_CC name +#endif +#else # define AVSC_EXPORT EXTERN_C __declspec(dllexport) # ifndef AVSC_NO_DECLSPEC # define AVSC_API(ret, name) EXTERN_C __declspec(dllimport) ret AVSC_CC name diff --git a/FrameServer/avisynth_headers/config.h b/FrameServer/avs/config.h similarity index 60% rename from FrameServer/avisynth_headers/config.h rename to FrameServer/avs/config.h index 84ae9880..e91caad6 100644 --- a/FrameServer/avisynth_headers/config.h +++ b/FrameServer/avs/config.h @@ -48,22 +48,31 @@ # define X86_64 #elif defined(_M_IX86) || defined(__i386__) # define X86_32 +// VS2017 introduced _M_ARM64 +#elif defined(_M_ARM64) || defined(__aarch64__) +# define ARM64 +#elif defined(_M_ARM) || defined(__arm__) +# define ARM32 #else # error Unsupported CPU architecture. #endif // VC++ LLVM-Clang-cl MinGW-Gnu -// MSVC x x +// MSVC x x // MSVC_PURE x -// CLANG x +// CLANG x // GCC x #if defined(__clang__) // Check clang first. clang-cl also defines __MSC_VER // We set MSVC because they are mostly compatible -# define MSVC # define CLANG +#if defined(_MSC_VER) +# define MSVC # define AVS_FORCEINLINE __attribute__((always_inline)) +#else +# define AVS_FORCEINLINE __attribute__((always_inline)) inline +#endif #elif defined(_MSC_VER) # define MSVC # define MSVC_PURE @@ -78,4 +87,55 @@ # define __forceinline inline #endif +#if defined(_WIN32) +# define AVS_WINDOWS +#elif defined(__linux__) +# define AVS_LINUX +# define AVS_POSIX +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) +# define AVS_BSD +# define AVS_POSIX +#elif defined(__APPLE__) +# define AVS_MACOS +# define AVS_POSIX +#else +# error Operating system unsupported. +#endif + +// useful warnings disabler macros for supported compilers + +#if defined(_MSC_VER) +#define DISABLE_WARNING_PUSH __pragma(warning( push )) +#define DISABLE_WARNING_POP __pragma(warning( pop )) +#define DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber )) + +#define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE DISABLE_WARNING(4101) +#define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(4505) +// other warnings you want to deactivate... + +#elif defined(__GNUC__) || defined(__clang__) +#define DO_PRAGMA(X) _Pragma(#X) +#define DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push) +#define DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop) +#define DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored #warningName) + +#define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE DISABLE_WARNING(-Wunused-variable) +#define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(-Wunused-function) +// other warnings you want to deactivate... + +#else +#define DISABLE_WARNING_PUSH +#define DISABLE_WARNING_POP +#define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE +#define DISABLE_WARNING_UNREFERENCED_FUNCTION +// other warnings you want to deactivate... + +#endif + +#if defined(AVS_POSIX) +#define NEW_AVSVALUE +#else +#define NEW_AVSVALUE +#endif + #endif //AVS_CONFIG_H diff --git a/FrameServer/avisynth_headers/cpuid.h b/FrameServer/avs/cpuid.h similarity index 97% rename from FrameServer/avisynth_headers/cpuid.h rename to FrameServer/avs/cpuid.h index b6354442..024e8437 100644 --- a/FrameServer/avisynth_headers/cpuid.h +++ b/FrameServer/avs/cpuid.h @@ -50,7 +50,7 @@ enum { CPUF_SSE3 = 0x100, // PIV+, K8 Venice CPUF_SSSE3 = 0x200, // Core 2 CPUF_SSE4 = 0x400, - CPUF_SSE4_1 = 0x400, // Penryn, Wolfdale, Yorkfield + CPUF_SSE4_1 = 0x400, // Penryn, Wolfdale, Yorkfield CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer CPUF_SSE4_2 = 0x1000, // Nehalem // AVS+ @@ -75,6 +75,7 @@ enum { #ifdef BUILDING_AVSCORE int GetCPUFlags(); +void SetMaxCPU(int new_flags); #endif #endif // AVSCORE_CPUID_H diff --git a/FrameServer/avisynth_headers/minmax.h b/FrameServer/avs/minmax.h similarity index 100% rename from FrameServer/avisynth_headers/minmax.h rename to FrameServer/avs/minmax.h diff --git a/FrameServer/avs/posix.h b/FrameServer/avs/posix.h new file mode 100644 index 00000000..9c938b26 --- /dev/null +++ b/FrameServer/avs/posix.h @@ -0,0 +1,111 @@ +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit +// http://www.gnu.org/copyleft/gpl.html . +// +// Linking Avisynth statically or dynamically with other modules is making a +// combined work based on Avisynth. Thus, the terms and conditions of the GNU +// General Public License cover the whole combination. +// +// As a special exception, the copyright holders of Avisynth give you +// permission to link Avisynth with independent modules that communicate with +// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license +// terms of these independent modules, and to copy and distribute the +// resulting combined work under terms of your choice, provided that +// every copy of the combined work is accompanied by a complete copy of +// the source code of Avisynth (the version of Avisynth used to produce the +// combined work), being distributed under the terms of the GNU General +// Public License plus this exception. An independent module is a module +// which is not derived from or based on Avisynth, such as 3rd-party filters, +// import and export plugins, or graphical user interfaces. + +#ifdef AVS_POSIX +#ifndef AVSCORE_POSIX_H +#define AVSCORE_POSIX_H + +#ifdef __cplusplus +#include +#endif +#include +#include + +// Define these MSVC-extension used in Avisynth +#define __single_inheritance + +// These things don't exist in Linux +#define __declspec(x) +#define lstrlen strlen +#define lstrcmp strcmp +#define lstrcmpi strcasecmp +#define _stricmp strcasecmp +#define _strnicmp strncasecmp +#define _strdup strdup +#define SetCurrentDirectory(x) chdir(x) +#define SetCurrentDirectoryW(x) chdir(x) +#define GetCurrentDirectoryW(x) getcwd(x) +#define _putenv putenv +#define _alloca alloca + +// Borrowing some compatibility macros from AvxSynth, slightly modified +#define UInt32x32To64(a, b) ((uint64_t)(((uint64_t)((uint32_t)(a))) * ((uint32_t)(b)))) +#define Int64ShrlMod32(a, b) ((uint64_t)((uint64_t)(a) >> (b))) +#define Int32x32To64(a, b) ((int64_t)(((int64_t)((long)(a))) * ((long)(b)))) + +#define InterlockedIncrement(x) __sync_add_and_fetch((x), 1) +#define InterlockedDecrement(x) __sync_sub_and_fetch((x), 1) +#define MulDiv(nNumber, nNumerator, nDenominator) (int32_t) (((int64_t) (nNumber) * (int64_t) (nNumerator) + (int64_t) ((nDenominator)/2)) / (int64_t) (nDenominator)) + +#ifndef TRUE +#define TRUE true +#endif + +#ifndef FALSE +#define FALSE false +#endif + +#define S_FALSE (0x00000001) +#define E_FAIL (0x80004005) +#define FAILED(hr) ((hr) & 0x80000000) +#define SUCCEEDED(hr) (!FAILED(hr)) + +// Statuses copied from comments in exception.cpp +#define STATUS_GUARD_PAGE_VIOLATION 0x80000001 +#define STATUS_DATATYPE_MISALIGNMENT 0x80000002 +#define STATUS_BREAKPOINT 0x80000003 +#define STATUS_SINGLE_STEP 0x80000004 +#define STATUS_ACCESS_VIOLATION 0xc0000005 +#define STATUS_IN_PAGE_ERROR 0xc0000006 +#define STATUS_INVALID_HANDLE 0xc0000008 +#define STATUS_NO_MEMORY 0xc0000017 +#define STATUS_ILLEGAL_INSTRUCTION 0xc000001d +#define STATUS_NONCONTINUABLE_EXCEPTION 0xc0000025 +#define STATUS_INVALID_DISPOSITION 0xc0000026 +#define STATUS_ARRAY_BOUNDS_EXCEEDED 0xc000008c +#define STATUS_FLOAT_DENORMAL_OPERAND 0xc000008d +#define STATUS_FLOAT_DIVIDE_BY_ZERO 0xc000008e +#define STATUS_FLOAT_INEXACT_RESULT 0xc000008f +#define STATUS_FLOAT_INVALID_OPERATION 0xc0000090 +#define STATUS_FLOAT_OVERFLOW 0xc0000091 +#define STATUS_FLOAT_STACK_CHECK 0xc0000092 +#define STATUS_FLOAT_UNDERFLOW 0xc0000093 +#define STATUS_INTEGER_DIVIDE_BY_ZERO 0xc0000094 +#define STATUS_INTEGER_OVERFLOW 0xc0000095 +#define STATUS_PRIVILEGED_INSTRUCTION 0xc0000096 +#define STATUS_STACK_OVERFLOW 0xc00000fd + +// Calling convension +#define __stdcall +#define __cdecl + +#endif // AVSCORE_POSIX_H +#endif // AVS_POSIX diff --git a/FrameServer/avisynth_headers/types.h b/FrameServer/avs/types.h similarity index 93% rename from FrameServer/avisynth_headers/types.h rename to FrameServer/avs/types.h index df15f1d8..19cc455e 100644 --- a/FrameServer/avisynth_headers/types.h +++ b/FrameServer/avs/types.h @@ -34,24 +34,21 @@ #define AVS_TYPES_H // Define all types necessary for interfacing with avisynth.dll - +#include +#include #ifdef __cplusplus #include + #include #else #include + #include #endif // Raster types used by VirtualDub & Avisynth -typedef unsigned int Pixel32; -typedef unsigned char BYTE; +typedef uint32_t Pixel32; +typedef uint8_t BYTE; // Audio Sample information typedef float SFLOAT; -#ifdef __GNUC__ -typedef long long int INT64; -#else -typedef __int64 INT64; -#endif - #endif //AVS_TYPES_H diff --git a/FrameServer/avisynth_headers/win.h b/FrameServer/avs/win.h similarity index 100% rename from FrameServer/avisynth_headers/win.h rename to FrameServer/avs/win.h diff --git a/General/CommandLine.vb b/General/CommandLine.vb index d0455ac5..7abb9539 100644 --- a/General/CommandLine.vb +++ b/General/CommandLine.vb @@ -74,12 +74,12 @@ Namespace CommandLine End Function Sub Execute() - If g.IsWindowsTerminalAvailable AndAlso false Then - Dim cl = "cmd.exe /s /k --% """ + GetCommandLine(True, True) + """" - Dim base64String = Convert.ToBase64String(Encoding.Unicode.GetBytes(cl)) 'UTF16LE - g.Execute("wt.exe", "PowerShell.exe -NoLogo -NoExit -EncodedCommand """ + base64String + """") + If g.IsWindowsTerminalAvailable Then + Dim cl = "cmd.exe /S /K --% """ + GetCommandLine(True, True) + """" + Dim base64 = Convert.ToBase64String(Encoding.Unicode.GetBytes(cl)) 'UTF16LE + g.Execute("wt.exe", "powershell.exe -NoLogo -NoExit -NoProfile -EncodedCommand """ + base64 + """") Else - g.Execute("cmd.exe", "/s /k """ + GetCommandLine(True, True) + """") + g.Execute("cmd.exe", "/S /K """ + GetCommandLine(True, True) + """") End If End Sub End Class diff --git a/General/Documentation.vb b/General/Documentation.vb index 876903a6..8dc950fa 100644 --- a/General/Documentation.vb +++ b/General/Documentation.vb @@ -129,7 +129,7 @@ Public Class Documentation row.Type = pack.GetTypeName row.Filename = pack.Filename - If pack.IsCorrectVersion Then + If pack.IsVersionCorrect Then row.Version = pack.Version End If diff --git a/General/GlobalClass.vb b/General/GlobalClass.vb index c89982e9..de869140 100644 --- a/General/GlobalClass.vb +++ b/General/GlobalClass.vb @@ -46,12 +46,12 @@ Public Class GlobalClass End Function Sub RunCodeInTerminal(code As String) - Dim base64String = Convert.ToBase64String(Encoding.Unicode.GetBytes(code)) 'UTF16LE + Dim base64 = Convert.ToBase64String(Encoding.Unicode.GetBytes(code)) 'UTF16LE If g.IsWindowsTerminalAvailable Then - RunCommandInTerminal("wt.exe", $"powershell.exe -nologo -noexit -EncodedCommand ""{base64String}""") + RunCommandInTerminal("wt.exe", $"powershell.exe -NoLogo -NoExit -NoProfile -EncodedCommand ""{base64}""") Else - RunCommandInTerminal("powershell.exe", $"-nologo -noexit -EncodedCommand ""{base64String}""") + RunCommandInTerminal("powershell.exe", $"-NoLogo -NoExit -NoProfile -EncodedCommand ""{base64}""") End If End Sub @@ -349,7 +349,9 @@ Public Class GlobalClass Function VerifyRequirements() As Boolean For Each pack In Package.Items.Values - If Not pack.VerifyOK Then Return False + If Not pack.VerifyOK Then + Return False + End If Next If Not p.Script.IsFilterActive("Source") Then @@ -784,7 +786,10 @@ Public Class GlobalClass Function IsValidSource(Optional warn As Boolean = True) As Boolean If p.SourceScript.GetFrameCount = 0 Then - If warn Then MsgWarn("Failed to load source.") + If warn Then + MsgWarn("Failed to load source.") + End If + Return False End If diff --git a/General/GlobalCommands.vb b/General/GlobalCommands.vb index d30fd3d9..3ca332ce 100644 --- a/General/GlobalCommands.vb +++ b/General/GlobalCommands.vb @@ -223,10 +223,10 @@ Public Class GlobalCommands If pack.IsIncluded Then If pack.Path = "" Then msg += BR2 + "# path missing for " + pack.Name - ElseIf Not pack.IgnoreVersion Then + ElseIf Not pack.VersionAllowAny Then If pack.Version = "" Then msg += BR2 + "# version missing for " + pack.Name - ElseIf Not pack.IsCorrectVersion Then + ElseIf Not pack.IsVersionValid Then msg += BR2 + "# wrong version for " + pack.Name End If End If diff --git a/General/Package.vb b/General/Package.vb index 3a9d14bb..f0391763 100644 --- a/General/Package.vb +++ b/General/Package.vb @@ -5,7 +5,6 @@ Imports Microsoft.Win32 Public Class Package Implements IComparable(Of Package) - Property AllowOldVersion As Boolean = True Property Description As String Property DownloadURL As String Property Filename As String @@ -15,9 +14,7 @@ Public Class Package Property HelpUrlAviSynth As String Property HelpUrlVapourSynth As String Property HintDirFunc As Func(Of String) - Property IgnoreNewVersion As Boolean Property IgnorePath As String - Property IgnoreVersion As Boolean Property IsGUI As Boolean Property IsIncluded As Boolean = True Property Location As String @@ -28,6 +25,9 @@ Public Class Package Property StatusFunc As Func(Of String) Property TreePath As String Property Version As String + Property VersionAllowAny As Boolean + Property VersionAllowNew As Boolean + Property VersionAllowOld As Boolean = True Property VersionDate As Date Property WebURL As String @@ -143,6 +143,7 @@ Public Class Package .Filename = "AviSynth.dll", .WebURL = "https://github.com/AviSynth/AviSynthPlus", .HelpURL = "http://avisynth.nl", + .DownloadURL = "https://github.com/AviSynth/AviSynthPlus/releases", .Description = "StaxRip supports both AviSynth and VapourSynth as video processing tool.", .Locations = {Folder.System, "FrameServer\AviSynth"}, .RequiredFunc = Function() p.Script.Engine = ScriptEngine.AviSynth}) @@ -288,7 +289,7 @@ Public Class Package .Filename = "mpc-be64.exe", .IsGUI = True, .IsIncluded = False, - .IgnoreVersion = True, + .VersionAllowAny = True, .Required = False, .WebURL = "https://sourceforge.net/projects/mpcbe/", .Description = "DirectShow based media player.", @@ -299,7 +300,7 @@ Public Class Package .Filename = "mpc-hc64.exe", .IsGUI = True, .IsIncluded = False, - .IgnoreVersion = True, + .VersionAllowAny = True, .Required = False, .WebURL = "https://mpc-hc.org/", .Description = "DirectShow based media player.", @@ -690,7 +691,9 @@ Public Class Package Add(New PluginPackage With { .Name = "KNLMeansCL", .Filename = "KNLMeansCL.dll", - .WebURL = "http://github.com/Khanattila/KNLMeansCL", + .WebURL = "https://github.com/pinterf/KNLMeansCL", + .DownloadURL = "https://github.com/pinterf/KNLMeansCL/releases", + .HelpURL = "https://github.com/Khanattila/KNLMeansCL/wiki", .Description = "KNLMeansCL is an optimized pixelwise OpenCL implementation of the Non-local means denoising algorithm. Every pixel is restored by the weighted average of all pixels in its search window. The level of averaging is determined by the filtering parameter h.", .VSFilterNames = {"knlm.KNLMeansCL"}, .AvsFilterNames = {"KNLMeansCL"}, @@ -707,8 +710,9 @@ Public Class Package Add(New PluginPackage With { .Name = "MPEG2DecPlus", - .Filename = "MPEG2DecPlus.dll", - .WebURL = "http://github.com/chikuzen/MPEG2DecPlus", + .Filename = "MPEG2DecPlus64.dll", + .WebURL = "https://github.com/Asd-g/MPEG2DecPlus", + .DownloadURL = "https://github.com/Asd-g/MPEG2DecPlus/releases", .Description = "Source filter to open D2V index files created with DGIndex or D2VWitch.", .AvsFilterNames = {"MPEG2Source"}, .AvsFiltersFunc = Function() {New VideoFilter("Source", "MPEG2Source", "MPEG2Source(""%source_file%"")")}}) @@ -729,7 +733,7 @@ Public Class Package .WebURL = "http://avisynth.nl/index.php/DeBlock", .Location = "Plugins\AVS\Deblock", .AvsFilterNames = {"Deblock"}, - .AvsFiltersFunc = Function() {New VideoFilter("Restoration", "DeBlock | DeBock", "Deblock(quant=25, aOffset=0, bOffset=0, planes=""yuv"")")}}) + .AvsFiltersFunc = Function() {New VideoFilter("Restoration", "DeBlock | DeBock", "Deblock(quant=25, aOffset=0, bOffset=0)")}}) Add(New PluginPackage With { .Name = "VapourSource", @@ -1220,6 +1224,7 @@ Public Class Package .Name = "masktools2", .Filename = "masktools2.dll", .WebURL = "http://github.com/pinterf/masktools", + .DownloadURL = "https://github.com/pinterf/masktools/releases", .Description = "MaskTools2 contain a set of filters designed to create, manipulate and use masks. Masks, in video processing, are a way to give a relative importance to each pixel. You can, for example, create a mask that selects only the green parts of the video, and then replace those parts with another video.", .AvsFilterNames = {"mt_adddiff", "mt_average", "mt_binarize", "mt_circle", "mt_clamp", "mt_convolution", "mt_diamond", "mt_edge", "mt_ellipse", "mt_expand", "mt_hysteresis", "mt_inflate", "mt_inpand", "mt_invert", "mt_logic", "mt_losange", "mt_lut", "mt_lutf", "mt_luts", "mt_lutxy", "mt_makediff", "mt_mappedblur", "mt_merge", "mt_motion", "mt_polish", "mt_rectangle", "mt_square"}}) @@ -1233,12 +1238,21 @@ Public Class Package Add(New PluginPackage With { .Name = "yadifmod2", .Filename = "yadifmod2.dll", - .Description = "Yet Another Deinterlacing Filter mod for Avisynth2.6/Avisynth+", - .WebURL = "http://github.com/chikuzen/yadifmod2", - .HelpURL = "http://github.com/chikuzen/yadifmod2/blob/master/avisynth/readme.md", + .Description = "Yet Another Deinterlacing Filter mod", + .WebURL = "https://github.com/Asd-g/yadifmod2", + .HelpUrlAviSynth = "https://github.com/Asd-g/yadifmod2/blob/master-1/avisynth/readme.md", + .HelpUrlVapourSynth = "https://github.com/Asd-g/yadifmod2/blob/master-1/vapoursynth/readme.md", .AvsFilterNames = {"yadifmod2"}, .AvsFiltersFunc = Function() {New VideoFilter("Field", "yadifmod2", "yadifmod2()")}}) + Add(New PluginPackage With { + .Name = "Yadifmod", + .Filename = "Yadifmod.dll", + .Description = "Modified version of Fizick's avisynth filter port of yadif from mplayer. This version doesn't internally generate spatial predictions, but takes them from an external clip.", + .WebURL = "http://github.com/HomeOfVapourSynthEvolution/VapourSynth-Yadifmod", + .VSFilterNames = {"yadifmod.Yadifmod"}, + .VSFiltersFunc = Function() {New VideoFilter("Field", "Yadifmod", "clip = core.yadifmod.Yadifmod(clip, core.nnedi3.nnedi3(clip, field=0), order=1, field=-1, mode=0)")}}) + Add(New PluginPackage With { .Name = "FixTelecinedFades", .Filename = "libftf_em64t_avx_fma.dll", @@ -1272,14 +1286,6 @@ Public Class Package .WebURL = "http://www.avisynth.nl/users/vcmohan/vcfreq/vcfreq.html", .VSFilterNames = {"vcfreq.F1Quiver", "vcfreq.F2Quiver", "vcfreq.Blur", "vcfreq.Sharp"}}) - Add(New PluginPackage With { - .Name = "Yadifmod", - .Filename = "Yadifmod.dll", - .Description = "Modified version of Fizick's avisynth filter port of yadif from mplayer. This version doesn't internally generate spatial predictions, but takes them from an external clip.", - .WebURL = "http://github.com/HomeOfVapourSynthEvolution/VapourSynth-Yadifmod", - .VSFilterNames = {"yadifmod.Yadifmod"}, - .VSFiltersFunc = Function() {New VideoFilter("Field", "Yadifmod", "clip = core.yadifmod.Yadifmod(clip, core.nnedi3.nnedi3(clip, field=0), order=1, field=-1, mode=0)")}}) - Add(New PluginPackage With { .Name = "nnedi3", .Filename = "libnnedi3.dll", @@ -1683,7 +1689,7 @@ Public Class Package .Description = "Visual C++ 2012 Redistributable is required by some tools used by StaxRip.", .DownloadURL = "http://www.microsoft.com/en-US/download/details.aspx?id=30679", .FixedDir = Folder.System, - .IgnoreVersion = True, + .VersionAllowAny = True, .TreePath = "Runtimes", .RequiredFunc = Function() Items("SangNom2 avs").Required OrElse Items("Deblock avs").Required OrElse Items("mClean avs").Required}) @@ -1693,7 +1699,7 @@ Public Class Package .Filename = "msvcp120.dll", .Description = "Visual C++ 2013 Redistributable is required by some tools used by StaxRip.", .DownloadURL = "http://www.microsoft.com/en-US/download/details.aspx?id=40784", - .IgnoreVersion = True, + .VersionAllowAny = True, .FixedDir = Folder.System, .TreePath = "Runtimes"}) @@ -1702,7 +1708,8 @@ Public Class Package .Filename = "msvcp140.dll", .Description = "Visual C++ Redistributable is required by many tools used by StaxRip.", .DownloadURL = "https://support.microsoft.com/en-gb/help/2977003/the-latest-supported-visual-c-downloads", - .AllowOldVersion = False, + .VersionAllowOld = False, + .VersionAllowNew = True, .FixedDir = Folder.System, .TreePath = "Runtimes"}) @@ -1712,7 +1719,7 @@ Public Class Package .Description = "DirectX 9.0c End-User Runtime.", .DownloadURL = "https://www.microsoft.com/en-us/download/details.aspx?id=34429", .FixedDir = Folder.System, - .IgnoreVersion = True, + .VersionAllowAny = True, .TreePath = "Runtimes", .RequiredFunc = Function() AviSynthShader.Required}) @@ -1974,14 +1981,16 @@ Public Class Package Function GetStatusVersion() As String Dim ret As String - If Not IsCorrectVersion() AndAlso Not IgnoreVersion Then - If IsOldVersion() Then - If Not AllowOldVersion Then + If Not IsVersionValid() Then + If IsVersionOld() Then + If Not VersionAllowOld Then ret = $"The currently used version of {Name} is not compatible (too old)." Else ret = $"An old {Name} version was found, click on Version (F12) and enter the name of this version or install a newer version." End If - Else + End If + + If IsVersionNew() Then ret = $"A new {Name} version was found, new versions are usually compatible, click on Version (F12) and enter the name of this version." End If End If @@ -2015,18 +2024,36 @@ Public Class Package End If End Function - Function IsOldVersion() As Boolean + Function IsVersionOld() As Boolean Dim filepath = Path - If filepath <> "" AndAlso Not IgnoreVersion Then + If filepath <> "" Then If (VersionDate - File.GetLastWriteTimeUtc(filepath)).TotalDays > 3 Then Return True End If End If End Function - Overridable Function IsCorrectVersion() As Boolean - If IgnoreVersion Then + Function IsVersionNew() As Boolean + Dim filepath = Path + + If filepath <> "" Then + If (VersionDate - File.GetLastWriteTimeUtc(filepath)).TotalDays < -3 Then + Return True + End If + End If + End Function + + Function IsVersionCorrect() As Boolean + Return Not IsVersionOld() AndAlso Not IsVersionNew() + End Function + + Overridable Function IsVersionValid() As Boolean + If VersionAllowAny Then + Return True + End If + + If IsVersionNew() AndAlso VersionAllowNew Then Return True End If diff --git a/Portable/PowerShell.vb b/Portable/PowerShell.vb index 89495079..7f924e59 100644 --- a/Portable/PowerShell.vb +++ b/Portable/PowerShell.vb @@ -16,6 +16,11 @@ Public Class PowerShell runspace.Open() Using pipeline = runspace.CreatePipeline() + Dim cmd = New Runspaces.Command("Set-ExecutionPolicy") + cmd.Parameters.Add("ExecutionPolicy", "Unrestricted") + cmd.Parameters.Add("Scope", "Process") + pipeline.Commands.Add(cmd) + If InitCode <> "" Then pipeline.Commands.AddScript(InitCode) End If diff --git a/docs/generated/tools.rst b/docs/generated/tools.rst index 5200828e..c335c723 100644 --- a/docs/generated/tools.rst +++ b/docs/generated/tools.rst @@ -34,14 +34,14 @@ Tools "HQDN3D","AviSynth Plugin","Hqdn3d.dll","0.11","2019-01-01" "JincResize","AviSynth Plugin","JincResize.dll","r44","2019-01-01" "JPSDR","AviSynth Plugin","Plugins_JPSDR.dll","3.2.0","2019-12-29" - "KNLMeansCL","AviSynth Plugin","KNLMeansCL.dll","1.1.1","2019-01-01" + "KNLMeansCL","AviSynth Plugin","KNLMeansCL.dll","1.1.1","2020-04-29" "L-SMASH-Works","AviSynth Plugin","LSMASHSource.dll","2020-03-28 HolyWu","2020-03-27" - "masktools2","AviSynth Plugin","masktools2.dll","2.2.18","2019-01-01" + "masktools2","AviSynth Plugin","masktools2.dll","2.2.23","2020-05-14" "MedianBlur2","AviSynth Plugin","MedianBlur2.dll","0.94","2014-02-10" "MiniDeen","AviSynth Plugin","MiniDeen.dll","r6","2020-03-09" "MipSmooth","AviSynth Plugin","MipSmooth.dll","1.1.2","2019-01-01" "modPlus","AviSynth Plugin","modPlus.dll","2017-10-17","2019-01-01" - "MPEG2DecPlus","AviSynth Plugin","MPEG2DecPlus.dll","1.5.8.0","2019-01-01" + "MPEG2DecPlus","AviSynth Plugin","MPEG2DecPlus64.dll","0.1.2","2020-05-09" "MSharpen","AviSynth Plugin","msharpen.dll","0.9","2013-11-30" "mvtools2","AviSynth Plugin","mvtools2.dll","2.7.41","2019-05-02" "NicAudio","AviSynth Plugin","NicAudio.dll","1.1","2019-01-01" @@ -63,7 +63,7 @@ Tools "vsCube","AviSynth Plugin","vscube.dll","1.0","2019-01-01" "VSFilterMod","AviSynth Plugin","VSFilterMod.dll","R5.2.1","2019-07-09" "xNLMeans","AviSynth Plugin","xNLMeans.dll","0.03","2019-01-01" - "yadifmod2","AviSynth Plugin","yadifmod2.dll","0.0.4-1","2016-07-05" + "yadifmod2","AviSynth Plugin","yadifmod2.dll","0.2.2","2020-05-14" "AnimeIVTC","AviSynth Script","AnimeIVTC.avsi","2.20","2019-01-01" "AviSynthShader AVSI","AviSynth Script","Shader.avsi","1.6.5","2018-05-13" "CropResize","AviSynth Script","CropResize.avsi","2019-09-09","2019-09-10" @@ -92,7 +92,7 @@ Tools "nnedi3 AVSI","AviSynth Script","nnedi3_16.avsi","3.0","2019-01-01" "nnedi3x AVSI","AviSynth Script","nnedi3x.avsi","3.0","2019-01-01" "pSharpen","AviSynth Script","pSharpen.avsi","2016-03-16","2019-01-01" - "QTGMC","AviSynth Script","QTGMC.avsi","3.361s","2019-01-01" + "QTGMC","AviSynth Script","QTGMC.avsi","3.364s","2020-05-22" "ResizeX","AviSynth Script","ResizeX.avsi","1.0.1","2019-01-01" "SMDegrain","AviSynth Script","SMDegrain.avsi","3.1.2.100s","2019-08-19" "SmoothD2c","AviSynth Script","SmoothD2c.avs","a2","2019-01-01" @@ -100,7 +100,7 @@ Tools "aomenc","Console App","aomenc.exe","2.0","2020-05-19" "AutoCrop","Console App","AutoCrop.exe","1.0.0.0","2020-05-06" "avs2pipemod","Console App","avs2pipemod64.exe","1.1.1","2016-08-14" - "AVSMeter","Console App","AVSMeter64.exe","2.9.9.1","2020-04-17" + "AVSMeter","Console App","AVSMeter64.exe","2.9.9.3","2020-05-22" "dsmux","Console App","dsmux.exe","2013-04-14","2013-04-14" "eac3to","Console App","eac3to.exe","3.34","2017-11-19" "fdkaac","Console App","fdkaac.exe","1.0.0","2019-02-13" @@ -121,26 +121,26 @@ Tools "vspipe","Console App","vspipe.exe","r50","2020-05-08" "x264","Console App","x264.exe","2991-1771b55 Patman","2020-02-20" "x265","Console App","x265.exe","3.3+27-g4780a8d99-gcc11.0.0 Patman","2020-05-07" - "xvid_encraw","Console App","xvid_encraw.exe","","" + "xvid_encraw","Console App","xvid_encraw.exe","1.3.7","" "BDSup2Sub++","GUI App","bdsup2sub++.exe","1.0.3","2018-05-09" "chapterEditor","GUI App","chapterEditor.exe","1.21","2020-02-29" - "DGIndex","GUI App","DGIndex.exe","","" - "MPC-BE","GUI App","mpc-be64.exe",,"2019-12-27" - "MPC-HC","GUI App","mpc-hc64.exe",,"2017-07-16" + "DGIndex","GUI App","DGIndex.exe","1.5.8","" + "MPC-BE","GUI App","mpc-be64.exe","","2019-12-27" + "MPC-HC","GUI App","mpc-hc64.exe","","2017-07-16" "mpv.net","GUI App","mpvnet.exe","5.4.8.0","2020-05-11" "Subtitle Edit","GUI App","SubtitleEdit.exe","3.5.14","2020-03-08" "VSRip","GUI App","VSRip.exe","1.0.0.7","2011-07-14" - "AviSynth","Library","AviSynth.dll","3.5.1","2020-04-03" - "DirectX 9","Library","d3d9.dll",,"2019-10-04" + "AviSynth","Library","AviSynth.dll","3.6.0","2020-05-20" + "DirectX 9","Library","d3d9.dll","","2019-10-04" "FFTW","Library","libfftw3-3.dll","3.3.8","2018-12-20" "MediaInfo","Library","MediaInfo.dll","20.03","2020-04-03" "VapourSynth","Library","vapoursynth.dll","r50","2020-05-08" - "Visual C++ 2012","Library","msvcp110.dll",,"2012-11-05" - "Visual C++ 2013","Library","msvcp120.dll",,"2016-02-10" - "Visual C++ 2019","Library","msvcp140.dll","14.25.28508.3","2020-01-08" + "Visual C++ 2012","Library","msvcp110.dll","","2012-11-05" + "Visual C++ 2013","Library","msvcp120.dll","","2016-02-10" + "Visual C++ 2019","Library","msvcp140.dll","","2020-03-20" "Get-MediaInfo","Misc","Get-MediaInfo.ps1","3.3","2020-05-04" "Haali Splitter","Misc","splitter.ax","","2013-04-14" - "MediaInfo.NET","Misc","MediaInfoNET.exe","6.3.0.0","2020-05-04" + "MediaInfo.NET","Misc","MediaInfoNET.exe","6.4.0.0","2020-05-22" "AWarpSharp2","VapourSynth Plugin","libawarpsharp2.dll","2018-06-18","2019-01-01" "BM3D","VapourSynth Plugin","BM3D.dll","r8","2019-01-03" "Bwdif","VapourSynth Plugin","Bwdif.dll","r1","2020-02-24" @@ -181,7 +181,7 @@ Tools "vcmod","VapourSynth Plugin","vcmod.dll","2017-10-17","2019-01-01" "vcmove","VapourSynth Plugin","vcmove.dll","2016-04-10","2019-01-01" "W3FDIF","VapourSynth Plugin","W3FDIF.dll","r1","2019-01-01" - "Yadifmod","VapourSynth Plugin","Yadifmod.dll","10","2017-02-07" + "Yadifmod","VapourSynth Plugin","Yadifmod.dll","r10","2017-02-07" "znedi3","VapourSynth Plugin","vsznedi3.dll","2018-01-11","2019-01-01" "adjust","VapourSynth Script","adjust.py","2015-03-22","2019-01-01" "Dither","VapourSynth Script","Dither.py","2018-02-23","2019-01-01" @@ -768,7 +768,7 @@ KNLMeansCL is an optimized pixelwise OpenCL implementation of the Non-local mean Filters: KNLMeansCL -http://github.com/Khanattila/KNLMeansCL +https://github.com/pinterf/KNLMeansCL L-SMASH-Works @@ -838,7 +838,7 @@ Source filter to open D2V index files created with DGIndex or D2VWitch. Filters: MPEG2Source -http://github.com/chikuzen/MPEG2DecPlus +https://github.com/Asd-g/MPEG2DecPlus MSharpen @@ -1054,11 +1054,11 @@ http://avisynth.nl/index.php/xNLMeans yadifmod2 ~~~~~~~~~ -Yet Another Deinterlacing Filter mod for Avisynth2.6/Avisynth+ +Yet Another Deinterlacing Filter mod Filters: yadifmod2 -http://github.com/chikuzen/yadifmod2 +https://github.com/Asd-g/yadifmod2 AviSynth Script