DctFilter

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (External Links: add link)
m (add Deep_color_tools category)
 
(18 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{FilterCat|External_filters|Plugins|Other_filters}}
+
{{FilterCat5|External_filters|Plugins|Plugins_x64|Other_filters|Deep_color_tools}}
 
{{Filter3
 
{{Filter3
| {{Author/Tom Barry}}
+
| {{Author/Chikuzen}}
| v0.0.1.5
+
| v0.5.1
|[http://dl.dropboxusercontent.com/u/54412753/doom9/DctFilter_015.zip DctFilter_015.zip]
+
|[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 an experimental 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).
+
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 2.5.8 or [http://forum.doom9.org/showthread.php?t=168764 greater]
+
* [x86]: [[AviSynth+]] or [http://forum.doom9.org/showthread.php?t=168764 AviSynth 2.6]
* Supported color formats: [[YUY2]], [[YV12]]
+
* [x64]: [[AviSynth+]]
* Width and height need to be a multiple of 16 (mod16)
+
* 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>
  
* [[MMX]], [[ISSE]] or [[SSE2]] capable CPU
 
<br>
 
== Known Issues ==
 
* [http://forum.doom9.org/showthread.php?p=1191185#post1191185 Stripe bug] - both variants are buggy at calculating DC, additional information [http://forum.doom9.org/showthread.php?p=1346201#post1346201 here] and [http://forum.doom9.org/showthread.php?p=1051452#post1051452 here].
 
 
<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>
 
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>
 
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.
Line 30: Line 39:
 
Note that while they look like floating point parameters above they really now only
 
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.
 
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>
 
<br>
 
<br>
:{{Template:FuncDef|DctFilter (clip, float, float, float, float, float, float, float, float, int "chroma", int "fdct", int "idct", int "offx", int "offy")}}
+
:<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>
 
<br>
 
::{{Par2| |clip| }}
 
::{{Par2| |clip| }}
:::Input clip.
+
:::All planar formats(8/10/12/14/16bit and float, YUV/RGB with or without alpha) are supported.
 
+
<br>
 
::{{Par2| |float| }}
 
::{{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.
+
:::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.
 
:::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}}
 
::{{Par2|chroma|int|1}}
 
:::Chroma processing:
 
:::Chroma processing:
::::*0 : do not process nor copy, output will be trash
+
::::*0 = copy from source (on RGB, B and R planes are copied).
::::*1 : process
+
::::*1 = process (default)
 
+
::::*2 = do not process nor copy, output will be trash.
::{{Par2|fdct|int|-1}}
+
::::Note: alpha channel will always be copied.
::{{Par2|idct|int|-1}}
+
<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!
 
:::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.
::::*-1 : default
+
::::*0 = use c++ routine.
::::*0 : integer (does not work correctly)
+
::::*1 = use SSE2 + SSE routine if possible. when SSE2 can't be used, fallback to 0.
::::*1 : [[MMX]]
+
::::*2 = use SSE4.1 + SSE2 + SSE routine if possible. when SSE4.1 can't be used, fallback to 1.
::::*2 : [[iSSE]]
+
::::*others = use AVX2 + FMA3 + AVX routine if possible. WHen AVX2 can't be used, fallback to 2.(default)
::::*3 : [[SSE2]]
+
 
+
::{{Par2|offx|int|0}}
+
::{{Par2|offy|int|0}}
+
:::Specify offsets, only use when the input clip's dimensions are mod16, otherwise it may crash.
+
 
<br>
 
<br>
::<span style="color:red">'''Note:'''</span> the last 5 parameters are only available in <tt>DctFilter v0.0.1.5</tt>, consider them as experimental so use with caution (except for chroma).
+
::<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>
  
=== DctFilterD ===
+
=== DctFilter8D ===
DctFilterD works similar to DctFilter but will zero out DiagCt number of the lower right diagonals of the DCT, leaving other values unchanged. <br/>
+
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>DctFilterD(4)</code> then the 4 diagonals in the lower right corner of the DCT result will be set to 0. <br/>I haven't tested this much but, like my results with custom quant tables, it appears if you set DiagCt very large you will start to get edge noise, something like ringing.[http://forum.doom9.org/showpost.php?p=266216&postcount=145]
+
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|DctFilterD (clip, int)}}
+
:<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| }}
:::"DiagCt" must be an integer from 1-14 saying how many of these diagonals must be zeroed, starting from the lower right hand corner.
+
:::<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>
=== DctAddConstant ===
+
=== DCTFilter4 ===
Not much is known about this filter...
+
Execute a 4x4 DCT to a clip.
 
<br/>
 
<br/>
 
<br/>
 
<br/>
:{{Template:FuncDef|DctAddConstant (clip, float, float, float, float)}}
+
:{{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====
 
====DctFilter====
The following example should effectively do nothing, due to a possible bug that's not the case.[http://forum.doom9.org/showthread.php?p=1191208#post1191208]
+
The following example should effectively do nothing:
 
  [[AviSource]]("blah.avi")
 
  [[AviSource]]("blah.avi")
 
  DctFilter(1,1,1,1,1,1,1,1)
 
  DctFilter(1,1,1,1,1,1,1,1)
Line 118: Line 188:
  
 
== Changelog ==
 
== Changelog ==
  Version      Date            Developer      Changes<br>
+
  Version      Date            Changes<br>
  v0.0.1.5    2007/02/09      foxyshadis     - Better memory management in DctFilter, chroma=0 to disable chroma.
+
  v0.5.1       2020/05/13     - Changes by asd-g
  v0.0.1.4    2003/02/21     Tom Barry      - Add DctFilterD, diagonal support
+
                              - Update to AviSynth+'s v8 interface
  v0.0.1.3    2003/01/30     Tom Barry      - Avisynth 2.5 beta, plugininit2, vs6
+
  v0.5.0       2016/08/17     - add avs+'s new colorspaces support.
  v0.0.1.2    2002/11/2?     SansGrip        - YUY2 support
+
  v0.4.0       2016/08/03     - add 4x4 DCT mode.
  v ?          2002/11/25     Tom Barry      - Initial test release for Avisynth 2.5 alpha only
+
                              - also add DCTFilter4(), DCTFilter4D
<br>
+
  v0.3.0       2016/08/01     - add avs2.6 support
 
+
                              - add version resource.
== Archived Downloads ==
+
  v0.2.0      2016/08/01     - add SSE4.1 code and more optimization.
{| class="wikitable" border="1"; width="600px"
+
v0.1.0      2016/07/31      - add "DCTFilterD"
|-
+
                              - optimized SIMD code.
!!width="100px"| Version
+
v0.0.1       2016/07/31      - fix wrong chroma processing.
!!width="150px"| Download
+
v0.0.0      2016/07/31      - Initial release
!!width="150px"| Mirror
+
!!width="150px"| Mirror 2
+
|-
+
!v0.0.1.4
+
|[http://web.archive.org/web/20130207143129/http://neuron2.net/trbarry/DctFilter.zip DctFilter.zip]
+
|[http://www.avisynth.nl/users/warpenterprises/files/dctfilter_5F25_dll_20030221.zip dctfilter_dll_20030221.zip]
+
|
+
|}
+
 
<br>
 
<br>
  
 
== External Links ==
 
== External Links ==
*[http://www.aquilinestudios.org/avsfilters/spatial.html#dct AquilineStudios] - Additional information on usage.
+
*[https://github.com/chikuzen/DCTFilter GitHub] - Source code repository.
*[http://forum.doom9.org/showthread.php?p=763059#post763059 Doom9Forum] - Another advanced usage example.
+
*[https://github.com/Asd-g/DCTFilter GitHub] - Source code repository (update).
*[http://forum.doom9.org/showthread.php?t=38539 Doom9 Forum] - Original DctFilter discussion.
+
*[http://forum.doom9.org/showthread.php?t=171039 Doom9 Forum] - DctFilter VapourSynth port.
*[http://forum.doom9.org/showthread.php?p=951432#post951432 Doom9 Forum] - DctFilter v0.0.1.5 discussion.
+
 
<br>
 
<br>
 
<br>
 
<br>
 
-----------------------------------------------
 
-----------------------------------------------
'''Back to [[External_filters#Edge_Detection|External Filters]] &larr;'''
+
'''Back to [[External_filters#Spatial_Denoisers|External Filters]] &larr;'''
 +
<!-- <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 &amp; 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


*** 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 for DCTFilter8 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.


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  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.


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.


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)


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 for DCTFilter8D 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.


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  x4 = 1
diagonals count for 4x4DCT.
  • 1 <= x <= 6, default=1


int  chroma = 1
same as DCTFilter8.


int  opt = MAX_INT
same as DCTFilter8.


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.


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.


int  chroma = 1
same as DCTFilter8.


int  opt = MAX_INT
same as DCTFilter8.


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.


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  chroma = 1
same as DCTFilter8.


int  opt = MAX_INT
same as DCTFilter8.


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

Personal tools