DctFilter

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (External Links)
m (add Deep_color_tools category)
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
{{FilterCat4|External_filters|Plugins|Plugins_x64|Other_filters}}
+
{{FilterCat5|External_filters|Plugins|Plugins_x64|Other_filters|Deep_color_tools}}
 
{{Filter3
 
{{Filter3
 
| {{Author/Chikuzen}}
 
| {{Author/Chikuzen}}
| v0.5.0
+
| v0.5.1
|[https://github.com/chikuzen/DCTFilter/releases DCTFilter-0.5.0.zip]
+
|[https://github.com/Asd-g/DCTFilter/releases DCTFilter-0.5.1.7z]
 
| 4=Other filters
 
| 4=Other filters
 
| 5=[http://www.gnu.org/licenses/gpl-2.0.txt GPLv2]
 
| 5=[http://www.gnu.org/licenses/gpl-2.0.txt GPLv2]
Line 9: Line 9:
 
== 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).
 
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>
Line 16: Line 18:
 
* [x64]: [[AviSynth+]]
 
* [x64]: [[AviSynth+]]
 
* Supported color formats: [[Y8]], [[YV12]], [[YV16]], [[YV24]]
 
* Supported color formats: [[Y8]], [[YV12]], [[YV16]], [[YV24]]
**AviSynth+: all planar formats (8/10/12/14/16bit and float, YUV/RGB with or without alpha) are supported.
+
**AviSynth+: all [[planar]] formats (8/10/12/14/16/32-bit, Y, YUV(A), and RGB(A) with or without alpha) are supported.
 
<br>
 
<br>
 
* Windows Vista SP2 or later
 
* Windows Vista SP2 or later
 
* SSE2 capable CPU
 
* SSE2 capable CPU
* Microsoft VisualC++ Redistributable Package 2015
+
* [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>
Line 184: Line 189:
 
== Changelog ==
 
== Changelog ==
 
  Version      Date            Changes<br>
 
  Version      Date            Changes<br>
 +
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.5.0      2016/08/17      - add avs+'s new colorspaces support.
 
  v0.4.0      2016/08/03      - add 4x4 DCT mode.
 
  v0.4.0      2016/08/03      - add 4x4 DCT mode.
Line 198: Line 205:
 
== External Links ==
 
== External Links ==
 
*[https://github.com/chikuzen/DCTFilter GitHub] - Source code repository.
 
*[https://github.com/chikuzen/DCTFilter GitHub] - Source code repository.
 +
*[https://github.com/Asd-g/DCTFilter GitHub] - Source code repository (update).
 
*[http://forum.doom9.org/showthread.php?t=171039 Doom9 Forum] - DctFilter VapourSynth port.
 
*[http://forum.doom9.org/showthread.php?t=171039 Doom9 Forum] - DctFilter VapourSynth port.
 
<br>
 
<br>

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