Downsample

https://github.com/Freed-Wu/x264-dsp/tree/main/scripts provides matlab (octave), opencv, pytorch’s results of bilinear and bicubic. The bilinear results are same. The bicubic results are not same. Because bicubic depends on two factors: a and padding method.

a

cubic

  • matlab (octave)’s a is -0.5.

  • opencv and pytorch’s a is -0.75.

  • We use -0.5 because it has a fast algorithm:

a

Padding Method

Padding method document.

  • matlab (octave) use symmetric padding.

  • opencv and pytorch use reflect padding.

  • We use symmetric padding by default. You can change it by ./configure --padding=X.

Unit Test

Install check, then:

$ make check
...
PASS: check_downsample
============================================================================
Testsuite summary for x264 UNKNOWN
============================================================================
# TOTAL: 1
# PASS:  1
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================
...
$ tests/check_downsample
Running suite(s): Core
100%: Checks: 5, Failures: 0, Errors: 0