X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=resample_effect_test.cpp;h=e4c23b10782c09e96fa91cd2a4cb030a7faf9c6c;hp=952553681a87834beab57618120c85c42cb661b2;hb=aa3e630eb0c455921c721f9ccd84e872bc9757bc;hpb=2b6a8585772bf9ae742a2ee36144a0cdd5ba0524 diff --git a/resample_effect_test.cpp b/resample_effect_test.cpp index 9525536..e4c23b1 100644 --- a/resample_effect_test.cpp +++ b/resample_effect_test.cpp @@ -166,3 +166,38 @@ TEST(ResampleEffectTest, UpscaleByThreeGetsCorrectPixelCenters) { } } } + +TEST(ResampleEffectTest, HeavyResampleGetsSumRight) { + const int swidth = 1280, sheight = 720; + const int dwidth = 36, dheight = 20; + + float data[swidth * sheight], out_data[dwidth * dheight], expected_data[dwidth * dheight]; + for (int y = 0; y < sheight; ++y) { + for (int x = 0; x < swidth; ++x) { + data[y * swidth + x] = 0.5f; + } + } + for (int y = 0; y < dheight; ++y) { + for (int x = 0; x < dwidth; ++x) { + expected_data[y * dwidth + x] = 0.5f; + } + } + + EffectChainTester tester(NULL, dwidth, dheight, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + + ImageFormat format; + format.color_space = COLORSPACE_sRGB; + format.gamma_curve = GAMMA_LINEAR; + + FlatInput *input = new FlatInput(format, FORMAT_GRAYSCALE, GL_FLOAT, swidth, sheight); + input->set_pixel_data(data); + + tester.get_chain()->add_input(input); + Effect *resample_effect = tester.get_chain()->add_effect(new ResampleEffect()); + ASSERT_TRUE(resample_effect->set_int("width", dwidth)); + ASSERT_TRUE(resample_effect->set_int("height", dheight)); + tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR); + + expect_equal(expected_data, out_data, dwidth, dheight, 0.001); +} +