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

Use noncustom kernel when possible #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sgt0
Copy link
Contributor

@sgt0 sgt0 commented Nov 24, 2024

descale.Decustom init is slow and AFAICT it's only being used for symmetry with resize2.Custom, which itself was introduced to enable setting blur (am I missing something else?). If that's the case, then everything is being made slower just for the (probably) few cases of blur usage. This hurts the native-res plugin especially.

With this change, things work like so:

  1. If descaling, always use descale.Debicubic/descale.Debilinear. They support blur so there should be no need for custom kernels.
  2. If scaling/resampling, use resize2.Bicubic/resize2.Bilinear if blur is not set to the default of 1.0. This isn't here to speed anything up, rather it just seems like a good idea to use the plugin's available filters when possible instead of custom ones.
  3. Otherwise, use the slower custom kernels since blur is needed and not provided by the plugin.

With this, native-res execution (height [502, 999], step size 1, Catrom) goes from ~3 minutes to ~30 seconds. If we like this approach and it works well then we can bring it to the other kernels.

@sgt0 sgt0 force-pushed the bicubic-bilinear-prefer-noncustom branch from 4acca74 to 57b31cb Compare November 24, 2024 22:40
@sgt0 sgt0 changed the title Use noncustom kernel when possible in bicubic and bilinear Use noncustom kernel when possible Nov 24, 2024
`descale.Decustom` init is slow and AFAICT it's only being used for
symmetry with `resize2.Custom`, which itself was introduced to enable
setting `blur` (am I missing something else?). If that's the
case, then everything is being made slower just for the (probably) few
cases of blur usage. This hurts the native-res plugin especially.

With this change, things work like so:

1. If descaling, always use `descale.Debicubic`/`descale.Debilinear`.
  They support `blur` so there should be no need for custom kernels.
2. If scaling/resampling, use `resize2.Bicubic`/`resize2.Bilinear` if
  `blur` is not set to the default of 1.0. This isn't here to speed
  anything up, rather it just seems like a good idea to use the plugin's
  available filters when possible instead of custom ones.
3. Otherwise, use the slower custom kernels since blur is needed and not
  provided by the plugin.

With this, native-res execution (height [502, 999], step size 1, Catrom)
goes from ~3 minutes to ~30 seconds.
@sgt0 sgt0 force-pushed the bicubic-bilinear-prefer-noncustom branch from 57b31cb to c4b6ce8 Compare November 24, 2024 22:42
@sgt0
Copy link
Contributor Author

sgt0 commented Nov 24, 2024

Updated to cover lanczos and the splines as well. Moved the logic into CustomComplexKernel to avoid a lot of duplication. It's not as pretty since that class is supposed to be generic but I didn't see any better options besides maybe yet another class.

@emotion3459
Copy link
Member

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

Successfully merging this pull request may close these issues.

2 participants