/* * Copyright (c) 2013 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// Ensure _reset() clears the error and _launch() can be called again.
return_value = 1;
EXPECT_NE(vpx_get_worker_interface()->reset(&worker_), 0);
EXPECT_FALSE(worker_.had_error);
vpx_get_worker_interface()->launch(&worker_);
EXPECT_NE(vpx_get_worker_interface()->sync(&worker_), 0);
EXPECT_FALSE(worker_.had_error);
}
TEST_P(VPxWorkerThreadTest, EndWithoutSync) { // Create a large number of threads to increase the chances of detecting a // race. Doing more work in the hook is no guarantee as any race would occur // post hook execution in the main thread loop driver. staticconstint kNumWorkers = 64;
VPxWorker workers[kNumWorkers]; int hook_data[kNumWorkers]; int return_value[kNumWorkers];
for (int n = 0; n < kNumWorkers; ++n) {
vpx_get_worker_interface()->init(&workers[n]);
return_value[n] = 1; // return successfully from the hook
workers[n].hook = ThreadHook;
workers[n].data1 = &hook_data[n];
workers[n].data2 = &return_value[n];
}
for (int i = 0; i < 2; ++i) { for (int n = 0; n < kNumWorkers; ++n) {
EXPECT_NE(vpx_get_worker_interface()->reset(&workers[n]), 0);
hook_data[n] = 0;
}
for (int n = 0; n < kNumWorkers; ++n) {
Run(&workers[n]);
}
for (int n = kNumWorkers - 1; n >= 0; --n) {
vpx_get_worker_interface()->end(&workers[n]);
}
}
}
TEST(VPxWorkerThreadTest, TestInterfaceAPI) {
EXPECT_EQ(0, vpx_set_worker_interface(nullptr));
EXPECT_NE(vpx_get_worker_interface(), nullptr); for (int i = 0; i < 6; ++i) {
VPxWorkerInterface winterface = *vpx_get_worker_interface(); switch (i) { default: case 0: winterface.init = nullptr; break; case 1: winterface.reset = nullptr; break; case 2: winterface.sync = nullptr; break; case 3: winterface.launch = nullptr; break; case 4: winterface.execute = nullptr; break; case 5: winterface.end = nullptr; break;
}
EXPECT_EQ(0, vpx_set_worker_interface(&winterface));
}
}
// ----------------------------------------------------------------------------- // Multi-threaded decode tests #if CONFIG_WEBM_IO // Decodes |filename| with |num_threads|. Returns the md5 of the decoded frames.
string DecodeFile(const string &filename, int num_threads) {
libvpx_test::WebMVideoSource video(filename);
video.Init();
// Get decompressed data while ((img = dec_iter.Next())) {
md5.Add(img);
}
} return string(md5.Get());
}
// Trivial serialized thread worker interface implementation. // Note any worker that requires synchronization between other workers will // hang. namespace impl { namespace {
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.