mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
Switch to Lanczos scaling from Hamming to get acceptable fast downscaling.
In visual tests we see that Hamming-1 is not as good as Lanczos-2, however it is about 40% faster, and Lanczos-2 itself is about 30% faster than Lanczos-3. The use of Hamming-1 has been deemed an unacceptable trade-off between quality and speed due to the limited pixel space it operates in, so we pick Lanczos-2 here. On modern hardware, Lanczos-2 doesn't have any noticeable impact in normal use.
This commit is contained in:
parent
bb6204c1ec
commit
d203062c4e
2 changed files with 11 additions and 16 deletions
|
|
@ -10,4 +10,4 @@
|
|||
# hardcoded milestones in the tree from these two files.
|
||||
#--------------------------------------------------------
|
||||
|
||||
4.1.3
|
||||
4.1.4
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright (c) 2006-2012 The Chromium Authors. All rights reserved.
|
||||
// Copyright (c) 2018 Mark Straver BASc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
|
|
@ -107,7 +108,7 @@ void ComputeFilters(ImageOperations::ResizeMethod method,
|
|||
|
||||
// Compute the unnormalized filter value at each location of the source
|
||||
// it covers.
|
||||
float filter_sum = 0.0f; // Sub of the filter values for normalizing.
|
||||
float filter_sum = 0.0f; // Sum of the filter values for normalizing.
|
||||
for (int cur_filter_pixel = src_begin; cur_filter_pixel <= src_end;
|
||||
cur_filter_pixel++) {
|
||||
// Distance from the center of the filter, this is the filter coordinate
|
||||
|
|
@ -158,28 +159,22 @@ void ComputeFilters(ImageOperations::ResizeMethod method,
|
|||
|
||||
ImageOperations::ResizeMethod ResizeMethodToAlgorithmMethod(
|
||||
ImageOperations::ResizeMethod method) {
|
||||
// Convert any "Quality Method" into an "Algorithm Method"
|
||||
// If we already have an "Algorithm Method", just return that.
|
||||
if (method >= ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD &&
|
||||
method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD) {
|
||||
return method;
|
||||
}
|
||||
// The call to ImageOperationsGtv::Resize() above took care of
|
||||
// GPU-acceleration in the cases where it is possible. So now we just
|
||||
// pick the appropriate software method for each resize quality.
|
||||
// Convert any "Quality Method" into an "Algorithm Method"
|
||||
switch (method) {
|
||||
// Users of RESIZE_GOOD are willing to trade a lot of quality to
|
||||
// get speed, allowing the use of linear resampling to get hardware
|
||||
// acceleration (SRB). Hence any of our "good" software filters
|
||||
// will be acceptable, and we use the fastest one, Hamming-1.
|
||||
case ImageOperations::RESIZE_GOOD:
|
||||
// Users of RESIZE_BETTER are willing to trade some quality in order
|
||||
// to improve performance, but are guaranteed not to devolve to a linear
|
||||
// resampling. In visual tests we see that Hamming-1 is not as good as
|
||||
// Lanczos-2, however it is about 40% faster and Lanczos-2 itself is
|
||||
// Users of RESIZE_GOOD are willing to trade quality to get speed.
|
||||
// In visual tests we see that Hamming-1 is not as good as
|
||||
// Lanczos-2, however it is about 40% faster, and Lanczos-2 itself is
|
||||
// about 30% faster than Lanczos-3. The use of Hamming-1 has been deemed
|
||||
// an acceptable trade-off between quality and speed.
|
||||
// an unacceptable trade-off between quality and speed due to the limited
|
||||
// pixel space it operates in, so we pick Lanczos-2 here.
|
||||
case ImageOperations::RESIZE_BETTER:
|
||||
return ImageOperations::RESIZE_HAMMING1;
|
||||
return ImageOperations::RESIZE_LANCZOS2;
|
||||
default:
|
||||
return ImageOperations::RESIZE_LANCZOS3;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue