Metadata-Version: 2.4
Name: vapoursynth-cdef
Version: 1.0.0
Summary: VapourSynth port of Constrained Directional Enhancement Filter
Keywords: VapourSynth
Author-Email: Akatsumekusa <Akatsumekusa@protonmail.com>
License-File: LICENSE
License-File: PATENTS
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: C++
Classifier: Topic :: Multimedia :: Video
Project-URL: Documentation, https://github.com/Akatmks/vapoursynth-cdef
Project-URL: Issues, https://github.com/Akatmks/vapoursynth-cdef/issues
Project-URL: Source, https://github.com/Akatmks/vapoursynth-cdef
Requires-Python: >=3.8
Requires-Dist: vapoursynth
Description-Content-Type: text/markdown

<h1 align="center">vapoursynth-cdef</h1>

VapourSynth port of Constrained Directional Enhancement Filter.  

### Usage

```py
from vscdef import cdef

clip = cdef(clip)
```

### Reference

The Python wrapper `vscdef.cdef` provides exactly the same features as the VapourSynth plugin `core.cdef.CDEF`.  
However, the VapourSynth plugin requires 12-bit or 10-bit integer input, and requires mod8 input. The Python wrapper converts it for you.  

```py
cdef(
    clip:         vs.VideoNode,

    # All these parameters accept up to 3 integers for 3 planes
    pri_strength: int | Sequence[int] = [3, 1],
    sec_strength: int | Sequence[int] = [1, 0],
    pri_damping:  int | Sequence[int] = 2,
    sec_damping:  int | Sequence[int] = 1,
    # If the default is too strong, try disabling secondary filtering by setting `sec_strength` to `0` first.  
    # If the default is too weak, try increasing `pri_strength` (of the Y plane) first.  

    planes:       PlanesT             = [0, 1, 2]
)
```

For each parameters, check:  
* https://github.com/5fish/SVT-AV1/blob/main/Docs/Appendix-CDEF.md  
* https://arxiv.org/pdf/1602.05975  

Note that even though the AV1 codec only supports certain value ranges, the implementation itself supports a much wider range of values.  

### Examples

On a bad source with heavy mosquito noise, this might be useful.  
Note that on newer versions of vs-jetpack with MVUtensils, unfortunately the support for `SADMode.ADAPTIVE_SATD_DCT` is dropped. You can either modify it to do a different search, or rewrite it using raw MVTools calls if your setup doesn't support it.  

```py
from vsdenoise import MotionMode, MVTools, Prefilter, SADMode
from vscdef import cdef

dn = cdef(clip)

mv = MVTools(clip, search_clip=Prefilter.DFTTEST)

mv.analyze(tr=2, blksize=32, overlap=16, truemotion=MotionMode.COHERENCE, divide=2)
mv.recalculate(thsad=10, blksize=8, overlap=4, dct=SADMode.ADAPTIVE_SATD_DCT, truemotion=MotionMode.COHERENCE)

dn = mv.degrain(dn, clip, tr=2, thsad=18)
```
