/* * Copyright (c) 2016, 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.
*/ #include <memory> #include <new> #include <tuple>
typedefbool (*ComputeMeanStddevFunc)(constunsignedchar *frame, int stride, int x, int y, double *mean, double *one_over_stddev); typedefdouble (*ComputeCorrFunc)(constunsignedchar *frame1, int stride1, int x1, int y1, double mean1, double one_over_stddev1, constunsignedchar *frame2, int stride2, int x2, int y2, double mean2, double one_over_stddev2);
using std::make_tuple; using std::tuple; typedef tuple<int, ComputeMeanStddevFunc, ComputeCorrFunc> CornerMatchParam;
class AV1CornerMatchTest : public ::testing::TestWithParam<CornerMatchParam> { public:
~AV1CornerMatchTest() override; void SetUp() override;
protected: void GenerateInput(uint8_t *input1, uint8_t *input2, int w, int h, int mode); void RunCheckOutput(); void RunSpeedTest();
ComputeMeanStddevFunc target_compute_mean_stddev_func;
ComputeCorrFunc target_compute_corr_func;
// Test the two extreme cases: // i) Random data, should have correlation close to 0 // ii) Linearly related data + noise, should have correlation close to 1 int mode = GET_PARAM(0);
GenerateInput(&input1[0], &input2[0], w, h, mode);
for (int i = 0; i < num_iters; ++i) { int x1 = MATCH_SZ_BY2 + rnd_.PseudoUniform(w + 1 - MATCH_SZ); int y1 = MATCH_SZ_BY2 + rnd_.PseudoUniform(h + 1 - MATCH_SZ); int x2 = MATCH_SZ_BY2 + rnd_.PseudoUniform(w + 1 - MATCH_SZ); int y2 = MATCH_SZ_BY2 + rnd_.PseudoUniform(h + 1 - MATCH_SZ);
// Run the correlation calculation even if one of the "valid" flags is // false, i.e. if one of the patches doesn't have enough variance. This is // safe because any potential division by 0 is caught in // aom_compute_mean_stddev(), and one_over_stddev is set to 0 instead. // This causes aom_compute_correlation() to return 0, without causing a // division by 0. constdouble c_corr = aom_compute_correlation_c(
input1.get(), w, x1, y1, c_mean1, c_one_over_stddev1, input2.get(), w,
x2, y2, c_mean2, c_one_over_stddev2); constdouble simd_corr = target_compute_corr_func(
input1.get(), w, x1, y1, c_mean1, c_one_over_stddev1, input2.get(), w,
x2, y2, c_mean2, c_one_over_stddev2);
// Test the two extreme cases: // i) Random data, should have correlation close to 0 // ii) Linearly related data + noise, should have correlation close to 1 int mode = GET_PARAM(0);
GenerateInput(&input1[0], &input2[0], w, h, mode);
// Time aom_compute_mean_stddev() double c_mean1, c_one_over_stddev1, c_mean2, c_one_over_stddev2;
aom_usec_timer_start(&ref_timer); for (int i = 0; i < num_iters; i++) {
aom_compute_mean_stddev_c(input1.get(), w, 0, 0, &c_mean1,
&c_one_over_stddev1);
aom_compute_mean_stddev_c(input2.get(), w, 0, 0, &c_mean2,
&c_one_over_stddev2);
}
aom_usec_timer_mark(&ref_timer); int elapsed_time_c = static_cast<int>(aom_usec_timer_elapsed(&ref_timer));
double simd_mean1, simd_one_over_stddev1, simd_mean2, simd_one_over_stddev2;
aom_usec_timer_start(&test_timer); for (int i = 0; i < num_iters; i++) {
target_compute_mean_stddev_func(input1.get(), w, 0, 0, &simd_mean1,
&simd_one_over_stddev1);
target_compute_mean_stddev_func(input2.get(), w, 0, 0, &simd_mean2,
&simd_one_over_stddev2);
}
aom_usec_timer_mark(&test_timer); int elapsed_time_simd = static_cast<int>(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.