AviSynth / AviSynthPlus

AviSynth with improvements
http://avs-plus.net
963 stars 73 forks source link

Bicubic resizer bugged with non-zero crop values #390

Closed Chab-b closed 6 months ago

Chab-b commented 6 months ago

The bug was discovered with DVD-sized images (720x576) but somehow bilinear resizer is not affected, only was able to find it with bicubic one.

When cropping parameters are omitted or are set to zero - it behaves as expected. But if at least one is larger than zero - image gets progressively distorted, when it gets to 10 and more - it gets major artifacts (green white magenta "grid").

Source image test

Bicubic with zero crop 0_0_0_0

Bicubic with 9 cropped pixels from left and right side 9_0_-9_0

Bicubic with 10 cropped pixels from left and right side and 1 pixel from top and bottom 10_1_-10_-1

Using Avisynth+ 3.7.3 r4003 both x86 and x84, Win10 21H1 x64, Ryzen 9 5900x

qyot27 commented 6 months ago

You aren't passing the parameters you think you are.

BicubicResize(clip clip, int target_width, int target_height [, float b, float c,
     float src_left, float src_top, float src_width, float src_height ] ) 

The b and c parameters are not present on the other resizers, but are for BicubicResize. And because those parameters are at the beginning of the optional list rather than the end (like the taps option for some of the other resizers), it means that relying on implicit invocation of the parameters results in you setting b=10, c=1, src_left=-10, src_top=-1, and leaving src_width, and src_height undefined.

If there is any break in the parameter list for what you want to set, the options used after the break must be explicitly invoked.

BicubicResize(1008,584,src_left=10,src_top=1,src_width=-10,src_height=-1)