X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=test_util.cpp;h=afeb8486041487878ac666b6916db9efc12d30fd;hb=2ea2c3ea1dffa080c2f7221e50d703731e4aa9bb;hp=4fba7bb02fe2a58e94dea62f10cb62474eb9b4cd;hpb=1ca4785183b5af9a2a255bba0a28dfdae156470a;p=movit diff --git a/test_util.cpp b/test_util.cpp index 4fba7bb..afeb848 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -1,3 +1,4 @@ +#include "init.h" #include "test_util.h" #include "flat_input.h" #include "gtest/gtest.h" @@ -7,10 +8,15 @@ #include -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) +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), finalized(false) { - add_input(data, pixel_format, color_space, gamma_curve); + init_movit(); + + if (data != NULL) { + add_input(data, pixel_format, color_space, gamma_curve); + } glGenTextures(1, &texnum); check_error(); @@ -54,13 +60,28 @@ Input *EffectChainTester::add_input(const float *data, MovitPixelFormat pixel_fo return input; } +Input *EffectChainTester::add_input(const unsigned char *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, pixel_format, GL_UNSIGNED_BYTE, width, height); + input->set_pixel_data(data); + chain.add_input(input); + return input; +} + void EffectChainTester::run(float *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve) { - ImageFormat image_format; - image_format.color_space = color_space; - image_format.gamma_curve = gamma_curve; - chain.add_output(image_format); - chain.finalize(); + if (!finalized) { + ImageFormat image_format; + image_format.color_space = color_space; + image_format.gamma_curve = gamma_curve; + chain.add_output(image_format); + chain.finalize(); + finalized = true; + } chain.render_to_fbo(fbo, width, height);