Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filtering to new created by AVS filters transients #339

Open
DTL2020 opened this issue Feb 20, 2023 · 1 comment
Open

Add filtering to new created by AVS filters transients #339

DTL2020 opened this issue Feb 20, 2023 · 1 comment

Comments

@DTL2020
Copy link

DTL2020 commented Feb 20, 2023

This is mostly about 'geometric' core filters like LetterBox() and AddBorders() but better all other core filters need to be revised for same issue.
For Layer() and Overlay() in the case of 'picture in picture' creation is also may be applicable.

Currently the transient from original frame to new samples completely hard and unfiltered. This create overshoots and ringing depending on the resampler at the display.

In current AVS this can be workarounded with long enough scripting - cropping the transient area (each left, right, top, bottom), applying filtering (1-dimensional only) to cropped area and masked layer/overlay back at the transient area. It is expected as complete service from moving pictures processing environment like AVS (designed not for static images processing) as single filter call and not search for or creation of workaround scripting.

For better results the transient need to be filtered (perpendicular to the added border only). Test condition of correct filtering - no ringing (and mostly probably in typical use cases no overshoot too) when applying upsampling to 2..4x times or more using SincResize with taps at least 4..6 or more or LanczosResize with taps at least 8..12 or more.

The filtering may be with Gauss kernel (from GaussResize) or simple blur (from Blur() filter). As it typically not required to highlight the added transient with AddBorders of LetterBox with overshoots - so the overshoots-capable kernels like SinPow or UserDefined may be not needed in most use cases.

So it is expected in the new versions to have new param like

tw (transient width) - may be of even values only (0 - default none, 2,4,6,... - symmetrical in number of samples around new transient, or 1,2,3.. as half-width one-sided size of new filtered transient width).

and may be
tkrn - used filter kernel (Gauss only ?).
tk_param - the param for kernel to adjust its response.

Defaults for kernel and param may be adjusted to meet requirement to have non-ringing and non-overshoot (overshoot less 1 LSB of 8bit) transient from nominal white 235 to nominal limited black of 16 while use 'typical' upsampler of LanczosResize with may be taps about 3..4 when simulating display's upscaler or DAC to analog output.

In more perfect world the filtering need to be processed in linear domain and converted back after filtering to transfer domain of current clip, but it require support of transfer functions conversions. So may be need one more param of 'transfer' to override auto-detection from clip properties.

As a partial solution a simple 1-D Blur() filter may be applied to transient area but I think it have 'small support' and creates not best possible transient encoding (in number of output samples used) of about 6..8+ samples in total width. As noted in Japan ARIB STD-B28 https://www.arib.or.jp/english/html/overview/doc/6-STD-B28v1_0-E1.pdf A.5 : The number of samples to be used for the transient shall be 6 to 9, in the case of 1920 horizontal samples, although it may depend upon the scale of hardware, process performance and the so-called “make up”. (This note and reference to standard may recommended to be copied to AVS documentation as valuable data for users).

'In a perfect world' it should be possible to create 'colour bars' pattern with simple script like BlankClip(white).AddBorders(right=yellow).AddBorders(right=cyan).AddBorders(right=green)... with broadcast-graded quality transients between bars (at least at RGB 4:4:4 encoding). Though high-graded transient design require to use not simple blur but filters like UserDefined with non-zero kernel members count up to 10 and more (for HBD/HDR) and proportionally increased 'filter support'. To have more precise control over resudual over/undershoots and ringing while keeping total transient size as low as possible (rise 'distance/time' from 0.1 to 0.9 of start and end transient levels).

@DTL2020
Copy link
Author

DTL2020 commented May 6, 2023

Example of left border transient processing in C and with edge conditions handling (when convolution can run out of line edge) DTL2020/AviSynth-FillBorders@e976baf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant