X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=deinterlace_effect_test.cpp;h=d2045eb478cd976d08f080f10fdce54637fc7de6;hp=31bd363024bb22ef3db70b51a1a29608b3b29abc;hb=0ed2c7fe3876a49d1565e3425e5a491206ffe32d;hpb=c06f1c4cc39bbebe13fe8e42a9278a55b5d0a216 diff --git a/deinterlace_effect_test.cpp b/deinterlace_effect_test.cpp index 31bd363..d2045eb 100644 --- a/deinterlace_effect_test.cpp +++ b/deinterlace_effect_test.cpp @@ -1,5 +1,8 @@ // Unit tests for DeinterlaceEffect. +#ifdef HAVE_BENCHMARK +#include +#endif #include #include @@ -74,7 +77,7 @@ TEST(DeinterlaceTest, VerticalInterpolation) { // Set previous and next fields to something so big that all the temporal checks // are effectively turned off. fill(neg_blowout_data, neg_blowout_data + width * height, -100.0f); - fill(neg_blowout_data, pos_blowout_data + width * height, 100.0f); + fill(pos_blowout_data, pos_blowout_data + width * height, 100.0f); EffectChainTester tester(NULL, width, height * 2); Effect *input1 = tester.add_input(neg_blowout_data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, height); @@ -193,4 +196,47 @@ TEST(DeinterlaceTest, FlickerBox) { } } +#ifdef HAVE_BENCHMARK +void BM_DeinterlaceEffect_Gray(benchmark::State &state) +{ + unsigned width = state.range(0), height = state.range(1); + unsigned field_height = height / 2; + + float *field1 = new float[width * field_height]; + float *field2 = new float[width * field_height]; + float *field3 = new float[width * field_height]; + float *field4 = new float[width * field_height]; + float *field5 = new float[width * field_height]; + float *out_data = new float[width * height]; + + for (unsigned i = 0; i < width * field_height; ++i) { + field1[i] = rand(); + field2[i] = rand(); + field3[i] = rand(); + field4[i] = rand(); + field5[i] = rand(); + } + + EffectChainTester tester(NULL, width, height); + Effect *input1 = tester.add_input(field1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, field_height); + Effect *input2 = tester.add_input(field2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, field_height); + Effect *input3 = tester.add_input(field3, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, field_height); + Effect *input4 = tester.add_input(field4, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, field_height); + Effect *input5 = tester.add_input(field5, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, field_height); + Effect *deinterlace_effect = tester.get_chain()->add_effect(new DeinterlaceEffect(), input1, input2, input3, input4, input5); + + ASSERT_TRUE(deinterlace_effect->set_int("current_field_position", 0)); + + tester.benchmark(state, out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR, OUTPUT_ALPHA_FORMAT_PREMULTIPLIED); + + delete[] field1; + delete[] field2; + delete[] field3; + delete[] field4; + delete[] field5; + delete[] out_data; +} +BENCHMARK(BM_DeinterlaceEffect_Gray)->Args({720, 576})->Args({1280, 720})->Args({1920, 1080})->UseRealTime()->Unit(benchmark::kMicrosecond); +#endif + } // namespace movit