From eb018b8240ea3d871e50e6b13e9b70787bebb2ba Mon Sep 17 00:00:00 2001 From: Pinterf Date: Thu, 29 Aug 2019 13:10:22 +0200 Subject: [PATCH] Trim and other no-op filters are to be cached again. Partly neutralize https://github.com/pinterf/AvisynthPlus/commit/50a1e569 --- avs_core/filters/edit.cpp | 14 ++++++------- avs_core/filters/edit.h | 42 +++++++++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/avs_core/filters/edit.cpp b/avs_core/filters/edit.cpp index bd6c2881d..c9c823bd7 100644 --- a/avs_core/filters/edit.cpp +++ b/avs_core/filters/edit.cpp @@ -111,7 +111,7 @@ int __stdcall NonCachedGenericVideoFilter::SetCacheHints(int cachehints, int fra ******************************/ Trim::Trim(double starttime, double endtime, PClip _child, trim_mode_e mode, IScriptEnvironment* env) - : NonCachedGenericVideoFilter(_child) + : GenericVideoFilter(_child) { int64_t esampleno = 0; @@ -184,7 +184,7 @@ AVSValue __cdecl Trim::CreateA(AVSValue args, void* user_arg, IScriptEnvironment ******************************/ Trim::Trim(int _firstframe, int _lastframe, bool _padaudio, PClip _child, trim_mode_e mode, IScriptEnvironment* env) - : NonCachedGenericVideoFilter(_child) + : GenericVideoFilter(_child) { int lastframe = 0; @@ -295,7 +295,7 @@ AVSValue __cdecl Trim::Create(AVSValue args, void* user_arg, IScriptEnvironment* *******************************/ FreezeFrame::FreezeFrame(int _first, int _last, int _source, PClip _child) - : NonCachedGenericVideoFilter(_child), first(_first), last(_last), source(_source) {} + : GenericVideoFilter(_child), first(_first), last(_last), source(_source) {} PVideoFrame FreezeFrame::GetFrame(int n, IScriptEnvironment* env) @@ -322,7 +322,7 @@ AVSValue __cdecl FreezeFrame::Create(AVSValue args, void*, IScriptEnvironment* e ******************************/ DeleteFrame::DeleteFrame(int _frame, PClip _child) - : NonCachedGenericVideoFilter(_child), frame(_frame) { --vi.num_frames; } + : GenericVideoFilter(_child), frame(_frame) { --vi.num_frames; } PVideoFrame DeleteFrame::GetFrame(int n, IScriptEnvironment* env) @@ -377,7 +377,7 @@ AVSValue __cdecl DeleteFrame::Create(AVSValue args, void*, IScriptEnvironment* e *********************************/ DuplicateFrame::DuplicateFrame(int _frame, PClip _child) - : NonCachedGenericVideoFilter(_child), frame(_frame) { ++vi.num_frames; } + : GenericVideoFilter(_child), frame(_frame) { ++vi.num_frames; } PVideoFrame DuplicateFrame::GetFrame(int n, IScriptEnvironment* env) @@ -881,7 +881,7 @@ AVSValue __cdecl AudioDub::Create(AVSValue args, void* mode, IScriptEnvironment* ******* Reverse Filter ****** *******************************/ -Reverse::Reverse(PClip _child) : NonCachedGenericVideoFilter(_child) {} +Reverse::Reverse(PClip _child) : GenericVideoFilter(_child) {} PVideoFrame Reverse::GetFrame(int n, IScriptEnvironment* env) @@ -926,7 +926,7 @@ AVSValue __cdecl Reverse::Create(AVSValue args, void*, IScriptEnvironment* env) *****************************/ Loop::Loop(PClip _child, int times, int _start, int _end, IScriptEnvironment* env) - : NonCachedGenericVideoFilter(_child), start(_start), end(_end) + : GenericVideoFilter(_child), start(_start), end(_end) { start = clamp(start,0,vi.num_frames-1); end = clamp(end,start,vi.num_frames-1); diff --git a/avs_core/filters/edit.h b/avs_core/filters/edit.h index 12b16c4cf..81561f89f 100644 --- a/avs_core/filters/edit.h +++ b/avs_core/filters/edit.h @@ -41,7 +41,7 @@ /******************************************************************** ********************************************************************/ -class Trim : public NonCachedGenericVideoFilter +class Trim : public GenericVideoFilter /** * Class to select a range of frames from a longer clip **/ @@ -55,6 +55,11 @@ class Trim : public NonCachedGenericVideoFilter void __stdcall GetAudio(void* buf, __int64 start, __int64 count, IScriptEnvironment* env); bool __stdcall GetParity(int n); + int __stdcall SetCacheHints(int cachehints, int frame_range) override { + AVS_UNUSED(frame_range); + return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; + } + static AVSValue __cdecl Create(AVSValue args, void* mode, IScriptEnvironment* env); static AVSValue __cdecl CreateA(AVSValue args, void* mode, IScriptEnvironment* env); @@ -66,7 +71,7 @@ class Trim : public NonCachedGenericVideoFilter -class FreezeFrame : public NonCachedGenericVideoFilter +class FreezeFrame : public GenericVideoFilter /** * Class to display a single frame for the duration of several **/ @@ -76,6 +81,11 @@ class FreezeFrame : public NonCachedGenericVideoFilter PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); bool __stdcall GetParity(int n); + int __stdcall SetCacheHints(int cachehints, int frame_range) override { + AVS_UNUSED(frame_range); + return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; + } + static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); private: @@ -85,7 +95,7 @@ class FreezeFrame : public NonCachedGenericVideoFilter -class DeleteFrame : public NonCachedGenericVideoFilter +class DeleteFrame : public GenericVideoFilter /** * Class to delete a frame **/ @@ -95,6 +105,11 @@ class DeleteFrame : public NonCachedGenericVideoFilter PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); bool __stdcall GetParity(int n); + int __stdcall SetCacheHints(int cachehints, int frame_range) override { + AVS_UNUSED(frame_range); + return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; + } + static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); private: @@ -104,7 +119,7 @@ class DeleteFrame : public NonCachedGenericVideoFilter -class DuplicateFrame : public NonCachedGenericVideoFilter +class DuplicateFrame : public GenericVideoFilter /** * Class to duplicate a frame **/ @@ -114,6 +129,11 @@ class DuplicateFrame : public NonCachedGenericVideoFilter PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); bool __stdcall GetParity(int n); + int __stdcall SetCacheHints(int cachehints, int frame_range) override { + AVS_UNUSED(frame_range); + return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; + } + static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); private: @@ -200,7 +220,7 @@ class AudioDub : public IClip { -class Reverse : public NonCachedGenericVideoFilter +class Reverse : public GenericVideoFilter /** * Class to play a clip backwards **/ @@ -211,13 +231,18 @@ class Reverse : public NonCachedGenericVideoFilter bool __stdcall GetParity(int n); void __stdcall GetAudio(void* buf, __int64 start, __int64 count, IScriptEnvironment* env); + int __stdcall SetCacheHints(int cachehints, int frame_range) override { + AVS_UNUSED(frame_range); + return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; + } + static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); }; -class Loop : public NonCachedGenericVideoFilter { +class Loop : public GenericVideoFilter { /** * Class to loop over a range of frames **/ @@ -227,6 +252,11 @@ class Loop : public NonCachedGenericVideoFilter { bool __stdcall GetParity(int n); void __stdcall GetAudio(void* buf, __int64 start, __int64 count, IScriptEnvironment* env); + int __stdcall SetCacheHints(int cachehints, int frame_range) override { + AVS_UNUSED(frame_range); + return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; + } + static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); private: int frames, start, end;