/* * Copyright (c) 2023, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
using ComputeFlowAtPointFunc = void (*)(const uint8_t *src, const uint8_t *ref, int x, int y, int width, int height, int stride, double *u, double *v);
class ComputeFlowTest
: public ::testing::TestWithParam<ComputeFlowAtPointFunc> { public:
ComputeFlowTest()
: target_func_(GetParam()),
rnd_(libaom_test::ACMRandom::DeterministicSeed()) {}
// Pick a random value between -5 and 5. The range was chosen arbitrarily as // u and v can take any kind of value in practise, but it shouldn't change the // outcome of the tests. constdouble u_rand = (static_cast<double>(rnd_.Rand8()) / 255) * 10 - 5; double u_ref = u_rand; double u_test = u_rand;
// Pick a random point in the frame. If the frame is 352x288, that means we // can call the function on all values of x comprised between 8 and 344, and // all values of y comprised between 8 and 280. constint x = rnd_((kWidth - 8) - 8 + 1) + 8; constint y = rnd_((kHeight - 8) - 8 + 1) + 8;
aom_usec_timer ref_timer, test_timer;
aom_compute_flow_at_point_c(src, ref, x, y, kWidth, kHeight, kWidth, &u_ref,
&v_ref);
target_func_(src, ref, x, y, kWidth, kHeight, kWidth, &u_test, &v_test);
if (run_times > 1) {
aom_usec_timer_start(&ref_timer); for (int i = 0; i < run_times; ++i) {
aom_compute_flow_at_point_c(src, ref, x, y, kWidth, kHeight, kWidth,
&u_ref, &v_ref);
}
aom_usec_timer_mark(&ref_timer); constdouble elapsed_time_c = static_cast<double>(aom_usec_timer_elapsed(&ref_timer));
aom_usec_timer_start(&test_timer); for (int i = 0; i < run_times; ++i) {
target_func_(src, ref, x, y, kWidth, kHeight, kWidth, &u_test, &v_test);
}
aom_usec_timer_mark(&test_timer); constdouble elapsed_time_simd = static_cast<double>(aom_usec_timer_elapsed(&test_timer));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.