CombMask

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(add more documentation)
m (Notes)
Line 166: Line 166:
 
<br>
 
<br>
 
== Notes ==
 
== Notes ==
* On AviSynth+, CombMask and MaskedMerge are set as [[MT_NICE_FILTER]]] automatically.
+
* On AviSynth+, CombMask and MaskedMerge are set as [[MT_NICE_FILTER]] automatically.
 
      
 
      
 
* This plugin's filters require appropriate memory alignments. Thus, if you want to crop the left side of your source clip before these filters, you have to set crop(align=true).
 
* This plugin's filters require appropriate memory alignments. Thus, if you want to crop the left side of your source clip before these filters, you have to set crop(align=true).
<br>  
+
<br>
 +
 
 
== Changelog ==
 
== Changelog ==
 
  Version      Date            Changes<br>
 
  Version      Date            Changes<br>

Revision as of 16:18, 17 May 2020

Abstract
Author Chikuzen
Version v1.1.1
Download CombMask-1.1.1.7z
Category Masking
License GPLv2
Discussion


Contents

Description

A filter to create and process comb masks. These filters were written from scratch, but most of logic comes from tritical's TIVTC plugin.

Requirements


*** vcredist_x86.exe is required for CombMask-x86
*** vcredist_x64.exe is required for CombMask-x64


Syntax and Parameters

CombMask

CombMask is a simple filter that creates a comb mask that can (could) be used by other filters like MaskTools2.
The mask consists of binaries of 0(not combed) and 255(combed).

CombMask (clip, int "cthresh", int "mthresh", bool "chroma", bool "expand", int "metric", int opt)


clip   =
Input clip.


int  cthresh =
Spatial combing threshold.
  • 0 to 255, default is 6 (metric=0)
  • 0 to 65025, default is 10 (metric=1


int  mthresh = 9
Motion adaptive threshold.
  • 0 to 255, default is 9.


bool  chroma = true
Whether processing is performed to UV planes or not.
  • Default is true.


bool  exapnd = true
When set this to true, left and right pixels of combed pixel also assumed to combed.
  • Default is true.


int  metric = 0
Sets which spatial combing metric is used to detect combed pixels.
Possible options:
             Assume 5 neighboring pixels (a,b,c,d,e) positioned vertically.

      a
      b
      c
      d
      e

0:  d1 = c - b;
    d2 = c - d;
    if ((d1 > cthresh && d2 > cthresh) || (d1 < -cthresh && d2 < -cthresh))
    {
       if (abs(a+4*c+e-3*(b+d)) > cthresh*6) it's combed;
    }

1:  val = (b - c) * (d - c);
    if (val > cthresh) it's combed;

default is 0.


int  opt =
Specify which CPU optimization are used.
  • 0 : Use C++ routine.
  • 1 : Use SSE2 routin if possible. When SSE2 can't be used, fallback to 0.
  • Others(default) : Use AVX2 routine if possible. When AVX2 can't be used, fallback to 1.



MaskedMerge

MaskedMerge is an exclusive masking filter for CombMask. This is often faster than MaskTools2's mt_merge().

MaskedMerge (clip base, clip alt, clip mask, int "MI", int "blockx", int "blocky", bool "chroma", int opt)


clip   =
base: base clip.


clip   =
alt: alternate clip which will be merged to base.


clip   =
mask: mask clip.


int  MI = 80
The number of combed pixels inside any of blockx * blocky size blocks on the Y-plane for the frame to be detected as combed. If the frame is not combed, merge process will be skipped.
  • Range: 0 to blockx*blocky, default is 80


int  blockx = 16
Sets the x-axis size of the window used during combed frame detection. This has to do with the size of the area in which MI number of pixels are required to be detected as combed for a frame to be declared combed.
  • Possible values are 8, 16(default) or 32.


int  blocky = 16
Sets the x-axis size of the window used during combed frame detection. This has to do with the size of the area in which MI number of pixels are required to be detected as combed for a frame to be declared combed.
  • Possible values are 8, 16(default) or 32.


bool  chroma = true
Whether processing is performed to UV planes or not.
  • Default is true.


int  opt =
Same as CombMask.



IsCombed

IsCombed is a is a utility function that can be used within AviSynth's ConditionalFilter to test whether or not a frame is combed and returns true if it is and false if it isn't.

IsCombed (clip, int "cthresh", int "mthresh", int "MI", int "blockx", int "blocky", int "metric", int "opt")


clip   =
Input clip.


int  cthresh =
Same as CombMask


int  mthresh = 9
Same as CombMask


int  MI = 80
Same as MaskedMerge.


int  blockx = 16
Same as MaskedMerge.


int  blocky = 16
Same as MaskedMerge.


int  metric = 0
Same as CombMask.


int  opt =
Same as CombMask.


Examples

   src = SourceFilter("foo\bar\fizz\buzz")
   deint = src.some_deinterlace_filter()
   deint2 = src.another_filter()
   mask = deint.CombMask()
   last = deint.MaskedMerge(deint2, mask)
   return last
   src = a_YV12_clip
   combed = src.ConvertToYV16(interlaced=true)
   nocomb = src.ConvertToYV16(interlaced=false)
   ConditionalFilter(src, combed, nocomb, "IsCombed", "=", "true")


Notes

  • On AviSynth+, CombMask and MaskedMerge are set as MT_NICE_FILTER automatically.
  • This plugin's filters require appropriate memory alignments. Thus, if you want to crop the left side of your source clip before these filters, you have to set crop(align=true).


Changelog

Version      Date            Changes
v1.1.1 2020/05/13 - Changes by asd-g - Update to AviSynth+'s v8 interface


External Links

  • GitHub - Source code repository.
  • GitHub - Source code repository (update).




Back to External Filters

Personal tools