TColorMask
(tcolormask: add documentation) |
(tcolormask: update stuff to v1.2.2) |
||
(One intermediate revision by one user not shown) | |||
Line 1: | Line 1: | ||
{{FilterCat5|External_filters|Plugins|Plugins_x64|Adjustment_filters|Masking}} | {{FilterCat5|External_filters|Plugins|Plugins_x64|Adjustment_filters|Masking}} | ||
{{Filter3 | {{Filter3 | ||
− | | {{Author/tp7}} | + | | {{Author/tp7}}, {{Author/Asd-g}} |
− | | v1.2 | + | | v1.2.2 |
− | |[https://github.com/ | + | |[https://github.com/Asd-g/AviSynth-tcolormask/releases tcolormask-x86.zip // tcolormask-x64.zip] |
| Masking | | Masking | ||
| [http://www.gnu.org/licenses/gpl-2.0.txt GPLv2] | | [http://www.gnu.org/licenses/gpl-2.0.txt GPLv2] | ||
Line 17: | Line 17: | ||
* [x86]: [[AviSynth+]] or [http://sourceforge.net/projects/avisynth2/ AviSynth 2.6] | * [x86]: [[AviSynth+]] or [http://sourceforge.net/projects/avisynth2/ AviSynth 2.6] | ||
* [x64]: [[AviSynth+]] | * [x64]: [[AviSynth+]] | ||
− | * Supported color formats: [[YV12]], [[YV16]], [[YV24]] | + | * Supported color formats: [[YV12]], [[YV16]], [[YV24]] (8/16bit) |
<br> | <br> | ||
== [[Script variables|Syntax and Parameters]] == | == [[Script variables|Syntax and Parameters]] == | ||
− | :{{Template:FuncDef|tcolormask (clip, string "colors, int "tolerance", bool "bt601", bool "gray", int "lutthr", bool "mt")}} | + | :{{Template:FuncDef|tcolormask(clip, string "colors, int "tolerance", bool "bt601", bool "gray", int "lutthr", bool "mt", bool "onlyY", int "opt")}} |
<br> | <br> | ||
::{{Par2| |clip| }} | ::{{Par2| |clip| }} | ||
− | ::: | + | :::A clip to process. |
+ | :::Must be in YUV420/422/444 8/16-bit planar format. | ||
<br> | <br> | ||
::{{Par2|colors|string|""}} | ::{{Par2|colors|string|""}} | ||
:::String of colors. Line and block comments are allowed. | :::String of colors. Line and block comments are allowed. | ||
<br> | <br> | ||
− | ::{{Par2|tolerance|int|10}} | + | ::{{Par2|tolerance|int|10(8-bit) / 2570(16-bit)}} |
:::Pixel value will pass if its absolute difference with color is less than tolerance (luma) or half the tolerance (chroma). | :::Pixel value will pass if its absolute difference with color is less than tolerance (luma) or half the tolerance (chroma). | ||
+ | :::It must be between 0 and 255/65535. | ||
<br> | <br> | ||
::{{Par2|bt601|bool|false}} | ::{{Par2|bt601|bool|false}} | ||
Line 36: | Line 38: | ||
<br> | <br> | ||
::{{Par2|gray|bool|false}} | ::{{Par2|gray|bool|false}} | ||
− | :::Set chroma of output clip to 128. | + | :::Set chroma of output clip to 128/32896. |
<br> | <br> | ||
::{{Par2|lutthr|int|9}} | ::{{Par2|lutthr|int|9}} | ||
:::If specified more than <code>lutthr</code> colors, LUT will be used instead of direct SIMD computations. | :::If specified more than <code>lutthr</code> colors, LUT will be used instead of direct SIMD computations. | ||
<br> | <br> | ||
− | ::{{Par2|mt|bool| | + | ::{{Par2|mt|bool|false}} |
:::Enable multithreading. It actually uses only two threads as any more threading doesn't seem to be useful. | :::Enable multithreading. It actually uses only two threads as any more threading doesn't seem to be useful. | ||
+ | <br> | ||
+ | ::{{Par2|onlyY|bool|false}} | ||
+ | :::The returned clip format is Y. | ||
+ | <br> | ||
+ | ::{{Par2|opt|int|-1}} | ||
+ | :::-1: Auto-detect. | ||
+ | :::0: Use C++ code. | ||
+ | :::1: Use SSE2 code. | ||
+ | :::2: Use AVX2 code. | ||
+ | :::3: Use AVX512 code. | ||
<br> | <br> | ||
Line 56: | Line 68: | ||
This plugin uses direct SIMD computations to do its dirty work. SIMD appears to be faster than LUT for the most common cases, but unfortunately its speed depends on the number of specified colors and at some point it does get slower than LUT. That's why the alternative is also provided. If specified more than lutthr (9 by default) colors, the plugin will use the LUT routine to avoid performance degradation. | This plugin uses direct SIMD computations to do its dirty work. SIMD appears to be faster than LUT for the most common cases, but unfortunately its speed depends on the number of specified colors and at some point it does get slower than LUT. That's why the alternative is also provided. If specified more than lutthr (9 by default) colors, the plugin will use the LUT routine to avoid performance degradation. | ||
− | See performance table on [https://github.com/tp7/tcolormask | + | See performance table on [https://github.com/tp7/tcolormask#performance GitHub]. |
<br> | <br> | ||
<br> | <br> | ||
+ | |||
== Examples == | == Examples == | ||
tcolormask with default values, except colors: | tcolormask with default values, except colors: | ||
Line 66: | Line 79: | ||
== Changelog == | == Changelog == | ||
Version Date Changes<br> | Version Date Changes<br> | ||
+ | v1.2.2 2022/06/11 - grayscale and 'onlyY' cannot be true in the same time. (Asd-g) | ||
+ | - Added AVX512 code. (Asd-g) | ||
+ | v1.2.1 2022/06/10 - Registered as MT_NICE_FILTER. (tp7) | ||
+ | - Disabled internal 'MT' by default. (tp7) | ||
+ | - Fixed YV12 processing. (tp7) | ||
+ | - Added support for frame properties passthrough. (Asd-g) | ||
+ | - Fixed the right side when width is not mod16. (Asd-g) | ||
+ | - Non-mod2 chroma height for YV12 and mt=true are not allowed. (Asd-g) | ||
+ | - Added C and AVX2 code. (Asd-g) | ||
+ | - Added 'opt' parameter. (Asd-g) | ||
+ | - Added support for 16-bit clips. (Asd-g) | ||
+ | - Added 'onlyY' parameter. (Asd-g) | ||
+ | - Added binary version. (Asd-g) | ||
v1.2 2013/11/30 - x64 build added. | v1.2 2013/11/30 - x64 build added. | ||
- Function from tcolormask_wrappers will not work with x64 build of AviSynth+. | - Function from tcolormask_wrappers will not work with x64 build of AviSynth+. | ||
Line 74: | Line 100: | ||
<br> | <br> | ||
== External Links == | == External Links == | ||
− | *[https://github.com/tp7/tcolormask GitHub] - Source code repository. | + | *[https://github.com/tp7/tcolormask GitHub] - Source code repository by tp7. |
+ | *[https://github.com/Asd-g/AviSynth-tcolormask GitHub] - Source code repository by Asd-g. | ||
<br> | <br> | ||
<br> | <br> | ||
----------------------------------------------- | ----------------------------------------------- | ||
'''Back to [[External_filters#Averaging.2FLayering.2FMasking|External Filters]] ←''' | '''Back to [[External_filters#Averaging.2FLayering.2FMasking|External Filters]] ←''' |
Latest revision as of 17:24, 12 June 2022
Abstract | |
---|---|
Author | tp7, Asd-g |
Version | v1.2.2 |
Download | tcolormask-x86.zip // tcolormask-x64.zip |
Category | Masking |
License | GPLv2 |
Discussion |
Contents |
[edit] Description
TColorMask This is a port of the great tophf's script t_colormask. It masks colors but unlike the old ColorKeyMask it works on YV12. The main reason for this plugin is performance. The API and output are not identical, please refer to the Difference section for details.
[edit] Requirements
- [x86]: AviSynth+ or AviSynth 2.6
- [x64]: AviSynth+
- Supported color formats: YV12, YV16, YV24 (8/16bit)
[edit] Syntax and Parameters
- tcolormask(clip, string "colors, int "tolerance", bool "bt601", bool "gray", int "lutthr", bool "mt", bool "onlyY", int "opt")
- clip =
- A clip to process.
- Must be in YUV420/422/444 8/16-bit planar format.
- clip =
- string colors = ""
- String of colors. Line and block comments are allowed.
- string colors = ""
- int tolerance = 10(8-bit) / 2570(16-bit)
- Pixel value will pass if its absolute difference with color is less than tolerance (luma) or half the tolerance (chroma).
- It must be between 0 and 255/65535.
- int tolerance = 10(8-bit) / 2570(16-bit)
- bool bt601 = false
- Use bt601 matrix for conversion of colors.
- bool bt601 = false
- bool gray = false
- Set chroma of output clip to 128/32896.
- bool gray = false
- int lutthr = 9
- If specified more than
lutthr
colors, LUT will be used instead of direct SIMD computations.
- If specified more than
- int lutthr = 9
- bool mt = false
- Enable multithreading. It actually uses only two threads as any more threading doesn't seem to be useful.
- bool mt = false
- bool onlyY = false
- The returned clip format is Y.
- bool onlyY = false
- int opt = -1
- -1: Auto-detect.
- 0: Use C++ code.
- 1: Use SSE2 code.
- 2: Use AVX2 code.
- 3: Use AVX512 code.
- int opt = -1
[edit] Difference
Unlike the old script, this plugin uses a single string to specify all colors and doesn't do any blurring. Wrapper functions are provided for convenience in the bin/tcolormask_wrappers.avs script.
Also since we process chroma and luma together to avoid having to merge planes later, output is not identical. Basically it appears a bit less blurred and doesn't contain any non-binary values produced by chroma resizing. This will not be fixed and there's no workaround. You'll most likely be blurring the output clip anyway.
[edit] Performance
This plugin uses direct SIMD computations to do its dirty work. SIMD appears to be faster than LUT for the most common cases, but unfortunately its speed depends on the number of specified colors and at some point it does get slower than LUT. That's why the alternative is also provided. If specified more than lutthr (9 by default) colors, the plugin will use the LUT routine to avoid performance degradation.
See performance table on GitHub.
[edit] Examples
tcolormask with default values, except colors:
AviSource("bah.avi") tcolormask("$E0C0AB", tolerance=10, bt601=false, gray=false, lutthr=9, mt=true)
[edit] Changelog
Version Date Changes
v1.2.2 2022/06/11 - grayscale and 'onlyY' cannot be true in the same time. (Asd-g) - Added AVX512 code. (Asd-g) v1.2.1 2022/06/10 - Registered as MT_NICE_FILTER. (tp7) - Disabled internal 'MT' by default. (tp7) - Fixed YV12 processing. (tp7) - Added support for frame properties passthrough. (Asd-g) - Fixed the right side when width is not mod16. (Asd-g) - Non-mod2 chroma height for YV12 and mt=true are not allowed. (Asd-g) - Added C and AVX2 code. (Asd-g) - Added 'opt' parameter. (Asd-g) - Added support for 16-bit clips. (Asd-g) - Added 'onlyY' parameter. (Asd-g) - Added binary version. (Asd-g) v1.2 2013/11/30 - x64 build added. - Function from tcolormask_wrappers will not work with x64 build of AviSynth+. v1.1 2013/07/26 - This plugin now only works with AviSynth 2.6 alpha 4. If you need support for older versions, download v1.0.1. - Also, YV16 colorspace is now supported. v1.0 2013/07/08 - Actually working now.
[edit] External Links
Back to External Filters ←