mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 12:27:29 +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.
|
# 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) 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
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions
|
// 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
|
// Compute the unnormalized filter value at each location of the source
|
||||||
// it covers.
|
// 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;
|
for (int cur_filter_pixel = src_begin; cur_filter_pixel <= src_end;
|
||||||
cur_filter_pixel++) {
|
cur_filter_pixel++) {
|
||||||
// Distance from the center of the filter, this is the filter coordinate
|
// 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 ResizeMethodToAlgorithmMethod(
|
||||||
ImageOperations::ResizeMethod method) {
|
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 &&
|
if (method >= ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD &&
|
||||||
method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD) {
|
method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
// The call to ImageOperationsGtv::Resize() above took care of
|
// Convert any "Quality Method" into an "Algorithm Method"
|
||||||
// GPU-acceleration in the cases where it is possible. So now we just
|
|
||||||
// pick the appropriate software method for each resize quality.
|
|
||||||
switch (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:
|
case ImageOperations::RESIZE_GOOD:
|
||||||
// Users of RESIZE_BETTER are willing to trade some quality in order
|
// Users of RESIZE_GOOD are willing to trade quality to get speed.
|
||||||
// to improve performance, but are guaranteed not to devolve to a linear
|
// In visual tests we see that Hamming-1 is not as good as
|
||||||
// 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
|
||||||
// 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
|
// 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:
|
case ImageOperations::RESIZE_BETTER:
|
||||||
return ImageOperations::RESIZE_HAMMING1;
|
return ImageOperations::RESIZE_LANCZOS2;
|
||||||
default:
|
default:
|
||||||
return ImageOperations::RESIZE_LANCZOS3;
|
return ImageOperations::RESIZE_LANCZOS3;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue