Skip to content

Commit

Permalink
remove SetFilterMTMode().
Browse files Browse the repository at this point in the history
  • Loading branch information
chikuzen committed Jul 21, 2016
1 parent 3888148 commit 9c708d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
8 changes: 6 additions & 2 deletions avisynth/src/CombMask.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <windows.h>
#include <avisynth.h>

#define CMASK_VERSION "1.1.0"
#define CMASK_VERSION "1.1.1"


typedef IScriptEnvironment ise_t;
Expand Down Expand Up @@ -43,7 +43,11 @@ class GVFmod : public GenericVideoFilter {
GVFmod(PClip c, bool chroma, arch_t a, bool ip) :
GenericVideoFilter(c), align(a == USE_AVX2 ? 32 : 16), isPlus(ip)
{
numPlanes = vi.IsY8() || !chroma ? 1 : 3;
numPlanes = (vi.IsY8() || !chroma) ? 1 : 3;
}
int __stdcall SetCacheHints(int hints, int)
{
return hints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0;
}
};

Expand Down
31 changes: 11 additions & 20 deletions avisynth/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ create_combmask(AVSValue args, void* user_data, ise_t* env)
int mth = args[MTHRESH].AsInt(9);
bool ch = args[CHROMA].AsBool(true);
bool expand = args[EXPAND].AsBool(true);
bool is_avsplus = user_data != nullptr;
bool is_avsplus = env->FunctionExists("SetFilterMTMode");
arch_t arch = get_arch(args[OPT].AsInt(-1), is_avsplus);

try{
return new CombMask(clip, cth, mth, ch, arch, expand, metric, is_avsplus);

} catch (std::runtime_error& e) {
env->ThrowError((std::string("CombMask: ") + e.what()).c_str());
env->ThrowError("CombMask: %s", e.what());
}

return 0;
}


static AVSValue __cdecl
create_maskedmerge(AVSValue args, void* user_data, IScriptEnvironment* env)
create_maskedmerge(AVSValue args, void*, IScriptEnvironment* env)
{
enum { BASE, ALT, MASK, MI, BLOCKX, BLOCKY, CHROMA, OPT };
try {
Expand All @@ -62,19 +62,19 @@ create_maskedmerge(AVSValue args, void* user_data, IScriptEnvironment* env)
int bx = args[BLOCKX].AsInt(8);
int by = args[BLOCKY].AsInt(8);
bool ch = args[CHROMA].AsBool(true);
bool is_avsplus = user_data != nullptr;
bool is_avsplus = env->FunctionExists("SetFilterMTMode");
arch_t arch = get_arch(args[OPT].AsInt(-1), is_avsplus);

return new MaskedMerge(base, alt, mask, mi, bx, by, ch, arch, is_avsplus);
} catch (std::runtime_error& e) {
env->ThrowError((std::string("MaskedMerge: ") + e.what()).c_str());
env->ThrowError("MaskedMerge: %s", e.what());
}
return 0;
}


static AVSValue __cdecl
create_iscombed(AVSValue args, void* user_data, ise_t* env)
create_iscombed(AVSValue args, void*, ise_t* env)
{
enum { CLIP, CTHRESH, MTHRESH, MI, BLOCKX, BLOCKY, METRIC, OPT };
CombMask* cm = nullptr;
Expand All @@ -92,7 +92,7 @@ create_iscombed(AVSValue args, void* user_data, ise_t* env)
int mi = args[MI].AsInt(80);
int blockx = args[BLOCKX].AsInt(16);
int blocky = args[BLOCKY].AsInt(16);
bool is_avsplus = user_data != nullptr;
bool is_avsplus = env->FunctionExists("SetFilterMTMode");
arch_t arch = get_arch(args[OPT].AsInt(-1), is_avsplus);

validate(mi < 0 || mi > 128, "MI must be between 0 and 128.");
Expand All @@ -112,7 +112,7 @@ create_iscombed(AVSValue args, void* user_data, ise_t* env)

} catch (std::runtime_error& e) {
if (cm) delete cm;
env->ThrowError((std::string("IsCombed: ") + e.what()).c_str());
env->ThrowError("IsCombed: %s", e.what());
}
return 0;
}
Expand All @@ -132,26 +132,17 @@ AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors)
{
AVS_linkage = vectors;

void* is_avsplus = env->FunctionExists("SetFilterMTMode") ? "true" : nullptr;

env->AddFunction(
"CombMask", "c[cthresh]i[mthresh]i[chroma]b[expand]b[metric]i[opt]i",
create_combmask, is_avsplus);
create_combmask, nullptr);
env->AddFunction(
"MaskedMerge",
"[base]c[alt]c[mask]c[MI]i[blockx]i[blocky]i[chroma]b[opt]i",
create_maskedmerge, is_avsplus);
create_maskedmerge, nullptr);
env->AddFunction(
"IsCombed",
"c[cthresh]i[mthresh]i[MI]i[blockx]i[blocky]i[metric]i[opt]i",
create_iscombed, is_avsplus);

if (is_avsplus != nullptr) {
auto env2 = static_cast<IScriptEnvironment2*>(env);
env2->SetFilterMTMode("CombMask", MT_NICE_FILTER, true);
env2->SetFilterMTMode("MaskedMerge", MT_NICE_FILTER, true);
env2->SetFilterMTMode("IsCombed", MT_SERIALIZED, true);
}
create_iscombed, nullptr);

return "CombMask filter for Avisynth2.6/Avisynth+ version " CMASK_VERSION;
}

0 comments on commit 9c708d7

Please sign in to comment.