X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=test_util.cpp;h=6beaba1423bda237d06d07d1c288850dc87b4f61;hp=4fba7bb02fe2a58e94dea62f10cb62474eb9b4cd;hb=62c039a63a8afdea4ec2da081d0173d7dd1d4578;hpb=1ca4785183b5af9a2a255bba0a28dfdae156470a diff --git a/test_util.cpp b/test_util.cpp index 4fba7bb..6beaba1 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -7,10 +7,13 @@ #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); + if (data != NULL) { + add_input(data, pixel_format, color_space, gamma_curve); + } glGenTextures(1, &texnum); check_error(); @@ -54,13 +57,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);