Giter VIP home page Giter VIP logo

vs-kernels's Introduction

vs-kernels

Read the Docs PyPI - Python Version PyPI GitHub commits since tagged version PyPI - License Discord

Kernels are a collection of wrappers pertaining to (de)scaling, format conversion, and other related operations, all while providing a consistent and clean interface. This allows for easy expansion and ease of use for any other maintainers who wishes to use them in their own functions.

You can create presets for common scaling algorithms or settings, while ensuring the interface will always remain the same, even across different plugins with their own settings and expected behavior.

For support you can check out the JET Discord server.

How to install

Install vskernels with the following command:

pip install vskernels --no-cache-dir -U

Or if you want the latest git version, install it with this command:

pip install git+https://github.com/Jaded-Encoding-Thaumaturgy/vs-kernels.git --no-cache-dir -U

vs-kernels's People

Contributors

lightarrowsexe avatar nsqy avatar setsugennoao avatar yuv420p10le avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vs-kernels's Issues

vskernels issue list

  • Make width/height optional arguments to allow 1x resampling with non-interpolatory kernels without manually specifying w/h.
  • add "match centers" resampling model.
  • Implement blur aka resizeable filter curves.

Properly handle interlaced descaling

When using descale, if the input clip is not Progressive, it needs to split per-field and descale each field separately to half the height, and these shifts must be applied by default unless the user passes their own shift (so the default of (0, 0) should probably be changed to None)

first field = 0.25 / (clip.height / (output_height / 2))
second_field = -0.25 / (clip.height / (output_height / 2))

Placebo kernels limitations

Radius, param1, param2, and wparam are not configurable.

Scalings that are possible using the plugin directly are not possible within vskernels
For example:
clip = vskernels.EwaRobidoux(b=50, c=50).scale(clip, 960, 540) will error with TypeError: Placebo.__init__() got multiple values for argument 'b'
but
clip = core.placebo.Resample(clip, 960, 540, filter="ewa_robidoux", param1=50, param2=50) works just fine.

placebo kernels return nonetype

>>> from vstools import vs, core; from vskernels import EwaHann, Spline64
>>> blank = core.std.BlankClip()
>>> [type(kernel().scale(blank, 10, 10)) for kernel in (EwaHann, Spline64)]
[<class 'NoneType'>, <class 'vapoursynth.VideoNode'>]

Spline100-Spline256 are not the actual Spline100-256 kernels

Fmtconv's spline works differently from the Spline100, Spline144, etc resizers found in other applications, they do not produce the same results. These kernels can be seen as entirely different and as such they should be made to match the original Spline kernels or just removed entirely.

Feature Request: Automatically use value_zimg for ColorRange provided in resample calls

from vstools import vs, initialize_clip, Matrix, Transfer, Primaries, ColorRange
from vskernels import Point

reference = vs.core.imwri.Read("reference.png")
reference = initialize_clip(reference, None)
limited_range_yuv = Point.resample(reference, range=ColorRange.FULL, matrix=Matrix.BT709, transfer=Transfer.BT709, format=vs.YUV444P8)

This script currently produces limited range output since the zimg values do not match the frameprop values. Using range=ColorRange.FULL.value_zimg does produce a full range output, but it would be more convenient and foolproof if the value_zimg could be automatically used when providing a ColorRange

placebo.Resample support

The main benefit here would be elliptical (EWA) kernel support, such as ewa_lanczos or ewa_robidoux*. From memory Robidoux kernels were originally intended to be EWA, there are posts on the imagemagick forum about this but I cannot find them at the moment.

With the placebo.Resample plugin, make sure not to accidentally use the 'bicubic' filter -- it's actually some kind of 'fast' bicubic kernel which is extremely blurry and not configurable.

EWA kernels in various.py

All the EWA kernels give AttributeError: module 'vskernels' has no attribute 'EWALanczos' in VSEditor. Other kernels in various.py and Lanczos in resize.py have no issue.

Deprecate questionable bicubic presets

These Bicubic presets are very questionable, producing poor results, with some of them even being literal shitposts that were kept anyways.

Bicubic Zopti variants specifically are auto generated bicubic presets based on poor metrics that were never even investigated through human eyes.

Users can still use these kernels through manually setting b/c, but their time as a preset should be coming to an end.

Expand cross conversion shifting params

Currently it's not clear to me whether we can really affect the shift introduced during the resampling of interlaced video.

top_shift, field_shift = de_kwargs.get('src_top', 0.0), 0.125 * height / clip.height
fields = clip.std.SeparateFields(field_based.is_tff)
interleaved = core.std.Interleave([
self.descale_function(fields[offset::2], **(de_kwargs | dict(src_top=top_shift + (field_shift * mult))))
for offset, mult in [(0, 1), (1, -1)]
])

Specifically, some implementations may improperly shift the fields in the same direction (@wiwaz can clarify or correct me here), however currently, to my understanding, there's no way to follow this behaviour, making it impossible to descale it the same way unless you separate the fields yourself. This is rather impractical in certain situations where you have to check different kernels for every frame. Having some kind of way to either override these parameters or toggle between different directions and the same direction would be nice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.