From 1dcca19ae0503fdf57f285028c5ec04beb272c6b Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Sat, 13 Sep 2014 08:06:39 -0700 Subject: [PATCH] because of we divide by /255 not /256, we lose numerical precision, so can't guarantee that box filter results round to same results as naive --- tests/resample_test.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/resample_test.cpp b/tests/resample_test.cpp index 335025f..1938c2c 100644 --- a/tests/resample_test.cpp +++ b/tests/resample_test.cpp @@ -155,7 +155,7 @@ static void performance(int argc, char **argv) out_w = w*2; out_h = h/4; count=20; // 2 // note this is structured pessimily, would be much faster to downsample vertically first #elif 0 out_w = w/4; out_h = h*2; count=50; // 3 - #elif 0 + #elif 1 out_w = w*3; out_h = h*3; count=5; srgb=0; // 4 #else out_w = w*3; out_h = h*3; count=3; // 5 // this is dominated by linear->sRGB conversion @@ -181,7 +181,7 @@ int main(int argc, char** argv) int out_w, out_h, out_stride; //resizer(argc, argv); - performance(argc, argv); + //performance(argc, argv); #if 1 test_suite(argc, argv); @@ -648,10 +648,10 @@ void verify_box(void) + image88[j*2+0][i*2+1] + image88[j*2+1][i*2+0] + image88[j*2+1][i*2+1]; - STBIR_ASSERT(output44[j][i] == ((n+2)>>2)); + STBIR_ASSERT(output44[j][i] == ((n+2)>>2) || output44[j][i] == ((n+1)>>2)); // can't guarantee exact rounding due to numerical precision t += n; } - STBIR_ASSERT(output11[0][0] == ((t+32)>>6)); + STBIR_ASSERT(output11[0][0] == ((t+32)>>6) || output11[0][0] == ((t+31)>>6)); // can't guarantee exact rounding due to numerical precision } void verify_filter_normalized(stbir_filter filter, int output_size, unsigned int value) @@ -675,6 +675,8 @@ void test_filters(void) { int i,j; + mtsrand(0); + for (i=0; i < sizeof(image88); ++i) image88[0][i] = mtrand() & 255; verify_box();