Skip to content

Commit 931d086

Browse files
backend: Don't enable Resample for unity scale
Our default Resample kernels introduce a slight sharpening even at unity scale and zero phase. Resample itself will truncate to 12-bit precision. So it's best to disable it in this case. Signed-off-by: Nick Hollinghurst <[email protected]>
1 parent 2fe9084 commit 931d086

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/libpisp/backend/backend_prepare.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,13 @@ void BackEnd::updateSmartResize()
617617
be_config_.global.rgb_enables &= ~PISP_BE_RGB_ENABLE_DOWNSCALE(i);
618618
}
619619

620-
pisp_be_resample_config resample;
621-
pisp_be_resample_extra resample_extra;
622-
memset(&resample, 0, sizeof(resample));
623-
memset(&resample_extra, 0, sizeof(resample_extra));
620+
// Don't resample by unity: it needlessly reduces bit-depth, and can over-sharpen
621+
if (resampler_input_width == resampler_output_width &&
622+
resampler_input_height == resampler_output_height)
623+
{
624+
be_config_.global.rgb_enables &= ~PISP_BE_RGB_ENABLE_RESAMPLE(i);
625+
continue;
626+
}
624627

625628
// Finally program up the resampler block.
626629
// If the following conditions are met:
@@ -634,6 +637,9 @@ void BackEnd::updateSmartResize()
634637
// on image quality for larger downscale factors.
635638
double scale_factor_x = (double)(resampler_input_width - 1) / (resampler_output_width - 1);
636639
double scale_factor_y = (double)(resampler_input_height - 1) / (resampler_output_height - 1);
640+
pisp_be_resample_config resample = {};
641+
pisp_be_resample_extra resample_extra = {};
642+
637643
if (scale_factor_x > 2.1 &&
638644
scale_factor_x < scale_factor_y * 1.1 && scale_factor_y < scale_factor_x * 1.1)
639645
{

0 commit comments

Comments
 (0)