Skip to content

Commit

Permalink
Trim and other no-op filters are to be cached again. Partly neutralize
Browse files Browse the repository at this point in the history
  • Loading branch information
pinterf committed Aug 29, 2019
1 parent 4f34a8b commit eb018b8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
14 changes: 7 additions & 7 deletions avs_core/filters/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
42 changes: 36 additions & 6 deletions avs_core/filters/edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/********************************************************************
********************************************************************/

class Trim : public NonCachedGenericVideoFilter
class Trim : public GenericVideoFilter
/**
* Class to select a range of frames from a longer clip
**/
Expand All @@ -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);

Expand All @@ -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
**/
Expand All @@ -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:
Expand All @@ -85,7 +95,7 @@ class FreezeFrame : public NonCachedGenericVideoFilter



class DeleteFrame : public NonCachedGenericVideoFilter
class DeleteFrame : public GenericVideoFilter
/**
* Class to delete a frame
**/
Expand All @@ -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:
Expand All @@ -104,7 +119,7 @@ class DeleteFrame : public NonCachedGenericVideoFilter



class DuplicateFrame : public NonCachedGenericVideoFilter
class DuplicateFrame : public GenericVideoFilter
/**
* Class to duplicate a frame
**/
Expand All @@ -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:
Expand Down Expand Up @@ -200,7 +220,7 @@ class AudioDub : public IClip {



class Reverse : public NonCachedGenericVideoFilter
class Reverse : public GenericVideoFilter
/**
* Class to play a clip backwards
**/
Expand All @@ -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
**/
Expand All @@ -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;
Expand Down

0 comments on commit eb018b8

Please sign in to comment.