X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=deinterlace_effect_test.cpp;h=d2045eb478cd976d08f080f10fdce54637fc7de6;hp=24e11a2bbbc6c7b79383eae914737672d2377a99;hb=0ed2c7fe3876a49d1565e3425e5a491206ffe32d;hpb=65c6584f77bff0af0c8e38d1ac90298bcd55e9ac diff --git a/deinterlace_effect_test.cpp b/deinterlace_effect_test.cpp index 24e11a2..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 @@ -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