DctFilter
(→External Links: add link) |
m (add Deep_color_tools category) |
||
(27 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | {{ | + | {{FilterCat5|External_filters|Plugins|Plugins_x64|Other_filters|Deep_color_tools}} |
{{Filter3 | {{Filter3 | ||
− | | {{Author/ | + | | {{Author/Chikuzen}} |
− | | v0. | + | | v0.5.1 |
− | |[ | + | |[https://github.com/Asd-g/DCTFilter/releases DCTFilter-0.5.1.7z] |
− | | | + | | 4=Other filters |
− | | [http://www.gnu.org/licenses/gpl-2.0.txt GPLv2] | + | | 5=[http://www.gnu.org/licenses/gpl-2.0.txt GPLv2] |
− | |}} | + | | 6=[https://forum.doom9.org/showthread.php?t=173738 Doom9 Forum]}} |
== Description == | == Description == | ||
− | + | DctFiler is a filter that, for each 8x8 block, will do a [http://en.wikipedia.org/wiki/Discrete_cosine_transform Discrete Cosine Transform] (DCT), scale down the selected frequency values, and then reverse the process with an Inverse Discrete Cosine Transform (IDCT). | |
+ | |||
+ | This version is a rewrite of the original [[DctFilter_v0.0.1.5|DctFilter]] by Tom Barry. | ||
<br> | <br> | ||
<br> | <br> | ||
+ | |||
== Requirements == | == Requirements == | ||
− | * AviSynth | + | * [x86]: [[AviSynth+]] or [http://forum.doom9.org/showthread.php?t=168764 AviSynth 2.6] |
− | * Supported color formats: [[ | + | * [x64]: [[AviSynth+]] |
− | * | + | * Supported color formats: [[Y8]], [[YV12]], [[YV16]], [[YV24]] |
+ | **AviSynth+: all [[planar]] formats (8/10/12/14/16/32-bit, Y, YUV(A), and RGB(A) with or without alpha) are supported. | ||
+ | <br> | ||
+ | * Windows Vista SP2 or later | ||
+ | * SSE2 capable CPU | ||
+ | * [https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads Microsoft Visual C++ 2015 Redistributable Package (x86 / x64)] | ||
+ | :<span style="color:red">***</span> <tt>vcredist_x86.exe</tt> is required for <tt>DctFilter-x86</tt> | ||
+ | :<span style="color:red">***</span> <tt>vcredist_x64.exe</tt> is required for <tt>DctFilter-x64</tt> | ||
− | |||
− | |||
− | |||
− | |||
<br> | <br> | ||
+ | |||
== [[Script variables|Syntax and Parameters]] == | == [[Script variables|Syntax and Parameters]] == | ||
<br> | <br> | ||
=== DctFilter === | === DctFilter === | ||
− | + | Execute an 8x8 DCT to a clip. | |
− | + | ||
− | + | For each 8x8 block it will do a Discrete Cosine Transform (DCT), scale down the selected frequency values, and then reverse the process with an Inverse Discrete Cosine Transform (IDCT).<br> | |
− | + | ||
− | + | ||
− | <br> | + | |
In the following example the highest frequency components in each row and column will be zeroed while the 2nd highest would be cut in half. | In the following example the highest frequency components in each row and column will be zeroed while the 2nd highest would be cut in half. | ||
− | + | :<code>DctFilter(1,1,1,1,1,1,.5,0)</code> | |
− | + | The row & column parameters are multiplied together to get the scale factor for each of the 64 values in a block. So if the top left value was V[0,0] then in the example above the we would scale row 6, col 6 (V[6,6]) by .5 * .5 = .25.<br/> | |
− | The row & column | + | Note that while they look like floating point parameters above they really now only |
− | Note that while they look like floating point | + | |
have 3 bit accuracy so the only actual values used are 0, {{Frac|1|8}}, {{Frac|1|4}}, {{Frac|3|8}} ... 1.0. But you can specify any value and it will be rounded to the nearest one. | have 3 bit accuracy so the only actual values used are 0, {{Frac|1|8}}, {{Frac|1|4}}, {{Frac|3|8}} ... 1.0. But you can specify any value and it will be rounded to the nearest one. | ||
+ | <br> | ||
+ | <br> | ||
+ | :<code>DCTFilter</code> is just an alias for <code>DCTFilter8</code> for backward compatibility. | ||
+ | :{{Template:FuncDef|DCTFilter8 (clip, float, float, float, float, float, float, float, float, float "x40", float "x41", float "x42", float "x43", int "chroma", int "opt")}} | ||
+ | :{{Template:FuncDef|DCTFilter (clip, float, float, float, float, float, float, float, float, float "x40", float "x41", float "x42", float "x43", int "chroma", int "opt")}} | ||
+ | <br> | ||
+ | ::{{Par2| |clip| }} | ||
+ | :::All planar formats(8/10/12/14/16bit and float, YUV/RGB with or without alpha) are supported. | ||
+ | <br> | ||
+ | ::{{Par2| |float| }} | ||
+ | :::There are 8 positional floating point parameters, all of which must be specified as in the range (0.0 <= x <= 1.0). | ||
+ | :::These correspond to scaling factors for the 8 rows and columns of the 8x8 DCT blocks. | ||
+ | :::The leftmost parameter corresponds to the top row, left column. This would be the DC component of the transform and should always be left as 1.0. | ||
+ | <br> | ||
+ | ::{{Par2|x40|float|1.0}} | ||
+ | ::{{Par2|x41|float|1.0}} | ||
+ | ::{{Par2|x42|float|1.0}} | ||
+ | ::{{Par2|x43|float|1.0}} | ||
+ | :::If planes's width and/or plane's height is not mod 8 but mod 4, DCTFilter8 execute 4x4 DCT to the most right/bottom 4 columns/rows. | ||
+ | :::These correspond to scaling factors for the 4 rows and columns of the 4x4 DCT blocks. The leftmost parameter corresponds to the top row, left column. | ||
+ | <br> | ||
+ | ::{{Par2|chroma|int|1}} | ||
+ | :::Chroma processing: | ||
+ | ::::*0 = copy from source (on RGB, B and R planes are copied). | ||
+ | ::::*1 = process (default) | ||
+ | ::::*2 = do not process nor copy, output will be trash. | ||
+ | ::::Note: alpha channel will always be copied. | ||
+ | <br> | ||
+ | ::{{Par2|opt|int|MAX_INT}} | ||
+ | :::Choose which DCT to use (if you want to compare). Do not use fdct=2 or idct=3, it may crash! | ||
+ | ::::*Specify which CPU optimization are used. | ||
+ | ::::*0 = use c++ routine. | ||
+ | ::::*1 = use SSE2 + SSE routine if possible. when SSE2 can't be used, fallback to 0. | ||
+ | ::::*2 = use SSE4.1 + SSE2 + SSE routine if possible. when SSE4.1 can't be used, fallback to 1. | ||
+ | ::::*others = use AVX2 + FMA3 + AVX routine if possible. WHen AVX2 can't be used, fallback to 2.(default) | ||
+ | <br> | ||
+ | ::<span style="color:red">'''Note:'''</span> the first 9 parameters are unnamed and do not have a default so they must be specified. | ||
<br> | <br> | ||
------------- | ------------- | ||
<br> | <br> | ||
− | === | + | |
− | + | === DctFilter8D === | |
− | In an 8x8 DCT result matrix there are 15 possible diagonals (visualize a chess board), so if you specify <code> | + | DctFilter8D works similar to DctFilter8 but will zero out DiagCt number of the lower right diagonals of the DCT, leaving other values unchanged. <br/> |
+ | In an 8x8 DCT result matrix there are 15 possible diagonals (visualize a chess board), so if you specify <code>DctFilter8D(4)</code> then the 4 diagonals in the lower right corner of the DCT result will be set to 0. | ||
<br> | <br> | ||
<br> | <br> | ||
− | :{{Template:FuncDef| | + | :<code>DCTFilterD</code> is just an alias for <code>DCTFilter8D</code> for backward compatibility. |
+ | :{{Template:FuncDef|DCTFilter8D (clip, int diagonals_count, int "x4", int "chroma", int "opt")}} | ||
+ | :{{Template:FuncDef|DCTFilterD (clip, int diagonals_count, int "x4", int "chroma", int "opt")}} | ||
<br> | <br> | ||
::{{Par2| |clip| }} | ::{{Par2| |clip| }} | ||
− | :::Input clip. | + | :::Input clip, same as DCTFilter8. |
− | + | <br> | |
::{{Par2| |int| }} | ::{{Par2| |int| }} | ||
− | ::: | + | :::<tt>'''diagonals_count'''</tt>: must be an integer from 1-14 saying how many of these diagonals must be zeroed, starting from the lower right hand corner. |
+ | <br> | ||
+ | ::{{Par2|x4|int|1}} | ||
+ | :::diagonals count for 4x4DCT. | ||
+ | :::*1 <= x <= 6, default=1 | ||
+ | <br> | ||
+ | ::{{Par2|chroma|int|1}} | ||
+ | :::same as DCTFilter8. | ||
+ | <br> | ||
+ | ::{{Par2|opt|int|MAX_INT}} | ||
+ | :::same as DCTFilter8. | ||
+ | <br> | ||
+ | ::<span style="color:red">'''Note:'''</span> the first 2 parameters are unnamed and do not have a default so they must be specified. | ||
<br> | <br> | ||
------------- | ------------- | ||
<br> | <br> | ||
− | === | + | === DCTFilter4 === |
− | + | Execute a 4x4 DCT to a clip. | |
<br/> | <br/> | ||
<br/> | <br/> | ||
− | :{{Template:FuncDef| | + | :{{Template:FuncDef|DCTFilter4 (clip, float, float, float, float, int "chroma", int "opt")}} |
+ | <br> | ||
+ | ::{{Par2| |clip| }} | ||
+ | :::Input clip, same as DCTFilter8. | ||
+ | <br> | ||
+ | ::{{Par2| |float| }} | ||
+ | ::{{Par2| |float| }} | ||
+ | ::{{Par2| |float| }} | ||
+ | ::{{Par2| |float| }} | ||
+ | :::There are 4 positional floating point parameters, all of which must be specified as in the range (0.0 <= x <= 1.0). | ||
+ | :::These correspond to scaling factors for the 4 rows and columns of the 4x4 DCT blocks. The leftmost parameter corresponds to the top row, left column. | ||
+ | :::This would be the DC component of the transform and should always be left as 1.0. | ||
+ | <br> | ||
+ | ::{{Par2|chroma|int|1}} | ||
+ | :::same as DCTFilter8. | ||
+ | <br> | ||
+ | ::{{Par2|opt|int|MAX_INT}} | ||
+ | :::same as DCTFilter8. | ||
+ | <br> | ||
+ | ::<span style="color:red">'''Note:'''</span> the first 5 parameters are unnamed and do not have a default so they must be specified. | ||
+ | <br> | ||
+ | ------------- | ||
+ | <br> | ||
+ | |||
+ | === DctFilter4D === | ||
+ | <br> | ||
+ | :{{Template:FuncDef|DCTFilter4D (clip, int diagonals_count, int "chroma", int "opt")}} | ||
+ | <br> | ||
+ | ::{{Par2| |clip| }} | ||
+ | :::Input clip, same as DCTFilter8. | ||
+ | <br> | ||
+ | ::{{Par2| |int| }} | ||
+ | :::<tt>'''diagonals_count'''</tt>: must be an integer from 1-6 saying how many of these diagonals must be zeroed, starting from the lower right hand corner. | ||
+ | <br> | ||
+ | ::{{Par2|chroma|int|1}} | ||
+ | :::same as DCTFilter8. | ||
+ | <br> | ||
+ | ::{{Par2|opt|int|MAX_INT}} | ||
+ | :::same as DCTFilter8. | ||
+ | <br> | ||
+ | ::<span style="color:red">'''Note:'''</span> the first 2 parameters are unnamed and do not have a default so they must be specified. | ||
<br> | <br> | ||
== Examples == | == Examples == | ||
− | + | ====DctFilter==== | |
+ | The following example should effectively do nothing: | ||
[[AviSource]]("blah.avi") | [[AviSource]]("blah.avi") | ||
− | DctFilter(1,1,1, | + | DctFilter(1,1,1,1,1,1,1,1) |
+ | <br> | ||
+ | Subtle softening: | ||
+ | DctFilter(1,1,1,1,1,0.75,0.25,0) | ||
<br> | <br> | ||
− | + | Remove high frequency components:[http://forum.doom9.org/showpost.php?p=298519&postcount=31] | |
− | + | DctFilter(1,1,1,.8,.4,0,0,0) #these settings may be prone to slight blocking | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<br> | <br> | ||
Measure luma variance within block (e.g. 8x8) of pixels?[http://forum.doom9.org/showthread.php?p=1689130#post1689130]<br/> | Measure luma variance within block (e.g. 8x8) of pixels?[http://forum.doom9.org/showthread.php?p=1689130#post1689130]<br/> | ||
Line 82: | Line 176: | ||
mt_edge("min/max", 0, 255, 0, 255).mt_lut("x 5 *") | mt_edge("min/max", 0, 255, 0, 255).mt_lut("x 5 *") | ||
DctFilter(1,0,0,0,0,0,0,0).[[GreyScale|Greyscale]]() | DctFilter(1,0,0,0,0,0,0,0).[[GreyScale|Greyscale]]() | ||
+ | <br> | ||
+ | ====DctFilterD==== | ||
+ | DctFilterD can be used as a fast way to average 8x8 blocks:[http://forum.doom9.org/showthread.php?p=1051452#post1051452] | ||
+ | DCTFilterD(14)<br/> | ||
+ | #DctFilter(1,0,0,0,0,0,0,0) #keeps the topmost line and leftmost row.[http://forum.doom9.org/showthread.php?p=626365#post626365] | ||
+ | <br> | ||
+ | Very easy way to get the normalized SAD over 8x8 blocks:[http://forum.doom9.org/showthread.php?t=150923] | ||
+ | mt_lutxy(clip1,clip2,"x y - abs") | ||
+ | DctFilterD(14) | ||
<br> | <br> | ||
== Changelog == | == Changelog == | ||
− | Version Date | + | Version Date Changes<br> |
− | v0. | + | v0.5.1 2020/05/13 - Changes by asd-g |
− | v0.0 | + | - Update to AviSynth+'s v8 interface |
− | v0.0 | + | v0.5.0 2016/08/17 - add avs+'s new colorspaces support. |
− | + | v0.4.0 2016/08/03 - add 4x4 DCT mode. | |
− | + | - also add DCTFilter4(), DCTFilter4D | |
− | + | v0.3.0 2016/08/01 - add avs2.6 support | |
− | + | - add version resource. | |
− | + | v0.2.0 2016/08/01 - add SSE4.1 code and more optimization. | |
− | + | v0.1.0 2016/07/31 - add "DCTFilterD" | |
− | + | - optimized SIMD code. | |
− | + | v0.0.1 2016/07/31 - fix wrong chroma processing. | |
− | + | v0.0.0 2016/07/31 - Initial release | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<br> | <br> | ||
== External Links == | == External Links == | ||
− | *[ | + | *[https://github.com/chikuzen/DCTFilter GitHub] - Source code repository. |
− | *[http://forum.doom9.org/showthread.php? | + | *[https://github.com/Asd-g/DCTFilter GitHub] - Source code repository (update). |
+ | *[http://forum.doom9.org/showthread.php?t=171039 Doom9 Forum] - DctFilter VapourSynth port. | ||
<br> | <br> | ||
<br> | <br> | ||
----------------------------------------------- | ----------------------------------------------- | ||
− | '''Back to [[External_filters# | + | '''Back to [[External_filters#Spatial_Denoisers|External Filters]] ←''' |
+ | <!-- <pre> | ||
+ | DCTFilter(v1,v2,v3,v4,v5,v6,v7,v8) then: | ||
+ | |||
+ | 0 1 2 3 4 5 6 7 | ||
+ | ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ | ||
+ | 0 │v1*v1│v2*v1│v3*v1│v4*v1│v5*v1│v6*v1│v7*v1│v8*v1│ | ||
+ | ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ | ||
+ | 1 │v1*v2│v2*v2│v3*v2│v4*v2│v5*v2│v6*v2│v7*v2│v8*v2│ | ||
+ | ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ | ||
+ | 2 │v1*v3│v2*v3│v3*v3│v4*v3│v5*v3│v6*v3│v7*v3│v8*v3│ | ||
+ | ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ | ||
+ | 3 │v1*v4│v2*v4│v3*v4│v4*v4│v5*v4│v6*v4│v7*v4│v8*v4│ | ||
+ | ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ | ||
+ | 4 │v1*v5│v2*v5│v3*v5│v4*v5│v5*v5│v6*v5│v7*v5│v8*v5│ | ||
+ | ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ | ||
+ | 5 │v1*v6│v2*v6│v3*v6│v4*v6│v5*v6│v6*v6│v7*v6│v8*v6│ | ||
+ | ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ | ||
+ | 6 │v1*v7│v2*v7│v3*v7│v4*v7│v5*v7│v6*v7│v7*v7│v8*v7│ | ||
+ | ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ | ||
+ | 7 │v1*v8│v2*v8│v3*v8│v4*v8│v5*v8│v6*v8│v7*v8│v8*v8│ | ||
+ | └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ | ||
+ | |||
+ | |||
+ | so DctFilter(1,1,1,1,1,1,.5,0) becomes: | ||
+ | |||
+ | ┌───┬───┬───┬───┬───┬───┬───┬───┐ | ||
+ | │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │0.5│ 0 │ | ||
+ | ├───┼───┼───┼───┼───┼───┼───┼───┤ | ||
+ | │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │0.5│ 0 │ | ||
+ | ├───┼───┼───┼───┼───┼───┼───┼───┤ | ||
+ | │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │0.5│ 0 │ | ||
+ | ├───┼───┼───┼───┼───┼───┼───┼───┤ | ||
+ | │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │0.5│ 0 │ | ||
+ | ├───┼───┼───┼───┼───┼───┼───┼───┤ | ||
+ | │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │0.5│ 0 │ | ||
+ | ├───┼───┼───┼───┼───┼───┼───┼───┤ | ||
+ | │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │0.5│ 0 │ | ||
+ | ├───┼───┼───┼───┼───┼───┼───┼───┤ | ||
+ | │0.5│0.5│0.5│0.5│0.5│0.5│.25│ 0 │ | ||
+ | ├───┼───┼───┼───┼───┼───┼───┼───┤ | ||
+ | │ 0 │ 0 │ 0 │ 0 │ 0 │ 0 │ 0 │ 0 │ | ||
+ | └───┴───┴───┴───┴───┴───┴───┴───┘ | ||
+ | </pre> | ||
+ | In the example above the highest frequency components in each row and column are zeroed while the 2nd highest are cut in half.<br> | ||
+ | The row & column parameters are multiplied together to get the scale factor for each of the 64 values in a block. So if the top left value was V[0,0] then in the example above the we would scale row 6, col 6 (V[6,6]) by .5 * .5 = .25.<br/> | ||
+ | Note that while they look like floating point parameters above they really now only | ||
+ | have 3 bit accuracy so the only actual values used are 0, {{Frac|1|8}}, {{Frac|1|4}}, {{Frac|3|8}} ... 1.0. But you can specify any value and it will be rounded to the nearest one. | ||
+ | --> |
Latest revision as of 21:27, 25 June 2020
Abstract | |
---|---|
Author | Chikuzen |
Version | v0.5.1 |
Download | DCTFilter-0.5.1.7z |
Category | Other filters |
License | GPLv2 |
Discussion | Doom9 Forum |
Contents |
[edit] Description
DctFiler is a filter that, for each 8x8 block, will do a Discrete Cosine Transform (DCT), scale down the selected frequency values, and then reverse the process with an Inverse Discrete Cosine Transform (IDCT).
This version is a rewrite of the original DctFilter by Tom Barry.
[edit] Requirements
- [x86]: AviSynth+ or AviSynth 2.6
- [x64]: AviSynth+
- Supported color formats: Y8, YV12, YV16, YV24
- AviSynth+: all planar formats (8/10/12/14/16/32-bit, Y, YUV(A), and RGB(A) with or without alpha) are supported.
- Windows Vista SP2 or later
- SSE2 capable CPU
- Microsoft Visual C++ 2015 Redistributable Package (x86 / x64)
- *** vcredist_x86.exe is required for DctFilter-x86
- *** vcredist_x64.exe is required for DctFilter-x64
[edit] Syntax and Parameters
[edit] DctFilter
Execute an 8x8 DCT to a clip.
For each 8x8 block it will do a Discrete Cosine Transform (DCT), scale down the selected frequency values, and then reverse the process with an Inverse Discrete Cosine Transform (IDCT).
In the following example the highest frequency components in each row and column will be zeroed while the 2nd highest would be cut in half.
DctFilter(1,1,1,1,1,1,.5,0)
The row & column parameters are multiplied together to get the scale factor for each of the 64 values in a block. So if the top left value was V[0,0] then in the example above the we would scale row 6, col 6 (V[6,6]) by .5 * .5 = .25.
Note that while they look like floating point parameters above they really now only
have 3 bit accuracy so the only actual values used are 0, 1/8, 1/4, 3/8 ... 1.0. But you can specify any value and it will be rounded to the nearest one.
DCTFilter
is just an alias forDCTFilter8
for backward compatibility.- DCTFilter8 (clip, float, float, float, float, float, float, float, float, float "x40", float "x41", float "x42", float "x43", int "chroma", int "opt")
- DCTFilter (clip, float, float, float, float, float, float, float, float, float "x40", float "x41", float "x42", float "x43", int "chroma", int "opt")
- clip =
- All planar formats(8/10/12/14/16bit and float, YUV/RGB with or without alpha) are supported.
- clip =
- float =
- There are 8 positional floating point parameters, all of which must be specified as in the range (0.0 <= x <= 1.0).
- These correspond to scaling factors for the 8 rows and columns of the 8x8 DCT blocks.
- The leftmost parameter corresponds to the top row, left column. This would be the DC component of the transform and should always be left as 1.0.
- float =
- float x40 = 1.0
- float x41 = 1.0
- float x42 = 1.0
- float x43 = 1.0
- If planes's width and/or plane's height is not mod 8 but mod 4, DCTFilter8 execute 4x4 DCT to the most right/bottom 4 columns/rows.
- These correspond to scaling factors for the 4 rows and columns of the 4x4 DCT blocks. The leftmost parameter corresponds to the top row, left column.
- float x40 = 1.0
- int chroma = 1
- Chroma processing:
- 0 = copy from source (on RGB, B and R planes are copied).
- 1 = process (default)
- 2 = do not process nor copy, output will be trash.
- Note: alpha channel will always be copied.
- Chroma processing:
- int chroma = 1
- int opt = MAX_INT
- Choose which DCT to use (if you want to compare). Do not use fdct=2 or idct=3, it may crash!
- Specify which CPU optimization are used.
- 0 = use c++ routine.
- 1 = use SSE2 + SSE routine if possible. when SSE2 can't be used, fallback to 0.
- 2 = use SSE4.1 + SSE2 + SSE routine if possible. when SSE4.1 can't be used, fallback to 1.
- others = use AVX2 + FMA3 + AVX routine if possible. WHen AVX2 can't be used, fallback to 2.(default)
- Choose which DCT to use (if you want to compare). Do not use fdct=2 or idct=3, it may crash!
- int opt = MAX_INT
- Note: the first 9 parameters are unnamed and do not have a default so they must be specified.
[edit] DctFilter8D
DctFilter8D works similar to DctFilter8 but will zero out DiagCt number of the lower right diagonals of the DCT, leaving other values unchanged.
In an 8x8 DCT result matrix there are 15 possible diagonals (visualize a chess board), so if you specify DctFilter8D(4)
then the 4 diagonals in the lower right corner of the DCT result will be set to 0.
DCTFilterD
is just an alias forDCTFilter8D
for backward compatibility.- DCTFilter8D (clip, int diagonals_count, int "x4", int "chroma", int "opt")
- DCTFilterD (clip, int diagonals_count, int "x4", int "chroma", int "opt")
- clip =
- Input clip, same as DCTFilter8.
- clip =
- int =
- diagonals_count: must be an integer from 1-14 saying how many of these diagonals must be zeroed, starting from the lower right hand corner.
- int =
- int x4 = 1
- diagonals count for 4x4DCT.
- 1 <= x <= 6, default=1
- diagonals count for 4x4DCT.
- int x4 = 1
- int chroma = 1
- same as DCTFilter8.
- int chroma = 1
- int opt = MAX_INT
- same as DCTFilter8.
- int opt = MAX_INT
- Note: the first 2 parameters are unnamed and do not have a default so they must be specified.
[edit] DCTFilter4
Execute a 4x4 DCT to a clip.
- DCTFilter4 (clip, float, float, float, float, int "chroma", int "opt")
- clip =
- Input clip, same as DCTFilter8.
- clip =
- float =
- float =
- float =
- float =
- There are 4 positional floating point parameters, all of which must be specified as in the range (0.0 <= x <= 1.0).
- These correspond to scaling factors for the 4 rows and columns of the 4x4 DCT blocks. The leftmost parameter corresponds to the top row, left column.
- This would be the DC component of the transform and should always be left as 1.0.
- float =
- int chroma = 1
- same as DCTFilter8.
- int chroma = 1
- int opt = MAX_INT
- same as DCTFilter8.
- int opt = MAX_INT
- Note: the first 5 parameters are unnamed and do not have a default so they must be specified.
[edit] DctFilter4D
- DCTFilter4D (clip, int diagonals_count, int "chroma", int "opt")
- clip =
- Input clip, same as DCTFilter8.
- clip =
- int =
- diagonals_count: must be an integer from 1-6 saying how many of these diagonals must be zeroed, starting from the lower right hand corner.
- int =
- int chroma = 1
- same as DCTFilter8.
- int chroma = 1
- int opt = MAX_INT
- same as DCTFilter8.
- int opt = MAX_INT
- Note: the first 2 parameters are unnamed and do not have a default so they must be specified.
[edit] Examples
[edit] DctFilter
The following example should effectively do nothing:
AviSource("blah.avi") DctFilter(1,1,1,1,1,1,1,1)
Subtle softening:
DctFilter(1,1,1,1,1,0.75,0.25,0)
Remove high frequency components:[1]
DctFilter(1,1,1,.8,.4,0,0,0) #these settings may be prone to slight blocking
Measure luma variance within block (e.g. 8x8) of pixels?[2]
The easiest somewhat correct "amount of variation for each block" you can get is using STD for each pixel and applying DctFilter to it (adjust the radius of STD calculation area for possibly better results).
mt_luts(last, "std", mt_square(1), "y").mt_lut("x 15 *") DctFilter(1,0,0,0,0,0,0,0).Greyscale()
A reasonably close approximation with a lot better performance is an edge mask:
mt_edge("min/max", 0, 255, 0, 255).mt_lut("x 5 *") DctFilter(1,0,0,0,0,0,0,0).Greyscale()
[edit] DctFilterD
DctFilterD can be used as a fast way to average 8x8 blocks:[3]
DCTFilterD(14)
#DctFilter(1,0,0,0,0,0,0,0) #keeps the topmost line and leftmost row.[4]
Very easy way to get the normalized SAD over 8x8 blocks:[5]
mt_lutxy(clip1,clip2,"x y - abs") DctFilterD(14)
[edit] Changelog
Version Date Changes
v0.5.1 2020/05/13 - Changes by asd-g - Update to AviSynth+'s v8 interface v0.5.0 2016/08/17 - add avs+'s new colorspaces support. v0.4.0 2016/08/03 - add 4x4 DCT mode. - also add DCTFilter4(), DCTFilter4D v0.3.0 2016/08/01 - add avs2.6 support - add version resource. v0.2.0 2016/08/01 - add SSE4.1 code and more optimization. v0.1.0 2016/07/31 - add "DCTFilterD" - optimized SIMD code. v0.0.1 2016/07/31 - fix wrong chroma processing. v0.0.0 2016/07/31 - Initial release
[edit] External Links
- GitHub - Source code repository.
- GitHub - Source code repository (update).
- Doom9 Forum - DctFilter VapourSynth port.
Back to External Filters ←