X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=test_util.cpp;h=aa9cf5651aced8ef9f29e99c2ba3a093d565d3d2;hp=4e37cec3fdd82900831f5b55fa34d905b80bb4c1;hb=47d5eca6c49be8f1bfcf62b36f884d97d12ca6f0;hpb=1a595d0396e943d09a1459707785d66406deb354 diff --git a/test_util.cpp b/test_util.cpp index 4e37cec..aa9cf56 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -7,10 +7,10 @@ #include -EffectChainTester::EffectChainTester(const float *data, unsigned width, unsigned height, ColorSpace color_space, GammaCurve gamma_curve) +EffectChainTester::EffectChainTester(const float *data, unsigned width, unsigned height, MovitPixelFormat pixel_format, ColorSpace color_space, GammaCurve gamma_curve) : chain(width, height), width(width), height(height) { - add_input(data, color_space, gamma_curve); + add_input(data, pixel_format, color_space, gamma_curve); glGenTextures(1, &texnum); check_error(); @@ -34,30 +34,30 @@ EffectChainTester::EffectChainTester(const float *data, unsigned width, unsigned check_error(); } -Input *EffectChainTester::add_input(const float *data, ColorSpace color_space, GammaCurve gamma_curve) +Input *EffectChainTester::add_input(const float *data, MovitPixelFormat pixel_format, ColorSpace color_space, GammaCurve gamma_curve) { ImageFormat format; format.color_space = color_space; format.gamma_curve = gamma_curve; - FlatInput *input = new FlatInput(format, FORMAT_GRAYSCALE, GL_FLOAT, width, height); + FlatInput *input = new FlatInput(format, pixel_format, GL_FLOAT, width, height); input->set_pixel_data(data); chain.add_input(input); return input; } -void EffectChainTester::run(float *out_data, ColorSpace color_space, GammaCurve gamma_curve) +void EffectChainTester::run(float *out_data, GLenum format, ColorSpace color_space, GammaCurve gamma_curve) { - ImageFormat format; - format.color_space = color_space; - format.gamma_curve = gamma_curve; - chain.add_output(format); + ImageFormat image_format; + image_format.color_space = color_space; + image_format.gamma_curve = gamma_curve; + chain.add_output(image_format); chain.finalize(); chain.render_to_fbo(fbo, width, height); glBindFramebuffer(GL_FRAMEBUFFER, fbo); - glReadPixels(0, 0, width, height, GL_RED, GL_FLOAT, out_data); + glReadPixels(0, 0, width, height, format, GL_FLOAT, out_data); // Flip upside-down to compensate for different origin. for (unsigned y = 0; y < height / 2; ++y) { @@ -68,7 +68,7 @@ void EffectChainTester::run(float *out_data, ColorSpace color_space, GammaCurve } } -void expect_equal(const float *ref, const float *result, unsigned width, unsigned height) +void expect_equal(const float *ref, const float *result, unsigned width, unsigned height, float largest_difference_limit, float rms_limit) { float largest_difference = -1.0f; float squared_difference = 0.0f; @@ -81,9 +81,6 @@ void expect_equal(const float *ref, const float *result, unsigned width, unsigne } } - const float largest_difference_limit = 1.5 / 255.0; - const float rms_limit = 0.5 / 255.0; - EXPECT_LT(largest_difference, largest_difference_limit); float rms = sqrt(squared_difference) / (width * height);